#7197 filter by correcting & supplierActivity #2641
|
@ -82,7 +82,11 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'correctedFk',
|
||||
type: 'number',
|
||||
description: 'The corrected invoice',
|
||||
description: 'The rectified invoice',
|
||||
},
|
||||
{
|
||||
arg: 'correctingFk',
|
||||
type: 'Boolean',
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -111,6 +115,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
let correctings;
|
||||
let correcteds;
|
||||
if (args.correctedFk) {
|
||||
correctings = await models.InvoiceInCorrection.find({
|
||||
fields: ['correctingFk'],
|
||||
|
@ -118,6 +123,9 @@ module.exports = Self => {
|
|||
});
|
||||
}
|
||||
|
||||
if (args.correctingFk || args.correctingFk === false)
|
||||
correcteds = await models.InvoiceInCorrection.find();
|
||||
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
|
@ -141,6 +149,10 @@ module.exports = Self => {
|
|||
return {[`ii.${param}`]: value};
|
||||
case 'awbCode':
|
||||
return {'sub.code': value};
|
||||
case 'correctingFk':
|
||||
return args.correctingFk
|
||||
? {'ii.id': {inq: correcteds.map(x => x.correctingFk)}}
|
||||
: {'ii.id': {nin: correcteds.map(x => x.correctingFk)}};
|
||||
case 'correctedFk':
|
||||
return {'ii.id': {inq: correctings.map(x => x.correctingFk)}};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
alterna entre solo rectificativas y las no rectificativas.