#7346 - manualInvoice #3060

Merged
jgallego merged 2 commits from 7346-manualInvoice into dev 2024-10-03 05:45:10 +00:00
2 changed files with 12 additions and 6 deletions
Showing only changes of commit ee52c8b45f - Show all commits

View File

@ -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);

View File

@ -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');