diff --git a/CHANGELOG.md b/CHANGELOG.md index fff8b03e6..bf8cfd17c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,11 +16,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - (Entradas -> Compras) Cambiados los campos "Precio Grouping/Packing" por "PVP" y "Precio" por "Coste" - (Artículos -> Últimas entradas) Cambiados los campos "P.P.U." y "P.P.P." por "PVP" +- (Rutas -> Sumario/Tickets) Actualizados campos de los tickets +- (Proveedores -> Crear/Editar) Permite añadir Proveedores con la misma razón social pero con países distintos - (Tickets -> Adelantar tickets) Cambiados selectores de estado por checks "Pendiente origen/destino" - (Tickets -> Adelantar tickets) Cambiado stock de destino a origen. ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. +- (Cliente -> Datos Fiscales) No se permite seleccionar 'Notificar vía e-mail' a los clientes sin e-mail +- (Tickets -> Datos básicos) Permite guardar la hora de envío - (Tickets -> Añadir pago) Eliminado "null" en las referencias - (Tickets -> Adelantar tickets) Permite ordenar por importe - (Tickets -> Adelantar tickets) El filtrado por encajado muestra también los tickets sin tipo de encajado diff --git a/db/changes/230201/00-SupplierUniqueKey.sql b/db/changes/230201/00-SupplierUniqueKey.sql new file mode 100644 index 000000000..9c0d4a192 --- /dev/null +++ b/db/changes/230201/00-SupplierUniqueKey.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`supplier` ADD UNIQUE (name, countryFk); diff --git a/db/changes/230401/00-updateIsToBeMailed.sql b/db/changes/230401/00-updateIsToBeMailed.sql new file mode 100644 index 000000000..1bb177f57 --- /dev/null +++ b/db/changes/230401/00-updateIsToBeMailed.sql @@ -0,0 +1,6 @@ +UPDATE `vn`.`client` + SET isToBeMailed = FALSE + WHERE + mailAddress is NULL + AND email is NULL + AND isToBeMailed = TRUE; diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 772d6055d..4626279e4 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -80203,4 +80203,3 @@ USE `vncontrol`; -- Dump completed on 2022-11-21 7:57:28 - diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 347396c94..32f1de99f 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -944,9 +944,9 @@ export default { routeSummary: { header: 'vn-route-summary > vn-card > h5', cost: 'vn-route-summary vn-label-value[label="Cost"]', - firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(2) > span', + firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10) > span', firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor', - firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span', + firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(5) > span', firstClientDescriptor: '.vn-popover.shown vn-client-descriptor', goToRouteSummaryButton: 'vn-route-summary > vn-card > h5 > a', diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a406b55a5..c810e5a69 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -67,7 +67,7 @@ "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", - "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked", + "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked", "Claim state has changed to incomplete": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*", "Claim state has changed to canceled": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", @@ -137,15 +137,18 @@ "Password does not meet requirements": "Password does not meet requirements", "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", "Not enough privileges to edit a client": "Not enough privileges to edit a client", - "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", + "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", "You don't have grant privilege": "You don't have grant privilege", "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", - "Email verify": "Email verify", + "Email verify": "Email verify", "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "Sale(s) blocked, please contact production": "Sale(s) blocked, please contact production", "App locked": "App locked by user {{userId}}", - "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", - "Receipt's bank was not found": "Receipt's bank was not found", - "This receipt was not compensated": "This receipt was not compensated", - "Client's email was not found": "Client's email was not found" + "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", + "Receipt's bank was not found": "Receipt's bank was not found", + "This receipt was not compensated": "This receipt was not compensated", + "Client's email was not found": "Client's email was not found", + "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", + "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", + "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", + "Valid priorities: 1,2,3": "Valid priorities: 1,2,3" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d65054f37..ad6d53d64 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -84,7 +84,6 @@ "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", - "Sale(s) blocked, contact production": "Linea(s) bloqueada(s), contacte con produccion", "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", @@ -259,5 +258,11 @@ "Try again": "Vuelve a intentarlo", "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", "Failed to upload file": "Error al subir archivo", - "The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists" + "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" } + diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index e07993f79..2d8e7bd27 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -141,6 +141,16 @@ module.exports = Self => { done(); } + Self.validateAsync('isToBeMailed', isToBeMailed, { + message: 'There is no assigned email for this client' + }); + + function isToBeMailed(err, done) { + if (this.isToBeMailed == true && !this.email) + err(); + done(); + } + Self.validateAsync('defaultAddressFk', isActive, {message: 'Unable to default a disabled consignee'} ); diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 708644c1a..1eb9e27f5 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -50,14 +50,17 @@ module.exports = Self => { am.name AS agencyModeName, u.nickname AS userNickname, vn.ticketTotalVolume(t.id) AS volume, - tob.description + tob.description, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt FROM vn.route r JOIN ticket t ON t.routeFk = r.id + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN warehouse wh ON wh.id = t.warehouseFk LEFT JOIN observationType ot ON ot.code = 'delivery' - LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = ot.id LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk @@ -70,7 +73,9 @@ module.exports = Self => { const where = filter.where; where['r.id'] = filter.id; - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge(conn.makeGroupBy('t.id')); + stmt.merge(conn.makeOrderBy(filter.order)); const tickets = await conn.executeStmt(stmt, myOptions); diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 86f558634..a64ad4ff7 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -10,26 +10,26 @@ - - - - - {{$ctrl.summary.route.worker.user.name}} - @@ -40,35 +40,35 @@ - - - -

- Ticket

-

Ticket @@ -77,45 +77,49 @@ Order - Ticket id - Alias + Street + City + PC + Client + Warehouse Packages - Warehouse - PC - Street + Packaging + Ticket {{ticket.priority | dashIfEmpty}} + {{ticket.street}} + {{ticket.city}} + {{ticket.postalCode}} + + + {{ticket.nickname}} + + + {{ticket.warehouseName}} + {{ticket.packages}} + {{ticket.volume}} + {{ticket.ipt}} - {{ticket.id}} - - {{ticket.nickname}} - - - {{ticket.packages}} - {{ticket.volume}} - {{ticket.warehouseName}} - {{ticket.postalCode}} - {{ticket.street}} - - - + + @@ -123,12 +127,12 @@ - - diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index dae894ac7..18d6fb160 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -6,9 +6,9 @@ data="$ctrl.tickets" auto-load="true"> - -
@@ -25,18 +25,18 @@ vn-tooltip="Open buscaman" icon="icon-buscaman"> - - - City PC Client + Warehouse Packages + Packaging Ticket @@ -100,8 +102,10 @@ {{::ticket.nickname}} + {{ticket.warehouseName}} {{::ticket.packages}} {{::ticket.volume | number:2}} + {{::ticket.ipt}}
- - @@ -160,7 +164,7 @@
-
- - - \ No newline at end of file + diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 44549c65c..4e509aafc 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -16,10 +16,6 @@ module.exports = Self => { message: 'The social name cannot be empty' }); - Self.validatesUniquenessOf('name', { - message: 'The supplier name must be unique' - }); - if (this.city) { Self.validatesPresenceOf('city', { message: 'City cannot be empty' @@ -117,6 +113,27 @@ module.exports = Self => { throw new UserError('You can not modify is pay method checked'); }); + Self.validateAsync('name', 'countryFk', hasSupplierSameName, { + message: 'A supplier with the same name already exists. Change the country.' + }); + + async function hasSupplierSameName(err, done) { + if (!this.name || !this.countryFk) done(); + const supplier = await Self.app.models.Supplier.findOne( + { + where: { + name: this.name, + countryFk: this.countryFk + }, + fields: ['id'] + }); + + if (supplier && supplier.id != this.id) + err(); + + done(); + } + Self.observe('before save', async function(ctx) { const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; diff --git a/modules/ticket/back/methods/sale/canEdit.js b/modules/ticket/back/methods/sale/canEdit.js index f44bd6743..3091ebca7 100644 --- a/modules/ticket/back/methods/sale/canEdit.js +++ b/modules/ticket/back/methods/sale/canEdit.js @@ -56,6 +56,13 @@ module.exports = Self => { const shouldEditCloned = canEditCloned || !hasSaleCloned; const shouldEditFloramondo = canEditFloramondo || !hasSaleFloramondo; - return shouldEditTracked && shouldEditCloned && shouldEditFloramondo; + if (!shouldEditTracked) + throw new UserError('It is not possible to modify tracked sales'); + if (!shouldEditCloned) + throw new UserError('It is not possible to modify cloned sales'); + if (!shouldEditFloramondo) + throw new UserError('It is not possible to modify sales that their articles are from Floramondo'); + + return true; }; }; diff --git a/modules/ticket/back/methods/sale/deleteSales.js b/modules/ticket/back/methods/sale/deleteSales.js index c045b9197..5d1463a66 100644 --- a/modules/ticket/back/methods/sale/deleteSales.js +++ b/modules/ticket/back/methods/sale/deleteSales.js @@ -43,9 +43,7 @@ module.exports = Self => { try { const saleIds = sales.map(sale => sale.id); - const canEditSales = await models.Sale.canEdit(ctx, saleIds, myOptions); - if (!canEditSales) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, saleIds, myOptions); const ticket = await models.Ticket.findById(ticketId, { include: { diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js index 38c68d7f6..2c8e6768b 100644 --- a/modules/ticket/back/methods/sale/recalculatePrice.js +++ b/modules/ticket/back/methods/sale/recalculatePrice.js @@ -37,9 +37,7 @@ module.exports = Self => { try { const salesIds = sales.map(sale => sale.id); - const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, salesIds, myOptions); const query = ` DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales; diff --git a/modules/ticket/back/methods/sale/reserve.js b/modules/ticket/back/methods/sale/reserve.js index 648e6de23..2dc368af6 100644 --- a/modules/ticket/back/methods/sale/reserve.js +++ b/modules/ticket/back/methods/sale/reserve.js @@ -51,9 +51,7 @@ module.exports = Self => { try { const salesIds = sales.map(sale => sale.id); - const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, salesIds, myOptions); let changesMade = ''; const promises = []; diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js index 2aa873df5..58d8f0635 100644 --- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js +++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js @@ -50,7 +50,7 @@ describe('sale canEdit()', () => { it('should return false if any of the sales has a saleTracking record', async() => { const tx = await models.Sale.beginTransaction({}); - + let error; try { const options = {transaction: tx}; @@ -59,15 +59,15 @@ describe('sale canEdit()', () => { const sales = [31]; - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(false); - + await models.Sale.canEdit(ctx, sales, options); await tx.rollback(); } catch (e) { await tx.rollback(); - throw e; + error = e; } + + expect(error).toEqual( + new Error('It is not possible to modify tracked sales')); }); }); @@ -75,22 +75,22 @@ describe('sale canEdit()', () => { const saleCloned = [29]; it('should return false if any of the sales is cloned', async() => { const tx = await models.Sale.beginTransaction({}); - + let error; try { const options = {transaction: tx}; const buyerId = 35; const ctx = {req: {accessToken: {userId: buyerId}}}; - const result = await models.Sale.canEdit(ctx, saleCloned, options); - - expect(result).toEqual(false); - + await models.Sale.canEdit(ctx, saleCloned, options); await tx.rollback(); } catch (e) { await tx.rollback(); - throw e; + error = e; } + + expect(error).toEqual( + new Error('It is not possible to modify cloned sales')); }); it('should return true if any of the sales is cloned and has the correct role', async() => { @@ -130,7 +130,7 @@ describe('sale canEdit()', () => { it('should return false if any of the sales isFloramondo', async() => { const tx = await models.Sale.beginTransaction({}); const sales = [26]; - + let error; try { const options = {transaction: tx}; @@ -140,15 +140,15 @@ describe('sale canEdit()', () => { const saleToEdit = await models.Sale.findById(sales[0], null, options); await saleToEdit.updateAttribute('itemFk', 9, options); - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(false); - + await models.Sale.canEdit(ctx, sales, options); await tx.rollback(); } catch (e) { await tx.rollback(); - throw e; + error = e; } + + expect(error).toEqual( + new Error('It is not possible to modify sales that their articles are from Floramondo')); }); it('should return true if any of the sales is of isFloramondo and has the correct role', async() => { diff --git a/modules/ticket/back/methods/sale/updateConcept.js b/modules/ticket/back/methods/sale/updateConcept.js index 0730f85e2..dcd25dcbb 100644 --- a/modules/ticket/back/methods/sale/updateConcept.js +++ b/modules/ticket/back/methods/sale/updateConcept.js @@ -40,10 +40,7 @@ module.exports = Self => { try { const currentLine = await models.Sale.findById(id, null, myOptions); - const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions); - - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, [id], myOptions); const line = await currentLine.updateAttributes({concept: newConcept}, myOptions); diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 8f27e1af5..505de5180 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -66,9 +66,7 @@ module.exports = Self => { const sale = await models.Sale.findById(id, filter, myOptions); - const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, [id], myOptions); const oldPrice = sale.price; const userId = ctx.req.accessToken.userId; diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js index 8cf0720ce..d2927c65c 100644 --- a/modules/ticket/back/methods/sale/updateQuantity.js +++ b/modules/ticket/back/methods/sale/updateQuantity.js @@ -41,9 +41,7 @@ module.exports = Self => { } try { - const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, [id], myOptions); const filter = { include: { diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index f532265e2..99782de44 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -75,8 +75,10 @@ class Controller extends Component { } set shipped(value) { + if (new Date(this.ticket.shipped).toDateString() != value.toDateString()) + value.setHours(0, 0, 0, 0); + this.ticket.shipped = value; - this.ticket.shipped.setHours(0, 0, 0, 0); this.getLanded({ shipped: value, addressFk: this.ticket.addressFk, diff --git a/print/templates/reports/receipt/receipt.html b/print/templates/reports/receipt/receipt.html index 5dd4299be..be0bfc375 100644 --- a/print/templates/reports/receipt/receipt.html +++ b/print/templates/reports/receipt/receipt.html @@ -4,7 +4,7 @@

{{$t('title')}}

- Recibo de {{client.socialName}}, + Recibo #{{receipt.id}} de {{client.socialName}}, la cantidad de {{receipt.amountPaid}} € en concepto de 'entrega a cuenta'.