From 38311f526d528ec0858ce0d7cf4728391573dd36 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 3 Feb 2021 09:03:03 +0100 Subject: [PATCH] Calculate volume --- modules/entry/back/methods/entry/import.js | 3 ++- .../entry/back/methods/entry/importPreview.js | 25 +++++++++++++++++++ modules/entry/front/buy/import/index.html | 24 +++--------------- modules/entry/front/buy/import/index.js | 4 ++- 4 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 modules/entry/back/methods/entry/importPreview.js diff --git a/modules/entry/back/methods/entry/import.js b/modules/entry/back/methods/entry/import.js index efcd1001d..4b33fe964 100644 --- a/modules/entry/back/methods/entry/import.js +++ b/modules/entry/back/methods/entry/import.js @@ -29,7 +29,6 @@ module.exports = Self => { const models = Self.app.models; const entry = await models.Entry.findById(id); - console.log(entry); const buys = []; for (let buy of args.buys) { @@ -37,8 +36,10 @@ module.exports = Self => { entryFk: entry.id, itemFk: buy.itemFk, stickers: 1, + quantity: 1, packing: buy.packing, grouping: buy.grouping, + buyingValue: buy.buyingValue, packageFk: 1 }); } diff --git a/modules/entry/back/methods/entry/importPreview.js b/modules/entry/back/methods/entry/importPreview.js new file mode 100644 index 000000000..074f27ca7 --- /dev/null +++ b/modules/entry/back/methods/entry/importPreview.js @@ -0,0 +1,25 @@ +module.exports = Self => { + Self.remoteMethod('importPreview', { + description: '', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + }, + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/:id/importPreview`, + verb: 'GET' + } + }); + + Self.importPreview = async id => { + return buys; + }; +}; diff --git a/modules/entry/front/buy/import/index.html b/modules/entry/front/buy/import/index.html index f3fbdc50c..231b086fd 100644 --- a/modules/entry/front/buy/import/index.html +++ b/modules/entry/front/buy/import/index.html @@ -87,15 +87,11 @@ Item ID Description Size - Quantity - Stickers Packing Grouping Buying value - - + Package + Volume @@ -118,8 +114,6 @@ {{::buy.description | dashIfEmpty}} {{::buy.size | dashIfEmpty}} - {{::line.quantity}} - {{::line.stickers | dashIfEmpty}} {{::buy.packing | dashIfEmpty}} @@ -131,18 +125,8 @@ {{::buy.buyingValue | currency: 'EUR':2}} - - + {{::buy.packageFk | dashIfEmpty}} + {{::buy.volume | number}} diff --git a/modules/entry/front/buy/import/index.js b/modules/entry/front/buy/import/index.js index 685af5ba8..08e515380 100644 --- a/modules/entry/front/buy/import/index.js +++ b/modules/entry/front/buy/import/index.js @@ -35,6 +35,7 @@ class Controller extends Section { const boxes = invoice.boxes; const buys = []; for (let box of boxes) { + const boxVolume = box.nu_length * box.nu_width * box.nu_height; for (let product of box.products) { const packing = product.nu_stems_bunch * product.nu_bunches; buys.push({ @@ -42,7 +43,8 @@ class Controller extends Section { size: product.nu_length, packing: packing, grouping: product.nu_stems_bunch, - buyingValue: parseFloat(product.mny_rate_stem) + buyingValue: parseFloat(product.mny_rate_stem), + volume: boxVolume }); } }