diff --git a/db/changes/10390-constitution/00-payMethod.sql b/db/changes/10390-constitution/00-payMethod.sql new file mode 100644 index 000000000..6e196af95 --- /dev/null +++ b/db/changes/10390-constitution/00-payMethod.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.payMethod CHANGE ibanRequiredForClients isIbanRequiredForClients tinyint(3) DEFAULT 0 NULL; +ALTER TABLE vn.payMethod CHANGE ibanRequiredForSuppliers isIbanRequiredForSuppliers tinyint(3) DEFAULT 0 NULL; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5b7ac3240..9220da4ef 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -217,7 +217,7 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; -INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `ibanRequiredForClients`, `ibanRequiredForSuppliers`) +INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`) VALUES (1, NULL, 'PayMethod one', 0, 001, 0, 0), (2, NULL, 'PayMethod two', 10, 001, 0, 0), diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index f3591750d..b4961771d 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -138,7 +138,8 @@ module.exports = Self => { function hasIban(err, done) { Self.app.models.PayMethod.findById(this.payMethodFk, (_, instance) => { - if (instance && instance.ibanRequiredForClients && !this.iban) + const isMissingIban = instance && instance.isIbanRequiredForClients && !this.iban; + if (isMissingIban) err(); done(); }); diff --git a/modules/client/back/models/pay-method.json b/modules/client/back/models/pay-method.json index 0666be7a5..4080a0953 100644 --- a/modules/client/back/models/pay-method.json +++ b/modules/client/back/models/pay-method.json @@ -25,10 +25,10 @@ "outstandingDebt": { "type": "Number" }, - "ibanRequiredForClients": { + "isIbanRequiredForClients": { "type": "boolean" }, - "ibanRequiredForSuppliers": { + "isIbanRequiredForSuppliers": { "type": "boolean" } } diff --git a/modules/client/front/billing-data/index.html b/modules/client/front/billing-data/index.html index 8c7c6cfe9..06d7d7d73 100644 --- a/modules/client/front/billing-data/index.html +++ b/modules/client/front/billing-data/index.html @@ -19,7 +19,7 @@ vn-acl="salesAssistant" ng-model="$ctrl.client.payMethodFk" data="paymethods" - fields="['ibanRequiredForClients']" + fields="['isIbanRequiredForClients']" initial-data="$ctrl.client.payMethod"> { 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; + const isMissingIban = payMethod && payMethod.isIbanRequiredForSuppliers && !hasIban; - if (payMethod && payMethod.ibanRequiredForSuppliers && !hasIban) + if (isMissingIban) err(); done(); diff --git a/modules/supplier/front/billing-data/index.html b/modules/supplier/front/billing-data/index.html index c1c57e135..238760c1a 100644 --- a/modules/supplier/front/billing-data/index.html +++ b/modules/supplier/front/billing-data/index.html @@ -24,7 +24,7 @@ vn-acl="salesAssistant" ng-model="$ctrl.supplier.payMethodFk" data="paymethods" - fields="['ibanRequiredForSuppliers']" + fields="['isIbanRequiredForSuppliers']" initial-data="$ctrl.supplier.payMethod">