From d1ef1c80f8271026905e45fd2790160984ae5de1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 3 Jul 2024 09:36:20 +0200 Subject: [PATCH 01/25] feat: refs #7382 Added unique key --- db/versions/11127-silverMoss/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11127-silverMoss/00-firstScript.sql diff --git a/db/versions/11127-silverMoss/00-firstScript.sql b/db/versions/11127-silverMoss/00-firstScript.sql new file mode 100644 index 000000000..aae2e857e --- /dev/null +++ b/db/versions/11127-silverMoss/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceInTax ADD CONSTRAINT invoiceInTax_unique UNIQUE KEY (invoiceInFk,expenseFk); From 2278b9a05aa25835ded18b6f2ff784ba5d88ff3f Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 3 Jul 2024 14:20:43 +0200 Subject: [PATCH 02/25] feat: refs #7382 Changes --- .../vn/procedures/invoiceIn_booking.sql | 25 +++++++++++++------ .../11127-silverMoss/00-firstScript.sql | 1 - 2 files changed, 18 insertions(+), 8 deletions(-) delete mode 100644 db/versions/11127-silverMoss/00-firstScript.sql diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index cd838861a..decbb7b1a 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -13,20 +13,31 @@ BEGIN * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo */ DECLARE vFiscalYear INT; - DECLARE vHasDistinctTransactions INT; + DECLARE vDistinctTransactions INT; + DECLARE vHasRepeatedTransactions BOOL; - SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions - FROM invoiceIn ii - JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id + SELECT COUNT(DISTINCT iit.transactionTypeSageFk) INTO vDistinctTransactions + FROM invoiceInTax iit JOIN invoiceInSerial iis ON iis.code = ii.serial - WHERE ii.id = vSelf + WHERE iit.invoiceInFk = vSelf AND iis.taxAreaFk = 'CEE' - AND transactionTypeSageFk; + AND iit.transactionTypeSageFk; - IF vHasDistinctTransactions > 1 THEN + IF vDistinctTransactions > 1 THEN CALL util.throw ('This invoice does not allow different types of transactions'); END IF; + SELECT TRUE INTO vHasRepeatedTransactions + FROM invoiceInTax + WHERE invoiceInFk = vSelf + GROUP BY transactionTypeSageFk + HAVING COUNT(transactionTypeSageFk) > 1 + LIMIT 1; + + IF vHasRepeatedTransactions THEN + CALL util.throw ('This invoice contains repeated types of transactions'); + END IF; + CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn ENGINE = MEMORY SELECT ii.bookEntried, diff --git a/db/versions/11127-silverMoss/00-firstScript.sql b/db/versions/11127-silverMoss/00-firstScript.sql deleted file mode 100644 index aae2e857e..000000000 --- a/db/versions/11127-silverMoss/00-firstScript.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.invoiceInTax ADD CONSTRAINT invoiceInTax_unique UNIQUE KEY (invoiceInFk,expenseFk); From 246b34571d786f8fbf635038304135629ab16077 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 3 Jul 2024 14:24:26 +0200 Subject: [PATCH 03/25] feat: refs #7382 Fix --- db/routines/vn/procedures/invoiceIn_booking.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index decbb7b1a..c194a774d 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -17,7 +17,8 @@ BEGIN DECLARE vHasRepeatedTransactions BOOL; SELECT COUNT(DISTINCT iit.transactionTypeSageFk) INTO vDistinctTransactions - FROM invoiceInTax iit + FROM invoiceIn ii + JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id JOIN invoiceInSerial iis ON iis.code = ii.serial WHERE iit.invoiceInFk = vSelf AND iis.taxAreaFk = 'CEE' From fcec3bc0ae24f5972281e3ce417a650671407b57 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 4 Jul 2024 09:54:09 +0200 Subject: [PATCH 04/25] refs #5525 fix sql accountDetail --- print/templates/reports/sepa-core/sepa-core.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 96c512a9d..f32fd92e7 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -27,7 +27,8 @@ module.exports = { FROM supplierAccount sa JOIN company co ON co.supplierAccountFk = sa.id JOIN supplier s ON sa.supplierFk = s.id - WHERE co.id = ?`) [this.companyId]; + WHERE co.id = ? + AND ad.accountDetailTypeFk = 3`) [this.companyId]; } } From cf621071d07c849b072173ce1baf718eaa0c1c0c Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 4 Jul 2024 16:50:54 +0200 Subject: [PATCH 05/25] refs #5525 fixear sql, fixtures, js --- db/dump/fixtures.before.sql | 15 +++++++++++++++ print/templates/reports/sepa-core/sepa-core.html | 3 +-- print/templates/reports/sepa-core/sepa-core.js | 15 +++++++++------ .../templates/reports/sepa-core/sql/supplier.sql | 14 ++++++++------ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index b6275d03c..05c1bbaa7 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3884,3 +3884,18 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli (1, '2001-05-17', 1, 5), (1, '2001-05-18', 1, 5); +INSERT INTO vn.accountDetail +(id, value, accountDetailTypeFk, supplierAccountFk) +VALUES + (21, 'ES12345B12345678', 3, 241), + (35, 'ES12346B12345679', 3, 241); + +INSERT INTO vn.accountDetailType +(id, description) +VALUES + (1, 'IBAN'), + (2, 'SWIFT'), + (3, 'Referencia Remesas'), + (4, 'Referencia Transferencias'), + (5, 'Referencia Nominas'), + (6, 'ABA'); diff --git a/print/templates/reports/sepa-core/sepa-core.html b/print/templates/reports/sepa-core/sepa-core.html index 363ebdfe5..e5d14d06c 100644 --- a/print/templates/reports/sepa-core/sepa-core.html +++ b/print/templates/reports/sepa-core/sepa-core.html @@ -27,8 +27,7 @@ {{$t('supplier.identifier')}} -
{{supplier.iban}}
-
{{supplier.nif}}
+
{{supplier.accountDetailValue.join(', ')}}
diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index f32fd92e7..6b941556e 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -7,7 +7,11 @@ module.exports = { async serverPrefetch() { this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]); this.checkMainEntity(this.client); - this.supplier = await this.findOneFromDef('supplier', [this.companyId, this.companyId, this.id]); + const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.companyId, this.id]); + this.supplier = { + ...suppliers[0], + accountDetailValue: suppliers.map(val => val?.accountDetailValue) + }; }, props: { id: { @@ -23,12 +27,11 @@ module.exports = { methods: { getSupplierCif() { return db.findOne(` - SELECT sa.iban, s.nif + SELECT DISTINCT ad.value FROM supplierAccount sa - JOIN company co ON co.supplierAccountFk = sa.id - JOIN supplier s ON sa.supplierFk = s.id - WHERE co.id = ? - AND ad.accountDetailTypeFk = 3`) [this.companyId]; + 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/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 156fc71c0..a49896244 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -1,15 +1,16 @@ SELECT - m.code mandateCode, + m.code AS mandateCode, s.name, s.street, - sc.name country, + sc.name AS country, s.postCode, s.city, - sp.name province, + sp.name AS province, s.nif, sa.iban, sa.supplierFk, - be.name bankName + be.name AS bankName, + ad.value AS accountDetailValue FROM client c LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL @@ -19,9 +20,10 @@ FROM 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 + LEFT 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)) ORDER BY - m.created DESC -LIMIT 1; + m.created DESC; From 64f5ad0e1960155c66c334a3b893a4a2d55c40fe Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 4 Jul 2024 16:54:57 +0200 Subject: [PATCH 06/25] refs #5525 remove AS --- print/templates/reports/sepa-core/sql/supplier.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index a49896244..a32d311de 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -1,16 +1,16 @@ SELECT - m.code AS mandateCode, + m.code mandateCode, s.name, s.street, - sc.name AS country, + sc.name country, s.postCode, s.city, - sp.name AS province, + sp.name province, s.nif, sa.iban, sa.supplierFk, - be.name AS bankName, - ad.value AS accountDetailValue + 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 From 859f610f43a1760631bd24bc16fe013b3ea8a526 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 5 Jul 2024 08:43:45 +0200 Subject: [PATCH 07/25] hotFix itemNewer refs #6964 --- .../methods/item-shelving/getListItemNewer.js | 2 +- .../specs/getListItemNewer.spec.js | 25 +++++-------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js index 1702bb05b..dafefe712 100644 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -63,7 +63,7 @@ module.exports = Self => { FROM tItemShelving ti JOIN tItemInSector tis ON tis.itemFk = ti.itemFk JOIN vn.productionConfig pc - WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`, + WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created ;`, [shelvingFk, shelvingFk], myOptions); return result; }; diff --git a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js index 15c480992..9287a179d 100644 --- a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js +++ b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js @@ -2,30 +2,17 @@ const {models} = require('vn-loopback/server/server'); describe('itemShelving getListItemNewer()', () => { - it('should return true because there is an older item', async() => { - const shelving = 'NCC'; - const parking = 'A-47-1'; + fit('should return true because there is an older item', async() => { + const shelving = 'NBB'; + const parking = '700-01'; - const sectorCamHighCode = 'CAMARA SECTOR D'; - const sectorCamCode = 'NAVE ALGEMESI'; - - const sectorCamCodeHighId = 1; - const sectorCamCodeId = 9991; + const sectorCamHighCode = 'FIRST'; + const sectorCamCode = 'NS'; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; try { - const sectorHighCam = await models.Sector.findById(sectorCamCodeHighId, null, myOptions); - await sectorHighCam.updateAttributes({ - code: sectorCamHighCode - }); - - const sectorCam = await models.Sector.findById(sectorCamCodeId, null, myOptions); - await sectorCam.updateAttributes({ - code: sectorCamCode - }); - const config = await models.ProductionConfig.findOne(); await config.updateAttributes({ @@ -35,7 +22,7 @@ describe('itemShelving getListItemNewer()', () => { const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions); - expect(result.length).toEqual(2); + expect(result.length).toEqual(3); await tx.rollback(); } catch (e) { await tx.rollback(); From 159f2f5f1c4b73a48fc994c1a17d97a48038e1b6 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 5 Jul 2024 08:44:09 +0200 Subject: [PATCH 08/25] hotFix itemNewer refs #6964 --- .../back/methods/item-shelving/specs/getListItemNewer.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js index 9287a179d..962863095 100644 --- a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js +++ b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js @@ -2,7 +2,7 @@ const {models} = require('vn-loopback/server/server'); describe('itemShelving getListItemNewer()', () => { - fit('should return true because there is an older item', async() => { + it('should return true because there is an older item', async() => { const shelving = 'NBB'; const parking = '700-01'; From 923efadf6a760bbeb207e096acf20861cc83bc50 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 5 Jul 2024 09:00:40 +0200 Subject: [PATCH 09/25] fix: refs #6371 restore table Series --- db/dump/.dump/structure.sql | 44 +++++++++---------- .../11134-silverRaphis/00-firstScript.sql | 42 ++++++++++++++++++ 2 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 db/versions/11134-silverRaphis/00-firstScript.sql diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 6797c01a5..5755ce085 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -19,7 +19,7 @@ -- Current Database: `account` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `account` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; +CREATE DATABASE /*!32312 */ `account` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; USE `account`; @@ -2230,7 +2230,7 @@ DELIMITER ; -- Current Database: `bi` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `bi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `bi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `bi`; @@ -4000,7 +4000,7 @@ DELIMITER ; -- Current Database: `bs` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `bs` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `bs` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `bs`; @@ -6967,7 +6967,7 @@ DELIMITER ; -- Current Database: `cache` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `cache` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `cache` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `cache`; @@ -8087,7 +8087,7 @@ DELIMITER ; -- Current Database: `dipole` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `dipole` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `dipole` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `dipole`; @@ -8316,7 +8316,7 @@ DELIMITER ; -- Current Database: `edi` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `edi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `edi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `edi`; @@ -11054,7 +11054,7 @@ DELIMITER ; -- Current Database: `floranet` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `floranet` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `floranet` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `floranet`; @@ -11638,7 +11638,7 @@ DELIMITER ; -- Current Database: `hedera` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `hedera` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `hedera` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `hedera`; @@ -15833,7 +15833,7 @@ DELIMITER ; -- Current Database: `pbx` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `pbx` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `pbx` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `pbx`; @@ -16499,7 +16499,7 @@ DELIMITER ; -- Current Database: `psico` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `psico` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `psico` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `psico`; @@ -16834,7 +16834,7 @@ DELIMITER ; -- Current Database: `sage` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `sage` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; +CREATE DATABASE /*!32312 */ `sage` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; USE `sage`; @@ -19146,7 +19146,7 @@ DELIMITER ; -- Current Database: `salix` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `salix` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `salix` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `salix`; @@ -19440,7 +19440,7 @@ DELIMITER ; -- Current Database: `srt` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `srt` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `srt` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `srt`; @@ -22991,7 +22991,7 @@ DELIMITER ; -- Current Database: `stock` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `stock` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; +CREATE DATABASE /*!32312 */ `stock` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; USE `stock`; @@ -24069,7 +24069,7 @@ DELIMITER ; -- Current Database: `tmp` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `tmp` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `tmp` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `tmp`; @@ -24147,7 +24147,7 @@ DELIMITER ; -- Current Database: `util` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `util` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `util` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `util`; @@ -26252,7 +26252,7 @@ DELIMITER ; -- Current Database: `vn` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `vn` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `vn`; @@ -63220,7 +63220,7 @@ BEGIN * @param vDate -> Date of the purchase operation. * @param vWarehouseFk -> Identifier of the warehouse (warehouseId). */ - ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT; + ALTER TABLE tmp.itemInventory ADD buy_id INT; CALL buyUltimate(vWarehouseFk, vDate); @@ -68883,7 +68883,7 @@ proc: BEGIN CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); - IF NOT EXISTS (SELECT TRUE FROM tmp.zoneGetLanded LIMIT 1) THEN + (SELECT TRUE FROM tmp.zoneGetLanded LIMIT 1) THEN CALL util.throw(CONCAT('There is no zone for these parameters ', vTicketFk)); END IF; @@ -77852,11 +77852,11 @@ BEGIN IF vWorkerFk THEN CALL timeControl_calculateByUser(vWorkerFk, vDatedFrom , vDatedTimeTo); - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` + CREATE TEMPORARY TABLE tmp.`user` SELECT vWorkerFk userFk; ELSE CALL timeControl_calculateAll(vDatedFrom, vDatedTimeTo); - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` + CREATE TEMPORARY TABLE tmp.`user` SELECT id userFk FROM worker w; END IF; @@ -81544,7 +81544,7 @@ DELIMITER ; -- Current Database: `vn2008` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn2008` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 */ `vn2008` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `vn2008`; diff --git a/db/versions/11134-silverRaphis/00-firstScript.sql b/db/versions/11134-silverRaphis/00-firstScript.sql new file mode 100644 index 000000000..0836abe4e --- /dev/null +++ b/db/versions/11134-silverRaphis/00-firstScript.sql @@ -0,0 +1,42 @@ +USE `vn`; + +CREATE TABLE IF NOT EXISTS vn.`tillSerial` ( + `code` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `account` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES(' S', 'Saldos final / inicial', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('A', 'Factura cliente', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('B', 'Factura cliente', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('C', 'Facturas Contado', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CC', 'Cuadre caja', '6780000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CD', 'Cuenta Director Comercial', '5510000002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CH', 'Cheques', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CM', 'Cambio', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CR', 'Ingreso/Reintegro Caja Rural', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CT', 'Correos y telégrafos', '6290000005'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DC', 'Dietas conductores', '6290000010'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DH', 'Deudas Holland', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DT', 'Dietas', '6290000011'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('E', 'Entrada mercancia', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('EN', 'Enric Martinez', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GC', 'Cuenta con dto. Comercial', '5510000003'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GP', 'Gastos de personal', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GR', 'Gastos RRPP dpto comercial', '6290001002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GS', 'Gasoil', '6280000002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GV', 'Gastos viaje', '6290001000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('JV', 'Juanvi', '6290000553'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MB', 'Movimiento bancario', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MP', 'Materias Primas', '6000000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('OG', 'Otros gastos', '6290000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('PM', 'Pequeño material', '6290000007'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('R', 'Factura proveedor', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RC', 'Ingreso/Reintegro Ruralcaja', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RN', 'Reparación nave', '6220000004'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('SS', 'Gastos Silla', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('T', 'Ticket', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TA', 'Factura rapida', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TC', 'Ticket contado', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TR', 'Traspaso', NULL); \ No newline at end of file From 27a4b747b5595a50087b34ae0fa866612bd09d0b Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 5 Jul 2024 09:05:39 +0200 Subject: [PATCH 10/25] fix: refs #6371 restore table Series --- .../11134-silverRaphis/00-firstScript.sql | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 db/versions/11134-silverRaphis/00-firstScript.sql diff --git a/db/versions/11134-silverRaphis/00-firstScript.sql b/db/versions/11134-silverRaphis/00-firstScript.sql new file mode 100644 index 000000000..0836abe4e --- /dev/null +++ b/db/versions/11134-silverRaphis/00-firstScript.sql @@ -0,0 +1,42 @@ +USE `vn`; + +CREATE TABLE IF NOT EXISTS vn.`tillSerial` ( + `code` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `account` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES(' S', 'Saldos final / inicial', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('A', 'Factura cliente', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('B', 'Factura cliente', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('C', 'Facturas Contado', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CC', 'Cuadre caja', '6780000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CD', 'Cuenta Director Comercial', '5510000002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CH', 'Cheques', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CM', 'Cambio', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CR', 'Ingreso/Reintegro Caja Rural', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CT', 'Correos y telégrafos', '6290000005'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DC', 'Dietas conductores', '6290000010'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DH', 'Deudas Holland', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DT', 'Dietas', '6290000011'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('E', 'Entrada mercancia', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('EN', 'Enric Martinez', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GC', 'Cuenta con dto. Comercial', '5510000003'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GP', 'Gastos de personal', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GR', 'Gastos RRPP dpto comercial', '6290001002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GS', 'Gasoil', '6280000002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GV', 'Gastos viaje', '6290001000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('JV', 'Juanvi', '6290000553'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MB', 'Movimiento bancario', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MP', 'Materias Primas', '6000000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('OG', 'Otros gastos', '6290000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('PM', 'Pequeño material', '6290000007'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('R', 'Factura proveedor', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RC', 'Ingreso/Reintegro Ruralcaja', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RN', 'Reparación nave', '6220000004'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('SS', 'Gastos Silla', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('T', 'Ticket', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TA', 'Factura rapida', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TC', 'Ticket contado', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TR', 'Traspaso', NULL); \ No newline at end of file From 182273d3b387c35cd40d296eceee468381d4ca4a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 5 Jul 2024 09:59:15 +0200 Subject: [PATCH 11/25] refs #7450 Modified msg throw --- db/routines/vn/procedures/entry_isEditable.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/entry_isEditable.sql b/db/routines/vn/procedures/entry_isEditable.sql index a05a1fd92..c279fac65 100644 --- a/db/routines/vn/procedures/entry_isEditable.sql +++ b/db/routines/vn/procedures/entry_isEditable.sql @@ -18,7 +18,7 @@ BEGIN AND e.id = vSelf; IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN - CALL util.throw('Entry is not editable'); + CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); END IF; END$$ DELIMITER ; From 3051e4ed251a7dc25a96efdee607769b79c4f2d7 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 5 Jul 2024 10:35:32 +0200 Subject: [PATCH 12/25] Merge branch '6371-restoreSeries' of https://gitea.verdnatura.es/verdnatura/salix into 6371-restoreSeries --- db/dump/.dump/structure.sql | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 5755ce085..6797c01a5 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -19,7 +19,7 @@ -- Current Database: `account` -- -CREATE DATABASE /*!32312 */ `account` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `account` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; USE `account`; @@ -2230,7 +2230,7 @@ DELIMITER ; -- Current Database: `bi` -- -CREATE DATABASE /*!32312 */ `bi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `bi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `bi`; @@ -4000,7 +4000,7 @@ DELIMITER ; -- Current Database: `bs` -- -CREATE DATABASE /*!32312 */ `bs` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `bs` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `bs`; @@ -6967,7 +6967,7 @@ DELIMITER ; -- Current Database: `cache` -- -CREATE DATABASE /*!32312 */ `cache` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `cache` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `cache`; @@ -8087,7 +8087,7 @@ DELIMITER ; -- Current Database: `dipole` -- -CREATE DATABASE /*!32312 */ `dipole` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `dipole` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `dipole`; @@ -8316,7 +8316,7 @@ DELIMITER ; -- Current Database: `edi` -- -CREATE DATABASE /*!32312 */ `edi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `edi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `edi`; @@ -11054,7 +11054,7 @@ DELIMITER ; -- Current Database: `floranet` -- -CREATE DATABASE /*!32312 */ `floranet` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `floranet` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `floranet`; @@ -11638,7 +11638,7 @@ DELIMITER ; -- Current Database: `hedera` -- -CREATE DATABASE /*!32312 */ `hedera` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `hedera` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `hedera`; @@ -15833,7 +15833,7 @@ DELIMITER ; -- Current Database: `pbx` -- -CREATE DATABASE /*!32312 */ `pbx` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `pbx` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `pbx`; @@ -16499,7 +16499,7 @@ DELIMITER ; -- Current Database: `psico` -- -CREATE DATABASE /*!32312 */ `psico` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `psico` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `psico`; @@ -16834,7 +16834,7 @@ DELIMITER ; -- Current Database: `sage` -- -CREATE DATABASE /*!32312 */ `sage` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `sage` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; USE `sage`; @@ -19146,7 +19146,7 @@ DELIMITER ; -- Current Database: `salix` -- -CREATE DATABASE /*!32312 */ `salix` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `salix` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `salix`; @@ -19440,7 +19440,7 @@ DELIMITER ; -- Current Database: `srt` -- -CREATE DATABASE /*!32312 */ `srt` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `srt` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `srt`; @@ -22991,7 +22991,7 @@ DELIMITER ; -- Current Database: `stock` -- -CREATE DATABASE /*!32312 */ `stock` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `stock` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */; USE `stock`; @@ -24069,7 +24069,7 @@ DELIMITER ; -- Current Database: `tmp` -- -CREATE DATABASE /*!32312 */ `tmp` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `tmp` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `tmp`; @@ -24147,7 +24147,7 @@ DELIMITER ; -- Current Database: `util` -- -CREATE DATABASE /*!32312 */ `util` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `util` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `util`; @@ -26252,7 +26252,7 @@ DELIMITER ; -- Current Database: `vn` -- -CREATE DATABASE /*!32312 */ `vn` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `vn`; @@ -63220,7 +63220,7 @@ BEGIN * @param vDate -> Date of the purchase operation. * @param vWarehouseFk -> Identifier of the warehouse (warehouseId). */ - ALTER TABLE tmp.itemInventory ADD buy_id INT; + ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT; CALL buyUltimate(vWarehouseFk, vDate); @@ -68883,7 +68883,7 @@ proc: BEGIN CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); - (SELECT TRUE FROM tmp.zoneGetLanded LIMIT 1) THEN + IF NOT EXISTS (SELECT TRUE FROM tmp.zoneGetLanded LIMIT 1) THEN CALL util.throw(CONCAT('There is no zone for these parameters ', vTicketFk)); END IF; @@ -77852,11 +77852,11 @@ BEGIN IF vWorkerFk THEN CALL timeControl_calculateByUser(vWorkerFk, vDatedFrom , vDatedTimeTo); - CREATE TEMPORARY TABLE tmp.`user` + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT vWorkerFk userFk; ELSE CALL timeControl_calculateAll(vDatedFrom, vDatedTimeTo); - CREATE TEMPORARY TABLE tmp.`user` + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT id userFk FROM worker w; END IF; @@ -81544,7 +81544,7 @@ DELIMITER ; -- Current Database: `vn2008` -- -CREATE DATABASE /*!32312 */ `vn2008` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn2008` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `vn2008`; From f3f450463b628ac57cb811985e3659519bf0fe70 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 5 Jul 2024 10:47:26 +0200 Subject: [PATCH 13/25] warmFix getSales refs #6861 --- back/methods/collection/getSales.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/back/methods/collection/getSales.js b/back/methods/collection/getSales.js index 8f5bfaeef..a9e5f2e60 100644 --- a/back/methods/collection/getSales.js +++ b/back/methods/collection/getSales.js @@ -60,15 +60,17 @@ module.exports = Self => { if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions); for (let ticket of tickets) { - let observations = ticket.observaciones.split(' '); + if (ticket.observaciones) { + let observations = ticket.observaciones.split(' '); - for (let observation of observations) { - const salesPerson = ticket.salesPersonFk; - if (observation.startsWith('#') || observation.startsWith('@')) { - await models.Chat.send(ctx, - observation, - $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson}) - ); + for (let observation of observations) { + const salesPerson = ticket.salesPersonFk; + if (observation.startsWith('#') || observation.startsWith('@')) { + await models.Chat.send(ctx, + observation, + $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson}) + ); + } } } } From 8ac26c7281ca26fa9110389783c7128ee90d0967 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 5 Jul 2024 12:50:31 +0200 Subject: [PATCH 14/25] refactor: refs #7640 Refactor multipleInventory --- .../vn/procedures/multipleInventory.sql | 85 ++++++++++--------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index ece57727d..704a93152 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -76,52 +76,52 @@ proc: BEGIN GROUP BY itemFk; -- Cálculo del visible - UPDATE tItemInventoryCalc iic - JOIN ( - SELECT itemFk, SUM(quantity) visible - FROM ( - SELECT s.itemFk, s.quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped >= vDate - AND t.shipped < vDateTomorrow - AND (NOT isPicked AND NOT t.isLabeled AND t.refFk IS NULL) - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - ) sub2 - GROUP BY itemFk - ) sub ON sub.itemFk = iic.itemFk - SET iic.visible = iic.visible + sub.visible; + CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT itemFk, SUM(quantity) visible + FROM ( + SELECT s.itemFk, s.quantity + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped >= vDate + AND t.shipped < vDateTomorrow + AND (NOT isPicked AND NOT t.isLabeled AND t.refFk IS NULL) + AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk + AND w.isComparative + UNION ALL + SELECT b.itemFk, - b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + WHERE t.landed = vDate + AND NOT t.isReceived + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk + AND w.isComparative + UNION ALL + SELECT b.itemFk, b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseOutFk + WHERE t.shipped = vDate + AND NOT t.isReceived + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk + AND w.isComparative + ) sub2 + GROUP BY itemFk; UPDATE tmp.itemInventory ai JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id + JOIN tItemVisibleCalc ivc ON ivc.itemFk = ai.id SET ai.inventory = iic.quantity, - ai.visible = iic.visible, + ai.visible = iic.quantity + ivc.visible, ai.avalaible = iic.quantity, ai.sd = iic.quantity; @@ -195,6 +195,7 @@ proc: BEGIN tmp.itemTravel, tmp.itemCalc, tItemInventoryCalc, + tItemVisibleCalc, tmp.itemAtp; END$$ DELIMITER ; From 1d59883d19f96020ec7d377cc965c975821b60e0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 5 Jul 2024 13:14:16 +0200 Subject: [PATCH 15/25] feat: refs #7644 Minor change --- print/templates/reports/buy-label/buy-label.html | 2 +- print/templates/reports/buy-label/sql/buys.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label/buy-label.html index 494cdcbc5..b14e54759 100644 --- a/print/templates/reports/buy-label/buy-label.html +++ b/print/templates/reports/buy-label/buy-label.html @@ -59,7 +59,7 @@
- {{buy.id}} + {{buy.itemFk}} diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql index 50b34bd03..41fd3556b 100644 --- a/print/templates/reports/buy-label/sql/buys.sql +++ b/print/templates/reports/buy-label/sql/buys.sql @@ -8,6 +8,7 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, b.`grouping`, i.stems, b.id, + b.itemFk, p.name producer FROM buy b JOIN item i ON i.id = b.itemFk From 3ddf49da0afdbd00b7f4c8466668149b439cacc1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 5 Jul 2024 13:21:07 +0200 Subject: [PATCH 16/25] feat: refs #7640 Fix --- db/routines/vn/procedures/multipleInventory.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index 704a93152..8eb4dae71 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -119,9 +119,9 @@ proc: BEGIN UPDATE tmp.itemInventory ai JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id - JOIN tItemVisibleCalc ivc ON ivc.itemFk = ai.id + LEFT JOIN tItemVisibleCalc ivc ON ivc.itemFk = iic.itemFk SET ai.inventory = iic.quantity, - ai.visible = iic.quantity + ivc.visible, + ai.visible = iic.visible + IFNULL(ivc.visible, 0), ai.avalaible = iic.quantity, ai.sd = iic.quantity; From 55f0e907711b4090fa7c97caf4f54817414d882f Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 5 Jul 2024 13:36:38 +0200 Subject: [PATCH 17/25] feat: refs #7640 Minor change --- db/routines/vn/procedures/multipleInventory.sql | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index 8eb4dae71..662aa2d63 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -75,6 +75,13 @@ proc: BEGIN ) sub GROUP BY itemFk; + UPDATE tmp.itemInventory ai + JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id + SET ai.inventory = iic.quantity, + ai.visible = iic.visible, + ai.avalaible = iic.quantity, + ai.sd = iic.quantity; + -- Cálculo del visible CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc (PRIMARY KEY (itemFk)) @@ -118,12 +125,8 @@ proc: BEGIN GROUP BY itemFk; UPDATE tmp.itemInventory ai - JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id - LEFT JOIN tItemVisibleCalc ivc ON ivc.itemFk = iic.itemFk - SET ai.inventory = iic.quantity, - ai.visible = iic.visible + IFNULL(ivc.visible, 0), - ai.avalaible = iic.quantity, - ai.sd = iic.quantity; + JOIN tItemVisibleCalc ivc ON ivc.itemFk = ai.id + SET ai.visible = ai.visible + ivc.visible; -- Calculo del disponible CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc From 592738c7a0c3d39da8c75c6f7fc365023c5402f7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 5 Jul 2024 13:48:03 +0200 Subject: [PATCH 18/25] refs #7024 & ticket 198125 Hotfix --- db/routines/vn/triggers/entry_beforeUpdate.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 31c6f9bd6..0a161853b 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -11,11 +11,9 @@ BEGIN IF NEW.isBooked = OLD.isBooked AND ( NOT (NEW.supplierFk <=> OLD.supplierFk) OR NOT (NEW.dated <=> OLD.dated) OR - NOT (NEW.invoiceNumber <=> OLD.invoiceNumber) OR NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.companyFk <=> OLD.companyFk) OR NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR - NOT (NEW.invoiceAmount <=> OLD.invoiceAmount) OR NOT (NEW.typeFk <=> OLD.typeFk) ) THEN From 3508cf3a9eea30366065b002e4135fce13590a17 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 5 Jul 2024 14:01:09 +0200 Subject: [PATCH 19/25] refs #7561 add fk en userFk --- db/versions/11137-salmonRoebelini/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/11137-salmonRoebelini/00-firstScript.sql diff --git a/db/versions/11137-salmonRoebelini/00-firstScript.sql b/db/versions/11137-salmonRoebelini/00-firstScript.sql new file mode 100644 index 000000000..69d20ac6d --- /dev/null +++ b/db/versions/11137-salmonRoebelini/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.expeditionState + MODIFY COLUMN userFk INT(10) UNSIGNED, + ADD CONSTRAINT expeditionState_userFk FOREIGN KEY (userFk) + REFERENCES account.`user`(id); \ No newline at end of file From 5192bfd8ead52327c2b474465f231b8e596466c8 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 5 Jul 2024 14:58:34 +0200 Subject: [PATCH 20/25] fix(salix): refs #7648 #7648 entryFilter and getBuys by fi --- modules/entry/back/methods/entry/filter.js | 7 ++++--- modules/entry/back/methods/entry/getBuys.js | 7 ++++--- modules/entry/back/methods/entry/specs/filter.spec.js | 4 ++-- modules/entry/back/methods/entry/specs/getBuys.spec.js | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 5989494a4..f21d9dbc4 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -146,10 +146,11 @@ module.exports = Self => { }); filter = mergeFilters(ctx.args.filter, {where}); const userId = ctx.req.accessToken.userId; - const isSupplier = await Self.app.models.Supplier.findById(userId, myOptions); - if (isSupplier) { + const client = await Self.app.models.Client.findById(userId, myOptions); + const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions); + if (supplier) { if (!filter.where) filter.where = {}; - filter.where[`e.supplierFk`] = ctx.req.accessToken.userId; + filter.where[`e.supplierFk`] = supplier.id; } const stmts = []; let stmt; diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 444e6cb14..0cb71653e 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -36,9 +36,10 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const isSupplier = await Self.app.models.Supplier.findById(userId, myOptions); - if (isSupplier) { - const isEntryOwner = (await Self.findById(id)).supplierFk === userId; + const client = await Self.app.models.Client.findById(userId, myOptions); + const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions); + if (supplier) { + const isEntryOwner = (await Self.findById(id)).supplierFk === supplier.id; if (!isEntryOwner) throw new UserError('Access Denied'); } diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 9d954cdc4..c8a5bd94f 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -56,7 +56,7 @@ describe('Entry filter()', () => { try { const ctx = { args: {}, - req: {accessToken: {userId: 2}} + req: {accessToken: {userId: 1102}} }; const result = await models.Entry.filter(ctx, options); @@ -79,7 +79,7 @@ describe('Entry filter()', () => { args: { supplierFk: 1 }, - req: {accessToken: {userId: 2}} + req: {accessToken: {userId: 1102}} }; const result = await models.Entry.filter(ctx, options); diff --git a/modules/entry/back/methods/entry/specs/getBuys.spec.js b/modules/entry/back/methods/entry/specs/getBuys.spec.js index cb7f7cb80..2d3531249 100644 --- a/modules/entry/back/methods/entry/specs/getBuys.spec.js +++ b/modules/entry/back/methods/entry/specs/getBuys.spec.js @@ -40,7 +40,7 @@ describe('entry getBuys()', () => { args: { search: 1 }, - req: {accessToken: {userId: 2}} + req: {accessToken: {userId: 1102}} }; const result = await models.Entry.getBuys(ctx, entryId, options); From 3a2acfb7f8e5e012704c9e3496375521416d06c8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 8 Jul 2024 07:21:53 +0200 Subject: [PATCH 21/25] feat: refs #7640 Optimization --- db/routines/vn/procedures/multipleInventory.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index 662aa2d63..941ac6c3d 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -40,8 +40,7 @@ proc: BEGIN (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT itemFk, - SUM(quantity) quantity, - SUM(quantity) visible + SUM(quantity) quantity FROM ( SELECT s.itemFk, - s.quantity quantity FROM sale s @@ -78,7 +77,7 @@ proc: BEGIN UPDATE tmp.itemInventory ai JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id SET ai.inventory = iic.quantity, - ai.visible = iic.visible, + ai.visible = iic.quantity, ai.avalaible = iic.quantity, ai.sd = iic.quantity; From e9d2ff14764bfc5eddcc1e0121de93d183c71546 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Jul 2024 09:43:59 +0200 Subject: [PATCH 22/25] feat: refs #7582 claimDestination addColumn code --- db/versions/11138-aquaGalax/00-firstScript.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/versions/11138-aquaGalax/00-firstScript.sql diff --git a/db/versions/11138-aquaGalax/00-firstScript.sql b/db/versions/11138-aquaGalax/00-firstScript.sql new file mode 100644 index 000000000..44fdd468f --- /dev/null +++ b/db/versions/11138-aquaGalax/00-firstScript.sql @@ -0,0 +1,9 @@ +USE `vn`; +ALTER TABLE `vn`.`claimDestination` +ADD COLUMN `code` varchar(45) DEFAULT NULL; + +UPDATE vn.claimDestination SET code='Good' WHERE description= 'Bueno'; +UPDATE vn.claimDestination SET code='Garbage/Loss' WHERE description = 'Basura/Perd.'; +UPDATE vn.claimDestination SET code='Manufacturing'WHERE description = 'Confeccion'; +UPDATE vn.claimDestination SET code='Claim' WHERE description = 'Reclam.PRAG'; +UPDATE vn.claimDestination SET code='Corrected' WHERE description = 'Corregido'; \ No newline at end of file From 3fa0823d931bc8a817772f0ed855172151e537c5 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Jul 2024 11:01:35 +0200 Subject: [PATCH 23/25] feat: refs #7582 quitar vn --- db/versions/11138-aquaGalax/00-firstScript.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/versions/11138-aquaGalax/00-firstScript.sql b/db/versions/11138-aquaGalax/00-firstScript.sql index 44fdd468f..1e759db61 100644 --- a/db/versions/11138-aquaGalax/00-firstScript.sql +++ b/db/versions/11138-aquaGalax/00-firstScript.sql @@ -1,4 +1,3 @@ -USE `vn`; ALTER TABLE `vn`.`claimDestination` ADD COLUMN `code` varchar(45) DEFAULT NULL; From a796787cb5eb3da34a893f25c79c7d52ff939aa0 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Jul 2024 11:04:35 +0200 Subject: [PATCH 24/25] feat: refs #7582 --- db/versions/11138-aquaGalax/00-firstScript.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/versions/11138-aquaGalax/00-firstScript.sql b/db/versions/11138-aquaGalax/00-firstScript.sql index 1e759db61..0c6547260 100644 --- a/db/versions/11138-aquaGalax/00-firstScript.sql +++ b/db/versions/11138-aquaGalax/00-firstScript.sql @@ -1,8 +1,8 @@ ALTER TABLE `vn`.`claimDestination` ADD COLUMN `code` varchar(45) DEFAULT NULL; -UPDATE vn.claimDestination SET code='Good' WHERE description= 'Bueno'; -UPDATE vn.claimDestination SET code='Garbage/Loss' WHERE description = 'Basura/Perd.'; -UPDATE vn.claimDestination SET code='Manufacturing'WHERE description = 'Confeccion'; -UPDATE vn.claimDestination SET code='Claim' WHERE description = 'Reclam.PRAG'; -UPDATE vn.claimDestination SET code='Corrected' WHERE description = 'Corregido'; \ No newline at end of file +UPDATE IGNORE vn.claimDestination SET code='Good' WHERE description= 'Bueno'; +UPDATE IGNORE vn.claimDestination SET code='Garbage/Loss' WHERE description = 'Basura/Perd.'; +UPDATE IGNORE vn.claimDestination SET code='Manufacturing'WHERE description = 'Confeccion'; +UPDATE IGNORE vn.claimDestination SET code='Claim' WHERE description = 'Reclam.PRAG'; +UPDATE IGNORE vn.claimDestination SET code='Corrected' WHERE description = 'Corregido'; \ No newline at end of file From 0722a97c6000bd9ebc36b9349589bd660ee5e31a Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Jul 2024 11:28:33 +0200 Subject: [PATCH 25/25] feat: refs #7582 --- db/versions/11138-aquaGalax/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11138-aquaGalax/00-firstScript.sql b/db/versions/11138-aquaGalax/00-firstScript.sql index 0c6547260..d492e6470 100644 --- a/db/versions/11138-aquaGalax/00-firstScript.sql +++ b/db/versions/11138-aquaGalax/00-firstScript.sql @@ -3,6 +3,6 @@ ADD COLUMN `code` varchar(45) DEFAULT NULL; UPDATE IGNORE vn.claimDestination SET code='Good' WHERE description= 'Bueno'; UPDATE IGNORE vn.claimDestination SET code='Garbage/Loss' WHERE description = 'Basura/Perd.'; -UPDATE IGNORE vn.claimDestination SET code='Manufacturing'WHERE description = 'Confeccion'; +UPDATE IGNORE vn.claimDestination SET code='Manufacturing' WHERE description = 'Confeccion'; UPDATE IGNORE vn.claimDestination SET code='Claim' WHERE description = 'Reclam.PRAG'; UPDATE IGNORE vn.claimDestination SET code='Corrected' WHERE description = 'Corregido'; \ No newline at end of file