From d414db73de1f43768519b3256f9e6516a6bc7140 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 30 Jun 2020 08:32:04 +0200 Subject: [PATCH 1/4] order index add buton and columns --- loopback/locale/es.json | 3 ++- modules/order/front/index/index.html | 20 ++++++++++++-------- modules/order/front/index/index.js | 15 +++++++++++++++ modules/order/front/locale/es.yml | 4 +++- modules/order/front/summary/index.html | 11 ++++++++++- modules/order/front/summary/index.js | 9 +++++++++ modules/order/front/summary/style.scss | 15 +++++++++++++++ 7 files changed, 66 insertions(+), 11 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e58d55da0..9951df4a5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -133,5 +133,6 @@ "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", "This ticket is deleted": "Este ticket está eliminado", "A travel with this data already exists": "Ya existe un travel con estos datos", - "This thermograph id already exists": "La id del termógrafo ya existe" + "This thermograph id already exists": "La id del termógrafo ya existe", + "ORDER_ALREADY_CONFIRMED": "ORDER_ALREADY_CONFIRMED" } \ No newline at end of file diff --git a/modules/order/front/index/index.html b/modules/order/front/index/index.html index a28979646..0d299a5b1 100644 --- a/modules/order/front/index/index.html +++ b/modules/order/front/index/index.html @@ -10,8 +10,8 @@ Id - Client Sales person + Client Confirmed Created Landed @@ -26,16 +26,16 @@ {{::order.id}} - {{::order.clientName}} + vn-click-stop="workerDescriptor.show($event, order.salesPersonFk)" + class="link" > + {{::order.name | dashIfEmpty}} - {{::order.name | dashIfEmpty}} + vn-click-stop="clientDescriptor.show($event, order.clientFk)" + class="link"> + {{::order.clientName}} @@ -45,7 +45,11 @@ {{::order.created | date: 'dd/MM/yyyy HH:mm'}} - {{::order.landed | date:'dd/MM/yyyy'}} + + + {{::order.landed | date:'dd/MM/yyyy'}} + + {{::order.total | currency: 'EUR': 2 | dashIfEmpty}} -
{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - {{$ctrl.summary.client.salesPerson.id}}
+
{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - {{$ctrl.summary.client.salesPerson.id}} + + +
{ + this.vnApp.showSuccess(this.$t('Order confirmed')); + this.$state.go(`ticket.index`, { + q: JSON.stringify({clientFk: this.order.clientFk}) + }); + }); + } } ngModule.component('vnOrderSummary', { diff --git a/modules/order/front/summary/style.scss b/modules/order/front/summary/style.scss index a0ed56d42..d0f7a3d03 100644 --- a/modules/order/front/summary/style.scss +++ b/modules/order/front/summary/style.scss @@ -3,6 +3,21 @@ vn-order-summary .summary{ max-width: $width-lg; + h5 { + display: flex; + justify-content: space-between; + align-items: center; + align-content: center; + + + span { + flex: 1; + } + + vn-button { + flex: none + } + } & > div > vn-horizontal > vn-one { min-width: 160px !important; From c42c6c19d6aba15f54322ea1f4ba211935fa3439 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 2 Jul 2020 07:46:55 +0200 Subject: [PATCH 2/4] changes in order index --- .../00-zoneEstimatedDelivery.sql | 47 +++++++++++++ db/changes/12200-Normalidad/01-zoneETD.sql | 16 +++++ db/dump/fixtures.sql | 39 ++++++++--- e2e/paths/07-order/01_summary.spec.js | 1 + modules/order/back/methods/order/filter.js | 10 ++- modules/order/front/index/index.html | 6 +- modules/order/front/index/index.js | 1 - modules/order/front/index/index.spec.js | 67 +++++++++++++++++++ modules/zone/back/model-config.json | 3 + .../back/models/zone-estimated-delivery.json | 44 ++++++++++++ 10 files changed, 219 insertions(+), 15 deletions(-) create mode 100644 db/changes/12200-Normalidad/00-zoneEstimatedDelivery.sql create mode 100644 db/changes/12200-Normalidad/01-zoneETD.sql create mode 100644 modules/order/front/index/index.spec.js create mode 100644 modules/zone/back/models/zone-estimated-delivery.json diff --git a/db/changes/12200-Normalidad/00-zoneEstimatedDelivery.sql b/db/changes/12200-Normalidad/00-zoneEstimatedDelivery.sql new file mode 100644 index 000000000..8cf30796e --- /dev/null +++ b/db/changes/12200-Normalidad/00-zoneEstimatedDelivery.sql @@ -0,0 +1,47 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`zoneEstimatedDelivery` AS + SELECT + `t`.`zoneFk` AS `zoneFk`, + CAST((CURDATE() + INTERVAL ((HOUR(`zc`.`hour`) * 60) + MINUTE(`zc`.`hour`)) MINUTE) + AS TIME) AS `hourTheoretical`, + CAST(SUM(`sv`.`volume`) AS DECIMAL (5 , 1 )) AS `totalVolume`, + CAST(SUM(IF((`s`.`alertLevel` < 2), + `sv`.`volume`, + 0)) + AS DECIMAL (5 , 1 )) AS `remainingVolume`, + GREATEST(IFNULL(`lhp`.`m3`, 0), + IFNULL(`dl`.`minSpeed`, 0)) AS `speed`, + CAST((`zc`.`hour` + INTERVAL ((-(SUM(IF((`s`.`alertLevel` < 2), + `sv`.`volume`, + 0))) * 60) / GREATEST(IFNULL(`lhp`.`m3`, 0), + IFNULL(`dl`.`minSpeed`, 0))) MINUTE) + AS TIME) AS `hourEffective`, + FLOOR(((-(SUM(IF((`s`.`alertLevel` < 2), + `sv`.`volume`, + 0))) * 60) / GREATEST(IFNULL(`lhp`.`m3`, 0), + IFNULL(`dl`.`minSpeed`, 0)))) AS `minutesLess`, + CAST((`zc`.`hour` + INTERVAL ((-(SUM(IF((`s`.`alertLevel` < 2), + `sv`.`volume`, + 0))) * 60) / GREATEST(IFNULL(`lhp`.`m3`, 0), + IFNULL(`dl`.`minSpeed`, 0))) MINUTE) + AS TIME) AS `etc` + FROM + ((((((((`ticket` `t` + JOIN `ticketStateToday` `tst` ON ((`tst`.`ticket` = `t`.`id`))) + JOIN `state` `s` ON ((`s`.`id` = `tst`.`state`))) + JOIN `saleVolume` `sv` ON ((`sv`.`ticketFk` = `t`.`id`))) + LEFT JOIN `lastHourProduction` `lhp` ON ((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) + JOIN `warehouse` `w` ON ((`w`.`id` = `t`.`warehouseFk`))) + JOIN `warehouseAlias` `wa` ON ((`wa`.`id` = `w`.`aliasFk`))) + LEFT JOIN `zoneClosure` `zc` ON (((`zc`.`zoneFk` = `t`.`zoneFk`) + AND (`zc`.`dated` = CURDATE())))) + LEFT JOIN `cache`.`departure_limit` `dl` ON (((`dl`.`warehouse_id` = `t`.`warehouseFk`) + AND (`dl`.`fecha` = CURDATE())))) + WHERE + ((`wa`.`name` = 'Silla') + AND (CAST(`t`.`shipped` AS DATE) = CURDATE())) + GROUP BY `t`.`zoneFk`; \ No newline at end of file diff --git a/db/changes/12200-Normalidad/01-zoneETD.sql b/db/changes/12200-Normalidad/01-zoneETD.sql new file mode 100644 index 000000000..e4cf48548 --- /dev/null +++ b/db/changes/12200-Normalidad/01-zoneETD.sql @@ -0,0 +1,16 @@ +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`zone_ETD` AS + SELECT + `zed`.`zoneFk` AS `zoneFk`, + `zed`.`hourTheoretical` AS `HoraTeórica`, + `zed`.`totalVolume` AS `volumenTotal`, + `zed`.`remainingVolume` AS `volumenPendiente`, + `zed`.`speed` AS `velocidad`, + `zed`.`hourEffective` AS `HoraPráctica`, + `zed`.`minutesLess` AS `minutesLess`, + `zed`.`etc` AS `etc` + FROM + `vn`.`zoneEstimatedDelivery` `zed` \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index e48a20ec6..ed2ee8a8f 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -88,13 +88,18 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, (19,'Francia', 1, 'FR', 1, 27), (30,'Canarias', 1, 'IC', 1, 24); -INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`) +INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) VALUES - (1, 'Warehouse One', 1, 1, 1, 1, 1, 1, 1), - (2, 'Warehouse Two', 1, 1, 1, 1, 0, 0, 1), - (3, 'Warehouse Three', 1, 1, 1, 1, 0, 0, 0), - (4, 'Warehouse Four', 1, 1, 1, 1, 0, 0, 0), - (5, 'Warehouse Five', 1, 1, 1, 1, 0, 0, 0); + (1, 'Main Warehouse'), + (2, 'Silla'); + +INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`) + VALUES + (1, 'Warehouse One', 1, 1, 1, 1, 1, 1, 1, 2), + (2, 'Warehouse Two', 1, 1, 1, 1, 0, 0, 1, 2), + (3, 'Warehouse Three', 1, 1, 1, 1, 0, 0, 0, 2), + (4, 'Warehouse Four', 1, 1, 1, 1, 0, 0, 0, 2), + (5, 'Warehouse Five', 1, 1, 1, 1, 0, 0, 0, 2); INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`) VALUES @@ -111,10 +116,6 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park ('GVC', '1', '0', '1', '0', '106'), ('HEJ', '2', '0', '1', '0', '106'); -INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) - VALUES - (1, 'Main Warehouse'); - INSERT INTO `vn`.`accountingType`(`id`, `description`) VALUES (1, 'Digital money'), @@ -510,7 +511,23 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) (11, 11, 5), (12, 12, 4), (13, 13, 5); - + +INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) + VALUES + (1, CURDATE(), '23:59'), + (2, CURDATE(), '23:59'), + (3, CURDATE(), '23:59'), + (4, CURDATE(), '23:59'), + (5, CURDATE(), '23:59'), + (6, CURDATE(), '23:59'), + (7, CURDATE(), '23:59'), + (8, CURDATE(), '23:59'), + (9, CURDATE(), '23:59'), + (10, CURDATE(), '23:59'), + (11, CURDATE(), '23:59'), + (12, CURDATE(), '23:59'), + (13, CURDATE(), '23:59'); + INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) diff --git a/e2e/paths/07-order/01_summary.spec.js b/e2e/paths/07-order/01_summary.spec.js index f4bc44827..d170f290e 100644 --- a/e2e/paths/07-order/01_summary.spec.js +++ b/e2e/paths/07-order/01_summary.spec.js @@ -8,6 +8,7 @@ describe('Order summary path', () => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('employee', 'order'); + await page.waitFor(2000); await page.accessToSearchResult('16'); }); diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index cdd54859f..7f45904eb 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -157,14 +157,20 @@ module.exports = Self => { c.salesPersonFk, u.nickname workerNickname, u.name name, - co.code companyCode + co.code companyCode, + zed.zoneFk, + zed.hourTheoretical, + zed.hourEffective FROM hedera.order o LEFT JOIN address a ON a.id = o.address_id LEFT JOIN agencyMode am ON am.id = o.agency_id LEFT JOIN client c ON c.id = o.customer_id LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.userFk - LEFT JOIN company co ON co.id = o.company_id`); + LEFT JOIN company co ON co.id = o.company_id + LEFT JOIN orderTicket ot ON ot.orderFk = o.id + LEFT JOIN ticket t ON t.id = ot.ticketFk + LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`); if (args && args.ticketFk) { stmt.merge({ diff --git a/modules/order/front/index/index.html b/modules/order/front/index/index.html index 0d299a5b1..8e64b4b0c 100644 --- a/modules/order/front/index/index.html +++ b/modules/order/front/index/index.html @@ -15,6 +15,8 @@ Confirmed Created Landed + T. Hour + Real hour Total
@@ -38,7 +40,7 @@ {{::order.clientName}} - + @@ -50,6 +52,8 @@ {{::order.landed | date:'dd/MM/yyyy'}} + {{::order.hourTheoretical | date: 'HH:mm'}} + {{::ticket.hourEffective | date: 'HH:mm'}} {{::order.total | currency: 'EUR': 2 | dashIfEmpty}} { + let controller; + let $window; + let orders = [{ + id: 1, + clientFk: 1, + isConfirmed: false + }, { + id: 2, + clientFk: 1, + isConfirmed: false + }, { + id: 3, + clientFk: 1, + isConfirmed: true + }]; + + beforeEach(ngModule('order')); + + beforeEach(inject(($componentController, _$window_,) => { + $window = _$window_; + const $element = angular.element(''); + controller = $componentController('vnOrderIndex', {$element}); + })); + + describe('compareDate()', () => { + it('should return warning when the date is the present', () => { + let curDate = new Date(); + let result = controller.compareDate(curDate); + + expect(result).toEqual('warning'); + }); + + it('should return sucess when the date is in the future', () => { + let futureDate = new Date(); + futureDate = futureDate.setDate(futureDate.getDate() + 10); + let result = controller.compareDate(futureDate); + + expect(result).toEqual('success'); + }); + + it('should return undefined when the date is in the past', () => { + let pastDate = new Date(); + pastDate = pastDate.setDate(pastDate.getDate() - 10); + let result = controller.compareDate(pastDate); + + expect(result).toEqual(undefined); + }); + }); + + describe('preview()', () => { + it('should show the dialog summary', () => { + controller.$.summary = {show: () => {}}; + jest.spyOn(controller.$.summary, 'show'); + + let event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + controller.preview(event, orders[0]); + + expect(controller.$.summary.show).toHaveBeenCalledWith(); + }); + }); +}); diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index 7638e3f6c..f353be088 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -28,5 +28,8 @@ }, "ZoneWarehouse": { "dataSource": "vn" + }, + "ZoneEstimatedDelivery": { + "dataSource": "vn" } } diff --git a/modules/zone/back/models/zone-estimated-delivery.json b/modules/zone/back/models/zone-estimated-delivery.json new file mode 100644 index 000000000..d65cee3b5 --- /dev/null +++ b/modules/zone/back/models/zone-estimated-delivery.json @@ -0,0 +1,44 @@ +{ + "name": "ZoneEstimatedDelivery", + "base": "VnModel", + "options": { + "mysql": { + "table": "zoneEstimatedDelivery" + } + }, + "properties": { + "zoneFk": { + "id": true, + "type": "Number" + }, + "hourTheoretical": { + "type": "date" + }, + "totalVolume": { + "type": "Number" + }, + "remainingVolume": { + "type": "Number" + }, + "speed": { + "type": "Number" + }, + "hourEffective": { + "type": "Date" + }, + "minutesLess": { + "type": "Date" + }, + "etc": { + "type": "Date" + } + + }, + "relations": { + "zone": { + "type": "belongsTo", + "model": "Zone", + "foreignKey": "zoneFk" + } + } +} \ No newline at end of file From ee704b302ccdb7443890b7099da5b454dd3e6ed8 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 6 Jul 2020 10:20:45 +0200 Subject: [PATCH 3/4] update order filter --- e2e/helpers/selectors.js | 2 +- e2e/paths/07-order/05_index.spec.js | 8 ++++---- .../back/methods/claim/specs/regularizeClaim.spec.js | 3 +-- modules/order/back/methods/order/filter.js | 8 ++++++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index c9286ef43..1f1ce7da5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -625,7 +625,7 @@ export default { }, ordersIndex: { searchResult: 'vn-order-index vn-card > vn-table > div > vn-tbody > a.vn-tr', - firstSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody vn-tr vn-td:nth-child(7)', + secondSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody vn-tr:nth-child(2) vn-td:nth-child(9)', searchResultDate: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)', searchResultAddress: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(6)', searchButton: 'vn-searchbar vn-icon[icon="search"]', diff --git a/e2e/paths/07-order/05_index.spec.js b/e2e/paths/07-order/05_index.spec.js index ef55051aa..c07a9c6f7 100644 --- a/e2e/paths/07-order/05_index.spec.js +++ b/e2e/paths/07-order/05_index.spec.js @@ -15,9 +15,9 @@ describe('Order Index', () => { await browser.close(); }); - it(`should check the first search result doesn't contain a total of 0€`, async() => { + it(`should check the second search result doesn't contain a total of 0€`, async() => { await page.waitToClick(selectors.ordersIndex.searchButton); - const result = await page.waitToGetProperty(selectors.ordersIndex.firstSearchResultTotal, 'innerText'); + const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText'); expect(result).not.toContain('0.00'); }); @@ -26,8 +26,8 @@ describe('Order Index', () => { await page.waitToClick(selectors.ordersIndex.openAdvancedSearch); await page.waitToClick(selectors.ordersIndex.advancedSearchShowEmptyCheckbox); await page.waitToClick(selectors.ordersIndex.advancedSearchButton); - await page.waitForTextInElement(selectors.ordersIndex.firstSearchResultTotal, '0.00'); - const result = await page.waitToGetProperty(selectors.ordersIndex.firstSearchResultTotal, 'innerText'); + await page.waitForTextInElement(selectors.ordersIndex.secondSearchResultTotal, '0.00'); + const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText'); expect(result).toContain('0.00'); }); diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index ecaccd4e4..1d3bff26d 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -1,7 +1,6 @@ const app = require('vn-loopback/server/server'); -// #2304 -xdescribe('regularizeClaim()', () => { +describe('regularizeClaim()', () => { const claimFk = 1; const pendentState = 1; const resolvedState = 3; diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 7f45904eb..3821c31e4 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -133,7 +133,6 @@ module.exports = Self => { }); filter = mergeFilters(filter, {where}); - let stmts = []; let stmt; @@ -178,7 +177,12 @@ module.exports = Self => { }); } - stmt.merge(conn.makeSuffix(filter)); + // stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge({ + sql: `GROUP BY o.id` + }); + stmt.merge(conn.makePagination(filter)); stmts.push(stmt); stmts.push(` From b2e3ebc2621820927029b6d9562c57c347ae906e Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 9 Jul 2020 11:21:06 +0200 Subject: [PATCH 4/4] cr changes --- modules/order/back/methods/order/filter.js | 1 - modules/order/front/summary/index.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 3821c31e4..bfa64c4dd 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -177,7 +177,6 @@ module.exports = Self => { }); } - // stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeWhere(filter.where)); stmt.merge({ sql: `GROUP BY o.id` diff --git a/modules/order/front/summary/index.js b/modules/order/front/summary/index.js index 5916aaf0b..1597e5e0a 100644 --- a/modules/order/front/summary/index.js +++ b/modules/order/front/summary/index.js @@ -23,7 +23,7 @@ class Controller extends Section { } save() { - this.$http.post(`Orders/${this.$params.id}/confirm`).then(() => { + this.$http.post(`Orders/${this.order.id}/confirm`).then(() => { this.vnApp.showSuccess(this.$t('Order confirmed')); this.$state.go(`ticket.index`, { q: JSON.stringify({clientFk: this.order.clientFk})