diff --git a/db/changes/10430-ash/00-aclAgency.sql b/db/changes/10430-ash/00-aclAgency.sql
new file mode 100644
index 000000000..8073ee69c
--- /dev/null
+++ b/db/changes/10430-ash/00-aclAgency.sql
@@ -0,0 +1,2 @@
+INSERT INTO salix.ACL (id, model, property, accessType, permission, principalType, principalId)
+ VALUES(304, 'Agency', '*', '*', 'ALLOW', 'ROLE', 'employee');
diff --git a/db/changes/10430-ash/00-aclSupplierAgencyTerms.sql b/db/changes/10430-ash/00-aclSupplierAgencyTerms.sql
new file mode 100644
index 000000000..fbeaa4447
--- /dev/null
+++ b/db/changes/10430-ash/00-aclSupplierAgencyTerms.sql
@@ -0,0 +1,3 @@
+INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
+ VALUES
+ ('SupplierAgencyTerms', '*', '*', 'ALLOW', 'ROLE', 'administrative');
diff --git a/db/changes/10430-ash/00-supplierAgencyTerm.sql b/db/changes/10430-ash/00-supplierAgencyTerm.sql
new file mode 100644
index 000000000..351efd143
--- /dev/null
+++ b/db/changes/10430-ash/00-supplierAgencyTerm.sql
@@ -0,0 +1,27 @@
+ALTER TABLE vn.agencyTerm ADD supplierFk INT NULL;
+ALTER TABLE vn.agencyTerm CHANGE supplierFk supplierFk INT NULL AFTER agencyFk;
+
+UPDATE vn.agencyTerm `at`
+ JOIN vn.agency a ON a.id = `at`.agencyFk
+SET `at`.supplierFk = a.supplierFk;
+
+ALTER TABLE vn.agencyTerm ADD CONSTRAINT agencyTerm_FK FOREIGN KEY (agencyFk) REFERENCES vn.agency(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+ALTER TABLE vn.agencyTerm ADD CONSTRAINT agencyTerm_FK_1 FOREIGN KEY (supplierFk) REFERENCES vn.supplier(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+RENAME TABLE vn.agencyTerm TO vn.supplierAgencyTerm;
+
+CREATE OR REPLACE
+ALGORITHM = UNDEFINED
+DEFINER=`root`@`localhost`
+VIEW `vn`.`agencyTerm` AS
+SELECT
+ `sat`.`agencyFk` AS `agencyFk`,
+ `sat`.`minimumPackages` AS `minimumPackages`,
+ `sat`.`kmPrice` AS `kmPrice`,
+ `sat`.`packagePrice` AS `packagePrice`,
+ `sat`.`routePrice` AS `routePrice`,
+ `sat`.`minimumKm` AS `minimumKm`,
+ `sat`.`minimumM3` AS `minimumM3`,
+ `sat`.`m3Price` AS `m3Price`
+FROM
+ `vn`.`supplierAgencyTerm` `sat`
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index edb937e5f..50a12a094 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -2472,3 +2472,11 @@ INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
INSERT INTO `vn`.`docuwareConfig` (`url`)
VALUES
('https://verdnatura.docuware.cloud/docuware/platform');
+
+INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
+ VALUES
+ (1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23),
+ (2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33),
+ (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0),
+ (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0),
+ (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0);
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 856ee57d8..aa86e8ab6 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -219,5 +219,6 @@
"You can not modify is pay method checked": "No se puede modificar el campo método de pago validado",
"Can't transfer claimed sales": "No puedes transferir lineas reclamadas",
"You don't have privileges to create pay back": "No tienes permisos para crear un abono",
- "The item is required": "El artículo es requerido"
+ "The item is required": "El artículo es requerido",
+ "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo"
}
\ No newline at end of file
diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json
index 7febc17b4..7c1bba1ec 100644
--- a/modules/supplier/back/model-config.json
+++ b/modules/supplier/back/model-config.json
@@ -11,6 +11,9 @@
"SupplierAccount": {
"dataSource": "vn"
},
+ "SupplierAgencyTerm": {
+ "dataSource": "vn"
+ },
"SupplierLog": {
"dataSource": "vn"
},
diff --git a/modules/supplier/back/models/supplier-agency-term.js b/modules/supplier/back/models/supplier-agency-term.js
new file mode 100644
index 000000000..93cee928b
--- /dev/null
+++ b/modules/supplier/back/models/supplier-agency-term.js
@@ -0,0 +1,9 @@
+let UserError = require('vn-loopback/util/user-error');
+
+module.exports = Self => {
+ Self.rewriteDbError(function(err) {
+ if (err.code === 'ER_DUP_ENTRY')
+ return new UserError(`The agency is already assigned to another autonomous`);
+ return err;
+ });
+};
diff --git a/modules/supplier/back/models/supplier-agency-term.json b/modules/supplier/back/models/supplier-agency-term.json
new file mode 100644
index 000000000..dff4c9e8b
--- /dev/null
+++ b/modules/supplier/back/models/supplier-agency-term.json
@@ -0,0 +1,47 @@
+{
+ "name": "SupplierAgencyTerm",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "supplierAgencyTerm"
+ }
+ },
+ "properties": {
+ "agencyFk": {
+ "type": "number",
+ "id": true
+ },
+ "supplierFk": {
+ "type": "number"
+ },
+ "minimumPackages": {
+ "type": "number"
+ },
+ "kmPrice": {
+ "type": "number"
+ },
+ "packagePrice": {
+ "type": "number"
+ },
+ "routePrice": {
+ "type": "number"
+ },
+ "minimumKm": {
+ "type": "number"
+ },
+ "minimumM3": {
+ "type": "number"
+ },
+ "m3Price": {
+ "type": "number"
+ }
+ },
+ "acls": [
+ {
+ "accessType": "EXECUTE",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/modules/supplier/front/agency-term/index.html b/modules/supplier/front/agency-term/index.html
new file mode 100644
index 000000000..5e61e311c
--- /dev/null
+++ b/modules/supplier/front/agency-term/index.html
@@ -0,0 +1,85 @@
+