refs #6925 fix(invoice): incoterms error

This commit is contained in:
Alex Moreno 2024-02-26 11:50:46 +01:00
parent e971070f2f
commit b1a8fcf968
6 changed files with 19 additions and 12 deletions

View File

@ -15,10 +15,11 @@ BEGIN
JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.id = ts.alertLevel
WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered')
WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered'))
AND t.id = vTicketFk
AND t.refFk IS NULL
GROUP BY t.id);
GROUP BY t.id
);
CALL ticket_close();

View File

@ -344,5 +344,6 @@
"CountryFK cannot be empty": "El país no puede estar vacío",
"Cmr file does not exist": "El archivo del cmr no existe",
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
"No tickets to invoice": "No hay tickets para facturar"
"No tickets to invoice": "No hay tickets para facturar",
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas"
}

View File

@ -1,7 +1,7 @@
module.exports = () => {
Date.vnUTC = (env = process.env.NODE_ENV) => {
if (!env || env === 'development')
return new Date(Date.UTC(2001, 0, 1, 11));
// if (!env || env === 'development')
// return new Date(Date.UTC(2001, 0, 1, 11));
return new Date();
};

View File

@ -30,7 +30,7 @@ module.exports = Self => {
// Prevent closure for current day
if (toDate >= todayMinDate && toDate <= todayMaxDate)
throw new UserError('You cannot close tickets for today');
console.log(toDate, toDate);
const tickets = await Self.rawSql(`
SELECT t.id,
t.clientFk,
@ -57,6 +57,7 @@ module.exports = Self => {
AND t.refFk IS NULL
GROUP BY t.id
`, [toDate, toDate]);
console.log('tickets: ', tickets);
await closure(ctx, Self, tickets);

View File

@ -15,11 +15,12 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
const [invoiceOut] = await Self.rawSql(`
SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued
FROM ticket t
JOIN invoiceOut io ON io.ref = t.refFk
JOIN company cny ON cny.id = io.companyFk
WHERE t.id = ?
`, [ticket.id]);
FROM ticket t
JOIN invoiceOut io ON io.ref = t.refFk
JOIN company cny ON cny.id = io.companyFk
WHERE t.id = ?
`, [ticket.id]);
console.log('invoiceOut: ', invoiceOut);
const mailOptions = {
overrideAttachments: true,

View File

@ -1,4 +1,5 @@
const vnReport = require('../../../core/mixins/vn-report.js');
const UserError = require('vn-loopback/util/user-error');
module.exports = {
name: 'invoice-incoterms',
@ -7,7 +8,9 @@ module.exports = {
this.invoice = await this.findOneFromDef('invoice', [this.reference]);
this.checkMainEntity(this.invoice);
this.client = await this.findOneFromDef('client', [this.reference]);
this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
this.incoterms =
await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
if (!this.incoterms) throw new UserError(`The client should be informed of the incoterms`);
},
props: {
reference: {