fix: refs #7346 findByid con fields
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javi Gallego 2024-10-02 15:34:53 +02:00
parent 43df98598c
commit ee52c8b45f
2 changed files with 12 additions and 6 deletions

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