From 618baaf6040b40a45beabaf86a7aada1778b2a78 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 11 Jul 2024 08:37:08 +0200 Subject: [PATCH] usa campo factura multipe --- db/routines/vn/procedures/invoiceOut_new.sql | 2 +- .../11142-aquaGerbera/00-invoiceOutSerialColumn.sql | 2 ++ .../11142-aquaGerbera/01-invoiceOutSerialUpdate.sql | 3 +++ .../back/methods/invoiceOut/clientsToInvoice.js | 2 +- .../invoiceOut/back/methods/invoiceOut/invoiceClient.js | 8 ++++++-- modules/invoiceOut/back/models/invoice-out-serial.json | 5 ++++- 6 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql create mode 100644 db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql index 42c3f99da..610e05cb4 100644 --- a/db/routines/vn/procedures/invoiceOut_new.sql +++ b/db/routines/vn/procedures/invoiceOut_new.sql @@ -97,7 +97,7 @@ BEGIN AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase()) THEN - -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial + -- el trigger añade el siguiente ref correspondiente a la vSerial INSERT INTO invoiceOut( ref, serial, diff --git a/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql new file mode 100644 index 000000000..db476c4a5 --- /dev/null +++ b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutSerial + MODIFY COLUMN `type` enum('global','quick','multiple') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; diff --git a/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql new file mode 100644 index 000000000..581a6f5f3 --- /dev/null +++ b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql @@ -0,0 +1,3 @@ +UPDATE vn.invoiceOutSerial + SET `type`='multiple' + WHERE `description` LIKE '%multiple%'; diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index 63b00fe38..5526d214a 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -75,7 +75,7 @@ module.exports = Self => { AND c.isTaxDataChecked AND c.isActive AND NOT t.isDeleted - GROUP BY c.id, IF(c.hasToInvoiceByAddress, a.id, TRUE) + GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id) HAVING SUM(t.totalWithVat) > 0;`; const addresses = await Self.rawSql(query, [ diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index 530b02353..ef8a26efc 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -28,6 +28,11 @@ module.exports = Self => { type: 'number', description: 'The company id to invoice', required: true + }, { + arg: 'serialType', + type: 'string', + description: 'Type of serial', + required: true } ], returns: { @@ -74,10 +79,9 @@ module.exports = Self => { ], options); } - const invoiceType = 'G'; const invoiceId = await models.Ticket.makeInvoice( ctx, - invoiceType, + serialType, args.companyFk, args.invoiceDate, null, diff --git a/modules/invoiceOut/back/models/invoice-out-serial.json b/modules/invoiceOut/back/models/invoice-out-serial.json index 912269fd7..30e1f1b39 100644 --- a/modules/invoiceOut/back/models/invoice-out-serial.json +++ b/modules/invoiceOut/back/models/invoice-out-serial.json @@ -20,6 +20,9 @@ }, "isCEE": { "type": "boolean" + }, + "type": { + "type": "string" } }, "relations": { @@ -35,4 +38,4 @@ "principalId": "$everyone", "permission": "ALLOW" }] -} \ No newline at end of file +}