From fe46dbd34312de5826b0315ab66a8f9b31aeb8bf Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 22 Nov 2021 11:49:30 +0100 Subject: [PATCH] feat(entry_last-buys): add filter isFloramondo --- db/dump/fixtures.sql | 2 +- .../back/methods/entry/latestBuysFilter.js | 7 ++++++ .../entry/specs/latestBuysFilter.spec.js | 24 +++++++++++++++++++ .../front/latest-buys-search-panel/index.html | 5 ++++ modules/entry/front/latest-buys/locale/es.yml | 2 ++ .../back/methods/item/specs/filter.spec.js | 4 ++-- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index b46056135..1fce7ae38 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -806,7 +806,7 @@ INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `d (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0), (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0), (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0), - (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 0), + (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1), (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0), (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0), (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0), diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index 7711bc0f1..435427448 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -49,6 +49,11 @@ module.exports = Self => { type: 'boolean', description: 'Whether the item is or not visible', }, + { + arg: 'floramondo', + type: 'boolean', + description: 'Whether the item is or not floramondo', + }, { arg: 'typeFk', type: 'integer', @@ -103,6 +108,8 @@ module.exports = Self => { return {'it.code': value}; case 'active': return {'i.isActive': value}; + case 'floramondo': + return {'i.isFloramondo': value}; case 'visible': if (value) return {'v.visible': {gt: 0}}; diff --git a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js index f386894dd..f983b8a4d 100644 --- a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js +++ b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js @@ -113,6 +113,30 @@ describe('Buy latests buys filter()', () => { expect(results.length).toBe(0); }); + it('should return results matching "floramondo"', async() => { + let ctx = { + args: { + floramondo: true + } + }; + + let results = await app.models.Buy.latestBuysFilter(ctx); + + expect(results.length).toBe(1); + }); + + it('should return results matching "not floramondo"', async() => { + let ctx = { + args: { + floramondo: false + } + }; + + let results = await app.models.Buy.latestBuysFilter(ctx); + + expect(results.length).toBe(5); + }); + it('should return results matching "salesPersonFk"', async() => { let ctx = { args: { diff --git a/modules/entry/front/latest-buys-search-panel/index.html b/modules/entry/front/latest-buys-search-panel/index.html index 4693141f8..8597ab0ea 100644 --- a/modules/entry/front/latest-buys-search-panel/index.html +++ b/modules/entry/front/latest-buys-search-panel/index.html @@ -58,6 +58,11 @@ ng-model="filter.visible" triple-state="true"> + + diff --git a/modules/entry/front/latest-buys/locale/es.yml b/modules/entry/front/latest-buys/locale/es.yml index 21eae0307..8d70844fa 100644 --- a/modules/entry/front/latest-buys/locale/es.yml +++ b/modules/entry/front/latest-buys/locale/es.yml @@ -4,6 +4,8 @@ Freight value: Porte Commission value: ComisiĆ³n Package value: Embalaje Is ignored: Ignorado +Is visible: Visible +Is floramondo: Floramondo Grouping price: Precio grouping Packing price: Precio packing Min price: Precio min diff --git a/modules/item/back/methods/item/specs/filter.spec.js b/modules/item/back/methods/item/specs/filter.spec.js index 7b1fac9ac..3e798bcca 100644 --- a/modules/item/back/methods/item/specs/filter.spec.js +++ b/modules/item/back/methods/item/specs/filter.spec.js @@ -70,8 +70,8 @@ describe('item filter()', () => { const ctx = {args: {filter: filter, isFloramondo: true}}; const result = await models.Item.filter(ctx, filter, options); - expect(result.length).toEqual(2); - expect(result[0].id).toEqual(13); + expect(result.length).toEqual(3); + expect(result[0].id).toEqual(9); await tx.rollback(); } catch (e) {