diff --git a/db/routines/vn/procedures/travel_throwAwb.sql b/db/routines/vn/procedures/travel_throwAwb.sql new file mode 100644 index 000000000..1b54f8532 --- /dev/null +++ b/db/routines/vn/procedures/travel_throwAwb.sql @@ -0,0 +1,14 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_throwAwb`(vSelf INT) +BEGIN +/** + * Throws an error if travel does not have a logical AWB + * or there are several AWBs associated with the same DUA + * + * @param vSelf The travel id + */ + IF NOT travel_hasUniqueAwb(vSelf) THEN + CALL util.throw('A different AWB is found in the entries'); + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/entry_beforeInsert.sql b/db/routines/vn/triggers/entry_beforeInsert.sql index c0c0aa28c..17831f1b8 100644 --- a/db/routines/vn/triggers/entry_beforeInsert.sql +++ b/db/routines/vn/triggers/entry_beforeInsert.sql @@ -7,8 +7,8 @@ BEGIN CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.travelFk); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index d56db5e01..e99eb087d 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -25,8 +25,8 @@ BEGIN IF NOT (NEW.travelFk <=> OLD.travelFk) THEN - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.travelFk); END IF; SELECT COUNT(*) > 0 INTO vIsVirtual diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 817bd69bb..e54a5d08b 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -9,8 +9,8 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); - IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF NEW.awbFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.id); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 5e43c8761..5e64ad5b3 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -33,8 +33,8 @@ BEGIN END IF; END IF; - IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.id); END IF; END$$ DELIMITER ; diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index 2f5999359..4f809a716 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -59,7 +59,7 @@ describe('Client Add address path', () => { await page.waitToClick(selectors.clientAddresses.saveButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Customs agent is required for a non UEE member'); + expect(message.text).toContain('Incoterms and Customs agent are required for a non UEE member'); }); it(`should create a new custom agent and then save the address`, async() => { diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 412a7a17e..b65b9c852 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -230,4 +230,3 @@ "You can only have one PDA": "You can only have one PDA", "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member" } -} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index fff7ebf70..14b40f5de 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -360,5 +360,6 @@ "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", "You can only have one PDA": "Solo puedes tener un PDA", - "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE" + "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", + "You can not use the same password": "No puedes usar la misma contraseña" }