From 50155cea8d5e3669b5293764f7666f0223a35c9c Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 28 Jul 2023 15:21:43 +0200 Subject: [PATCH 01/32] refs #5914 WIP transfer invoiceOut --- .../233201/00-transferInvoiceOutACL.sql | 6 + db/dump/fixtures.sql | 13 ++ loopback/locale/es.json | 3 +- .../methods/invoiceOut/transferInvoiceOut.js | 81 +++++++++++ modules/invoiceOut/back/model-config.json | 12 ++ .../back/models/cplus-correcting-type.json | 19 +++ .../back/models/cplus-rectification-type.json | 19 +++ .../back/models/invoice-correction-type.json | 19 +++ modules/invoiceOut/back/models/invoice-out.js | 1 + .../back/models/invoiceCorrection.json | 28 ++++ .../front/descriptor-menu/index.html | 89 ++++++++++++ .../invoiceOut/front/descriptor-menu/index.js | 13 ++ .../front/descriptor-menu/locale/en.yml | 2 + .../front/descriptor-menu/locale/es.yml | 2 + modules/ticket/back/methods/sale/clone.js | 76 ++++++++++ .../back/methods/sale/createTicketRefund.js | 25 ++++ modules/ticket/back/methods/sale/refund.js | 137 +++++++++++++++++- 17 files changed, 543 insertions(+), 2 deletions(-) create mode 100644 db/changes/233201/00-transferInvoiceOutACL.sql create mode 100644 modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js create mode 100644 modules/invoiceOut/back/models/cplus-correcting-type.json create mode 100644 modules/invoiceOut/back/models/cplus-rectification-type.json create mode 100644 modules/invoiceOut/back/models/invoice-correction-type.json create mode 100644 modules/invoiceOut/back/models/invoiceCorrection.json create mode 100644 modules/ticket/back/methods/sale/clone.js create mode 100644 modules/ticket/back/methods/sale/createTicketRefund.js diff --git a/db/changes/233201/00-transferInvoiceOutACL.sql b/db/changes/233201/00-transferInvoiceOutACL.sql new file mode 100644 index 000000000..b549e52a8 --- /dev/null +++ b/db/changes/233201/00-transferInvoiceOutACL.sql @@ -0,0 +1,6 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('CplusRectificationType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('CplusCorrectingType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('InvoiceOut', 'transferInvoiceOut', 'WRITE', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index eaa00a3de..0a17e2e42 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2958,3 +2958,16 @@ INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `t INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`) VALUES (1, 0, 0, 'marvel.com'); + +INSERT INTO `vn`.`cplusCorrectingType` (`description`) + VALUES + ('Embalajes'), + ('Anulación'), + ('Impagado'), + ('Moroso'); + +INSERT INTO `vn`.`invoiceCorrectionType` (`description`) + VALUES + ('Error en el cálculo del IVA'), + ('Error en el detalle de las ventas'), + ('Error en los datos del cliente'); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index ac62d62e1..3439adcde 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -311,5 +311,6 @@ "You don't have enough privileges.": "No tienes suficientes permisos.", "This ticket is locked.": "Este ticket está bloqueado.", "This ticket is not editable.": "Este ticket no es editable.", - "The ticket doesn't exist.": "No existe el ticket." + "The ticket doesn't exist.": "No existe el ticket.", + "There are missing fields.": "There are missing fields." } \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js new file mode 100644 index 000000000..b50e4b1a7 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js @@ -0,0 +1,81 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('transferInvoiceOut', { + description: 'Transfer an invoice out to another client', + accessType: 'WRITE', + accepts: [ + { + arg: 'data', + type: 'Object', + required: true + } + ], + returns: { + type: 'boolean', + root: true + }, + http: { + path: '/transferInvoice', + verb: 'post' + } + }); + + Self.transferInvoiceOut = async(ctx, params, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + try { + const {ref, newClientFk, cplusRectificationId, cplusCorrectingTypeId, invoiceCorrectionTypeId} = params; + if (!ref || !newClientFk || !cplusRectificationId || !cplusCorrectingTypeId || !invoiceCorrectionTypeId) + throw new UserError(`There are missing fields.`); + + const filter = {where: {refFk: ref}}; + const tickets = await models.Ticket.find(filter, myOptions); + const ticketsIds = tickets.map(ticket => ticket.id); + const refundTicket = await models.Ticket.refund(ctx, ticketsIds, null, myOptions); + // Clonar tickets + const refundAgencyMode = await models.AgencyMode.findOne({ + include: { + relation: 'zones', + scope: { + limit: 1, + field: ['id', 'name'] + } + }, + where: {code: 'refund'} + }, myOptions); + const refoundZoneId = refundAgencyMode.zones()[0].id; + const services = await models.TicketService.find(filter, myOptions); + const servicesIds = services.map(service => service.id); + const salesFilter = { + where: {id: {inq: salesIds}}, + include: { + relation: 'components', + scope: { + fields: ['saleFk', 'componentFk', 'value'] + } + } + }; + const sales = await models.Sale.find(salesFilter, myOptions); + // Actualizar cliente + + // Invoice Ticket - Factura rápida ?? + + // Insert InvoiceCorrection + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + return true; + }; +}; diff --git a/modules/invoiceOut/back/model-config.json b/modules/invoiceOut/back/model-config.json index 9e8b119ab..995ea976b 100644 --- a/modules/invoiceOut/back/model-config.json +++ b/modules/invoiceOut/back/model-config.json @@ -31,5 +31,17 @@ }, "ZipConfig": { "dataSource": "vn" + }, + "CplusRectificationType": { + "dataSource": "vn" + }, + "CplusCorrectingType": { + "dataSource": "vn" + }, + "InvoiceCorrectionType": { + "dataSource": "vn" + }, + "InvoiceCorrection": { + "dataSource": "vn" } } diff --git a/modules/invoiceOut/back/models/cplus-correcting-type.json b/modules/invoiceOut/back/models/cplus-correcting-type.json new file mode 100644 index 000000000..660f60008 --- /dev/null +++ b/modules/invoiceOut/back/models/cplus-correcting-type.json @@ -0,0 +1,19 @@ +{ + "name": "CplusCorrectingType", + "base": "VnModel", + "options": { + "mysql": { + "table": "cplusCorrectingType" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "description": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/invoiceOut/back/models/cplus-rectification-type.json b/modules/invoiceOut/back/models/cplus-rectification-type.json new file mode 100644 index 000000000..e7bfb957f --- /dev/null +++ b/modules/invoiceOut/back/models/cplus-rectification-type.json @@ -0,0 +1,19 @@ +{ + "name": "CplusRectificationType", + "base": "VnModel", + "options": { + "mysql": { + "table": "cplusRectificationType" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "description": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/invoiceOut/back/models/invoice-correction-type.json b/modules/invoiceOut/back/models/invoice-correction-type.json new file mode 100644 index 000000000..ad3f034ea --- /dev/null +++ b/modules/invoiceOut/back/models/invoice-correction-type.json @@ -0,0 +1,19 @@ +{ + "name": "InvoiceCorrectionType", + "base": "VnModel", + "options": { + "mysql": { + "table": "invoiceCorrectionType" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "description": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index d3aaf3b3d..0bb31ce12 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -23,6 +23,7 @@ module.exports = Self => { require('../methods/invoiceOut/getInvoiceDate')(Self); require('../methods/invoiceOut/negativeBases')(Self); require('../methods/invoiceOut/negativeBasesCsv')(Self); + require('../methods/invoiceOut/transferInvoiceOut')(Self); Self.filePath = async function(id, options) { const fields = ['ref', 'issued']; diff --git a/modules/invoiceOut/back/models/invoiceCorrection.json b/modules/invoiceOut/back/models/invoiceCorrection.json new file mode 100644 index 000000000..48bd172a6 --- /dev/null +++ b/modules/invoiceOut/back/models/invoiceCorrection.json @@ -0,0 +1,28 @@ +{ + "name": "InvoiceCorrection", + "base": "VnModel", + "options": { + "mysql": { + "table": "invoiceCorrection" + } + }, + "properties": { + "correctingFk": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "correctedFk": { + "type": "number" + }, + "cplusRectificationTypeFk": { + "type": "number" + }, + "cplusInvoiceType477Fk": { + "type": "number" + }, + "invoiceCorrectionTypeFk": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 106f8e3cc..d6eaa1cc7 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -1,3 +1,19 @@ + + + + + + + + Transfer invoice to... + Confirm + + + + + + + #{{id}} - {{::name}} + + + + + {{::description}} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 38c3c9434..0b43b73a7 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -125,6 +125,19 @@ class Controller extends Section { this.$state.go('ticket.card.sale', {id: refundTicket.id}); }); } + + transferInvoice() { + const params = { + data: { + ref: this.invoiceOut.ref, + newClientFk: this.invoiceOut.client.id, + cplusRectificationId: this.cplusRectificationType, + cplusCorrectingTypeId: this.cplusCorrectingType, + invoiceCorrectionTypeId: this.invoiceCorrectionType + } + }; + this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => console.log(res.data)); + } } Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; diff --git a/modules/invoiceOut/front/descriptor-menu/locale/en.yml b/modules/invoiceOut/front/descriptor-menu/locale/en.yml index d299155d7..8fad5f25e 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/en.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/en.yml @@ -1 +1,3 @@ The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}" +Transfer invoice to...: Transfer invoice to... +Cplus Type: Cplus Type \ No newline at end of file diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml index 393efd58c..0f74b5fec 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml @@ -21,3 +21,5 @@ The invoice PDF document has been regenerated: El documento PDF de la factura ha The email can't be empty: El correo no puede estar vacío The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}" Refund...: Abono... +Transfer invoice to...: Transferir factura a... +Cplus Type: Cplus Tipo diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js new file mode 100644 index 000000000..1d69ca158 --- /dev/null +++ b/modules/ticket/back/methods/sale/clone.js @@ -0,0 +1,76 @@ +module.exports = async function clone(ctx, Self, sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, isRefund, myOptions) { + const models = Self.app.models; + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; + const [firstTicketId] = ticketsIds; + + const now = Date.vnNew(); + let refundTickets = []; + let refundTicket; + + if (!group) { + for (const ticketId of ticketsIds) { + refundTicket = await createTicketRefund( + ticketId, + now, + refundAgencyMode, + refoundZoneId, + null, + myOptions + ); + refundTickets.push(refundTicket); + } + } else { + refundTicket = await createTicketRefund( + firstTicketId, + now, + refundAgencyMode, + refoundZoneId, + withWarehouse, + myOptions + ); + } + + for (const sale of sales) { + const createdSale = await models.Sale.create({ + ticketFk: (group) ? refundTicket.id : sale.ticketFk, + itemFk: sale.itemFk, + quantity: (isRefund) ? - sale.quantity : sale.quantity, + concept: sale.concept, + price: sale.price, + discount: sale.discount, + }, myOptions); + + const components = sale.components(); + for (const component of components) + component.saleFk = createdSale.id; + + await models.SaleComponent.create(components, myOptions); + } + + if (servicesIds && servicesIds.length > 0) { + const servicesFilter = { + where: {id: {inq: servicesIds}} + }; + const services = await models.TicketService.find(servicesFilter, myOptions); + for (const service of services) { + await models.TicketService.create({ + description: service.description, + quantity: (isRefund) ? - service.quantity : service.quantity, + price: service.price, + taxClassFk: service.taxClassFk, + ticketFk: (group) ? refundTicket.id : service.ticketFk, + ticketServiceTypeFk: service.ticketServiceTypeFk, + }, myOptions); + } + } + + const query = `CALL vn.ticket_recalc(?, NULL)`; + if (refundTickets.length > 0) { + for (const refundTicket of refundTickets) + await Self.rawSql(query, [refundTicket.id], myOptions); + return refundTickets.map(refundTicket => refundTicket.id); + } else { + await Self.rawSql(query, [refundTicket.id], myOptions); + return refundTicket; + } +}; diff --git a/modules/ticket/back/methods/sale/createTicketRefund.js b/modules/ticket/back/methods/sale/createTicketRefund.js new file mode 100644 index 000000000..0ecc62e0c --- /dev/null +++ b/modules/ticket/back/methods/sale/createTicketRefund.js @@ -0,0 +1,25 @@ +module.exports = async function createTicketRefund(models, ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { + // const models = Self.app.models; + + const filter = {include: {relation: 'address'}}; + const ticket = await models.Ticket.findById(ticketId, filter, myOptions); + + const refundTicket = await models.Ticket.create({ + clientFk: ticket.clientFk, + shipped: now, + addressFk: ticket.address().id, + agencyModeFk: refundAgencyMode.id, + nickname: ticket.address().nickname, + warehouseFk: withWarehouse ? ticket.warehouseFk : null, + companyFk: ticket.companyFk, + landed: now, + zoneFk: refoundZoneId + }, myOptions); + + await models.TicketRefund.create({ + refundTicketFk: refundTicket.id, + originalTicketFk: ticket.id, + }, myOptions); + + return refundTicket; +}; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index a8191610a..fc6d8bbc2 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -28,7 +28,7 @@ module.exports = Self => { } }); - Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => { + /* Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; let tx; @@ -111,6 +111,64 @@ module.exports = Self => { if (tx) await tx.commit(); + return refundTicket; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; */ + + Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => { + const models = Self.app.models; + const myOptions = {userId: ctx.req.accessToken.userId}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const refundAgencyMode = await models.AgencyMode.findOne({ + include: { + relation: 'zones', + scope: { + limit: 1, + field: ['id', 'name'] + } + }, + where: {code: 'refund'} + }, myOptions); + + const refoundZoneId = refundAgencyMode.zones()[0].id; + + const salesFilter = { + where: {id: {inq: salesIds}}, + include: { + relation: 'components', + scope: { + fields: ['saleFk', 'componentFk', 'value'] + } + } + }; + const sales = await models.Sale.find(salesFilter, myOptions); + const group = true; + const isRefund = true; + + const refundTicket = await clone( + sales, + refundAgencyMode, + refoundZoneId, servicesIds, + withWarehouse, + group, + isRefund, + myOptions + ); + if (tx) await tx.commit(); + return refundTicket; } catch (e) { if (tx) await tx.rollback(); @@ -118,6 +176,83 @@ module.exports = Self => { } }; + async function clone(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, isRefund, myOptions) { + const models = Self.app.models; + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; + const [firstTicketId] = ticketsIds; + + const now = Date.vnNew(); + let refundTickets = []; + let refundTicket; + + if (!group) { + for (const ticketId of ticketsIds) { + refundTicket = await createTicketRefund( + ticketId, + now, + refundAgencyMode, + refoundZoneId, + null, + myOptions + ); + refundTickets.push(refundTicket); + } + } else { + refundTicket = await createTicketRefund( + firstTicketId, + now, + refundAgencyMode, + refoundZoneId, + withWarehouse, + myOptions + ); + } + + for (const sale of sales) { + const createdSale = await models.Sale.create({ + ticketFk: (group) ? refundTicket.id : sale.ticketFk, + itemFk: sale.itemFk, + quantity: (isRefund) ? - sale.quantity : sale.quantity, + concept: sale.concept, + price: sale.price, + discount: sale.discount, + }, myOptions); + + const components = sale.components(); + for (const component of components) + component.saleFk = createdSale.id; + + await models.SaleComponent.create(components, myOptions); + } + + if (servicesIds && servicesIds.length > 0) { + const servicesFilter = { + where: {id: {inq: servicesIds}} + }; + const services = await models.TicketService.find(servicesFilter, myOptions); + for (const service of services) { + await models.TicketService.create({ + description: service.description, + quantity: (isRefund) ? - service.quantity : service.quantity, + price: service.price, + taxClassFk: service.taxClassFk, + ticketFk: (group) ? refundTicket.id : service.ticketFk, + ticketServiceTypeFk: service.ticketServiceTypeFk, + }, myOptions); + } + } + + const query = `CALL vn.ticket_recalc(?, NULL)`; + if (refundTickets.length > 0) { + for (const refundTicket of refundTickets) + await Self.rawSql(query, [refundTicket.id], myOptions); + return refundTickets.map(refundTicket => refundTicket.id); + } else { + await Self.rawSql(query, [refundTicket.id], myOptions); + return refundTicket; + } + } + async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { const models = Self.app.models; From 22f76ec6a943282c8e870e54f17b2cebe79f1d5a Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 31 Jul 2023 10:33:51 +0200 Subject: [PATCH 02/32] refs #5914 WIP clone method created --- .../233201/00-transferInvoiceOutACL.sql | 2 +- .../methods/invoiceOut/transferInvoiceOut.js | 31 ++++- modules/invoiceOut/back/model-config.json | 6 +- ...-type.json => cplus-invoice-type-477.json} | 4 +- .../front/descriptor-menu/index.html | 10 +- .../invoiceOut/front/descriptor-menu/index.js | 3 +- modules/ticket/back/methods/sale/clone.js | 127 ++++++++---------- .../back/methods/sale/createTicketRefund.js | 25 ---- modules/ticket/back/methods/sale/refund.js | 71 +++++----- modules/ticket/back/models/sale.js | 1 + 10 files changed, 129 insertions(+), 151 deletions(-) rename modules/invoiceOut/back/models/{cplus-correcting-type.json => cplus-invoice-type-477.json} (78%) delete mode 100644 modules/ticket/back/methods/sale/createTicketRefund.js diff --git a/db/changes/233201/00-transferInvoiceOutACL.sql b/db/changes/233201/00-transferInvoiceOutACL.sql index b549e52a8..6e8d88c5d 100644 --- a/db/changes/233201/00-transferInvoiceOutACL.sql +++ b/db/changes/233201/00-transferInvoiceOutACL.sql @@ -1,6 +1,6 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES ('CplusRectificationType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('CplusCorrectingType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('CplusInvoiceType477', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), ('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), ('InvoiceOut', 'transferInvoiceOut', 'WRITE', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js index b50e4b1a7..d53581ac6 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js @@ -34,15 +34,17 @@ module.exports = Self => { myOptions.transaction = tx; } try { - const {ref, newClientFk, cplusRectificationId, cplusCorrectingTypeId, invoiceCorrectionTypeId} = params; - if (!ref || !newClientFk || !cplusRectificationId || !cplusCorrectingTypeId || !invoiceCorrectionTypeId) + const {id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477FkId, invoiceCorrectionTypeId} = params; + if (!id || !ref || !newClientFk || !cplusRectificationId || !cplusInvoiceType477FkId || !invoiceCorrectionTypeId) throw new UserError(`There are missing fields.`); + // Refund tickets and group const filter = {where: {refFk: ref}}; const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundTicket = await models.Ticket.refund(ctx, ticketsIds, null, myOptions); - // Clonar tickets + await models.Ticket.refund(ctx, ticketsIds, null, myOptions); + + // Clone tickets const refundAgencyMode = await models.AgencyMode.findOne({ include: { relation: 'zones', @@ -66,11 +68,28 @@ module.exports = Self => { } }; const sales = await models.Sale.find(salesFilter, myOptions); - // Actualizar cliente + const isRefund = false; + const clonedTicketIds = await models.Sale.clone(sales, refundAgencyMode, refoundZoneId, servicesIds, null, isRefund, myOptions); - // Invoice Ticket - Factura rápida ?? + // Update client + for (const clonedTicketId of clonedTicketIds) { + const ticket = await models.Ticket.findById(clonedTicketId, myOptions); + await ticket.updateAttributes({clientFk: newClientFk}); + } + // Quick invoice + const invoiceIds = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); // Insert InvoiceCorrection + for (const invoiceId of invoiceIds) { + await models.invoiceCorrection.create({ + correctingFk: invoiceId, + correctedFk: id, + cplusRectificationTypeFk: cplusRectificationId, + cplusInvoiceType477Fk: cplusInvoiceType477FkId, + invoiceCorrectionType: invoiceCorrectionTypeId + }); + } + if (tx) await tx.commit(); } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/invoiceOut/back/model-config.json b/modules/invoiceOut/back/model-config.json index 995ea976b..23246893b 100644 --- a/modules/invoiceOut/back/model-config.json +++ b/modules/invoiceOut/back/model-config.json @@ -35,13 +35,13 @@ "CplusRectificationType": { "dataSource": "vn" }, - "CplusCorrectingType": { - "dataSource": "vn" - }, "InvoiceCorrectionType": { "dataSource": "vn" }, "InvoiceCorrection": { "dataSource": "vn" + }, + "CplusInvoiceType477": { + "dataSource": "vn" } } diff --git a/modules/invoiceOut/back/models/cplus-correcting-type.json b/modules/invoiceOut/back/models/cplus-invoice-type-477.json similarity index 78% rename from modules/invoiceOut/back/models/cplus-correcting-type.json rename to modules/invoiceOut/back/models/cplus-invoice-type-477.json index 660f60008..840a9a7e4 100644 --- a/modules/invoiceOut/back/models/cplus-correcting-type.json +++ b/modules/invoiceOut/back/models/cplus-invoice-type-477.json @@ -1,9 +1,9 @@ { - "name": "CplusCorrectingType", + "name": "CplusInvoiceType477", "base": "VnModel", "options": { "mysql": { - "table": "cplusCorrectingType" + "table": "cplusInvoiceType477" } }, "properties": { diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index d6eaa1cc7..1655290f4 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -6,8 +6,8 @@ + url="CplusInvoiceType477s" + data="cplusInvoiceType477"> sale.ticketFk))]; - const [firstTicketId] = ticketsIds; +module.exports = Self => { + Self.clone = async(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, isRefund, myOptions) => { + const models = Self.app.models; + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - const now = Date.vnNew(); - let refundTickets = []; - let refundTicket; + const now = Date.vnNew(); + let updatedTickets = []; - if (!group) { for (const ticketId of ticketsIds) { - refundTicket = await createTicketRefund( - ticketId, - now, - refundAgencyMode, - refoundZoneId, - null, - myOptions - ); - refundTickets.push(refundTicket); - } - } else { - refundTicket = await createTicketRefund( - firstTicketId, - now, - refundAgencyMode, - refoundZoneId, - withWarehouse, - myOptions - ); - } + const filter = {include: {relation: 'address'}}; + const ticket = await models.Ticket.findById(ticketId, filter, myOptions); - for (const sale of sales) { - const createdSale = await models.Sale.create({ - ticketFk: (group) ? refundTicket.id : sale.ticketFk, - itemFk: sale.itemFk, - quantity: (isRefund) ? - sale.quantity : sale.quantity, - concept: sale.concept, - price: sale.price, - discount: sale.discount, - }, myOptions); - - const components = sale.components(); - for (const component of components) - component.saleFk = createdSale.id; - - await models.SaleComponent.create(components, myOptions); - } - - if (servicesIds && servicesIds.length > 0) { - const servicesFilter = { - where: {id: {inq: servicesIds}} - }; - const services = await models.TicketService.find(servicesFilter, myOptions); - for (const service of services) { - await models.TicketService.create({ - description: service.description, - quantity: (isRefund) ? - service.quantity : service.quantity, - price: service.price, - taxClassFk: service.taxClassFk, - ticketFk: (group) ? refundTicket.id : service.ticketFk, - ticketServiceTypeFk: service.ticketServiceTypeFk, + const ticketUpdated = await models.Ticket.create({ + clientFk: ticket.clientFk, + shipped: now, + addressFk: ticket.address().id, + agencyModeFk: refundAgencyMode.id, + nickname: ticket.address().nickname, + warehouseFk: withWarehouse ? ticket.warehouseFk : null, + companyFk: ticket.companyFk, + landed: now, + zoneFk: refoundZoneId }, myOptions); + updatedTickets.push(ticketUpdated); } - } - const query = `CALL vn.ticket_recalc(?, NULL)`; - if (refundTickets.length > 0) { - for (const refundTicket of refundTickets) - await Self.rawSql(query, [refundTicket.id], myOptions); - return refundTickets.map(refundTicket => refundTicket.id); - } else { - await Self.rawSql(query, [refundTicket.id], myOptions); - return refundTicket; - } + for (const sale of sales) { + const createdSale = await models.Sale.create({ + ticketFk: sale.ticketFk, + itemFk: sale.itemFk, + quantity: (isRefund) ? - sale.quantity : sale.quantity, + concept: sale.concept, + price: sale.price, + discount: sale.discount, + }, myOptions); + + const components = sale.components(); + for (const component of components) + component.saleFk = createdSale.id; + + await models.SaleComponent.create(components, myOptions); + } + + if (servicesIds && servicesIds.length > 0) { + const servicesFilter = { + where: {id: {inq: servicesIds}} + }; + const services = await models.TicketService.find(servicesFilter, myOptions); + for (const service of services) { + await models.TicketService.create({ + description: service.description, + quantity: (isRefund) ? - service.quantity : service.quantity, + price: service.price, + taxClassFk: service.taxClassFk, + ticketFk: service.ticketFk, + ticketServiceTypeFk: service.ticketServiceTypeFk, + }, myOptions); + } + } + + const query = `CALL vn.ticket_recalc(?, NULL)`; + + for (const updatedTicket of updatedTickets) + await Self.rawSql(query, [updatedTicket.id], myOptions); + return updatedTickets.map(updatedTicket => updatedTicket.id); + }; }; diff --git a/modules/ticket/back/methods/sale/createTicketRefund.js b/modules/ticket/back/methods/sale/createTicketRefund.js deleted file mode 100644 index 0ecc62e0c..000000000 --- a/modules/ticket/back/methods/sale/createTicketRefund.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = async function createTicketRefund(models, ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { - // const models = Self.app.models; - - const filter = {include: {relation: 'address'}}; - const ticket = await models.Ticket.findById(ticketId, filter, myOptions); - - const refundTicket = await models.Ticket.create({ - clientFk: ticket.clientFk, - shipped: now, - addressFk: ticket.address().id, - agencyModeFk: refundAgencyMode.id, - nickname: ticket.address().nickname, - warehouseFk: withWarehouse ? ticket.warehouseFk : null, - companyFk: ticket.companyFk, - landed: now, - zoneFk: refoundZoneId - }, myOptions); - - await models.TicketRefund.create({ - refundTicketFk: refundTicket.id, - originalTicketFk: ticket.id, - }, myOptions); - - return refundTicket; -}; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index fc6d8bbc2..6bb131e4d 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -158,10 +158,11 @@ module.exports = Self => { const group = true; const isRefund = true; - const refundTicket = await clone( + const refundTicket = await cloneAndGroup( sales, refundAgencyMode, - refoundZoneId, servicesIds, + refoundZoneId, + servicesIds, withWarehouse, group, isRefund, @@ -176,41 +177,37 @@ module.exports = Self => { } }; - async function clone(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, isRefund, myOptions) { - const models = Self.app.models; + async function cloneAndGroup(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, isRefund, myOptions) { + if (!group) { + const tickets = await models.Sale.clone(sales, + refundAgencyMode, + refoundZoneId, servicesIds, + withWarehouse, + isRefund, + myOptions); + return tickets; + } + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; const [firstTicketId] = ticketsIds; + const filter = {include: {relation: 'address'}}; + const ticket = await models.Ticket.findById(firstTicketId, filter, myOptions); - const now = Date.vnNew(); - let refundTickets = []; - let refundTicket; - - if (!group) { - for (const ticketId of ticketsIds) { - refundTicket = await createTicketRefund( - ticketId, - now, - refundAgencyMode, - refoundZoneId, - null, - myOptions - ); - refundTickets.push(refundTicket); - } - } else { - refundTicket = await createTicketRefund( - firstTicketId, - now, - refundAgencyMode, - refoundZoneId, - withWarehouse, - myOptions - ); - } + const ticketUpdated = await models.Ticket.create({ + clientFk: ticket.clientFk, + shipped: now, + addressFk: ticket.address().id, + agencyModeFk: refundAgencyMode.id, + nickname: ticket.address().nickname, + warehouseFk: withWarehouse ? ticket.warehouseFk : null, + companyFk: ticket.companyFk, + landed: now, + zoneFk: refoundZoneId + }, myOptions); for (const sale of sales) { const createdSale = await models.Sale.create({ - ticketFk: (group) ? refundTicket.id : sale.ticketFk, + ticketFk: ticketUpdated.id, itemFk: sale.itemFk, quantity: (isRefund) ? - sale.quantity : sale.quantity, concept: sale.concept, @@ -236,21 +233,15 @@ module.exports = Self => { quantity: (isRefund) ? - service.quantity : service.quantity, price: service.price, taxClassFk: service.taxClassFk, - ticketFk: (group) ? refundTicket.id : service.ticketFk, + ticketFk: ticketUpdated.id, ticketServiceTypeFk: service.ticketServiceTypeFk, }, myOptions); } } const query = `CALL vn.ticket_recalc(?, NULL)`; - if (refundTickets.length > 0) { - for (const refundTicket of refundTickets) - await Self.rawSql(query, [refundTicket.id], myOptions); - return refundTickets.map(refundTicket => refundTicket.id); - } else { - await Self.rawSql(query, [refundTicket.id], myOptions); - return refundTicket; - } + await Self.rawSql(query, [refundTicket.id], myOptions); + return ticketUpdated; } async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index bab201fdd..e65c98fea 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -10,6 +10,7 @@ module.exports = Self => { require('../methods/sale/refund')(Self); require('../methods/sale/canEdit')(Self); require('../methods/sale/usesMana')(Self); + require('../methods/sale/clone')(Self); Self.validatesPresenceOf('concept', { message: `Concept cannot be blank` From 3ef74cab5c00ee70ebc8ad78e15a5b0f40145f59 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 1 Aug 2023 12:45:57 +0200 Subject: [PATCH 03/32] refs #5914 WIP created transferInvoiceOut --- .../methods/invoiceOut/transferInvoiceOut.js | 66 +++++--- .../front/descriptor-menu/index.html | 3 +- .../invoiceOut/front/descriptor-menu/index.js | 14 +- modules/ticket/back/methods/sale/clone.js | 151 +++++++++++------- modules/ticket/back/methods/sale/refund.js | 87 ++-------- .../back/methods/sale/specs/refund.spec.js | 2 +- modules/ticket/back/methods/ticket/refund.js | 1 - modules/ticket/back/models/ticket.json | 5 + 8 files changed, 161 insertions(+), 168 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js index d53581ac6..86de59e9d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js @@ -6,10 +6,35 @@ module.exports = Self => { accessType: 'WRITE', accepts: [ { - arg: 'data', - type: 'Object', + arg: 'id', + type: 'number', required: true - } + }, + { + arg: 'ref', + type: 'string', + required: true + }, + { + arg: 'newClientFk', + type: 'number', + required: true + }, + { + arg: 'cplusRectificationId', + type: 'number', + required: true + }, + { + arg: 'cplusInvoiceType477Id', + type: 'number', + required: true + }, + { + arg: 'invoiceCorrectionTypeId', + type: 'number', + required: true + }, ], returns: { type: 'boolean', @@ -21,7 +46,7 @@ module.exports = Self => { } }); - Self.transferInvoiceOut = async(ctx, params, options) => { + Self.transferInvoiceOut = async(ctx, id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477Id, invoiceCorrectionTypeId, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -34,16 +59,12 @@ module.exports = Self => { myOptions.transaction = tx; } try { - const {id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477FkId, invoiceCorrectionTypeId} = params; - if (!id || !ref || !newClientFk || !cplusRectificationId || !cplusInvoiceType477FkId || !invoiceCorrectionTypeId) - throw new UserError(`There are missing fields.`); - // Refund tickets and group const filter = {where: {refFk: ref}}; const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); await models.Ticket.refund(ctx, ticketsIds, null, myOptions); - + console.log('Ticket refunded'); // Clone tickets const refundAgencyMode = await models.AgencyMode.findOne({ include: { @@ -58,25 +79,20 @@ module.exports = Self => { const refoundZoneId = refundAgencyMode.zones()[0].id; const services = await models.TicketService.find(filter, myOptions); const servicesIds = services.map(service => service.id); - const salesFilter = { - where: {id: {inq: salesIds}}, - include: { - relation: 'components', - scope: { - fields: ['saleFk', 'componentFk', 'value'] - } - } - }; + const salesFilter = {where: {ticketFk: {inq: ticketsIds}}}; const sales = await models.Sale.find(salesFilter, myOptions); - const isRefund = false; - const clonedTicketIds = await models.Sale.clone(sales, refundAgencyMode, refoundZoneId, servicesIds, null, isRefund, myOptions); - + const clonedTickets = await models.Sale.clone(sales, refundAgencyMode, refoundZoneId, servicesIds, null, false, false, myOptions); + console.log('cloned tickets'); // Update client - for (const clonedTicketId of clonedTicketIds) { - const ticket = await models.Ticket.findById(clonedTicketId, myOptions); - await ticket.updateAttributes({clientFk: newClientFk}); + for (const clonedTicket of clonedTickets) { + // const ticket = await models.Ticket.findById(clonedTicketId, myOptions); + console.log(clonedTicket); + await clonedTicket.updateAttributes({clientFk: newClientFk}, myOptions); + console.log(clonedTicket); } // Quick invoice + const clonedTicketIds = clonedTickets.map(clonedTicket => clonedTicket.id); + console.log(clonedTicketIds); const invoiceIds = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); // Insert InvoiceCorrection @@ -85,7 +101,7 @@ module.exports = Self => { correctingFk: invoiceId, correctedFk: id, cplusRectificationTypeFk: cplusRectificationId, - cplusInvoiceType477Fk: cplusInvoiceType477FkId, + cplusInvoiceType477Fk: cplusInvoiceType477Id, invoiceCorrectionType: invoiceCorrectionTypeId }); } diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 1655290f4..dc5c2a8e9 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -222,12 +222,13 @@ console.log(res.data)); } diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index 96e66de2c..e1793d088 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -1,67 +1,104 @@ module.exports = Self => { - Self.clone = async(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, isRefund, myOptions) => { + Self.clone = async(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, negative, myOptions) => { const models = Self.app.models; - const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; + let tx; + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; + const [firstTicketId] = ticketsIds; const now = Date.vnNew(); let updatedTickets = []; + let newTicket; + const filter = { + include: [ + {relation: 'address'}, + { + relation: 'sale', + inq: sales, + }, + ] + }; + try { + for (const [index, ticketId] of ticketsIds.entries()) { + const ticket = await models.Ticket.findById(ticketId, filter, myOptions); + if (!group || !index) { + newTicket = await models.Ticket.create({ + clientFk: ticket.clientFk, + shipped: now, + addressFk: ticket.address().id, + agencyModeFk: refundAgencyMode.id, + nickname: ticket.address().nickname, + warehouseFk: withWarehouse ? ticket.warehouseFk : null, + companyFk: ticket.companyFk, + landed: now, + zoneFk: refoundZoneId + }, myOptions); + updatedTickets.push(newTicket); + } + const sales = ticket.sale(); + const saleIds = sales.map(sale => sale.id); + const saleComponentsFilter = { + where: {saleFk: {inq: saleIds}}, + scope: { + fields: ['saleFk', 'componentFk', 'value'] + } + }; + for (const sale of sales) { + const createdSale = await models.Sale.create({ + ticketFk: newTicket.id, + itemFk: sale.itemFk, + quantity: (negative) ? - sale.quantity : sale.quantity, + concept: sale.concept, + price: sale.price, + discount: sale.discount, + }, myOptions); + const components = await models.SaleComponent.find(saleComponentsFilter, myOptions); + // const components = sale.components(); + for (const component of components) + component.saleFk = createdSale.id; - for (const ticketId of ticketsIds) { - const filter = {include: {relation: 'address'}}; - const ticket = await models.Ticket.findById(ticketId, filter, myOptions); - - const ticketUpdated = await models.Ticket.create({ - clientFk: ticket.clientFk, - shipped: now, - addressFk: ticket.address().id, - agencyModeFk: refundAgencyMode.id, - nickname: ticket.address().nickname, - warehouseFk: withWarehouse ? ticket.warehouseFk : null, - companyFk: ticket.companyFk, - landed: now, - zoneFk: refoundZoneId - }, myOptions); - updatedTickets.push(ticketUpdated); - } - - for (const sale of sales) { - const createdSale = await models.Sale.create({ - ticketFk: sale.ticketFk, - itemFk: sale.itemFk, - quantity: (isRefund) ? - sale.quantity : sale.quantity, - concept: sale.concept, - price: sale.price, - discount: sale.discount, - }, myOptions); - - const components = sale.components(); - for (const component of components) - component.saleFk = createdSale.id; - - await models.SaleComponent.create(components, myOptions); - } - - if (servicesIds && servicesIds.length > 0) { - const servicesFilter = { - where: {id: {inq: servicesIds}} - }; - const services = await models.TicketService.find(servicesFilter, myOptions); - for (const service of services) { - await models.TicketService.create({ - description: service.description, - quantity: (isRefund) ? - service.quantity : service.quantity, - price: service.price, - taxClassFk: service.taxClassFk, - ticketFk: service.ticketFk, - ticketServiceTypeFk: service.ticketServiceTypeFk, - }, myOptions); + await models.SaleComponent.create(components, myOptions); + } } + if (servicesIds && servicesIds.length > 0) { + const servicesFilter = { + where: {id: {inq: servicesIds}} + }; + const services = await models.TicketService.find(servicesFilter, myOptions); + for (const service of services) { + await models.TicketService.create({ + description: service.description, + quantity: (negative) ? - service.quantity : service.quantity, + price: service.price, + taxClassFk: service.taxClassFk, + ticketFk: service.ticketFk, + ticketServiceTypeFk: service.ticketServiceTypeFk, + }, myOptions); + } + } + + const query = `CALL vn.ticket_recalc(?, NULL)`; + + if (group) { + await Self.rawSql(query, [newTicket.id], myOptions); + if (tx) await tx.commit(); + return { + refundTicket: newTicket, + originalTicketFk: firstTicketId + }; + } else { + for (const updatedTicket of updatedTickets) + await Self.rawSql(query, [updatedTicket.id], myOptions); + if (tx) await tx.commit(); + return updatedTickets/* updatedTickets.map(updatedTicket => updatedTicket.id) */; + } + } catch (e) { + if (tx) await tx.rollback(); + throw e; } - - const query = `CALL vn.ticket_recalc(?, NULL)`; - - for (const updatedTicket of updatedTickets) - await Self.rawSql(query, [updatedTicket.id], myOptions); - return updatedTickets.map(updatedTicket => updatedTicket.id); }; }; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 6bb131e4d..c85bcd834 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -155,19 +155,23 @@ module.exports = Self => { } }; const sales = await models.Sale.find(salesFilter, myOptions); - const group = true; - const isRefund = true; - - const refundTicket = await cloneAndGroup( + const clonedTicket = await models.Sale.clone( sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, - group, - isRefund, + true, + true, myOptions ); + + const refundTicket = clonedTicket.refundTicket; + + await models.TicketRefund.create({ + refundTicketFk: refundTicket.id, + originalTicketFk: clonedTicket.originalTicketFk, + }, myOptions); if (tx) await tx.commit(); return refundTicket; @@ -177,74 +181,7 @@ module.exports = Self => { } }; - async function cloneAndGroup(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, isRefund, myOptions) { - if (!group) { - const tickets = await models.Sale.clone(sales, - refundAgencyMode, - refoundZoneId, servicesIds, - withWarehouse, - isRefund, - myOptions); - return tickets; - } - - const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - const [firstTicketId] = ticketsIds; - const filter = {include: {relation: 'address'}}; - const ticket = await models.Ticket.findById(firstTicketId, filter, myOptions); - - const ticketUpdated = await models.Ticket.create({ - clientFk: ticket.clientFk, - shipped: now, - addressFk: ticket.address().id, - agencyModeFk: refundAgencyMode.id, - nickname: ticket.address().nickname, - warehouseFk: withWarehouse ? ticket.warehouseFk : null, - companyFk: ticket.companyFk, - landed: now, - zoneFk: refoundZoneId - }, myOptions); - - for (const sale of sales) { - const createdSale = await models.Sale.create({ - ticketFk: ticketUpdated.id, - itemFk: sale.itemFk, - quantity: (isRefund) ? - sale.quantity : sale.quantity, - concept: sale.concept, - price: sale.price, - discount: sale.discount, - }, myOptions); - - const components = sale.components(); - for (const component of components) - component.saleFk = createdSale.id; - - await models.SaleComponent.create(components, myOptions); - } - - if (servicesIds && servicesIds.length > 0) { - const servicesFilter = { - where: {id: {inq: servicesIds}} - }; - const services = await models.TicketService.find(servicesFilter, myOptions); - for (const service of services) { - await models.TicketService.create({ - description: service.description, - quantity: (isRefund) ? - service.quantity : service.quantity, - price: service.price, - taxClassFk: service.taxClassFk, - ticketFk: ticketUpdated.id, - ticketServiceTypeFk: service.ticketServiceTypeFk, - }, myOptions); - } - } - - const query = `CALL vn.ticket_recalc(?, NULL)`; - await Self.rawSql(query, [refundTicket.id], myOptions); - return ticketUpdated; - } - - async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { + /* async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { const models = Self.app.models; const filter = {include: {relation: 'address'}}; @@ -268,5 +205,5 @@ module.exports = Self => { }, myOptions); return refundTicket; - } + } */ }; diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index b81f7f84d..727ce2fac 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -describe('Sale refund()', () => { +fdescribe('Sale refund()', () => { const userId = 5; const ctx = {req: {accessToken: userId}}; const activeCtx = { diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js index c99b6aa83..758384ae2 100644 --- a/modules/ticket/back/methods/ticket/refund.js +++ b/modules/ticket/back/methods/ticket/refund.js @@ -39,7 +39,6 @@ module.exports = Self => { try { const filter = {where: {ticketFk: {inq: ticketsIds}}}; - const sales = await models.Sale.find(filter, myOptions); const salesIds = sales.map(sale => sale.id); diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index ec4193bed..1c5610a2a 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -136,6 +136,11 @@ "type": "belongsTo", "model": "Zone", "foreignKey": "zoneFk" + }, + "sale": { + "type": "hasMany", + "model": "Sale", + "foreignKey": "ticketFk" } } } From bd122e6327024b2ad885cfcd340d9bcb2f5e42e5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 1 Aug 2023 16:13:24 +0200 Subject: [PATCH 04/32] refs #5014 WIP trasactions added --- .../methods/invoiceOut/transferInvoiceOut.js | 17 +++++------------ ...orrection.json => invoice-correction.json} | 0 modules/ticket/back/methods/sale/clone.js | 19 ++++++++++--------- modules/ticket/back/methods/sale/refund.js | 14 ++++++++------ 4 files changed, 23 insertions(+), 27 deletions(-) rename modules/invoiceOut/back/models/{invoiceCorrection.json => invoice-correction.json} (100%) diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js index 86de59e9d..e059aa431 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js @@ -48,7 +48,7 @@ module.exports = Self => { Self.transferInvoiceOut = async(ctx, id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477Id, invoiceCorrectionTypeId, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') @@ -64,7 +64,6 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); await models.Ticket.refund(ctx, ticketsIds, null, myOptions); - console.log('Ticket refunded'); // Clone tickets const refundAgencyMode = await models.AgencyMode.findOne({ include: { @@ -82,22 +81,17 @@ module.exports = Self => { const salesFilter = {where: {ticketFk: {inq: ticketsIds}}}; const sales = await models.Sale.find(salesFilter, myOptions); const clonedTickets = await models.Sale.clone(sales, refundAgencyMode, refoundZoneId, servicesIds, null, false, false, myOptions); - console.log('cloned tickets'); // Update client - for (const clonedTicket of clonedTickets) { - // const ticket = await models.Ticket.findById(clonedTicketId, myOptions); - console.log(clonedTicket); + for (const clonedTicket of clonedTickets) await clonedTicket.updateAttributes({clientFk: newClientFk}, myOptions); - console.log(clonedTicket); - } + // Quick invoice const clonedTicketIds = clonedTickets.map(clonedTicket => clonedTicket.id); - console.log(clonedTicketIds); const invoiceIds = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); // Insert InvoiceCorrection for (const invoiceId of invoiceIds) { - await models.invoiceCorrection.create({ + await models.InvoiceCorrection.create({ correctingFk: invoiceId, correctedFk: id, cplusRectificationTypeFk: cplusRectificationId, @@ -105,12 +99,11 @@ module.exports = Self => { invoiceCorrectionType: invoiceCorrectionTypeId }); } - if (tx) await tx.commit(); + return true; } catch (e) { if (tx) await tx.rollback(); throw e; } - return true; }; }; diff --git a/modules/invoiceOut/back/models/invoiceCorrection.json b/modules/invoiceOut/back/models/invoice-correction.json similarity index 100% rename from modules/invoiceOut/back/models/invoiceCorrection.json rename to modules/invoiceOut/back/models/invoice-correction.json diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index e1793d088..dae15d7df 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -1,8 +1,12 @@ module.exports = Self => { - Self.clone = async(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, negative, myOptions) => { + Self.clone = async(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, negative, options) => { const models = Self.app.models; + const myOptions = {}; let tx; + if (typeof options == 'object') + Object.assign(myOptions, options); + if (!myOptions.transaction) { tx = await Self.beginTransaction({}); myOptions.transaction = tx; @@ -39,15 +43,15 @@ module.exports = Self => { }, myOptions); updatedTickets.push(newTicket); } - const sales = ticket.sale(); - const saleIds = sales.map(sale => sale.id); + const salesByTicket = ticket.sale(); + const saleIds = salesByTicket.map(sale => sale.id); const saleComponentsFilter = { where: {saleFk: {inq: saleIds}}, scope: { fields: ['saleFk', 'componentFk', 'value'] } }; - for (const sale of sales) { + for (const sale of salesByTicket) { const createdSale = await models.Sale.create({ ticketFk: newTicket.id, itemFk: sale.itemFk, @@ -56,7 +60,7 @@ module.exports = Self => { price: sale.price, discount: sale.discount, }, myOptions); - const components = await models.SaleComponent.find(saleComponentsFilter, myOptions); + const components = await models.SaleComponent.find(saleComponentsFilter, myOptions); // Revisar con Alex // const components = sale.components(); for (const component of components) component.saleFk = createdSale.id; @@ -86,10 +90,7 @@ module.exports = Self => { if (group) { await Self.rawSql(query, [newTicket.id], myOptions); if (tx) await tx.commit(); - return { - refundTicket: newTicket, - originalTicketFk: firstTicketId - }; + return newTicket; } else { for (const updatedTicket of updatedTickets) await Self.rawSql(query, [updatedTicket.id], myOptions); diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index c85bcd834..a69c05f36 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -155,7 +155,7 @@ module.exports = Self => { } }; const sales = await models.Sale.find(salesFilter, myOptions); - const clonedTicket = await models.Sale.clone( + const refundTicket = await models.Sale.clone( sales, refundAgencyMode, refoundZoneId, @@ -166,12 +166,14 @@ module.exports = Self => { myOptions ); - const refundTicket = clonedTicket.refundTicket; + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; + for (const ticketId of ticketsIds) { + await models.TicketRefund.create({ + refundTicketFk: refundTicket.id, + originalTicketFk: ticketId, + }, myOptions); + } - await models.TicketRefund.create({ - refundTicketFk: refundTicket.id, - originalTicketFk: clonedTicket.originalTicketFk, - }, myOptions); if (tx) await tx.commit(); return refundTicket; From 725fe674c0babb414a7ea7f7b99763c8f066bcce Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 3 Aug 2023 14:01:50 +0200 Subject: [PATCH 05/32] refs #5914 WIP fixing transacticions --- .../methods/invoiceOut/transferInvoiceOut.js | 47 ++++------ .../invoiceOut/front/descriptor-menu/index.js | 6 +- modules/ticket/back/methods/sale/clone.js | 9 +- modules/ticket/back/methods/sale/refund.js | 90 ------------------- 4 files changed, 27 insertions(+), 125 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js index e059aa431..fbb40061d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js @@ -1,5 +1,3 @@ -const UserError = require('vn-loopback/util/user-error'); - module.exports = Self => { Self.remoteMethodCtx('transferInvoiceOut', { description: 'Transfer an invoice out to another client', @@ -48,7 +46,7 @@ module.exports = Self => { Self.transferInvoiceOut = async(ctx, id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477Id, invoiceCorrectionTypeId, options) => { const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') @@ -65,42 +63,35 @@ module.exports = Self => { const ticketsIds = tickets.map(ticket => ticket.id); await models.Ticket.refund(ctx, ticketsIds, null, myOptions); // Clone tickets - const refundAgencyMode = await models.AgencyMode.findOne({ - include: { - relation: 'zones', - scope: { - limit: 1, - field: ['id', 'name'] - } - }, - where: {code: 'refund'} - }, myOptions); - const refoundZoneId = refundAgencyMode.zones()[0].id; const services = await models.TicketService.find(filter, myOptions); const servicesIds = services.map(service => service.id); const salesFilter = {where: {ticketFk: {inq: ticketsIds}}}; const sales = await models.Sale.find(salesFilter, myOptions); - const clonedTickets = await models.Sale.clone(sales, refundAgencyMode, refoundZoneId, servicesIds, null, false, false, myOptions); + const clonedTickets = await models.Sale.clone(sales, servicesIds, null, false, false, myOptions); + console.log('cloned tickets', clonedTickets); // Update client - for (const clonedTicket of clonedTickets) - await clonedTicket.updateAttributes({clientFk: newClientFk}, myOptions); + for (const clonedTicket of clonedTickets) { + const ticket = await models.Ticket.findById(clonedTicket); + console.log(ticket); + await ticket.updateAttributes({clientFk: newClientFk}, myOptions); + // await clonedTicket.updateAttributes({clientFk: newClientFk}, myOptions); + } // Quick invoice const clonedTicketIds = clonedTickets.map(clonedTicket => clonedTicket.id); - const invoiceIds = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); + const invoiceId = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); // Insert InvoiceCorrection - for (const invoiceId of invoiceIds) { - await models.InvoiceCorrection.create({ - correctingFk: invoiceId, - correctedFk: id, - cplusRectificationTypeFk: cplusRectificationId, - cplusInvoiceType477Fk: cplusInvoiceType477Id, - invoiceCorrectionType: invoiceCorrectionTypeId - }); - } + await models.InvoiceCorrection.create({ + correctingFk: invoiceId, + correctedFk: id, + cplusRectificationTypeFk: cplusRectificationId, + cplusInvoiceType477Fk: cplusInvoiceType477Id, + invoiceCorrectionType: invoiceCorrectionTypeId + }); + if (tx) await tx.commit(); - return true; + return invoiceId; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 8ec5de3e6..ef69098c4 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -135,7 +135,11 @@ class Controller extends Section { cplusInvoiceType477Id: this.cplusInvoiceType477, invoiceCorrectionTypeId: this.invoiceCorrectionType }; - this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => console.log(res.data)); + this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => { + newInvoice = res.data;// id de la nueva factura + this.vnApp.showSucces(this.$t('Invoice trasfered!')); + this.$state.go('invoiceOut.index', {id: newInvoice}); + }); } } diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index dae15d7df..c168f4b3c 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.clone = async(sales, refundAgencyMode, refoundZoneId, servicesIds, withWarehouse, group, negative, options) => { + Self.clone = async(sales, servicesIds, withWarehouse, group, negative, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -13,7 +13,6 @@ module.exports = Self => { } const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - const [firstTicketId] = ticketsIds; const now = Date.vnNew(); let updatedTickets = []; let newTicket; @@ -22,7 +21,7 @@ module.exports = Self => { {relation: 'address'}, { relation: 'sale', - inq: sales, + where: {saleFk: {inq: sales}}, }, ] }; @@ -34,12 +33,10 @@ module.exports = Self => { clientFk: ticket.clientFk, shipped: now, addressFk: ticket.address().id, - agencyModeFk: refundAgencyMode.id, nickname: ticket.address().nickname, warehouseFk: withWarehouse ? ticket.warehouseFk : null, companyFk: ticket.companyFk, landed: now, - zoneFk: refoundZoneId }, myOptions); updatedTickets.push(newTicket); } @@ -95,7 +92,7 @@ module.exports = Self => { for (const updatedTicket of updatedTickets) await Self.rawSql(query, [updatedTicket.id], myOptions); if (tx) await tx.commit(); - return updatedTickets/* updatedTickets.map(updatedTicket => updatedTicket.id) */; + return /* updatedTickets */updatedTickets.map(updatedTicket => updatedTicket.id); } } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index a69c05f36..dabafb469 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -28,96 +28,6 @@ module.exports = Self => { } }); - /* Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => { - const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const refundAgencyMode = await models.AgencyMode.findOne({ - include: { - relation: 'zones', - scope: { - limit: 1, - field: ['id', 'name'] - } - }, - where: {code: 'refund'} - }, myOptions); - - const refoundZoneId = refundAgencyMode.zones()[0].id; - - const salesFilter = { - where: {id: {inq: salesIds}}, - include: { - relation: 'components', - scope: { - fields: ['saleFk', 'componentFk', 'value'] - } - } - }; - const sales = await models.Sale.find(salesFilter, myOptions); - const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - - const now = Date.vnNew(); - const [firstTicketId] = ticketsIds; - - const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions); - - for (const sale of sales) { - const createdSale = await models.Sale.create({ - ticketFk: refundTicket.id, - itemFk: sale.itemFk, - quantity: - sale.quantity, - concept: sale.concept, - price: sale.price, - discount: sale.discount, - }, myOptions); - - const components = sale.components(); - for (const component of components) - component.saleFk = createdSale.id; - - await models.SaleComponent.create(components, myOptions); - } - - if (servicesIds && servicesIds.length > 0) { - const servicesFilter = { - where: {id: {inq: servicesIds}} - }; - const services = await models.TicketService.find(servicesFilter, myOptions); - for (const service of services) { - await models.TicketService.create({ - description: service.description, - quantity: - service.quantity, - price: service.price, - taxClassFk: service.taxClassFk, - ticketFk: refundTicket.id, - ticketServiceTypeFk: service.ticketServiceTypeFk, - }, myOptions); - } - } - - const query = `CALL vn.ticket_recalc(?, NULL)`; - await Self.rawSql(query, [refundTicket.id], myOptions); - - if (tx) await tx.commit(); - - return refundTicket; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; */ - Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; From 700ba4a7b1fce37f7575b3308ead22163687a14b Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 4 Aug 2023 08:22:43 +0200 Subject: [PATCH 06/32] refs #5914 feat(transferInvoiceOut): optimization --- .../methods/invoiceOut/transferInvoiceOut.js | 18 ++++++++---------- modules/ticket/back/methods/sale/clone.js | 2 +- .../back/methods/ticket/invoiceTickets.js | 7 +++++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js index fbb40061d..440ebe4d3 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js @@ -46,7 +46,8 @@ module.exports = Self => { Self.transferInvoiceOut = async(ctx, id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477Id, invoiceCorrectionTypeId, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; + let tx; if (typeof options == 'object') @@ -65,20 +66,17 @@ module.exports = Self => { // Clone tickets const services = await models.TicketService.find(filter, myOptions); const servicesIds = services.map(service => service.id); - const salesFilter = {where: {ticketFk: {inq: ticketsIds}}}; - const sales = await models.Sale.find(salesFilter, myOptions); + const sales = await models.Sale.find({where: {ticketFk: {inq: ticketsIds}}}, myOptions); const clonedTickets = await models.Sale.clone(sales, servicesIds, null, false, false, myOptions); - console.log('cloned tickets', clonedTickets); + const clonedTicketIds = []; + // Update client for (const clonedTicket of clonedTickets) { - const ticket = await models.Ticket.findById(clonedTicket); - console.log(ticket); - await ticket.updateAttributes({clientFk: newClientFk}, myOptions); - // await clonedTicket.updateAttributes({clientFk: newClientFk}, myOptions); + await clonedTicket.updateAttribute('clientFk', newClientFk, myOptions); + clonedTicketIds.push(clonedTicket.id); } // Quick invoice - const clonedTicketIds = clonedTickets.map(clonedTicket => clonedTicket.id); const invoiceId = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); // Insert InvoiceCorrection @@ -88,7 +86,7 @@ module.exports = Self => { cplusRectificationTypeFk: cplusRectificationId, cplusInvoiceType477Fk: cplusInvoiceType477Id, invoiceCorrectionType: invoiceCorrectionTypeId - }); + }, myOptions); if (tx) await tx.commit(); return invoiceId; diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index c168f4b3c..7d52fd0e6 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -92,7 +92,7 @@ module.exports = Self => { for (const updatedTicket of updatedTickets) await Self.rawSql(query, [updatedTicket.id], myOptions); if (tx) await tx.commit(); - return /* updatedTickets */updatedTickets.map(updatedTicket => updatedTicket.id); + return /* updatedTickets */updatedTickets; } } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/invoiceTickets.js b/modules/ticket/back/methods/ticket/invoiceTickets.js index ca1bf15fb..7baee133d 100644 --- a/modules/ticket/back/methods/ticket/invoiceTickets.js +++ b/modules/ticket/back/methods/ticket/invoiceTickets.js @@ -77,9 +77,11 @@ module.exports = function(Self) { if (tx) await tx.rollback(); throw e; } - - for (const invoiceId of invoicesIds) + console.log(invoicesIds, 'invoicesIds'); + for (const invoiceId of invoicesIds) { + console.log(await models.InvoiceOut.find()); await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); + } return invoicesIds; }; @@ -98,6 +100,7 @@ module.exports = function(Self) { `, [ticketsIds], myOptions); const invoiceId = await models.Ticket.makeInvoice(ctx, 'R', companyId, Date.vnNew(), myOptions); + console.log(await models.InvoiceOut.find(null, myOptions)); invoicesIds.push(invoiceId); } }; From 3d4a99b07e0024d4161bbc91d65e5cd97c560973 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 24 Aug 2023 10:51:34 +0200 Subject: [PATCH 07/32] refs 5914 transferInvoice created --- loopback/locale/es.json | 346 ++---------------- .../methods/invoiceOut/makePdfAndNotify.js | 2 +- ...ansferInvoiceOut.js => transferInvoice.js} | 28 +- .../front/descriptor-menu/index.html | 3 +- .../invoiceOut/front/descriptor-menu/index.js | 6 +- .../front/descriptor-menu/style.scss | 8 +- modules/ticket/back/methods/sale/clone.js | 171 ++++++--- modules/ticket/back/methods/sale/refund.js | 18 +- .../back/methods/ticket/invoiceTickets.js | 8 +- .../methods/ticket/invoiceTicketsWithPdf.js | 0 print/templates/reports/invoice/invoice.js | 3 + 11 files changed, 178 insertions(+), 415 deletions(-) rename modules/invoiceOut/back/methods/invoiceOut/{transferInvoiceOut.js => transferInvoice.js} (76%) create mode 100644 modules/ticket/back/methods/ticket/invoiceTicketsWithPdf.js diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d196f99fa..627ab9a46 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -1,324 +1,26 @@ { - "Phone format is invalid": "El formato del teléfono no es correcto", - "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito", - "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia", - "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado", - "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado", - "Can't be blank": "No puede estar en blanco", - "Invalid TIN": "NIF/CIF invalido", - "TIN must be unique": "El NIF/CIF debe ser único", - "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", - "Is invalid": "Is invalid", - "Quantity cannot be zero": "La cantidad no puede ser cero", - "Enter an integer different to zero": "Introduce un entero distinto de cero", - "Package cannot be blank": "El embalaje no puede estar en blanco", - "The company name must be unique": "La razón social debe ser única", - "Invalid email": "Correo electrónico inválido", - "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto", - "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN", - "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC", - "State cannot be blank": "El estado no puede estar en blanco", - "Worker cannot be blank": "El trabajador no puede estar en blanco", - "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado", - "can't be blank": "El campo no puede estar vacío", - "Observation type must be unique": "El tipo de observación no puede repetirse", + "Name cannot be blank": "Name cannot be blank", + "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", + "Social name should be uppercase": "Social name should be uppercase", + "Street cannot be empty": "Street cannot be empty", + "Street should be uppercase": "Street should be uppercase", + "City cannot be empty": "City cannot be empty", + "Invalid email": "Invalid email", + "Phone cannot be blank": "Phone cannot be blank", "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", - "The grade must be similar to the last one": "El grade debe ser similar al último", - "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", - "Name cannot be blank": "El nombre no puede estar en blanco", - "Phone cannot be blank": "El teléfono no puede estar en blanco", - "Period cannot be blank": "El periodo no puede estar en blanco", - "Choose a company": "Selecciona una empresa", - "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto", - "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres", - "Cannot be blank": "El campo no puede estar en blanco", - "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero", - "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco", - "Description cannot be blank": "Se debe rellenar el campo de texto", - "The new quantity should be smaller than the old one": "La nueva cantidad debe de ser menor que la anterior", - "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%", - "The value should be a number": "El valor debe ser un numero", - "This order is not editable": "Esta orden no se puede modificar", - "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado", - "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda", - "is not a valid date": "No es una fecha valida", - "Barcode must be unique": "El código de barras debe ser único", - "The warehouse can't be repeated": "El almacén no puede repetirse", - "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item", - "The observation type can't be repeated": "El tipo de observación no puede repetirse", - "A claim with that sale already exists": "Ya existe una reclamación para esta línea", - "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo", - "Warehouse cannot be blank": "El almacén no puede quedar en blanco", - "Agency cannot be blank": "La agencia no puede quedar en blanco", - "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados", - "This address doesn't exist": "Este consignatario no existe", - "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", - "You don't have enough privileges": "No tienes suficientes permisos", - "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", - "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos basicos de una orden con artículos", - "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no esta permitido el uso de la letra ñ", - "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", - "You can't create a ticket for a inactive client": "No puedes crear un ticket para un cliente inactivo", - "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", - "ORDER_EMPTY": "Cesta vacía", - "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", - "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", - "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", - "Street cannot be empty": "Dirección no puede estar en blanco", - "City cannot be empty": "Cuidad no puede estar en blanco", - "Code cannot be blank": "Código no puede estar en blanco", - "You cannot remove this department": "No puedes eliminar este departamento", - "The extension must be unique": "La extensión debe ser unica", - "The secret can't be blank": "La contraseña no puede estar en blanco", - "We weren't able to send this SMS": "No hemos podido enviar el SMS", - "This client can't be invoiced": "Este cliente no puede ser facturado", - "This ticket can't be invoiced": "Este ticket no puede ser facturado", - "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", - "This ticket can not be modified": "Este ticket no puede ser modificado", - "The introduced hour already exists": "Esta hora ya ha sido introducida", - "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", - "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", - "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", - "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", - "The current ticket can't be modified": "El ticket actual no puede ser modificado", - "The current claim can't be modified": "La reclamación actual no puede ser modificada", - "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", - "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", - "Please select at least one sale": "Por favor selecciona al menos una linea", - "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", - "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", - "This item doesn't exists": "El artículo no existe", - "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", - "Extension format is invalid": "El formato de la extensión es inválido", - "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket", - "This item is not available": "Este artículo no está disponible", - "This postcode already exists": "Este código postal ya existe", - "Concept cannot be blank": "El concepto no puede quedar en blanco", - "File doesn't exists": "El archivo no existe", - "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", - "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", - "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", - "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", - "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", - "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", - "Invalid quantity": "Cantidad invalida", - "This postal code is not valid": "This postal code is not valid", - "is invalid": "is invalid", - "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", - "The department name can't be repeated": "El nombre del departamento no puede repetirse", - "This phone already exists": "Este teléfono ya existe", - "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos", - "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado", - "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", - "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", - "You should specify a date": "Debes especificar una fecha", - "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fín", - "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fín", - "You should mark at least one week day": "Debes marcar al menos un día de la semana", - "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", - "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", - "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", - "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", - "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "State": "Estado", - "regular": "normal", - "reserved": "reservado", - "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", - "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", - "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", - "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}", - "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*", - "Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*", - "Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*", - "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", - "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", - "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", - "This ticket is deleted": "Este ticket está eliminado", - "Unable to clone this travel": "No ha sido posible clonar este travel", - "This thermograph id already exists": "La id del termógrafo ya existe", - "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", - "ORDER_ALREADY_CONFIRMED": "ORDER_ALREADY_CONFIRMED", - "Invalid password": "Invalid password", - "Password does not meet requirements": "La contraseña no cumple los requisitos", - "Role already assigned": "Role already assigned", - "Invalid role name": "Invalid role name", - "Role name must be written in camelCase": "Role name must be written in camelCase", - "Email already exists": "Email already exists", - "User already exists": "User already exists", - "Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral", - "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", - "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", - "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", - "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})", - "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})", - "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación", - "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "agencyModeFk": "Agencia", - "clientFk": "Cliente", - "zoneFk": "Zona", - "warehouseFk": "Almacén", - "shipped": "F. envío", - "landed": "F. entrega", - "addressFk": "Consignatario", - "companyFk": "Empresa", - "The social name cannot be empty": "La razón social no puede quedar en blanco", - "The nif cannot be empty": "El NIF no puede quedar en blanco", - "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados", - "ASSIGN_ZONE_FIRST": "Asigna una zona primero", - "Amount cannot be zero": "El importe no puede ser cero", - "Company has to be official": "Empresa inválida", - "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", - "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", - "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", - "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", - "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", - "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", - "This BIC already exist.": "Este BIC ya existe.", - "That item doesn't exists": "Ese artículo no existe", - "There's a new urgent ticket:": "Hay un nuevo ticket urgente:", - "Invalid account": "Cuenta inválida", - "Compensation account is empty": "La cuenta para compensar está vacia", - "This genus already exist": "Este genus ya existe", - "This specie already exist": "Esta especie ya existe", - "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "None": "Ninguno", - "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", - "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'", - "This document already exists on this ticket": "Este documento ya existe en el ticket", - "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables", - "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes", - "nickname": "nickname", - "INACTIVE_PROVIDER": "Proveedor inactivo", - "This client is not invoiceable": "Este cliente no es facturable", - "serial non editable": "Esta serie no permite asignar la referencia", - "Max shipped required": "La fecha límite es requerida", - "Can't invoice to future": "No se puede facturar a futuro", - "Can't invoice to past": "No se puede facturar a pasado", - "This ticket is already invoiced": "Este ticket ya está facturado", - "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero", - "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa", - "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes", - "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", - "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", - "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", - "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", - "Amounts do not match": "Las cantidades no coinciden", - "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", - "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", - "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", - "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", - "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", - "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado", - "Can't transfer claimed sales": "No puedes transferir lineas reclamadas", - "You don't have privileges to create refund": "No tienes permisos para crear un abono", - "The item is required": "El artículo es requerido", - "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", - "date in the future": "Fecha en el futuro", - "reference duplicated": "Referencia duplicada", - "This ticket is already a refund": "Este ticket ya es un abono", - "isWithoutNegatives": "isWithoutNegatives", - "routeFk": "routeFk", - "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", - "No hay un contrato en vigor": "No hay un contrato en vigor", - "No se permite fichar a futuro": "No se permite fichar a futuro", - "No está permitido trabajar": "No está permitido trabajar", - "Fichadas impares": "Fichadas impares", - "Descanso diario 12h.": "Descanso diario 12h.", - "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", - "Dirección incorrecta": "Dirección incorrecta", - "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", - "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route does not exists": "Esta ruta no existe", - "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", - "You don't have grant privilege": "No tienes privilegios para dar privilegios", - "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", - "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "Already has this status": "Ya tiene este estado", - "There aren't records for this week": "No existen registros para esta semana", - "Empty data source": "Origen de datos vacio", - "App locked": "Aplicación bloqueada por el usuario {{userId}}", - "Email verify": "Correo de verificación", - "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", - "Receipt's bank was not found": "No se encontró el banco del recibo", - "This receipt was not compensated": "Este recibo no ha sido compensado", - "Client's email was not found": "No se encontró el email del cliente", - "Negative basis": "Base negativa", - "This worker code already exists": "Este codigo de trabajador ya existe", - "This personal mail already exists": "Este correo personal ya existe", - "This worker already exists": "Este trabajador ya existe", - "App name does not exist": "El nombre de aplicación no es válido", - "Try again": "Vuelve a intentarlo", - "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", - "Failed to upload delivery note": "Error al subir albarán {{id}}", - "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", - "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", - "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", - "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas", - "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", - "There is no assigned email for this client": "No hay correo asignado para este cliente", - "Exists an invoice with a future date": "Existe una factura con fecha posterior", - "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", - "Warehouse inventory not set": "El almacén inventario no está establecido", - "This locker has already been assigned": "Esta taquilla ya ha sido asignada", - "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %d", - "Not exist this branch": "La rama no existe", - "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", - "Collection does not exist": "La colección no existe", - "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", - "Insert a date range": "Inserte un rango de fechas", - "Added observation": "{{user}} añadió esta observacion: {{text}}", - "Comment added to client": "Observación añadida al cliente {{clientFk}}", - "Invalid auth code": "Código de verificación incorrecto", - "Invalid or expired verification code": "Código de verificación incorrecto o expirado", - "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", - "company": "Compañía", - "country": "País", - "clientId": "Id cliente", - "clientSocialName": "Cliente", - "amount": "Importe", - "taxableBase": "Base", - "ticketFk": "Id ticket", - "isActive": "Activo", - "hasToInvoice": "Facturar", - "isTaxDataChecked": "Datos comprobados", - "comercialId": "Id comercial", - "comercialName": "Comercial", - "Pass expired": "La contraseña ha caducado, cambiela desde Salix", - "Invalid NIF for VIES": "Invalid NIF for VIES", - "Ticket does not exist": "Este ticket no existe", - "Ticket is already signed": "Este ticket ya ha sido firmado", - "Authentication failed": "Autenticación fallida", - "You can't use the same password": "No puedes usar la misma contraseña", - "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono", - "Fecha fuera de rango": "Fecha fuera de rango", - "Error while generating PDF": "Error al generar PDF", - "Error when sending mail to client": "Error al enviar el correo al cliente", - "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", - "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", - "Valid priorities": "Prioridades válidas: %d", - "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", - "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", - "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s", - "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", - "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", - "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado", - "You don't have enough privileges.": "No tienes suficientes permisos.", - "This ticket is locked.": "Este ticket está bloqueado.", - "This ticket is not editable.": "Este ticket no es editable.", - "The ticket doesn't exist.": "No existe el ticket.", -<<<<<<< HEAD - "There are missing fields.": "There are missing fields." -} -======= - "Social name should be uppercase": "La razón social debe ir en mayúscula", - "Street should be uppercase": "La dirección fiscal debe ir en mayúscula" -} ->>>>>>> ce78fc8e5dd383b3c6457fe5f78a45b21b246858 + "The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", + "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", + "Amount cannot be zero": "Amount cannot be zero", + "Period cannot be blank": "Period cannot be blank", + "Sample type cannot be blank": "Sample type cannot be blank", + "Cannot be blank": "Cannot be blank", + "The social name cannot be empty": "The social name cannot be empty", + "Concept cannot be blank": "Concept cannot be blank", + "Enter an integer different to zero": "Enter an integer different to zero", + "Package cannot be blank": "Package cannot be blank", + "State cannot be blank": "State cannot be blank", + "Worker cannot be blank": "Worker cannot be blank", + "Description cannot be blank": "Description cannot be blank", + "Agency cannot be blank": "Agency cannot be blank", + "The renew period has not been exceeded": "The renew period has not been exceeded" +} \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js b/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js index a48664b30..e13ec0255 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js +++ b/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js @@ -23,7 +23,7 @@ module.exports = Self => { } }); - Self.makePdfAndNotify = async function(ctx, id, printerFk) { + Self.makePdfAndNotify = async function(ctx, id, printerFk, options) { const models = Self.app.models; options = typeof options == 'object' diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js similarity index 76% rename from modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js rename to modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index 440ebe4d3..c590ff9ea 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoiceOut.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('transferInvoiceOut', { - description: 'Transfer an invoice out to another client', + Self.remoteMethodCtx('transferInvoice', { + description: 'Transfer an issued invoice to another client', accessType: 'WRITE', accepts: [ { @@ -49,7 +49,6 @@ module.exports = Self => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; - if (typeof options == 'object') Object.assign(myOptions, options); @@ -59,15 +58,21 @@ module.exports = Self => { } try { // Refund tickets and group - const filter = {where: {refFk: ref}}; - const tickets = await models.Ticket.find(filter, myOptions); + const filterRef = {where: {refFk: ref}}; + const tickets = await models.Ticket.find(filterRef, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); await models.Ticket.refund(ctx, ticketsIds, null, myOptions); + // Clone tickets - const services = await models.TicketService.find(filter, myOptions); + const filterTicket = {where: {ticketFk: {inq: ticketsIds}}}; + + const services = await models.TicketService.find(filterTicket, myOptions); const servicesIds = services.map(service => service.id); - const sales = await models.Sale.find({where: {ticketFk: {inq: ticketsIds}}}, myOptions); - const clonedTickets = await models.Sale.clone(sales, servicesIds, null, false, false, myOptions); + + const sales = await models.Sale.find(filterTicket, myOptions); + const salesIds = sales.map(sale => sale.id); + + const clonedTickets = await models.Sale.clone(salesIds, servicesIds, null, false, false, myOptions); const clonedTicketIds = []; // Update client @@ -77,7 +82,8 @@ module.exports = Self => { } // Quick invoice - const invoiceId = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); + const invoiceIds = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); + const [invoiceId] = invoiceIds; // Insert InvoiceCorrection await models.InvoiceCorrection.create({ @@ -89,6 +95,10 @@ module.exports = Self => { }, myOptions); if (tx) await tx.commit(); + + // Crear PDF + await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); + return invoiceId; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index dc5c2a8e9..7d465f4ea 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -184,9 +184,9 @@ +
+
diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index ef69098c4..7d2644158 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -136,9 +136,9 @@ class Controller extends Section { invoiceCorrectionTypeId: this.invoiceCorrectionType }; this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => { - newInvoice = res.data;// id de la nueva factura - this.vnApp.showSucces(this.$t('Invoice trasfered!')); - this.$state.go('invoiceOut.index', {id: newInvoice}); + const invoiceId = res.data; + this.vnApp.showSuccess(this.$t('Invoice trasfered!')); + this.$state.go('invoiceOut.card.summary', {id: invoiceId}); }); } } diff --git a/modules/invoiceOut/front/descriptor-menu/style.scss b/modules/invoiceOut/front/descriptor-menu/style.scss index b68301961..25c02c80c 100644 --- a/modules/invoiceOut/front/descriptor-menu/style.scss +++ b/modules/invoiceOut/front/descriptor-menu/style.scss @@ -21,4 +21,10 @@ vn-invoice-out-descriptor-menu { font-size: 1.75rem; } } -} \ No newline at end of file + +} +@media screen and (min-width: 1000px) { + .transferInvoice { + min-width: 900px; + } +} diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index 7d52fd0e6..9a3b5fedc 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.clone = async(sales, servicesIds, withWarehouse, group, negative, options) => { + Self.clone = async(salesIds, servicesIds, withWarehouse, group, negative, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -12,91 +12,142 @@ module.exports = Self => { myOptions.transaction = tx; } - const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - const now = Date.vnNew(); - let updatedTickets = []; - let newTicket; - const filter = { - include: [ - {relation: 'address'}, - { - relation: 'sale', - where: {saleFk: {inq: sales}}, - }, - ] - }; try { - for (const [index, ticketId] of ticketsIds.entries()) { - const ticket = await models.Ticket.findById(ticketId, filter, myOptions); - if (!group || !index) { - newTicket = await models.Ticket.create({ - clientFk: ticket.clientFk, - shipped: now, - addressFk: ticket.address().id, - nickname: ticket.address().nickname, - warehouseFk: withWarehouse ? ticket.warehouseFk : null, - companyFk: ticket.companyFk, - landed: now, - }, myOptions); - updatedTickets.push(newTicket); - } - const salesByTicket = ticket.sale(); - const saleIds = salesByTicket.map(sale => sale.id); - const saleComponentsFilter = { - where: {saleFk: {inq: saleIds}}, + const salesFilter = { + where: {id: {inq: salesIds}}, + include: { + relation: 'components', scope: { fields: ['saleFk', 'componentFk', 'value'] } - }; - for (const sale of salesByTicket) { - const createdSale = await models.Sale.create({ - ticketFk: newTicket.id, - itemFk: sale.itemFk, - quantity: (negative) ? - sale.quantity : sale.quantity, - concept: sale.concept, - price: sale.price, - discount: sale.discount, - }, myOptions); - const components = await models.SaleComponent.find(saleComponentsFilter, myOptions); // Revisar con Alex - // const components = sale.components(); - for (const component of components) - component.saleFk = createdSale.id; + } + }; + const sales = await models.Sale.find(salesFilter, myOptions); + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - await models.SaleComponent.create(components, myOptions); + const refundTickets = []; + const mappedTickets = new Map(); + const now = Date.vnNew(); + + const [firstTicketId] = ticketsIds; + if (group) { + await createTicketRefund( + firstTicketId, + withWarehouse, + refundTickets, + mappedTickets, + now, + myOptions + ); + } else { + for (let ticketId of ticketsIds) { + await createTicketRefund( + ticketId, + withWarehouse, + refundTickets, + mappedTickets, + now, + myOptions + ); } } + + for (const sale of sales) { + const refundTicketId = await getTicketRefundId(group, sale.ticketFk, refundTickets, mappedTickets); + + const createdSale = await models.Sale.create({ + ticketFk: refundTicketId, + itemFk: sale.itemFk, + quantity: negative ? - sale.quantity : sale.quantity, + concept: sale.concept, + price: sale.price, + discount: sale.discount, + }, myOptions); + + const components = sale.components(); + for (const component of components) + component.saleFk = createdSale.id; + + await models.SaleComponent.create(components, myOptions); + } + if (servicesIds && servicesIds.length > 0) { 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); + await models.TicketService.create({ description: service.description, - quantity: (negative) ? - service.quantity : service.quantity, + quantity: negative ? - service.quantity : service.quantity, price: service.price, taxClassFk: service.taxClassFk, - ticketFk: service.ticketFk, + ticketFk: refundTicketId, ticketServiceTypeFk: service.ticketServiceTypeFk, }, myOptions); } } - const query = `CALL vn.ticket_recalc(?, NULL)`; + if (tx) await tx.commit(); - if (group) { - await Self.rawSql(query, [newTicket.id], myOptions); - if (tx) await tx.commit(); - return newTicket; - } else { - for (const updatedTicket of updatedTickets) - await Self.rawSql(query, [updatedTicket.id], myOptions); - if (tx) await tx.commit(); - return /* updatedTickets */updatedTickets; - } + return refundTickets; } catch (e) { if (tx) await tx.rollback(); throw e; } }; + + async function createTicketRefund( + ticketId, + withWarehouse, + refundTickets, + mappedTickets, + now, + myOptions + ) { + const models = Self.app.models; + + const filter = { + include: [ + { + relation: 'address' + }, + { + relation: 'agencyMode' + }, + { + relation: 'zone' + } + ] + }; + const ticket = await models.Ticket.findById(ticketId, filter, myOptions); + const refundTicket = await models.Ticket.create({ + clientFk: ticket.clientFk, + shipped: now, + addressFk: ticket.address().id, + agencyModeFk: ticket.agencyMode().id, + nickname: ticket.address().nickname, + warehouseFk: withWarehouse ? ticket.warehouseFk : null, + companyFk: ticket.companyFk, + zonePrice: ticket.zonePrice, + zoneBonus: ticket.zoneBonus, + weight: ticket.weight, + landed: now, + zoneFk: ticket.zone().id, + }, myOptions); + + refundTickets.push(refundTicket); + + mappedTickets.set(ticketId, refundTicket.id); + } + + async function getTicketRefundId(group, ticketId, refundTickets, mappedTickets) { + if (group) { + const [firstRefundTicket] = refundTickets; + return firstRefundTicket.id; + } else return mappedTickets.get(ticketId); + } }; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index dabafb469..3f7e1cd21 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -64,27 +64,19 @@ module.exports = Self => { } } }; - const sales = await models.Sale.find(salesFilter, myOptions); + // const sales = await models.Sale.find(salesFilter, myOptions); const refundTicket = await models.Sale.clone( - sales, - refundAgencyMode, - refoundZoneId, + salesIds, servicesIds, withWarehouse, + // refundAgencyMode, + // refoundZoneId, true, true, myOptions ); - const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - for (const ticketId of ticketsIds) { - await models.TicketRefund.create({ - refundTicketFk: refundTicket.id, - originalTicketFk: ticketId, - }, myOptions); - } - - if (tx) await tx.commit(); + if (tx && !options) await tx.commit(); return refundTicket; } catch (e) { diff --git a/modules/ticket/back/methods/ticket/invoiceTickets.js b/modules/ticket/back/methods/ticket/invoiceTickets.js index 7baee133d..e65c14e9a 100644 --- a/modules/ticket/back/methods/ticket/invoiceTickets.js +++ b/modules/ticket/back/methods/ticket/invoiceTickets.js @@ -77,10 +77,9 @@ module.exports = function(Self) { if (tx) await tx.rollback(); throw e; } - console.log(invoicesIds, 'invoicesIds'); - for (const invoiceId of invoicesIds) { - console.log(await models.InvoiceOut.find()); - await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); + if (tx) { + for (const invoiceId of invoicesIds) + await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null, myOptions); } return invoicesIds; @@ -100,7 +99,6 @@ module.exports = function(Self) { `, [ticketsIds], myOptions); const invoiceId = await models.Ticket.makeInvoice(ctx, 'R', companyId, Date.vnNew(), myOptions); - console.log(await models.InvoiceOut.find(null, myOptions)); invoicesIds.push(invoiceId); } }; diff --git a/modules/ticket/back/methods/ticket/invoiceTicketsWithPdf.js b/modules/ticket/back/methods/ticket/invoiceTicketsWithPdf.js new file mode 100644 index 000000000..e69de29bb diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js index 1c9965d3b..4424c8ea3 100755 --- a/print/templates/reports/invoice/invoice.js +++ b/print/templates/reports/invoice/invoice.js @@ -6,7 +6,10 @@ module.exports = { name: 'invoice', mixins: [vnReport], async serverPrefetch() { + console.log(this.reference); this.invoice = await this.findOneFromDef('invoice', [this.reference]); + console.log(this.invoice); + this.checkMainEntity(this.invoice); this.client = await this.findOneFromDef('client', [this.reference]); this.taxes = await this.rawSqlFromDef(`taxes`, [this.reference]); From 4870b0830b720ba609afe4880d2b8f3813759aa6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 20 Sep 2023 11:06:30 +0200 Subject: [PATCH 08/32] ref #5914 fix refund and change method name --- .../00-transferInvoiceACL.sql} | 2 +- loopback/locale/es.json | 304 +----------------- .../methods/invoiceOut/transferInvoice.js | 2 +- modules/invoiceOut/back/models/invoice-out.js | 2 +- modules/ticket/back/methods/sale/refund.js | 83 +---- 5 files changed, 13 insertions(+), 380 deletions(-) rename db/changes/{233201/00-transferInvoiceOutACL.sql => 233601/00-transferInvoiceACL.sql} (80%) diff --git a/db/changes/233201/00-transferInvoiceOutACL.sql b/db/changes/233601/00-transferInvoiceACL.sql similarity index 80% rename from db/changes/233201/00-transferInvoiceOutACL.sql rename to db/changes/233601/00-transferInvoiceACL.sql index 6e8d88c5d..a45e3f479 100644 --- a/db/changes/233201/00-transferInvoiceOutACL.sql +++ b/db/changes/233601/00-transferInvoiceACL.sql @@ -3,4 +3,4 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp ('CplusRectificationType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), ('CplusInvoiceType477', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), ('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('InvoiceOut', 'transferInvoiceOut', 'WRITE', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file + ('InvoiceOut', 'transferInvoice', 'WRITE', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index b2c6ae3e9..d436ec197 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -8,7 +8,6 @@ "Invalid email": "Invalid email", "Phone cannot be blank": "Phone cannot be blank", "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", -<<<<<<< HEAD "The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", "Amount cannot be zero": "Amount cannot be zero", @@ -22,304 +21,5 @@ "State cannot be blank": "State cannot be blank", "Worker cannot be blank": "Worker cannot be blank", "Description cannot be blank": "Description cannot be blank", - "Agency cannot be blank": "Agency cannot be blank", - "The renew period has not been exceeded": "The renew period has not been exceeded" -} -======= - "The grade must be similar to the last one": "El grade debe ser similar al último", - "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", - "Name cannot be blank": "El nombre no puede estar en blanco", - "Phone cannot be blank": "El teléfono no puede estar en blanco", - "Period cannot be blank": "El periodo no puede estar en blanco", - "Choose a company": "Selecciona una empresa", - "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto", - "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres", - "Cannot be blank": "El campo no puede estar en blanco", - "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero", - "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco", - "Description cannot be blank": "Se debe rellenar el campo de texto", - "The new quantity should be smaller than the old one": "La nueva cantidad debe de ser menor que la anterior", - "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%", - "The value should be a number": "El valor debe ser un numero", - "This order is not editable": "Esta orden no se puede modificar", - "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado", - "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda", - "is not a valid date": "No es una fecha valida", - "Barcode must be unique": "El código de barras debe ser único", - "The warehouse can't be repeated": "El almacén no puede repetirse", - "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item", - "The observation type can't be repeated": "El tipo de observación no puede repetirse", - "A claim with that sale already exists": "Ya existe una reclamación para esta línea", - "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo", - "Warehouse cannot be blank": "El almacén no puede quedar en blanco", - "Agency cannot be blank": "La agencia no puede quedar en blanco", - "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados", - "This address doesn't exist": "Este consignatario no existe", - "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", - "You don't have enough privileges": "No tienes suficientes permisos", - "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", - "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos basicos de una orden con artículos", - "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no esta permitido el uso de la letra ñ", - "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", - "You can't create a ticket for a inactive client": "No puedes crear un ticket para un cliente inactivo", - "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", - "ORDER_EMPTY": "Cesta vacía", - "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", - "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", - "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", - "Street cannot be empty": "Dirección no puede estar en blanco", - "City cannot be empty": "Cuidad no puede estar en blanco", - "Code cannot be blank": "Código no puede estar en blanco", - "You cannot remove this department": "No puedes eliminar este departamento", - "The extension must be unique": "La extensión debe ser unica", - "The secret can't be blank": "La contraseña no puede estar en blanco", - "We weren't able to send this SMS": "No hemos podido enviar el SMS", - "This client can't be invoiced": "Este cliente no puede ser facturado", - "This ticket can't be invoiced": "Este ticket no puede ser facturado", - "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", - "This ticket can not be modified": "Este ticket no puede ser modificado", - "The introduced hour already exists": "Esta hora ya ha sido introducida", - "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", - "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", - "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", - "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", - "The current ticket can't be modified": "El ticket actual no puede ser modificado", - "The current claim can't be modified": "La reclamación actual no puede ser modificada", - "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", - "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", - "Please select at least one sale": "Por favor selecciona al menos una linea", - "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", - "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", - "This item doesn't exists": "El artículo no existe", - "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", - "Extension format is invalid": "El formato de la extensión es inválido", - "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket", - "This item is not available": "Este artículo no está disponible", - "This postcode already exists": "Este código postal ya existe", - "Concept cannot be blank": "El concepto no puede quedar en blanco", - "File doesn't exists": "El archivo no existe", - "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", - "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", - "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", - "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", - "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", - "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", - "Invalid quantity": "Cantidad invalida", - "This postal code is not valid": "This postal code is not valid", - "is invalid": "is invalid", - "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", - "The department name can't be repeated": "El nombre del departamento no puede repetirse", - "This phone already exists": "Este teléfono ya existe", - "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos", - "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado", - "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", - "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", - "You should specify a date": "Debes especificar una fecha", - "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fín", - "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fín", - "You should mark at least one week day": "Debes marcar al menos un día de la semana", - "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", - "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", - "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", - "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", - "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "State": "Estado", - "regular": "normal", - "reserved": "reservado", - "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", - "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", - "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", - "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}", - "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*", - "Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*", - "Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*", - "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", - "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", - "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", - "This ticket is deleted": "Este ticket está eliminado", - "Unable to clone this travel": "No ha sido posible clonar este travel", - "This thermograph id already exists": "La id del termógrafo ya existe", - "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", - "ORDER_ALREADY_CONFIRMED": "ORDER_ALREADY_CONFIRMED", - "Invalid password": "Invalid password", - "Password does not meet requirements": "La contraseña no cumple los requisitos", - "Role already assigned": "Role already assigned", - "Invalid role name": "Invalid role name", - "Role name must be written in camelCase": "Role name must be written in camelCase", - "Email already exists": "Email already exists", - "User already exists": "User already exists", - "Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral", - "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", - "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", - "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", - "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})", - "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})", - "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación", - "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "agencyModeFk": "Agencia", - "clientFk": "Cliente", - "zoneFk": "Zona", - "warehouseFk": "Almacén", - "shipped": "F. envío", - "landed": "F. entrega", - "addressFk": "Consignatario", - "companyFk": "Empresa", - "The social name cannot be empty": "La razón social no puede quedar en blanco", - "The nif cannot be empty": "El NIF no puede quedar en blanco", - "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados", - "ASSIGN_ZONE_FIRST": "Asigna una zona primero", - "Amount cannot be zero": "El importe no puede ser cero", - "Company has to be official": "Empresa inválida", - "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", - "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", - "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", - "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", - "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", - "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", - "This BIC already exist.": "Este BIC ya existe.", - "That item doesn't exists": "Ese artículo no existe", - "There's a new urgent ticket:": "Hay un nuevo ticket urgente:", - "Invalid account": "Cuenta inválida", - "Compensation account is empty": "La cuenta para compensar está vacia", - "This genus already exist": "Este genus ya existe", - "This specie already exist": "Esta especie ya existe", - "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "None": "Ninguno", - "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", - "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'", - "This document already exists on this ticket": "Este documento ya existe en el ticket", - "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables", - "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes", - "nickname": "nickname", - "INACTIVE_PROVIDER": "Proveedor inactivo", - "This client is not invoiceable": "Este cliente no es facturable", - "serial non editable": "Esta serie no permite asignar la referencia", - "Max shipped required": "La fecha límite es requerida", - "Can't invoice to future": "No se puede facturar a futuro", - "Can't invoice to past": "No se puede facturar a pasado", - "This ticket is already invoiced": "Este ticket ya está facturado", - "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero", - "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa", - "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes", - "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", - "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", - "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", - "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", - "Amounts do not match": "Las cantidades no coinciden", - "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", - "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", - "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", - "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", - "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", - "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado", - "Can't transfer claimed sales": "No puedes transferir lineas reclamadas", - "You don't have privileges to create refund": "No tienes permisos para crear un abono", - "The item is required": "El artículo es requerido", - "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", - "date in the future": "Fecha en el futuro", - "reference duplicated": "Referencia duplicada", - "This ticket is already a refund": "Este ticket ya es un abono", - "isWithoutNegatives": "isWithoutNegatives", - "routeFk": "routeFk", - "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", - "No hay un contrato en vigor": "No hay un contrato en vigor", - "No se permite fichar a futuro": "No se permite fichar a futuro", - "No está permitido trabajar": "No está permitido trabajar", - "Fichadas impares": "Fichadas impares", - "Descanso diario 12h.": "Descanso diario 12h.", - "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", - "Dirección incorrecta": "Dirección incorrecta", - "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", - "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route does not exists": "Esta ruta no existe", - "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", - "You don't have grant privilege": "No tienes privilegios para dar privilegios", - "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", - "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "Already has this status": "Ya tiene este estado", - "There aren't records for this week": "No existen registros para esta semana", - "Empty data source": "Origen de datos vacio", - "App locked": "Aplicación bloqueada por el usuario {{userId}}", - "Email verify": "Correo de verificación", - "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", - "Receipt's bank was not found": "No se encontró el banco del recibo", - "This receipt was not compensated": "Este recibo no ha sido compensado", - "Client's email was not found": "No se encontró el email del cliente", - "Negative basis": "Base negativa", - "This worker code already exists": "Este codigo de trabajador ya existe", - "This personal mail already exists": "Este correo personal ya existe", - "This worker already exists": "Este trabajador ya existe", - "App name does not exist": "El nombre de aplicación no es válido", - "Try again": "Vuelve a intentarlo", - "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", - "Failed to upload delivery note": "Error al subir albarán {{id}}", - "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", - "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", - "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", - "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas", - "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", - "There is no assigned email for this client": "No hay correo asignado para este cliente", - "Exists an invoice with a future date": "Existe una factura con fecha posterior", - "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", - "Warehouse inventory not set": "El almacén inventario no está establecido", - "This locker has already been assigned": "Esta taquilla ya ha sido asignada", - "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %d", - "Not exist this branch": "La rama no existe", - "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", - "Collection does not exist": "La colección no existe", - "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", - "Insert a date range": "Inserte un rango de fechas", - "Added observation": "{{user}} añadió esta observacion: {{text}}", - "Comment added to client": "Observación añadida al cliente {{clientFk}}", - "Invalid auth code": "Código de verificación incorrecto", - "Invalid or expired verification code": "Código de verificación incorrecto o expirado", - "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", - "company": "Compañía", - "country": "País", - "clientId": "Id cliente", - "clientSocialName": "Cliente", - "amount": "Importe", - "taxableBase": "Base", - "ticketFk": "Id ticket", - "isActive": "Activo", - "hasToInvoice": "Facturar", - "isTaxDataChecked": "Datos comprobados", - "comercialId": "Id comercial", - "comercialName": "Comercial", - "Pass expired": "La contraseña ha caducado, cambiela desde Salix", - "Invalid NIF for VIES": "Invalid NIF for VIES", - "Ticket does not exist": "Este ticket no existe", - "Ticket is already signed": "Este ticket ya ha sido firmado", - "Authentication failed": "Autenticación fallida", - "You can't use the same password": "No puedes usar la misma contraseña", - "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono", - "Fecha fuera de rango": "Fecha fuera de rango", - "Error while generating PDF": "Error al generar PDF", - "Error when sending mail to client": "Error al enviar el correo al cliente", - "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", - "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", - "Valid priorities": "Prioridades válidas: %d", - "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", - "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", - "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s", - "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", - "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", - "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado", - "You don't have enough privileges.": "No tienes suficientes permisos.", - "This ticket is locked.": "Este ticket está bloqueado.", - "This ticket is not editable.": "Este ticket no es editable.", - "The ticket doesn't exist.": "No existe el ticket.", - "Social name should be uppercase": "La razón social debe ir en mayúscula", - "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", - "The response is not a PDF": "La respuesta no es un PDF", - "Ticket without Route": "Ticket sin ruta" -} ->>>>>>> 72a8256aee7bff0be1dd68c8d4cfbe2edcf8ce60 + "Agency cannot be blank": "Agency cannot be blank" +} \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index c590ff9ea..0b123dd3d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -44,7 +44,7 @@ module.exports = Self => { } }); - Self.transferInvoiceOut = async(ctx, id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477Id, invoiceCorrectionTypeId, options) => { + Self.transferInvoice = async(ctx, id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477Id, invoiceCorrectionTypeId, options) => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index 0bb31ce12..ca77c856f 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -23,7 +23,7 @@ module.exports = Self => { require('../methods/invoiceOut/getInvoiceDate')(Self); require('../methods/invoiceOut/negativeBases')(Self); require('../methods/invoiceOut/negativeBasesCsv')(Self); - require('../methods/invoiceOut/transferInvoiceOut')(Self); + require('../methods/invoiceOut/transferInvoice')(Self); Self.filePath = async function(id, options) { const fields = ['ref', 'issued']; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 303d830b6..3f7e1cd21 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -5,7 +5,8 @@ module.exports = Self => { accepts: [ { arg: 'salesIds', - type: ['number'] + type: ['number'], + required: true }, { arg: 'servicesIds', @@ -40,7 +41,6 @@ module.exports = Self => { myOptions.transaction = tx; } - let refundTicket = null; try { const refundAgencyMode = await models.AgencyMode.findOne({ include: { @@ -55,42 +55,14 @@ module.exports = Self => { const refoundZoneId = refundAgencyMode.zones()[0].id; - if (salesIds) { - const salesFilter = { - where: {id: {inq: salesIds}}, - include: { - relation: 'components', - scope: { - fields: ['saleFk', 'componentFk', 'value'] - } + const salesFilter = { + where: {id: {inq: salesIds}}, + include: { + relation: 'components', + scope: { + fields: ['saleFk', 'componentFk', 'value'] } - }; - const sales = await models.Sale.find(salesFilter, myOptions); - const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - - const now = Date.vnNew(); - const [firstTicketId] = ticketsIds; - - // eslint-disable-next-line max-len - refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions); - - for (const sale of sales) { - const createdSale = await models.Sale.create({ - ticketFk: refundTicket.id, - itemFk: sale.itemFk, - quantity: - sale.quantity, - concept: sale.concept, - price: sale.price, - discount: sale.discount, - }, myOptions); - - const components = sale.components(); - for (const component of components) - component.saleFk = createdSale.id; - - await models.SaleComponent.create(components, myOptions); } -<<<<<<< HEAD }; // const sales = await models.Sale.find(salesFilter, myOptions); const refundTicket = await models.Sale.clone( @@ -105,45 +77,6 @@ module.exports = Self => { ); if (tx && !options) await tx.commit(); -======= - } - - if (!refundTicket) { - const servicesFilter = { - where: {id: {inq: servicesIds}} - }; - const services = await models.TicketService.find(servicesFilter, myOptions); - const ticketsIds = [...new Set(services.map(service => service.ticketFk))]; - - const now = Date.vnNew(); - const [firstTicketId] = ticketsIds; - - // eslint-disable-next-line max-len - refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions); - } - - if (servicesIds && servicesIds.length > 0) { - const servicesFilter = { - where: {id: {inq: servicesIds}} - }; - const services = await models.TicketService.find(servicesFilter, myOptions); - for (const service of services) { - await models.TicketService.create({ - description: service.description, - quantity: service.quantity, - price: - service.price, - taxClassFk: service.taxClassFk, - ticketFk: refundTicket.id, - ticketServiceTypeFk: service.ticketServiceTypeFk, - }, myOptions); - } - } - - const query = `CALL vn.ticket_recalc(?, NULL)`; - await Self.rawSql(query, [refundTicket.id], myOptions); - - if (tx) await tx.commit(); ->>>>>>> 72a8256aee7bff0be1dd68c8d4cfbe2edcf8ce60 return refundTicket; } catch (e) { From ac4aea7d38f6d0492561606818af213c3ef1698f Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 21 Sep 2023 09:14:46 +0200 Subject: [PATCH 09/32] ref #5914 created transfer issued invoice --- db/dump/fixtures.sql | 17 +- loopback/locale/en.json | 10 +- loopback/locale/es.json | 341 ++++++++++++++++-- .../methods/invoiceOut/transferInvoice.js | 39 +- modules/ticket/back/methods/sale/clone.js | 1 - modules/ticket/back/methods/sale/refund.js | 55 +-- .../back/methods/sale/specs/refund.spec.js | 2 +- 7 files changed, 351 insertions(+), 114 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 691f7e6df..bb46880bd 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -604,7 +604,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES - (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), @@ -2966,20 +2966,6 @@ INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`) VALUES (1, 0, 0, 'marvel.com'); -<<<<<<< HEAD -INSERT INTO `vn`.`cplusCorrectingType` (`description`) - VALUES - ('Embalajes'), - ('Anulación'), - ('Impagado'), - ('Moroso'); - -INSERT INTO `vn`.`invoiceCorrectionType` (`description`) - VALUES - ('Error en el cálculo del IVA'), - ('Error en el detalle de las ventas'), - ('Error en los datos del cliente'); -======= INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, BASEEURO, SERIE, FACTURA, IVA, RECEQUIV, CLAVE, CAMBIO, DEBEME, HABERME, AUXILIAR, MONEDAUSO, TIPOOPE, NFACTICK, TERIDNIF, TERNIF, TERNOM, OPBIENES, L340, enlazado, FECHA_EX, LRECT349, empresa_id, LDIFADUAN, METAL, METALIMP, CLIENTE, METALEJE, FECHA_OP, FACTURAEX, TIPOCLAVE, TIPOEXENCI, TIPONOSUJE, TIPOFACT, TIPORECTIF, SERIE_RT, FACTU_RT, BASEIMP_RT, BASEIMP_RF, RECTIFICA, FECHA_RT, FECREGCON, enlazadoSage) VALUES (1, 1.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T3333333', 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, 1), @@ -2988,4 +2974,3 @@ 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); ->>>>>>> 72a8256aee7bff0be1dd68c8d4cfbe2edcf8ce60 diff --git a/loopback/locale/en.json b/loopback/locale/en.json index fb4e72bd6..3755c4a67 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -187,5 +187,11 @@ "This ticket is not editable.": "This ticket is not editable.", "The ticket doesn't exist.": "The ticket doesn't exist.", "The sales do not exists": "The sales do not exists", - "Ticket without Route": "Ticket without route" -} + "Ticket without Route": "Ticket without route", + "Select a different customer": "Select a different customer", + "Fill all the fields": "Fill all the fields", + "Error while generating PDF": "Error while generating PDF", + "Can't invoice to future": "Can't invoice to future", + "This ticket is already invoiced": "This ticket is already invoiced", + "Negative basis of tickets: 23": "Negative basis of tickets: 23" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d436ec197..f5973dcb7 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -1,25 +1,322 @@ { - "Name cannot be blank": "Name cannot be blank", - "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", - "Social name should be uppercase": "Social name should be uppercase", - "Street cannot be empty": "Street cannot be empty", - "Street should be uppercase": "Street should be uppercase", - "City cannot be empty": "City cannot be empty", - "Invalid email": "Invalid email", - "Phone cannot be blank": "Phone cannot be blank", + "Phone format is invalid": "El formato del teléfono no es correcto", + "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito", + "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia", + "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado", + "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado", + "Can't be blank": "No puede estar en blanco", + "Invalid TIN": "NIF/CIF invalido", + "TIN must be unique": "El NIF/CIF debe ser único", + "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", + "Is invalid": "Is invalid", + "Quantity cannot be zero": "La cantidad no puede ser cero", + "Enter an integer different to zero": "Introduce un entero distinto de cero", + "Package cannot be blank": "El embalaje no puede estar en blanco", + "The company name must be unique": "La razón social debe ser única", + "Invalid email": "Correo electrónico inválido", + "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto", + "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN", + "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC", + "State cannot be blank": "El estado no puede estar en blanco", + "Worker cannot be blank": "El trabajador no puede estar en blanco", + "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado", + "can't be blank": "El campo no puede estar vacío", + "Observation type must be unique": "El tipo de observación no puede repetirse", "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", - "The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", - "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", - "Amount cannot be zero": "Amount cannot be zero", - "Period cannot be blank": "Period cannot be blank", - "Sample type cannot be blank": "Sample type cannot be blank", - "Cannot be blank": "Cannot be blank", - "The social name cannot be empty": "The social name cannot be empty", - "Concept cannot be blank": "Concept cannot be blank", - "Enter an integer different to zero": "Enter an integer different to zero", - "Package cannot be blank": "Package cannot be blank", - "State cannot be blank": "State cannot be blank", - "Worker cannot be blank": "Worker cannot be blank", - "Description cannot be blank": "Description cannot be blank", - "Agency cannot be blank": "Agency cannot be blank" + "The grade must be similar to the last one": "El grade debe ser similar al último", + "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", + "Name cannot be blank": "El nombre no puede estar en blanco", + "Phone cannot be blank": "El teléfono no puede estar en blanco", + "Period cannot be blank": "El periodo no puede estar en blanco", + "Choose a company": "Selecciona una empresa", + "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto", + "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres", + "Cannot be blank": "El campo no puede estar en blanco", + "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero", + "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco", + "Description cannot be blank": "Se debe rellenar el campo de texto", + "The new quantity should be smaller than the old one": "La nueva cantidad debe de ser menor que la anterior", + "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%", + "The value should be a number": "El valor debe ser un numero", + "This order is not editable": "Esta orden no se puede modificar", + "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado", + "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda", + "is not a valid date": "No es una fecha valida", + "Barcode must be unique": "El código de barras debe ser único", + "The warehouse can't be repeated": "El almacén no puede repetirse", + "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item", + "The observation type can't be repeated": "El tipo de observación no puede repetirse", + "A claim with that sale already exists": "Ya existe una reclamación para esta línea", + "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo", + "Warehouse cannot be blank": "El almacén no puede quedar en blanco", + "Agency cannot be blank": "La agencia no puede quedar en blanco", + "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados", + "This address doesn't exist": "Este consignatario no existe", + "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", + "You don't have enough privileges": "No tienes suficientes permisos", + "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", + "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos basicos de una orden con artículos", + "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no esta permitido el uso de la letra ñ", + "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", + "You can't create a ticket for a inactive client": "No puedes crear un ticket para un cliente inactivo", + "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", + "ORDER_EMPTY": "Cesta vacía", + "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", + "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", + "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", + "Street cannot be empty": "Dirección no puede estar en blanco", + "City cannot be empty": "Cuidad no puede estar en blanco", + "Code cannot be blank": "Código no puede estar en blanco", + "You cannot remove this department": "No puedes eliminar este departamento", + "The extension must be unique": "La extensión debe ser unica", + "The secret can't be blank": "La contraseña no puede estar en blanco", + "We weren't able to send this SMS": "No hemos podido enviar el SMS", + "This client can't be invoiced": "Este cliente no puede ser facturado", + "This ticket can't be invoiced": "Este ticket no puede ser facturado", + "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", + "This ticket can not be modified": "Este ticket no puede ser modificado", + "The introduced hour already exists": "Esta hora ya ha sido introducida", + "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", + "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", + "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", + "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", + "The current ticket can't be modified": "El ticket actual no puede ser modificado", + "The current claim can't be modified": "La reclamación actual no puede ser modificada", + "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", + "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", + "Please select at least one sale": "Por favor selecciona al menos una linea", + "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", + "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", + "This item doesn't exists": "El artículo no existe", + "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", + "Extension format is invalid": "El formato de la extensión es inválido", + "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket", + "This item is not available": "Este artículo no está disponible", + "This postcode already exists": "Este código postal ya existe", + "Concept cannot be blank": "El concepto no puede quedar en blanco", + "File doesn't exists": "El archivo no existe", + "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", + "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", + "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", + "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", + "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", + "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", + "Invalid quantity": "Cantidad invalida", + "This postal code is not valid": "This postal code is not valid", + "is invalid": "is invalid", + "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", + "The department name can't be repeated": "El nombre del departamento no puede repetirse", + "This phone already exists": "Este teléfono ya existe", + "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos", + "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado", + "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", + "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", + "You should specify a date": "Debes especificar una fecha", + "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fín", + "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fín", + "You should mark at least one week day": "Debes marcar al menos un día de la semana", + "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", + "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", + "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", + "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", + "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", + "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "State": "Estado", + "regular": "normal", + "reserved": "reservado", + "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", + "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", + "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", + "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", + "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", + "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}", + "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*", + "Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*", + "Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*", + "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", + "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", + "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", + "This ticket is deleted": "Este ticket está eliminado", + "Unable to clone this travel": "No ha sido posible clonar este travel", + "This thermograph id already exists": "La id del termógrafo ya existe", + "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", + "ORDER_ALREADY_CONFIRMED": "ORDER_ALREADY_CONFIRMED", + "Invalid password": "Invalid password", + "Password does not meet requirements": "La contraseña no cumple los requisitos", + "Role already assigned": "Role already assigned", + "Invalid role name": "Invalid role name", + "Role name must be written in camelCase": "Role name must be written in camelCase", + "Email already exists": "Email already exists", + "User already exists": "User already exists", + "Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral", + "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", + "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", + "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", + "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})", + "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})", + "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación", + "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "agencyModeFk": "Agencia", + "clientFk": "Cliente", + "zoneFk": "Zona", + "warehouseFk": "Almacén", + "shipped": "F. envío", + "landed": "F. entrega", + "addressFk": "Consignatario", + "companyFk": "Empresa", + "The social name cannot be empty": "La razón social no puede quedar en blanco", + "The nif cannot be empty": "El NIF no puede quedar en blanco", + "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados", + "ASSIGN_ZONE_FIRST": "Asigna una zona primero", + "Amount cannot be zero": "El importe no puede ser cero", + "Company has to be official": "Empresa inválida", + "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", + "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", + "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", + "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", + "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", + "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", + "This BIC already exist.": "Este BIC ya existe.", + "That item doesn't exists": "Ese artículo no existe", + "There's a new urgent ticket:": "Hay un nuevo ticket urgente:", + "Invalid account": "Cuenta inválida", + "Compensation account is empty": "La cuenta para compensar está vacia", + "This genus already exist": "Este genus ya existe", + "This specie already exist": "Esta especie ya existe", + "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", + "None": "Ninguno", + "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", + "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'", + "This document already exists on this ticket": "Este documento ya existe en el ticket", + "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables", + "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes", + "nickname": "nickname", + "INACTIVE_PROVIDER": "Proveedor inactivo", + "This client is not invoiceable": "Este cliente no es facturable", + "serial non editable": "Esta serie no permite asignar la referencia", + "Max shipped required": "La fecha límite es requerida", + "Can't invoice to future": "No se puede facturar a futuro", + "Can't invoice to past": "No se puede facturar a pasado", + "This ticket is already invoiced": "Este ticket ya está facturado", + "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero", + "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa", + "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes", + "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", + "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", + "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", + "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", + "Amounts do not match": "Las cantidades no coinciden", + "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", + "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", + "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", + "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", + "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", + "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado", + "Can't transfer claimed sales": "No puedes transferir lineas reclamadas", + "You don't have privileges to create refund": "No tienes permisos para crear un abono", + "The item is required": "El artículo es requerido", + "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", + "date in the future": "Fecha en el futuro", + "reference duplicated": "Referencia duplicada", + "This ticket is already a refund": "Este ticket ya es un abono", + "isWithoutNegatives": "isWithoutNegatives", + "routeFk": "routeFk", + "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", + "No hay un contrato en vigor": "No hay un contrato en vigor", + "No se permite fichar a futuro": "No se permite fichar a futuro", + "No está permitido trabajar": "No está permitido trabajar", + "Fichadas impares": "Fichadas impares", + "Descanso diario 12h.": "Descanso diario 12h.", + "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", + "Dirección incorrecta": "Dirección incorrecta", + "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", + "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "This route does not exists": "Esta ruta no existe", + "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", + "You don't have grant privilege": "No tienes privilegios para dar privilegios", + "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", + "Already has this status": "Ya tiene este estado", + "There aren't records for this week": "No existen registros para esta semana", + "Empty data source": "Origen de datos vacio", + "App locked": "Aplicación bloqueada por el usuario {{userId}}", + "Email verify": "Correo de verificación", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", + "Receipt's bank was not found": "No se encontró el banco del recibo", + "This receipt was not compensated": "Este recibo no ha sido compensado", + "Client's email was not found": "No se encontró el email del cliente", + "Negative basis": "Base negativa", + "This worker code already exists": "Este codigo de trabajador ya existe", + "This personal mail already exists": "Este correo personal ya existe", + "This worker already exists": "Este trabajador ya existe", + "App name does not exist": "El nombre de aplicación no es válido", + "Try again": "Vuelve a intentarlo", + "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", + "Failed to upload delivery note": "Error al subir albarán {{id}}", + "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", + "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", + "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", + "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas", + "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", + "There is no assigned email for this client": "No hay correo asignado para este cliente", + "Exists an invoice with a future date": "Existe una factura con fecha posterior", + "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", + "Warehouse inventory not set": "El almacén inventario no está establecido", + "This locker has already been assigned": "Esta taquilla ya ha sido asignada", + "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %d", + "Not exist this branch": "La rama no existe", + "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", + "Collection does not exist": "La colección no existe", + "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", + "Insert a date range": "Inserte un rango de fechas", + "Added observation": "{{user}} añadió esta observacion: {{text}}", + "Comment added to client": "Observación añadida al cliente {{clientFk}}", + "Invalid auth code": "Código de verificación incorrecto", + "Invalid or expired verification code": "Código de verificación incorrecto o expirado", + "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", + "company": "Compañía", + "country": "País", + "clientId": "Id cliente", + "clientSocialName": "Cliente", + "amount": "Importe", + "taxableBase": "Base", + "ticketFk": "Id ticket", + "isActive": "Activo", + "hasToInvoice": "Facturar", + "isTaxDataChecked": "Datos comprobados", + "comercialId": "Id comercial", + "comercialName": "Comercial", + "Pass expired": "La contraseña ha caducado, cambiela desde Salix", + "Invalid NIF for VIES": "Invalid NIF for VIES", + "Ticket does not exist": "Este ticket no existe", + "Ticket is already signed": "Este ticket ya ha sido firmado", + "Authentication failed": "Autenticación fallida", + "You can't use the same password": "No puedes usar la misma contraseña", + "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono", + "Fecha fuera de rango": "Fecha fuera de rango", + "Error while generating PDF": "Error al generar PDF", + "Error when sending mail to client": "Error al enviar el correo al cliente", + "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", + "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", + "Valid priorities": "Prioridades válidas: %d", + "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", + "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", + "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s", + "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", + "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", + "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado", + "You don't have enough privileges.": "No tienes suficientes permisos.", + "This ticket is locked.": "Este ticket está bloqueado.", + "This ticket is not editable.": "Este ticket no es editable.", + "The ticket doesn't exist.": "No existe el ticket.", + "Social name should be uppercase": "La razón social debe ir en mayúscula", + "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", + "Ticket without Route": "Ticket sin ruta", + "Select a different customer": "Seleccione un cliente distinto", + "Fill all the fields": "Rellene todos los campos" } \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index 0b123dd3d..65b671716 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { Self.remoteMethodCtx('transferInvoice', { description: 'Transfer an issued invoice to another client', @@ -6,7 +8,8 @@ module.exports = Self => { { arg: 'id', type: 'number', - required: true + required: true, + description: 'Issued invoice id' }, { arg: 'ref', @@ -16,22 +19,18 @@ module.exports = Self => { { arg: 'newClientFk', type: 'number', - required: true }, { arg: 'cplusRectificationId', type: 'number', - required: true }, { arg: 'cplusInvoiceType477Id', type: 'number', - required: true }, { arg: 'invoiceCorrectionTypeId', type: 'number', - required: true }, ], returns: { @@ -44,26 +43,32 @@ module.exports = Self => { } }); - Self.transferInvoice = async(ctx, id, ref, newClientFk, cplusRectificationId, cplusInvoiceType477Id, invoiceCorrectionTypeId, options) => { + Self.transferInvoice = async(ctx, options) => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; - + const args = ctx.args; let tx; if (typeof options == 'object') Object.assign(myOptions, options); + const {clientFk} = await models.InvoiceOut.findById(args.id); + + if (clientFk == args.newClientFk) + throw new UserError(`Select a different customer`); + + if (!args.newClientFk || !args.cplusRectificationId || !args.cplusInvoiceType477Id || !args.invoiceCorrectionTypeId) + throw new UserError(`Fill all the fields`); + if (!myOptions.transaction) { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } try { - // Refund tickets and group - const filterRef = {where: {refFk: ref}}; + const filterRef = {where: {refFk: args.ref}}; const tickets = await models.Ticket.find(filterRef, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); await models.Ticket.refund(ctx, ticketsIds, null, myOptions); - // Clone tickets const filterTicket = {where: {ticketFk: {inq: ticketsIds}}}; const services = await models.TicketService.find(filterTicket, myOptions); @@ -75,28 +80,24 @@ module.exports = Self => { const clonedTickets = await models.Sale.clone(salesIds, servicesIds, null, false, false, myOptions); const clonedTicketIds = []; - // Update client for (const clonedTicket of clonedTickets) { - await clonedTicket.updateAttribute('clientFk', newClientFk, myOptions); + await clonedTicket.updateAttribute('clientFk', args.newClientFk, myOptions); clonedTicketIds.push(clonedTicket.id); } - // Quick invoice const invoiceIds = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, myOptions); const [invoiceId] = invoiceIds; - // Insert InvoiceCorrection await models.InvoiceCorrection.create({ correctingFk: invoiceId, - correctedFk: id, - cplusRectificationTypeFk: cplusRectificationId, - cplusInvoiceType477Fk: cplusInvoiceType477Id, - invoiceCorrectionType: invoiceCorrectionTypeId + correctedFk: args.id, + cplusRectificationTypeFk: args.cplusRectificationId, + cplusInvoiceType477Fk: args.cplusInvoiceType477Id, + invoiceCorrectionType: args.invoiceCorrectionTypeId }, myOptions); if (tx) await tx.commit(); - // Crear PDF await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); return invoiceId; diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index 9a3b5fedc..d899b3c44 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -28,7 +28,6 @@ module.exports = Self => { const refundTickets = []; const mappedTickets = new Map(); const now = Date.vnNew(); - const [firstTicketId] = ticketsIds; if (group) { await createTicketRefund( diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 3f7e1cd21..ba7d71253 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -42,35 +42,10 @@ module.exports = Self => { } try { - const refundAgencyMode = await models.AgencyMode.findOne({ - include: { - relation: 'zones', - scope: { - limit: 1, - field: ['id', 'name'] - } - }, - where: {code: 'refund'} - }, myOptions); - - const refoundZoneId = refundAgencyMode.zones()[0].id; - - const salesFilter = { - where: {id: {inq: salesIds}}, - include: { - relation: 'components', - scope: { - fields: ['saleFk', 'componentFk', 'value'] - } - } - }; - // const sales = await models.Sale.find(salesFilter, myOptions); - const refundTicket = await models.Sale.clone( + const refundsTicket = await models.Sale.clone( salesIds, servicesIds, withWarehouse, - // refundAgencyMode, - // refoundZoneId, true, true, myOptions @@ -78,36 +53,10 @@ module.exports = Self => { if (tx && !options) await tx.commit(); - return refundTicket; + return refundsTicket[0]; } catch (e) { if (tx) await tx.rollback(); throw e; } }; - - /* async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { - const models = Self.app.models; - - const filter = {include: {relation: 'address'}}; - const ticket = await models.Ticket.findById(ticketId, filter, myOptions); - - const refundTicket = await models.Ticket.create({ - clientFk: ticket.clientFk, - shipped: now, - addressFk: ticket.address().id, - agencyModeFk: refundAgencyMode.id, - nickname: ticket.address().nickname, - warehouseFk: withWarehouse ? ticket.warehouseFk : null, - companyFk: ticket.companyFk, - landed: now, - zoneFk: refoundZoneId - }, myOptions); - - await models.TicketRefund.create({ - refundTicketFk: refundTicket.id, - originalTicketFk: ticket.id, - }, myOptions); - - return refundTicket; - } */ }; diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 727ce2fac..b81f7f84d 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -fdescribe('Sale refund()', () => { +describe('Sale refund()', () => { const userId = 5; const ctx = {req: {accessToken: userId}}; const activeCtx = { From 82f14e62ade80aed1df3ebd0e45bebba603def3b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 21 Sep 2023 16:08:55 +0200 Subject: [PATCH 10/32] ref #5914 tests fixed --- modules/invoiceOut/back/models/invoice-out.js | 1 + modules/ticket/back/methods/sale/refund.js | 2 +- modules/ticket/back/methods/ticket/invoiceTickets.js | 2 +- print/templates/reports/invoice/invoice.js | 2 -- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index ca77c856f..34b4dc798 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -44,6 +44,7 @@ module.exports = Self => { Self.makePdf = async function(id, options) { const fields = ['id', 'hasPdf', 'ref']; const invoiceOut = await Self.findById(id, {fields}, options); + console.log('Recoge invoiceOut?'); const invoiceReport = new print.Report('invoice', { reference: invoiceOut.ref }); diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index ba7d71253..5d8297a4e 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -51,7 +51,7 @@ module.exports = Self => { myOptions ); - if (tx && !options) await tx.commit(); + if (tx) await tx.commit(); return refundsTicket[0]; } catch (e) { diff --git a/modules/ticket/back/methods/ticket/invoiceTickets.js b/modules/ticket/back/methods/ticket/invoiceTickets.js index e65c14e9a..fa3ee93af 100644 --- a/modules/ticket/back/methods/ticket/invoiceTickets.js +++ b/modules/ticket/back/methods/ticket/invoiceTickets.js @@ -79,7 +79,7 @@ module.exports = function(Self) { } if (tx) { for (const invoiceId of invoicesIds) - await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null, myOptions); + await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); } return invoicesIds; diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js index 4424c8ea3..b26472b08 100755 --- a/print/templates/reports/invoice/invoice.js +++ b/print/templates/reports/invoice/invoice.js @@ -6,9 +6,7 @@ module.exports = { name: 'invoice', mixins: [vnReport], async serverPrefetch() { - console.log(this.reference); this.invoice = await this.findOneFromDef('invoice', [this.reference]); - console.log(this.invoice); this.checkMainEntity(this.invoice); this.client = await this.findOneFromDef('client', [this.reference]); From 731bad59818e3d1e8adb3cef2238561ccaa8400f Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 22 Sep 2023 14:52:56 +0200 Subject: [PATCH 11/32] ref #5914 create ticket with new and refactor --- .../00-transferInvoiceACL.sql | 8 +-- loopback/locale/en.json | 2 +- loopback/locale/es.json | 34 +++++----- .../methods/invoiceOut/transferInvoice.js | 13 ++-- modules/invoiceOut/back/models/invoice-out.js | 1 - .../front/descriptor-menu/style.scss | 2 +- modules/ticket/back/methods/sale/clone.js | 67 ++++++------------- modules/ticket/back/methods/sale/refund.js | 3 +- .../methods/ticket/invoiceTicketsWithPdf.js | 0 modules/ticket/back/models/ticket.json | 5 -- 10 files changed, 51 insertions(+), 84 deletions(-) rename db/changes/{233601 => 234001}/00-transferInvoiceACL.sql (67%) delete mode 100644 modules/ticket/back/methods/ticket/invoiceTicketsWithPdf.js diff --git a/db/changes/233601/00-transferInvoiceACL.sql b/db/changes/234001/00-transferInvoiceACL.sql similarity index 67% rename from db/changes/233601/00-transferInvoiceACL.sql rename to db/changes/234001/00-transferInvoiceACL.sql index a45e3f479..2bf4ec688 100644 --- a/db/changes/233601/00-transferInvoiceACL.sql +++ b/db/changes/234001/00-transferInvoiceACL.sql @@ -1,6 +1,6 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES - ('CplusRectificationType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('CplusInvoiceType477', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('InvoiceOut', 'transferInvoice', 'WRITE', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file + ('CplusRectificationType', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('CplusInvoiceType477', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceOut', 'transferInvoice', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 3755c4a67..95e5ebc1c 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -188,7 +188,7 @@ "The ticket doesn't exist.": "The ticket doesn't exist.", "The sales do not exists": "The sales do not exists", "Ticket without Route": "Ticket without route", - "Select a different customer": "Select a different customer", + "Select a different client": "Select a different client", "Fill all the fields": "Fill all the fields", "Error while generating PDF": "Error while generating PDF", "Can't invoice to future": "Can't invoice to future", diff --git a/loopback/locale/es.json b/loopback/locale/es.json index f5973dcb7..18f51d7f8 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -5,10 +5,10 @@ "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado", "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado", "Can't be blank": "No puede estar en blanco", - "Invalid TIN": "NIF/CIF invalido", + "Invalid TIN": "NIF/CIF inválido", "TIN must be unique": "El NIF/CIF debe ser único", "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", - "Is invalid": "Is invalid", + "Is invalid": "Es inválido", "Quantity cannot be zero": "La cantidad no puede ser cero", "Enter an integer different to zero": "Introduce un entero distinto de cero", "Package cannot be blank": "El embalaje no puede estar en blanco", @@ -55,8 +55,8 @@ "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", "You don't have enough privileges": "No tienes suficientes permisos", "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", - "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos basicos de una orden con artículos", - "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no esta permitido el uso de la letra ñ", + "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos", + "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ", "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", "You can't create a ticket for a inactive client": "No puedes crear un ticket para un cliente inactivo", "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", @@ -65,7 +65,7 @@ "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", "Street cannot be empty": "Dirección no puede estar en blanco", - "City cannot be empty": "Cuidad no puede estar en blanco", + "City cannot be empty": "Ciudad no puede estar en blanco", "Code cannot be blank": "Código no puede estar en blanco", "You cannot remove this department": "No puedes eliminar este departamento", "The extension must be unique": "La extensión debe ser unica", @@ -102,8 +102,8 @@ "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", "Invalid quantity": "Cantidad invalida", - "This postal code is not valid": "This postal code is not valid", - "is invalid": "is invalid", + "This postal code is not valid": "Este código postal no es válido", + "is invalid": "es inválido", "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", "The department name can't be repeated": "El nombre del departamento no puede repetirse", "This phone already exists": "Este teléfono ya existe", @@ -112,8 +112,8 @@ "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", "You should specify a date": "Debes especificar una fecha", - "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fín", - "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fín", + "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fin", + "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fin", "You should mark at least one week day": "Debes marcar al menos un día de la semana", "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", @@ -144,15 +144,15 @@ "Unable to clone this travel": "No ha sido posible clonar este travel", "This thermograph id already exists": "La id del termógrafo ya existe", "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", - "ORDER_ALREADY_CONFIRMED": "ORDER_ALREADY_CONFIRMED", + "ORDER_ALREADY_CONFIRMED": "ORDEN YA CONFIRMADA", "Invalid password": "Invalid password", "Password does not meet requirements": "La contraseña no cumple los requisitos", - "Role already assigned": "Role already assigned", - "Invalid role name": "Invalid role name", - "Role name must be written in camelCase": "Role name must be written in camelCase", - "Email already exists": "Email already exists", - "User already exists": "User already exists", - "Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral", + "Role already assigned": "Rol ya asignado", + "Invalid role name": "Nombre de rol no válido", + "Role name must be written in camelCase": "El nombre del rol debe escribirse en camelCase", + "Email already exists": "El correo ya existe", + "User already exists": "El/La usuario/a ya existe", + "Absence change notification on the labour calendar": "Notificación de cambio de ausencia en el calendario laboral", "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", @@ -317,6 +317,6 @@ "Social name should be uppercase": "La razón social debe ir en mayúscula", "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", "Ticket without Route": "Ticket sin ruta", - "Select a different customer": "Seleccione un cliente distinto", + "Select a different client": "Seleccione un cliente distinto", "Fill all the fields": "Rellene todos los campos" } \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index 65b671716..c4f6e9445 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -19,18 +19,22 @@ module.exports = Self => { { arg: 'newClientFk', type: 'number', + required: true }, { arg: 'cplusRectificationId', type: 'number', + required: true }, { arg: 'cplusInvoiceType477Id', type: 'number', + required: true }, { arg: 'invoiceCorrectionTypeId', type: 'number', + required: true }, ], returns: { @@ -54,10 +58,7 @@ module.exports = Self => { const {clientFk} = await models.InvoiceOut.findById(args.id); if (clientFk == args.newClientFk) - throw new UserError(`Select a different customer`); - - if (!args.newClientFk || !args.cplusRectificationId || !args.cplusInvoiceType477Id || !args.invoiceCorrectionTypeId) - throw new UserError(`Fill all the fields`); + throw new UserError(`Select a different client`); if (!myOptions.transaction) { tx = await Self.beginTransaction({}); @@ -77,7 +78,7 @@ module.exports = Self => { const sales = await models.Sale.find(filterTicket, myOptions); const salesIds = sales.map(sale => sale.id); - const clonedTickets = await models.Sale.clone(salesIds, servicesIds, null, false, false, myOptions); + const clonedTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, false, myOptions); const clonedTicketIds = []; for (const clonedTicket of clonedTickets) { @@ -93,7 +94,7 @@ module.exports = Self => { correctedFk: args.id, cplusRectificationTypeFk: args.cplusRectificationId, cplusInvoiceType477Fk: args.cplusInvoiceType477Id, - invoiceCorrectionType: args.invoiceCorrectionTypeId + invoiceCorrectionTypeFk: args.invoiceCorrectionTypeId }, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index 34b4dc798..ca77c856f 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -44,7 +44,6 @@ module.exports = Self => { Self.makePdf = async function(id, options) { const fields = ['id', 'hasPdf', 'ref']; const invoiceOut = await Self.findById(id, {fields}, options); - console.log('Recoge invoiceOut?'); const invoiceReport = new print.Report('invoice', { reference: invoiceOut.ref }); diff --git a/modules/invoiceOut/front/descriptor-menu/style.scss b/modules/invoiceOut/front/descriptor-menu/style.scss index 25c02c80c..9e4cf4297 100644 --- a/modules/invoiceOut/front/descriptor-menu/style.scss +++ b/modules/invoiceOut/front/descriptor-menu/style.scss @@ -25,6 +25,6 @@ vn-invoice-out-descriptor-menu { } @media screen and (min-width: 1000px) { .transferInvoice { - min-width: 900px; + min-width: $width-md; } } diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index d899b3c44..7ce7675da 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.clone = async(salesIds, servicesIds, withWarehouse, group, negative, options) => { + Self.clone = async(ctx, salesIds, servicesIds, withWarehouse, group, negative, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -23,32 +23,24 @@ module.exports = Self => { } }; const sales = await models.Sale.find(salesFilter, myOptions); - const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; + let ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; const refundTickets = []; const mappedTickets = new Map(); const now = Date.vnNew(); - const [firstTicketId] = ticketsIds; - if (group) { + + if (group) ticketsIds = [ticketsIds[0]]; + + for (let ticketId in ticketsIds) { await createTicketRefund( - firstTicketId, + ctx, + ticketsIds[ticketId], withWarehouse, refundTickets, - mappedTickets, now, myOptions ); - } else { - for (let ticketId of ticketsIds) { - await createTicketRefund( - ticketId, - withWarehouse, - refundTickets, - mappedTickets, - now, - myOptions - ); - } + mappedTickets.set(ticketsIds[ticketId], refundTickets[ticketId].id); } for (const sale of sales) { @@ -100,47 +92,26 @@ module.exports = Self => { }; async function createTicketRefund( + ctx, ticketId, withWarehouse, refundTickets, - mappedTickets, now, myOptions ) { const models = Self.app.models; - const filter = { - include: [ - { - relation: 'address' - }, - { - relation: 'agencyMode' - }, - { - relation: 'zone' - } - ] - }; - const ticket = await models.Ticket.findById(ticketId, filter, myOptions); - const refundTicket = await models.Ticket.create({ - clientFk: ticket.clientFk, - shipped: now, - addressFk: ticket.address().id, - agencyModeFk: ticket.agencyMode().id, - nickname: ticket.address().nickname, - warehouseFk: withWarehouse ? ticket.warehouseFk : null, - companyFk: ticket.companyFk, - zonePrice: ticket.zonePrice, - zoneBonus: ticket.zoneBonus, - weight: ticket.weight, - landed: now, - zoneFk: ticket.zone().id, - }, myOptions); + const ticket = await models.Ticket.findById(ticketId, myOptions); + ctx.args.clientId = ticket.clientFk; + ctx.args.shipped = now; + ctx.args.landed = now; + ctx.args.warehouseId = withWarehouse ? ticket.warehouseFk : null; + ctx.args.companyId = ticket.companyFk; + ctx.args.addressId = ticket.addressFk; + + const refundTicket = await models.Ticket.new(ctx, myOptions); refundTickets.push(refundTicket); - - mappedTickets.set(ticketId, refundTicket.id); } async function getTicketRefundId(group, ticketId, refundTickets, mappedTickets) { diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 5d8297a4e..17b70f12b 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -43,10 +43,11 @@ module.exports = Self => { try { const refundsTicket = await models.Sale.clone( + ctx, salesIds, servicesIds, withWarehouse, - true, + false, true, myOptions ); diff --git a/modules/ticket/back/methods/ticket/invoiceTicketsWithPdf.js b/modules/ticket/back/methods/ticket/invoiceTicketsWithPdf.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index 1c5610a2a..ec4193bed 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -136,11 +136,6 @@ "type": "belongsTo", "model": "Zone", "foreignKey": "zoneFk" - }, - "sale": { - "type": "hasMany", - "model": "Sale", - "foreignKey": "ticketFk" } } } From c8c06f498c4910282540b7001e020ed729c8aace Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 25 Sep 2023 10:49:47 +0200 Subject: [PATCH 12/32] ref #5914 fixed tests e2e --- e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js | 6 +++--- loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- .../back/methods/invoiceOut/specs/refund.spec.js | 2 +- modules/ticket/back/methods/sale/specs/refund.spec.js | 8 +++++--- modules/ticket/back/methods/ticket/new.js | 2 +- modules/ticket/back/methods/ticket/specs/new.spec.js | 2 +- modules/ticket/back/methods/ticket/transferSales.js | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 6264073f6..da4b2c92b 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -220,7 +220,7 @@ describe('Ticket Edit sale path', () => { it('should log in as salesAssistant and navigate to ticket sales', async() => { await page.loginAndModule('salesAssistant', 'ticket'); - await page.accessToSearchResult('17'); + await page.accessToSearchResult('15'); await page.accessToSection('ticket.card.sale'); }); @@ -324,7 +324,7 @@ describe('Ticket Edit sale path', () => { }); it('should confirm the transfered quantity is the correct one', async() => { - const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText'); + const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleQuantityCell, 'innerText'); expect(result).toContain('20'); }); @@ -378,7 +378,7 @@ describe('Ticket Edit sale path', () => { await page.waitToClick(selectors.ticketSales.moveToNewTicketButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain(`You can't create a ticket for a inactive client`); + expect(message.text).toContain(`You can't create a ticket for an inactive client`); await page.closePopup(); }); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 95e5ebc1c..b56c3de77 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -23,7 +23,7 @@ "Agency cannot be blank": "Agency cannot be blank", "The IBAN does not have the correct format": "The IBAN does not have the correct format", "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", - "You can't create a ticket for a inactive client": "You can't create a ticket for a inactive client", + "You can't create a ticket for an inactive client": "You can't create a ticket for an inactive client", "Worker cannot be blank": "Worker cannot be blank", "You must delete the claim id %d first": "You must delete the claim id %d first", "You don't have enough privileges": "You don't have enough privileges", diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 18f51d7f8..568c9a306 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -58,7 +58,7 @@ "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos", "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ", "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", - "You can't create a ticket for a inactive client": "No puedes crear un ticket para un cliente inactivo", + "You can't create a ticket for an inactive client": "No puedes crear un ticket para un cliente inactivo", "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", "ORDER_EMPTY": "Cesta vacía", "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js index 6ecfe6015..22891f161 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -3,7 +3,7 @@ const LoopBackContext = require('loopback-context'); describe('InvoiceOut refund()', () => { const userId = 5; - const ctx = {req: {accessToken: userId}}; + const ctx = {req: {accessToken: userId}, args: {}}; const withWarehouse = true; const activeCtx = { accessToken: {userId: userId}, diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index b81f7f84d..08eb1fabd 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -3,7 +3,7 @@ const LoopBackContext = require('loopback-context'); describe('Sale refund()', () => { const userId = 5; - const ctx = {req: {accessToken: userId}}; + const ctx = {req: {accessToken: userId}, args: {}}; const activeCtx = { accessToken: {userId}, }; @@ -40,6 +40,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; + const ticketsBefore = await models.Ticket.find({}, options); const ticket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options); @@ -61,12 +62,13 @@ describe('Sale refund()', () => { } ] }, options); - + const ticketsAfter = await models.Ticket.find({}, options); const salesLength = refundedTicket.ticketSales().length; const componentsLength = refundedTicket.ticketSales()[0].components().length; expect(refundedTicket).toBeDefined(); - expect(salesLength).toEqual(2); + expect(salesLength).toEqual(1); + expect(ticketsBefore.length).toEqual(ticketsAfter.length - 2); expect(componentsLength).toEqual(4); await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index b461fb26d..65bc76c5d 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -96,7 +96,7 @@ module.exports = Self => { if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) { const canCreateTicket = await models.Client.canCreateTicket(args.clientId, myOptions); if (!canCreateTicket) - throw new UserError(`You can't create a ticket for a inactive client`); + throw new UserError(`You can't create a ticket for an inactive client`); } if (!args.shipped && args.landed) { diff --git a/modules/ticket/back/methods/ticket/specs/new.spec.js b/modules/ticket/back/methods/ticket/specs/new.spec.js index 0a2f93bc4..9aa073a7b 100644 --- a/modules/ticket/back/methods/ticket/specs/new.spec.js +++ b/modules/ticket/back/methods/ticket/specs/new.spec.js @@ -30,7 +30,7 @@ describe('ticket new()', () => { await tx.rollback(); } - expect(error).toEqual(new UserError(`You can't create a ticket for a inactive client`)); + expect(error).toEqual(new UserError(`You can't create a ticket for an inactive client`)); }); it('should throw an error if the address doesnt exist', async() => { diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 1124f7ec7..f2cb89205 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -66,7 +66,7 @@ module.exports = Self => { const ticket = await models.Ticket.findById(id); const canCreateTicket = await models.Client.canCreateTicket(ticket.clientFk); if (!canCreateTicket) - throw new UserError(`You can't create a ticket for a inactive client`); + throw new UserError(`You can't create a ticket for an inactive client`); ticketId = await cloneTicket(originalTicket, myOptions); } From 98ee9bbaf320684102e08f91fee8813abf5c7417 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 25 Sep 2023 12:54:31 +0200 Subject: [PATCH 13/32] ref #5914 back test added --- ...rInvoiceACL.sql => 00-transferInvoice.sql} | 6 ++- .../invoiceOut/specs/transferinvoice.spec.js | 43 +++++++++++++++++++ .../methods/invoiceOut/transferInvoice.js | 7 +-- 3 files changed, 52 insertions(+), 4 deletions(-) rename db/changes/234001/{00-transferInvoiceACL.sql => 00-transferInvoice.sql} (76%) create mode 100644 modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js diff --git a/db/changes/234001/00-transferInvoiceACL.sql b/db/changes/234001/00-transferInvoice.sql similarity index 76% rename from db/changes/234001/00-transferInvoiceACL.sql rename to db/changes/234001/00-transferInvoice.sql index 2bf4ec688..f0608327a 100644 --- a/db/changes/234001/00-transferInvoiceACL.sql +++ b/db/changes/234001/00-transferInvoice.sql @@ -3,4 +3,8 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp ('CplusRectificationType', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), ('CplusInvoiceType477', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), ('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'), - ('InvoiceOut', 'transferInvoice', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file + ('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/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js new file mode 100644 index 000000000..cea4ffacc --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js @@ -0,0 +1,43 @@ +const models = require('vn-loopback/server/server').models; + +describe('InvoiceOut tranferInvoice()', () => { + const userId = 5; + const ctx = {req: {accessToken: userId}}; + ctx.args = { + id: '1', + ref: 'T1111111', + newClientFk: 1, + cplusRectificationId: 1, + cplusInvoiceType477Id: 1, + invoiceCorrectionTypeId: 1 + }; + it('should return the id of the created issued invoice', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + try { + const result = await models.InvoiceOut.transferInvoice( + ctx, + options); + + expect(result).toBeDefined(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should throw an UserError when it is the same client', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + try { + ctx.args.newClientFk = 1101; + await models.InvoiceOut.transferInvoice( + ctx, + options); + } catch (e) { + expect(e.message).toBe(`Select a different client`); + await tx.rollback(); + } + }); +}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index c4f6e9445..8a0609b8d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -97,9 +97,10 @@ module.exports = Self => { invoiceCorrectionTypeFk: args.invoiceCorrectionTypeId }, myOptions); - if (tx) await tx.commit(); - - await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); + if (tx) { + await tx.commit(); + await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); + } return invoiceId; } catch (e) { From 64eb216367d6702ad1e0d2a672df05e9103d28c2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 25 Sep 2023 14:01:40 +0200 Subject: [PATCH 14/32] ref #5914 fixed back test --- .../invoiceOut/specs/transferinvoice.spec.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js index cea4ffacc..75bf649ec 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js @@ -3,17 +3,18 @@ const models = require('vn-loopback/server/server').models; describe('InvoiceOut tranferInvoice()', () => { const userId = 5; const ctx = {req: {accessToken: userId}}; - ctx.args = { - id: '1', - ref: 'T1111111', - newClientFk: 1, - cplusRectificationId: 1, - cplusInvoiceType477Id: 1, - invoiceCorrectionTypeId: 1 - }; it('should return the id of the created issued invoice', async() => { const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; + const args = { + id: '1', + ref: 'T1111111', + newClientFk: 1, + cplusRectificationId: 1, + cplusInvoiceType477Id: 1, + invoiceCorrectionTypeId: 1 + }; + ctx.args = args; try { const result = await models.InvoiceOut.transferInvoice( ctx, @@ -30,8 +31,16 @@ describe('InvoiceOut tranferInvoice()', () => { it('should throw an UserError when it is the same client', async() => { const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; + const args = { + id: '1', + ref: 'T1111111', + newClientFk: 1101, + cplusRectificationId: 1, + cplusInvoiceType477Id: 1, + invoiceCorrectionTypeId: 1 + }; + ctx.args = args; try { - ctx.args.newClientFk = 1101; await models.InvoiceOut.transferInvoice( ctx, options); From 474399b383cefa9c6d9a715082222cc4d8ada3b9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 25 Sep 2023 15:23:51 +0200 Subject: [PATCH 15/32] 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); - } }; From 50543963c104dc1adf421f4c25f4dbf3480254aa Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Sep 2023 12:42:45 +0200 Subject: [PATCH 16/32] ref #5914 refactor createTicketRefund --- modules/ticket/back/methods/sale/clone.js | 57 +++++++++++------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index 84f0e02f8..dd1b108b2 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -3,6 +3,7 @@ module.exports = Self => { const models = Self.app.models; const myOptions = {}; let tx; + const refundTickets = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -25,22 +26,19 @@ module.exports = Self => { const sales = await models.Sale.find(salesFilter, myOptions); let ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - const refundTickets = []; const mappedTickets = new Map(); - const now = Date.vnNew(); if (group) ticketsIds = [ticketsIds[0]]; - for (let ticketId in ticketsIds) { - await createTicketRefund( + for (let ticketId of ticketsIds) { + const ticketRefund = await createTicketRefund( ctx, - ticketsIds[ticketId], + ticketId, withWarehouse, - refundTickets, - now, myOptions ); - mappedTickets.set(ticketsIds[ticketId], refundTickets[ticketId].id); + refundTickets.push(ticketRefund); + mappedTickets.set(ticketId, ticketRefund.id); } for (const sale of sales) { @@ -89,28 +87,25 @@ module.exports = Self => { if (tx) await tx.rollback(); throw e; } + + async function createTicketRefund( + ctx, + ticketId, + withWarehouse, + myOptions + ) { + const models = Self.app.models; + const now = Date.vnNew(); + + const ticket = await models.Ticket.findById(ticketId, null, myOptions); + ctx.args.clientId = ticket.clientFk; + ctx.args.shipped = now; + ctx.args.landed = now; + ctx.args.warehouseId = withWarehouse ? ticket.warehouseFk : null; + ctx.args.companyId = ticket.companyFk; + ctx.args.addressId = ticket.addressFk; + + return models.Ticket.new(ctx, myOptions); + } }; - - async function createTicketRefund( - ctx, - ticketId, - withWarehouse, - refundTickets, - now, - myOptions - ) { - const models = Self.app.models; - - const ticket = await models.Ticket.findById(ticketId, myOptions); - ctx.args.clientId = ticket.clientFk; - ctx.args.shipped = now; - ctx.args.landed = now; - ctx.args.warehouseId = withWarehouse ? ticket.warehouseFk : null; - ctx.args.companyId = ticket.companyFk; - ctx.args.addressId = ticket.addressFk; - - const refundTicket = await models.Ticket.new(ctx, myOptions); - - refundTickets.push(refundTicket); - } }; From 463fc8ae958d8ebe7c388636575636c0ad5ded1b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 28 Sep 2023 08:20:59 +0200 Subject: [PATCH 17/32] ref #5914 added fixtures in English --- db/dump/fixtures.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 15d78adff..31ec9b138 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2977,6 +2977,6 @@ INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EU 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 + (1, 'Error in VAT calculation'), + (2, 'Error in sales details'), + (3, 'Error in customer data'); \ No newline at end of file From 6691cbf32f1285240b093f3ed24c720f3e380c98 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Sep 2023 11:24:24 +0200 Subject: [PATCH 18/32] ref #5914 changes moved --- db/changes/{234001 => 234201}/00-transferInvoice.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{234001 => 234201}/00-transferInvoice.sql (100%) diff --git a/db/changes/234001/00-transferInvoice.sql b/db/changes/234201/00-transferInvoice.sql similarity index 100% rename from db/changes/234001/00-transferInvoice.sql rename to db/changes/234201/00-transferInvoice.sql From cf856a585bba1be47c63e66794df6ffef4f5467a Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 23 Oct 2023 09:50:00 +0200 Subject: [PATCH 19/32] refs #6199 fix(sale_quantity): add isReduction --- modules/ticket/back/models/sale.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 1c86ddc0c..cce6343ec 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -33,6 +33,7 @@ module.exports = Self => { const itemId = changes?.itemFk || instance?.itemFk; const oldQuantity = instance?.quantity ?? null; const quantityAdded = newQuantity - oldQuantity; + const isReduction = oldQuantity && newQuantity <= oldQuantity; const ticket = await models.Ticket.findById( ticketId, @@ -81,7 +82,7 @@ module.exports = Self => { const [itemInfo] = await models.Sale.rawSql(`SELECT available FROM tmp.ticketCalculateItem`, null, ctx.options); - if (!itemInfo?.available || itemInfo.available < quantityAdded) + if ((!isReduction && !itemInfo?.available) || itemInfo.available < quantityAdded) throw new UserError(`This item is not available`); if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return; @@ -89,7 +90,7 @@ module.exports = Self => { if (newQuantity < item.minQuantity && newQuantity != itemInfo?.available) throw new UserError('The amount cannot be less than the minimum'); - if (ctx.isNewInstance || newQuantity <= oldQuantity) return; + if (ctx.isNewInstance || isReduction) return; const [saleGrouping] = await models.Sale.rawSql(` SELECT t.price newPrice From 247aa5af2a9a1ffd4ba829d1ecfe776ceb8feb48 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 23 Oct 2023 09:52:06 +0200 Subject: [PATCH 20/32] refs #6199 fix(sale_quantity): add isReduction --- modules/ticket/back/models/sale.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index cce6343ec..99cfeeeea 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -81,13 +81,14 @@ module.exports = Self => { ctx.options); const [itemInfo] = await models.Sale.rawSql(`SELECT available FROM tmp.ticketCalculateItem`, null, ctx.options); + const available = itemInfo?.available; - if ((!isReduction && !itemInfo?.available) || itemInfo.available < quantityAdded) + if ((!isReduction && !available) || available < quantityAdded) throw new UserError(`This item is not available`); if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return; - if (newQuantity < item.minQuantity && newQuantity != itemInfo?.available) + if (newQuantity < item.minQuantity && newQuantity != available) throw new UserError('The amount cannot be less than the minimum'); if (ctx.isNewInstance || isReduction) return; From 5529f08ce6f949a922954e67f52157e52547cca3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 24 Oct 2023 08:35:45 +0200 Subject: [PATCH 21/32] ref #5914 fix locale --- loopback/locale/en.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index fec1c8566..26650175d 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -188,19 +188,14 @@ "The ticket doesn't exist.": "The ticket doesn't exist.", "The sales do not exists": "The sales do not exists", "Ticket without Route": "Ticket without route", -<<<<<<< HEAD "Select a different client": "Select a different client", "Fill all the fields": "Fill all the fields", "Error while generating PDF": "Error while generating PDF", "Can't invoice to future": "Can't invoice to future", "This ticket is already invoiced": "This ticket is already invoiced", "Negative basis of tickets: 23": "Negative basis of tickets: 23", - "Booking completed": "Booking completed", - "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation" -======= "Booking completed": "Booking complete", "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation", "You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets" ->>>>>>> ae27aa5b1e61c74bfbbc1b7b8af63642072acc6d } From 22b7c5981294dcf5573c4f23b92a7f3010f5e98c Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 24 Oct 2023 09:23:03 +0200 Subject: [PATCH 22/32] refs #6335 feat(ticketAdvance): add zone field --- .../234003/00-ticket_canAdvance_zone.sql | 132 ++++++++++++++++++ .../back/methods/ticket/getTicketsAdvance.js | 15 +- modules/ticket/front/advance/index.html | 4 + modules/ticket/front/advance/index.js | 44 +++--- 4 files changed, 159 insertions(+), 36 deletions(-) create mode 100644 db/changes/234003/00-ticket_canAdvance_zone.sql diff --git a/db/changes/234003/00-ticket_canAdvance_zone.sql b/db/changes/234003/00-ticket_canAdvance_zone.sql new file mode 100644 index 000000000..c11cdc49a --- /dev/null +++ b/db/changes/234003/00-ticket_canAdvance_zone.sql @@ -0,0 +1,132 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDateFuture Fecha de los tickets que se quieren adelantar. + * @param vDateToAdvance Fecha a cuando se quiere adelantar. + * @param vWarehouseFk Almacén + */ + DECLARE vDateInventory DATE; + + SELECT inventoried INTO vDateInventory FROM config; + + DROP TEMPORARY TABLE IF EXISTS tmp.stock; + CREATE TEMPORARY TABLE tmp.stock + (itemFk INT PRIMARY KEY, + amount INT) + ENGINE = MEMORY; + + INSERT INTO tmp.stock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + CREATE OR REPLACE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT + origin.ticketFk futureId, + dest.ticketFk id, + dest.state, + origin.futureState, + origin.futureIpt, + dest.ipt, + origin.workerFk, + origin.futureLiters, + origin.futureLines, + dest.shipped, + origin.shipped futureShipped, + dest.totalWithVat, + origin.totalWithVat futureTotalWithVat, + dest.agency, + origin.futureAgency, + dest.lines, + dest.liters, + origin.futureLines - origin.hasStock AS notMovableLines, + (origin.futureLines = origin.hasStock) AS isFullMovable, + origin.futureZoneFk, + origin.futureZoneName, + origin.classColor futureClassColor, + dest.classColor + FROM ( + SELECT + s.ticketFk, + t.workerFk, + t.shipped, + t.totalWithVat, + st.name futureState, + t.addressFk, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM((s.quantity <= IFNULL(st.amount,0))) hasStock, + z.id futureZoneFk, + z.name futureZoneName, + st.classColor + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN zone z ON t.zoneFk = z.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) origin + JOIN ( + SELECT + t.id ticketFk, + t.addressFk, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t.shipped, + t.totalWithVat, + am.name agency, + CAST(SUM(litros) AS DECIMAL(10,0)) liters, + CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, + st.classColor + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t.warehouseFk = vWarehouseFk + AND st.order <= 5 + GROUP BY t.id + ) dest ON dest.addressFk = origin.addressFk + WHERE origin.hasStock != 0; + + DROP TEMPORARY TABLE tmp.stock; +END$$ +DELIMITER ; + diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index ec9314db2..ab40b9559 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -28,32 +28,27 @@ module.exports = Self => { { arg: 'ipt', type: 'string', - description: 'Origin Item Packaging Type', - required: false + description: 'Origin Item Packaging Type' }, { arg: 'futureIpt', type: 'string', - description: 'Destination Item Packaging Type', - required: false + description: 'Destination Item Packaging Type' }, { arg: 'id', type: 'number', - description: 'Origin id', - required: false + description: 'Origin id' }, { arg: 'futureId', type: 'number', - description: 'Destination id', - required: false + description: 'Destination id' }, { arg: 'isFullMovable', type: 'boolean', - description: 'True when lines and stock of origin are equal', - required: false + description: 'True when lines and stock of origin are equal' }, { arg: 'filter', diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index e6f16c965..a6cf8face 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -81,6 +81,9 @@ Liters + + Zone + Not Movable @@ -155,6 +158,7 @@ {{::ticket.futureLiters | dashIfEmpty}} + {{::ticket.futureZoneName | dashIfEmpty}} {{::ticket.notMovableLines | dashIfEmpty}} {{::ticket.futureLines | dashIfEmpty}} diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 6f8a92ebe..389bcdf14 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -15,28 +15,22 @@ export default class Controller extends Section { { field: 'state', searchable: false - }, - { + }, { field: 'futureState', searchable: false - }, - { + }, { field: 'totalWithVat', searchable: false - }, - { + }, { field: 'futureTotalWithVat', searchable: false - }, - { + }, { field: 'shipped', searchable: false - }, - { + }, { field: 'futureShipped', searchable: false - }, - { + }, { field: 'ipt', autocomplete: { url: 'ItemPackingTypes', @@ -44,8 +38,7 @@ export default class Controller extends Section { showField: 'description', valueField: 'code' } - }, - { + }, { field: 'futureIpt', autocomplete: { url: 'ItemPackingTypes', @@ -53,6 +46,11 @@ export default class Controller extends Section { showField: 'description', valueField: 'code' } + }, { + field: 'futureZoneFk', + autocomplete: { + url: 'Zones', + } }, ] }; @@ -158,27 +156,21 @@ export default class Controller extends Section { exprBuilder(param, value) { switch (param) { case 'id': - return {'id': value}; case 'futureId': - return {'futureId': value}; case 'liters': - return {'liters': value}; case 'futureLiters': - return {'futureLiters': value}; case 'lines': - return {'lines': value}; case 'futureLines': - return {'futureLines': value}; + case 'totalWithVat': + case 'futureTotalWithVat': + case 'futureZone': + case 'notMovableLines': + case 'futureZoneFk': + return {[param]: value}; case 'ipt': return {'ipt': {like: `%${value}%`}}; case 'futureIpt': return {'futureIpt': {like: `%${value}%`}}; - case 'totalWithVat': - return {'totalWithVat': value}; - case 'futureTotalWithVat': - return {'futureTotalWithVat': value}; - case 'notMovableLines': - return {'notMovableLines': value}; } } } From f1deeb69cabfc11210f24173a8d683e9e99ab27c Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 24 Oct 2023 09:34:04 +0200 Subject: [PATCH 23/32] ref #5914 add ticketrefund and fix text --- .../invoiceOut/specs/transferinvoice.spec.js | 22 ++++++++++++++++--- modules/ticket/back/methods/sale/clone.js | 8 ++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js index 75bf649ec..04f6df299 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js @@ -1,14 +1,30 @@ + const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('InvoiceOut tranferInvoice()', () => { - const userId = 5; - const ctx = {req: {accessToken: userId}}; + const activeCtx = { + accessToken: {userId: 5}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + const ctx = {req: activeCtx}; + + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should return the id of the created issued invoice', async() => { const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; const args = { id: '1', - ref: 'T1111111', + ref: 'T4444444', newClientFk: 1, cplusRectificationId: 1, cplusInvoiceType477Id: 1, diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index dd1b108b2..a72f17af6 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -105,7 +105,13 @@ module.exports = Self => { ctx.args.companyId = ticket.companyFk; ctx.args.addressId = ticket.addressFk; - return models.Ticket.new(ctx, myOptions); + const newTicket = await models.Ticket.new(ctx, myOptions); + await models.TicketRefund.create({ + originalTicketFk: ticketId, + refundTicketFk: newTicket.id + }, myOptions); + + return newTicket; } }; }; From 589d7cbbb82dce802cf30096ed1e47e85dd157e0 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 24 Oct 2023 12:02:21 +0200 Subject: [PATCH 24/32] fix: ticket_canAdvance correct worker. fix(dockerFIle)! dockerFile debian version --- Dockerfile | 2 +- db/changes/234003/00-ticket_canAdvance_zone.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e1173ad73..c82b20b31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim ENV TZ Europe/Madrid ARG DEBIAN_FRONTEND=noninteractive diff --git a/db/changes/234003/00-ticket_canAdvance_zone.sql b/db/changes/234003/00-ticket_canAdvance_zone.sql index c11cdc49a..ee07ce978 100644 --- a/db/changes/234003/00-ticket_canAdvance_zone.sql +++ b/db/changes/234003/00-ticket_canAdvance_zone.sql @@ -72,7 +72,7 @@ BEGIN FROM ( SELECT s.ticketFk, - t.workerFk, + c.salesPersonFk workerFk, t.shipped, t.totalWithVat, st.name futureState, @@ -86,6 +86,7 @@ BEGIN z.name futureZoneName, st.classColor FROM ticket t + JOIN client c ON c.id = t.clientFk JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk From 22fdcef7bb2faa0f9737d6fa01d3e51487924607 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 24 Oct 2023 14:07:05 +0200 Subject: [PATCH 25/32] fix(dockerFIle)! front debian version --- Dockerfile | 2 +- front/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c82b20b31..e1173ad73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bookworm-slim +FROM debian:bullseye-slim ENV TZ Europe/Madrid ARG DEBIAN_FRONTEND=noninteractive diff --git a/front/Dockerfile b/front/Dockerfile index 098ee161e..d0ee26904 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:stretch-slim +FROM debian:bookworm-slim EXPOSE 80 ENV TZ Europe/Madrid From efa9f1645213124f7575c9d3be6e6d2216d8c4e1 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 25 Oct 2023 09:22:44 +0200 Subject: [PATCH 26/32] fix: remove unnecessary UserError --- modules/ticket/back/methods/ticket/addSale.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 3455ec2c4..826de6e12 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -1,5 +1,3 @@ -const UserError = require('vn-loopback/util/user-error'); - module.exports = Self => { Self.remoteMethodCtx('addSale', { description: 'Inserts a new sale for the current ticket', From 013b010c220702957705347d672edcf173484317 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 26 Oct 2023 07:56:57 +0200 Subject: [PATCH 27/32] refs #6278 test(itemRequest): fix e2e, correct selector --- e2e/helpers/selectors.js | 10 +++++----- modules/item/front/request/index.html | 28 +++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 5e071911e..cec0545a0 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -409,11 +409,11 @@ export default { inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]' }, itemRequest: { - firstRequestItemID: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(7)', - firstRequestQuantity: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(8)', - firstRequestConcept: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(9)', - firstRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10)', - secondRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(10)', + firstRequestItemID: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(8)', + firstRequestQuantity: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(9)', + firstRequestConcept: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10)', + firstRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(11)', + secondRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(11)', secondRequestDecline: 'vn-item-request vn-tr:nth-child(2) vn-icon-button[icon="thumb_down"]', declineReason: 'vn-textarea[ng-model="$ctrl.denyObservation"]' }, diff --git a/modules/item/front/request/index.html b/modules/item/front/request/index.html index 200ce3902..03c8db8ec 100644 --- a/modules/item/front/request/index.html +++ b/modules/item/front/request/index.html @@ -26,7 +26,7 @@ Ticket ID Shipped Description - Requester + Requester Requested Price Atender @@ -86,8 +86,8 @@ - {{request.itemDescription}} @@ -114,13 +114,13 @@ - - - @@ -149,24 +149,24 @@ ng-click="contextmenu.filterBySelection()"> Filter by selection
- Exclude selection - Remove filter - Remove all filters - Copy value - \ No newline at end of file + From 83cff374227dc893ddd5e7ae405260ab8411079e Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 26 Oct 2023 08:23:18 +0200 Subject: [PATCH 28/32] refs #6350 fix: 00-dropWorkerCreate.sql --- db/changes/234201/00-dropWorkerCreate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/234201/00-dropWorkerCreate.sql b/db/changes/234201/00-dropWorkerCreate.sql index be2761c3d..b903909b6 100644 --- a/db/changes/234201/00-dropWorkerCreate.sql +++ b/db/changes/234201/00-dropWorkerCreate.sql @@ -1 +1 @@ -DROP PROCEDURE IF EXISTS vn.workerCreate; \ No newline at end of file +DROP PROCEDURE IF EXISTS `vn`.`workerCreate`; From 3a1227bdc225545d46c3ee47191759e2ba4d9bba Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 26 Oct 2023 09:20:25 +0200 Subject: [PATCH 29/32] ref #5914 fix ticketrefund --- modules/ticket/back/methods/sale/clone.js | 33 +++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index a72f17af6..a5ccb6de4 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -3,7 +3,7 @@ module.exports = Self => { const models = Self.app.models; const myOptions = {}; let tx; - const refundTickets = []; + const newTickets = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -31,21 +31,22 @@ module.exports = Self => { if (group) ticketsIds = [ticketsIds[0]]; for (let ticketId of ticketsIds) { - const ticketRefund = await createTicketRefund( + const newTicket = await createTicket( ctx, ticketId, withWarehouse, + negative, myOptions ); - refundTickets.push(ticketRefund); - mappedTickets.set(ticketId, ticketRefund.id); + newTickets.push(newTicket); + mappedTickets.set(ticketId, newTicket.id); } for (const sale of sales) { - const refundTicketId = mappedTickets.get(sale.ticketFk); + const newTicketId = mappedTickets.get(sale.ticketFk); const createdSale = await models.Sale.create({ - ticketFk: refundTicketId, + ticketFk: newTicketId, itemFk: sale.itemFk, quantity: negative ? - sale.quantity : sale.quantity, concept: sale.concept, @@ -67,14 +68,14 @@ module.exports = Self => { const services = await models.TicketService.find(servicesFilter, myOptions); for (const service of services) { - const refundTicketId = mappedTickets.get(service.ticketFk); + const newTicketId = mappedTickets.get(service.ticketFk); await models.TicketService.create({ description: service.description, quantity: negative ? - service.quantity : service.quantity, price: service.price, taxClassFk: service.taxClassFk, - ticketFk: refundTicketId, + ticketFk: newTicketId, ticketServiceTypeFk: service.ticketServiceTypeFk, }, myOptions); } @@ -82,16 +83,17 @@ module.exports = Self => { if (tx) await tx.commit(); - return refundTickets; + return newTickets; } catch (e) { if (tx) await tx.rollback(); throw e; } - async function createTicketRefund( + async function createTicket( ctx, ticketId, withWarehouse, + negative, myOptions ) { const models = Self.app.models; @@ -106,10 +108,13 @@ module.exports = Self => { ctx.args.addressId = ticket.addressFk; const newTicket = await models.Ticket.new(ctx, myOptions); - await models.TicketRefund.create({ - originalTicketFk: ticketId, - refundTicketFk: newTicket.id - }, myOptions); + + if (negative) { + await models.TicketRefund.create({ + originalTicketFk: ticketId, + refundTicketFk: newTicket.id + }, myOptions); + } return newTicket; } From cecdf8633cea829928b37608f14ea7e97e29184f Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 26 Oct 2023 09:27:32 +0200 Subject: [PATCH 30/32] refs #6350 deploy: init version 23.46 --- CHANGELOG.md | 8 +++++++- db/{changes => .archive}/231201/00-ACL.sql | 0 db/{changes => .archive}/231201/00-chatRefactor.sql | 0 db/{changes => .archive}/231201/00-invoiceInSerial.sql | 0 db/{changes => .archive}/231201/00-itemType_isFragile.sql | 0 db/{changes => .archive}/231201/00-mailACL.sql | 0 db/{changes => .archive}/231201/00-operator.sql | 0 .../231201/00-supplierAccount_deleteTriggers.sql | 0 db/{changes => .archive}/231201/00-ticket_getWarnings.sql | 0 db/{changes => .archive}/231201/00-wagon.sql | 0 db/{changes => .archive}/231202/00-delivery.sql | 0 db/{changes => .archive}/231203/00-delivery.sql | 0 db/{changes => .archive}/231204/00-rollbackDelivery.sql | 0 db/{changes => .archive}/231205/00-printQueueArgs.sql | 0 .../231401/00-claimBeginningAfterInsert.sql | 0 db/{changes => .archive}/231401/00-clientBeforeUpdate.sql | 0 db/{changes => .archive}/231401/00-hotfixDelivery.sql | 0 .../231401/00-invoiceOutAfterInsert.sql | 0 db/{changes => .archive}/231401/00-negativeBases.sql | 0 db/{changes => .archive}/231401/00-workerNotes.sql | 0 db/{changes => .archive}/231402/00-negativeBases.sql | 0 db/{changes => .archive}/231801/00-aclClientInforma.sql | 0 db/{changes => .archive}/231801/00-acl_receiptEmail.sql | 0 db/{changes => .archive}/231801/00-clientInforma.sql | 0 .../231801/00-client_setRatingAcl.sql | 0 db/{changes => .archive}/231801/00-deleteProcs_refund.sql | 0 db/{changes => .archive}/231801/00-deviceProduction.sql | 0 db/{changes => .archive}/231801/00-kkearEntryNotes.sql | 0 db/{changes => .archive}/231801/00-newCompanyI18n.sql | 0 db/{changes => .archive}/231801/00-newTableWeb.sql | 0 .../231801/00-observationEmailACL.sql | 0 .../231801/00-optimiceZoneEstimatedDelivery.sql | 0 db/{changes => .archive}/231801/00-saleTracking.sql | 0 db/{changes => .archive}/231801/00-ticketConfig.sql | 0 db/{changes => .archive}/231801/00-updateIsVies.sql | 0 db/{changes => .archive}/231801/00-updateisViesClient.sql | 0 db/{changes => .archive}/231801/00-userAcl.sql | 0 db/{changes => .archive}/231801/00-userRoleLog.sql | 0 db/{changes => .archive}/231801/01-viewCompany10L.sql | 0 db/{changes => .archive}/232001/00-clientWorkerName.sql | 0 db/{changes => .archive}/232001/00-createWorker.sql | 0 db/{changes => .archive}/232001/00-invoiceOut_new.sql | 0 db/{changes => .archive}/232001/00-wagon.sql | 0 db/{changes => .archive}/232201/00-defaulterView.sql | 0 .../232201/00-procedurecanAdvance.sql | 0 .../232201/00-procedurecanbePostponed.sql | 0 .../232201/00-workerConfigPayMethod.sql | 0 .../232202/00-procedurecanAdvance.sql | 0 .../232202/00-procedurecanbePostponed.sql | 0 db/{changes => .archive}/232401/.gitkeep | 0 .../232401/00-buyConfig_travelConfig.sql | 0 db/{changes => .archive}/232401/00-printer.sql | 0 db/{changes => .archive}/232401/00-ticket_warehouse.sql | 0 db/{changes => .archive}/232401/00-userPassExpired.sql | 0 .../232402/00-hotFix_travelConfig.sql | 0 db/{changes => .archive}/232601/00-aclAccount.sql | 0 db/{changes => .archive}/232601/00-aclInvoiceTickets.sql | 0 .../232601/00-aclMailAliasAccount.sql | 0 db/{changes => .archive}/232601/00-aclMailForward.sql | 0 db/{changes => .archive}/232601/00-aclRole.sql | 0 db/{changes => .archive}/232601/00-aclVnUser.sql | 0 .../232601/00-aclVnUser_renewToken.sql | 0 .../232601/00-entry_updateComission.sql | 0 .../232601/00-packingSiteAdvanced.sql | 0 db/{changes => .archive}/232601/00-salix.sql | 0 db/{changes => .archive}/232601/00-useSpecificsAcls.sql | 0 db/{changes => .archive}/232601/01-invoiceOutPdf.sql | 0 db/{changes => .archive}/232602/01-aclAddAlias.sql | 0 db/{changes => .archive}/232801/00-authCode.sql | 0 db/{changes => .archive}/232801/00-client_create.sql | 0 db/{changes => .archive}/232801/00-client_create2.sql | 0 db/{changes => .archive}/232801/00-department.sql | 0 db/{changes => .archive}/232801/00-fix_editCredit.sql | 0 db/{changes => .archive}/232801/00-user.sql | 0 db/{changes => .archive}/232802/01-aclWorkerDisable.sql | 0 db/changes/234601/.gitkeep | 0 package-lock.json | 4 ++-- package.json | 2 +- 78 files changed, 10 insertions(+), 4 deletions(-) rename db/{changes => .archive}/231201/00-ACL.sql (100%) rename db/{changes => .archive}/231201/00-chatRefactor.sql (100%) rename db/{changes => .archive}/231201/00-invoiceInSerial.sql (100%) rename db/{changes => .archive}/231201/00-itemType_isFragile.sql (100%) rename db/{changes => .archive}/231201/00-mailACL.sql (100%) rename db/{changes => .archive}/231201/00-operator.sql (100%) rename db/{changes => .archive}/231201/00-supplierAccount_deleteTriggers.sql (100%) rename db/{changes => .archive}/231201/00-ticket_getWarnings.sql (100%) rename db/{changes => .archive}/231201/00-wagon.sql (100%) rename db/{changes => .archive}/231202/00-delivery.sql (100%) rename db/{changes => .archive}/231203/00-delivery.sql (100%) rename db/{changes => .archive}/231204/00-rollbackDelivery.sql (100%) rename db/{changes => .archive}/231205/00-printQueueArgs.sql (100%) rename db/{changes => .archive}/231401/00-claimBeginningAfterInsert.sql (100%) rename db/{changes => .archive}/231401/00-clientBeforeUpdate.sql (100%) rename db/{changes => .archive}/231401/00-hotfixDelivery.sql (100%) rename db/{changes => .archive}/231401/00-invoiceOutAfterInsert.sql (100%) rename db/{changes => .archive}/231401/00-negativeBases.sql (100%) rename db/{changes => .archive}/231401/00-workerNotes.sql (100%) rename db/{changes => .archive}/231402/00-negativeBases.sql (100%) rename db/{changes => .archive}/231801/00-aclClientInforma.sql (100%) rename db/{changes => .archive}/231801/00-acl_receiptEmail.sql (100%) rename db/{changes => .archive}/231801/00-clientInforma.sql (100%) rename db/{changes => .archive}/231801/00-client_setRatingAcl.sql (100%) rename db/{changes => .archive}/231801/00-deleteProcs_refund.sql (100%) rename db/{changes => .archive}/231801/00-deviceProduction.sql (100%) rename db/{changes => .archive}/231801/00-kkearEntryNotes.sql (100%) rename db/{changes => .archive}/231801/00-newCompanyI18n.sql (100%) rename db/{changes => .archive}/231801/00-newTableWeb.sql (100%) rename db/{changes => .archive}/231801/00-observationEmailACL.sql (100%) rename db/{changes => .archive}/231801/00-optimiceZoneEstimatedDelivery.sql (100%) rename db/{changes => .archive}/231801/00-saleTracking.sql (100%) rename db/{changes => .archive}/231801/00-ticketConfig.sql (100%) rename db/{changes => .archive}/231801/00-updateIsVies.sql (100%) rename db/{changes => .archive}/231801/00-updateisViesClient.sql (100%) rename db/{changes => .archive}/231801/00-userAcl.sql (100%) rename db/{changes => .archive}/231801/00-userRoleLog.sql (100%) rename db/{changes => .archive}/231801/01-viewCompany10L.sql (100%) rename db/{changes => .archive}/232001/00-clientWorkerName.sql (100%) rename db/{changes => .archive}/232001/00-createWorker.sql (100%) rename db/{changes => .archive}/232001/00-invoiceOut_new.sql (100%) rename db/{changes => .archive}/232001/00-wagon.sql (100%) rename db/{changes => .archive}/232201/00-defaulterView.sql (100%) rename db/{changes => .archive}/232201/00-procedurecanAdvance.sql (100%) rename db/{changes => .archive}/232201/00-procedurecanbePostponed.sql (100%) rename db/{changes => .archive}/232201/00-workerConfigPayMethod.sql (100%) rename db/{changes => .archive}/232202/00-procedurecanAdvance.sql (100%) rename db/{changes => .archive}/232202/00-procedurecanbePostponed.sql (100%) rename db/{changes => .archive}/232401/.gitkeep (100%) rename db/{changes => .archive}/232401/00-buyConfig_travelConfig.sql (100%) rename db/{changes => .archive}/232401/00-printer.sql (100%) rename db/{changes => .archive}/232401/00-ticket_warehouse.sql (100%) rename db/{changes => .archive}/232401/00-userPassExpired.sql (100%) rename db/{changes => .archive}/232402/00-hotFix_travelConfig.sql (100%) rename db/{changes => .archive}/232601/00-aclAccount.sql (100%) rename db/{changes => .archive}/232601/00-aclInvoiceTickets.sql (100%) rename db/{changes => .archive}/232601/00-aclMailAliasAccount.sql (100%) rename db/{changes => .archive}/232601/00-aclMailForward.sql (100%) rename db/{changes => .archive}/232601/00-aclRole.sql (100%) rename db/{changes => .archive}/232601/00-aclVnUser.sql (100%) rename db/{changes => .archive}/232601/00-aclVnUser_renewToken.sql (100%) rename db/{changes => .archive}/232601/00-entry_updateComission.sql (100%) rename db/{changes => .archive}/232601/00-packingSiteAdvanced.sql (100%) rename db/{changes => .archive}/232601/00-salix.sql (100%) rename db/{changes => .archive}/232601/00-useSpecificsAcls.sql (100%) rename db/{changes => .archive}/232601/01-invoiceOutPdf.sql (100%) rename db/{changes => .archive}/232602/01-aclAddAlias.sql (100%) rename db/{changes => .archive}/232801/00-authCode.sql (100%) rename db/{changes => .archive}/232801/00-client_create.sql (100%) rename db/{changes => .archive}/232801/00-client_create2.sql (100%) rename db/{changes => .archive}/232801/00-department.sql (100%) rename db/{changes => .archive}/232801/00-fix_editCredit.sql (100%) rename db/{changes => .archive}/232801/00-user.sql (100%) rename db/{changes => .archive}/232802/01-aclWorkerDisable.sql (100%) create mode 100644 db/changes/234601/.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md index d677b80e3..cd6ed4522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2342.01] - 2023-10-19 +## [2346.01] - 2023-11-16 + +### Added +### Changed +### Fixed + +## [2342.01] - 2023-11-02 ### Added ### Changed diff --git a/db/changes/231201/00-ACL.sql b/db/.archive/231201/00-ACL.sql similarity index 100% rename from db/changes/231201/00-ACL.sql rename to db/.archive/231201/00-ACL.sql diff --git a/db/changes/231201/00-chatRefactor.sql b/db/.archive/231201/00-chatRefactor.sql similarity index 100% rename from db/changes/231201/00-chatRefactor.sql rename to db/.archive/231201/00-chatRefactor.sql diff --git a/db/changes/231201/00-invoiceInSerial.sql b/db/.archive/231201/00-invoiceInSerial.sql similarity index 100% rename from db/changes/231201/00-invoiceInSerial.sql rename to db/.archive/231201/00-invoiceInSerial.sql diff --git a/db/changes/231201/00-itemType_isFragile.sql b/db/.archive/231201/00-itemType_isFragile.sql similarity index 100% rename from db/changes/231201/00-itemType_isFragile.sql rename to db/.archive/231201/00-itemType_isFragile.sql diff --git a/db/changes/231201/00-mailACL.sql b/db/.archive/231201/00-mailACL.sql similarity index 100% rename from db/changes/231201/00-mailACL.sql rename to db/.archive/231201/00-mailACL.sql diff --git a/db/changes/231201/00-operator.sql b/db/.archive/231201/00-operator.sql similarity index 100% rename from db/changes/231201/00-operator.sql rename to db/.archive/231201/00-operator.sql diff --git a/db/changes/231201/00-supplierAccount_deleteTriggers.sql b/db/.archive/231201/00-supplierAccount_deleteTriggers.sql similarity index 100% rename from db/changes/231201/00-supplierAccount_deleteTriggers.sql rename to db/.archive/231201/00-supplierAccount_deleteTriggers.sql diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/.archive/231201/00-ticket_getWarnings.sql similarity index 100% rename from db/changes/231201/00-ticket_getWarnings.sql rename to db/.archive/231201/00-ticket_getWarnings.sql diff --git a/db/changes/231201/00-wagon.sql b/db/.archive/231201/00-wagon.sql similarity index 100% rename from db/changes/231201/00-wagon.sql rename to db/.archive/231201/00-wagon.sql diff --git a/db/changes/231202/00-delivery.sql b/db/.archive/231202/00-delivery.sql similarity index 100% rename from db/changes/231202/00-delivery.sql rename to db/.archive/231202/00-delivery.sql diff --git a/db/changes/231203/00-delivery.sql b/db/.archive/231203/00-delivery.sql similarity index 100% rename from db/changes/231203/00-delivery.sql rename to db/.archive/231203/00-delivery.sql diff --git a/db/changes/231204/00-rollbackDelivery.sql b/db/.archive/231204/00-rollbackDelivery.sql similarity index 100% rename from db/changes/231204/00-rollbackDelivery.sql rename to db/.archive/231204/00-rollbackDelivery.sql diff --git a/db/changes/231205/00-printQueueArgs.sql b/db/.archive/231205/00-printQueueArgs.sql similarity index 100% rename from db/changes/231205/00-printQueueArgs.sql rename to db/.archive/231205/00-printQueueArgs.sql diff --git a/db/changes/231401/00-claimBeginningAfterInsert.sql b/db/.archive/231401/00-claimBeginningAfterInsert.sql similarity index 100% rename from db/changes/231401/00-claimBeginningAfterInsert.sql rename to db/.archive/231401/00-claimBeginningAfterInsert.sql diff --git a/db/changes/231401/00-clientBeforeUpdate.sql b/db/.archive/231401/00-clientBeforeUpdate.sql similarity index 100% rename from db/changes/231401/00-clientBeforeUpdate.sql rename to db/.archive/231401/00-clientBeforeUpdate.sql diff --git a/db/changes/231401/00-hotfixDelivery.sql b/db/.archive/231401/00-hotfixDelivery.sql similarity index 100% rename from db/changes/231401/00-hotfixDelivery.sql rename to db/.archive/231401/00-hotfixDelivery.sql diff --git a/db/changes/231401/00-invoiceOutAfterInsert.sql b/db/.archive/231401/00-invoiceOutAfterInsert.sql similarity index 100% rename from db/changes/231401/00-invoiceOutAfterInsert.sql rename to db/.archive/231401/00-invoiceOutAfterInsert.sql diff --git a/db/changes/231401/00-negativeBases.sql b/db/.archive/231401/00-negativeBases.sql similarity index 100% rename from db/changes/231401/00-negativeBases.sql rename to db/.archive/231401/00-negativeBases.sql diff --git a/db/changes/231401/00-workerNotes.sql b/db/.archive/231401/00-workerNotes.sql similarity index 100% rename from db/changes/231401/00-workerNotes.sql rename to db/.archive/231401/00-workerNotes.sql diff --git a/db/changes/231402/00-negativeBases.sql b/db/.archive/231402/00-negativeBases.sql similarity index 100% rename from db/changes/231402/00-negativeBases.sql rename to db/.archive/231402/00-negativeBases.sql diff --git a/db/changes/231801/00-aclClientInforma.sql b/db/.archive/231801/00-aclClientInforma.sql similarity index 100% rename from db/changes/231801/00-aclClientInforma.sql rename to db/.archive/231801/00-aclClientInforma.sql diff --git a/db/changes/231801/00-acl_receiptEmail.sql b/db/.archive/231801/00-acl_receiptEmail.sql similarity index 100% rename from db/changes/231801/00-acl_receiptEmail.sql rename to db/.archive/231801/00-acl_receiptEmail.sql diff --git a/db/changes/231801/00-clientInforma.sql b/db/.archive/231801/00-clientInforma.sql similarity index 100% rename from db/changes/231801/00-clientInforma.sql rename to db/.archive/231801/00-clientInforma.sql diff --git a/db/changes/231801/00-client_setRatingAcl.sql b/db/.archive/231801/00-client_setRatingAcl.sql similarity index 100% rename from db/changes/231801/00-client_setRatingAcl.sql rename to db/.archive/231801/00-client_setRatingAcl.sql diff --git a/db/changes/231801/00-deleteProcs_refund.sql b/db/.archive/231801/00-deleteProcs_refund.sql similarity index 100% rename from db/changes/231801/00-deleteProcs_refund.sql rename to db/.archive/231801/00-deleteProcs_refund.sql diff --git a/db/changes/231801/00-deviceProduction.sql b/db/.archive/231801/00-deviceProduction.sql similarity index 100% rename from db/changes/231801/00-deviceProduction.sql rename to db/.archive/231801/00-deviceProduction.sql diff --git a/db/changes/231801/00-kkearEntryNotes.sql b/db/.archive/231801/00-kkearEntryNotes.sql similarity index 100% rename from db/changes/231801/00-kkearEntryNotes.sql rename to db/.archive/231801/00-kkearEntryNotes.sql diff --git a/db/changes/231801/00-newCompanyI18n.sql b/db/.archive/231801/00-newCompanyI18n.sql similarity index 100% rename from db/changes/231801/00-newCompanyI18n.sql rename to db/.archive/231801/00-newCompanyI18n.sql diff --git a/db/changes/231801/00-newTableWeb.sql b/db/.archive/231801/00-newTableWeb.sql similarity index 100% rename from db/changes/231801/00-newTableWeb.sql rename to db/.archive/231801/00-newTableWeb.sql diff --git a/db/changes/231801/00-observationEmailACL.sql b/db/.archive/231801/00-observationEmailACL.sql similarity index 100% rename from db/changes/231801/00-observationEmailACL.sql rename to db/.archive/231801/00-observationEmailACL.sql diff --git a/db/changes/231801/00-optimiceZoneEstimatedDelivery.sql b/db/.archive/231801/00-optimiceZoneEstimatedDelivery.sql similarity index 100% rename from db/changes/231801/00-optimiceZoneEstimatedDelivery.sql rename to db/.archive/231801/00-optimiceZoneEstimatedDelivery.sql diff --git a/db/changes/231801/00-saleTracking.sql b/db/.archive/231801/00-saleTracking.sql similarity index 100% rename from db/changes/231801/00-saleTracking.sql rename to db/.archive/231801/00-saleTracking.sql diff --git a/db/changes/231801/00-ticketConfig.sql b/db/.archive/231801/00-ticketConfig.sql similarity index 100% rename from db/changes/231801/00-ticketConfig.sql rename to db/.archive/231801/00-ticketConfig.sql diff --git a/db/changes/231801/00-updateIsVies.sql b/db/.archive/231801/00-updateIsVies.sql similarity index 100% rename from db/changes/231801/00-updateIsVies.sql rename to db/.archive/231801/00-updateIsVies.sql diff --git a/db/changes/231801/00-updateisViesClient.sql b/db/.archive/231801/00-updateisViesClient.sql similarity index 100% rename from db/changes/231801/00-updateisViesClient.sql rename to db/.archive/231801/00-updateisViesClient.sql diff --git a/db/changes/231801/00-userAcl.sql b/db/.archive/231801/00-userAcl.sql similarity index 100% rename from db/changes/231801/00-userAcl.sql rename to db/.archive/231801/00-userAcl.sql diff --git a/db/changes/231801/00-userRoleLog.sql b/db/.archive/231801/00-userRoleLog.sql similarity index 100% rename from db/changes/231801/00-userRoleLog.sql rename to db/.archive/231801/00-userRoleLog.sql diff --git a/db/changes/231801/01-viewCompany10L.sql b/db/.archive/231801/01-viewCompany10L.sql similarity index 100% rename from db/changes/231801/01-viewCompany10L.sql rename to db/.archive/231801/01-viewCompany10L.sql diff --git a/db/changes/232001/00-clientWorkerName.sql b/db/.archive/232001/00-clientWorkerName.sql similarity index 100% rename from db/changes/232001/00-clientWorkerName.sql rename to db/.archive/232001/00-clientWorkerName.sql diff --git a/db/changes/232001/00-createWorker.sql b/db/.archive/232001/00-createWorker.sql similarity index 100% rename from db/changes/232001/00-createWorker.sql rename to db/.archive/232001/00-createWorker.sql diff --git a/db/changes/232001/00-invoiceOut_new.sql b/db/.archive/232001/00-invoiceOut_new.sql similarity index 100% rename from db/changes/232001/00-invoiceOut_new.sql rename to db/.archive/232001/00-invoiceOut_new.sql diff --git a/db/changes/232001/00-wagon.sql b/db/.archive/232001/00-wagon.sql similarity index 100% rename from db/changes/232001/00-wagon.sql rename to db/.archive/232001/00-wagon.sql diff --git a/db/changes/232201/00-defaulterView.sql b/db/.archive/232201/00-defaulterView.sql similarity index 100% rename from db/changes/232201/00-defaulterView.sql rename to db/.archive/232201/00-defaulterView.sql diff --git a/db/changes/232201/00-procedurecanAdvance.sql b/db/.archive/232201/00-procedurecanAdvance.sql similarity index 100% rename from db/changes/232201/00-procedurecanAdvance.sql rename to db/.archive/232201/00-procedurecanAdvance.sql diff --git a/db/changes/232201/00-procedurecanbePostponed.sql b/db/.archive/232201/00-procedurecanbePostponed.sql similarity index 100% rename from db/changes/232201/00-procedurecanbePostponed.sql rename to db/.archive/232201/00-procedurecanbePostponed.sql diff --git a/db/changes/232201/00-workerConfigPayMethod.sql b/db/.archive/232201/00-workerConfigPayMethod.sql similarity index 100% rename from db/changes/232201/00-workerConfigPayMethod.sql rename to db/.archive/232201/00-workerConfigPayMethod.sql diff --git a/db/changes/232202/00-procedurecanAdvance.sql b/db/.archive/232202/00-procedurecanAdvance.sql similarity index 100% rename from db/changes/232202/00-procedurecanAdvance.sql rename to db/.archive/232202/00-procedurecanAdvance.sql diff --git a/db/changes/232202/00-procedurecanbePostponed.sql b/db/.archive/232202/00-procedurecanbePostponed.sql similarity index 100% rename from db/changes/232202/00-procedurecanbePostponed.sql rename to db/.archive/232202/00-procedurecanbePostponed.sql diff --git a/db/changes/232401/.gitkeep b/db/.archive/232401/.gitkeep similarity index 100% rename from db/changes/232401/.gitkeep rename to db/.archive/232401/.gitkeep diff --git a/db/changes/232401/00-buyConfig_travelConfig.sql b/db/.archive/232401/00-buyConfig_travelConfig.sql similarity index 100% rename from db/changes/232401/00-buyConfig_travelConfig.sql rename to db/.archive/232401/00-buyConfig_travelConfig.sql diff --git a/db/changes/232401/00-printer.sql b/db/.archive/232401/00-printer.sql similarity index 100% rename from db/changes/232401/00-printer.sql rename to db/.archive/232401/00-printer.sql diff --git a/db/changes/232401/00-ticket_warehouse.sql b/db/.archive/232401/00-ticket_warehouse.sql similarity index 100% rename from db/changes/232401/00-ticket_warehouse.sql rename to db/.archive/232401/00-ticket_warehouse.sql diff --git a/db/changes/232401/00-userPassExpired.sql b/db/.archive/232401/00-userPassExpired.sql similarity index 100% rename from db/changes/232401/00-userPassExpired.sql rename to db/.archive/232401/00-userPassExpired.sql diff --git a/db/changes/232402/00-hotFix_travelConfig.sql b/db/.archive/232402/00-hotFix_travelConfig.sql similarity index 100% rename from db/changes/232402/00-hotFix_travelConfig.sql rename to db/.archive/232402/00-hotFix_travelConfig.sql diff --git a/db/changes/232601/00-aclAccount.sql b/db/.archive/232601/00-aclAccount.sql similarity index 100% rename from db/changes/232601/00-aclAccount.sql rename to db/.archive/232601/00-aclAccount.sql diff --git a/db/changes/232601/00-aclInvoiceTickets.sql b/db/.archive/232601/00-aclInvoiceTickets.sql similarity index 100% rename from db/changes/232601/00-aclInvoiceTickets.sql rename to db/.archive/232601/00-aclInvoiceTickets.sql diff --git a/db/changes/232601/00-aclMailAliasAccount.sql b/db/.archive/232601/00-aclMailAliasAccount.sql similarity index 100% rename from db/changes/232601/00-aclMailAliasAccount.sql rename to db/.archive/232601/00-aclMailAliasAccount.sql diff --git a/db/changes/232601/00-aclMailForward.sql b/db/.archive/232601/00-aclMailForward.sql similarity index 100% rename from db/changes/232601/00-aclMailForward.sql rename to db/.archive/232601/00-aclMailForward.sql diff --git a/db/changes/232601/00-aclRole.sql b/db/.archive/232601/00-aclRole.sql similarity index 100% rename from db/changes/232601/00-aclRole.sql rename to db/.archive/232601/00-aclRole.sql diff --git a/db/changes/232601/00-aclVnUser.sql b/db/.archive/232601/00-aclVnUser.sql similarity index 100% rename from db/changes/232601/00-aclVnUser.sql rename to db/.archive/232601/00-aclVnUser.sql diff --git a/db/changes/232601/00-aclVnUser_renewToken.sql b/db/.archive/232601/00-aclVnUser_renewToken.sql similarity index 100% rename from db/changes/232601/00-aclVnUser_renewToken.sql rename to db/.archive/232601/00-aclVnUser_renewToken.sql diff --git a/db/changes/232601/00-entry_updateComission.sql b/db/.archive/232601/00-entry_updateComission.sql similarity index 100% rename from db/changes/232601/00-entry_updateComission.sql rename to db/.archive/232601/00-entry_updateComission.sql diff --git a/db/changes/232601/00-packingSiteAdvanced.sql b/db/.archive/232601/00-packingSiteAdvanced.sql similarity index 100% rename from db/changes/232601/00-packingSiteAdvanced.sql rename to db/.archive/232601/00-packingSiteAdvanced.sql diff --git a/db/changes/232601/00-salix.sql b/db/.archive/232601/00-salix.sql similarity index 100% rename from db/changes/232601/00-salix.sql rename to db/.archive/232601/00-salix.sql diff --git a/db/changes/232601/00-useSpecificsAcls.sql b/db/.archive/232601/00-useSpecificsAcls.sql similarity index 100% rename from db/changes/232601/00-useSpecificsAcls.sql rename to db/.archive/232601/00-useSpecificsAcls.sql diff --git a/db/changes/232601/01-invoiceOutPdf.sql b/db/.archive/232601/01-invoiceOutPdf.sql similarity index 100% rename from db/changes/232601/01-invoiceOutPdf.sql rename to db/.archive/232601/01-invoiceOutPdf.sql diff --git a/db/changes/232602/01-aclAddAlias.sql b/db/.archive/232602/01-aclAddAlias.sql similarity index 100% rename from db/changes/232602/01-aclAddAlias.sql rename to db/.archive/232602/01-aclAddAlias.sql diff --git a/db/changes/232801/00-authCode.sql b/db/.archive/232801/00-authCode.sql similarity index 100% rename from db/changes/232801/00-authCode.sql rename to db/.archive/232801/00-authCode.sql diff --git a/db/changes/232801/00-client_create.sql b/db/.archive/232801/00-client_create.sql similarity index 100% rename from db/changes/232801/00-client_create.sql rename to db/.archive/232801/00-client_create.sql diff --git a/db/changes/232801/00-client_create2.sql b/db/.archive/232801/00-client_create2.sql similarity index 100% rename from db/changes/232801/00-client_create2.sql rename to db/.archive/232801/00-client_create2.sql diff --git a/db/changes/232801/00-department.sql b/db/.archive/232801/00-department.sql similarity index 100% rename from db/changes/232801/00-department.sql rename to db/.archive/232801/00-department.sql diff --git a/db/changes/232801/00-fix_editCredit.sql b/db/.archive/232801/00-fix_editCredit.sql similarity index 100% rename from db/changes/232801/00-fix_editCredit.sql rename to db/.archive/232801/00-fix_editCredit.sql diff --git a/db/changes/232801/00-user.sql b/db/.archive/232801/00-user.sql similarity index 100% rename from db/changes/232801/00-user.sql rename to db/.archive/232801/00-user.sql diff --git a/db/changes/232802/01-aclWorkerDisable.sql b/db/.archive/232802/01-aclWorkerDisable.sql similarity index 100% rename from db/changes/232802/01-aclWorkerDisable.sql rename to db/.archive/232802/01-aclWorkerDisable.sql diff --git a/db/changes/234601/.gitkeep b/db/changes/234601/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/package-lock.json b/package-lock.json index c3f88bc2c..5bf7a2cb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "salix-back", - "version": "23.42.01", + "version": "23.46.01", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "salix-back", - "version": "23.42.01", + "version": "23.46.01", "license": "GPL-3.0", "dependencies": { "axios": "^1.2.2", diff --git a/package.json b/package.json index 3320705f5..b1539f9a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.42.01", + "version": "23.46.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From e0b4ac733e32e44225931b38d2f0a16236dfc12c Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 26 Oct 2023 09:30:48 +0200 Subject: [PATCH 31/32] ref #5914 move changes --- db/changes/{234201 => 234601}/00-transferInvoice.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{234201 => 234601}/00-transferInvoice.sql (100%) diff --git a/db/changes/234201/00-transferInvoice.sql b/db/changes/234601/00-transferInvoice.sql similarity index 100% rename from db/changes/234201/00-transferInvoice.sql rename to db/changes/234601/00-transferInvoice.sql From 7ae12327f5e8b81cae9a8c48f82dc938b9df8ed0 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 27 Oct 2023 16:16:22 +0200 Subject: [PATCH 32/32] refs #5134 fix: model ExpeditionScan --- modules/ticket/back/models/expeditionScan.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/models/expeditionScan.json b/modules/ticket/back/models/expeditionScan.json index 1db2c1238..7b95eff1e 100644 --- a/modules/ticket/back/models/expeditionScan.json +++ b/modules/ticket/back/models/expeditionScan.json @@ -8,17 +8,16 @@ "properties": { "id": { "type": "number", - "description": "Identifier" + "description": "Identifier", + "id": true }, "expeditionFk": { "type": "number", - "description": "Identifier", - "id": true + "description": "Identifier" }, "palletFk": { "type": "number", - "description": "Identifier", - "id": true + "description": "Identifier" }, "scanned": { "type": "date",