From 012cd68c8988e411818dd57caf9f132c16881d44 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 11 Oct 2022 11:43:01 +0200 Subject: [PATCH 01/24] Added menu to create a new supplier, not working --- modules/supplier/back/methods/supplier/new.js | 28 +++++++++++++++ modules/supplier/back/models/supplier.js | 1 + modules/supplier/front/create/index.html | 36 +++++++++++++++++++ modules/supplier/front/create/index.js | 25 +++++++++++++ modules/supplier/front/index.js | 1 + modules/supplier/front/index/index.html | 7 +++- modules/supplier/front/index/index.js | 5 +++ modules/supplier/front/index/locale/es.yml | 3 +- modules/supplier/front/routes.json | 8 ++++- 9 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 modules/supplier/back/methods/supplier/new.js create mode 100644 modules/supplier/front/create/index.html create mode 100644 modules/supplier/front/create/index.js diff --git a/modules/supplier/back/methods/supplier/new.js b/modules/supplier/back/methods/supplier/new.js new file mode 100644 index 000000000..9fb807532 --- /dev/null +++ b/modules/supplier/back/methods/supplier/new.js @@ -0,0 +1,28 @@ +/* eslint-disable no-console */ +// eslint-disable-next-line no-unused-vars +let UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('new', { + description: 'returns the created item', + accessType: 'WRITE', + accepts: [{ + arg: 'params', + type: 'object', + http: {source: 'body'} + }], + returns: { + type: 'number', + root: true + }, + http: { + path: `/new`, + verb: 'POST' + } + }); + + Self.new = async(params, options) => { + console.log(params); + console.log(options); + }; +}; diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index c9af7b297..a2831845a 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -10,6 +10,7 @@ module.exports = Self => { require('../methods/supplier/freeAgencies')(Self); require('../methods/supplier/campaignMetricsPdf')(Self); require('../methods/supplier/campaignMetricsEmail')(Self); + require('../methods/supplier/new')(Self); Self.validatesPresenceOf('name', { message: 'The social name cannot be empty' diff --git a/modules/supplier/front/create/index.html b/modules/supplier/front/create/index.html new file mode 100644 index 000000000..71fe3b488 --- /dev/null +++ b/modules/supplier/front/create/index.html @@ -0,0 +1,36 @@ + + + + +
+ + + + + + + + + + + + +
diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js new file mode 100644 index 000000000..8708aacd6 --- /dev/null +++ b/modules/supplier/front/create/index.js @@ -0,0 +1,25 @@ +/* eslint-disable no-console */ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + constructor($element, $) { + super($element, $); + console.log($); + } + + onSubmit() { + this.$.watcher.submit().then( + console.log('abc'), + json => this.$state.go('item.card.basicData', {id: json.data.id}) + + ); + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.vnComponent('vnSupplierCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index ba2768854..9216d0781 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -20,3 +20,4 @@ import './address/create'; import './address/edit'; import './agency-term/index'; import './agency-term/create'; +import './create/index'; diff --git a/modules/supplier/front/index/index.html b/modules/supplier/front/index/index.html index 87e822eea..5d29ba0eb 100644 --- a/modules/supplier/front/index/index.html +++ b/modules/supplier/front/index/index.html @@ -58,4 +58,9 @@ - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/modules/supplier/front/index/index.js b/modules/supplier/front/index/index.js index 77b2e8347..b9b43321d 100644 --- a/modules/supplier/front/index/index.js +++ b/modules/supplier/front/index/index.js @@ -10,6 +10,11 @@ export default class Controller extends Section { this.supplierSelected = supplier; this.$.dialogSummarySupplier.show(); } + + test() { + // eslint-disable-next-line no-console + console.log('Creating new supplier'); + } } ngModule.vnComponent('vnSupplierIndex', { diff --git a/modules/supplier/front/index/locale/es.yml b/modules/supplier/front/index/locale/es.yml index ad8a4f0bb..ce06f462c 100644 --- a/modules/supplier/front/index/locale/es.yml +++ b/modules/supplier/front/index/locale/es.yml @@ -2,4 +2,5 @@ Payment deadline: Plazo de pago Pay day: Dia de pago Account: Cuenta Pay method: Metodo de pago -Tax number: Nif \ No newline at end of file +Tax number: Nif +New supplier: Nuevo proveedor \ No newline at end of file diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 61420b40d..03efea0f3 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -30,7 +30,13 @@ "abstract": true, "component": "vn-supplier", "description": "Suppliers" - }, + }, + { + "url": "/create", + "state": "supplier.create", + "component": "vn-supplier-create", + "description": "New supplier" + }, { "url": "/index?q", "state": "supplier.index", From dc6c8f924d902425aad22b959028ab0a039d4f39 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 07:25:25 +0200 Subject: [PATCH 02/24] feat: Create new Supplier --- .../10491-august/00-newSupplier_ACL.sql | 2 + .../00-newSupplier_Modify_supplier.sql | 5 ++ modules/supplier/back/methods/supplier/new.js | 28 ----------- .../back/methods/supplier/newSupplier.js | 50 +++++++++++++++++++ modules/supplier/back/models/supplier.js | 11 ++-- modules/supplier/front/create/index.html | 2 +- modules/supplier/front/create/index.js | 14 ++++-- modules/supplier/front/routes.json | 12 ++--- 8 files changed, 83 insertions(+), 41 deletions(-) create mode 100644 db/changes/10491-august/00-newSupplier_ACL.sql create mode 100644 db/changes/10491-august/00-newSupplier_Modify_supplier.sql delete mode 100644 modules/supplier/back/methods/supplier/new.js create mode 100644 modules/supplier/back/methods/supplier/newSupplier.js diff --git a/db/changes/10491-august/00-newSupplier_ACL.sql b/db/changes/10491-august/00-newSupplier_ACL.sql new file mode 100644 index 000000000..f23f3026b --- /dev/null +++ b/db/changes/10491-august/00-newSupplier_ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model,property,accessType,principalId) + VALUES ('Supplier','newSupplier','WRITE','administrative'); diff --git a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql new file mode 100644 index 000000000..d64cd3663 --- /dev/null +++ b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql @@ -0,0 +1,5 @@ +ALTER TABLE vn.supplier MODIFY COLUMN payMethodFk tinyint(3) unsigned DEFAULT NULL NULL; + +/* ------------------------------------------------------------------------------------------- */ + +ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file diff --git a/modules/supplier/back/methods/supplier/new.js b/modules/supplier/back/methods/supplier/new.js deleted file mode 100644 index 9fb807532..000000000 --- a/modules/supplier/back/methods/supplier/new.js +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-disable no-console */ -// eslint-disable-next-line no-unused-vars -let UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethod('new', { - description: 'returns the created item', - accessType: 'WRITE', - accepts: [{ - arg: 'params', - type: 'object', - http: {source: 'body'} - }], - returns: { - type: 'number', - root: true - }, - http: { - path: `/new`, - verb: 'POST' - } - }); - - Self.new = async(params, options) => { - console.log(params); - console.log(options); - }; -}; diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js new file mode 100644 index 000000000..9fe47fd53 --- /dev/null +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -0,0 +1,50 @@ +/* eslint-disable no-console */ +// eslint-disable-next-line no-unused-vars + +module.exports = Self => { + Self.remoteMethod('newSupplier', { + description: 'returns the created item', + accessType: 'WRITE', + accepts: [{ + arg: 'params', + type: 'object', + http: {source: 'body'} + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/newSupplier`, + verb: 'POST' + } + }); + + Self.newSupplier = async(params, options) => { + const models = Self.app.models; + const myOptions = {}; + + params.payDemFk = 1; + + console.log(params); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const supplier = await models.Supplier.create(params, myOptions); + + if (tx) await tx.commit(); + + return { + supplier + }; + } catch (e) { + console.log(e); + if (tx) await tx.rollback(); + return params; + } + }; +}; diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index a2831845a..6edfe274c 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -10,7 +10,7 @@ module.exports = Self => { require('../methods/supplier/freeAgencies')(Self); require('../methods/supplier/campaignMetricsPdf')(Self); require('../methods/supplier/campaignMetricsEmail')(Self); - require('../methods/supplier/new')(Self); + require('../methods/supplier/newSupplier')(Self); Self.validatesPresenceOf('name', { message: 'The social name cannot be empty' @@ -58,6 +58,9 @@ module.exports = Self => { } async function tinIsValid(err, done) { + if (!this.countryFk) + return done(); + const filter = { fields: ['code'], where: {id: this.countryFk} @@ -81,6 +84,7 @@ module.exports = Self => { }); async function hasSupplierAccount(err, done) { + if (!this.payMethodFk) return done(); const payMethod = await Self.app.models.PayMethod.findById(this.payMethodFk); const supplierAccount = await Self.app.models.SupplierAccount.findOne({where: {supplierFk: this.id}}); const hasIban = supplierAccount && supplierAccount.iban; @@ -93,6 +97,7 @@ module.exports = Self => { } Self.observe('before save', async function(ctx) { + if (ctx.isNewInstance) return; const loopbackContext = LoopBackContext.getCurrentContext(); const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; @@ -102,7 +107,7 @@ module.exports = Self => { const isPayMethodChecked = changes.isPayMethodChecked || orgData.isPayMethodChecked; const hasChanges = orgData && changes; const isPayMethodCheckedChanged = hasChanges - && orgData.isPayMethodChecked != isPayMethodChecked; + && orgData.isPayMethodChecked != isPayMethodChecked; if (isNotFinancial && isPayMethodCheckedChanged) throw new UserError('You can not modify is pay method checked'); @@ -115,7 +120,7 @@ module.exports = Self => { const socialName = changes.name || orgData.name; const hasChanges = orgData && changes; const socialNameChanged = hasChanges - && orgData.socialName != socialName; + && orgData.socialName != socialName; if ((socialNameChanged) && !isAlpha(socialName)) throw new UserError('The social name has an invalid format'); diff --git a/modules/supplier/front/create/index.html b/modules/supplier/front/create/index.html index 71fe3b488..17e424115 100644 --- a/modules/supplier/front/create/index.html +++ b/modules/supplier/front/create/index.html @@ -1,6 +1,6 @@ diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js index 8708aacd6..01b02179b 100644 --- a/modules/supplier/front/create/index.js +++ b/modules/supplier/front/create/index.js @@ -5,14 +5,22 @@ import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); - console.log($); } onSubmit() { this.$.watcher.submit().then( - console.log('abc'), - json => this.$state.go('item.card.basicData', {id: json.data.id}) + json => { + console.log('abc'); + this.$state.go('item.card.basicData', {id: json.data.id}); + console.log('ctrl --> ', this.$.$ctrl); + redirect(this.$.$ctrl); + + async function redirect(ctrl) { + await new Promise(r => setTimeout(r, 100)); + window.location.href = `/#!/supplier/${ctrl.supplier.supplier.id}/fiscal-data`; + } + } ); } } diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 03efea0f3..8c9b7f760 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -31,12 +31,6 @@ "component": "vn-supplier", "description": "Suppliers" }, - { - "url": "/create", - "state": "supplier.create", - "component": "vn-supplier-create", - "description": "New supplier" - }, { "url": "/index?q", "state": "supplier.index", @@ -57,6 +51,12 @@ "params": { "supplier": "$ctrl.supplier" } + }, + { + "url": "/create", + "state": "supplier.create", + "component": "vn-supplier-create", + "description": "New supplier" }, { "url": "/basic-data", From 594cee12f3fd982daf4a8c6a54d327f756e9a25d Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 07:35:02 +0200 Subject: [PATCH 03/24] add checks to the existence of object variables --- modules/supplier/back/models/supplier.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 6edfe274c..44549c65c 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -20,13 +20,17 @@ module.exports = Self => { message: 'The supplier name must be unique' }); - Self.validatesPresenceOf('city', { - message: 'City cannot be empty' - }); + if (this.city) { + Self.validatesPresenceOf('city', { + message: 'City cannot be empty' + }); + } - Self.validatesPresenceOf('nif', { - message: 'The nif cannot be empty' - }); + if (this.nif) { + Self.validatesPresenceOf('nif', { + message: 'The nif cannot be empty' + }); + } Self.validatesUniquenessOf('nif', { message: 'TIN must be unique' From 1603619d812a4330fc073ad42bd9d1c7648a0485 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 07:38:54 +0200 Subject: [PATCH 04/24] removed debugging elements --- modules/supplier/back/methods/supplier/newSupplier.js | 6 ------ modules/supplier/front/create/index.js | 3 --- 2 files changed, 9 deletions(-) diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 9fe47fd53..7cb292871 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -1,6 +1,3 @@ -/* eslint-disable no-console */ -// eslint-disable-next-line no-unused-vars - module.exports = Self => { Self.remoteMethod('newSupplier', { description: 'returns the created item', @@ -26,8 +23,6 @@ module.exports = Self => { params.payDemFk = 1; - console.log(params); - if (!myOptions.transaction) { tx = await Self.beginTransaction({}); myOptions.transaction = tx; @@ -42,7 +37,6 @@ module.exports = Self => { supplier }; } catch (e) { - console.log(e); if (tx) await tx.rollback(); return params; } diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js index 01b02179b..3104d73b5 100644 --- a/modules/supplier/front/create/index.js +++ b/modules/supplier/front/create/index.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import ngModule from '../module'; import Section from 'salix/components/section'; @@ -10,9 +9,7 @@ class Controller extends Section { onSubmit() { this.$.watcher.submit().then( json => { - console.log('abc'); this.$state.go('item.card.basicData', {id: json.data.id}); - console.log('ctrl --> ', this.$.$ctrl); redirect(this.$.$ctrl); From 0cdee89ac31fd380a0b74e8877ef4590da9d305c Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 09:20:45 +0200 Subject: [PATCH 05/24] Button removed when user does not have permissions --- modules/supplier/front/index/index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/supplier/front/index/index.html b/modules/supplier/front/index/index.html index 5d29ba0eb..49f38cb1b 100644 --- a/modules/supplier/front/index/index.html +++ b/modules/supplier/front/index/index.html @@ -59,8 +59,6 @@ supplier="$ctrl.supplierSelected"> - - + \ No newline at end of file From f0b1591b142437b4949cf736c29482697ad8cb0b Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 09:22:50 +0200 Subject: [PATCH 06/24] Remove debugging elements --- modules/supplier/front/index/index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/supplier/front/index/index.js b/modules/supplier/front/index/index.js index b9b43321d..77b2e8347 100644 --- a/modules/supplier/front/index/index.js +++ b/modules/supplier/front/index/index.js @@ -10,11 +10,6 @@ export default class Controller extends Section { this.supplierSelected = supplier; this.$.dialogSummarySupplier.show(); } - - test() { - // eslint-disable-next-line no-console - console.log('Creating new supplier'); - } } ngModule.vnComponent('vnSupplierIndex', { From a4243e14c53a3309125d3caeb5719d0b03ad52f9 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 10:17:56 +0200 Subject: [PATCH 07/24] Created Back test for newSupplier --- .../methods/supplier/specs/newSupplier.spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 modules/supplier/back/methods/supplier/specs/newSupplier.spec.js diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js new file mode 100644 index 000000000..69a32436e --- /dev/null +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -0,0 +1,14 @@ +const app = require('vn-loopback/server/server'); + +describe('Supplier newSupplier()', () => { + const supplier = { + name: 'TestSupplier-1' + }; + + it('should create a new supplier containing only the name', async() => { + const result = await app.models.Supplier.newSupplier(supplier); + + expect(result.payDemFk).toEqual('TestSupplier-1'); + expect(result.payDemFk).toEqual(1); + }); +}); From 70c9c3d78839a30fa6fbb7c78032e99f7cc9589e Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 12:07:34 +0200 Subject: [PATCH 08/24] initial back test created, modified DB statetments --- db/changes/10491-august/00-newSupplier_ACL.sql | 2 +- .../10491-august/00-newSupplier_Modify_supplier.sql | 4 ++-- modules/supplier/back/methods/supplier/newSupplier.js | 10 +++++++++- .../back/methods/supplier/specs/newSupplier.spec.js | 11 ++++++++--- modules/supplier/front/create/index.js | 1 - 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/db/changes/10491-august/00-newSupplier_ACL.sql b/db/changes/10491-august/00-newSupplier_ACL.sql index f23f3026b..c88f3de3f 100644 --- a/db/changes/10491-august/00-newSupplier_ACL.sql +++ b/db/changes/10491-august/00-newSupplier_ACL.sql @@ -1,2 +1,2 @@ -INSERT INTO salix.ACL (model,property,accessType,principalId) +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) VALUES ('Supplier','newSupplier','WRITE','administrative'); diff --git a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql index d64cd3663..660f5e932 100644 --- a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql +++ b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql @@ -1,5 +1,5 @@ -ALTER TABLE vn.supplier MODIFY COLUMN payMethodFk tinyint(3) unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned DEFAULT NULL NULL; /* ------------------------------------------------------------------------------------------- */ -ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file +ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 7cb292871..9d162557c 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -17,10 +17,17 @@ module.exports = Self => { } }); - Self.newSupplier = async(params, options) => { + Self.newSupplier = async params => { const models = Self.app.models; const myOptions = {}; + process.stdout.write(typeof(params)); + + if (typeof(params) == 'string') { + console.log('params was a string, why?'); + params = JSON.parse(params); + } + params.payDemFk = 1; if (!myOptions.transaction) { @@ -38,6 +45,7 @@ module.exports = Self => { }; } catch (e) { if (tx) await tx.rollback(); + params.e = e; return params; } }; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 69a32436e..982a1bb42 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -1,14 +1,19 @@ const app = require('vn-loopback/server/server'); describe('Supplier newSupplier()', () => { - const supplier = { + const newSupp = { name: 'TestSupplier-1' }; it('should create a new supplier containing only the name', async() => { - const result = await app.models.Supplier.newSupplier(supplier); + let result = await app.models.Supplier.newSupplier(JSON.stringify(newSupp)); - expect(result.payDemFk).toEqual('TestSupplier-1'); + expect(result.name).toEqual('TestSupplier-1'); expect(result.payDemFk).toEqual(1); + console.log(result); + + // const createdSupplier = await app.models.Supplier. + + // process.stdout.write(createdSupplier); }); }); diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js index 3104d73b5..bed14c826 100644 --- a/modules/supplier/front/create/index.js +++ b/modules/supplier/front/create/index.js @@ -14,7 +14,6 @@ class Controller extends Section { redirect(this.$.$ctrl); async function redirect(ctrl) { - await new Promise(r => setTimeout(r, 100)); window.location.href = `/#!/supplier/${ctrl.supplier.supplier.id}/fiscal-data`; } } From 9290cd6fb6281f0c1bc704de73fead29ef7342f7 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 17 Oct 2022 14:02:18 +0200 Subject: [PATCH 09/24] Finished back tests --- .../00-newSupplier_Modify_supplier.sql | 6 +++- .../back/methods/supplier/newSupplier.js | 8 ++--- .../supplier/specs/newSupplier.spec.js | 35 +++++++++++++++++-- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql index 660f5e932..29a188480 100644 --- a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql +++ b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql @@ -2,4 +2,8 @@ ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned DEFAUL /* ------------------------------------------------------------------------------------------- */ -ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file +ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; + +/* ------------------------------------------------------------------------------------------- */ + +ALTER TABLE `vn`.`supplierLog` MODIFY COLUMN userFk int(10) unsigned NULL; diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 9d162557c..748d7f5ee 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -21,14 +21,11 @@ module.exports = Self => { const models = Self.app.models; const myOptions = {}; - process.stdout.write(typeof(params)); - - if (typeof(params) == 'string') { - console.log('params was a string, why?'); + if (typeof(params) == 'string') params = JSON.parse(params); - } params.payDemFk = 1; + params.nickname = params.name; if (!myOptions.transaction) { tx = await Self.beginTransaction({}); @@ -45,7 +42,6 @@ module.exports = Self => { }; } catch (e) { if (tx) await tx.rollback(); - params.e = e; return params; } }; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 982a1bb42..a4ccd05ac 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -8,12 +8,41 @@ describe('Supplier newSupplier()', () => { it('should create a new supplier containing only the name', async() => { let result = await app.models.Supplier.newSupplier(JSON.stringify(newSupp)); + result = result.supplier; + expect(result.name).toEqual('TestSupplier-1'); expect(result.payDemFk).toEqual(1); - console.log(result); + expect(result.id).toEqual(443); - // const createdSupplier = await app.models.Supplier. + const createdSupplier = await app.models.Supplier.findById(result.id); - // process.stdout.write(createdSupplier); + expect(createdSupplier.id).toEqual(result.id); + expect(createdSupplier.name).toEqual(result.name); + expect(createdSupplier.account).toBeNull(); + expect(createdSupplier.nif).toBeNull(); + expect(createdSupplier.phone).toBeNull(); + expect(createdSupplier.retAccount).toBeNull(); + expect(createdSupplier.commission).toBeFalse(); + expect(createdSupplier.created).toBeLessThanOrEqual(new Date); + expect(createdSupplier.postcodeFk).toBeNull(); + expect(createdSupplier.isActive).toBeTrue(); + expect(createdSupplier.isOfficial).toBeTrue(); + expect(createdSupplier.isSerious).toBeTrue(); + expect(createdSupplier.note).toBeNull(); + expect(createdSupplier.street).toBeNull(); + expect(createdSupplier.city).toBeNull(); + expect(createdSupplier.provinceFk).toBeNull(); + expect(createdSupplier.postCode).toBeNull(); + expect(createdSupplier.payMethodFk).toBeNull(); + expect(createdSupplier.payDemFk).toEqual(1); + expect(createdSupplier.payDay).toBeNull(); + expect(createdSupplier.nickname).toEqual(result.name); + expect(createdSupplier.workerFk).toBeNull(); + expect(createdSupplier.sageTaxTypeFk).toBeNull(); + expect(createdSupplier.sageTransactionTypeFk).toBeNull(); + expect(createdSupplier.sageWithholdingFk).toBeNull(); + expect(createdSupplier.isPayMethodChecked).toBeFalse(); + expect(createdSupplier.supplierActivityFk).toBeNull(); + expect(createdSupplier.healthRegister).toBeNull(); }); }); From 047076f189097be54cf7dc500d29da8d3aaba1ce Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 07:14:40 +0200 Subject: [PATCH 10/24] changed tests --- .../supplier/back/methods/supplier/specs/newSupplier.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index a4ccd05ac..aacb2d42d 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -23,7 +23,7 @@ describe('Supplier newSupplier()', () => { expect(createdSupplier.phone).toBeNull(); expect(createdSupplier.retAccount).toBeNull(); expect(createdSupplier.commission).toBeFalse(); - expect(createdSupplier.created).toBeLessThanOrEqual(new Date); + expect(createdSupplier.created).toBeDefined(); expect(createdSupplier.postcodeFk).toBeNull(); expect(createdSupplier.isActive).toBeTrue(); expect(createdSupplier.isOfficial).toBeTrue(); From a204c6e2b09738acbf01bc6fd0bd44a1f729ce88 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 12:29:04 +0200 Subject: [PATCH 11/24] Fixed the suppliers not appearing --- .../10491-august/00-defaultPayDem_sameAs_production.sql | 2 ++ .../00-defaultSupplierActivityFk_to_Null.sql | 1 + .../10491-august/00-newSupplier_Modify_supplier.sql | 9 --------- db/changes/10491-august/00-payMethodFk_Allow_Null.sql | 1 + .../10491-august/00-supplierActivityFk_Allow_Null.sql | 1 + modules/supplier/back/methods/supplier/filter.js | 4 ++-- modules/supplier/back/methods/supplier/newSupplier.js | 2 -- .../back/methods/supplier/specs/newSupplier.spec.js | 3 +-- 8 files changed, 8 insertions(+), 15 deletions(-) create mode 100644 db/changes/10491-august/00-defaultPayDem_sameAs_production.sql create mode 100644 db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql delete mode 100644 db/changes/10491-august/00-newSupplier_Modify_supplier.sql create mode 100644 db/changes/10491-august/00-payMethodFk_Allow_Null.sql create mode 100644 db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql diff --git a/db/changes/10491-august/00-defaultPayDem_sameAs_production.sql b/db/changes/10491-august/00-defaultPayDem_sameAs_production.sql new file mode 100644 index 000000000..2a7f5c61f --- /dev/null +++ b/db/changes/10491-august/00-defaultPayDem_sameAs_production.sql @@ -0,0 +1,2 @@ +INSERT INTO vn.payDem (id,payDem) + VALUES (7,'0'); diff --git a/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql b/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql new file mode 100644 index 000000000..1fc4e2905 --- /dev/null +++ b/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql @@ -0,0 +1 @@ +ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; diff --git a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql deleted file mode 100644 index 29a188480..000000000 --- a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned DEFAULT NULL NULL; - -/* ------------------------------------------------------------------------------------------- */ - -ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; - -/* ------------------------------------------------------------------------------------------- */ - -ALTER TABLE `vn`.`supplierLog` MODIFY COLUMN userFk int(10) unsigned NULL; diff --git a/db/changes/10491-august/00-payMethodFk_Allow_Null.sql b/db/changes/10491-august/00-payMethodFk_Allow_Null.sql new file mode 100644 index 000000000..6fd2fee6e --- /dev/null +++ b/db/changes/10491-august/00-payMethodFk_Allow_Null.sql @@ -0,0 +1 @@ +ALTER TABLE vn.supplier MODIFY COLUMN payMethodFk tinyint(3) unsigned NULL; diff --git a/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql new file mode 100644 index 000000000..6f4cdcc39 --- /dev/null +++ b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql @@ -0,0 +1 @@ +ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 'flowersPlants' NULL; diff --git a/modules/supplier/back/methods/supplier/filter.js b/modules/supplier/back/methods/supplier/filter.js index 3500afacd..0b473f7df 100644 --- a/modules/supplier/back/methods/supplier/filter.js +++ b/modules/supplier/back/methods/supplier/filter.js @@ -95,8 +95,8 @@ module.exports = Self => { pm.name AS payMethod, pd.payDem AS payDem FROM vn.supplier s - JOIN vn.payMethod pm ON pm.id = s.payMethodFk - JOIN vn.payDem pd ON pd.id = s.payDemFk` + LEFT JOIN vn.payMethod pm ON pm.id = s.payMethodFk + LEFT JOIN vn.payDem pd ON pd.id = s.payDemFk` ); stmt.merge(conn.makeSuffix(filter)); diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 748d7f5ee..0395e982b 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -24,7 +24,6 @@ module.exports = Self => { if (typeof(params) == 'string') params = JSON.parse(params); - params.payDemFk = 1; params.nickname = params.name; if (!myOptions.transaction) { @@ -42,7 +41,6 @@ module.exports = Self => { }; } catch (e) { if (tx) await tx.rollback(); - return params; } }; }; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index aacb2d42d..b252c4d60 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -11,7 +11,6 @@ describe('Supplier newSupplier()', () => { result = result.supplier; expect(result.name).toEqual('TestSupplier-1'); - expect(result.payDemFk).toEqual(1); expect(result.id).toEqual(443); const createdSupplier = await app.models.Supplier.findById(result.id); @@ -34,7 +33,7 @@ describe('Supplier newSupplier()', () => { expect(createdSupplier.provinceFk).toBeNull(); expect(createdSupplier.postCode).toBeNull(); expect(createdSupplier.payMethodFk).toBeNull(); - expect(createdSupplier.payDemFk).toEqual(1); + expect(createdSupplier.payDemFk).toEqual(7); expect(createdSupplier.payDay).toBeNull(); expect(createdSupplier.nickname).toEqual(result.name); expect(createdSupplier.workerFk).toBeNull(); From 470b4485d59abf4ddcc216986ac233f97af5ebe8 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 12:58:44 +0200 Subject: [PATCH 12/24] Fixed test and DB structure --- .../00-defaultSupplierActivityFk_to_Null.sql | 1 - .../10491-august/00-supplierActivityFk_Allow_Null.sql | 2 +- modules/supplier/back/methods/supplier/newSupplier.js | 1 + .../back/methods/supplier/specs/newSupplier.spec.js | 9 +++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) delete mode 100644 db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql diff --git a/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql b/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql deleted file mode 100644 index 1fc4e2905..000000000 --- a/db/changes/10491-august/00-defaultSupplierActivityFk_to_Null.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; diff --git a/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql index 6f4cdcc39..1fc4e2905 100644 --- a/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql +++ b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql @@ -1 +1 @@ -ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 'flowersPlants' NULL; +ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 0395e982b..6206eaf1c 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -41,6 +41,7 @@ module.exports = Self => { }; } catch (e) { if (tx) await tx.rollback(); + return params; } }; }; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index b252c4d60..8bf271348 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -1,11 +1,20 @@ const app = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); describe('Supplier newSupplier()', () => { const newSupp = { name: 'TestSupplier-1' }; + const administrativeId = 5; it('should create a new supplier containing only the name', async() => { + const activeCtx = { + accessToken: {userId: administrativeId}, + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + let result = await app.models.Supplier.newSupplier(JSON.stringify(newSupp)); result = result.supplier; From db12ceb369556bd7b9652267900fa206354efc4e Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 13:07:10 +0200 Subject: [PATCH 13/24] removed async from the redirect function --- modules/supplier/front/create/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js index bed14c826..7c5a638bf 100644 --- a/modules/supplier/front/create/index.js +++ b/modules/supplier/front/create/index.js @@ -13,7 +13,7 @@ class Controller extends Section { redirect(this.$.$ctrl); - async function redirect(ctrl) { + function redirect(ctrl) { window.location.href = `/#!/supplier/${ctrl.supplier.supplier.id}/fiscal-data`; } } From c2fd1fa44d1b65087d68eea51dfa2fb3bf1cbba6 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 14:22:54 +0200 Subject: [PATCH 14/24] fixed tests --- modules/supplier/back/methods/supplier/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/back/methods/supplier/specs/filter.spec.js b/modules/supplier/back/methods/supplier/specs/filter.spec.js index 1f74b10ff..2620bb687 100644 --- a/modules/supplier/back/methods/supplier/specs/filter.spec.js +++ b/modules/supplier/back/methods/supplier/specs/filter.spec.js @@ -10,7 +10,7 @@ describe('Supplier filter()', () => { let result = await app.models.Supplier.filter(ctx); - expect(result.length).toEqual(1); + expect(result.length).toBeGreaterThanOrEqual(1); expect(result[0].id).toEqual(1); }); From 0b4df19c43a66fdeedbe35aed77d806979ff82a5 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 20 Oct 2022 08:00:46 +0200 Subject: [PATCH 15/24] Fixed E2E tests --- e2e/paths/13-supplier/03_fiscal_data.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index 0238c8704..4f9581e32 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -31,7 +31,7 @@ describe('Supplier fiscal data path', () => { await page.clearInput(selectors.supplierFiscalData.taxNumber); await page.write(selectors.supplierFiscalData.taxNumber, 'Wrong tax number'); await page.clearInput(selectors.supplierFiscalData.account); - await page.write(selectors.supplierFiscalData.account, 'edited account number'); + await page.write(selectors.supplierFiscalData.account, '0123456789'); await page.autocompleteSearch(selectors.supplierFiscalData.sageWihholding, 'retencion estimacion objetiva'); await page.autocompleteSearch(selectors.supplierFiscalData.sageTaxType, 'operaciones no sujetas'); @@ -70,7 +70,7 @@ describe('Supplier fiscal data path', () => { it('should check the account was edited', async() => { const result = await page.waitToGetProperty(selectors.supplierFiscalData.account, 'value'); - expect(result).toEqual('edited account number'); + expect(result).toEqual('0123456789'); }); it('should check the sageWihholding was edited', async() => { From 6a17a634d41a62e5ce3b8fa733736ef407bf315f Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 24 Oct 2022 09:49:51 +0200 Subject: [PATCH 16/24] hotFix(receipt): add receiptPdf --- .../client/back/methods/receipt/receiptPdf.js | 55 +++++++++++++++++++ modules/client/back/models/receipt.js | 1 + modules/client/front/balance/create/index.js | 8 +-- .../client/front/balance/create/index.spec.js | 8 +-- 4 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 modules/client/back/methods/receipt/receiptPdf.js diff --git a/modules/client/back/methods/receipt/receiptPdf.js b/modules/client/back/methods/receipt/receiptPdf.js new file mode 100644 index 000000000..f55e05040 --- /dev/null +++ b/modules/client/back/methods/receipt/receiptPdf.js @@ -0,0 +1,55 @@ +const {Report} = require('vn-print'); + +module.exports = Self => { + Self.remoteMethodCtx('receiptPdf', { + description: 'Returns the receipt pdf', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The claim id', + http: {source: 'path'} + }, + { + arg: 'recipientId', + type: 'number', + description: 'The recipient id', + required: false + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/receipt-pdf', + verb: 'GET' + } + }); + + Self.receiptPdf = async(ctx, id) => { + const args = Object.assign({}, ctx.args); + const params = {lang: ctx.req.getLocale()}; + + delete args.ctx; + for (const param in args) + params[param] = args[param]; + + const report = new Report('receipt', params); + const stream = await report.toPdfStream(); + + return [stream, 'application/pdf', `filename="doc-${id}.pdf"`]; + }; +}; diff --git a/modules/client/back/models/receipt.js b/modules/client/back/models/receipt.js index 36a4a8952..b79102e6b 100644 --- a/modules/client/back/models/receipt.js +++ b/modules/client/back/models/receipt.js @@ -2,6 +2,7 @@ const LoopBackContext = require('loopback-context'); module.exports = function(Self) { require('../methods/receipt/filter')(Self); + require('../methods/receipt/receiptPdf')(Self); Self.validateBinded('amountPaid', isNotZero, { message: 'Amount cannot be zero', diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index c6a6e7ff9..935129574 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -144,12 +144,8 @@ class Controller extends Dialog { }) .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) .then(() => { - if (this.viewReceipt) { - this.vnReport.show('receipt', { - receiptId: receiptId, - companyId: this.companyFk - }); - } + if (this.viewReceipt) + this.vnReport.show(`Receipts/${receiptId}/receipt-pdf`); }); } diff --git a/modules/client/front/balance/create/index.spec.js b/modules/client/front/balance/create/index.spec.js index 77fe32e0f..fa6b48ea4 100644 --- a/modules/client/front/balance/create/index.spec.js +++ b/modules/client/front/balance/create/index.spec.js @@ -85,6 +85,8 @@ describe('Client', () => { }); it('should make an http POST query and then call to the report show() method', () => { + const receiptId = 1; + jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.vnReport, 'show'); window.open = jest.fn(); @@ -92,14 +94,12 @@ describe('Client', () => { controller.$params = {id: 1101}; controller.viewReceipt = true; - $httpBackend.expect('POST', `Clients/1101/createReceipt`).respond({id: 1}); + $httpBackend.expect('POST', `Clients/1101/createReceipt`).respond({id: receiptId}); controller.responseHandler('accept'); $httpBackend.flush(); - const expectedParams = {receiptId: 1, companyId: 442}; - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.vnReport.show).toHaveBeenCalledWith('receipt', expectedParams); + expect(controller.vnReport.show).toHaveBeenCalledWith(`Receipts/${receiptId}/receipt-pdf`); }); }); From a66c5e67984950e8f6fcb11a424af51694ec6f9d Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 24 Oct 2022 11:30:17 +0200 Subject: [PATCH 17/24] acl --- db/changes/10490-august/00-acl_receiptPdf.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/changes/10490-august/00-acl_receiptPdf.sql diff --git a/db/changes/10490-august/00-acl_receiptPdf.sql b/db/changes/10490-august/00-acl_receiptPdf.sql new file mode 100644 index 000000000..42f84b87d --- /dev/null +++ b/db/changes/10490-august/00-acl_receiptPdf.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Receipt', 'receiptPdf', '*', 'ALLOW', 'ROLE', 'salesAssistant'); From e80754f2805dcf06772877456eb9ba55bb14bde4 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 24 Oct 2022 18:37:38 +0200 Subject: [PATCH 18/24] Added new SQL version --- db/changes/10491-august/delete.keep | 0 db/changes/10500-november/00-ACL.sql | 5 ++++ db/changes/10500-november/00-claim.sql | 1 + db/changes/10500-november/00-claimRma.sql | 7 +++++ .../claim/back/methods/claim/getSummary.js | 2 +- modules/claim/back/model-config.json | 9 ++++-- modules/claim/back/models/claim-rma.json | 30 +++++++++++++++++++ modules/claim/back/models/claim.json | 9 ++++++ 8 files changed, 59 insertions(+), 4 deletions(-) delete mode 100644 db/changes/10491-august/delete.keep create mode 100644 db/changes/10500-november/00-ACL.sql create mode 100644 db/changes/10500-november/00-claim.sql create mode 100644 db/changes/10500-november/00-claimRma.sql create mode 100644 modules/claim/back/models/claim-rma.json diff --git a/db/changes/10491-august/delete.keep b/db/changes/10491-august/delete.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/10500-november/00-ACL.sql b/db/changes/10500-november/00-ACL.sql new file mode 100644 index 000000000..0b726538c --- /dev/null +++ b/db/changes/10500-november/00-ACL.sql @@ -0,0 +1,5 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) +VALUES + ('ClaimRma', '*', 'READ', 'ALLOW', 'ROLE', 'claimManager'), + ('ClaimRma', '*', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'); + diff --git a/db/changes/10500-november/00-claim.sql b/db/changes/10500-november/00-claim.sql new file mode 100644 index 000000000..0b9879878 --- /dev/null +++ b/db/changes/10500-november/00-claim.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`claim` ADD rma varchar(100) NULL ; \ No newline at end of file diff --git a/db/changes/10500-november/00-claimRma.sql b/db/changes/10500-november/00-claimRma.sql new file mode 100644 index 000000000..91e1ebaba --- /dev/null +++ b/db/changes/10500-november/00-claimRma.sql @@ -0,0 +1,7 @@ +CREATE TABLE `vn`.`claimRma` ( + id INT UNSIGNED auto_increment NOT NULL PRIMARY KEY, + code varchar(100) NOT NULL, + created timestamp DEFAULT current_timestamp() NOT NULL, + workerFk INTEGER UNSIGNED NOT NULL +) +ENGINE=InnoDB; diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js index 8ab39eb45..ca376f853 100644 --- a/modules/claim/back/methods/claim/getSummary.js +++ b/modules/claim/back/methods/claim/getSummary.js @@ -47,7 +47,7 @@ module.exports = Self => { { relation: 'claimState', scope: { - fields: ['id', 'description'] + fields: ['id', 'code', 'description'] } }, { diff --git a/modules/claim/back/model-config.json b/modules/claim/back/model-config.json index e99a455ac..83d88039c 100644 --- a/modules/claim/back/model-config.json +++ b/modules/claim/back/model-config.json @@ -2,6 +2,9 @@ "Claim": { "dataSource": "vn" }, + "ClaimContainer": { + "dataSource": "claimStorage" + }, "ClaimBeginning": { "dataSource": "vn" }, @@ -41,7 +44,7 @@ "ClaimObservation": { "dataSource": "vn" }, - "ClaimContainer": { - "dataSource": "claimStorage" - } + "ClaimRma": { + "dataSource": "vn" + } } diff --git a/modules/claim/back/models/claim-rma.json b/modules/claim/back/models/claim-rma.json new file mode 100644 index 000000000..24c17a234 --- /dev/null +++ b/modules/claim/back/models/claim-rma.json @@ -0,0 +1,30 @@ +{ + "name": "ClaimRma", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimRma" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "code": { + "type": "string", + "required": true + }, + "created": { + "type": "date" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "worker", + "foreignKey": "workerFk" + } + } +} diff --git a/modules/claim/back/models/claim.json b/modules/claim/back/models/claim.json index a3490ccf4..76125c483 100644 --- a/modules/claim/back/models/claim.json +++ b/modules/claim/back/models/claim.json @@ -46,6 +46,9 @@ }, "packages": { "type": "number" + }, + "rma": { + "type": "string" } }, "relations": { @@ -54,6 +57,12 @@ "model": "ClaimState", "foreignKey": "claimStateFk" }, + "claimRma": { + "type": "belongsTo", + "model": "ClaimRma", + "foreignKey": "rma", + "primaryKey": "code" + }, "client": { "type": "belongsTo", "model": "Client", From 931a891f716da36e72ff7c109df9a8bc7bc08952 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 25 Oct 2022 08:09:23 +0200 Subject: [PATCH 19/24] fix: check client.email exists --- modules/client/back/methods/client/checkDuplicated.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/client/back/methods/client/checkDuplicated.js b/modules/client/back/methods/client/checkDuplicated.js index acaffbf42..522cd088f 100644 --- a/modules/client/back/methods/client/checkDuplicated.js +++ b/modules/client/back/methods/client/checkDuplicated.js @@ -25,10 +25,9 @@ module.exports = Self => { const client = await Self.app.models.Client.findById(id, myOptions); - const emails = client.email ? client.email.split(',') : null; - const findParams = []; - if (emails.length) { + if (client.email) { + const emails = client.email.split(','); for (let email of emails) findParams.push({email: email}); } From 4520443734acaa97fe7286399014e7010b7918fc Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 25 Oct 2022 08:16:56 +0200 Subject: [PATCH 20/24] fix: Intl polyfill for spanish locale --- print/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/print/index.js b/print/index.js index 7ba3586eb..2ed713897 100644 --- a/print/index.js +++ b/print/index.js @@ -7,8 +7,12 @@ const componentsPath = path.resolve(__dirname, './core/components'); module.exports = { async boot(app) { - // Init database instance + // Extended locale intl polyfill + const IntlPolyfill = require('intl'); + Intl.NumberFormat = IntlPolyfill.NumberFormat; + Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat; + // Init database instance require('./core/database').init(app.dataSources); require('./core/smtp').init(); require('./core/cluster').init(); From 9089ba73469f9b75e6248ea08aa0aa5672ea1e7e Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 25 Oct 2022 10:42:16 +0200 Subject: [PATCH 21/24] requested changes --- .../00-defaultPayDem_sameAs_production.sql | 2 +- .../00-payMethodFk_Allow_Null.sql | 2 +- .../00-supplierActivityFk_Allow_Null.sql | 2 +- .../back/methods/supplier/newSupplier.js | 7 +++--- .../supplier/specs/newSupplier.spec.js | 24 ------------------- modules/supplier/front/create/index.html | 7 ------ modules/supplier/front/create/index.js | 8 +------ modules/supplier/front/routes.json | 1 + 8 files changed, 8 insertions(+), 45 deletions(-) diff --git a/db/changes/10491-august/00-defaultPayDem_sameAs_production.sql b/db/changes/10491-august/00-defaultPayDem_sameAs_production.sql index 2a7f5c61f..294247338 100644 --- a/db/changes/10491-august/00-defaultPayDem_sameAs_production.sql +++ b/db/changes/10491-august/00-defaultPayDem_sameAs_production.sql @@ -1,2 +1,2 @@ -INSERT INTO vn.payDem (id,payDem) +INSERT INTO `vn`.`payDem` (id,payDem) VALUES (7,'0'); diff --git a/db/changes/10491-august/00-payMethodFk_Allow_Null.sql b/db/changes/10491-august/00-payMethodFk_Allow_Null.sql index 6fd2fee6e..6d9931d3c 100644 --- a/db/changes/10491-august/00-payMethodFk_Allow_Null.sql +++ b/db/changes/10491-august/00-payMethodFk_Allow_Null.sql @@ -1 +1 @@ -ALTER TABLE vn.supplier MODIFY COLUMN payMethodFk tinyint(3) unsigned NULL; +ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned NULL; \ No newline at end of file diff --git a/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql index 1fc4e2905..62aac0556 100644 --- a/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql +++ b/db/changes/10491-august/00-supplierActivityFk_Allow_Null.sql @@ -1 +1 @@ -ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; +ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 6206eaf1c..a1894af70 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('newSupplier', { - description: 'returns the created item', + description: 'Creates a new supplier and returns it', accessType: 'WRITE', accepts: [{ arg: 'params', @@ -33,12 +33,11 @@ module.exports = Self => { try { const supplier = await models.Supplier.create(params, myOptions); + console.log('supplier: ', supplier); if (tx) await tx.commit(); - return { - supplier - }; + return supplier; } catch (e) { if (tx) await tx.rollback(); return params; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 8bf271348..42012df01 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -26,31 +26,7 @@ describe('Supplier newSupplier()', () => { expect(createdSupplier.id).toEqual(result.id); expect(createdSupplier.name).toEqual(result.name); - expect(createdSupplier.account).toBeNull(); - expect(createdSupplier.nif).toBeNull(); - expect(createdSupplier.phone).toBeNull(); - expect(createdSupplier.retAccount).toBeNull(); - expect(createdSupplier.commission).toBeFalse(); - expect(createdSupplier.created).toBeDefined(); - expect(createdSupplier.postcodeFk).toBeNull(); - expect(createdSupplier.isActive).toBeTrue(); - expect(createdSupplier.isOfficial).toBeTrue(); - expect(createdSupplier.isSerious).toBeTrue(); - expect(createdSupplier.note).toBeNull(); - expect(createdSupplier.street).toBeNull(); - expect(createdSupplier.city).toBeNull(); - expect(createdSupplier.provinceFk).toBeNull(); - expect(createdSupplier.postCode).toBeNull(); - expect(createdSupplier.payMethodFk).toBeNull(); expect(createdSupplier.payDemFk).toEqual(7); - expect(createdSupplier.payDay).toBeNull(); expect(createdSupplier.nickname).toEqual(result.name); - expect(createdSupplier.workerFk).toBeNull(); - expect(createdSupplier.sageTaxTypeFk).toBeNull(); - expect(createdSupplier.sageTransactionTypeFk).toBeNull(); - expect(createdSupplier.sageWithholdingFk).toBeNull(); - expect(createdSupplier.isPayMethodChecked).toBeFalse(); - expect(createdSupplier.supplierActivityFk).toBeNull(); - expect(createdSupplier.healthRegister).toBeNull(); }); }); diff --git a/modules/supplier/front/create/index.html b/modules/supplier/front/create/index.html index 17e424115..446a16cb6 100644 --- a/modules/supplier/front/create/index.html +++ b/modules/supplier/front/create/index.html @@ -5,13 +5,6 @@ insert-mode="true" form="form"> - -
diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js index 7c5a638bf..c33367dac 100644 --- a/modules/supplier/front/create/index.js +++ b/modules/supplier/front/create/index.js @@ -9,13 +9,7 @@ class Controller extends Section { onSubmit() { this.$.watcher.submit().then( json => { - this.$state.go('item.card.basicData', {id: json.data.id}); - - redirect(this.$.$ctrl); - - function redirect(ctrl) { - window.location.href = `/#!/supplier/${ctrl.supplier.supplier.id}/fiscal-data`; - } + this.$state.go(`supplier.card.fiscalData`, {id: json.data.id}); } ); } diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 8c9b7f760..75b8213cb 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -56,6 +56,7 @@ "url": "/create", "state": "supplier.create", "component": "vn-supplier-create", + "acl": ["administrative"], "description": "New supplier" }, { From 330af56d2f9dbfad7fe3291a6b39ac07c3fde5de Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 25 Oct 2022 11:42:28 +0200 Subject: [PATCH 22/24] Intl polyfill --- print/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/print/index.js b/print/index.js index 484aba00e..a71a452c4 100644 --- a/print/index.js +++ b/print/index.js @@ -7,8 +7,12 @@ const componentsPath = path.resolve(__dirname, './core/components'); module.exports = { async boot(app) { - // Init database instance + // Extended locale intl polyfill + const IntlPolyfill = require('intl'); + Intl.NumberFormat = IntlPolyfill.NumberFormat; + Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat; + // Init database instance require('./core/database').init(app.dataSources); require('./core/smtp').init(); require('./core/mixins'); From 296a743d8a70e4a454f307050c48de2667c8592f Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 25 Oct 2022 12:25:56 +0200 Subject: [PATCH 23/24] Fix test, remove console log --- modules/supplier/back/methods/supplier/newSupplier.js | 1 - .../supplier/back/methods/supplier/specs/newSupplier.spec.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index a1894af70..f4059a259 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -33,7 +33,6 @@ module.exports = Self => { try { const supplier = await models.Supplier.create(params, myOptions); - console.log('supplier: ', supplier); if (tx) await tx.commit(); diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 42012df01..8f22a4f20 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -17,8 +17,6 @@ describe('Supplier newSupplier()', () => { let result = await app.models.Supplier.newSupplier(JSON.stringify(newSupp)); - result = result.supplier; - expect(result.name).toEqual('TestSupplier-1'); expect(result.id).toEqual(443); From 4334907d91c50b25cacec31ae33eb106199a4931 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 25 Oct 2022 14:09:21 +0200 Subject: [PATCH 24/24] fix(database): updated sql files --- ...Ticket.sql => 00-ticket_closeByTicket.sql} | 8 +++-- db/dump/fixtures.sql | 34 ++++++++++++------- modules/claim/back/models/claim-rma.js | 9 +++++ modules/claim/back/models/claim-rma.json | 2 +- 4 files changed, 38 insertions(+), 15 deletions(-) rename db/changes/10491-august/{ticket_closeByTicket.sql => 00-ticket_closeByTicket.sql} (85%) create mode 100644 modules/claim/back/models/claim-rma.js diff --git a/db/changes/10491-august/ticket_closeByTicket.sql b/db/changes/10491-august/00-ticket_closeByTicket.sql similarity index 85% rename from db/changes/10491-august/ticket_closeByTicket.sql rename to db/changes/10491-august/00-ticket_closeByTicket.sql index 25b04f629..f378b1146 100644 --- a/db/changes/10491-august/ticket_closeByTicket.sql +++ b/db/changes/10491-august/00-ticket_closeByTicket.sql @@ -1,7 +1,9 @@ drop procedure `vn`.`ticket_closeByTicket`; +DELIMITER $$ +$$ create - definer = root@localhost procedure `vn`.`ticket_closeByTicket`(IN vTicketFk int) + definer = `root`@`localhost` procedure `vn`.`ticket_closeByTicket`(IN vTicketFk int) BEGIN /** @@ -27,5 +29,7 @@ BEGIN CALL ticket_close(); DROP TEMPORARY TABLE tmp.ticket_close; -END; +END$$ +DELIMITER ; + diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7e59c1a54..5b769e285 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1380,13 +1380,6 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'), (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 8', 1, 1, '', ''); -INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) - VALUES - (1101, 500, NULL, 0.00, 0.00, 1.00), - (1102, 1000, 2.00, 0.01, 0.05, 1.00), - (1103, 2000, 0.00, 0.00, 0.02, 1.00), - (1104, 2500, 150.00, 0.02, 0.10, 1.00); - INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`) VALUES ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'), @@ -1743,12 +1736,12 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, ( 6, 'mana', 'Mana', 1, 4, 0), ( 7, 'lack', 'Faltas', 1, 2, 0); -INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`) +INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`) VALUES - (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0), - (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1), - (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5), - (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10); + (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, '02676A049183'), + (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, NULL), + (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, NULL), + (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, NULL); INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`) VALUES @@ -1790,6 +1783,23 @@ INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`) (1, 'Contact description', 50), (2, 'Contact description', 30); +INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) + VALUES + (1101, 500, NULL, 0.00, 0.00, 1.00), + (1102, 1000, 2.00, 0.01, 0.05, 1.00), + (1103, 2000, 0.00, 0.00, 0.02, 1.00), + (1104, 2500, 150.00, 0.02, 0.10, 1.00); + +INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`) +VALUES + (1, '02676A049183', DEFAULT, 1106), + (2, '02676A049183', DEFAULT, 1106), + (3, '02676A049183', DEFAULT, 1107), + (4, '02676A049183', DEFAULT, 1107), + (5, '01837B023653', DEFAULT, 1106); + + + INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `secretKey`) VALUES (1, 'Arkham Bank', 442, 1, 'h12387193H10238'), diff --git a/modules/claim/back/models/claim-rma.js b/modules/claim/back/models/claim-rma.js new file mode 100644 index 000000000..6a93613bd --- /dev/null +++ b/modules/claim/back/models/claim-rma.js @@ -0,0 +1,9 @@ +const LoopBackContext = require('loopback-context'); + +module.exports = Self => { + Self.observe('before save', async function(ctx) { + const changes = ctx.data || ctx.instance; + const loopBackContext = LoopBackContext.getCurrentContext(); + changes.workerFk = loopBackContext.active.accessToken.userId; + }); +}; diff --git a/modules/claim/back/models/claim-rma.json b/modules/claim/back/models/claim-rma.json index 24c17a234..e3849422c 100644 --- a/modules/claim/back/models/claim-rma.json +++ b/modules/claim/back/models/claim-rma.json @@ -23,7 +23,7 @@ "relations": { "worker": { "type": "belongsTo", - "model": "worker", + "model": "Worker", "foreignKey": "workerFk" } }