From 2f8fa59561a4f88672ce0c1600a421b5988198eb Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 16 Jun 2020 08:50:59 +0200 Subject: [PATCH 01/10] 2332 - Fixed on load error --- modules/claim/front/detail/index.js | 14 ++++++++++++-- modules/claim/front/locale/es.yml | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index f73cfd996..591072e6e 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -99,13 +99,21 @@ class Controller extends Section { this._salesClaimed.forEach(sale => { let orgSale = sale.sale; this.paidTotal += this.getSaleTotal(orgSale); - this.claimedTotal += sale.quantity * orgSale.price - ((orgSale.discount * (sale.quantity * orgSale.price)) / 100); + + const price = sale.quantity * orgSale.price; + const discount = ((orgSale.discount * price) / 100); + + this.claimedTotal += price - discount; }); } getSaleTotal(sale) { let total = 0.0; - total += sale.quantity * sale.price - ((sale.discount * (sale.quantity * sale.price)) / 100); + + const price = sale.quantity * sale.price; + const discount = ((sale.discount * price) / 100); + + total += price - discount; return total; } @@ -127,6 +135,8 @@ class Controller extends Section { } isClaimEditable() { + if (!this.claim) return; + this.$http.get(`Tickets/${this.claim.ticketFk}/isEditable`).then(res => { this.isEditable = res.data; }); diff --git a/modules/claim/front/locale/es.yml b/modules/claim/front/locale/es.yml index b65593bbd..338342eb5 100644 --- a/modules/claim/front/locale/es.yml +++ b/modules/claim/front/locale/es.yml @@ -14,5 +14,6 @@ Send Pickup order: Enviar orden de recogida Show Pickup order: Ver orden de recogida Search claim by id or client name: Buscar reclamaciones por identificador o nombre de cliente Claim deleted!: Reclamación eliminada! -claim: reclamacióm +claim: reclamación +Photos: Fotos From 9e62fd78a2af147342b90ede7fcabb71dd63e14f Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 16 Jun 2020 10:47:01 +0200 Subject: [PATCH 02/10] hasta precio --- modules/client/back/models/address.js | 2 - modules/order/front/catalog-view/index.html | 2 +- modules/order/front/locale/es.yml | 2 +- package-lock.json | 43 ++++++++++----------- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/modules/client/back/models/address.js b/modules/client/back/models/address.js index 384a2e686..3a1157add 100644 --- a/modules/client/back/models/address.js +++ b/modules/client/back/models/address.js @@ -16,7 +16,6 @@ module.exports = Self => { } else cannotHaveET = false; - if (cannotHaveET && this.isEqualizated) err(); done(); @@ -37,7 +36,6 @@ module.exports = Self => { done(); } - Self.beforeRemote('findById', function(ctx, modelInstance, next) { ctx.args.filter = { include: [{ diff --git a/modules/order/front/catalog-view/index.html b/modules/order/front/catalog-view/index.html index 739fdfe8e..459a61f59 100644 --- a/modules/order/front/catalog-view/index.html +++ b/modules/order/front/catalog-view/index.html @@ -37,7 +37,7 @@
{{::item.available}} - from + to {{::item.price | currency:'EUR':2}} Date: Wed, 17 Jun 2020 13:09:40 +0200 Subject: [PATCH 03/10] Language bug fix --- front/salix/module.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/salix/module.js b/front/salix/module.js index c3e8dcb8a..2c61af4d1 100644 --- a/front/salix/module.js +++ b/front/salix/module.js @@ -73,7 +73,7 @@ export function config($translateProvider, $translatePartialLoaderProvider, $htt return locale; if (langOptions.langAliases[locale]) return langOptions.langAliases[locale]; - return fallbackLang; + return langOptions.fallbackLang; }); $translatePartialLoaderProvider.addPart(appName); From d1bedfdb226ec8ebdc339db2683559e2a12d2684 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Jun 2020 13:13:13 +0200 Subject: [PATCH 04/10] Skip tests on master/test --- Jenkinsfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 9af09b306..2848ea59b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -54,6 +54,10 @@ pipeline { } } stage('Test') { + when { not { anyOf { + branch 'test' + branch 'master' + }}} environment { NODE_ENV = "" } From fa882ebde614ddcd7ac2187bef96e7a87498b7f7 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Jun 2020 13:14:28 +0200 Subject: [PATCH 05/10] Skip tests on master/test --- Jenkinsfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 9af09b306..4ede8d22e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -54,6 +54,10 @@ pipeline { } } stage('Test') { + when { not { anyOf { + branch 'test' + branch 'master' + }} environment { NODE_ENV = "" } From 063571cb3cd48711685ee5909daec68eef7db0d8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Jun 2020 13:14:59 +0200 Subject: [PATCH 06/10] Jenkins fix --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4ede8d22e..2848ea59b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,7 +57,7 @@ pipeline { when { not { anyOf { branch 'test' branch 'master' - }} + }}} environment { NODE_ENV = "" } From 01a09926e321e89c1c56b840ae3d2257018db16b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 17 Jun 2020 13:30:59 +0200 Subject: [PATCH 07/10] NodeJs version downgrade to 10 LTS --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a574e61fd..5a65b9b18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update \ ca-certificates \ gnupg2 \ libfontconfig \ - && curl -sL https://deb.nodesource.com/setup_12.x | bash - \ + && curl -sL https://deb.nodesource.com/setup_10.x | bash - \ && apt-get install -y --no-install-recommends \ nodejs \ && apt-get purge -y --auto-remove \ From fd9784597973aaf562fec2c93bbc24a95e512418 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 17 Jun 2020 14:00:04 +0200 Subject: [PATCH 08/10] Revert "Removed sms excluded tests" This reverts commit 30912bd5e9c9fd9b335ce1461a32f7aef69a8097. --- .../back/methods/client/specs/sendSms.spec.js | 27 ++++++++++++++ modules/client/back/methods/sms/send.spec.js | 37 +++++++++++++++++++ .../back/methods/ticket/specs/sendSms.spec.js | 27 ++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 modules/client/back/methods/client/specs/sendSms.spec.js create mode 100644 modules/client/back/methods/sms/send.spec.js create mode 100644 modules/ticket/back/methods/ticket/specs/sendSms.spec.js diff --git a/modules/client/back/methods/client/specs/sendSms.spec.js b/modules/client/back/methods/client/specs/sendSms.spec.js new file mode 100644 index 000000000..b299ac3c1 --- /dev/null +++ b/modules/client/back/methods/client/specs/sendSms.spec.js @@ -0,0 +1,27 @@ +const app = require('vn-loopback/server/server'); + +describe('client sendSms()', () => { + let createdLog; + + afterAll(async done => { + await app.models.ClientLog.destroyById(createdLog.id); + + done(); + }); + + it('should send a message and log it', async() => { + let ctx = {req: {accessToken: {userId: 9}}}; + let id = 101; + let destination = 222222222; + let message = 'this is the message created in a test'; + + let sms = await app.models.Client.sendSms(ctx, id, destination, message); + + logId = sms.logId; + + createdLog = await app.models.ClientLog.findById(logId); + let json = JSON.parse(JSON.stringify(createdLog.newInstance)); + + expect(json.message).toEqual(message); + }); +}); diff --git a/modules/client/back/methods/sms/send.spec.js b/modules/client/back/methods/sms/send.spec.js new file mode 100644 index 000000000..612a16cf1 --- /dev/null +++ b/modules/client/back/methods/sms/send.spec.js @@ -0,0 +1,37 @@ +const app = require('vn-loopback/server/server'); +const soap = require('soap'); + +describe('sms send()', () => { + it('should return the expected message and status code', async() => { + const code = 200; + const smsConfig = await app.models.SmsConfig.findOne(); + const soapClient = await soap.createClientAsync(smsConfig.uri); + spyOn(soap, 'createClientAsync').and.returnValue(soapClient); + spyOn(soapClient, 'sendSMSAsync').and.returnValue([{ + result: { + $value: + ` + + + ${code} + + + Envio en procesamiento + + + 1 + + + + 444328681 + + ` + } + }]); + let ctx = {req: {accessToken: {userId: 1}}}; + let result = await app.models.Sms.send(ctx, 105, 'destination', 'My SMS Body'); + + expect(result.statusCode).toEqual(200); + expect(result.status).toContain('Fake response'); + }); +}); diff --git a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js new file mode 100644 index 000000000..20066a5ba --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js @@ -0,0 +1,27 @@ +const app = require('vn-loopback/server/server'); + +describe('ticket sendSms()', () => { + let logId; + + afterAll(async done => { + await app.models.TicketLog.destroyById(logId); + + done(); + }); + + it('should send a message and log it', async() => { + let ctx = {req: {accessToken: {userId: 9}}}; + let id = 11; + let destination = 222222222; + let message = 'this is the message created in a test'; + + let sms = await app.models.Ticket.sendSms(ctx, id, destination, message); + + logId = sms.logId; + + let createdLog = await app.models.TicketLog.findById(logId); + let json = JSON.parse(JSON.stringify(createdLog.newInstance)); + + expect(json.message).toEqual(message); + }); +}); From b46cc205119416b964dc9f51f89efcc68e2febe1 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 17 Jun 2020 14:03:14 +0200 Subject: [PATCH 09/10] Min TLS v1.0 --- Dockerfile | 2 +- db/docker.js | 2 +- gulpfile.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5a65b9b18..a574e61fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update \ ca-certificates \ gnupg2 \ libfontconfig \ - && curl -sL https://deb.nodesource.com/setup_10.x | bash - \ + && curl -sL https://deb.nodesource.com/setup_12.x | bash - \ && apt-get install -y --no-install-recommends \ nodejs \ && apt-get purge -y --auto-remove \ diff --git a/db/docker.js b/db/docker.js index e3f105971..0a221a0be 100644 --- a/db/docker.js +++ b/db/docker.js @@ -54,7 +54,7 @@ module.exports = class Docker { this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort']; } - await this.waitForHealthy(); + if (runChown) await this.wait(); } catch (err) { if (this.isRandom) await this.rm(); diff --git a/gulpfile.js b/gulpfile.js index 6cf75e3fc..b946b48de 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -48,7 +48,7 @@ function backWatch(done) { // XXX: Workaround to avoid nodemon bug // https://github.com/remy/nodemon/issues/1346 - let commands = ['node --inspect ./node_modules/gulp/bin/gulp.js']; + let commands = ['node --tls-min-v1.0 --inspect ./node_modules/gulp/bin/gulp.js']; if (!isWindows) commands.unshift('sleep 1'); nodemon({ @@ -136,7 +136,7 @@ function backTest(done) { const nodemon = require('gulp-nodemon'); nodemon({ - exec: ['node ./node_modules/gulp/bin/gulp.js'], + exec: ['node --tls-min-v1.0 ./node_modules/gulp/bin/gulp.js'], args: ['backTestOnce'], watch: backSources, done: done From 7f3a431ae84f16147fe6737d0cfda3bf26b43288 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 17 Jun 2020 14:07:14 +0200 Subject: [PATCH 10/10] PM2 Min TLS v1.0 --- back/process.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/back/process.yml b/back/process.yml index 41a2fafff..38d2b9eaf 100644 --- a/back/process.yml +++ b/back/process.yml @@ -4,3 +4,4 @@ apps: instances: 1 max_restarts: 3 restart_delay: 15000 + node_args: --tls-min-v1.0