From 4e329a42013341e042924f3715ec3912f4917741 Mon Sep 17 00:00:00 2001 From: Bernat Date: Wed, 31 Jul 2019 07:46:24 +0200 Subject: [PATCH 01/22] Bug/Test #1607 ticket.updateDiscount and fix test --- db/dump/fixtures.sql | 3 ++- e2e/paths/03-worker-module/02_time_control.spec.js | 1 + modules/ticket/back/methods/ticket-request/confirm.js | 2 +- .../ticket/back/methods/ticket-request/specs/confirm.spec.js | 4 ++-- .../ticket/back/methods/ticket-request/specs/filter.spec.js | 2 +- modules/ticket/back/methods/ticket/getSales.js | 1 - modules/ticket/front/sale/index.html | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 3fecb432e..821df10d5 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1446,7 +1446,8 @@ INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `atenderFk` (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, 4, 3.06, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()); + (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()), + (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, CURDATE()); INSERT INTO `vn`.`ticketServiceType`(`id`, `name`) VALUES diff --git a/e2e/paths/03-worker-module/02_time_control.spec.js b/e2e/paths/03-worker-module/02_time_control.spec.js index 89273d26c..b6d6d1754 100644 --- a/e2e/paths/03-worker-module/02_time_control.spec.js +++ b/e2e/paths/03-worker-module/02_time_control.spec.js @@ -381,6 +381,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym doesn't have hours set on the next months first week`, async() => { const wholeWeekHours = await nightmare + .waitToClick(selectors.workerTimeControl.nextMonthButton) .waitToClick(selectors.workerTimeControl.nextMonthButton) .waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText'); diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 02d1a33c5..92dd06dae 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -53,7 +53,7 @@ module.exports = Self => { false ]); - if (stock.available < ctx.args.quantity) + if (stock.available < 0) throw new UserError(`This item is not available`); diff --git a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js index cab7e8b8b..574469d86 100644 --- a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js @@ -39,8 +39,8 @@ describe('ticket-request confirm()', () => { }); it(`should throw an error if the item is not available`, async() => { - const requestId = 4; - const itemId = 1; + const requestId = 5; + const itemId = 4; const quantity = 99999; let ctx = {req: {accessToken: {userId: 9}}, args: { diff --git a/modules/ticket/back/methods/ticket-request/specs/filter.spec.js b/modules/ticket/back/methods/ticket-request/specs/filter.spec.js index ae73eb1da..24e74e4df 100644 --- a/modules/ticket/back/methods/ticket-request/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/filter.spec.js @@ -6,7 +6,7 @@ describe('ticket-request filter()', () => { let result = await app.models.TicketRequest.filter(ctx); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); }); it('should return the ticket request matching a generic search value which is the ticket ID', async() => { diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index 0c33d9db9..b59d678f2 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -54,7 +54,6 @@ module.exports = Self => { line.item = map[line.itemFk]; line.claim = claimMap[line.id]; } - return lines; }; }; diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index f1266bede..993b81003 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -86,7 +86,7 @@ From e011c120db6deb4364b08ad3e91fa25130c18cac Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 6 Aug 2019 07:36:26 +0200 Subject: [PATCH 02/22] ticket.sale split show active tickets --- modules/ticket/back/methods/ticket/threeLastActive.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/threeLastActive.js b/modules/ticket/back/methods/ticket/threeLastActive.js index fa4eab99d..839fcc465 100644 --- a/modules/ticket/back/methods/ticket/threeLastActive.js +++ b/modules/ticket/back/methods/ticket/threeLastActive.js @@ -25,9 +25,10 @@ module.exports = Self => { JOIN vn.ticketState ts ON t.id = ts.ticketFk JOIN vn.agencyMode a ON t.agencyModeFk = a.id JOIN vn.warehouse w ON t.warehouseFk = w.id - WHERE t.shipped > CURDATE() AND t.clientFk = ? AND ts.alertLevel = 0 AND t.id <> ? + WHERE t.shipped >= CURDATE() AND t.clientFk = ? + AND ts.alertLevel = 0 AND t.id <> ? ORDER BY t.shipped - LIMIT 3`; + LIMIT 5`; let tickets = await Self.rawSql(query, [params.clientFk, params.ticketFk]); return tickets; }; From 72a02112b53174871bebeb3b55f6df3694340553 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 6 Aug 2019 12:07:48 +0200 Subject: [PATCH 03/22] fixed fiscal data postcode selection --- e2e/paths/02-client-module/03_edit_fiscal_data.spec.js | 3 ++- modules/client/front/fiscal-data/index.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js index 9ae1f6ae4..f94b6cf3c 100644 --- a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js @@ -67,6 +67,7 @@ describe('Client Edit fiscalData path', () => { .write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!') .clearInput(selectors.clientFiscalData.addressInput) .write(selectors.clientFiscalData.addressInput, 'Somewhere edited') + .autocompleteSearch(selectors.clientFiscalData.cityAutocomplete, 'Valencia') .autocompleteSearch(selectors.clientFiscalData.postcodeAutocomplete, '46000') .waitToClick(selectors.clientFiscalData.activeCheckbox) .waitToClick(selectors.clientFiscalData.frozenCheckbox) @@ -80,7 +81,7 @@ describe('Client Edit fiscalData path', () => { .waitForLastSnackbar(); expect(result).toEqual('Invalid Tax number'); - }, 15000); + }); it(`should edit the fiscal this time with a valid fiscal id`, async() => { const result = await nightmare diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index d44b3db66..dac6d7db9 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -70,8 +70,8 @@ export default class Controller { const town = selection.town; const province = town.province; - this.address.city = town.name; - this.address.provinceFk = province.id; + this.client.city = town.name; + this.client.provinceFk = province.id; } } Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; From 96d438fb9939280166ea0c53ba8960905601935c Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 6 Aug 2019 07:41:54 +0200 Subject: [PATCH 04/22] updated allowed mimeTypes --- loopback/server/datasources.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 6f6ef8648..a8cf8e765 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -22,9 +22,14 @@ "root": "./e2e/dms", "maxFileSize": "10485760", "allowedContentTypes": [ + "application/x-7z-compressed", + "application/x-zip-compressed", + "application/x-rar-compressed", + "application/octet-stream", "application/pdf", "application/zip", "application/rar", + "multipart/x-zip", "image/png", "image/jpeg", "image/jpg" From a1e3ea7ad7693fe3c1f2053ba734cd060550ad62 Mon Sep 17 00:00:00 2001 From: Bernat Date: Thu, 22 Aug 2019 13:15:07 +0200 Subject: [PATCH 05/22] Tarea #1650 rpt-claim-pickup-order --- print/report/rpt-claim-pickup-order/locale.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/report/rpt-claim-pickup-order/locale.js b/print/report/rpt-claim-pickup-order/locale.js index 27b1bc5f4..e257b712a 100644 --- a/print/report/rpt-claim-pickup-order/locale.js +++ b/print/report/rpt-claim-pickup-order/locale.js @@ -15,7 +15,7 @@ module.exports = { sections: { agency: { description: `Para agilizar tu recogida, por favor, pónte en contacto con la oficina de integrados.
- Tlf: 96 166 77 88 - Ana Gómez (Ext. 113) (agomezf@integra2.es) ` + Tlf: 96 166 77 88 - Ana Gómez (Ext. 2113) (agomezf@integra2.es) ` } } }, From 8726aa70c5b25a427f96683b04e1ddfe53b90ccf Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 2 Sep 2019 09:11:40 +0200 Subject: [PATCH 06/22] removed autocompletion on change postal code #1638 --- modules/client/front/address/edit/index.html | 6 ----- modules/client/front/address/edit/index.js | 17 ------------ .../client/front/address/edit/index.spec.js | 26 ------------------- modules/client/front/fiscal-data/index.html | 8 ++---- modules/client/front/fiscal-data/index.js | 18 +------------ 5 files changed, 3 insertions(+), 72 deletions(-) diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index c2dce8f37..8c604d323 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -61,17 +61,11 @@ fields="['code', 'townFk']" field="$ctrl.address.postalCode" where="{townFk: town.selection.id}" - selection="$ctrl.postcodeSelection" search-function="{code: $search}" - fetch-function="{townFk: town.selection.id}" order="code, townFk" show-field="code" value-field="code" label="Postcode"> - - {{code}}, {{town.name}} - {{town.province.name}} - ({{town.province.country.country}}) - { expect(controller.$state.go).toHaveBeenCalledWith('client.card.address.index'); }); }); - - describe('postcodeSelection() setter', () => { - it(`should set the town, province and contry properties`, () => { - controller.address = {}; - controller._postcodeSelection = {townFk: 2}; - controller.postcodeSelection = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.address.city).toEqual('New York'); - expect(controller.address.provinceFk).toEqual(1); - }); - }); }); }); diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 67d7705ce..061ee92f1 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -58,16 +58,12 @@ url="/api/Postcodes/location" fields="['code', 'townFk']" field="$ctrl.client.postcode" - selection="$ctrl.postcodeSelection" search-function="{code: $search}" where="{townFk: town.selection.id}" + order="code, townFk" show-field="code" value-field="code" - label="Postcode"> - - {{code}}, {{town.name}} - {{town.province.name}} - ({{town.province.country.country}}) - + label="Postcode"> diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index dac6d7db9..a794d93ac 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -56,24 +56,8 @@ export default class Controller { ); } } - - get postcodeSelection() { - return this._postcodeSelection; - } - - set postcodeSelection(selection) { - const hasValue = this._postcodeSelection; - this._postcodeSelection = selection; - - if (!selection || !hasValue) return; - - const town = selection.town; - const province = town.province; - - this.client.city = town.name; - this.client.provinceFk = province.id; - } } + Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; ngModule.component('vnClientFiscalData', { From 7b40fe29421e536faa7effc3456f8671490f8792 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 2 Sep 2019 14:36:54 +0200 Subject: [PATCH 07/22] ticket.basicData Update zone on changes + fixes #1668 --- .../back/methods/ticket/priceDifference.js | 12 +-- .../front/basic-data/step-one/index.html | 3 +- .../ticket/front/basic-data/step-one/index.js | 87 ++++++++++++++----- .../ticket/front/basic-data/step-two/index.js | 7 +- 4 files changed, 78 insertions(+), 31 deletions(-) diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 552c2b991..122d20e50 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -94,14 +94,16 @@ module.exports = Self => { salesObj.items.forEach(sale => { const difComponent = map.get(sale.id); - if (difComponent) + if (difComponent) { sale.component = difComponent; + salesObj.totalNewPrice += sale.component.newPrice; + salesObj.totalDifference += sale.component.difference; + salesObj.totalUnitPrice = Math.round(salesObj.totalUnitPrice * 100) / 100; + salesObj.totalNewPrice = Math.round(salesObj.totalNewPrice * 100) / 100; + } + salesObj.totalUnitPrice += sale.price; - salesObj.totalNewPrice += sale.component.newPrice; - salesObj.totalDifference += sale.component.difference; - salesObj.totalUnitPrice = Math.round(salesObj.totalUnitPrice * 100) / 100; - salesObj.totalNewPrice = Math.round(salesObj.totalNewPrice * 100) / 100; salesObj.totalDifference = Math.round(salesObj.totalDifference * 100) / 100; }); diff --git a/modules/ticket/front/basic-data/step-one/index.html b/modules/ticket/front/basic-data/step-one/index.html index d3f2807b9..4a636f49a 100644 --- a/modules/ticket/front/basic-data/step-one/index.html +++ b/modules/ticket/front/basic-data/step-one/index.html @@ -36,8 +36,7 @@ label="Warehouse" show-field="name" value-field="id" - field="$ctrl.ticket.warehouseFk" - initial-data="$ctrl.ticket.warehouseFk"> + field="$ctrl.warehouseId"> diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index be8e380e5..afe4d4c75 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -39,11 +39,21 @@ class Controller { this.onChangeClient(value); } - set shipped(value) { - this.ticket.shipped = value; - this.onChangeShipped(value); + get warehouseId() { + if (this.ticket) + return this.ticket.warehouseFk; + + return null; } + set warehouseId(id) { + if (id != this.ticket.warehouseFk) { + this.ticket.warehouseFk = id; + this.onChangeWarehouse(id); + } + } + + get shipped() { if (this.ticket) return this.ticket.shipped; @@ -51,6 +61,11 @@ class Controller { return null; } + set shipped(value) { + this.ticket.shipped = value; + this.onChangeShipped(value); + } + get landed() { if (this.ticket) return this.ticket.landed; @@ -120,23 +135,6 @@ class Controller { }); } - /* - * Returns a landing date - */ - getLanded(params) { - let query = `/api/Agencies/getLanded`; - return this.$http.get(query, {params}); - } - - /* - * Returns a shipment date - */ - getShipped(params) { - let query = `/api/Agencies/getShipped`; - return this.$http.get(query, {params}); - } - - onChangeShipped(shipped) { let params = { shipped: shipped, @@ -144,6 +142,8 @@ class Controller { agencyModeFk: this.ticket.agencyModeFk, warehouseFk: this.ticket.warehouseFk }; + this.ticket.zoneFk = null; + let query = `/api/Agencies/getLanded`; this.$http.get(query, {params}).then(res => { if (res.data && res.data.landed) { @@ -164,6 +164,8 @@ class Controller { agencyModeFk: this.ticket.agencyModeFk, warehouseFk: this.ticket.warehouseFk }; + this.ticket.zoneFk = null; + let query = `/api/Agencies/getShipped`; this.$http.get(query, {params}).then(res => { if (res.data) { @@ -183,8 +185,10 @@ class Controller { onChangeZone(zoneId) { const query = `/api/Zones/${zoneId}`; this.$http.get(query).then(res => { - if (res.data) + if (res.data) { this.ticket.agencyModeFk = res.data.agencyModeFk; + this.ticket.warehouseFk = res.data.warehouseFk; + } }); } @@ -212,6 +216,31 @@ class Controller { }); } + /* + * Gets a zone from an agency + */ + onChangeWarehouse(warehouseId) { + let params = { + landed: this.ticket.landed, + addressFk: this.ticket.addressFk, + agencyModeFk: this.ticket.agencyModeFk, + warehouseFk: warehouseId + }; + + this.ticket.zoneFk = null; + let query = `/api/Agencies/getShipped`; + this.$http.get(query, {params}).then(res => { + if (res.data) + this.ticket.zoneFk = res.data.id; + + if (!res.data) { + this.vnApp.showMessage( + this.$translate.instant('No delivery zone available for this parameters') + ); + } + }); + } + async onStepChange() { if (this.isFormInvalid()) { return this.vnApp.showError( @@ -240,6 +269,22 @@ class Controller { }); } + /* + * Returns a landing date + */ + getLanded(params) { + let query = `/api/Agencies/getLanded`; + return this.$http.get(query, {params}); + } + + /* + * Returns a shipment date + */ + getShipped(params) { + let query = `/api/Agencies/getShipped`; + return this.$http.get(query, {params}); + } + isFormInvalid() { return !this.ticket.clientFk || !this.ticket.addressFk || !this.ticket.agencyModeFk || !this.ticket.companyFk || !this.ticket.shipped || !this.ticket.landed diff --git a/modules/ticket/front/basic-data/step-two/index.js b/modules/ticket/front/basic-data/step-two/index.js index 1d18f6ba0..1446ac171 100644 --- a/modules/ticket/front/basic-data/step-two/index.js +++ b/modules/ticket/front/basic-data/step-two/index.js @@ -28,8 +28,8 @@ class Controller { getTotalNewPrice() { let totalNewPrice = 0; this.ticket.sale.items.forEach(item => { - let itemTotalNewPrice = item.quantity * item.component.newPrice; - totalNewPrice += itemTotalNewPrice; + if (item.component) + totalNewPrice += item.quantity * item.component.newPrice; }); this.totalNewPrice = totalNewPrice; } @@ -37,7 +37,8 @@ class Controller { getTotalDifferenceOfPrice() { let totalPriceDifference = 0; this.ticket.sale.items.forEach(item => { - totalPriceDifference += item.component.difference; + if (item.component) + totalPriceDifference += item.component.difference; }); this.totalPriceDifference = totalPriceDifference; } From 81072ce7e813dab5ced2c3e7de8c1dd7f2630544 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Sep 2019 13:39:01 +0200 Subject: [PATCH 08/22] fixed claim refund --- .../importToNewRefundTicket.js | 20 ++++++++++++++----- .../importToNewRefundTicket.spec.js | 7 +------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js index 45a9ec0d6..c2ab2001e 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js @@ -30,7 +30,13 @@ module.exports = Self => { { relation: 'ticket', scope: { - fields: ['id', 'clientFk', 'warehouseFk', 'companyFk', 'addressFk'] + fields: ['id', 'clientFk', 'warehouseFk', 'companyFk', 'addressFk'], + include: { + relation: 'address', + scope: { + fields: ['nickname'] + } + } } } ] @@ -67,7 +73,7 @@ module.exports = Self => { where: {description: 'comercial'} }, options); - const agency = await models.AgencyMode.findOne({ + const agencyMode = await models.AgencyMode.findOne({ where: {code: 'refund'} }, options); @@ -75,19 +81,23 @@ module.exports = Self => { where: {code: 'DELIVERED'} }, options); + const zone = await models.Zone.findOne({ + where: {agencyModeFk: agencyMode.id} + }, options); const claim = await models.Claim.findOne(filter, options); const today = new Date(); - const newRefundTicket = await models.Ticket.new(ctx, { + const newRefundTicket = await models.Ticket.create({ clientFk: claim.ticket().clientFk, shipped: today, landed: today, + nickname: claim.ticket().address().nickname, warehouseFk: claim.ticket().warehouseFk, companyFk: claim.ticket().companyFk, addressFk: claim.ticket().addressFk, - agencyModeFk: agency.id, - userId: userId + agencyModeFk: agencyMode.id, + zoneFk: zone.id }, options); await saveObservation({ diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js index 15d5be4dc..5fecf8bcd 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js @@ -2,7 +2,6 @@ const app = require('vn-loopback/server/server'); describe('claimBeginning', () => { let ticket; - let refundTicketObservations; let refundTicketSales; let salesInsertedInClaimEnd; @@ -16,7 +15,7 @@ describe('claimBeginning', () => { }); describe('importToNewRefundTicket()', () => { - it('should create a new ticket with negative sales, save an observation, update the state and insert the negative sales into claimEnd', async() => { + it('should create a new ticket with negative sales and insert the negative sales into claimEnd', async() => { let ctxOfSalesAssistant = {req: {accessToken: {userId: 21}}}; let claimId = 1; ticket = await app.models.ClaimBeginning.importToNewRefundTicket(ctxOfSalesAssistant, claimId); @@ -24,14 +23,10 @@ describe('claimBeginning', () => { await app.models.Ticket.findById(ticket.id); refundTicketSales = await app.models.Sale.find({where: {ticketFk: ticket.id}}); - refundTicketObservations = await app.models.TicketObservation.find({where: {ticketFk: ticket.id}}); - let refundTicketState = await app.models.TicketState.findById(ticket.id); salesInsertedInClaimEnd = await app.models.ClaimEnd.find({where: {claimFk: claimId}}); expect(refundTicketSales.length).toEqual(1); expect(refundTicketSales[0].quantity).toEqual(-5); - expect(refundTicketObservations[0].description).toEqual('Reclama ticket: 11'); - expect(refundTicketState.stateFk).toEqual(16); expect(salesInsertedInClaimEnd[0].saleFk).toEqual(refundTicketSales[0].id); }); }); From 9db989d1913cad60b6b02a7c317bc5cf34640a90 Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 13 Aug 2019 14:03:02 +0200 Subject: [PATCH 09/22] ticket.sale ok state fixed --- modules/ticket/front/sale/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 9b05350a9..e0ed865bd 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -20,6 +20,11 @@ class Controller { this._sales = []; this.imagesPath = '//verdnatura.es/vn-image-data/catalog'; } + isTicketEditable() { + this.$http.get(`/api/Tickets/${this.$state.params.id}/isEditable`).then(res => { + this.isEditable = res.data; + }); + } get ticket() { return this._ticket; @@ -27,7 +32,7 @@ class Controller { set ticket(value) { this._ticket = value; - this.isEditable(); + this.isTicketEditable(); } get sales() { @@ -94,11 +99,6 @@ class Controller { callback.call(this); } - isEditable() { - this.$http.get(`/api/Tickets/${this.$state.params.id}/isEditable`).then(res => { - this.isEditable = res.data; - }); - } get isChecked() { if (this.sales) { for (let instance of this.sales) From b36846994db34369b6dcd1302c71a5865bd825dd Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Sep 2019 14:12:03 +0200 Subject: [PATCH 10/22] Server error on change paymethod #1687 --- modules/client/back/models/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index dc60d3111..a73070a61 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -198,9 +198,9 @@ module.exports = Self => { if (payMethodChanged || ibanChanged || dueDayChanged) { const message = `La forma de pago del cliente con id ${instance.id} ha cambiado`; const salesPersonFk = instance.salesPersonFk; - const salesPerson = await Self.app.models.Worker.findById(salesPersonFk); - if (salesPerson) { + if (salesPersonFk) { + const salesPerson = await Self.app.models.Worker.findById(salesPersonFk); await Self.app.models.Message.send(ctx, { recipientFk: salesPerson.userFk, message: message From ac26d224dd57f7d5ed89154287de91ad6414a660 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 12 Sep 2019 07:20:48 +0200 Subject: [PATCH 11/22] updated fonts & added "Fruit" item category #1688 --- front/core/styles/salixfont.css | 259 +------------------------------ front/core/styles/salixfont.svg | 1 + front/core/styles/salixfont.ttf | Bin 26156 -> 26852 bytes front/core/styles/salixfont.woff | Bin 26232 -> 26928 bytes 4 files changed, 3 insertions(+), 257 deletions(-) diff --git a/front/core/styles/salixfont.css b/front/core/styles/salixfont.css index 5bea56e13..267e3ba01 100644 --- a/front/core/styles/salixfont.css +++ b/front/core/styles/salixfont.css @@ -23,263 +23,8 @@ -moz-osx-font-smoothing: grayscale; } -.icon-basketadd:before { - content: "\e955"; -} -.icon-catalog:before { - content: "\e952"; -} -.icon-agency:before { - content: "\e910"; -} -.icon-delivery:before { - content: "\e94a"; -} -.icon-wand:before { - content: "\e954"; -} -.icon-unavailable:before { - content: "\e953"; -} -.icon-buscaman:before { - content: "\e951"; -} -.icon-pbx:before { - content: "\e950"; -} -.icon-calendar:before { - content: "\e94f"; -} -.icon-linesplit:before { - content: "\e945"; -} -.icon-invoices:before { - content: "\e91c"; -} -.icon-pets:before { - content: "\e94e"; -} -.icon-100:before { - content: "\e940"; -} -.icon-accessory:before { - content: "\e90a"; -} -.icon-actions:before { - content: "\e900"; -} -.icon-addperson:before { - content: "\e901"; -} -.icon-albaran:before { - content: "\e902"; -} -.icon-apps:before { - content: "\e948"; -} -.icon-artificial:before { - content: "\e903"; -} -.icon-barcode:before { - content: "\e904"; -} -.icon-basket:before { - content: "\e942"; -} -.icon-bin:before { - content: "\e905"; -} -.icon-botanical:before { - content: "\e906"; -} -.icon-bucket:before { - content: "\e907"; -} -.icon-claims:before { - content: "\e908"; -} -.icon-clone:before { - content: "\e909"; -} -.icon-columnadd:before { - content: "\e944"; -} -.icon-columndelete:before { - content: "\e90f"; -} -.icon-components:before { - content: "\e90b"; -} -.icon-consignatarios:before { - content: "\e90d"; -} -.icon-control:before { - content: "\e93f"; -} -.icon-credit:before { - content: "\e90e"; -} -.icon-details:before { - content: "\e911"; -} -.icon-disabled:before { - content: "\e91b"; -} -.icon-doc:before { - content: "\e913"; -} -.icon-entry:before { - content: "\e914"; -} -.icon-exit:before { - content: "\e947"; -} -.icon-eye:before { - content: "\e915"; -} -.icon-fiscal:before { - content: "\e912"; -} -.icon-flower:before { - content: "\e916"; -} -.icon-frozen:before { - content: "\e917"; -} -.icon-greenery:before { - content: "\e93c"; -} -.icon-greuge:before { - content: "\e918"; -} -.icon-grid:before { - content: "\e919"; -} -.icon-handmade:before { - content: "\e90c"; -} -.icon-history:before { - content: "\e91a"; -} -.icon-info:before { - content: "\e949"; -} -.icon-item:before { - content: "\e941"; -} -.icon-languaje:before { - content: "\e91d"; -} -.icon-linedelete:before { - content: "\e946"; -} -.icon-lines:before { - content: "\e91e"; -} -.icon-linesprepaired:before { - content: "\e94b"; -} -.icon-logout:before { - content: "\e91f"; -} -.icon-mana:before { - content: "\e920"; -} -.icon-mandatory:before { - content: "\e921"; -} -.icon-niche:before { - content: "\e922"; -} -.icon-no036:before { - content: "\e923"; -} -.icon-notes:before { - content: "\e924"; -} -.icon-noweb:before { - content: "\e925"; -} -.icon-onlinepayment:before { - content: "\e926"; -} -.icon-package:before { - content: "\e927"; -} -.icon-payment:before { - content: "\e928"; -} -.icon-person:before { - content: "\e929"; -} -.icon-photo:before { - content: "\e92a"; -} -.icon-plant:before { - content: "\e92b"; -} -.icon-recovery:before { - content: "\e92d"; -} -.icon-regentry:before { - content: "\e92e"; -} -.icon-reserve:before { - content: "\e92f"; -} -.icon-revision:before { - content: "\e94c"; -} -.icon-risk:before { - content: "\e930"; -} -.icon-services:before { - content: "\e94d"; -} -.icon-settings:before { - content: "\e931"; -} -.icon-sms:before { - content: "\e932"; -} -.icon-solclaim:before { - content: "\e933"; -} -.icon-solunion:before { - content: "\e934"; -} -.icon-splur:before { - content: "\e935"; -} -.icon-stowaway:before { - content: "\e92c"; -} -.icon-supplier:before { - content: "\e936"; -} -.icon-tags:before { - content: "\e937"; -} -.icon-tax:before { - content: "\e938"; -} -.icon-ticket:before { - content: "\e939"; -} -.icon-traceability:before { - content: "\e93a"; -} -.icon-transaction:before { - content: "\e93b"; -} -.icon-volume:before { - content: "\e93d"; -} -.icon-web:before { - content: "\e93e"; -} -.icon-worker:before { - content: "\e943"; +.icon-fruit:before { + content: "\e957"; } .icon-deliveryprices:before { content: "\e956"; diff --git a/front/core/styles/salixfont.svg b/front/core/styles/salixfont.svg index 04dd47f6f..d3837cc76 100644 --- a/front/core/styles/salixfont.svg +++ b/front/core/styles/salixfont.svg @@ -94,4 +94,5 @@ + \ No newline at end of file diff --git a/front/core/styles/salixfont.ttf b/front/core/styles/salixfont.ttf index b11c6f64c37915d53e3f50ca5f682de420164cee..5def0c5b8cb324db06c4fef3578b60c7504658d7 100644 GIT binary patch delta 986 zcmYL|PfQe79LIl;H+{nlJbdjN-((k-F1t8WmVYbQr5cN6Hwd^0!CgfS?6QK(s!&ik zV5?baS`#lOf<3gU-c3w2!GkvSVB8*>w1>8ra%eC0t{0E~`OScF-b{Y^{J!7c@4a6# z@9yv9*`K5g1ORH_3Q&lTW;(lee8j%S%rE#&P0tq=?PGua2S6H-v$KVzMT`R3i`BDp z7mG)(b*>?=08DG8(}fu|d3iU$%q7$lB~0iQEr9$0xw$mIyiz2_-^l-XJ?0js_ZB|B zpkD_l4x-`b`NGN~d_|rD%xcKtFAMXhbK{!>$jw-AdvRfD84rq2sdD4t02yB+X)?Ys zOjf7LwGe&tKmC{9f(FHbo-zY;zE!n{kFUPmxG zZU^zRy~Ou460F$epikM2WT)lZZ1nVcudRHR9p(3=GspE*EZ9=9nATw%Y@XPzp&jJY zJ&Eovucs$`fKCj4*0Z>n#uD#DehI~`>qs=RbvkA1zP=@T8_{xccq;#EZt~Ef=4R?R z!|5DSKD|w$WHxg@do-1bG?AuoGMUNVJDNp`kfx@-SA(GjQ(c#Gbfl&IJYQ&U(~PT9 zju^Z<*wC-OmvIp~XGn^VrCjSfRugDHrL(LMU6x{6E925VQl|PS=WRk5^j<7K!~-X} z(arggQ`Hj+T51)$kG921q8RJc*tgOeGI=~?_XhX7U(kaA`=Dt!oR73D30DLs4N*<0 zE>xqSo!b+q?kDtdp+h(Fy6}5Szf!3 zY5fj~$(CR|y)5Jbq3T7%+aSTrptO%mlkJp$@Dto_)v2nr5~1)Qd;KGiDR=n16iFc* zaWXn4!qp~U6>>nMpNIX+hZk_*lGUEyvHvC1c)vZs=Ix*I@8bH4LJyhP_~g_a(NK-9 f-<*DE?fwR3@8(XBClKu8pU`RXzlsC%&3a}qxkzim*Vgd41 zGIC2Qk{CHR0Qnj~Jvlk~$(D(4Kd|>PFeFa_D%g>mSW&=G$#|H7A;kyCSIA4uO^pk` z2{bSz2dH6QL4I)w(4jz(#xrq;J7d@+MsLQj%|48c3CbXU0CBM5g@f_@HeVUIK~^#_ k+_W;yg3*%~q?j{CZ@!U|!#LR^Z3i3J@6nsN(r+;W0KdONs{jB1 diff --git a/front/core/styles/salixfont.woff b/front/core/styles/salixfont.woff index f88e6bfbfb773cf76feb69b2da2ad11cfe47df4b..3884346c1ae9a5cda7ebee3c50c54d9dd249129d 100644 GIT binary patch delta 1008 zcmYLIO-vI(7@cv}U3Ot`l38cdLb0^C8%lvHTGSv)8$c{lkt%ASrGTX>2nvb+X)tQy z#YE9WjdJ&-2^TfqtcfOi(Gw;b6TN#f@!;P#ON}%8GI{TN@0%hBD6WLj*JqKP^0-KmTn**(g(3m2z z?^^TC{E_T9LgTN%6O|Cd7dPZVMCb@mR41Vo6;FO@?hI(avFtmO!}|Nl=`rxN=Wc=N znZ&wN+V!dI88A%j1@3oo4!<~&oq}!?GPo#_9$fC8nVy}4dDxAgNj$jFixYTo=?uX#n?tus7ixMxwEf8v?Qfr#&q&1lhqdn9=a#Pp*+ilnicgjH+u{k@mcNOHfJa4@>pGlZd2M-=V)GH6IQs<^094Z({Q zX=+7O;$?h`Ke)%hMSH}w4TIe>d5UOp+Z&!V*e2$=$XHx8`a{3_ogtMrP;rb_Y*Up^ z8;5wkH_SI!CGFtpZRw#w2ijnp{2ReNvuFMxbS)G RiLv1llp%#LG;6AKs^7&CxEAs{RscIj?8+ZtAH^3 z5f+Jz+>#2QSP4*n4hSbPa&E}UPX?;9OMU=Uv;&0Seqis*O{@S~oH7H*R{-Nm#>07u zxv4-gpc=+`ARHHd)4d?S7-(2p#Kb@TjA4^~7`++8HqT&eOi%{-5Qu{nFC2{LxB1Gz p%>oo)V7O^zngydLzezD?jNYu0n!`AGO4<%KaHvFY4oknq2ms5bNzecQ From 5d980f51292948d65fc64abfbfd4deeb6ab2971f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 12 Sep 2019 07:25:05 +0200 Subject: [PATCH 12/22] Added fruit translation --- modules/order/front/locale/es.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/order/front/locale/es.yml b/modules/order/front/locale/es.yml index cd32325eb..943606a47 100644 --- a/modules/order/front/locale/es.yml +++ b/modules/order/front/locale/es.yml @@ -8,6 +8,7 @@ Enter a new search: Introduce una nueva búsqueda Plant: Planta Flower: Flor Handmade: Confección +Fruit: Fruta Green: Verde Lines: Lineas Accessories: Complemento From 248dff274734fbfeb774326643838c266213748a Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 12 Sep 2019 14:16:09 +0200 Subject: [PATCH 13/22] cherry-pick --- front/nginx.conf | 2 +- loopback/server/datasources.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/nginx.conf b/front/nginx.conf index cf429b153..bbba60ab2 100644 --- a/front/nginx.conf +++ b/front/nginx.conf @@ -16,7 +16,7 @@ server { listen [::]:80 default_server; server_name _; autoindex off; - client_max_body_size 50M; + client_max_body_size 250M; root /salix/dist; error_page 404 = @notfound; diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index a8cf8e765..4c9e407a0 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -20,7 +20,7 @@ "connector": "loopback-component-storage", "provider": "filesystem", "root": "./e2e/dms", - "maxFileSize": "10485760", + "maxFileSize": "262144000", "allowedContentTypes": [ "application/x-7z-compressed", "application/x-zip-compressed", From 043fe80254aff13f2ee3a8e6eba389c93aeb8497 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Sep 2019 13:26:50 +0200 Subject: [PATCH 14/22] cherry 1 --- modules/agency/back/methods/zone-geo/getLeaves.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/agency/back/methods/zone-geo/getLeaves.js b/modules/agency/back/methods/zone-geo/getLeaves.js index 4f21aea41..f3ddc722e 100644 --- a/modules/agency/back/methods/zone-geo/getLeaves.js +++ b/modules/agency/back/methods/zone-geo/getLeaves.js @@ -92,7 +92,9 @@ module.exports = Self => { AND child.depth = parent.depth + 1 LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id AND zi.zoneFk = ? - WHERE parent.id = ?) AS nst`, [zoneFk, parentFk]); + WHERE (? IS NULL AND zg.parentFk IS NULL) + OR (? IS NOT NULL AND zg.parentFk = ?)) AS nst`, + [zoneFk, parentFk, parentFk, parentFk]); // Get nodes from depth greather than Origin stmt.merge(conn.makeSuffix(filter)); From dd0c34d31b64151034358d30613cab016aa0762d Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Sep 2019 12:16:38 +0200 Subject: [PATCH 15/22] allowed null parent --- modules/agency/back/methods/zone-geo/getLeaves.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/agency/back/methods/zone-geo/getLeaves.js b/modules/agency/back/methods/zone-geo/getLeaves.js index f3ddc722e..6a4d1bc0d 100644 --- a/modules/agency/back/methods/zone-geo/getLeaves.js +++ b/modules/agency/back/methods/zone-geo/getLeaves.js @@ -31,7 +31,7 @@ module.exports = Self => { } }); - Self.getLeaves = async(zoneFk, parentFk = 1, filter) => { + Self.getLeaves = async(zoneFk, parentFk, filter) => { let conn = Self.dataSource.connector; let stmts = []; @@ -47,7 +47,7 @@ module.exports = Self => { isIncluded TINYINT ) ENGINE = MEMORY`)); - if (parentFk === 1) { + if (!parentFk) { stmts.push(new ParameterizedSQL( `INSERT INTO tmp.checkedChilds SELECT From c7423f5580076159968b493c28ac51670ed8d75b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Sep 2019 13:00:33 +0200 Subject: [PATCH 16/22] pick2 --- .../agency/back/methods/zone-geo/getLeaves.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/agency/back/methods/zone-geo/getLeaves.js b/modules/agency/back/methods/zone-geo/getLeaves.js index 6a4d1bc0d..f07095b08 100644 --- a/modules/agency/back/methods/zone-geo/getLeaves.js +++ b/modules/agency/back/methods/zone-geo/getLeaves.js @@ -31,7 +31,7 @@ module.exports = Self => { } }); - Self.getLeaves = async(zoneFk, parentFk, filter) => { + Self.getLeaves = async(zoneFk, parentFk = null, filter) => { let conn = Self.dataSource.connector; let stmts = []; @@ -79,18 +79,15 @@ module.exports = Self => { AND zg.depth > 0 UNION ALL SELECT - child.id, - child.name, - child.lft, - child.rgt, - child.depth, - child.sons, + zg.id, + zg.name, + zg.lft, + zg.rgt, + zg.depth, + zg.sons, zi.isIncluded AS selected - FROM zoneGeo parent - JOIN zoneGeo child ON child.lft > parent.lft - AND child.rgt < parent.rgt - AND child.depth = parent.depth + 1 - LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id + FROM zoneGeo zg + LEFT JOIN zoneIncluded zi ON zi.geoFk = zg.id AND zi.zoneFk = ? WHERE (? IS NULL AND zg.parentFk IS NULL) OR (? IS NOT NULL AND zg.parentFk = ?)) AS nst`, From f56e4f4b7ddbfd477327888eadd2613f2a46e4b5 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 18 Sep 2019 10:35:46 +0200 Subject: [PATCH 17/22] pick --- e2e/helpers/selectors.js | 12 ++++----- .../02-client-module/01_create_client.spec.js | 7 ++++-- .../03_edit_fiscal_data.spec.js | 12 ++++++--- .../02-client-module/05_add_address.spec.js | 10 +++++--- loopback/locale/en.json | 8 +++++- loopback/locale/es.json | 12 ++++++++- modules/client/back/models/address.js | 15 +++++++++++ modules/client/back/models/client.js | 25 +++++++++++++++++++ .../client/front/address/create/index.html | 16 +++++++++--- modules/client/front/address/edit/index.html | 16 +++++++++--- modules/client/front/create/index.html | 20 ++++++++++----- modules/client/front/fiscal-data/index.html | 12 +++++++-- 12 files changed, 132 insertions(+), 33 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index e2c75597a..b259a1704 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -33,8 +33,8 @@ export default { taxNumber: `${components.vnTextfield}[name="fi"]`, socialName: `${components.vnTextfield}[name="socialName"]`, street: `${components.vnTextfield}[name="street"]`, - postcode: `vn-autocomplete[field="$ctrl.client.postcode"]`, - city: `vn-autocomplete[field="$ctrl.client.city"]`, + postcode: `${components.vnTextfield}[name="postcode"]`, + city: `${components.vnTextfield}[name="city"]`, province: `vn-autocomplete[field="$ctrl.client.provinceFk"]`, country: `vn-autocomplete[field="$ctrl.client.countryFk"]`, userName: `${components.vnTextfield}[name="userName"]`, @@ -65,8 +65,8 @@ export default { equalizationTaxCheckbox: 'vn-check[label="Is equalizated"] md-checkbox', acceptPropagationButton: 'vn-client-fiscal-data > vn-confirm button[response=ACCEPT]', addressInput: `${components.vnTextfield}[name="street"]`, - postcodeAutocomplete: `vn-autocomplete[field="$ctrl.client.postcode"]`, - cityAutocomplete: `vn-autocomplete[field="$ctrl.client.city"]`, + postcodeInput: `${components.vnTextfield}[name="postcode"]`, + cityInput: `${components.vnTextfield}[name="city"]`, provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]', countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]', activeCheckbox: 'vn-check[label="Active"] md-checkbox', @@ -100,8 +100,8 @@ export default { defaultCheckboxInput: 'vn-check[label="Default"] md-checkbox', consigneeInput: `${components.vnTextfield}[name="nickname"]`, streetAddressInput: `${components.vnTextfield}[name="street"]`, - postcodeAutocomplete: `vn-autocomplete[field="$ctrl.address.postalCode"]`, - cityAutocomplete: `vn-autocomplete[field="$ctrl.address.city"]`, + postcodeInput: `${components.vnTextfield}[name="postalCode"]`, + cityInput: `${components.vnTextfield}[name="city"]`, provinceAutocomplete: 'vn-autocomplete[field="$ctrl.address.provinceFk"]', agencyAutocomplete: 'vn-autocomplete[field="$ctrl.address.agencyModeFk"]', phoneInput: `${components.vnTextfield}[name="phone"]`, diff --git a/e2e/paths/02-client-module/01_create_client.spec.js b/e2e/paths/02-client-module/01_create_client.spec.js index b9ea5e112..b67a89e68 100644 --- a/e2e/paths/02-client-module/01_create_client.spec.js +++ b/e2e/paths/02-client-module/01_create_client.spec.js @@ -53,7 +53,10 @@ describe('Client create path', () => { .write(selectors.createClientView.name, 'Carol Danvers') .write(selectors.createClientView.socialName, 'AVG tax') .write(selectors.createClientView.street, 'Many places') - .autocompleteSearch(selectors.createClientView.postcode, '46000') + .autocompleteSearch(selectors.createClientView.country, 'España') + .autocompleteSearch(selectors.createClientView.province, 'Province one') + .write(selectors.createClientView.city, 'Valencia') + .write(selectors.createClientView.postcode, '46000') .clearInput(selectors.createClientView.email) .write(selectors.createClientView.email, 'incorrect email format') .waitToClick(selectors.createClientView.createButton) @@ -64,7 +67,7 @@ describe('Client create path', () => { it(`should check for autocompleted city, province and country`, async() => { const clientCity = await nightmare - .waitToGetProperty(`${selectors.createClientView.city} input`, 'value'); + .waitToGetProperty(`${selectors.createClientView.city}`, 'value'); const clientProvince = await nightmare .waitToGetProperty(`${selectors.createClientView.province} input`, 'value'); diff --git a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js index f94b6cf3c..1e11de223 100644 --- a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js @@ -67,8 +67,12 @@ describe('Client Edit fiscalData path', () => { .write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!') .clearInput(selectors.clientFiscalData.addressInput) .write(selectors.clientFiscalData.addressInput, 'Somewhere edited') - .autocompleteSearch(selectors.clientFiscalData.cityAutocomplete, 'Valencia') - .autocompleteSearch(selectors.clientFiscalData.postcodeAutocomplete, '46000') + .autocompleteSearch(selectors.clientFiscalData.countryAutocomplete, 'España') + .autocompleteSearch(selectors.clientFiscalData.provinceAutocomplete, 'Province one') + .clearInput(selectors.clientFiscalData.cityInput) + .write(selectors.clientFiscalData.cityInput, 'Valencia') + .clearInput(selectors.clientFiscalData.postcodeInput) + .write(selectors.clientFiscalData.postcodeInput, '46000') .waitToClick(selectors.clientFiscalData.activeCheckbox) .waitToClick(selectors.clientFiscalData.frozenCheckbox) .waitToClick(selectors.clientFiscalData.hasToInvoiceCheckbox) @@ -194,14 +198,14 @@ describe('Client Edit fiscalData path', () => { it('should confirm the postcode have been edited', async() => { const result = await nightmare - .waitToGetProperty(`${selectors.clientFiscalData.postcodeAutocomplete} input`, 'value'); + .waitToGetProperty(`${selectors.clientFiscalData.postcodeInput}`, 'value'); expect(result).toContain('46000'); }); it('should confirm the city have been autocompleted', async() => { const result = await nightmare - .waitToGetProperty(`${selectors.clientFiscalData.cityAutocomplete} input`, 'value'); + .waitToGetProperty(`${selectors.clientFiscalData.cityInput}`, 'value'); expect(result).toEqual('Valencia'); }); diff --git a/e2e/paths/02-client-module/05_add_address.spec.js b/e2e/paths/02-client-module/05_add_address.spec.js index 5e21f87d8..4bf7482ee 100644 --- a/e2e/paths/02-client-module/05_add_address.spec.js +++ b/e2e/paths/02-client-module/05_add_address.spec.js @@ -24,7 +24,11 @@ describe('Client Add address path', () => { const result = await nightmare .waitToClick(selectors.clientAddresses.defaultCheckboxInput) .clearInput(selectors.clientAddresses.streetAddressInput) - .autocompleteSearch(selectors.clientAddresses.postcodeAutocomplete, '46000') + .autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one') + .clearInput(selectors.clientAddresses.cityInput) + .write(selectors.clientAddresses.cityInput, 'Valencia') + .clearInput(selectors.clientAddresses.postcodeInput) + .write(selectors.clientAddresses.postcodeInput, '46000') .autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement') .write(selectors.clientAddresses.phoneInput, '999887744') .write(selectors.clientAddresses.mobileInput, '999887744') @@ -36,14 +40,14 @@ describe('Client Add address path', () => { it('should confirm the postcode have been edited', async() => { const result = await nightmare - .waitToGetProperty(`${selectors.clientAddresses.postcodeAutocomplete} input`, 'value'); + .waitToGetProperty(`${selectors.clientAddresses.postcodeInput}`, 'value'); expect(result).toContain('46000'); }); it('should confirm the city have been autocompleted', async() => { const result = await nightmare - .waitToGetProperty(`${selectors.clientAddresses.cityAutocomplete} input`, 'value'); + .waitToGetProperty(`${selectors.clientAddresses.cityInput}`, 'value'); expect(result).toEqual('Valencia'); }); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 111349c17..4c29d0a70 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -49,5 +49,11 @@ "This client can't be invoiced": "This client can't be invoiced", "The introduced hour already exists": "The introduced hour already exists", "Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket", - "Concept cannot be blank": "Concept cannot be blank" + "Concept cannot be blank": "Concept cannot be blank", + "Ticket id cannot be blank": "Ticket id cannot be blank", + "Weekday cannot be blank": "Weekday cannot be blank", + "This ticket can not be modified": "This ticket can not be modified", + "You can't delete a confirmed order": "You can't delete a confirmed order", + "Value has an invalid format": "Value has an invalid format", + "The postcode doesn't exists. Ensure you put the correct format": "The postcode doesn't exists. Ensure you put the correct format" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 76b1017b3..43b3c8177 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -97,5 +97,15 @@ "This postcode already exists": "Este código postal ya existe", "Concept cannot be blank": "El concepto no puede quedar en blanco", "File doesn't exists": "El archivo no existe", - "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona" + "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona", + "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", + "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", + "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", + "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", + "Can't create stowaway for this ticket": "No se puede crear un polizon para este ticket", + "Value has an invalid format": "El valor tiene un formato incorrecto", + "Invalid quantity": "Cantidad invalida", + "This postal code is not valid": "This postal code is not valid", + "is invalid": "is invalid", + "The postcode doesn't exists. Ensure you put the correct format": "El código postal no existe. Asegúrate de ponerlo con el formato correcto" } \ No newline at end of file diff --git a/modules/client/back/models/address.js b/modules/client/back/models/address.js index f0f1efa35..2399bee0c 100644 --- a/modules/client/back/models/address.js +++ b/modules/client/back/models/address.js @@ -43,6 +43,21 @@ module.exports = Self => { next(); }); + Self.validateAsync('postalCode', hasValidPostcode, { + message: `The postcode doesn't exists. Ensure you put the correct format` + }); + + async function hasValidPostcode(err, done) { + if (!this.postalCode) + return done(); + + const models = Self.app.models; + const postcode = await models.Postcode.findById(this.postalCode); + + if (!postcode) err(); + done(); + } + // Helpers Self.observe('before save', async function(ctx) { diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index a73070a61..03290811c 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -149,6 +149,31 @@ module.exports = Self => { done(); } + Self.validateBinded('socialName', isAlpha, { + message: 'Value has an invalid format' + }); + + function isAlpha(value) { + const regexp = new RegExp(/^[a-zA-Z\s]*$/); + + return regexp.test(value); + } + + Self.validateAsync('postCode', hasValidPostcode, { + message: `The postcode doesn't exists. Ensure you put the correct format` + }); + + async function hasValidPostcode(err, done) { + if (!this.postcode) + return done(); + + const models = Self.app.models; + const postcode = await models.Postcode.findById(this.postcode); + + if (!postcode) err(); + done(); + } + Self.observe('before save', async function(ctx) { let changes = ctx.data || ctx.instance; let orgData = ctx.currentInstance; diff --git a/modules/client/front/address/create/index.html b/modules/client/front/address/create/index.html index 432d4ebbe..0240aceb5 100644 --- a/modules/client/front/address/create/index.html +++ b/modules/client/front/address/create/index.html @@ -31,7 +31,11 @@ value-field="id" label="Province"> - + + + + + - + + + + + - + + + + + + - + + + + Date: Wed, 18 Sep 2019 15:11:09 +0200 Subject: [PATCH 18/22] updated transactions --- back/methods/message/send.js | 10 +++---- .../back/methods/claim/regularizeClaim.js | 26 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/back/methods/message/send.js b/back/methods/message/send.js index 5968964b1..f7b7ad76e 100644 --- a/back/methods/message/send.js +++ b/back/methods/message/send.js @@ -25,24 +25,24 @@ module.exports = Self => { } }); - Self.send = async(ctx, data, transaction) => { + Self.send = async(ctx, data, options) => { const accessToken = ctx.options && ctx.options.accessToken || ctx.req && ctx.req.accessToken; const userId = accessToken.userId; const models = Self.app.models; - const sender = await models.Account.findById(userId, transaction); - const recipient = await models.Account.findById(data.recipientFk, transaction); + const sender = await models.Account.findById(userId, options); + const recipient = await models.Account.findById(data.recipientFk, options); await Self.create({ sender: sender.name, recipient: recipient.name, message: data.message - }, transaction); + }, options); return await models.MessageInbox.create({ sender: sender.name, recipient: recipient.name, finalRecipient: recipient.name, message: data.message - }, transaction); + }, options); }; }; diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index 5c54a7a2f..a2896174e 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -22,18 +22,18 @@ module.exports = Self => { const models = Self.app.models; const resolvedState = 3; - const claimEnds = await models.ClaimEnd.find({ - include: { - relation: 'claimDestination', - fields: ['addressFk'] - }, - where: {claimFk: params.claimFk} - }); - let tx = await Self.beginTransaction({}); try { let options = {transaction: tx}; + const claimEnds = await models.ClaimEnd.find({ + include: { + relation: 'claimDestination', + fields: ['addressFk'] + }, + where: {claimFk: params.claimFk} + }, options); + for (let i = 0; i < claimEnds.length; i++) { const claimEnd = claimEnds[i]; const destination = claimEnd.claimDestination(); @@ -42,7 +42,7 @@ module.exports = Self => { if (!addressFk) continue; - let sale = await getSale(claimEnd.saleFk); + let sale = await getSale(claimEnd.saleFk, options); let ticketFk = await getTicketId({ addressFk: addressFk, companyFk: sale.ticket().companyFk, @@ -51,7 +51,7 @@ module.exports = Self => { let address = await models.Address.findOne({ where: {id: addressFk} - }); + }, options); if (!ticketFk) { ticketFk = await createTicket(ctx, { @@ -84,7 +84,7 @@ module.exports = Self => { } } - let claim = await Self.findById(params.claimFk); + let claim = await Self.findById(params.claimFk, null, options); claim = await claim.updateAttributes({ claimStateFk: resolvedState }, options); @@ -98,7 +98,7 @@ module.exports = Self => { } }; - async function getSale(saleFk) { + async function getSale(saleFk, options) { return await Self.app.models.Sale.findOne({ include: [ { @@ -116,7 +116,7 @@ module.exports = Self => { } }], where: {id: saleFk} - }); + }, options); } async function getTicketId(params, options) { From 4d894365eb68f80213517fa790706b7cf7e92406 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 19 Sep 2019 08:58:42 +0200 Subject: [PATCH 19/22] Fixed production errors #1699 --- README.md | 2 +- db/dump/fixtures.sql | 3 ++- modules/client/back/models/client.js | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b3cc9fdbe..06883779b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ext install dbaeumer.vscode-eslint You will need to install globally the following items. ``` -# npm install -g karma-cli gulp-cli nodemon +# npm install -g jest gulp-cli nodemon ``` ## Linux Only Prerequisites diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 821df10d5..facb222a4 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -570,7 +570,8 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`) (4, 'Handmade', 1, NULL, 'icon-handmade'), (5, 'Artificial', 1, NULL, 'icon-artificial'), (6, 'Green', 1, NULL, 'icon-greenery'), - (7, 'Accessories', 1, NULL, 'icon-accessory'); + (7, 'Accessories', 1, NULL, 'icon-accessory'), + (8, 'Fruit', 1, NULL, 'icon-fruit'); INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`,`workerFk`, `isPackaging`) VALUES diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 03290811c..a85ef4751 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -107,6 +107,8 @@ module.exports = Self => { }); function cannotHaveET(err) { + if (!this.fi) return; + let tin = this.fi.toUpperCase(); let cannotHaveET = /^[A-B]/.test(tin); From 9ce18fbd0a62bba8fcdf823553979f7769dd5b7c Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 19 Sep 2019 09:37:02 +0200 Subject: [PATCH 20/22] double start pick --- modules/client/front/address/index/index.html | 81 +++++++++++-------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/modules/client/front/address/index/index.html b/modules/client/front/address/index/index.html index 8696e321f..b396b9da6 100644 --- a/modules/client/front/address/index/index.html +++ b/modules/client/front/address/index/index.html @@ -18,41 +18,52 @@ ng-class="{ 'item-hightlight': $ctrl.isDefaultAddress(address), 'item-disabled': !address.isActive && !$ctrl.isDefaultAddress(address) - }"> - - - - - - - - - - - - -
{{::address.nickname}}
-
{{::address.street}}
-
{{::address.city}}, {{::address.province}}
-
{{::address.phone}}, {{::address.mobile}}
-
- - - - -
+ }" + translate-attr="{title: 'Edit address'}" + border-radius> + + + + + + + + + +
{{::address.nickname}}
+
{{::address.street}}
+
{{::address.city}}, {{::address.province.name}}
+
+ {{::address.phone}}, + {{::address.mobile}} +
+ + +
+ + + {{::observation.observationType.description}}: + {{::observation.description}} From f67006e526bd11a5b717ce91813fea5be4479a5e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 19 Sep 2019 09:41:02 +0200 Subject: [PATCH 21/22] changed fiscal name translation --- loopback/locale/es.json | 2 +- modules/client/back/models/client.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 43b3c8177..b6c70be3a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -103,7 +103,7 @@ "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", "Can't create stowaway for this ticket": "No se puede crear un polizon para este ticket", - "Value has an invalid format": "El valor tiene un formato incorrecto", + "The socialName has an invalid format": "El nombre fiscal tiene un formato incorrecto", "Invalid quantity": "Cantidad invalida", "This postal code is not valid": "This postal code is not valid", "is invalid": "is invalid", diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index a85ef4751..49ab954d8 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -152,7 +152,7 @@ module.exports = Self => { } Self.validateBinded('socialName', isAlpha, { - message: 'Value has an invalid format' + message: 'The socialName has an invalid format' }); function isAlpha(value) { From d6d825ebf16fcc027944e8d89ec442758ed5bb33 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 19 Sep 2019 10:52:23 +0200 Subject: [PATCH 22/22] fixed automerge --- modules/client/front/address/index/index.html | 81 ++++++++----------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/modules/client/front/address/index/index.html b/modules/client/front/address/index/index.html index b396b9da6..7abf9e676 100644 --- a/modules/client/front/address/index/index.html +++ b/modules/client/front/address/index/index.html @@ -18,52 +18,41 @@ ng-class="{ 'item-hightlight': $ctrl.isDefaultAddress(address), 'item-disabled': !address.isActive && !$ctrl.isDefaultAddress(address) - }" - translate-attr="{title: 'Edit address'}" - border-radius> - - - - - - - - - -
{{::address.nickname}}
-
{{::address.street}}
-
{{::address.city}}, {{::address.province.name}}
-
- {{::address.phone}}, - {{::address.mobile}} -
- - -
- - - {{::observation.observationType.description}}: - {{::observation.description}} + }"> + + + + + + + + + + + + +
{{::address.nickname}}
+
{{::address.street}}
+
{{::address.city}}, {{::address.province}}
+
{{::address.phone}}, {{::address.mobile}}
+
+ + + + +