From 5211a0d9d7e70a018fa36669f322ad264d3fef94 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 25 Apr 2022 11:51:34 +0200 Subject: [PATCH 1/4] feat(supplier.fiscal-data): add two fields --- db/dump/fixtures.sql | 8 +++---- modules/supplier/back/model-config.json | 3 +++ .../back/models/supplier-activity.json | 18 ++++++++++++++++ modules/supplier/back/models/supplier.json | 11 ++++++++++ modules/supplier/front/fiscal-data/index.html | 21 +++++++++++++++++++ 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 modules/supplier/back/models/supplier-activity.json diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0849e6708..f571dc07e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1332,11 +1332,11 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr (5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'), (6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`) VALUES - (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1), - (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1), - (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants', 1); + (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), + (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) VALUES diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json index 7c1bba1ec..dbc387ed2 100644 --- a/modules/supplier/back/model-config.json +++ b/modules/supplier/back/model-config.json @@ -11,6 +11,9 @@ "SupplierAccount": { "dataSource": "vn" }, + "SupplierActivity": { + "dataSource": "vn" + }, "SupplierAgencyTerm": { "dataSource": "vn" }, diff --git a/modules/supplier/back/models/supplier-activity.json b/modules/supplier/back/models/supplier-activity.json new file mode 100644 index 000000000..7a0b9a537 --- /dev/null +++ b/modules/supplier/back/models/supplier-activity.json @@ -0,0 +1,18 @@ +{ + "name": "SupplierActivity", + "base": "VnModel", + "options": { + "mysql": { + "table": "supplierActivity" + } + }, + "properties": { + "code": { + "type": "string", + "id": true + }, + "name": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 8b4b8f26f..b27073ca5 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -101,6 +101,12 @@ }, "isPayMethodChecked": { "type": "boolean" + }, + "supplierActivityFk": { + "type": "string" + }, + "healthRegister": { + "type": "string" } }, "relations": { @@ -159,6 +165,11 @@ "type": "hasMany", "model": "SupplierAddress", "foreignKey": "supplierFk" + }, + "supplierActivity": { + "type": "belongsTo", + "model": "SupplierActivity", + "foreignKey": "supplierActivityFk" } } } \ No newline at end of file diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html index fc44468f4..a3a634f7d 100644 --- a/modules/supplier/front/fiscal-data/index.html +++ b/modules/supplier/front/fiscal-data/index.html @@ -30,6 +30,11 @@ data="sageWithholdings" order="withholding"> + +
@@ -87,6 +92,22 @@ {{id}}: {{transaction}} + + + + + + Date: Mon, 25 Apr 2022 12:23:03 +0200 Subject: [PATCH 2/4] feat(supllier.summary): add two fields --- db/changes/10451-april/00-aclSupplierActivity.sql | 2 ++ modules/supplier/back/methods/supplier/getSummary.js | 10 +++++++++- .../supplier/back/methods/supplier/updateFiscalData.js | 8 ++++++++ modules/supplier/front/fiscal-data/index.html | 8 ++++---- modules/supplier/front/fiscal-data/locale/es.yml | 2 ++ modules/supplier/front/summary/index.html | 7 +++++++ modules/supplier/front/summary/locale/es.yml | 4 +++- 7 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 db/changes/10451-april/00-aclSupplierActivity.sql diff --git a/db/changes/10451-april/00-aclSupplierActivity.sql b/db/changes/10451-april/00-aclSupplierActivity.sql new file mode 100644 index 000000000..5d91a1357 --- /dev/null +++ b/db/changes/10451-april/00-aclSupplierActivity.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, 'principalId') +VALUES('SupplierActivity', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js index 67f5267b6..ad8417d89 100644 --- a/modules/supplier/back/methods/supplier/getSummary.js +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -41,7 +41,9 @@ module.exports = Self => { 'sageTaxTypeFk', 'sageTransactionTypeFk', 'sageWithholdingFk', - 'workerFk' + 'workerFk', + 'supplierActivityFk', + 'healthRegister' ], include: [ { @@ -98,6 +100,12 @@ module.exports = Self => { } } }, + { + relation: 'supplierActivity', + scope: { + fields: ['code', 'name'] + } + } ] }; let supplier = await Self.app.models.Supplier.findOne(filter); diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index daa602af0..4604b3f91 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -56,6 +56,14 @@ module.exports = Self => { { arg: 'countryFk', type: 'any' + }, + { + arg: 'supplierActivityFk', + type: 'string' + }, + { + arg: 'healthRegister', + type: 'string' }], returns: { arg: 'res', diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html index a3a634f7d..ea42aed20 100644 --- a/modules/supplier/front/fiscal-data/index.html +++ b/modules/supplier/front/fiscal-data/index.html @@ -32,8 +32,8 @@ + url="SupplierActivities" + data="supplierActivities"> @@ -95,8 +95,8 @@ diff --git a/modules/supplier/front/fiscal-data/locale/es.yml b/modules/supplier/front/fiscal-data/locale/es.yml index 8b98a91af..4cb537198 100644 --- a/modules/supplier/front/fiscal-data/locale/es.yml +++ b/modules/supplier/front/fiscal-data/locale/es.yml @@ -1,3 +1,5 @@ Sage tax type: Tipo de impuesto Sage Sage transaction type: Tipo de transacción Sage Sage withholding: Retención Sage +Supplier activity: Actividad proveedor +Healt register: Pasaporte sanitario diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html index 51ebde695..161c7081c 100644 --- a/modules/supplier/front/summary/index.html +++ b/modules/supplier/front/summary/index.html @@ -118,6 +118,13 @@ label="Sage withholding" value="{{::$ctrl.summary.sageWithholding.withholding}}"> + + + diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml index 512b75f9d..35291e579 100644 --- a/modules/supplier/front/summary/locale/es.yml +++ b/modules/supplier/front/summary/locale/es.yml @@ -7,4 +7,6 @@ Sage tax type: Tipo de impuesto Sage Sage transaction type: Tipo de transacción Sage Sage withholding: Retencion Sage Go to the supplier: Ir al proveedor -Responsible: Responsable \ No newline at end of file +Responsible: Responsable +Supplier activity: Actividad proveedor +Healt register: Pasaporte sanitario \ No newline at end of file From 39f4c4a6e867d7a8eddc2ba0ecacdcd6e20ec0b2 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 25 Apr 2022 12:36:05 +0200 Subject: [PATCH 3/4] feat: updated backTest --- db/changes/10451-april/00-aclSupplierActivity.sql | 2 +- .../back/methods/supplier/specs/updateFiscalData.spec.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/changes/10451-april/00-aclSupplierActivity.sql b/db/changes/10451-april/00-aclSupplierActivity.sql index 5d91a1357..1892704ab 100644 --- a/db/changes/10451-april/00-aclSupplierActivity.sql +++ b/db/changes/10451-april/00-aclSupplierActivity.sql @@ -1,2 +1,2 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, 'principalId') +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES('SupplierActivity', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js index 0eec54926..a47e547d1 100644 --- a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js +++ b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js @@ -66,6 +66,8 @@ describe('Supplier updateFiscalData', () => { city: 'VALENCIA', provinceFk: 2, countryFk: 1, + supplierActivityFk: 'animals', + healthRegister: '400664487H' }; const result = await app.models.Supplier.updateFiscalData(ctx, supplierId); @@ -80,6 +82,8 @@ describe('Supplier updateFiscalData', () => { expect(result.city).toEqual('VALENCIA'); expect(result.provinceFk).toEqual(2); expect(result.countryFk).toEqual(1); + expect(result.supplierActivityFk).toEqual('animals'); + expect(result.healthRegister).toEqual('400664487H'); // Restores ctx.args = defaultData; From 40bcc567584d8b6ee4324dd7e85d1c4bc80a8296 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 16 May 2022 07:22:01 +0200 Subject: [PATCH 4/4] refactor: change acl --- db/changes/10451-april/00-aclSupplierActivity.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/changes/10451-april/00-aclSupplierActivity.sql b/db/changes/10451-april/00-aclSupplierActivity.sql index 1892704ab..bf73a1506 100644 --- a/db/changes/10451-april/00-aclSupplierActivity.sql +++ b/db/changes/10451-april/00-aclSupplierActivity.sql @@ -1,2 +1,5 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) -VALUES('SupplierActivity', '*', '*', 'ALLOW', 'ROLE', 'employee'); +VALUES('SupplierActivity', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) +VALUES('SupplierActivity', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');