From b460579834ebbe0a546e703dd25404ec39a05c90 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Nov 2021 09:00:46 +0100 Subject: [PATCH 1/3] feat(entry_latest-buys): add from and to in search-panel --- .../00-defaultViewConfig.sql | 7 +++++++ .../back/methods/entry/latestBuysFilter.js | 17 ++++++++++++++++- .../entry/specs/latestBuysFilter.spec.js | 19 +++++++++++++++++++ .../front/latest-buys-search-panel/index.html | 12 ++++++++++++ modules/entry/front/latest-buys/index.html | 4 ++++ modules/entry/front/latest-buys/index.js | 5 ++++- 6 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 db/changes/10390-constitution/00-defaultViewConfig.sql diff --git a/db/changes/10390-constitution/00-defaultViewConfig.sql b/db/changes/10390-constitution/00-defaultViewConfig.sql new file mode 100644 index 0000000000..75788f581b --- /dev/null +++ b/db/changes/10390-constitution/00-defaultViewConfig.sql @@ -0,0 +1,7 @@ +UPDATE `salix`.`defaultViewConfig` + SET `columns` = '{"intrastat":false,"description":false,"density":false,"isActive":false, + "freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":true, + "ektFk":false,"weight":false,"id":true,"packing":true,"grouping":true,"quantity":true, + "size":false,"name":true,"code":true,"origin":true,"family":true,"entryFk":true,"buyingValue":true, + "comissionValue":false,"price3":true,"packageFk":true,"packingOut":true,"landing":false}' + WHERE tableCode = 'latestBuys' \ No newline at end of file diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index 8bae27ab2c..04570533c2 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -73,6 +73,16 @@ module.exports = Self => { arg: 'packingOut', type: 'integer', description: 'the packingOut', + }, + { + arg: 'from', + type: 'date', + description: `The from date filter` + }, + { + arg: 'to', + type: 'date', + description: `The to date filter` } ], returns: { @@ -117,6 +127,10 @@ module.exports = Self => { return {'i.isActive': value}; case 'floramondo': return {'i.isFloramondo': value}; + case 'from': + return {'lb.landing': {gte: value}}; + case 'to': + return {'lb.landing': {lte: value}}; case 'visible': if (value) return {'v.visible': {gt: 0}}; @@ -176,7 +190,8 @@ module.exports = Self => { b.price3, b.ektFk, b.weight, - b.packageFk + b.packageFk, + lb.landing FROM cache.last_buy lb LEFT JOIN cache.visible v ON v.item_id = lb.item_id AND v.calc_id = @calc_id diff --git a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js index f4a404fa4e..2a9e860607 100644 --- a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js +++ b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js @@ -172,5 +172,24 @@ describe('Buy latests buys filter()', () => { expect(results.length).toBe(2); }); + + it('should return results matching "from" and "to"', async() => { + const from = new Date(); + from.setHours(0, 0, 0, 0); + + const to = new Date(); + to.setHours(23, 59, 59, 999); + + let ctx = { + args: { + from: from, + to: to, + } + }; + + let results = await app.models.Buy.latestBuysFilter(ctx); + + expect(results.length).toBe(2); + }); }); diff --git a/modules/entry/front/latest-buys-search-panel/index.html b/modules/entry/front/latest-buys-search-panel/index.html index c829a25bab..3ef688f588 100644 --- a/modules/entry/front/latest-buys-search-panel/index.html +++ b/modules/entry/front/latest-buys-search-panel/index.html @@ -58,6 +58,18 @@ {{name}}: {{nickname}} + + + + + + Package out + + Landing + @@ -207,6 +210,7 @@ {{::buy.weight}} {{::buy.packageFk}} {{::buy.packingOut}} + {{::buy.landing | date: 'dd/MM/yyyy'}} diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index e899c50fad..ed66292628 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -76,7 +76,8 @@ export default class Controller extends Section { {field: 'description', displayName: this.$t('Description')}, {field: 'size', displayName: this.$t('Size')}, {field: 'density', displayName: this.$t('Density')}, - {field: 'packingOut', displayName: this.$t('PackingOut')} + {field: 'packingOut', displayName: this.$t('PackingOut')}, + {field: 'landing', displayName: this.$t('Landing')} ]; return this._columns; @@ -112,6 +113,8 @@ export default class Controller extends Section { return {'intr.description': value}; case 'origin': return {'ori.code': value}; + case 'landing': + return {[`lb.${param}`]: value}; case 'packing': case 'grouping': case 'quantity': From 854ed9936d50c084cf68275cfffa165e632b0cf8 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Nov 2021 09:05:42 +0100 Subject: [PATCH 2/3] deleted unnecessary comma --- modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js index 2a9e860607..2a26dfa555 100644 --- a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js +++ b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js @@ -183,7 +183,7 @@ describe('Buy latests buys filter()', () => { let ctx = { args: { from: from, - to: to, + to: to } }; From 00072a7dd137357d310dee126808bf25ec3af47d Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Nov 2021 10:02:52 +0100 Subject: [PATCH 3/3] landing searchable false --- db/changes/10390-constitution/00-defaultViewConfig.sql | 6 ++---- modules/entry/front/latest-buys/index.js | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db/changes/10390-constitution/00-defaultViewConfig.sql b/db/changes/10390-constitution/00-defaultViewConfig.sql index 75788f581b..c67b6fed02 100644 --- a/db/changes/10390-constitution/00-defaultViewConfig.sql +++ b/db/changes/10390-constitution/00-defaultViewConfig.sql @@ -1,7 +1,5 @@ UPDATE `salix`.`defaultViewConfig` SET `columns` = '{"intrastat":false,"description":false,"density":false,"isActive":false, - "freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":true, - "ektFk":false,"weight":false,"id":true,"packing":true,"grouping":true,"quantity":true, - "size":false,"name":true,"code":true,"origin":true,"family":true,"entryFk":true,"buyingValue":true, - "comissionValue":false,"price3":true,"packageFk":true,"packingOut":true,"landing":false}' + "freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"ektFk":false,"weight":false, + "size":false,"comissionValue":false,"landing":false}' WHERE tableCode = 'latestBuys' \ No newline at end of file diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index ed66292628..385e7e4b65 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -61,6 +61,10 @@ export default class Controller extends Section { field: 'isIgnored', searchable: false }, + { + field: 'landing', + searchable: false + } ] }; }