3863-feat(client.defaulter&claim): change socialName to name #933

Merged
joan merged 2 commits from 3863-client_name into dev 2022-04-08 07:13:13 +00:00
11 changed files with 30 additions and 39 deletions

View File

@ -28,7 +28,7 @@ describe('Client defaulter path', () => {
const salesPersonName =
await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText');
expect(clientName).toEqual('Batman');
expect(clientName).toEqual('Ororo Munroe');
expect(salesPersonName).toEqual('salesPersonNick');
});

View File

@ -27,7 +27,7 @@ module.exports = Self => {
http: {source: 'query'}
},
{
arg: 'client',
arg: 'clientName',
type: 'string',
description: 'The worker name',
http: {source: 'query'}
@ -94,11 +94,11 @@ module.exports = Self => {
? {'cl.id': value}
: {
or: [
{'cl.socialName': {like: `%${value}%`}}
{'cl.clientName': {like: `%${value}%`}}
]
};
case 'client':
return {'cl.socialName': {like: `%${value}%`}};
case 'clientName':
return {'cl.clientName': {like: `%${value}%`}};
case 'clientFk':
return {'cl.clientFk': value};
case 'id':
@ -128,7 +128,7 @@ module.exports = Self => {
SELECT
cl.id,
cl.clientFk,
c.socialName,
c.name AS clientName,
cl.workerFk,
u.name AS workerName,
cs.description,

View File

@ -25,7 +25,7 @@ describe('claim filter()', () => {
try {
const options = {transaction: tx};
const result = await app.models.Claim.filter({args: {filter: {}, search: 'Iron man'}}, null, options);
const result = await app.models.Claim.filter({args: {filter: {}, search: 'Tony Stark'}}, null, options);
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(4);

View File

@ -10,16 +10,16 @@
<table>
<thead>
<tr>
<th field="id" shrink>
<th field="clientFk" shrink>
<span translate>Id</span>
</th>
<th field="clientFk">
<th field="clientName">
<span translate>Client</span>
</th>
<th field="created" center shrink-date>
<span translate>Created</span>
</th>
<th field="salesPersonFk">
<th field="workerFk">
<span translate>Worker</span>
</th>
<th field="claimStateFk">
@ -40,7 +40,7 @@
<span
vn-click-stop="clientDescriptor.show($event, claim.clientFk)"
class="link">
{{::claim.socialName}}
{{::claim.clientName}}
</span>
</td>
<td center shrink-date>{{::claim.created | date:'dd/MM/yyyy'}}</td>

View File

@ -11,11 +11,11 @@ class Controller extends Section {
},
columns: [
{
field: 'clientFk',
field: 'clientName',
autocomplete: {
url: 'Clients',
showField: 'socialName',
valueField: 'socialName'
showField: 'name',
valueField: 'name'
}
},
{
@ -46,21 +46,12 @@ class Controller extends Section {
exprBuilder(param, value) {
switch (param) {
case 'clientName':
return {'cl.clientName': {like: `%${value}%`}};
case 'clientFk':
return {['cl.socialName']: value};
case 'id':
case 'claimStateFk':
case 'priority':
case 'workerFk':
return {[`cl.${param}`]: value};
case 'salesPersonFk':
case 'attenderFk':
return {'cl.workerFk': value};
case 'created':
value.setHours(0, 0, 0, 0);
to = new Date(value);
to.setHours(23, 59, 59, 999);
return {'cl.created': {between: [value, to]}};
}
}

View File

@ -18,7 +18,7 @@
<vn-textfield
vn-one
label="Client"
ng-model="filter.client">
ng-model="filter.clientName">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>

View File

@ -56,7 +56,7 @@ module.exports = Self => {
FROM (
SELECT
DISTINCT c.id clientFk,
c.socialName clientName,
c.name clientName,
c.salesPersonFk,
u.nickname salesPersonName,
d.amount,

View File

@ -47,12 +47,12 @@ describe('defaulter filter()', () => {
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'spider'}};
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'Petter Parker'}};
const result = await models.Defaulter.filter(ctx, null, options);
const firstRow = result[0];
expect(firstRow.clientName).toEqual('Spider man');
expect(firstRow.clientName).toEqual('Petter Parker');
await tx.rollback();
} catch (e) {

View File

@ -49,7 +49,7 @@
model="model">
</vn-multi-check>
</th>
<th field="clientName">
<th field="clientFk">
<span translate>Client</span>
</th>
<th field="salesPersonFk">

View File

@ -13,11 +13,11 @@ export default class Controller extends Section {
},
columns: [
{
field: 'clientName',
field: 'clientFk',
autocomplete: {
url: 'Clients',
showField: 'socialName',
valueField: 'socialName'
showField: 'name',
valueField: 'id'
}
},
{
@ -114,7 +114,7 @@ export default class Controller extends Section {
switch (param) {
case 'creditInsurance':
case 'amount':
case 'clientName':
case 'clientFk':
case 'workerFk':
case 'salesPersonFk':
return {[`d.${param}`]: value};

View File

@ -104,15 +104,15 @@ describe('client defaulter', () => {
describe('exprBuilder()', () => {
it('should search by sales person', () => {
let expr = controller.exprBuilder('salesPersonFk', '5');
const expr = controller.exprBuilder('salesPersonFk', '5');
expect(expr).toEqual({'d.salesPersonFk': '5'});
});
it('should search by client name', () => {
let expr = controller.exprBuilder('clientName', '1foo');
it('should search by client', () => {
const expr = controller.exprBuilder('clientFk', '5');
expect(expr).toEqual({'d.clientName': '1foo'});
expect(expr).toEqual({'d.clientFk': '5'});
});
});
});