From 226794236853f5e1125f086530d39cd9e47d2b7d Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 10:25:40 +0100 Subject: [PATCH 1/4] fix: fix invoiceOut filter --- modules/invoiceOut/back/methods/invoiceOut/filter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/invoiceOut/back/methods/invoiceOut/filter.js b/modules/invoiceOut/back/methods/invoiceOut/filter.js index 99a80c169..764fdbb78 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/filter.js +++ b/modules/invoiceOut/back/methods/invoiceOut/filter.js @@ -14,6 +14,12 @@ module.exports = Self => { description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} }, + { + arg: 'id', + type: 'number', + description: 'The invoiceOut id', + http: {source: 'query'} + }, { arg: 'search', type: 'string', @@ -106,6 +112,8 @@ module.exports = Self => { return {'i.created': value}; case 'clientFk': return {'i.clientFk': value}; + case 'id': + return {'i.id': value}; case 'fi': return {'c.fi': value}; case 'amount': From 104bef43c1077bbf13a1dd7064793baac603e540 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 3 Dec 2024 14:03:08 +0100 Subject: [PATCH 2/4] feat: add country id filter to sales monitor --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 927f49999..a0c1fd427 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -88,6 +88,11 @@ module.exports = Self => { arg: 'alertLevel', type: 'number', description: `The alert level of the tickets` + }, + { + arg: 'countryFk', + type: 'number', + description: 'The country id filter' } ], returns: { @@ -182,6 +187,7 @@ module.exports = Self => { t.totalWithVat, io.id invoiceOutId, a.provinceFk, + p.countryFk, p.name province, w.name warehouse, am.name agencyMode, @@ -360,6 +366,7 @@ module.exports = Self => { } case 'agencyModeFk': case 'warehouseFk': + case 'countryFk': param = `f.${param}`; return {[param]: value}; } From d7af439787a9362ec0999fd9d9a1d9a5db2cde30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 3 Dec 2024 17:49:48 +0000 Subject: [PATCH 3/4] Actualizar modules/travel/back/methods/travel/extraCommunityFilter.js --- .../methods/travel/extraCommunityFilter.js | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index dcb704ff5..164da93af 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -112,45 +111,42 @@ module.exports = Self => { let stmt; stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.travel'); stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.travel + `CREATE TEMPORARY TABLE tmp.travel (INDEX (id)) ENGINE = MEMORY - SELECT - t.id, + SELECT t.id, t.ref, t.shipped, t.landed, t.kg, - am.id AS agencyModeFk, - am.name AS agencyModeName, - wo.id AS warehouseOutFk, - wo.name AS warehouseOutName, - w.name AS warehouseInFk, - w.name AS warehouseInName, - SUM(b.stickers) AS stickers, - s.id AS cargoSupplierFk, - s.nickname AS cargoSupplierNickname, - s.name AS supplierName, - CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg, + am.id agencyModeFk, + am.name agencyModeName, + wo.id warehouseOutFk, + wo.name warehouseOutName, + w.name warehouseInFk, + w.name warehouseInName, + SUM(b.stickers) stickers, + s.id cargoSupplierFk, + s.nickname cargoSupplierNickname, + s.name supplierName, + CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg, CAST( SUM( vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 - ) as DECIMAL(10,0) - ) as volumeKg, - GREATEST( - CAST(SUM(b.weight * b.stickers) AS INT), - CAST( + ) AS DECIMAL(10,0) + ) volumeKg, + CAST( + GREATEST( + SUM(b.weight * b.stickers) , SUM(vc.aerealVolumetricDensity * b.stickers * - IF(pkg.volume, - pkg.volume, - pkg.width * pkg.depth * pkg.height - ) / 1000000 - ) AS INT - ) - / t.kg * 100, 0) percentageKg + IF(pkg.volume, + pkg.volume, + pkg.width * pkg.depth * pkg.height) / 1000000) + ) / t.kg * 100 AS INT + ) percentageKg FROM travel t LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN entry e ON e.travelFk = t.id From 187cd226c44efc9089adc26d8f7d597aff864267 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 5 Dec 2024 06:56:18 +0100 Subject: [PATCH 4/4] feat: refs #7644 Added distinct total label count --- modules/entry/back/methods/entry/buyLabelSupplier.js | 4 ++++ modules/entry/back/methods/entry/labelSupplier.js | 3 +-- .../buy-label-supplier/buy-label-supplier.html | 2 +- .../reports/buy-label-supplier/buy-label-supplier.js | 11 ++++++++++- .../templates/reports/buy-label-supplier/sql/buy.sql | 7 +++++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/entry/back/methods/entry/buyLabelSupplier.js b/modules/entry/back/methods/entry/buyLabelSupplier.js index 61938f2f8..23806f561 100644 --- a/modules/entry/back/methods/entry/buyLabelSupplier.js +++ b/modules/entry/back/methods/entry/buyLabelSupplier.js @@ -9,6 +9,10 @@ module.exports = Self => { required: true, description: 'The entry id', http: {source: 'path'} + }, { + arg: 'showEntryLines', + type: 'boolean', + required: false } ], returns: [ diff --git a/modules/entry/back/methods/entry/labelSupplier.js b/modules/entry/back/methods/entry/labelSupplier.js index 32d80c427..07107d032 100644 --- a/modules/entry/back/methods/entry/labelSupplier.js +++ b/modules/entry/back/methods/entry/labelSupplier.js @@ -47,8 +47,7 @@ module.exports = Self => { for (const buy of buys) { if (buy.stickers < 1) continue; - ctx.args.id = buy.id; - ctx.args.copies = buy.stickers; + ctx.args = {...ctx.args, id: buy.id, showEntryLines: true}; const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions); await merger.add(new Uint8Array(pdfBuffer[0])); } diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.html b/print/templates/reports/buy-label-supplier/buy-label-supplier.html index 5777d34de..31fef38f7 100644 --- a/print/templates/reports/buy-label-supplier/buy-label-supplier.html +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.html @@ -86,7 +86,7 @@
{{$t('boxNum')}} - {{`${buy.labelNum} / ${buy.maxLabelNum}`}} + {{getTotal(buy)}}
diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.js b/print/templates/reports/buy-label-supplier/buy-label-supplier.js index 3cef5f295..5e59472eb 100755 --- a/print/templates/reports/buy-label-supplier/buy-label-supplier.js +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.js @@ -9,7 +9,7 @@ module.exports = { mixins: [vnReport], async serverPrefetch() { const buy = await models.Buy.findById(this.id, null); - this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]); + this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id, this.id]); const date = new Date(); this.weekNum = moment(date).isoWeek(); this.dayNum = moment(date).day(); @@ -27,6 +27,11 @@ module.exports = { height: 115, }); return new XMLSerializer().serializeToString(svgNode); + }, + getTotal(buy) { + return (this.showEntryLines) ? + `${buy.entryLabelNum} / ${buy.entryLabels}` : + `${buy.buyLabelNum} / ${buy.buyLabels}`; } }, props: { @@ -34,6 +39,10 @@ module.exports = { type: Number, required: true, description: 'The entry id' + }, + showEntryLines: { + type: Boolean, + required: false } } }; diff --git a/print/templates/reports/buy-label-supplier/sql/buy.sql b/print/templates/reports/buy-label-supplier/sql/buy.sql index 26efeb06e..fe001ff10 100644 --- a/print/templates/reports/buy-label-supplier/sql/buy.sql +++ b/print/templates/reports/buy-label-supplier/sql/buy.sql @@ -10,7 +10,7 @@ WITH RECURSIVE numbers AS ( ) ), labels AS ( - SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, + SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) entryLabelNum, i.name, i.`size`, i.category, @@ -33,6 +33,9 @@ labels AS ( WHERE b.entryFk = ? AND num.n <= b.stickers ) -SELECT *, (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) maxLabelNum +SELECT *, + ROW_NUMBER() OVER(ORDER BY entryLabelNum) buyLabelNum, + (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) entryLabels, + (SELECT stickers FROM buy WHERE id = ?) buyLabels FROM labels WHERE id = ? \ No newline at end of file