3389-item and entry/latest-buys search-panels add filter supplier #796
|
@ -39,6 +39,11 @@ module.exports = Self => {
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
description: 'The buyer of the item',
|
description: 'The buyer of the item',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'supplierFk',
|
||||||
|
type: 'integer',
|
||||||
|
description: 'The supplier of the item',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'active',
|
arg: 'active',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -99,6 +104,8 @@ module.exports = Self => {
|
||||||
return {'ic.id': value};
|
return {'ic.id': value};
|
||||||
case 'salesPersonFk':
|
case 'salesPersonFk':
|
||||||
return {'it.workerFk': value};
|
return {'it.workerFk': value};
|
||||||
|
case 'supplierFk':
|
||||||
|
return {'s.id': value};
|
||||||
case 'code':
|
case 'code':
|
||||||
return {'it.code': value};
|
return {'it.code': value};
|
||||||
case 'active':
|
case 'active':
|
||||||
|
@ -172,7 +179,9 @@ module.exports = Self => {
|
||||||
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
LEFT JOIN itemType t ON t.id = i.typeFk
|
LEFT JOIN itemType t ON t.id = i.typeFk
|
||||||
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
||||||
LEFT JOIN origin ori ON ori.id = i.originFk`
|
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||||
|
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(CURDATE(),INTERVAL 1 YEAR)
|
||||||
|
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ctx.args.tags) {
|
if (ctx.args.tags) {
|
||||||
|
|
|
@ -136,5 +136,17 @@ describe('Buy latests buys filter()', () => {
|
||||||
|
|
||||||
expect(results.length).toBe(1);
|
expect(results.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return results matching "supplierFk"', async() => {
|
||||||
|
let ctx = {
|
||||||
|
args: {
|
||||||
|
supplierFk: 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let results = await app.models.Buy.latestBuysFilter(ctx);
|
||||||
|
|
||||||
|
expect(results.length).toBe(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,17 @@
|
||||||
where="{role: {inq: ['logistic', 'buyer']}}"
|
where="{role: {inq: ['logistic', 'buyer']}}"
|
||||||
label="Buyer">
|
label="Buyer">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Supplier"
|
||||||
|
ng-model="filter.supplierFk"
|
||||||
|
url="Suppliers"
|
||||||
|
fields="['name','nickname']"
|
||||||
|
search-function="{or: [{nickname: {like: '%'+ $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id">
|
||||||
|
<tpl-item>{{name}}: {{nickname}}</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-check
|
<vn-check
|
||||||
|
|
|
@ -48,6 +48,11 @@ module.exports = Self => {
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
description: 'The buyer of the item',
|
description: 'The buyer of the item',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'supplierFk',
|
||||||
|
type: 'integer',
|
||||||
|
description: 'The supplier of the item',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'description',
|
arg: 'description',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -119,6 +124,8 @@ module.exports = Self => {
|
||||||
return {'ic.id': value};
|
return {'ic.id': value};
|
||||||
case 'buyerFk':
|
case 'buyerFk':
|
||||||
return {'it.workerFk': value};
|
return {'it.workerFk': value};
|
||||||
|
case 'supplierFk':
|
||||||
|
return {'s.id': value};
|
||||||
case 'origin':
|
case 'origin':
|
||||||
return {'ori.code': value};
|
return {'ori.code': value};
|
||||||
case 'intrastat':
|
case 'intrastat':
|
||||||
|
@ -169,7 +176,9 @@ module.exports = Self => {
|
||||||
LEFT JOIN producer pr ON pr.id = i.producerFk
|
LEFT JOIN producer pr ON pr.id = i.producerFk
|
||||||
LEFT JOIN origin ori ON ori.id = i.originFk
|
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||||
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = it.warehouseFk
|
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = it.warehouseFk
|
||||||
LEFT JOIN vn.buy b ON b.id = lb.buy_id`
|
LEFT JOIN buy b ON b.id = lb.buy_id
|
||||||
|
LEFT JOIN entry e ON e.id = b.entryFk
|
||||||
|
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ctx.args.tags) {
|
if (ctx.args.tags) {
|
||||||
|
|
|
@ -79,4 +79,44 @@ describe('item filter()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return 2 result filtering by buyerFk', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const filter = {};
|
||||||
|
const ctx = {args: {filter: filter, buyerFk: 16}};
|
||||||
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(2);
|
||||||
|
expect(result[0].id).toEqual(16);
|
||||||
|
expect(result[1].id).toEqual(71);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return 2 result filtering by supplierFk', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const filter = {};
|
||||||
|
const ctx = {args: {filter: filter, supplierFk: 1}};
|
||||||
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(2);
|
||||||
|
expect(result[0].id).toEqual(1);
|
||||||
|
expect(result[1].id).toEqual(3);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,10 +43,21 @@
|
||||||
ng-model="filter.buyerFk"
|
ng-model="filter.buyerFk"
|
||||||
url="Items/activeBuyers"
|
url="Items/activeBuyers"
|
||||||
show-field="nickname"
|
show-field="nickname"
|
||||||
search-function="{firstName: $search}"
|
search-function="{nickname: {like: '%'+ $search +'%'}}"
|
||||||
value-field="workerFk"
|
value-field="workerFk"
|
||||||
label="Buyer">
|
label="Buyer">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Supplier"
|
||||||
|
ng-model="filter.supplierFk"
|
||||||
|
url="Suppliers"
|
||||||
|
fields="['name','nickname']"
|
||||||
|
search-function="{or: [{nickname: {like: '%'+ $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id">
|
||||||
|
<tpl-item>{{name}}: {{nickname}}</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="vn-pt-sm">
|
<vn-horizontal class="vn-pt-sm">
|
||||||
<vn-one class="text-subtitle1" translate>
|
<vn-one class="text-subtitle1" translate>
|
||||||
|
|
Loading…
Reference in New Issue