From a3052c1cf98c325ceee9d2437e3d3bdc6f3ee398 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 1 Mar 2024 15:05:12 +0100 Subject: [PATCH] refs #6925 hotFix(invoice) parenthesis & handle incoterms error --- db/routines/vn/procedures/ticket_closeByTicket.sql | 2 +- loopback/locale/es.json | 5 +++-- .../reports/invoice-incoterms/invoice-incoterms.js | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/ticket_closeByTicket.sql b/db/routines/vn/procedures/ticket_closeByTicket.sql index 93772225b..6e32a3e76 100644 --- a/db/routines/vn/procedures/ticket_closeByTicket.sql +++ b/db/routines/vn/procedures/ticket_closeByTicket.sql @@ -15,7 +15,7 @@ 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); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index b14358e85..49283e633 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -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 newline at end of file + "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" +} diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js index 9cc2600af..cfe29169b 100755 --- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js @@ -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,10 @@ 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 address of the customer must have information about Incoterms and Customs Agent`); }, props: { reference: {