From 1e90b5ae004a72f8c63679d6eec89592ead0a7bf Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 11 Apr 2019 12:44:43 +0200 Subject: [PATCH 01/10] =?UTF-8?q?a=C3=B1ade=20opcion=20mana=20con=20permis?= =?UTF-8?q?os?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/claim/back/methods/claim/updateClaim.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index d177ac050..66b409d09 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -41,7 +41,7 @@ module.exports = Self => { let notModifiable = ['id', 'responsibility', 'isChargedToMana']; let changedFields = diff(oldClaim, params); let changedFieldsPicked = pick(changedFields, notModifiable); - let statesViables = ['Gestionado', 'Pendiente', 'Anulado']; + let statesViables = ['Gestionado', 'Pendiente', 'Anulado', 'Mana']; let oldState = await models.ClaimState.findOne({where: {id: oldClaim.claimStateFk}}); let newState = await models.ClaimState.findOne({where: {id: params.claimStateFk}}); let canChangeState = statesViables.includes(oldState.description) From 2c5dd324eae6aa19f30e9228947110e3320d304f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 16 Apr 2019 12:11:06 +0200 Subject: [PATCH 02/10] fixed catalog price popover --- modules/order/front/prices-popover/index.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/order/front/prices-popover/index.html b/modules/order/front/prices-popover/index.html index 82df68707..def04cb16 100644 --- a/modules/order/front/prices-popover/index.html +++ b/modules/order/front/prices-popover/index.html @@ -48,11 +48,10 @@ x {{::price.price | currency: 'EUR': 2}} - From d2006e60bbee6af637c5073342a45964a49cf3d6 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 24 Apr 2019 09:21:24 +0200 Subject: [PATCH 03/10] fixed catalog filter bugs #1352 --- modules/order/front/catalog/index.html | 6 ++++-- modules/order/front/catalog/index.js | 6 ++---- modules/order/front/filter/index.js | 8 ++++---- modules/order/front/filter/index.spec.js | 2 ++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index 1d834a66c..5ec0aeac0 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -23,7 +23,8 @@ order="name" show-field="name" value-field="field" - label="Order by"> + label="Order by" + disabled="!model.data"> + label="Order" + disabled="!model.data"> diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index bc9bd20d5..a21d9dc18 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -74,8 +74,7 @@ class Controller { set way(value) { this._way = value; - if (value) - this.applyOrder(); + if (value) this.applyOrder(); } /** @@ -88,8 +87,7 @@ class Controller { set field(value) { this._field = value; - if (value) - this.applyOrder(); + if (value) this.applyOrder(); } /** diff --git a/modules/order/front/filter/index.js b/modules/order/front/filter/index.js index 26495b025..3a738ee5b 100644 --- a/modules/order/front/filter/index.js +++ b/modules/order/front/filter/index.js @@ -64,7 +64,7 @@ class Controller { if (this.tags.length > 0) this.applyFilters(); - if (value) + if (this._category) this.updateItemTypes(); } @@ -97,8 +97,8 @@ class Controller { } onSearchById(event) { - if (event.key !== 'Enter' || !this.itemFk) return; - this.applyFilters(); + if (event.key === 'Enter' && (this.tags.length > 0 || this.itemFk || this.type)) + this.applyFilters(); } onSearchByTag(event) { @@ -113,7 +113,7 @@ class Controller { remove(index) { this.tags.splice(index, 1); - if (this.tags.length == 0 && this.category && this.type) + if (this.tags.length >= 0 || this.itemFk || this.type) this.applyFilters(); } diff --git a/modules/order/front/filter/index.spec.js b/modules/order/front/filter/index.spec.js index 88075e820..6c9ecee34 100644 --- a/modules/order/front/filter/index.spec.js +++ b/modules/order/front/filter/index.spec.js @@ -137,11 +137,13 @@ describe('Order', () => { describe('remove()', () => { it(`should remove a tag from tags property`, () => { + spyOn(controller, 'applyFilters'); controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}]; controller.remove(0); expect(controller.tags.length).toEqual(1); expect(controller.tags[0].tagFk).toEqual(2); + expect(controller.applyFilters).toHaveBeenCalledWith(); }); it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => { From 2186f8409e28f91170ee9775fb183c5ccdfb8a04 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 24 Apr 2019 09:54:25 +0200 Subject: [PATCH 04/10] fixed available/visible icon on ticket sales #1363 --- modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/summary/index.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 479ac8f09..6107287c9 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -85,7 +85,7 @@ diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 1cb9713d5..98e6cdc5c 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -63,8 +63,8 @@ - Item - Quantity + Item + Quantity Description Price Discount @@ -89,14 +89,14 @@ - + {{sale.itemFk | zeroFill:6}} - {{::sale.quantity}} + {{::sale.quantity}} Date: Wed, 24 Apr 2019 11:02:31 +0200 Subject: [PATCH 05/10] #1364 bug create ticket --- loopback/locale/es.json | 1 - modules/ticket/back/methods/ticket/new.js | 7 ------- 2 files changed, 8 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d4f3733b0..54ead9ee8 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -67,7 +67,6 @@ "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", "ORDER_EMPTY": "Cesta vacía", "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", - "You can't create a ticket for a client that has a debt": "No puedes crear un ticket para un client con deuda", "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", "Street cannot be empty": "Dirección no puede estar en blanco", diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index db25fe715..7522fbbcc 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -49,13 +49,6 @@ module.exports = Self => { if (!address.client().isActive) throw new UserError(`You can't create a ticket for a inactive client`); - - let clientFk = address.clientFk; - let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`; - let clientDebt = await Self.rawSql(query, [clientFk]); - - if (address.client().credit - clientDebt[0].debt <= 0) - throw new UserError(`You can't create a ticket for a client that has a debt`); } if (!params.shipped && params.landed) { From bd605a5d9d7d070a2fb6decf0c43f9fa1e602775 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 24 Apr 2019 11:23:24 +0200 Subject: [PATCH 06/10] update ticket line discount until invoiced #1365 --- modules/ticket/back/methods/sale/updateDiscount.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/sale/updateDiscount.js b/modules/ticket/back/methods/sale/updateDiscount.js index e1793241b..18ad5eb33 100644 --- a/modules/ticket/back/methods/sale/updateDiscount.js +++ b/modules/ticket/back/methods/sale/updateDiscount.js @@ -26,7 +26,6 @@ module.exports = Self => { throw new UserError(`The value should be a number`); let model = Self.app.models; - let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk); let ticket = await model.Ticket.find({ where: { id: params.editLines[0].ticketFk @@ -40,13 +39,9 @@ module.exports = Self => { fields: ['id', 'clientFk', 'refFk'] }); - let userId = ctx.req.accessToken.userId; - let isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); - - if ((!thisTicketIsEditable && !isSalesAssistant) || (ticket.refFk && isSalesAssistant)) + if (ticket.refFk) throw new UserError(`The sales of this ticket can't be modified`); - let componentToUse; let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'}); From 7b59164fed01ec830052990279c40e962c81c75d Mon Sep 17 00:00:00 2001 From: Bernat Date: Wed, 24 Apr 2019 11:36:13 +0200 Subject: [PATCH 07/10] negative package quantity --- .../04_create_ticket_packages.spec.js | 18 ++++-------------- modules/ticket/front/package/index.html | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js index 6576893a9..2578388de 100644 --- a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js +++ b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js @@ -41,20 +41,10 @@ describe('Ticket Create packages path', () => { expect(result).toEqual('Some fields are invalid'); }); - it(`should attempt create a new package but receive an error if package is blank`, async() => { - const result = await nightmare - .clearInput(selectors.ticketPackages.firstQuantityInput) - .write(selectors.ticketPackages.firstQuantityInput, 99) - .waitToClick(selectors.ticketPackages.clearPackageAutocompleteButton) - .waitToClick(selectors.ticketPackages.savePackagesButton) - .waitForLastSnackbar(); - - expect(result).toEqual('Package cannot be blank'); - }); - it(`should create a new package with correct data`, async() => { const result = await nightmare - .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Legendary Box') + .clearInput(selectors.ticketPackages.firstQuantityInput) + .write(selectors.ticketPackages.firstQuantityInput, -99) .waitToClick(selectors.ticketPackages.savePackagesButton) .waitForLastSnackbar(); @@ -72,9 +62,9 @@ describe('Ticket Create packages path', () => { it(`should confirm the first quantity is the expected one`, async() => { const result = await nightmare - .waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99') + .waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '-99') .waitToGetProperty(selectors.ticketPackages.firstQuantityInput, 'value'); - expect(result).toEqual('99'); + expect(result).toEqual('-99'); }); }); diff --git a/modules/ticket/front/package/index.html b/modules/ticket/front/package/index.html index 5fbfffcf5..7478bac5d 100644 --- a/modules/ticket/front/package/index.html +++ b/modules/ticket/front/package/index.html @@ -25,7 +25,7 @@ field="package.packagingFk"> {{itemFk}} : {{name}} - From be9f2f66947983f2ef634a6fc7c4616bb0614c6c Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 25 Apr 2019 13:32:14 +0200 Subject: [PATCH 08/10] fix send notification to salesPerson #1382 --- .../back/methods/claim/regularizeClaim.js | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index 8a897ba5c..8ae47a3fa 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -70,14 +70,16 @@ module.exports = Self => { discount: 100 }, {transaction: transaction}); - await sendMessage(ctx, { - itemFk: sale.itemFk, - ticketFk: sale.ticketFk, - recipientFk: sale.item().itemType().worker().userFk, - quantity: sale.quantity, - concept: sale.concept, - nickname: address.nickname - }, transaction); + if (sale.ticket().client().salesPerson()) { + await sendMessage(ctx, { + itemFk: sale.itemFk, + ticketFk: sale.ticketFk, + recipientFk: sale.ticket().client().salesPerson().userFk, + quantity: sale.quantity, + concept: sale.concept, + nickname: address.nickname + }, transaction); + } } let claim = await Self.findById(params.claimFk); @@ -99,23 +101,14 @@ module.exports = Self => { include: [ { relation: 'ticket', - scope: {fields: ['warehouseFk', 'companyFk']} - }, - { - relation: 'item', scope: { - fields: ['typeFk'], + fields: ['clientFk', 'warehouseFk', 'companyFk'], include: { - relation: 'itemType', + relation: 'client', scope: { - fields: ['workerFk'], include: { - relation: 'worker', - scope: { - fields: ['id', 'userFk'], - } + relation: 'salesPerson' } - } } } From 0a37922b9401efba11f10e3fea0033752e689732 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 25 Apr 2019 13:22:49 +0200 Subject: [PATCH 09/10] Nginx now logs original proxy src/dst hosts --- front/nginx.conf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/front/nginx.conf b/front/nginx.conf index d6205af1e..84daf2ef2 100644 --- a/front/nginx.conf +++ b/front/nginx.conf @@ -1,4 +1,12 @@ +set_real_ip_from 0.0.0.0/0; +real_ip_header X-Forwarded-For; +log_format upstreamlog + '[$time_local] $remote_addr -> $proxy_host:$upstream_addr ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent"'; +access_log /var/log/nginx/access.log upstreamlog; + upstream back { server back_1:3000; server back_2:3000; From 94566b7ef47f429a32c6f2c6267d670ab11f8270 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 30 Apr 2019 11:43:26 +0200 Subject: [PATCH 10/10] fixed worker calendar error for local holidays --- modules/worker/front/calendar/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index c97e1b138..88433e59e 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -42,10 +42,14 @@ class Controller { const holidays = data.holidays; const events = []; holidays.forEach(holiday => { + const holidayDetail = holiday.detail && holiday.detail.description; + const holidayType = holiday.type && holiday.type.name; + const holidayName = holidayDetail || holidayType; + events.push({ date: holiday.dated, className: 'red', - title: holiday.detail.description || holiday.type.name, + title: holidayName, isRemovable: false }); });