From c593b95935302ef661dea268525a3546576541f0 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 23 Oct 2024 15:21:24 +0200 Subject: [PATCH 01/14] feat: refs #7880 error code and translations --- .../hedera/procedures/order_confirmWithUser.sql | 2 +- db/versions/11320-salmonRose/00-firstScript.sql | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/versions/11320-salmonRose/00-firstScript.sql diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 644d68a87..db83cba5c 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -107,7 +107,7 @@ BEGIN ) INTO vHas0Amount; IF vHas0Amount THEN - CALL util.throw('Hay líneas vacías. Por favor, elimínelas'); + CALL util.throw('orderLinesWithZero'); END IF; START TRANSACTION; diff --git a/db/versions/11320-salmonRose/00-firstScript.sql b/db/versions/11320-salmonRose/00-firstScript.sql new file mode 100644 index 000000000..cd3431fee --- /dev/null +++ b/db/versions/11320-salmonRose/00-firstScript.sql @@ -0,0 +1,11 @@ +INSERT INTO hedera.message (code, description) + VALUES ('orderLinesWithZero','There are empty lines. Please delete them'); + +INSERT INTO hedera.messageI18n (code, lang, description) + VALUES ('orderLinesWithZero','es','Hay líneas vacías. Por favor, elimínelas'); + +INSERT INTO hedera.messageI18n (code, lang, description) + VALUES ('orderLinesWithZero','fr','Il y a des lignes vides. Veuillez les supprimer'); + +INSERT INTO hedera.messageI18n (code, lang, description) + VALUES ('orderLinesWithZero','pt','Existem linhas vazias. Por favor, apague-os'); \ No newline at end of file From e748e9a0127bb25bb62ecdcc9a0390b4281d2d7e Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 13 Dec 2024 08:30:23 +0100 Subject: [PATCH 02/14] feat: refs #7235 add serialType parameter to getInvoiceDate and implement corresponding tests --- modules/account/back/methods/account/sync.js | 4 +- .../back/methods/invoiceOut/getInvoiceDate.js | 15 ++++--- .../invoiceOut/specs/getInvoiceDate.spec.js | 39 +++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js diff --git a/modules/account/back/methods/account/sync.js b/modules/account/back/methods/account/sync.js index 1026c5020..b38e4dd37 100644 --- a/modules/account/back/methods/account/sync.js +++ b/modules/account/back/methods/account/sync.js @@ -29,14 +29,14 @@ module.exports = Self => { const models = Self.app.models; const myOptions = {}; let tx; - + if (typeof options == 'object') Object.assign(myOptions, options); if (!myOptions.transaction) { tx = await Self.beginTransaction({}); myOptions.transaction = tx; - }; + } try { const user = await models.VnUser.findOne({ diff --git a/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js b/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js index dcc1fa6e8..493f19aa7 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js +++ b/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js @@ -7,7 +7,12 @@ module.exports = Self => { arg: 'companyFk', type: 'number', required: true - } + }, + { + arg: 'serialType', + type: 'string', + required: true + }, ], returns: { type: ['object'], @@ -19,16 +24,16 @@ module.exports = Self => { } }); - Self.getInvoiceDate = async companyFk => { + Self.getInvoiceDate = async(companyFk, serialType) => { const models = Self.app.models; const [invoiceDate] = await models.InvoiceOut.rawSql( `SELECT MAX(io.issued) issued FROM invoiceOut io JOIN invoiceOutSerial ios ON ios.code = io.serial - WHERE ios.type = 'global' - AND io.issued + WHERE ios.type = ? + AND io.issued AND io.companyFk = ?`, - [companyFk] + [serialType, companyFk] ); return invoiceDate; }; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js new file mode 100644 index 000000000..830402250 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js @@ -0,0 +1,39 @@ +const models = require('vn-loopback/server/server').models; +const moment = require('moment'); + +describe('getInvoiceDate()', () => { + const companyFk = 442; + let tx; + let options; + + beforeEach(async() => { + tx = await models.InvoiceOut.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should return a correct date for serialType "global"', async() => { + const serialType = 'global'; + const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options); + + expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2000-12-01'); + }); + + it('should return null for serialType "multiple"', async() => { + const serialType = 'multiple'; + const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options); + + expect(result.issued).toBeNull(); + }); + + it('should return correct date for serialType "quick"', async() => { + const serialType = 'quick'; + const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options); + + expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2001-01-01'); + }); +}); + From 42c3cdae5d76d8da0420c8aff7fee07ba1f2f35c Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 18 Dec 2024 11:33:48 +0100 Subject: [PATCH 03/14] build: init version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e823eaad..a843ac9c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.52.0", + "version": "25.02.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 83d46d0a281d9b9fbbda13a798c52aee79e67174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 18 Dec 2024 17:58:30 +0100 Subject: [PATCH 04/14] feat: refs #8324 country unique --- db/versions/11390-goldenPalmetto/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11390-goldenPalmetto/00-firstScript.sql diff --git a/db/versions/11390-goldenPalmetto/00-firstScript.sql b/db/versions/11390-goldenPalmetto/00-firstScript.sql new file mode 100644 index 000000000..adcc76e4f --- /dev/null +++ b/db/versions/11390-goldenPalmetto/00-firstScript.sql @@ -0,0 +1,3 @@ + +ALTER TABLE vn.country + ADD CONSTRAINT country_unique_name UNIQUE KEY (name); From 9ae27e104e006a964f7feb2cf8aa51a16f12a3a7 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 19 Dec 2024 07:07:56 +0100 Subject: [PATCH 05/14] feat: refs #8167 update canBeInvoiced method to include active status check and improve test cases --- .../back/methods/client/canBeInvoiced.js | 9 +-- .../client/specs/canBeInvoiced.spec.js | 67 ++++++++----------- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/modules/client/back/methods/client/canBeInvoiced.js b/modules/client/back/methods/client/canBeInvoiced.js index cdb865500..536606b0b 100644 --- a/modules/client/back/methods/client/canBeInvoiced.js +++ b/modules/client/back/methods/client/canBeInvoiced.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = function(Self) { Self.remoteMethod('canBeInvoiced', { - description: 'Change property isEqualizated in all client addresses', + description: 'Check if a client can be invoiced', accessType: 'READ', accepts: [ { @@ -38,7 +38,7 @@ module.exports = function(Self) { Object.assign(myOptions, options); const client = await models.Client.findById(id, { - fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk'], + fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk', 'isActive'], include: { relation: 'payMethod', @@ -53,9 +53,6 @@ module.exports = function(Self) { if (client.payMethod().code === 'wireTransfer' && !company.supplierAccountFk) throw new UserError('The company has not informed the supplier account for bank transfers'); - if (client.isTaxDataChecked && client.hasToInvoice) - return true; - - return false; + return client.isTaxDataChecked && client.hasToInvoice && client.isActive; }; }; diff --git a/modules/client/back/methods/client/specs/canBeInvoiced.spec.js b/modules/client/back/methods/client/specs/canBeInvoiced.spec.js index 397be3c92..4012b7409 100644 --- a/modules/client/back/methods/client/specs/canBeInvoiced.spec.js +++ b/modules/client/back/methods/client/specs/canBeInvoiced.spec.js @@ -8,6 +8,8 @@ describe('client canBeInvoiced()', () => { const activeCtx = { accessToken: {userId: userId} }; + let tx; + let options; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -15,60 +17,45 @@ describe('client canBeInvoiced()', () => { }); }); + beforeEach(async() => { + tx = await models.Client.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); + it('should return falsy for a client without the data checked', async() => { - const tx = await models.Client.beginTransaction({}); + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('isTaxDataChecked', false, options); - try { - const options = {transaction: tx}; + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - const client = await models.Client.findById(clientId, null, options); - await client.updateAttribute('isTaxDataChecked', false, options); + expect(canBeInvoiced).toEqual(false); + }); - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); + it('should return falsy for a client not active', async() => { + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('isActive', false, options); - expect(canBeInvoiced).toEqual(false); + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(canBeInvoiced).toEqual(false); }); it('should return falsy for a client with invoicing disabled', async() => { - const tx = await models.Client.beginTransaction({}); + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('hasToInvoice', false, options); - try { - const options = {transaction: tx}; + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - const client = await models.Client.findById(clientId, null, options); - await client.updateAttribute('hasToInvoice', false, options); - - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - - expect(canBeInvoiced).toEqual(false); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(canBeInvoiced).toEqual(false); }); it('should return truthy for an invoiceable client', async() => { - const tx = await models.Client.beginTransaction({}); + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - try { - const options = {transaction: tx}; - - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - - expect(canBeInvoiced).toEqual(true); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(canBeInvoiced).toEqual(true); }); }); From 49c30890e5c6487ecf8ad41e27fff13693fbfb66 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 19 Dec 2024 08:31:51 +0100 Subject: [PATCH 06/14] fix: refs #7301 update SQL fixtures and improve lastEntriesFilter logic --- db/dump/fixtures.before.sql | 11 ++++--- .../back/methods/item/lastEntriesFilter.js | 30 ++++++++++++------- .../item/specs/lastEntriesFilter.spec.js | 16 +++++----- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 57a9f9ca8..41ed69d53 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1516,7 +1516,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, NULL), (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2), (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), - (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), + (13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`) VALUES @@ -1529,8 +1530,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'), (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10',1, '', 'product'), - (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 11',0, '', 'product'), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2010', 'Movement 10',1, '', 'product'), + (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 1, 442, 'IN2011', 'Movement 11',0, '', 'product'), + (12, 4, util.VN_CURDATE() - INTERVAL 1 MONTH, 13, 1, 442, 'IN2012', 'Movement 12',0, '', 'product'), (99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product'); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) @@ -1572,7 +1574,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), - (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); + (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), + (18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 06c60162f..dd2e638e4 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -29,10 +29,11 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT w.id AS warehouseFk, - w.name AS warehouse, - tr.landed, - b.id AS buyFk, + `SELECT i.id itemFk, + w.id warehouseFk, + w.name warehouse, + CAST(tr.landed AS CHAR) landed, + b.id buyFk, b.entryFk, b.isIgnored, b.price2, @@ -47,15 +48,18 @@ module.exports = Self => { b.buyingValue + b.freightValue + b.comissionValue + - b.packageValue AS cost, + b.packageValue cost, b.buyingValue, b.freightValue, b.comissionValue, b.packageValue, b.packagingFk , - s.id AS supplierFk, - s.name AS supplier, - b.printedStickers + s.id supplierFk, + s.name supplier, + b.printedStickers, + c.inventoried, + ic.supplierFk inventorySupplierFk, + s.id = ic.supplierFk isInventorySupplier FROM itemType it RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk @@ -66,10 +70,16 @@ module.exports = Self => { LEFT JOIN warehouse w ON w.id = tr.warehouseInFk LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk - LEFT JOIN edi.ekt ek ON b.ektFk = ek.id` + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id + JOIN config c + JOIN inventoryConfig ic` ); - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge('AND IF(s.id = ic.supplierFk, tr.landed = DATE(c.inventoried), TRUE)'); + stmt.merge(conn.makePagination(filter)); + + console.log('stmt: ', stmt); return conn.executeStmt(stmt, myOptions); }; }; diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index d4429e158..3182f3a35 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,16 +1,17 @@ const {models} = require('vn-loopback/server/server'); +const itemFk = 1; describe('item lastEntriesFilter()', () => { - it('should return two entry for the given item', async() => { + fit('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); + maxDate.setHours(23, 59, 59, 999); const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); expect(result.length).toEqual(2); @@ -22,7 +23,7 @@ describe('item lastEntriesFilter()', () => { } }); - it('should return six entries for the given item', async() => { + fit('should return six entries for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2, 1); @@ -34,11 +35,10 @@ describe('item lastEntriesFilter()', () => { const options = {transaction: tx}; try { - const itemFk = 1; const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - const minDateUtc = new Date(minDate).getTime(); - const maxDateUtc = new Date(maxDate).getTime(); + const minDateUtc = minDate.getTime(); + const maxDateUtc = maxDate.getTime(); const resultMatch = ( await Promise.all( @@ -50,7 +50,7 @@ describe('item lastEntriesFilter()', () => { }); const isItemFkValid = itemRecord?.id === itemFk; - const landedDate = new Date(item.landed).getTime(); + const landedDate = Date.vnNew(item.landed).getTime(); const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; return isItemFkValid && isLandedValid; From b838e988e0e6262cf81d2b186b51e7ce160fff1d Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 19 Dec 2024 08:39:47 +0100 Subject: [PATCH 07/14] fix: refs #7301 remove debug console log and update test cases in lastEntriesFilter --- modules/item/back/methods/item/lastEntriesFilter.js | 1 - .../item/back/methods/item/specs/lastEntriesFilter.spec.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index dd2e638e4..7a98eabd9 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -79,7 +79,6 @@ module.exports = Self => { stmt.merge('AND IF(s.id = ic.supplierFk, tr.landed = DATE(c.inventoried), TRUE)'); stmt.merge(conn.makePagination(filter)); - console.log('stmt: ', stmt); return conn.executeStmt(stmt, myOptions); }; }; diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 3182f3a35..a32225af7 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,7 +1,7 @@ const {models} = require('vn-loopback/server/server'); const itemFk = 1; describe('item lastEntriesFilter()', () => { - fit('should return two entry for the given item', async() => { + it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); const maxDate = Date.vnNew(); @@ -23,7 +23,7 @@ describe('item lastEntriesFilter()', () => { } }); - fit('should return six entries for the given item', async() => { + it('should return six entries for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2, 1); From a99d7adfe88c36e4356a3dd685dbf2d1e9ffd5d7 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 19 Dec 2024 10:11:33 +0100 Subject: [PATCH 08/14] feat: refs #7924 add isCustomInspectionRequired field to item and update related logic --- db/dump/fixtures.before.sql | 46 ++++++++++--------- .../11391-redPalmetto/00-itemAlter.sql | 2 + modules/item/back/models/item.json | 5 +- .../methods/travel/extraCommunityFilter.js | 19 ++++---- .../travel/specs/extraCommunityFilter.spec.js | 13 ++++++ 5 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 db/versions/11391-redPalmetto/00-itemAlter.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 97ed0ae47..181b34e5a 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -974,26 +974,30 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('SER', 'Services'), ('VT', 'Sales'); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`) - VALUES - (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3), - (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2), - (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5), - (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), - (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL), - (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), - (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL); +INSERT INTO `vn`.`item`( + `id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, + `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`, `isCustomInspectionRequired` +) +VALUES + (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3, 1), + (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2, 1), + (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5, 0), + (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), + (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL, 0), + (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), + (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), + (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), + (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); + -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 @@ -4038,7 +4042,7 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); -INSERT INTO vn.referenceRate (currencyFk, dated, value) +INSERT INTO vn.referenceRate (currencyFk, dated, value) VALUES (2, '2000-12-01', 1.0495), (2, '2001-01-01', 1.0531), (2, '2001-02-01', 7.6347); diff --git a/db/versions/11391-redPalmetto/00-itemAlter.sql b/db/versions/11391-redPalmetto/00-itemAlter.sql new file mode 100644 index 000000000..1eaef1a1b --- /dev/null +++ b/db/versions/11391-redPalmetto/00-itemAlter.sql @@ -0,0 +1,2 @@ +ALTER TABLE `item` +ADD COLUMN `isCustomInspectionRequired` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Indicates if the item requires physical inspection at customs'; diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index eda56e938..159883455 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -154,6 +154,9 @@ }, "photoMotivation": { "type": "string" + }, + "isCustomInspectionRequired": { + "type": "boolean" } }, "relations": { @@ -222,4 +225,4 @@ } } } -} \ No newline at end of file +} diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index f1586f804..2f3f998d6 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -132,18 +132,18 @@ module.exports = Self => { CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg, CAST( SUM( - vc.aerealVolumetricDensity * - b.stickers * + vc.aerealVolumetricDensity * + b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) AS DECIMAL(10,0) ) volumeKg, CAST( GREATEST( SUM(b.weight * b.stickers) , - SUM(vc.aerealVolumetricDensity * - b.stickers * - IF(pkg.volume, - pkg.volume, + SUM(vc.aerealVolumetricDensity * + b.stickers * + IF(pkg.volume, + pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) ) / t.kg * 100 AS INT ) percentageKg @@ -185,11 +185,12 @@ module.exports = Self => { CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) as loadedkg, CAST( SUM( - vc.aerealVolumetricDensity * - b.stickers * + vc.aerealVolumetricDensity * + b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) AS DECIMAL(10,0) - ) as volumeKg + ) as volumeKg, + MAX(i.isCustomInspectionRequired) isCustomInspectionRequired FROM tmp.travel tr JOIN entry e ON e.travelFk = tr.id JOIN buy b ON b.entryFk = e.id diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 7e90c7681..8fa013fe4 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -112,4 +112,17 @@ describe('Travel extraCommunityFilter()', () => { expect(result.length).toEqual(2); }); + + it('should return field isCustomInspectionRequired true', async() => { + const ctx = { + args: { + id: 2 + } + }; + + const result = await app.models.Travel.extraCommunityFilter(ctx, filter); + + expect(result[0].entries[0].isCustomInspectionRequired).toBeTruthy(); + expect(result[0].entries[1].isCustomInspectionRequired).toBeFalsy(); + }); }); From ea4b11801516e7abca32781501dcd31731177402 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 19 Dec 2024 10:26:53 +0100 Subject: [PATCH 09/14] feat: refs #7301 update lastEntriesFilter to include landedDate and enhance test cases --- .../back/methods/item/lastEntriesFilter.js | 1 + .../item/specs/lastEntriesFilter.spec.js | 53 ++++++++++++++----- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 7a98eabd9..b038bb155 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -33,6 +33,7 @@ module.exports = Self => { w.id warehouseFk, w.name warehouse, CAST(tr.landed AS CHAR) landed, + tr.landed landedDate, b.id buyFk, b.entryFk, b.isIgnored, diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index a32225af7..b2bfdf59c 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,17 +1,22 @@ const {models} = require('vn-loopback/server/server'); const itemFk = 1; + +const today = Date.vnNew(); +today.setHours(23, 59, 59, 999); + +const twoMonthsAgo = Date.vnNew(); +twoMonthsAgo.setHours(0, 0, 0, 0); +twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - 2, 1); describe('item lastEntriesFilter()', () => { it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 999); const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [minDate, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); expect(result.length).toEqual(2); @@ -24,21 +29,14 @@ describe('item lastEntriesFilter()', () => { }); it('should return six entries for the given item', async() => { - const minDate = Date.vnNew(); - minDate.setHours(0, 0, 0, 0); - minDate.setMonth(minDate.getMonth() - 2, 1); - - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); - const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - const minDateUtc = minDate.getTime(); - const maxDateUtc = maxDate.getTime(); + const twoMonthsAgoUtc = twoMonthsAgo.getTime(); + const todayUtc = today.getTime(); const resultMatch = ( await Promise.all( @@ -51,7 +49,7 @@ describe('item lastEntriesFilter()', () => { const isItemFkValid = itemRecord?.id === itemFk; const landedDate = Date.vnNew(item.landed).getTime(); - const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; + const isLandedValid = landedDate >= twoMonthsAgoUtc && landedDate <= todayUtc; return isItemFkValid && isLandedValid; }) @@ -66,4 +64,31 @@ describe('item lastEntriesFilter()', () => { throw e; } }); + + it('should return just the inventoried inventory', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; + const result = await models.Item.lastEntriesFilter(filter, options); + + const {supplierFk} = await models.InventoryConfig.findOne(options); + const {inventoried} = await models.Config.findOne(options); + + let hasInventoriedDate = false; + result.forEach(entry => { + if (entry.supplierFk === supplierFk && + entry.landedDate.getTime() === inventoried.getTime() + )hasInventoriedDate = true; + }); + + expect(hasInventoriedDate).toEqual(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From a2218b41f8b5192b060ca2ad1944dd25ec221dfb Mon Sep 17 00:00:00 2001 From: jtubau Date: Mon, 23 Dec 2024 14:49:44 +0100 Subject: [PATCH 10/14] feat: refs #8266 added itemFk and needed fixtures --- db/dump/fixtures.before.sql | 2 +- modules/ticket/back/methods/expedition/filter.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 663705ff5..8dbaac2c2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3963,7 +3963,7 @@ VALUES(1, ''); INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) -VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); +VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, 'Ranged Reinforced weapon sniper rifle 700mm' , 'NCC', NULL); INSERT INTO vn.accountDetail (id, value, accountDetailTypeFk, supplierAccountFk) diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index bd2012668..801d00a9b 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -50,7 +50,8 @@ module.exports = Self => { su.name scannerUserName, es.scanned, est.description state, - de.longName + de.longName, + de.itemFk FROM vn.expedition e LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk INNER JOIN vn.item i1 ON i1.id = e.freightItemFk From 98e2483565754146a05fe7dd3f2a2773b13ceba3 Mon Sep 17 00:00:00 2001 From: jgallego Date: Sun, 29 Dec 2024 09:38:51 +0100 Subject: [PATCH 11/14] feat: refs #8167 update locale and improve invoicing logic with error handling --- loopback/locale/en.json | 9 +++++---- .../back/methods/invoiceOut/clientsToInvoice.js | 12 ++++++++---- .../invoiceOut/specs/clientsToInvoice.spec.js | 4 ++-- .../back/methods/ticket/specs/makeInvoice.spec.js | 4 +++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index e6ec52d63..80da13ae5 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -246,8 +246,9 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "Holidays to past days not available": "Holidays to past days not available", + "Sales already moved": "Sales already moved", + "Holidays to past days not available": "Holidays to past days not available", "Price cannot be blank": "Price cannot be blank", - "There are tickets to be invoiced": "There are tickets to be invoiced" -} + "There are tickets to be invoiced": "There are tickets to be invoiced", + "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent" +} \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index 5526d214a..7befdcbeb 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { Self.remoteMethodCtx('clientsToInvoice', { description: 'Get the clients to make global invoicing', @@ -47,7 +49,12 @@ module.exports = Self => { } try { - // Packaging liquidation + const clientCanBeInvoiced = + await Self.app.models.Client.canBeInvoiced(clientId, companyFk, myOptions); + + if (!clientCanBeInvoiced) + throw new UserError(`This client can't be invoiced`); + const vIsAllInvoiceable = false; await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?)', [ clientId, @@ -71,9 +78,6 @@ module.exports = Self => { AND t.shipped BETWEEN ? AND util.dayEnd(?) AND (t.clientFk = ? OR ? IS NULL ) AND t.companyFk = ? - AND c.hasToInvoice - AND c.isTaxDataChecked - AND c.isActive AND NOT t.isDeleted GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id) HAVING SUM(t.totalWithVat) > 0;`; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js index 470690c5a..df0566c54 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js @@ -4,11 +4,11 @@ describe('InvoiceOut clientsToInvoice()', () => { const userId = 1; const clientId = 1101; const companyFk = 442; - const maxShipped = new Date(); + const maxShipped = Date.vnNew(); maxShipped.setMonth(11); maxShipped.setDate(31); maxShipped.setHours(23, 59, 59, 999); - const invoiceDate = new Date(); + const invoiceDate = Date.vnNew(); const activeCtx = { getLocale: () => { return 'en'; diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 88812dc92..f9e4bcac0 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -77,6 +77,8 @@ describe('ticket makeInvoice()', () => { await tx.rollback(); } - expect(error.message).toEqual(`The address of the customer must have information about Incoterms and Customs Agent`); + expect(error.message).toEqual( + `The address of the customer must have information about Incoterms and Customs Agent` + ); }); }); From 8ca5808554dc01b28f5a88eb7f8e412b58644397 Mon Sep 17 00:00:00 2001 From: jgallego Date: Sun, 29 Dec 2024 10:16:38 +0100 Subject: [PATCH 12/14] fix: add isCustomInspectionRequired column to item table for customs inspection indication --- db/versions/11391-redPalmetto/00-itemAlter.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11391-redPalmetto/00-itemAlter.sql b/db/versions/11391-redPalmetto/00-itemAlter.sql index 1eaef1a1b..fc47d5fc0 100644 --- a/db/versions/11391-redPalmetto/00-itemAlter.sql +++ b/db/versions/11391-redPalmetto/00-itemAlter.sql @@ -1,2 +1,2 @@ -ALTER TABLE `item` +ALTER TABLE `vn`.`item` ADD COLUMN `isCustomInspectionRequired` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Indicates if the item requires physical inspection at customs'; From 879ffcad64a8e3867b8e1b76afe3df47c0ee4545 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 30 Dec 2024 15:51:11 +0100 Subject: [PATCH 13/14] fix: refs #6598 update ACL property assignment --- back/methods/vn-user/acls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/acls.js b/back/methods/vn-user/acls.js index 7da75ed2c..347cfa426 100644 --- a/back/methods/vn-user/acls.js +++ b/back/methods/vn-user/acls.js @@ -19,7 +19,7 @@ module.exports = Self => { if (acl.principalType == 'ROLE' && acl.permission == 'ALLOW') { const staticAcl = { model: model.name, - property: '*', + property: acl.property, accessType: acl.accessType, permission: acl.permission, principalType: acl.principalType, From ad0c1eb4c5e8b493066cf8302863df0515ecb633 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 7 Jan 2025 07:12:33 +0100 Subject: [PATCH 14/14] feat: refs #8246 added relation for the front's new field --- modules/client/back/models/address.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/client/back/models/address.json b/modules/client/back/models/address.json index e8bf8d8a0..2d11b7745 100644 --- a/modules/client/back/models/address.json +++ b/modules/client/back/models/address.json @@ -84,6 +84,11 @@ "type": "belongsTo", "model": "CustomsAgent", "foreignKey": "customsAgentFk" + }, + "postcode": { + "type": "belongsTo", + "model": "Postcode", + "foreignKey": "postalCode" } } }