From 6416b0ad799f9abad1cc03e62ae8423bf6ce231c Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 22 Dec 2020 14:56:21 +0100 Subject: [PATCH 1/6] 2666 - Closure invalid email notification --- .../components/descriptor-popover/index.js | 2 ++ .../ticket/front/tracking/index/index.html | 4 +-- modules/worker/front/log/index.html | 8 ++--- modules/worker/front/log/locale/es.yml | 3 +- print/methods/closure.js | 34 +++++++++++++++++++ 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/front/salix/components/descriptor-popover/index.js b/front/salix/components/descriptor-popover/index.js index b746f5c817..3ec5be1aec 100644 --- a/front/salix/components/descriptor-popover/index.js +++ b/front/salix/components/descriptor-popover/index.js @@ -4,6 +4,8 @@ import './style.scss'; export default class DescriptorPopover extends Popover { show(parent, id) { + if (!id) return; + super.show(parent); this.id = id; diff --git a/modules/ticket/front/tracking/index/index.html b/modules/ticket/front/tracking/index/index.html index 42d2197d0f..7cb9431ab4 100644 --- a/modules/ticket/front/tracking/index/index.html +++ b/modules/ticket/front/tracking/index/index.html @@ -23,9 +23,9 @@ {{::tracking.state.name}} - {{::tracking.worker.user.name | dashIfEmpty}} + {{::tracking.worker.user.name || 'System' | translate}} {{::tracking.created | date:'dd/MM/yyyy HH:mm'}} diff --git a/modules/worker/front/log/index.html b/modules/worker/front/log/index.html index bfa60a8c38..b7cf9fc77c 100644 --- a/modules/worker/front/log/index.html +++ b/modules/worker/front/log/index.html @@ -33,7 +33,7 @@ {{::log.user.name | dashIfEmpty}} + translate>{{::log.user.name || 'System' | translate}}
@@ -54,7 +54,7 @@ {{::log.user.name | dashIfEmpty}} + translate>{{::log.user.name || 'System' | translate}} @@ -70,7 +70,7 @@
{{::old.key}}: - {{::old.value}} + {{::old.value | dashIfEmpty}}
@@ -81,7 +81,7 @@ id="newInstance">
{{::new.key}}: - {{::new.value}} + {{::new.value | dashIfEmpty}}
{ SELECT t.id, t.clientFk, + c.name clientName, c.email recipient, c.salesPersonFk, c.isToBeMailed, @@ -196,6 +197,10 @@ module.exports = app => { const email = new Email('delivery-note-link', args); await email.send(); } catch (error) { + // Domain not found + if (error.responseCode == 450) + return invalidEmail(ticket); + // Save tickets on a list of failed ids failedtickets.push({ id: ticket.id, @@ -220,4 +225,33 @@ module.exports = app => { }); } } + + async function invalidEmail(ticket) { + await db.rawSql(`UPDATE client SET email = NULL WHERE id = :clientId`, { + clientId: ticket.clientFk + }); + + const oldInstance = `{"email": "${ticket.recipient}"}`; + const newInstance = `{"email": ""}`; + await db.rawSql(` + INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) + VALUES (:clientId, :userId, 'UPDATE', 'Client', :oldInstance, :newInstance)`, { + clientId: ticket.clientFk, + userId: null, + oldInstance: oldInstance, + newInstance: newInstance + }); + + const body = `No se ha podido enviar el albarán ${ticket.id} + al cliente ${ticket.clientFk} - ${ticket.clientName} + porque la dirección de email "${ticket.recipient}" no es correcta o no está disponible.

+ Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente. + Actualiza la dirección de email con una correcta.`; + + smtp.send({ + to: ticket.salesPersonEmail, + subject: 'No se ha podido enviar el albarán', + html: body + }); + } }; From a19064cb1b6088c491630caced5428081865ceec Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 12:23:37 +0100 Subject: [PATCH 2/6] Nueva tabla entryObservation y he juntado la consulta de 1260-navidad con 1260-holydays --- db/changes/10260-holidays/00-ACL.sql | 3 ++- db/changes/10260-holidays/00-entryObservation.sql | 11 +++++++++++ db/changes/10260-navidad/00-acl.sql | 2 -- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/changes/10260-holidays/00-entryObservation.sql delete mode 100644 db/changes/10260-navidad/00-acl.sql diff --git a/db/changes/10260-holidays/00-ACL.sql b/db/changes/10260-holidays/00-ACL.sql index 1f8045bc7c..e72e6fa73b 100644 --- a/db/changes/10260-holidays/00-ACL.sql +++ b/db/changes/10260-holidays/00-ACL.sql @@ -1 +1,2 @@ -INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES ('Image', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee') \ No newline at end of file +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES ('Image', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('PayDem', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10260-holidays/00-entryObservation.sql b/db/changes/10260-holidays/00-entryObservation.sql new file mode 100644 index 0000000000..f72d64b015 --- /dev/null +++ b/db/changes/10260-holidays/00-entryObservation.sql @@ -0,0 +1,11 @@ +CREATE TABLE `vn`.`entryObservation` ( + id int NOT NULL AUTO_INCREMENT, + entryFk int NOT NULL, + observationTypeFk TINYINT(3) UNSIGNED, + description TEXT, + PRIMARY KEY (id), + CONSTRAINT entry_id_entryFk + FOREIGN KEY (entryFk) REFERENCES entry(id), + CONSTRAINT observationType_id_observationTypeFk + FOREIGN KEY (observationTypeFk) REFERENCES observationType(id) +); \ No newline at end of file diff --git a/db/changes/10260-navidad/00-acl.sql b/db/changes/10260-navidad/00-acl.sql deleted file mode 100644 index 9fba4786b7..0000000000 --- a/db/changes/10260-navidad/00-acl.sql +++ /dev/null @@ -1,2 +0,0 @@ - INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES ('PayDem', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); From 2948747da3497c2f016b74481f84852bc9390243 Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 12:25:12 +0100 Subject: [PATCH 3/6] Seccion nueva, "Note" mas campo entryObservation --- modules/entry/back/model-config.json | 3 + .../entry/back/models/entry-observation.js | 9 +++ .../entry/back/models/entry-observation.json | 38 ++++++++++ modules/entry/front/index.js | 1 + modules/entry/front/note/index.html | 72 +++++++++++++++++++ modules/entry/front/note/index.js | 20 ++++++ modules/entry/front/routes.json | 11 ++- 7 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 modules/entry/back/models/entry-observation.js create mode 100644 modules/entry/back/models/entry-observation.json create mode 100644 modules/entry/front/note/index.html create mode 100644 modules/entry/front/note/index.js diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index 0e37b947ff..eddef9c410 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -7,5 +7,8 @@ }, "EntryLog": { "dataSource": "vn" + }, + "EntryObservation": { + "dataSource": "vn" } } diff --git a/modules/entry/back/models/entry-observation.js b/modules/entry/back/models/entry-observation.js new file mode 100644 index 0000000000..77d15d85c3 --- /dev/null +++ b/modules/entry/back/models/entry-observation.js @@ -0,0 +1,9 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`The observation type can't be repeated`); + return err; + }); +}; diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json new file mode 100644 index 0000000000..87d3fd964c --- /dev/null +++ b/modules/entry/back/models/entry-observation.json @@ -0,0 +1,38 @@ +{ + "name": "EntryObservation", + "base": "Loggable", + "log": { + "model": "EntryLog", + "relation": "entry" + }, + "options": { + "mysql": { + "table": "entryObservation" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + } + }, + "relations": { + "entry": { + "type": "belongsTo", + "model": "Entry", + "foreignKey": "entryFk", + "required": true + }, + "observationType": { + "type": "belongsTo", + "model": "ObservationType", + "foreignKey": "observationTypeFk", + "required": true + } + } +} diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index e92f23fc19..14aecc8dbf 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -10,6 +10,7 @@ import './latest-buys-search-panel'; import './descriptor'; import './descriptor-popover'; import './card'; +import './note'; import './summary'; import './log'; import './buy'; diff --git a/modules/entry/front/note/index.html b/modules/entry/front/note/index.html new file mode 100644 index 0000000000..5f3c7f77e7 --- /dev/null +++ b/modules/entry/front/note/index.html @@ -0,0 +1,72 @@ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/entry/front/note/index.js b/modules/entry/front/note/index.js new file mode 100644 index 0000000000..fccd609137 --- /dev/null +++ b/modules/entry/front/note/index.js @@ -0,0 +1,20 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + }); + } +} + +ngModule.vnComponent('vnEntryObservation', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index a430a95fa7..010e738b30 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -12,6 +12,7 @@ "card": [ {"state": "entry.card.basicData", "icon": "settings"}, {"state": "entry.card.buy", "icon": "icon-lines"}, + {"state": "entry.card.observation", "icon": "insert_drive_file"}, {"state": "entry.card.log", "icon": "history"} ] }, @@ -61,7 +62,15 @@ "params": { "entry": "$ctrl.entry" } - }, { + },{ + "url": "/observation", + "state": "entry.card.observation", + "component": "vn-entry-observation", + "description": "Notes", + "params": { + "entry": "$ctrl.entry" + } + },{ "url" : "/log", "state": "entry.card.log", "component": "vn-entry-log", From a21476e3df80bf6f136df3807280c786d44ad6e0 Mon Sep 17 00:00:00 2001 From: bernat Date: Wed, 23 Dec 2020 12:42:41 +0100 Subject: [PATCH 4/6] fix searchbar index --- db/dump/fixtures.sql | 2 +- e2e/paths/02-client/15_user_config.spec.js | 2 +- modules/route/front/main/index.html | 5 ++--- modules/route/front/main/index.js | 3 ++- modules/ticket/front/main/index.html | 2 +- modules/ticket/front/main/index.js | 2 +- modules/travel/front/main/index.html | 3 ++- modules/travel/front/main/index.js | 8 ++++++++ 8 files changed, 18 insertions(+), 9 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 4ad5321b0d..aa15b774fb 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1638,7 +1638,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES - (1, 2, 69), + (1, 1, 69), (5, 1, 442), (9, 1, 442), (18, 3, 567); diff --git a/e2e/paths/02-client/15_user_config.spec.js b/e2e/paths/02-client/15_user_config.spec.js index 0e18c07add..2954ff522f 100644 --- a/e2e/paths/02-client/15_user_config.spec.js +++ b/e2e/paths/02-client/15_user_config.spec.js @@ -71,7 +71,7 @@ describe('User config', () => { expect(expectedLocalWarehouse).toBeTruthy(); expect(expectedLocalBank).toBeTruthy(); expect(expectedLocalCompany).toBeTruthy(); - expect(userWarehouse).toEqual('Warehouse Two'); + expect(userWarehouse).toEqual('Warehouse One'); expect(userCompany).toEqual('CCs'); }); diff --git a/modules/route/front/main/index.html b/modules/route/front/main/index.html index f0de3f09b3..16243be032 100644 --- a/modules/route/front/main/index.html +++ b/modules/route/front/main/index.html @@ -2,15 +2,14 @@ vn-id="model" url="Routes/filter" limit="20" - order="created DESC" - auto-load="true"> + order="created DESC"> diff --git a/modules/route/front/main/index.js b/modules/route/front/main/index.js index 8aa6552e1d..a6d5bedd1d 100644 --- a/modules/route/front/main/index.js +++ b/modules/route/front/main/index.js @@ -10,7 +10,8 @@ export default class Route extends ModuleMain { let from = new Date(); from.setHours(0, 0, 0, 0); - this.filter = {from, to, warehouseFk: this.vnConfig.warehouseFk}; + this.filterParams = {from, to, warehouseFk: this.vnConfig.warehouseFk}; + this.$.model.applyFilter(null, this.filterParams); } } diff --git a/modules/ticket/front/main/index.html b/modules/ticket/front/main/index.html index 7ea5c86e6e..953dc8a6be 100644 --- a/modules/ticket/front/main/index.html +++ b/modules/ticket/front/main/index.html @@ -11,7 +11,7 @@ info="Search ticket by id or alias" model="model" fetch-params="$ctrl.fetchParams($params)" - suggested-filter="$ctrl.defaultFilter"> + suggested-filter="$ctrl.filterParams"> diff --git a/modules/ticket/front/main/index.js b/modules/ticket/front/main/index.js index 9bbedbcc96..78334ba97c 100644 --- a/modules/ticket/front/main/index.js +++ b/modules/ticket/front/main/index.js @@ -5,7 +5,7 @@ export default class Ticket extends ModuleMain { constructor() { super(); - this.defaultFilter = { + this.filterParams = { scopeDays: 1 }; } diff --git a/modules/travel/front/main/index.html b/modules/travel/front/main/index.html index 56167c6fc1..feb1e8b017 100644 --- a/modules/travel/front/main/index.html +++ b/modules/travel/front/main/index.html @@ -10,7 +10,8 @@ panel="vn-travel-search-panel" info="Search travels by id" model="model" - fetch-params="$ctrl.fetchParams($params)"> + fetch-params="$ctrl.fetchParams($params)" + suggested-filter="$ctrl.filterParams"> diff --git a/modules/travel/front/main/index.js b/modules/travel/front/main/index.js index f04cc750d2..d6f1030338 100644 --- a/modules/travel/front/main/index.js +++ b/modules/travel/front/main/index.js @@ -2,6 +2,14 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Travel extends ModuleMain { + constructor() { + super(); + + this.filterParams = { + scopeDays: 1 + }; + } + fetchParams($params) { if (!Object.entries($params).length) $params.scopeDays = 1; From 3517bdea415feb31b282ced953e66e90f94141ec Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 13:31:55 +0100 Subject: [PATCH 5/6] =?UTF-8?q?A=C3=B1adido=20a=20las=20foreignKeys=20el?= =?UTF-8?q?=20valor=20UNIQUE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/10260-holidays/00-entryObservation.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/changes/10260-holidays/00-entryObservation.sql b/db/changes/10260-holidays/00-entryObservation.sql index f72d64b015..6184cf3bd9 100644 --- a/db/changes/10260-holidays/00-entryObservation.sql +++ b/db/changes/10260-holidays/00-entryObservation.sql @@ -8,4 +8,7 @@ CREATE TABLE `vn`.`entryObservation` ( FOREIGN KEY (entryFk) REFERENCES entry(id), CONSTRAINT observationType_id_observationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES observationType(id) -); \ No newline at end of file +); + +ALTER TABLE `vn`.`entryObservation` +ADD UNIQUE INDEX `entryFk_observationTypeFk_UNIQUE` (`entryFk` ASC,`observationTypeFk` ASC); \ No newline at end of file From 259842c22de493210ffba283a7826ef5fd4a5bf8 Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 23 Dec 2020 13:32:58 +0100 Subject: [PATCH 6/6] Retirado el parametro required por no utilizarse --- modules/entry/back/models/entry-observation.json | 3 +-- modules/ticket/back/models/ticket-observation.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json index 87d3fd964c..535735d839 100644 --- a/modules/entry/back/models/entry-observation.json +++ b/modules/entry/back/models/entry-observation.json @@ -25,8 +25,7 @@ "entry": { "type": "belongsTo", "model": "Entry", - "foreignKey": "entryFk", - "required": true + "foreignKey": "entryFk" }, "observationType": { "type": "belongsTo", diff --git a/modules/ticket/back/models/ticket-observation.json b/modules/ticket/back/models/ticket-observation.json index 51469c7a6c..ba4f85ce8b 100644 --- a/modules/ticket/back/models/ticket-observation.json +++ b/modules/ticket/back/models/ticket-observation.json @@ -25,8 +25,7 @@ "ticket": { "type": "belongsTo", "model": "Ticket", - "foreignKey": "ticketFk", - "required": true + "foreignKey": "ticketFk" }, "observationType": { "type": "belongsTo",