From e6790f6120be66b89c325b12f57a11099afe2260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Wed, 2 Sep 2020 10:06:25 +0200 Subject: [PATCH 1/7] #2406 - Sort by occurrences --- modules/order/front/catalog/index.html | 2 +- modules/order/front/catalog/index.js | 14 ++++++++------ modules/order/front/catalog/index.spec.js | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index a13274484..ecce520a6 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -63,7 +63,7 @@ ng-model="$ctrl.orderField" selection="$ctrl.orderSelection" translate-fields="['name']" - order="name" + order="priority DESC" show-field="name" value-field="field" label="Order by" diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index ddfe69cc9..d5d944607 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -14,10 +14,10 @@ class Controller extends Section { {way: 'DESC', name: 'Descendant'}, ]; this.defaultOrderFields = [ - {field: 'relevancy DESC, name', name: 'Relevancy'}, - {field: 'showOrder, price', name: 'Color and price'}, - {field: 'name', name: 'Name'}, - {field: 'price', name: 'Price'} + {field: 'relevancy DESC, name', name: 'Relevancy', priority: 999}, + {field: 'showOrder, price', name: 'Color and price', priority: 999}, + {field: 'name', name: 'Name', priority: 999}, + {field: 'price', name: 'Price', priority: 999} ]; this.orderFields = [].concat(this.defaultOrderFields); this._orderWay = this.orderWays[0].way; @@ -312,9 +312,11 @@ class Controller extends Section { tags.push({ name: itemTag.name, field: itemTag.tagFk, - isTag: true + isTag: true, + priority: 1 }); - } + } else + tags[alreadyAdded].priority += 1; }); }); let newFilterList = [].concat(this.defaultOrderFields); diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index eceb3eb66..4ef9cbeb9 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -45,7 +45,7 @@ describe('Order', () => { jest.spyOn(controller, 'buildTagsFilter'); jest.spyOn(controller, 'buildOrderFilter'); - const expectedResult = [{field: 'showOrder, price', name: 'Color and price'}]; + const expectedResult = [{field: 'showOrder, price', name: 'Color and price', priority: 999}]; const items = [{id: 1, name: 'My Item', tags: [ {tagFk: 4, name: 'Length'}, {tagFk: 5, name: 'Color'} From b848fa52f2cb4a8f3a0571ae5e8097e1eb2fb7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 3 Sep 2020 15:11:16 +0200 Subject: [PATCH 2/7] 2385 - Replaced worker nickname --- e2e/helpers/selectors.js | 2 +- modules/claim/back/methods/claim/filter.js | 2 +- modules/claim/front/card/index.js | 2 +- modules/claim/front/descriptor/index.html | 32 +++++++++++++++---- modules/claim/front/index/index.html | 2 +- modules/client/back/methods/client/summary.js | 2 +- modules/client/front/credit/index/index.html | 11 ++++++- modules/client/front/credit/index/index.js | 2 +- modules/client/front/descriptor/index.html | 13 ++++++-- modules/client/front/dms/index/index.html | 8 ++++- modules/client/front/dms/index/index.js | 2 +- modules/client/front/sample/index/index.html | 2 +- modules/client/front/sample/index/index.js | 2 +- modules/client/front/summary/index.html | 13 ++++++-- .../invoiceOut/front/descriptor/index.html | 13 ++++++-- modules/item/back/methods/item/filter.js | 2 +- modules/item/back/methods/item/getCard.js | 2 +- modules/item/back/methods/item/getSummary.js | 2 +- modules/item/front/descriptor/index.html | 11 +++++-- modules/item/front/index/index.html | 4 +-- modules/item/front/summary/index.html | 13 ++++++-- modules/order/front/card/index.js | 2 +- modules/order/front/descriptor/index.html | 13 ++++++-- modules/route/back/methods/route/filter.js | 3 +- .../back/methods/route/specs/summary.spec.js | 2 +- modules/route/back/methods/route/summary.js | 2 +- modules/route/front/index/index.html | 2 +- modules/route/front/summary/index.html | 11 +++++-- modules/ticket/back/methods/ticket/summary.js | 2 +- modules/ticket/front/card/index.js | 2 +- modules/ticket/front/descriptor/index.html | 13 ++++++-- modules/ticket/front/descriptor/index.js | 2 +- modules/ticket/front/dms/index/index.html | 11 +++++-- modules/ticket/front/dms/index/index.js | 2 +- modules/ticket/front/summary/index.html | 13 ++++++-- .../ticket/front/tracking/index/index.html | 2 +- modules/ticket/front/tracking/index/index.js | 2 +- modules/travel/front/descriptor/locale/es.yml | 4 +-- modules/worker/front/dms/index/index.html | 9 +++++- 39 files changed, 174 insertions(+), 65 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index fe93e8b41..a675b4167 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -199,7 +199,7 @@ export default { }, dms: { deleteFileButton: 'vn-client-dms-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]', - firstDocWorker: 'vn-client-dms-index vn-td:nth-child(7) > span', + firstDocWorker: 'vn-client-dms-index vn-td:nth-child(8) > span', firstDocWorkerDescriptor: '.vn-popover.shown vn-worker-descriptor' }, clientContacts: { diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 1caa120be..7ba89089a 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -106,7 +106,7 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL( - `SELECT cl.id, c.name, cl.clientFk, cl.workerFk, u.nickName, cs.description, cl.created + `SELECT cl.id, c.name, cl.clientFk, cl.workerFk, u.name AS userName, cs.description, cl.created FROM claim cl LEFT JOIN client c ON c.id = cl.clientFk LEFT JOIN worker w ON w.id = cl.workerFk diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js index 361b0e74f..747eea9e7 100644 --- a/modules/claim/front/card/index.js +++ b/modules/claim/front/card/index.js @@ -12,7 +12,7 @@ class Controller extends ModuleCard { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index 627537348..d6fb75ac5 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -32,20 +32,32 @@ value="{{$ctrl.claim.created | date: 'dd/MM/yyyy HH:mm'}}"> + label="Salesperson"> + + {{$ctrl.claim.client.salesPersonUser.name}} + + label="Attended by"> + + {{$ctrl.claim.worker.user.name}} + + label="Ticket"> + + {{$ctrl.claim.ticketFk}} +
@@ -89,4 +93,7 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/client/front/dms/index/index.html b/modules/client/front/dms/index/index.html index 3402074cc..f38e91134 100644 --- a/modules/client/front/dms/index/index.html +++ b/modules/client/front/dms/index/index.html @@ -53,6 +53,12 @@ {{::document.dms.description}} + + + + @@ -62,7 +68,7 @@ - {{::document.dms.worker.user.nickname | dashIfEmpty}} + {{::document.dms.worker.user.name | dashIfEmpty}} {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} diff --git a/modules/client/front/dms/index/index.js b/modules/client/front/dms/index/index.js index c65de39e4..a18f195bb 100644 --- a/modules/client/front/dms/index/index.js +++ b/modules/client/front/dms/index/index.js @@ -32,7 +32,7 @@ class Controller extends Section { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } }, } diff --git a/modules/client/front/sample/index/index.html b/modules/client/front/sample/index/index.html index bd7fc6e4a..7bb503fa2 100644 --- a/modules/client/front/sample/index/index.html +++ b/modules/client/front/sample/index/index.html @@ -32,7 +32,7 @@ - {{::sample.worker.user.nickname}} + {{::sample.worker.user.name}} {{::sample.company.code}} diff --git a/modules/client/front/sample/index/index.js b/modules/client/front/sample/index/index.js index e93c2d2dc..132704de0 100644 --- a/modules/client/front/sample/index/index.js +++ b/modules/client/front/sample/index/index.js @@ -18,7 +18,7 @@ class Controller extends Section { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html index 9e53d4988..ce69bf158 100644 --- a/modules/client/front/summary/index.html +++ b/modules/client/front/summary/index.html @@ -21,8 +21,12 @@ - + + + {{$ctrl.summary.salesPerson.user.name}} + @@ -197,4 +201,7 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/invoiceOut/front/descriptor/index.html b/modules/invoiceOut/front/descriptor/index.html index 093d9edf7..fe22e4dd8 100644 --- a/modules/invoiceOut/front/descriptor/index.html +++ b/modules/invoiceOut/front/descriptor/index.html @@ -37,8 +37,12 @@ value="{{$ctrl.invoiceOut.amount | currency: 'EUR': 2}}"> + label="Client"> + + {{$ctrl.invoiceOut.client.name}} + - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index a38a06713..1fefab77e 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -113,7 +113,7 @@ module.exports = Self => { i.isActive, t.name type, t.workerFk buyerFk, - u.nickname userNickname, + u.name userName, intr.description AS intrastat, i.stems, ori.code AS origin, diff --git a/modules/item/back/methods/item/getCard.js b/modules/item/back/methods/item/getCard.js index 9780c5601..69b5c1116 100644 --- a/modules/item/back/methods/item/getCard.js +++ b/modules/item/back/methods/item/getCard.js @@ -37,7 +37,7 @@ module.exports = Self => { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index fd52951d7..698984572 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -38,7 +38,7 @@ module.exports = Self => { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html index c872d2bf2..8363a652f 100644 --- a/modules/item/front/descriptor/index.html +++ b/modules/item/front/descriptor/index.html @@ -44,8 +44,12 @@
+ label="Buyer"> + + {{$ctrl.item.itemType.worker.user.name}} + + + \ No newline at end of file diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index eaef0f34f..01128ed74 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -70,11 +70,11 @@ {{::item.intrastat}} {{::item.origin}} - + - {{::item.userNickname}} + {{::item.userName}} {{::item.density}} diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index 938005828..bf9ab9445 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -36,8 +36,12 @@ - + + + {{$ctrl.summary.item.itemType.worker.user.name}} + @@ -105,4 +109,7 @@

- \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/order/front/card/index.js b/modules/order/front/card/index.js index d154b0b52..33012d0f6 100644 --- a/modules/order/front/card/index.js +++ b/modules/order/front/card/index.js @@ -37,7 +37,7 @@ class Controller extends ModuleCard { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/order/front/descriptor/index.html b/modules/order/front/descriptor/index.html index b16470bf2..e9f1684e5 100644 --- a/modules/order/front/descriptor/index.html +++ b/modules/order/front/descriptor/index.html @@ -15,8 +15,12 @@ value="{{$ctrl.$t($ctrl.order.isConfirmed ? 'Confirmed' : 'Not confirmed')}}">
+ label="Sales person"> + + {{$ctrl.order.client.salesPerson.user.name}} + - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index eeeef1dac..c96f856f0 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -119,7 +119,7 @@ module.exports = Self => { r.m3, r.description, am.name agencyName, - u.nickname AS workerNickname, + u.name AS workerUserName, v.numberPlate AS vehiclePlateNumber FROM route r LEFT JOIN agencyMode am ON am.id = r.agencyModeFk @@ -128,7 +128,6 @@ module.exports = Self => { LEFT JOIN account.user u ON u.id = w.userFk` ); - stmt.merge(conn.makeSuffix(filter)); let itemsIndex = stmts.push(stmt) - 1; diff --git a/modules/route/back/methods/route/specs/summary.spec.js b/modules/route/back/methods/route/specs/summary.spec.js index ba976ae94..a9516f7c5 100644 --- a/modules/route/back/methods/route/specs/summary.spec.js +++ b/modules/route/back/methods/route/specs/summary.spec.js @@ -25,7 +25,7 @@ describe('route summary()', () => { const result = await app.models.Route.summary(1); const worker = result.route.worker().user(); - expect(worker.nickname).toEqual('deliveryNick'); + expect(worker.name).toEqual('delivery'); }); it(`should return a summary object containing data from the tickets`, async() => { diff --git a/modules/route/back/methods/route/summary.js b/modules/route/back/methods/route/summary.js index 0a8710e88..52927d974 100644 --- a/modules/route/back/methods/route/summary.js +++ b/modules/route/back/methods/route/summary.js @@ -38,7 +38,7 @@ module.exports = Self => { { relation: 'user', scope: { - fields: ['id', 'nickname'] + fields: ['id', 'name'] } } ] diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html index 7258018f1..965c17409 100644 --- a/modules/route/front/index/index.html +++ b/modules/route/front/index/index.html @@ -38,7 +38,7 @@ - {{::route.workerNickname}} + {{::route.workerUserName}}
{{::route.agencyName | dashIfEmpty}} diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index b2c9255e0..4c45d3985 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -14,8 +14,12 @@ - + + + {{$ctrl.summary.route.worker.user.name}} + @@ -106,3 +110,6 @@ + + diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index 79a7c24d9..434cf5624 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -63,7 +63,7 @@ module.exports = Self => { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 5b3c3c405..34ec2be98 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -44,7 +44,7 @@ class Controller extends ModuleCard { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index 1ad27aac3..f5c4891c3 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -90,8 +90,12 @@ value="{{$ctrl.ticket.ticketState.state.name}}"> + label="Sales person"> + + {{$ctrl.ticket.client.salesPerson.user.name}} + - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index fdcd50e3c..b67474427 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -210,7 +210,7 @@ class Controller extends Descriptor { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/ticket/front/dms/index/index.html b/modules/ticket/front/dms/index/index.html index 80ddbf899..851276a6b 100644 --- a/modules/ticket/front/dms/index/index.html +++ b/modules/ticket/front/dms/index/index.html @@ -51,6 +51,12 @@ {{::document.dms.description}} + + + + @@ -60,8 +66,9 @@ - {{::document.dms.worker.user.nickname | dashIfEmpty}} - + {{::document.dms.worker.user.name | dashIfEmpty}} + + {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} diff --git a/modules/ticket/front/dms/index/index.js b/modules/ticket/front/dms/index/index.js index 2a67d6890..da6aa6b6f 100644 --- a/modules/ticket/front/dms/index/index.js +++ b/modules/ticket/front/dms/index/index.js @@ -33,7 +33,7 @@ class Controller extends Section { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } }, } diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 7b0e9d06d..ed269914c 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -18,8 +18,12 @@ - + + + {{$ctrl.summary.client.salesPerson.user.name}} + @@ -239,4 +243,7 @@ - \ No newline at end of file + + + diff --git a/modules/ticket/front/tracking/index/index.html b/modules/ticket/front/tracking/index/index.html index bf22bfb98..42d2197d0 100644 --- a/modules/ticket/front/tracking/index/index.html +++ b/modules/ticket/front/tracking/index/index.html @@ -25,7 +25,7 @@ - {{::tracking.worker.user.nickname | dashIfEmpty}} + {{::tracking.worker.user.name | dashIfEmpty}} {{::tracking.created | date:'dd/MM/yyyy HH:mm'}} diff --git a/modules/ticket/front/tracking/index/index.js b/modules/ticket/front/tracking/index/index.js index 5528fc1ad..38abcd8ab 100644 --- a/modules/ticket/front/tracking/index/index.js +++ b/modules/ticket/front/tracking/index/index.js @@ -13,7 +13,7 @@ class Controller extends Section { include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name'] } } } diff --git a/modules/travel/front/descriptor/locale/es.yml b/modules/travel/front/descriptor/locale/es.yml index 1f51a0132..0ae18fdbf 100644 --- a/modules/travel/front/descriptor/locale/es.yml +++ b/modules/travel/front/descriptor/locale/es.yml @@ -1,6 +1,6 @@ Reference: Referencia -Wh. In: Warehouse entrada -Wh. Out: Warehouse salida +Wh. In: Almacén entrada +Wh. Out: Almacén salida Shipped: F. envío Landed: F. entrega Total entries: Entradas totales \ No newline at end of file diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 4564dba44..d74d65bfa 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -18,6 +18,7 @@ Reference Description Original + File Created @@ -36,7 +37,13 @@ {{::document.description}} - + + + + + From ff5a942771761a411330e735f9ad208d500e71c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Mon, 7 Sep 2020 08:53:47 +0200 Subject: [PATCH 3/7] Updated unit test --- modules/worker/front/calendar/index.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js index ebf52dc66..cb42fb316 100644 --- a/modules/worker/front/calendar/index.spec.js +++ b/modules/worker/front/calendar/index.spec.js @@ -81,8 +81,8 @@ describe('Worker', () => { $httpBackend.whenRoute('GET', 'Calendars/absences') .respond({ holidays: [ - {dated: today, detail: {description: 'New year'}}, - {dated: tomorrow, detail: {description: 'Easter'}} + {dated: today, detail: {name: 'New year'}}, + {dated: tomorrow, detail: {name: 'Easter'}} ], absences: [ {dated: today, absenceType: {name: 'Holiday', rgb: '#aaa'}}, From 5ef9afdb5313a6922b044f6a061937b47aee5807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Tue, 8 Sep 2020 15:07:57 +0200 Subject: [PATCH 4/7] Empty url fix --- modules/item/back/methods/item-image-queue/downloadImages.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index 420b357a5..d953d1938 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -26,7 +26,9 @@ module.exports = Self => { await fs.mkdir(tempPath, {recursive: true}); const timer = setInterval(async() => { - const image = await Self.findOne({where: {error: null}}); + const image = await Self.findOne({ + where: {error: null, url: {neq: null}} + }); // Exit loop if (!image) return clearInterval(timer); From db081501eb0ae82b5bde6bbcf7a90512b4bcb39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Wed, 9 Sep 2020 08:14:17 +0200 Subject: [PATCH 5/7] 2440 - Ticket filter hotfix --- modules/ticket/back/methods/ticket/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 3a34be442..878b4278e 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -245,7 +245,7 @@ module.exports = Self => { SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped FROM tmp.filter f LEFT JOIN alertLevel al ON al.alertLevel = f.alertLevel - WHERE (f.alertLevelCode = 'FREE' OR f.alertLevel IS NULL) + WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) AND f.shipped >= CURDATE()`); stmts.push('CALL ticketGetProblems()'); From 957096172d55af465985226c78bfc8882bd97aaa Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 9 Sep 2020 11:39:18 +0200 Subject: [PATCH 6/7] entry summary buys listed --- modules/entry/back/methods/entry/getBuys.js | 74 +++++++++++++++ .../back/methods/entry/specs/getBuys.spec.js | 14 +++ modules/entry/back/models/buy.json | 12 +++ modules/entry/back/models/entry.js | 1 + modules/entry/front/summary/index.html | 93 ++++++++++++++++++- modules/entry/front/summary/index.js | 12 ++- modules/entry/front/summary/index.spec.js | 18 +++- modules/entry/front/summary/locale/es.yml | 7 +- modules/entry/front/summary/style.scss | 16 +++- 9 files changed, 240 insertions(+), 7 deletions(-) create mode 100644 modules/entry/back/methods/entry/getBuys.js create mode 100644 modules/entry/back/methods/entry/specs/getBuys.spec.js diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js new file mode 100644 index 000000000..1b05ec483 --- /dev/null +++ b/modules/entry/back/methods/entry/getBuys.js @@ -0,0 +1,74 @@ +module.exports = Self => { + Self.remoteMethod('getBuys', { + description: 'Returns buys for one entry', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + }, + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/:id/getBuys`, + verb: 'GET' + } + }); + + Self.getBuys = async id => { + let filter = { + where: {entryFk: id}, + fields: [ + 'id', + 'itemFk', + 'stickers', + 'packing', + 'grouping', + 'quantity', + 'packageFk', + 'weight', + 'buyingValue', + 'price2', + 'price3' + ], + include: { + relation: 'item', + scope: { + fields: [ + 'id', + 'typeFk', + 'name', + 'size', + 'minPrice', + 'tag5', + 'value5', + 'tag6', + 'value6', + 'tag7', + 'value7', + 'tag8', + 'value8', + 'tag9', + 'value9', + 'tag10', + 'value10', + 'groupingMode' + ], + include: { + relation: 'itemType', + scope: { + fields: ['code', 'description'] + } + } + } + } + }; + + let buys = await Self.app.models.Buy.find(filter); + return buys; + }; +}; diff --git a/modules/entry/back/methods/entry/specs/getBuys.spec.js b/modules/entry/back/methods/entry/specs/getBuys.spec.js new file mode 100644 index 000000000..b660ab2ad --- /dev/null +++ b/modules/entry/back/methods/entry/specs/getBuys.spec.js @@ -0,0 +1,14 @@ +const app = require('vn-loopback/server/server'); + +describe('entry getBuys()', () => { + const entryId = 4; + it('should get the buys and items of an entry', async() => { + const result = await app.models.Entry.getBuys(entryId); + + const length = result.length; + const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; + + expect(result.length).toEqual(4); + expect(anyResult.item).toBeDefined(); + }); +}); diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index 1f3f1b862..56f1eef4f 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -31,6 +31,12 @@ "grouping": { "type": "number" }, + "stickers": { + "type": "number" + }, + "packageFk": { + "type": "number" + }, "groupingMode": { "type": "number" }, @@ -56,6 +62,12 @@ "model": "Entry", "foreignKey": "entryFk", "required": true + }, + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk", + "required": true } } } \ No newline at end of file diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 713154d1b..94dbe787d 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/entry/filter')(Self); require('../methods/entry/getEntry')(Self); + require('../methods/entry/getBuys')(Self); }; diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index af9eae30c..9151558f2 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -19,8 +19,12 @@ - + + + {{$ctrl.entryData.travel.agency.name}} + @@ -65,4 +69,89 @@ + + +

Buys

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
QuantityStickersPackageWeightPackingGroupingBuying valueImportGrouping pricePacking price
{{::line.quantity}}{{::line.stickers | dashIfEmpty}}{{::line.packageFk | dashIfEmpty}}{{::line.weight}} + + {{::line.packing | dashIfEmpty}} + + + + {{::line.grouping | dashIfEmpty}} + + + {{::line.buyingValue | currency: 'EUR':2}}{{::line.quantity * line.buyingValue | currency: 'EUR':2}}{{::line.price2 | currency: 'EUR':2}}{{::line.price3 | currency: 'EUR':2}}
+ + {{::line.item.itemType.code}} + + + + {{::line.item.id | zeroFill:6}} + + + + {{::line.item.size}} + + + + {{::line.item.minPrice | currency: 'EUR':2}} + + + + +
+
+
+ + + + + diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js index f0b4c62b3..2a3dfe37b 100644 --- a/modules/entry/front/summary/index.js +++ b/modules/entry/front/summary/index.js @@ -10,15 +10,23 @@ class Controller extends Section { set entry(value) { this._entry = value; - if (value && value.id) + if (value && value.id) { this.getEntryData(); + this.getBuys(); + } } getEntryData() { - return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { + return this.$http.get(`Entries/${this.entry.id}/getEntry`).then(response => { this.entryData = response.data; }); } + + getBuys() { + return this.$http.get(`Entries/${this.entry.id}/getBuys`).then(response => { + this.buys = response.data; + }); + } } ngModule.vnComponent('vnEntrySummary', { diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js index a2d25d0d6..396e92b01 100644 --- a/modules/entry/front/summary/index.spec.js +++ b/modules/entry/front/summary/index.spec.js @@ -38,7 +38,7 @@ describe('component vnEntrySummary', () => { it('should perform a get and then store data on the controller', () => { controller._entry = {id: 999}; - const query = `/api/Entries/${controller._entry.id}/getEntry`; + const query = `Entries/${controller._entry.id}/getEntry`; $httpBackend.expectGET(query).respond('I am the entryData'); controller.getEntryData(); $httpBackend.flush(); @@ -46,4 +46,20 @@ describe('component vnEntrySummary', () => { expect(controller.entryData).toEqual('I am the entryData'); }); }); + + describe('getBuys()', () => { + it('should perform a get asking for the buys of an entry', () => { + controller._entry = {id: 999}; + + const thatQuery = `Entries/${controller._entry.id}/getEntry`; + const query = `Entries/${controller._entry.id}/getBuys`; + + $httpBackend.whenGET(thatQuery).respond('My Entries'); + $httpBackend.expectGET(query).respond('Some buys'); + controller.getBuys(); + $httpBackend.flush(); + + expect(controller.buys).toEqual('Some buys'); + }); + }); }); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml index 1673d6a17..6f442b2c8 100644 --- a/modules/entry/front/summary/locale/es.yml +++ b/modules/entry/front/summary/locale/es.yml @@ -1,3 +1,8 @@ Inventory: Inventario Virtual: Redada -Entry: Entrada \ No newline at end of file +Entry: Entrada +Stickers: Etiquetas +Item size: Tamaño +Item type: Tipo +Minimum price: Precio mínimo +Buys: Compras diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss index 1374d2ec7..27d361056 100644 --- a/modules/entry/front/summary/style.scss +++ b/modules/entry/front/summary/style.scss @@ -3,4 +3,18 @@ vn-entry-summary .summary { max-width: $width-lg; -} \ No newline at end of file + + .dark-row { + background-color: lighten($color-marginal, 10%); + } + + tbody { + border: 2px solid $color-marginal; + } + + tr { + margin-bottom: 10px; + } +} + +$color-font-link-medium: lighten($color-font-link, 20%) \ No newline at end of file From f570a07c7ce66d2e10cd6e0b29d92a07363603ac Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 9 Sep 2020 13:07:06 +0200 Subject: [PATCH 7/7] entry.summary e2e buys being listed --- e2e/helpers/selectors.js | 1 + e2e/paths/12-entry/01_summary.spec.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 33eecc627..64da72607 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -894,6 +894,7 @@ export default { header: 'vn-entry-summary > vn-card > h5', reference: 'vn-entry-summary vn-label-value[label="Reference"]', confirmed: 'vn-entry-summary vn-check[label="Confirmed"]', + anyBuyLine: 'vn-entry-summary tr.dark-row' }, entryDescriptor: { agency: 'vn-entry-descriptor div.body vn-label-value:nth-child(1) span', diff --git a/e2e/paths/12-entry/01_summary.spec.js b/e2e/paths/12-entry/01_summary.spec.js index e57654f94..a6ac8dab1 100644 --- a/e2e/paths/12-entry/01_summary.spec.js +++ b/e2e/paths/12-entry/01_summary.spec.js @@ -9,7 +9,7 @@ describe('Entry summary path', () => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('buyer', 'entry'); - await page.waitToClick('vn-entry-index vn-tbody > a:nth-child(2)'); + await page.accessToSearchResult('4'); }); afterAll(async() => { @@ -30,7 +30,7 @@ describe('Entry summary path', () => { it('should display some entry details like the reference', async() => { const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText'); - expect(result).toContain('Movement 2'); + expect(result).toContain('Movement 4'); }); it('should display other entry details like the confirmed', async() => { @@ -38,4 +38,10 @@ describe('Entry summary path', () => { expect(result).toContain('unchecked'); }); + + it('should display all buys for the entry', async() => { + const result = await page.countElement(selectors.entrySummary.anyBuyLine); + + expect(result).toEqual(4); + }); });