From 939c507fba5c4d0286f8c7458cf3ffe75c3b0f79 Mon Sep 17 00:00:00 2001 From: Bernat Date: Mon, 21 Oct 2019 09:16:52 +0200 Subject: [PATCH 1/2] =?UTF-8?q?#1810=20El=20m=C3=A9todo=20listPackaging=20?= =?UTF-8?q?filtrar=20por=20isPackagingReturnable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/dump/fixtures.sql | 6 +++--- modules/ticket/back/methods/packaging/listPackaging.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2d3353f15..61d548edf 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -666,9 +666,9 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `create INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`) VALUES - (1, 0.00, 10, 10, 0, 0, CURDATE(), 6, 1.50), - (2, 100.00, 20, 20, 0, 0, CURDATE(), 7, 1.00), - (3, 14000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), + (1, 0.00, 10, 10, 0, 1, CURDATE(), 6, 1.50), + (2, 100.00, 20, 20, 0, 1, CURDATE(), 7, 1.00), + (3, 14000.00, 0, 0, 0, 1, CURDATE(), NULL, 0), (4, 218000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), (5, 292000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), (94, 140875.00, 49.00, 115.00, 25.00, 0, CURDATE(), 71, 0.00); diff --git a/modules/ticket/back/methods/packaging/listPackaging.js b/modules/ticket/back/methods/packaging/listPackaging.js index 033201818..174630f29 100644 --- a/modules/ticket/back/methods/packaging/listPackaging.js +++ b/modules/ticket/back/methods/packaging/listPackaging.js @@ -29,7 +29,7 @@ module.exports = Self => { FROM (SELECT i.name, i.id itemFk, p.id packagingFk FROM item i JOIN packaging p ON i.id = p.itemFk - WHERE i.name <> '') p` + WHERE i.name <> '' AND p.isPackageReturnable) p` ); stmt.merge(conn.makeSuffix(filter)); From 7bdb49797699b850ef01133986aa0039e7021e0a Mon Sep 17 00:00:00 2001 From: Bernat Date: Thu, 24 Oct 2019 12:49:18 +0200 Subject: [PATCH 2/2] #1773 travel.summary & #1774 --- db/changes/10100-AllSaints/00-upperGap.sql | 6 ++ db/dump/fixtures.sql | 82 +++++++------- .../travel/back/methods/travel/getEntries.js | 57 ++++++++++ .../travel/back/methods/travel/getTravel.js | 50 +++++++++ .../methods/travel/specs/getEntries.spec.js | 29 +++++ .../methods/travel/specs/getTravel.spec.js | 30 ++++++ modules/travel/back/model-config.json | 2 + modules/travel/back/models/entry.json | 72 +++++++++++++ modules/travel/back/models/travel.js | 4 + modules/travel/back/models/travel.json | 3 + modules/travel/front/card/index.html | 7 ++ modules/travel/front/card/index.js | 58 ++++++++++ modules/travel/front/descriptor/index.html | 36 +++++++ modules/travel/front/descriptor/index.js | 24 +++++ modules/travel/front/descriptor/locale/es.yml | 6 ++ modules/travel/front/index.js | 3 + modules/travel/front/index/index.html | 25 ++++- modules/travel/front/index/index.js | 9 +- modules/travel/front/routes.json | 13 +++ modules/travel/front/summary/index.html | 100 ++++++++++++++++++ modules/travel/front/summary/index.js | 44 ++++++++ modules/travel/front/summary/index.spec.js | 61 +++++++++++ modules/travel/front/summary/locale/es.yml | 17 +++ modules/travel/front/summary/style.scss | 10 ++ 24 files changed, 704 insertions(+), 44 deletions(-) create mode 100644 db/changes/10100-AllSaints/00-upperGap.sql create mode 100644 modules/travel/back/methods/travel/getEntries.js create mode 100644 modules/travel/back/methods/travel/getTravel.js create mode 100644 modules/travel/back/methods/travel/specs/getEntries.spec.js create mode 100644 modules/travel/back/methods/travel/specs/getTravel.spec.js create mode 100644 modules/travel/back/models/entry.json create mode 100644 modules/travel/back/models/travel.js create mode 100644 modules/travel/front/card/index.html create mode 100644 modules/travel/front/card/index.js create mode 100644 modules/travel/front/descriptor/index.html create mode 100644 modules/travel/front/descriptor/index.js create mode 100644 modules/travel/front/descriptor/locale/es.yml create mode 100644 modules/travel/front/summary/index.html create mode 100644 modules/travel/front/summary/index.js create mode 100644 modules/travel/front/summary/index.spec.js create mode 100644 modules/travel/front/summary/locale/es.yml create mode 100644 modules/travel/front/summary/style.scss diff --git a/db/changes/10100-AllSaints/00-upperGap.sql b/db/changes/10100-AllSaints/00-upperGap.sql new file mode 100644 index 000000000..6554c47b4 --- /dev/null +++ b/db/changes/10100-AllSaints/00-upperGap.sql @@ -0,0 +1,6 @@ +CREATE TABLE `vn`.`packagingConfig` ( + `id` INT NOT NULL AUTO_INCREMENT, + `upperGap` INT NOT NULL, + PRIMARY KEY (`id`)); + +INSERT INTO `vn`.`packagingConfig` (`upperGap`) VALUES ('10'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 61d548edf..1baaeaa10 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -649,7 +649,9 @@ INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `d (12, 3, 30, 'GRE', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, NULL), (13, 5, 30, 'GRE', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), (14, 5, 90, 'AZL', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), - (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, NULL, 2, NULL); + (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, NULL); INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`) VALUES @@ -666,12 +668,14 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `create INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`) VALUES - (1, 0.00, 10, 10, 0, 1, CURDATE(), 6, 1.50), - (2, 100.00, 20, 20, 0, 1, CURDATE(), 7, 1.00), - (3, 14000.00, 0, 0, 0, 1, CURDATE(), NULL, 0), - (4, 218000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), - (5, 292000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), - (94, 140875.00, 49.00, 115.00, 25.00, 0, CURDATE(), 71, 0.00); + (1, 0.00, 10, 10, 0, 1, CURDATE(), 6, 1.50), + (2, 100.00, 20, 20, 0, 1, CURDATE(), 7, 1.00), + (3, 14000.00, 0, 0, 0, 1, CURDATE(), NULL, 0), + (4, 218000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), + (5, 292000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), + (94, 140875.00, 49.00, 115.00, 25.00, 0, CURDATE(), 71, 0.00), + ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, CURDATE(), 15, 90.00), + ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, CURDATE(), 16, 0.00); INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`) VALUES @@ -1047,50 +1051,50 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`) (4, 4), (5, 6); -INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`) +INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`,`ref`, `totalEntries`) VALUES - (1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000), - (2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000), - (3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00), - (4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500), - (5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500), - (6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500), - (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500); + (1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1), + (2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 1), + (3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1), + (4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500, 'fourth travel', 1), + (5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500, 'fifth travel', 1), + (6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500, 'sixth travel', 1), + (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 1); -INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`,`ref`) +INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`, `notes`, `evaNotes`) VALUES - (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movimiento 1'), - (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movimiento 2'), - (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movimiento 3'), - (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 69, 'Movimiento 4'), - (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movimiento 5'), - (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movimiento 6'), - (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movimiento 7'); + (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 'this is the note one', 'observation one'), + (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 'this is the note two', 'observation two'), + (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 'this is the note three', 'observation three'), + (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 'this is the note four', 'observation four'), + (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 'this is the note five', 'observation five'), + (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 'this is the note six', 'observation six'), + (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 'this is the note seven', 'observation seven'); INSERT INTO `bi`.`claims_ratio`(`id_Cliente`, `Consumo`, `Reclamaciones`, `Ratio`, `recobro`, `inflacion`) VALUES (101, 500, NULL, 0.00, 0.00, 1.00), - (102, 1000, 2.00, 0.01, 0.05, 1.00), + (102, 1000, 2.00, 0.01, 0.05, 1.00), (103, 2000, 0.00, 0.00, 0.02, 1.00), (104, 2500, 150.00, 0.02, 0.10, 1.00); INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`,`minPrice`,`producer`,`printedStickers`,`isChecked`,`isIgnored`, `created`) VALUES - (1, 1, 1, 50, 5000, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (2, 2, 1, 50, 100, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, 3, 1, 50, 100, 4, 1, 0.000, 0.000, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), - (4, 2, 2, 5, 450, 3, 1, 0.000, 0.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), - (5, 3, 3, 55, 500, 5, 1, 0.000, 0.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0.00, NULL, 0, 1, 0, CURDATE()), - (6, 4, 8, 50, 1000, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), - (7, 4, 9, 20, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0.00, NULL, 0, 1, 0, CURDATE()), - (8, 4, 4, 1.25, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), - (9, 4, 4, 1.25, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), - (10, 5, 1, 50, 10, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), - (11, 5, 4, 1.25, 10, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), - (12, 6, 4, 1.25, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), - (13, 7, 1, 50, 0, 3, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), - (14, 7, 2, 5, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), - (15, 7, 4, 1.25, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()); + (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), + (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), + (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), + (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), + (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0.00, NULL, 0, 1, 0, CURDATE()), + (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), + (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0.00, NULL, 0, 1, 0, CURDATE()), + (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), + (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), + (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), + (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), + (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), + (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), + (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), + (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()); INSERT INTO `vn2008`.`tblContadores`(`id`,`FechaInventario`) VALUES diff --git a/modules/travel/back/methods/travel/getEntries.js b/modules/travel/back/methods/travel/getEntries.js new file mode 100644 index 000000000..7dc952999 --- /dev/null +++ b/modules/travel/back/methods/travel/getEntries.js @@ -0,0 +1,57 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +module.exports = Self => { + Self.remoteMethod('getEntries', { + description: 'Return the entries of a travel', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The travel id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/getEntries`, + verb: 'GET' + } + }); + + Self.getEntries = async id => { + let stmt; + + stmt = new ParameterizedSQL(` + SELECT e.travelFk, e.id, e.isConfirmed, e.ref, e.notes, e.evaNotes, + s.name AS supplierName, + CAST((SUM(IF(p.volume > 0,p.volume,p.width * p.depth * IF(p.height, p.height, i.size + pconfig.upperGap)) + * b.stickers)/1000000)/((pcc.width*pcc.depth*pcc.height)/1000000) AS DECIMAL(10,2)) cc, + CAST((SUM(IF(p.volume > 0,p.volume,p.width * p.depth * IF(p.height, p.height, i.size + pconfig.upperGap)) + * b.stickers)/1000000)/((ppallet.width*ppallet.depth*ppallet.height)/1000000) AS DECIMAL(10,2)) pallet, + CAST((SUM(IF(p.volume > 0,p.volume,p.width * p.depth * IF(p.height, p.height, i.size + pconfig.upperGap)) + * b.stickers)/1000000) AS DECIMAL(10,2)) m3, + TRUNCATE(SUM(b.stickers)/(COUNT( b.id) / COUNT( DISTINCT b.id)),0) hb, + CAST(SUM(b.freightValue*b.quantity) AS DECIMAL(10,2)) freightValue, + CAST(SUM(b.packageValue*b.quantity) AS DECIMAL(10,2)) packageValue + FROM vn.travel t + LEFT JOIN vn.entry e ON t.id = e.travelFk + LEFT JOIN vn.buy b ON b.entryFk = e.id + LEFT JOIN vn.supplier s ON e.supplierFk = s.id + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.packaging p ON p.id = b.packageFk + JOIN vn.packaging pcc ON pcc.id = 'cc' + JOIN vn.packaging ppallet ON ppallet.id = 'pallet 100' + JOIN vn.packagingConfig pconfig + WHERE t.id = ? + GROUP BY e.id;`, [ + id + ]); + + let result = await Self.rawStmt(stmt); + + return result; + }; +}; diff --git a/modules/travel/back/methods/travel/getTravel.js b/modules/travel/back/methods/travel/getTravel.js new file mode 100644 index 000000000..171b64db1 --- /dev/null +++ b/modules/travel/back/methods/travel/getTravel.js @@ -0,0 +1,50 @@ +module.exports = Self => { + Self.remoteMethod('getTravel', { + description: 'Returns the travel', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The travel id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/getTravel`, + verb: 'GET' + } + }); + + Self.getTravel = async id => { + let filter = { + where: {id: id}, + include: [ + { + relation: 'agency', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['id', 'name'] + } + } + ], + }; + + let travel = await Self.app.models.Travel.findOne(filter); + return travel; + }; +}; diff --git a/modules/travel/back/methods/travel/specs/getEntries.spec.js b/modules/travel/back/methods/travel/specs/getEntries.spec.js new file mode 100644 index 000000000..9b5c4fe49 --- /dev/null +++ b/modules/travel/back/methods/travel/specs/getEntries.spec.js @@ -0,0 +1,29 @@ +const app = require('vn-loopback/server/server'); + +describe('travel getEntries()', () => { + const travelId = 1; + it('should check the response contains the id', async() => { + const entries = await app.models.Travel.getEntries(travelId); + + expect(entries.length).toEqual(1); + expect(entries[0].id).toEqual(1); + }); + + it('should check the response contains the travelFk', async() => { + const entries = await app.models.Travel.getEntries(travelId); + + expect(entries[0].travelFk).toEqual(1); + }); + + it('should check the response contains the ref', async() => { + const entries = await app.models.Travel.getEntries(travelId); + + expect(entries[0].ref).toEqual('Movement 1'); + }); + + it('should check the response contains the m3', async() => { + const entries = await app.models.Travel.getEntries(travelId); + + expect(entries[0].m3).toEqual(0.22); + }); +}); diff --git a/modules/travel/back/methods/travel/specs/getTravel.spec.js b/modules/travel/back/methods/travel/specs/getTravel.spec.js new file mode 100644 index 000000000..7820077f5 --- /dev/null +++ b/modules/travel/back/methods/travel/specs/getTravel.spec.js @@ -0,0 +1,30 @@ +const app = require('vn-loopback/server/server'); + +describe('travel getTravel()', () => { + const travelId = 1; + it('should check travel contains the id', async() => { + const travel = await app.models.Travel.getTravel(travelId); + + expect(travel.id).toEqual(1); + }); + + it('should check travel contains the agency', async() => { + const travel = await app.models.Travel.getTravel(travelId); + const agencyName = travel.agency().name; + + expect(agencyName).toEqual('inhouse pickup'); + }); + + it('should check travel contains the receiver warehouse name', async() => { + const travel = await app.models.Travel.getTravel(travelId); + const receiverWarehouseName = travel.warehouseIn().name; + + expect(receiverWarehouseName).toEqual('Warehouse One'); + }); + + it('should check travel contains the totalEntries', async() => { + const travel = await app.models.Travel.getTravel(travelId); + + expect(travel.totalEntries).toEqual(1); + }); +}); diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index 95879c1a5..ed089d755 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -1,5 +1,7 @@ { "Travel": { "dataSource": "vn" + },"Entry": { + "dataSource": "vn" } } diff --git a/modules/travel/back/models/entry.json b/modules/travel/back/models/entry.json new file mode 100644 index 000000000..23c88091a --- /dev/null +++ b/modules/travel/back/models/entry.json @@ -0,0 +1,72 @@ +{ + "name": "Entry", + "base": "VnModel", + "options": { + "mysql": { + "table": "entry" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "dated": { + "type": "date" + }, + "ref": { + "type": "String" + }, + "isBooked": { + "type": "Boolean" + }, + "isInventory": { + "type": "Boolean" + }, + "notes": { + "type": "Number" + }, + "isConfirmed": { + "type": "Boolean" + }, + "isRaid": { + "type": "Boolean" + }, + "commission": { + "type": "Number" + }, + "created": { + "type": "date" + }, + "evaNotes": { + "type": "String", + "mysql": { + "columnName": "observation" + } + }, + "isBlocked": { + "type": "Boolean" + }, + "loadPriority": { + "type": "Number" + } + }, + "relations": { + "supplier": { + "type": "belongsTo", + "model": "Supplier", + "foreignKey": "supplierFk" + }, + "travel": { + "type": "belongsTo", + "model": "Travel", + "foreignKey": "travelFk" + }, + "company": { + "type": "belongsTo", + "model": "Company", + "foreignKey": "companyFk" + } + } +} diff --git a/modules/travel/back/models/travel.js b/modules/travel/back/models/travel.js new file mode 100644 index 000000000..936b68cd9 --- /dev/null +++ b/modules/travel/back/models/travel.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/travel/getTravel')(Self); + require('../methods/travel/getEntries')(Self); +}; diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index e7fe4684e..fd881dd10 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -29,6 +29,9 @@ }, "totalEntries": { "type": "Number" + }, + "m3": { + "type": "Number" } }, "relations": { diff --git a/modules/travel/front/card/index.html b/modules/travel/front/card/index.html new file mode 100644 index 000000000..e6a112c7d --- /dev/null +++ b/modules/travel/front/card/index.html @@ -0,0 +1,7 @@ + + + + + +
+
diff --git a/modules/travel/front/card/index.js b/modules/travel/front/card/index.js new file mode 100644 index 000000000..677e944c2 --- /dev/null +++ b/modules/travel/front/card/index.js @@ -0,0 +1,58 @@ +import ngModule from '../module'; + +export default class Controller { + constructor($stateParams, $http) { + this.$http = $http; + this.$stateParams = $stateParams; + this.travel = null; + this.filter = { + fields: [ + 'id', + 'ref', + 'warehouseInFk', + 'warehouseOutFk', + 'shipped', + 'landed', + 'totalEntries' + ], + + where: {id: $stateParams.id}, + include: [ + { + relation: 'warehouseIn', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['id', 'name'] + } + } + ] + }; + } + + $onInit() { + this.getCard(); + } + + getCard() { + const params = {filter: this.filter}; + this.$http.get(`/api/Travels/${this.$stateParams.id}`, {params}).then(response => { + this.travel = response.data; + }); + } + + reload() { + this.getCard(); + } +} +Controller.$inject = ['$stateParams', '$http']; + +ngModule.component('vnTravelCard', { + template: require('./index.html'), + controller: Controller +}); + diff --git a/modules/travel/front/descriptor/index.html b/modules/travel/front/descriptor/index.html new file mode 100644 index 000000000..3b932ef53 --- /dev/null +++ b/modules/travel/front/descriptor/index.html @@ -0,0 +1,36 @@ +
+
+ + + + + + + +
+
+
+ + + + + + + + + + + + + + +
+
+
diff --git a/modules/travel/front/descriptor/index.js b/modules/travel/front/descriptor/index.js new file mode 100644 index 000000000..034e3a0ff --- /dev/null +++ b/modules/travel/front/descriptor/index.js @@ -0,0 +1,24 @@ +import ngModule from '../module'; + +class Controller { + constructor($, $http, vnApp, $translate, aclService) { + this.$http = $http; + this.vnApp = vnApp; + this.$translate = $translate; + this.$ = $; + this.aclService = aclService; + } +} + +Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService']; + +ngModule.component('vnTravelDescriptor', { + template: require('./index.html'), + bindings: { + travel: '<' + }, + require: { + card: '^vnTravelCard' + }, + controller: Controller +}); diff --git a/modules/travel/front/descriptor/locale/es.yml b/modules/travel/front/descriptor/locale/es.yml new file mode 100644 index 000000000..1f51a0132 --- /dev/null +++ b/modules/travel/front/descriptor/locale/es.yml @@ -0,0 +1,6 @@ +Reference: Referencia +Wh. In: Warehouse entrada +Wh. Out: Warehouse salida +Shipped: F. envío +Landed: F. entrega +Total entries: Entradas totales \ No newline at end of file diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js index 6849e9df3..82795940d 100644 --- a/modules/travel/front/index.js +++ b/modules/travel/front/index.js @@ -2,3 +2,6 @@ export * from './module'; import './index/'; import './search-panel'; +import './descriptor'; +import './card'; +import './summary'; diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 637e9ac05..6af3ddad0 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -31,11 +31,13 @@ Warehouse In Landed Received - + - + {{::travel.id}} {{::travel.ref}} {{::travel.agency.name}} @@ -45,11 +47,26 @@ {{::travel.warehouseIn.name}} {{::travel.landed | date:'dd/MM/yyyy'}} - - + + + + + + + + + + + \ No newline at end of file diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index d30cc39f8..068569c0b 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; export default class Controller { constructor($scope) { - this.$scope = $scope; + this.$ = $scope; this.ticketSelected = null; this.filter = { @@ -47,6 +47,13 @@ export default class Controller { return {[param]: value}; } } + + preview(event, travel) { + this.travelSelected = travel; + this.$.summary.show(); + event.preventDefault(); + event.stopImmediatePropagation(); + } } Controller.$inject = ['$scope']; diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index ed7b229cf..070785831 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -16,6 +16,19 @@ "component": "vn-travel-index", "description": "Travels", "acl": ["developer"] + }, { + "url": "/:id", + "state": "travel.card", + "abstract": true, + "component": "vn-travel-card" + }, { + "url": "/summary", + "state": "travel.card.summary", + "component": "vn-travel-summary", + "description": "Summary", + "params": { + "travel": "$ctrl.travel" + } } ] } \ No newline at end of file diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html new file mode 100644 index 000000000..623c4a0ad --- /dev/null +++ b/modules/travel/front/summary/index.html @@ -0,0 +1,100 @@ + +
{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Entries

+ + + + Confirmed + Entry Id + Supplier + Reference + HB + Freight cost + Package cost + CC + Pallet + m3 + + + + + + + + {{entry.id}} + {{entry.supplierName}} + {{entry.ref}} + {{entry.hb}} + {{entry.freightValue}} + {{entry.packageValue}} + {{entry.cc}} + {{entry.pallet}} + {{entry.m3}} + + + + + + + + + +
+
+
+ + + + \ No newline at end of file diff --git a/modules/travel/front/summary/index.js b/modules/travel/front/summary/index.js new file mode 100644 index 000000000..20946ed3b --- /dev/null +++ b/modules/travel/front/summary/index.js @@ -0,0 +1,44 @@ +import ngModule from '../module'; +import './style.scss'; + +class Controller { + constructor($scope, $http) { + this.$ = $scope; + this.$http = $http; + } + + get travel() { + return this._travel; + } + + set travel(value) { + this._travel = value; + + if (value && value.id) { + this.getTravel(); + this.getEntries(); + } + } + + getTravel() { + return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => { + this.travelData = response.data; + }); + } + + getEntries() { + return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => { + this.entries = response.data; + }); + } +} + +Controller.$inject = ['$scope', '$http']; + +ngModule.component('vnTravelSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + travel: '<' + } +}); diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js new file mode 100644 index 000000000..dc6e4b23a --- /dev/null +++ b/modules/travel/front/summary/index.spec.js @@ -0,0 +1,61 @@ +import './index'; + +describe('component vnTravelSummary', () => { + let controller; + let $httpBackend; + + + beforeEach(angular.mock.module('travel', $translateProvider => { + $translateProvider.translations('en', {}); + })); + + beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnTravelSummary'); + })); + + describe('travel setter/getter', () => { + it('should return the travel', () => { + controller.travel = {id: null}; + + expect(controller.travel).toEqual(jasmine.any(Object)); + }); + + it('should return the travel and then call both getTravel() and getEntries()', () => { + spyOn(controller, 'getTravel'); + spyOn(controller, 'getEntries'); + controller.travel = {id: 99}; + + + expect(controller._travel.id).toEqual(99); + expect(controller.getTravel).toHaveBeenCalledWith(); + expect(controller.getEntries).toHaveBeenCalledWith(); + }); + }); + + describe('getTravel()', () => { + it('should perform a get and then store data on the controller', () => { + controller._travel = {id: 999}; + + const query = `/api/Travels/${controller._travel.id}/getTravel`; + $httpBackend.expectGET(query).respond('I am the travelData'); + controller.getTravel(); + $httpBackend.flush(); + + expect(controller.travelData).toEqual('I am the travelData'); + }); + }); + + describe('getEntries()', () => { + it('should call the getEntries method to get the entries data', () => { + controller._travel = {id: 999}; + + const query = `/api/Travels/${controller._travel.id}/getEntries`; + $httpBackend.expectGET(query).respond('I am the entries'); + controller.getEntries(); + $httpBackend.flush(); + + expect(controller.entries).toEqual('I am the entries'); + }); + }); +}); diff --git a/modules/travel/front/summary/locale/es.yml b/modules/travel/front/summary/locale/es.yml new file mode 100644 index 000000000..16f21fdde --- /dev/null +++ b/modules/travel/front/summary/locale/es.yml @@ -0,0 +1,17 @@ +Reference: Referencia +Warehouse In: Almacen entrada +Warehouse Out: Almacen salida +Shipped: F. envío +Landed: F. entrega +Total entries: Entradas totales +Delivered: Enviada +Received: Recibida +Agency: Agencia +Entries: Entradas +Confirmed: Confirmada +Entry Id: Entrada Id +Supplier: Proveedor +Pallet: Pallet +Freight cost: Coste porte +Package cost: Coste embalaje +Half box: Media caja diff --git a/modules/travel/front/summary/style.scss b/modules/travel/front/summary/style.scss new file mode 100644 index 000000000..922b36ad8 --- /dev/null +++ b/modules/travel/front/summary/style.scss @@ -0,0 +1,10 @@ +@import "variables"; + + +vn-travel-summary .summary { + max-width: $width-lg; + + vn-icon[icon=insert_drive_file]{ + color: $color-font-secondary; + } +} \ No newline at end of file