diff --git a/modules/supplier/back/models/bank-entity.js b/modules/supplier/back/models/bank-entity.js new file mode 100644 index 000000000..565c27752 --- /dev/null +++ b/modules/supplier/back/models/bank-entity.js @@ -0,0 +1,11 @@ +module.exports = Self => { + Self.validatesPresenceOf('name', { + message: 'Name cannot be blank' + }); + Self.validatesPresenceOf('bic', { + message: 'Swift / BIC cannot be empty' + }); + Self.validatesUniquenessOf('bic', { + message: 'This BIC already exist.' + }); +}; diff --git a/modules/supplier/back/models/bank-entity.json b/modules/supplier/back/models/bank-entity.json new file mode 100644 index 000000000..c45cd4336 --- /dev/null +++ b/modules/supplier/back/models/bank-entity.json @@ -0,0 +1,29 @@ +{ + "name": "BankEntity", + "base": "VnModel", + "options": { + "mysql": { + "table": "bankEntity" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "bic": { + "type": "String" + }, + "name": { + "type": "String" + } + }, + "relations": { + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + } + } +} \ No newline at end of file