7806_devToTest_2332 #2801
|
@ -82,7 +82,15 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
arg: 'correctedFk',
|
arg: 'correctedFk',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The corrected invoice',
|
description: 'The rectified invoice',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'correctingFk',
|
||||||
|
type: 'Boolean',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'supplierActivityFk',
|
||||||
|
type: 'string',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -111,6 +119,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let correctings;
|
let correctings;
|
||||||
|
let correcteds;
|
||||||
if (args.correctedFk) {
|
if (args.correctedFk) {
|
||||||
correctings = await models.InvoiceInCorrection.find({
|
correctings = await models.InvoiceInCorrection.find({
|
||||||
fields: ['correctingFk'],
|
fields: ['correctingFk'],
|
||||||
|
@ -118,6 +127,9 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.correctingFk || args.correctingFk === false)
|
||||||
|
correcteds = await models.InvoiceInCorrection.find();
|
||||||
|
|
||||||
const where = buildFilter(ctx.args, (param, value) => {
|
const where = buildFilter(ctx.args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'search':
|
case 'search':
|
||||||
|
@ -141,8 +153,14 @@ module.exports = Self => {
|
||||||
return {[`ii.${param}`]: value};
|
return {[`ii.${param}`]: value};
|
||||||
case 'awbCode':
|
case 'awbCode':
|
||||||
return {'sub.code': value};
|
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':
|
case 'correctedFk':
|
||||||
return {'ii.id': {inq: correctings.map(x => x.correctingFk)}};
|
return {'ii.id': {inq: correctings.map(x => x.correctingFk)}};
|
||||||
|
case 'supplierActivityFk':
|
||||||
|
return {'s.supplierActivityFk': value};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue