changes supplier models
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Bernat Exposito Domenech 2020-10-22 13:00:11 +02:00
parent fe2f12cd8f
commit e3757e9191
5 changed files with 42 additions and 18 deletions

View File

@ -186,6 +186,12 @@
"model": "BankEntity",
"foreignKey": "bankEntityFk"
},
"supplier": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "fi",
"primaryKey": "nif"
},
"defaulters": {
"type": "hasMany",
"model": "Defaulter",

View File

@ -20,7 +20,6 @@ module.exports = Self => {
});
Self.isAClient = async nif => {
const client = await Self.app.models.Client.findOne({where: {fi: nif}});
console.log('client', client);
return client;
};
};

View File

@ -96,7 +96,13 @@
"type": "belongsTo",
"model": "Country",
"foreignKey": "countryFk"
}
},
"client": {
"type": "belongsTo",
"model": "Client",
"foreignKey": "fi",
"primaryKey": "nif"
}
},
"acls": [
{

View File

@ -28,6 +28,12 @@ class Controller extends ModuleCard {
scope: {
fields: ['id', 'payDem']
}
},
{
relation: 'client',
scope: {
fields: ['id', 'fi']
}
}
]
};

View File

@ -8,7 +8,8 @@ class Controller extends Descriptor {
set supplier(value) {
this.entity = value;
this.iSupplierAClient();
console.log('this.entity', this.entity);
// this.iSupplierAClient();
}
get entryFilter() {
@ -29,22 +30,22 @@ class Controller extends Descriptor {
to
});
}
iSupplierAClient() {
if (!this.supplier) return;
// iSupplierAClient() {
// if (!this.supplier) return;
const filter = {
where: {fi: this.supplier.nif}
};
this.$http.get('Clients/findOne', {filter}).then(res => {
if (res.data)
this.isAClient = res.data;
}).catch(error => {
return this.isAClient = false;
});
// this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => {
// this.isAClient = res.data;
// });
}
// const filter = {
// where: {fi: this.supplier.nif}
// };
// this.$http.get('Clients/findOne', {filter}).then(res => {
// if (res.data)
// this.isAClient = res.data;
// }).catch(error => {
// return this.isAClient = false;
// });
// // this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => {
// // this.isAClient = res.data;
// // });
// }
loadData() {
const filter = {
@ -72,6 +73,12 @@ class Controller extends Descriptor {
scope: {
fields: ['id', 'payDem']
}
},
{
relation: 'client',
scope: {
fields: ['id', 'fi']
}
}
]
};