From 56331da20b144890280d8cacbdd1ab4b0788de2f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 1 Feb 2022 09:37:11 +0100 Subject: [PATCH 1/8] feat(item_index): add column producer --- db/changes/10420/00-defaultViewConfig.sql | 3 +++ modules/item/back/methods/item/filter.js | 1 + modules/item/front/index/index.html | 4 ++++ 3 files changed, 8 insertions(+) create mode 100644 db/changes/10420/00-defaultViewConfig.sql diff --git a/db/changes/10420/00-defaultViewConfig.sql b/db/changes/10420/00-defaultViewConfig.sql new file mode 100644 index 000000000..c65c1f403 --- /dev/null +++ b/db/changes/10420/00-defaultViewConfig.sql @@ -0,0 +1,3 @@ +UPDATE salix.defaultViewConfig + SET `columns`='{"intrastat":false,"stemMultiplier":false,"landed":false,"producer":false}' + WHERE tableCode ='itemsIndex'; diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 98e78c7aa..5755de69b 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -161,6 +161,7 @@ module.exports = Self => { i.stemMultiplier, i.typeFk, i.isFloramondo, + pr.name AS producer, it.name AS typeName, it.workerFk AS buyerFk, u.name AS userName, diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 816777a74..1456c74ef 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -54,6 +54,9 @@ Active + + Producer + Landed @@ -122,6 +125,7 @@ ng-model="::item.isActive"> + {{::item.producer}} {{::item.landed | date:'dd/MM/yyyy'}} From f90607c8c7aa9e823d9a803724d6f4d34dc6fd23 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 1 Feb 2022 12:39:58 +0100 Subject: [PATCH 2/8] change changes folder name --- db/changes/{10420 => 10420-valentines}/00-defaultViewConfig.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{10420 => 10420-valentines}/00-defaultViewConfig.sql (100%) diff --git a/db/changes/10420/00-defaultViewConfig.sql b/db/changes/10420-valentines/00-defaultViewConfig.sql similarity index 100% rename from db/changes/10420/00-defaultViewConfig.sql rename to db/changes/10420-valentines/00-defaultViewConfig.sql From 8be7f9153ead745f24f6af5f6e4469c5891618d3 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 1 Feb 2022 14:50:24 +0100 Subject: [PATCH 3/8] Removed non compatible ECMA options --- modules/ticket/back/methods/ticket/componentUpdate.js | 6 ++++-- modules/ticket/back/methods/ticket/priceDifference.js | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index de06212c7..0fa26c9ea 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -138,7 +138,9 @@ module.exports = Self => { const params = [args.id, args.shipped, args.warehouseFk]; const [salesMovable] = await Self.rawSql(query, params, myOptions); - const salesNewTicket = salesMovable.filter(sale => (sale.movable ?? 0) >= sale.quantity); + const saleMovable = sale.movable ? sale.movable : 0; + + const salesNewTicket = salesMovable.filter(sale => saleMovable >= sale.quantity); if (salesNewTicket.length) { const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions); args.id = newTicket.id; @@ -250,7 +252,7 @@ module.exports = Self => { res.id = args.id; if (tx) await tx.commit(); - + return res; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index c91956ece..d47fabd51 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -114,7 +114,7 @@ module.exports = Self => { const ticketOrigin = await models.Ticket.findById(args.id, null, myOptions); const differenceShipped = ticketOrigin.shipped.getTime() != args.shipped.getTime(); const differenceWarehouse = ticketOrigin.warehouseFk != args.warehouseId; - + salesObj.haveDifferences = differenceShipped || differenceWarehouse; let query = `CALL ticket_getMovable(?,?,?)`; @@ -122,8 +122,10 @@ module.exports = Self => { const [salesMovable] = await Self.rawSql(query, params, myOptions); const itemMovable = new Map(); - for (sale of salesMovable) - itemMovable.set(sale.id, sale.movable ?? 0); + for (sale of salesMovable) { + const saleMovable = sale.movable ? sale.movable : 0; + itemMovable.set(sale.id, saleMovable); + } // Sale price component, one per sale query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`; @@ -152,7 +154,7 @@ module.exports = Self => { } if (tx) await tx.commit(); - + return salesObj; } catch (e) { if (tx) await tx.rollback(); From 483a67e8b53fcfda2bc6174d71404e154b295395 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 2 Feb 2022 09:26:33 +0100 Subject: [PATCH 4/8] fix(salesFilter): search by ticket id --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 1f1d4d88a..047095abc 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -133,6 +133,10 @@ module.exports = Self => { const where = buildFilter(ctx.args, (param, value) => { switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {'t.id': {inq: value}} + : {'t.nickname': {like: `%${value}%`}}; case 'from': return {'t.shipped': {gte: value}}; case 'to': From 001aed3cb51cf728e24a836ff26e2e211b63f4bf Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 2 Feb 2022 14:32:16 +0100 Subject: [PATCH 5/8] fix(claim): filter created --- modules/claim/back/methods/claim/filter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 16f23433b..ec12c4de2 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -82,6 +82,7 @@ module.exports = Self => { Self.filter = async(ctx, filter, options) => { const conn = Self.dataSource.connector; const myOptions = {}; + let to; if (typeof options == 'object') Object.assign(myOptions, options); @@ -109,7 +110,11 @@ module.exports = Self => { case 'attenderFk': return {'cl.workerFk': value}; case 'created': - return {'cl.created': value}; + value.setHours(0, 0, 0); + to = new Date(value); + to.setHours(23, 59, 59, 999); + + return {'cl.created': {between: [value, to]}}; } }); From 91b6dcee05d10f42f8a826f0e293bfcb8d00d125 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 2 Feb 2022 14:33:16 +0100 Subject: [PATCH 6/8] fix(test): fixed bugs non compatible ECMA options --- e2e/paths/05-ticket/06_basic_data_steps.spec.js | 2 +- modules/ticket/back/methods/ticket/componentUpdate.js | 3 +-- modules/ticket/back/methods/ticket/priceDifference.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js index 7a09edf06..fa118c25d 100644 --- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket/06_basic_data_steps.spec.js @@ -94,7 +94,7 @@ describe('Ticket Edit basic data path', () => { it(`should split ticket without negatives`, async() => { const newAgency = 'Silla247'; const newDate = new Date(); - newDate.setDate(newDate.getDate() + 1); + newDate.setDate(newDate.getDate() - 1); await page.accessToSearchResult('14'); await page.accessToSection('ticket.card.basicData.stepOne'); diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 0fa26c9ea..2294e6d25 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -138,9 +138,8 @@ module.exports = Self => { const params = [args.id, args.shipped, args.warehouseFk]; const [salesMovable] = await Self.rawSql(query, params, myOptions); - const saleMovable = sale.movable ? sale.movable : 0; + const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity); - const salesNewTicket = salesMovable.filter(sale => saleMovable >= sale.quantity); if (salesNewTicket.length) { const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions); args.id = newTicket.id; diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index d47fabd51..e0ffac55a 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -112,7 +112,7 @@ module.exports = Self => { // Get items movable const ticketOrigin = await models.Ticket.findById(args.id, null, myOptions); - const differenceShipped = ticketOrigin.shipped.getTime() != args.shipped.getTime(); + const differenceShipped = ticketOrigin.shipped.getTime() > args.shipped.getTime(); const differenceWarehouse = ticketOrigin.warehouseFk != args.warehouseId; salesObj.haveDifferences = differenceShipped || differenceWarehouse; From 1250382209b82e107c0f0f7300cf4e38ca55d905 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 3 Feb 2022 09:52:17 +0100 Subject: [PATCH 7/8] missing zero --- modules/claim/back/methods/claim/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index ec12c4de2..f4b0c26a2 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -110,7 +110,7 @@ module.exports = Self => { case 'attenderFk': return {'cl.workerFk': value}; case 'created': - value.setHours(0, 0, 0); + value.setHours(0, 0, 0, 0); to = new Date(value); to.setHours(23, 59, 59, 999); From 902714ba7da69bfeed4c93d8f8c4a87dfd5ec85f Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 3 Feb 2022 10:32:59 +0100 Subject: [PATCH 8/8] feat(item_index): add producer basic filter --- modules/item/front/index/index.html | 2 +- modules/item/front/index/index.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 1456c74ef..750dbfc4d 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -125,7 +125,7 @@ ng-model="::item.isActive"> - {{::item.producer}} + {{::item.producer | dashIfEmpty}} {{::item.landed | date:'dd/MM/yyyy'}} diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index 915027c3c..d9e00305d 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -81,6 +81,8 @@ class Controller extends Section { return {'intr.description': value}; case 'name': return {'i.name': {like: `%${value}%`}}; + case 'producer': + return {'pr.name': {like: `%${value}%`}}; case 'id': case 'size': case 'subname':