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