This commit is contained in:
parent
43df98598c
commit
ee52c8b45f
|
@ -39,8 +39,8 @@ BEGIN
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
AND t.companyFk = vCompanyFk
|
AND t.companyFk = vCompanyFk
|
||||||
AND t.shipped BETWEEN
|
AND t.shipped BETWEEN
|
||||||
util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR) AND
|
util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR)
|
||||||
util.dayend(vMaxShipped);
|
AND util.dayend(vMaxShipped);
|
||||||
|
|
||||||
CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId);
|
CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
arg: 'addressFk',
|
arg: 'addressFk',
|
||||||
type: 'any',
|
type: 'any',
|
||||||
description: 'The consignatary address id'
|
description: 'The address id'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'ticketFk',
|
arg: 'ticketFk',
|
||||||
|
@ -72,8 +72,12 @@ module.exports = Self => {
|
||||||
let query;
|
let query;
|
||||||
try {
|
try {
|
||||||
if (ticketFk) {
|
if (ticketFk) {
|
||||||
const ticket = await models.Ticket.findById(ticketFk, null, myOptions);
|
const ticket = await models.Ticket.findById(ticketFk, {
|
||||||
const company = await models.Company.findById(ticket.companyFk, null, myOptions);
|
fields: ['clientFk', 'companyFk', 'shipped', 'refFk', 'totalWithVat']
|
||||||
|
}, myOptions);
|
||||||
|
const company = await models.Company.findById(ticket.companyFk, {
|
||||||
|
fields: ['code']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
clientFk = ticket.clientFk;
|
clientFk = ticket.clientFk;
|
||||||
maxShipped = ticket.shipped;
|
maxShipped = ticket.shipped;
|
||||||
|
@ -93,7 +97,9 @@ module.exports = Self => {
|
||||||
throw new UserError(`Max shipped required`);
|
throw new UserError(`Max shipped required`);
|
||||||
|
|
||||||
if (addressFk) {
|
if (addressFk) {
|
||||||
const address = await models.Address.findById(addressFk, null, myOptions);
|
const address = await models.Address.findById(addressFk, {
|
||||||
|
fields: ['clientFk']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
if (clientFk && clientFk !== address.clientFk)
|
if (clientFk && clientFk !== address.clientFk)
|
||||||
throw new UserError('The provided clientFk does not match');
|
throw new UserError('The provided clientFk does not match');
|
||||||
|
|
Loading…
Reference in New Issue