From 474399b383cefa9c6d9a715082222cc4d8ada3b9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 25 Sep 2023 15:23:51 +0200 Subject: [PATCH] ref #5914 refactor --- db/changes/234001/00-transferInvoice.sql | 4 ---- db/dump/fixtures.sql | 6 ++++++ modules/ticket/back/methods/sale/clone.js | 13 +++---------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/db/changes/234001/00-transferInvoice.sql b/db/changes/234001/00-transferInvoice.sql index f0608327a..7a9890ae4 100644 --- a/db/changes/234001/00-transferInvoice.sql +++ b/db/changes/234001/00-transferInvoice.sql @@ -4,7 +4,3 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp ('CplusInvoiceType477', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), ('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), ('InvoiceOut', 'transferInvoice', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); - -INSERT INTO `vn`.`invoiceCorrectionType` (description) - VALUES - ('Error en el cálculo del IVA') \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 1d115af0d..15d78adff 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2974,3 +2974,9 @@ INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EU (4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0), (5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0), (6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0); + +INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`) + VALUES + (1, 'Error en el cálculo del IVA'), + (2, 'Error en el detalle de las ventas'), + (3, 'Error en los datos del cliente'); \ No newline at end of file diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index 7ce7675da..84f0e02f8 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -44,7 +44,7 @@ module.exports = Self => { } for (const sale of sales) { - const refundTicketId = await getTicketRefundId(group, sale.ticketFk, refundTickets, mappedTickets); + const refundTicketId = mappedTickets.get(sale.ticketFk); const createdSale = await models.Sale.create({ ticketFk: refundTicketId, @@ -62,14 +62,14 @@ module.exports = Self => { await models.SaleComponent.create(components, myOptions); } - if (servicesIds && servicesIds.length > 0) { + if (servicesIds && servicesIds.length) { const servicesFilter = { where: {id: {inq: servicesIds}} }; const services = await models.TicketService.find(servicesFilter, myOptions); for (const service of services) { - const refundTicketId = await getTicketRefundId(group, service.ticketFk, refundTickets, mappedTickets); + const refundTicketId = mappedTickets.get(service.ticketFk); await models.TicketService.create({ description: service.description, @@ -113,11 +113,4 @@ module.exports = Self => { refundTickets.push(refundTicket); } - - async function getTicketRefundId(group, ticketId, refundTickets, mappedTickets) { - if (group) { - const [firstRefundTicket] = refundTickets; - return firstRefundTicket.id; - } else return mappedTickets.get(ticketId); - } };