diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql
index bea56eae6..e917c5eb2 100644
--- a/db/routines/vn/procedures/expeditionPallet_build.sql
+++ b/db/routines/vn/procedures/expeditionPallet_build.sql
@@ -1,5 +1,10 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(IN vExpeditions JSON, IN vArcId INT, IN vWorkerFk INT, OUT vPalletFk INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(
+ vExpeditions JSON,
+ vArcId INT,
+ vWorkerFk INT,
+ OUT vPalletFk INT
+)
BEGIN
/** Construye un pallet de expediciones.
*
@@ -7,28 +12,22 @@ BEGIN
* en cuyo caso actualiza ese pallet.
*
* @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...]
- * @param vArcId INT Identificador de vn.arcRead
- * @param vWorkerFk INT Identificador de vn.worker
- * @param out vPalletFk Identificador de vn.expeditionPallet
+ * @param vArcId INT Identificador de arcRead
+ * @param vWorkerFk INT Identificador de worker
+ * @param out vPalletFk Identificador de expeditionPallet
*/
DECLARE vCounter INT;
DECLARE vExpeditionFk INT;
DECLARE vTruckFk INT;
DECLARE vPrinterFk INT;
+ DECLARE vExpeditionStateTypeFk INT;
- DROP TEMPORARY TABLE IF EXISTS tExpedition;
- CREATE TEMPORARY TABLE tExpedition
- SELECT
- e.id expeditionFk,
- r.id routeFk,
- ep.id palletFk
- FROM
- vn.expedition e,
- vn.route r,
- vn.expeditionPallet ep
- LIMIT 0;
-
- ALTER TABLE tExpedition ADD PRIMARY KEY (expeditionFk);
+ CREATE OR REPLACE TEMPORARY TABLE tExpedition (
+ expeditionFk INT,
+ routeFk INT,
+ palletFk INT,
+ PRIMARY KEY (expeditionFk)
+ );
SET vCounter = JSON_LENGTH(vExpeditions);
@@ -39,53 +38,58 @@ BEGIN
INSERT IGNORE INTO tExpedition(expeditionFk, routeFk, palletFk)
SELECT vExpeditionFk, t.routeFk, es.palletFk
- FROM vn.expedition e
- LEFT JOIN vn.ticket t ON t.id = e.ticketFk
- LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id
+ FROM expedition e
+ LEFT JOIN ticket t ON t.id = e.ticketFk
+ LEFT JOIN expeditionScan es ON es.expeditionFk = e.id
WHERE e.id = vExpeditionFk;
END WHILE;
SELECT palletFk INTO vPalletFk
FROM (
- SELECT palletFk, count(*) n
- FROM tExpedition
- WHERE palletFk > 0
- GROUP BY palletFk
- ORDER BY n DESC
- LIMIT 100 ) sub
+ SELECT palletFk, count(*) n
+ FROM tExpedition
+ WHERE palletFk > 0
+ GROUP BY palletFk
+ ORDER BY n DESC
+ LIMIT 100
+ ) sub
LIMIT 1;
IF vPalletFk IS NULL THEN
- SELECT roadmapStopFk
- INTO vTruckFk
- FROM (
- SELECT rm.roadmapStopFk, count(*) n
- FROM vn.routesMonitor rm
- JOIN tExpedition e ON e.routeFk = rm.routeFk
- GROUP BY roadmapStopFk
- ORDER BY n DESC
- LIMIT 1) sub;
+ SELECT roadmapStopFk INTO vTruckFk
+ FROM (
+ SELECT rm.roadmapStopFk, count(*) n
+ FROM routesMonitor rm
+ JOIN tExpedition e ON e.routeFk = rm.routeFk
+ GROUP BY roadmapStopFk
+ ORDER BY n DESC
+ LIMIT 1
+ ) sub;
IF vTruckFk IS NULL THEN
CALL util.throw ('TRUCK_NOT_AVAILABLE');
END IF;
- INSERT INTO vn.expeditionPallet(truckFk)
- VALUES(vTruckFk);
+ INSERT INTO expeditionPallet SET truckFk = vTruckFk;
SET vPalletFk = LAST_INSERT_ID();
END IF;
- INSERT INTO vn.expeditionScan(expeditionFk, palletFk, workerFk)
+ INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk)
SELECT expeditionFk, vPalletFk, vWorkerFk
FROM tExpedition
ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk;
- SELECT printerFk INTO vPrinterFk
- FROM vn.arcRead
- WHERE id = vArcId;
+ SELECT id INTO vExpeditionStateTypeFk
+ FROM expeditionStateType
+ WHERE code = 'PALLETIZED';
- CALL vn.report_print(
+ INSERT INTO expeditionState(expeditionFk, typeFk)
+ SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition;
+
+ SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId;
+
+ CALL report_print(
'LabelPalletExpedition',
vPrinterFk,
account.myUser_getId(),
@@ -93,7 +97,7 @@ BEGIN
'high'
);
- UPDATE vn.expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk;
+ UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk;
DROP TEMPORARY TABLE tExpedition;
END$$
diff --git a/db/routines/vn/procedures/itemMinimumQuantity_check.sql b/db/routines/vn/procedures/itemMinimumQuantity_check.sql
new file mode 100644
index 000000000..fef7cdbdb
--- /dev/null
+++ b/db/routines/vn/procedures/itemMinimumQuantity_check.sql
@@ -0,0 +1,28 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemMinimumQuantity_check`(
+ vSelf INT,
+ vItemFk INT,
+ vStarted DATE,
+ vEnded DATE,
+ vWarehouseFk INT
+)
+BEGIN
+ DECLARE vHasCollision BOOL;
+
+ IF vStarted IS NULL THEN
+ CALL util.throw('The field "started" cannot be null');
+ END IF;
+
+ SELECT COUNT(*) INTO vHasCollision
+ FROM itemMinimumQuantity
+ WHERE vItemFk = itemFk
+ AND ((vStarted <= ended OR ended IS NULL)
+ AND (vStarted >= `started` OR vEnded IS NULL))
+ AND (vWarehouseFk <=> warehouseFk)
+ AND vSelf <> id;
+
+ IF vHasCollision THEN
+ CALL util.throw('A line with the same configuration already exists');
+ END IF;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql b/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql
index 8833ac968..3ee6c0b1a 100644
--- a/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql
+++ b/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql
@@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemMinimumQuantity_b
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+ CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk);
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql b/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql
index ef030f9f9..6f082551c 100644
--- a/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql
+++ b/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql
@@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemMinimumQuantity_b
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+ CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk);
END$$
DELIMITER ;
diff --git a/db/versions/11118-limeCymbidium/00-firstScript.sql b/db/versions/11118-limeCymbidium/00-firstScript.sql
index 3921a8a13..b15dfbd41 100644
--- a/db/versions/11118-limeCymbidium/00-firstScript.sql
+++ b/db/versions/11118-limeCymbidium/00-firstScript.sql
@@ -16,6 +16,4 @@ INSERT IGNORE INTO account.roleInherit (`role`,`inheritsFrom`)
UPDATE salix.ACL
SET principalId='$authenticated'
- WHERE id=264;
-
-
+ WHERE id=(SELECT id FROM salix.ACL WHERE model='StarredModule' and property='*' and `accessType`='*');
diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js
index 0cb71653e..3a4d5cc47 100644
--- a/modules/entry/back/methods/entry/getBuys.js
+++ b/modules/entry/back/methods/entry/getBuys.js
@@ -1,5 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
-
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
module.exports = Self => {
diff --git a/modules/item/back/models/specs/itemMinimumQuantity.spec.js b/modules/item/back/models/specs/itemMinimumQuantity.spec.js
index 072a80f94..7d1e19def 100644
--- a/modules/item/back/models/specs/itemMinimumQuantity.spec.js
+++ b/modules/item/back/models/specs/itemMinimumQuantity.spec.js
@@ -2,9 +2,10 @@ const {models} = require('vn-loopback/server/server');
describe('itemMinimumQuantity model', () => {
const itemFk = 5;
+ const quantity = 100;
const warehouseFk = 60;
- beforeAll(async() => {
+ beforeEach(async() => {
await models.ItemMinimumQuantity.destroyAll({where: {itemFk: itemFk}});
});
@@ -12,7 +13,7 @@ describe('itemMinimumQuantity model', () => {
it('should create a new itemMinimumQuantity record', async() => {
const newRecord = {
itemFk: itemFk,
- quantity: 100,
+ quantity: quantity,
started: Date.vnNew(),
ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 1)),
warehouseFk: warehouseFk
@@ -27,7 +28,7 @@ describe('itemMinimumQuantity model', () => {
it('should read an existing itemMinimumQuantity record', async() => {
const newRecord = {
itemFk: itemFk,
- quantity: 100,
+ quantity: quantity,
started: Date.vnNew(),
ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 2)),
warehouseFk: warehouseFk
@@ -44,7 +45,7 @@ describe('itemMinimumQuantity model', () => {
it('should update an existing itemMinimumQuantity record', async() => {
const newRecord = {
itemFk: itemFk,
- quantity: 100,
+ quantity: quantity,
started: Date.vnNew(),
ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 3)),
warehouseFk: warehouseFk
@@ -67,7 +68,7 @@ describe('itemMinimumQuantity model', () => {
it('should enforce unique constraint on itemFk, started, ended, and warehouseFk', async() => {
const newRecord = {
itemFk: itemFk,
- quantity: 100,
+ quantity: quantity,
started: Date.vnNew(),
ended: Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 5),
warehouseFk: warehouseFk
@@ -78,14 +79,14 @@ describe('itemMinimumQuantity model', () => {
await models.ItemMinimumQuantity.create(newRecord);
} catch (e) {
expect(e).toBeDefined();
- expect(e.code).toContain('ER_DUP_ENTRY');
+ expect(e.code).toContain('ER_SIGNAL_EXCEPTION');
}
});
it('should allow null values for ended and warehouseFk', async() => {
const newRecord = {
itemFk: itemFk,
- quantity: 100,
+ quantity: quantity,
started: Date.vnNew(),
ended: null,
warehouseFk: null
diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html
index 481cec51a..7fb3b870e 100644
--- a/modules/item/front/diary/index.html
+++ b/modules/item/front/diary/index.html
@@ -1,121 +1,2 @@
-
Given the excellent relationship between our two companies + and to facilitate the payment processes of our invoices, we suggest the use + of the SEPA CORE direct debit system.
+This service involves issuing our receipts to your company in an automated + and electronic manner, which represents a substantial reduction in costs for you + in terms of fees and bank charges.
+If you accept our proposal, on the due date of each payment, it will be automatically + debited from your account through your bank.
+This system is based on the electronic transmission of data; the handling of + physical documents has been eliminated.
+We appreciate your cooperation,
+ conclusion: Thank you for your attention! diff --git a/print/templates/email/sepa-core/locale/es.yml b/print/templates/email/sepa-core/locale/es.yml index 10a1d32fe..a8dd9032e 100644 --- a/print/templates/email/sepa-core/locale/es.yml +++ b/print/templates/email/sepa-core/locale/es.yml @@ -9,9 +9,7 @@ description: forma automatizada y electrónicamente, lo que supone para usted una reducción sustancial de costos en términos de honorarios y gastos bancarios.En caso de que acepte nuestra propuesta, a la fecha de vencimiento de cada efecto, - se debitará a su cuenta automáticamente a través de su entidad bancaria. - Por tanto, le pedimos que firme y envíe a su banco la autorización original adjunta, - debidamente cumplimentada, y nos devuelva una fotocopia de dicha autorización.
+ se debitará a su cuenta automáticamente a través de su entidad bancaria.Este sistema se basa en la transmisión electrónica de datos; el manejo de documentos físicos ha sido eliminado.
Le agradecemos su cooperación,
diff --git a/print/templates/email/sepa-core/locale/fr.yml b/print/templates/email/sepa-core/locale/fr.yml index 98bd7593a..6d76ef24f 100644 --- a/print/templates/email/sepa-core/locale/fr.yml +++ b/print/templates/email/sepa-core/locale/fr.yml @@ -14,11 +14,7 @@ description: et commissions bancaires.Dans le cas où vous accepteriez notre proposition, à l’échéance de chaque effet, votre compte sera débité - automatiquement par votre Banque. - Ainsi, nous vous demandons de signer et envoyer à votre - Banque l'original de l'autorisation pour débit en annexe, - dûment remplie, et de nous retourner une photocopie de la - dite autorisation.
+ automatiquement par votre Banque.Ce système étant basé sur la transmission de données de manière électronique, le maniement de documents physiques á été éliminé
diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql index e05ca2a66..d75366815 100644 --- a/print/templates/reports/buy-label/sql/buys.sql +++ b/print/templates/reports/buy-label/sql/buys.sql @@ -28,4 +28,4 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, LEFT JOIN origin o ON o.id = i.originFk JOIN numbers num WHERE b.entryFk = ? - AND num.n <= b.stickers \ No newline at end of file + AND num.n <= b.stickers diff --git a/print/templates/reports/sepa-core/locale/en.yml b/print/templates/reports/sepa-core/locale/en.yml new file mode 100644 index 000000000..6d7e23501 --- /dev/null +++ b/print/templates/reports/sepa-core/locale/en.yml @@ -0,0 +1,46 @@ +reportName: direct-debit-order +title: SEPA CORE Direct Debit Order +description: By signing this direct debit order, the debtor authorizes (A) the creditor + to send instructions to the debtor's bank to debit their account and (B) the bank to debit + their account according to the creditor's instructions. As part of their rights, + the debtor is entitled to a refund by their bank under the terms and conditions + of the contract signed with the bank. The refund request must be made within + eight weeks of the debit. You can obtain additional information about your rights + from your financial institution. +documentCopy: You must take a signed copy of this document to your Bank for registration to avoid returns. +mandatoryFields: ALL FIELDS MUST BE COMPLETED. +sendOrder: ONCE THIS DIRECT DEBIT ORDER IS SIGNED, IT MUST BE SENT TO THE CREDITOR + FOR SAFEGUARDING AND IT IS RECOMMENDED TO PROVIDE A COPY TO YOUR BANK. +supplier: + toCompleteBySupplier: To be completed by the creditor + orderReference: Direct debit order reference + identifier: Creditor identifier + name: Creditor's name + street: Address + location: Postal Code - City - Province + country: Country +client: + toCompleteByClient: To be completed by the debtor + name: Debtor's name(s) + fiscalId: NIF + street: Debtor's address + location: Postal Code - City - Province + country: Debtor's country + swift: Swift BIC + accountNumber: IBAN + accountHolder: "(Account holder(s))" + accountNumberFormat: In {0}, the IBAN consists of {1} characters always starting with {2} + paymentType: Payment type + recurrent: Recurrent + unique: Unique + signLocation: Date - City + sign: Debtor's signature and stamp +order: Direct Debit Order {0} +Francia: France +España: Spain +Portugal: Portugal +instructions: + title: Instructions + accountFields: Fill in the fields related to the bank account + signDocument: Sign and stamp the document. For it to be valid, the stamp must show the CIF/NIF. If not, the request must be accompanied by an account ownership certificate. + thanks: Thank you for your cooperation! \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 6b941556e..8c4e4911c 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -1,13 +1,12 @@ const vnReport = require('../../../core/mixins/vn-report.js'); -const db = require('../../../core/database'); module.exports = { name: 'sepa-core', mixins: [vnReport], async serverPrefetch() { - this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]); + this.client = await this.findOneFromDef('client', [this.id]); this.checkMainEntity(this.client); - const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.companyId, this.id]); + const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.id]); this.supplier = { ...suppliers[0], accountDetailValue: suppliers.map(val => val?.accountDetailValue) @@ -23,16 +22,5 @@ module.exports = { type: Number, required: true } - }, - methods: { - getSupplierCif() { - return db.findOne(` - SELECT DISTINCT ad.value - FROM supplierAccount sa - JOIN accountDetail ad ON ad.supplierAccountFk = sa.id - JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3 - WHERE sa.supplierFk = ?`) [this.companyId]; - } } - }; diff --git a/print/templates/reports/sepa-core/sql/client.sql b/print/templates/reports/sepa-core/sql/client.sql index b3ba180b3..6e0ec89eb 100644 --- a/print/templates/reports/sepa-core/sql/client.sql +++ b/print/templates/reports/sepa-core/sql/client.sql @@ -1,19 +1,14 @@ -SELECT - c.id, - m.code mandateCode, +SELECT c.id, c.socialName, c.street, c.postcode, c.city, c.fi, - p.name AS province, + p.name province, ct.name country, - ct.code AS countryCode, - ct.ibanLength AS ibanLength -FROM client c - JOIN country ct ON ct.id = c.countryFk - LEFT JOIN mandate m ON m.clientFk = c.id - AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN province p ON p.id = c.provinceFk -WHERE (m.companyFk = ? OR m.companyFk IS NULL) AND c.id = ? -ORDER BY m.created DESC LIMIT 1 \ No newline at end of file + ct.code countryCode, + ct.ibanLength ibanLength + FROM client c + JOIN country ct ON ct.id = c.countryFk + JOIN province p ON p.id = c.provinceFk + WHERE c.id = ? \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 1276f2437..da543147a 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -1,29 +1,24 @@ -SELECT - m.code mandateCode, - s.name, - s.street, - sc.name country, - s.postCode, - s.city, - sp.name province, - s.nif, - sa.supplierFk, - be.name bankName, - ad.value accountDetailValue -FROM - client c - LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN supplier s ON s.id = m.companyFk - LEFT JOIN country sc ON sc.id = s.countryFk - LEFT JOIN province sp ON sp.id = s.provinceFk - LEFT JOIN province p ON p.id = c.provinceFk - LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id - LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id - LEFT JOIN accountDetail ad ON ad.supplierAccountFk = sa.id - JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3 -WHERE - (m.companyFk = ? OR m.companyFk IS NULL) - AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)) -GROUP BY ad.value -ORDER BY -m.created DESC; +SELECT m.code mandateCode, + s.name, + s.street, + sc.name country, + s.postCode, + s.city, + sp.name province, + ad.value accountDetailValue + FROM client c + JOIN mandate m ON m.clientFk = c.id + JOIN mandateType mt ON mt.id = m.mandateTypeFk + JOIN supplier s ON s.id = m.companyFk + LEFT JOIN country sc ON sc.id = s.countryFk + LEFT JOIN province sp ON sp.id = s.provinceFk + JOIN supplierAccount sa ON sa.supplierFk = s.id + JOIN accountDetail ad ON ad.supplierAccountFk = sa.id + JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk + WHERE m.companyFk = ? + AND m.finished IS NULL + AND c.id = ? + AND mt.name = 'CORE' + AND adt.description = 'Referencia Remesas' + GROUP BY m.id, ad.value + ORDER BY m.created DESC \ No newline at end of file