From a5f3580b175fc174a79a7bd3e4a7bb9ca9f9eec4 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 26 May 2022 16:14:10 +0200 Subject: [PATCH] derp --- db/changes/10470-family/00-client.sql | 3 +++ .../back/methods/client/updateFiscalData.js | 4 ++++ modules/client/back/models/client-sample.json | 6 +++--- modules/client/back/models/client.json | 3 +++ modules/client/front/fiscal-data/index.html | 8 ++++++++ modules/client/front/fiscal-data/locale/es.yml | 3 ++- modules/client/front/sample/index/index.html | 6 +++--- modules/client/front/sample/index/index.js | 10 ++-------- print/methods/closure/closeAll.js | 1 + print/methods/closure/closeByAgency.js | 1 + print/methods/closure/closeByRoute.js | 1 + print/methods/closure/closeByTicket.js | 1 + print/methods/closure/closure.js | 11 +++++++++++ .../email/incoterms-authorization/locale/es.yml | 6 +++--- .../incoterms-authorization.html | 16 ---------------- .../incoterms-authorization.js | 2 +- 16 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 db/changes/10470-family/00-client.sql diff --git a/db/changes/10470-family/00-client.sql b/db/changes/10470-family/00-client.sql new file mode 100644 index 000000000..4a39bbdf9 --- /dev/null +++ b/db/changes/10470-family/00-client.sql @@ -0,0 +1,3 @@ +alter table `vn`.`client` + add hasIncoterms tinyint(1) default 0 not null comment 'Received incoterms authorization from client'; + diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index c2de8f927..b4fbe89aa 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -95,6 +95,10 @@ module.exports = Self => { { arg: 'despiteOfClient', type: 'number' + }, + { + arg: 'hasIncoterms', + type: 'boolean' } ], returns: { diff --git a/modules/client/back/models/client-sample.json b/modules/client/back/models/client-sample.json index 920758217..fc64cd949 100644 --- a/modules/client/back/models/client-sample.json +++ b/modules/client/back/models/client-sample.json @@ -32,10 +32,10 @@ "model": "Sample", "foreignKey": "typeFk" }, - "worker": { + "user": { "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" + "model": "Account", + "foreignKey": "userFk" }, "account": { "type": "belongsTo", diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index b9951e8bb..fb59fafec 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -98,6 +98,9 @@ "hasCoreVnh": { "type": "boolean" }, + "hasIncoterms": { + "type": "boolean" + }, "isTaxDataChecked":{ "type": "boolean" }, diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 2249127c5..b3eda2bc0 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -185,6 +185,14 @@ vn-acl="administrative"> + + + + - {{::sample.worker.user.name}} + ng-click="workerDescriptor.show($event, sample.user.id)" + ng-class="{'link': sample.user}"> + {{::sample.user.name || 'System' | translate}} {{::sample.company.code}} diff --git a/modules/client/front/sample/index/index.js b/modules/client/front/sample/index/index.js index 132704de0..7aa44c67f 100644 --- a/modules/client/front/sample/index/index.js +++ b/modules/client/front/sample/index/index.js @@ -12,15 +12,9 @@ class Controller extends Section { fields: ['code', 'description'] } }, { - relation: 'worker', + relation: 'user', scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } + fields: ['id', 'name'] } }, { relation: 'company', diff --git a/print/methods/closure/closeAll.js b/print/methods/closure/closeAll.js index 7af3676f2..400ca2917 100644 --- a/print/methods/closure/closeAll.js +++ b/print/methods/closure/closeAll.js @@ -15,6 +15,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closeByAgency.js b/print/methods/closure/closeByAgency.js index 7807de23a..12e6b4c53 100644 --- a/print/methods/closure/closeByAgency.js +++ b/print/methods/closure/closeByAgency.js @@ -23,6 +23,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closeByRoute.js b/print/methods/closure/closeByRoute.js index 2c0bfd1eb..32a1688d3 100644 --- a/print/methods/closure/closeByRoute.js +++ b/print/methods/closure/closeByRoute.js @@ -17,6 +17,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closeByTicket.js b/print/methods/closure/closeByTicket.js index c71b3ecd0..f6d97cba3 100644 --- a/print/methods/closure/closeByTicket.js +++ b/print/methods/closure/closeByTicket.js @@ -16,6 +16,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closure.js b/print/methods/closure/closure.js index 925eb6f67..92d0c8f24 100644 --- a/print/methods/closure/closure.js +++ b/print/methods/closure/closure.js @@ -94,8 +94,10 @@ module.exports = { const {firstOrder} = await db.findOne(` SELECT COUNT(*) as firstOrder FROM ticket t + JOIN client c ON c.id = t.clientFk WHERE t.clientFk = ? AND NOT t.isDeleted + AND c.isVies `, [ticket.clientFk]); if (firstOrder == 1) { @@ -108,6 +110,15 @@ module.exports = { const email = new Email('incoterms-authorization', args); await email.send(); + + const sample = await db.findOne( + `SELECT id + FROM sample + WHERE code = 'incoterms-authorization'`); + + await db.rawSql(` + INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?) + `, [ticket.clientFk, sample.id, ticket.companyFk]) } } catch (error) { // Domain not found diff --git a/print/templates/email/incoterms-authorization/locale/es.yml b/print/templates/email/incoterms-authorization/locale/es.yml index fe08fb0a8..d0aaf9ab4 100644 --- a/print/templates/email/incoterms-authorization/locale/es.yml +++ b/print/templates/email/incoterms-authorization/locale/es.yml @@ -1,5 +1,5 @@ -subject: Orden de recogida -title: Orden de recogida +subject: Autorización incoterms +title: Autorización incoterms description: dear: Estimado cliente - instructions: Aqui tienes tu orden de recogida. \ No newline at end of file + instructions: A continuación le adjuntamos la autorización incoterms que deberá entregar rellenada y firmada. \ No newline at end of file diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.html b/print/templates/reports/incoterms-authorization/incoterms-authorization.html index 2d8342a47..9f45331bc 100644 --- a/print/templates/reports/incoterms-authorization/incoterms-authorization.html +++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.html @@ -68,22 +68,6 @@

- diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js index 1adc75fa6..5132c0442 100755 --- a/print/templates/reports/incoterms-authorization/incoterms-authorization.js +++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js @@ -3,7 +3,7 @@ const reportHeader = new Component('report-header'); const reportFooter = new Component('report-footer'); module.exports = { - name: 'cmr-authorization', + name: 'incoterms-authorization', async serverPrefetch() { this.ticket = await this.findOneFromDef('ticket', [this.ticketId]); if (!this.ticket)