Merge pull request '3312-ibanRequired' (#772) from 3312-ibanRequired into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #772 Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
commit
d53a07dbf2
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE vn.payMethod CHANGE ibanRequired ibanRequiredForClients tinyint(3) DEFAULT 0 NULL;
|
||||
ALTER TABLE vn.payMethod ADD ibanRequiredForSuppliers tinyint(3) DEFAULT 0 NULL;
|
||||
ALTER TABLE vn.payMethod CHANGE ibanRequiredForSuppliers ibanRequiredForSuppliers tinyint(3) DEFAULT 0 NULL AFTER ibanRequiredForClients;
|
||||
UPDATE vn.payMethod SET ibanRequiredForSuppliers = 1 WHERE code = 'wireTransfer';
|
|
@ -217,14 +217,14 @@ 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`, `ibanRequired`)
|
||||
INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `ibanRequiredForClients`, `ibanRequiredForSuppliers`)
|
||||
VALUES
|
||||
(1, NULL, 'PayMethod one', 0, 001, 0),
|
||||
(2, NULL, 'PayMethod two', 10, 001, 0),
|
||||
(3, 'compensation', 'PayMethod three', 0, 001, 0),
|
||||
(4, NULL, 'PayMethod with IBAN', 0, 001, 1),
|
||||
(5, NULL, 'PayMethod five', 10, 001, 0),
|
||||
(8,'wireTransfer', 'WireTransfer', 5, 001, 1);
|
||||
(1, NULL, 'PayMethod one', 0, 001, 0, 0),
|
||||
(2, NULL, 'PayMethod two', 10, 001, 0, 0),
|
||||
(3, 'compensation', 'PayMethod three', 0, 001, 0, 0),
|
||||
(4, NULL, 'PayMethod with IBAN', 0, 001, 1, 0),
|
||||
(5, NULL, 'PayMethod five', 10, 001, 0, 0),
|
||||
(8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1);
|
||||
|
||||
INSERT INTO `vn`.`payDem`(`id`, `payDem`)
|
||||
VALUES
|
||||
|
|
|
@ -33928,7 +33928,8 @@ CREATE TABLE `payMethod` (
|
|||
`solution` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`outstandingDebt` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000',
|
||||
`graceDays` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`ibanRequired` tinyint(3) DEFAULT '0',
|
||||
`ibanRequiredForClients` tinyint(3) DEFAULT '0',
|
||||
`ibanRequiredForSuppliers` tinyint(3) DEFAULT '0',
|
||||
`isNotified` tinyint(3) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
|
|
@ -129,7 +129,7 @@ module.exports = Self => {
|
|||
|
||||
function hasIban(err, done) {
|
||||
Self.app.models.PayMethod.findById(this.payMethodFk, (_, instance) => {
|
||||
if (instance && instance.ibanRequired && !this.iban)
|
||||
if (instance && instance.ibanRequiredForClients && !this.iban)
|
||||
err();
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
"outstandingDebt": {
|
||||
"type": "Number"
|
||||
},
|
||||
"ibanRequired": {
|
||||
"ibanRequiredForClients": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ibanRequiredForSuppliers": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
vn-acl="salesAssistant"
|
||||
ng-model="$ctrl.client.payMethodFk"
|
||||
data="paymethods"
|
||||
fields="['ibanRequired']"
|
||||
fields="['ibanRequiredForClients']"
|
||||
initial-data="$ctrl.client.payMethod">
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('loopback model Supplier', () => {
|
||||
let supplierOne;
|
||||
let supplierTwo;
|
||||
|
||||
beforeAll(async() => {
|
||||
supplierOne = await app.models.Supplier.findById(1);
|
||||
supplierTwo = await app.models.Supplier.findById(442);
|
||||
supplierOne = await models.Supplier.findById(1);
|
||||
supplierTwo = await models.Supplier.findById(442);
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
|
@ -18,9 +19,9 @@ describe('loopback model Supplier', () => {
|
|||
it('should throw an error when attempting to set an invalid payMethod id in the supplier', async() => {
|
||||
let error;
|
||||
const expectedError = 'You can not select this payment method without a registered bankery account';
|
||||
const supplier = await app.models.Supplier.findById(1);
|
||||
const supplier = await models.Supplier.findById(1);
|
||||
|
||||
await supplier.updateAttribute('payMethodFk', 4)
|
||||
await supplier.updateAttribute('payMethodFk', 8)
|
||||
.catch(e => {
|
||||
error = e;
|
||||
|
||||
|
@ -31,14 +32,27 @@ describe('loopback model Supplier', () => {
|
|||
});
|
||||
|
||||
it('should not throw if the payMethod id is valid', async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
|
||||
let error;
|
||||
const supplier = await app.models.Supplier.findById(442);
|
||||
const supplier = await models.Supplier.findById(442);
|
||||
await supplier.updateAttribute('payMethodFk', 4)
|
||||
.catch(e => {
|
||||
error = e;
|
||||
});
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(error).not.toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,40 +9,40 @@
|
|||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "Number",
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "Number",
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "Number"
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "String",
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "String"
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "Object"
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "Object"
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "Date"
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "String"
|
||||
"type": "string"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "String"
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "String"
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -80,7 +80,7 @@ module.exports = Self => {
|
|||
const supplierAccount = await Self.app.models.SupplierAccount.findOne({where: {supplierFk: this.id}});
|
||||
const hasIban = supplierAccount && supplierAccount.iban;
|
||||
|
||||
if (payMethod && payMethod.ibanRequired && !hasIban)
|
||||
if (payMethod && payMethod.ibanRequiredForSuppliers && !hasIban)
|
||||
err();
|
||||
|
||||
done();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
vn-acl="salesAssistant"
|
||||
ng-model="$ctrl.supplier.payMethodFk"
|
||||
data="paymethods"
|
||||
fields="['ibanRequired']"
|
||||
fields="['ibanRequiredForSuppliers']"
|
||||
initial-data="$ctrl.supplier.payMethod">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
|
|
Loading…
Reference in New Issue