diff --git a/db/changes/10281-valentineDay/00-supplier.sql b/db/changes/10281-valentineDay/00-supplier.sql new file mode 100644 index 0000000000..c35a86a230 --- /dev/null +++ b/db/changes/10281-valentineDay/00-supplier.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`supplier` ADD COLUMN `workerFk` INT(11) NULL DEFAULT NULL COMMENT 'Responsible for approving invoices' AFTER `isTrucker`; +ALTER TABLE `vn`.`supplier` ADD CONSTRAINT `supplier_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/changes/10281-valentineDay/delete.keep b/db/changes/10281-valentineDay/delete.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 8742c161f1..7c1ee93f00 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1233,11 +1233,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) (104, 500), (105, 5000); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`) VALUES - (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1), - (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8), - (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3); + (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18), + (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18), + (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18); INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) VALUES diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js index e6509eaa24..1148c16cb2 100644 --- a/modules/supplier/back/methods/supplier/getSummary.js +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -42,6 +42,7 @@ module.exports = Self => { 'sageTaxTypeFk', 'sageTransactionTypeFk', 'sageWithholdingFk', + 'workerFk' ], include: [ { @@ -85,7 +86,19 @@ module.exports = Self => { scope: { fields: ['id', 'withholding'] } - } + }, + { + relation: 'worker', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } + }, ] }; let supplier = await Self.app.models.Supplier.findOne(filter); diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index eb3c5989e6..4ec568c8be 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -11,75 +11,78 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String" + "type": "string" }, "account": { - "type": "String" + "type": "string" }, "countryFk": { - "type": "Number" + "type": "number" }, "nif": { - "type": "String" + "type": "string" }, "isFarmer": { - "type": "Boolean" + "type": "boolean" }, "phone": { - "type": "Number" + "type": "number" }, "retAccount": { - "type": "Number" + "type": "number" }, "commission": { - "type": "Boolean" + "type": "boolean" }, "created": { - "type": "Date" + "type": "date" }, "postcodeFk": { - "type": "Number" + "type": "number" }, "isActive": { - "type": "Boolean" + "type": "boolean" }, "isOfficial": { - "type": "Boolean" + "type": "boolean" }, "isSerious": { - "type": "Boolean" + "type": "boolean" }, "note": { - "type": "String" + "type": "string" }, "street": { - "type": "String" + "type": "string" }, "city": { - "type": "String" + "type": "string" }, "provinceFk": { - "type": "Number" + "type": "number" }, "postCode": { - "type": "String" + "type": "string" }, "payMethodFk": { - "type": "Number" + "type": "number" }, "payDemFk": { - "type": "Number" + "type": "number" }, "payDay": { - "type": "Number" + "type": "number" }, "nickname": { - "type": "String" + "type": "string" + }, + "workerFk": { + "type": "number" }, "sageTaxTypeFk": { "type": "number", @@ -126,6 +129,11 @@ "model": "Client", "foreignKey": "nif", "primaryKey": "fi" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" }, "sageTaxType": { "type": "belongsTo", diff --git a/modules/supplier/front/basic-data/index.html b/modules/supplier/front/basic-data/index.html index 72accfb5f3..7d2f801a44 100644 --- a/modules/supplier/front/basic-data/index.html +++ b/modules/supplier/front/basic-data/index.html @@ -15,6 +15,17 @@ rule vn-focus> + + + + + {{$ctrl.summary.worker.user.nickname}} + + diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml index 6afaf857dc..512b75f9d4 100644 --- a/modules/supplier/front/summary/locale/es.yml +++ b/modules/supplier/front/summary/locale/es.yml @@ -6,4 +6,5 @@ Is Farmer: Es agrícola 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 \ No newline at end of file +Go to the supplier: Ir al proveedor +Responsible: Responsable \ No newline at end of file