2021-01-07 14:14:38 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Section from 'salix/components/section';
|
|
|
|
|
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
|
|
|
this.include = {
|
|
|
|
relation: 'bankEntity',
|
|
|
|
scope: {
|
|
|
|
fields: ['countryFk', 'id', 'name', 'bic']
|
|
|
|
}
|
|
|
|
};
|
2021-08-15 06:35:14 +00:00
|
|
|
const filter = {
|
|
|
|
where: {code: 'wireTransfer'}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$http.get(`payMethods/findOne`, {filter})
|
|
|
|
.then(res => {
|
|
|
|
this.wireTransferFk = res.data.id;
|
|
|
|
});
|
2021-01-07 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add() {
|
|
|
|
this.$.model.insert({
|
|
|
|
supplierFk: this.$params.id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-11 17:35:23 +00:00
|
|
|
onResponse(response) {
|
2021-02-17 11:07:04 +00:00
|
|
|
const data = this.$.model.data;
|
|
|
|
const supplierAccount = data[this.currentRowIndex];
|
|
|
|
supplierAccount.bankEntityFk = response.id;
|
2021-01-07 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 11:07:04 +00:00
|
|
|
showBankEntity(event, $index) {
|
2021-01-07 14:14:38 +00:00
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
event.preventDefault();
|
2021-02-17 11:07:04 +00:00
|
|
|
this.currentRowIndex = $index;
|
|
|
|
this.$.bankEntity.open();
|
2021-01-07 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onBankEntityAccept() {
|
|
|
|
const query = `SupplierAccounts/${this.$params.id}/createBankEntity`;
|
|
|
|
return this.$http.patch(query, this.newBankEntity)
|
|
|
|
.then(res => this.supplierAccount.bankEntityFk = res.data.id);
|
|
|
|
}
|
2021-02-11 17:35:23 +00:00
|
|
|
|
2021-08-15 06:35:14 +00:00
|
|
|
onAddSave() {
|
|
|
|
const values = {
|
|
|
|
id: this.$params.id,
|
|
|
|
payMethodFk: this.wireTransferFk
|
|
|
|
};
|
|
|
|
const query = `Suppliers/${this.$params.id}`;
|
|
|
|
return this.$http.patch(query, values)
|
|
|
|
.then(this.$.watcher.notifySaved());
|
|
|
|
}
|
|
|
|
|
2021-02-11 17:35:23 +00:00
|
|
|
onSubmit() {
|
|
|
|
this.$.watcher.check();
|
|
|
|
this.$.model.save().then(() => {
|
2021-08-15 06:35:14 +00:00
|
|
|
if (this.supplier.payMethodFk != this.wireTransferFk)
|
|
|
|
this.$.payMethodToTransfer.show();
|
|
|
|
|
2021-02-11 17:35:23 +00:00
|
|
|
this.$.watcher.notifySaved();
|
|
|
|
this.$.watcher.updateOriginalData();
|
|
|
|
this.card.reload();
|
|
|
|
});
|
|
|
|
}
|
2021-01-07 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnSupplierAccount', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
require: {
|
|
|
|
card: '^vnSupplierCard'
|
|
|
|
}
|
|
|
|
});
|