2018-10-24 12:10:48 +00:00
|
|
|
import ngModule from '../../module';
|
2020-03-17 13:43:46 +00:00
|
|
|
import Section from 'salix/components/section';
|
2019-02-05 15:46:02 +00:00
|
|
|
import './style.scss';
|
2018-10-24 12:10:48 +00:00
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2018-10-24 12:10:48 +00:00
|
|
|
this.receipt = {
|
|
|
|
payed: new Date(),
|
2020-03-18 07:35:59 +00:00
|
|
|
clientFk: this.$params.id,
|
|
|
|
companyFk: this.vnConfig.companyFk,
|
|
|
|
bankFk: this.vnConfig.bankFk
|
2018-10-24 12:10:48 +00:00
|
|
|
};
|
2019-02-05 15:46:02 +00:00
|
|
|
}
|
2018-10-24 12:10:48 +00:00
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
set payed(value) {
|
|
|
|
this.receipt.payed = value;
|
|
|
|
}
|
2018-10-24 12:10:48 +00:00
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
set bankFk(value) {
|
|
|
|
this.receipt.bankFk = value;
|
|
|
|
}
|
2018-10-24 12:10:48 +00:00
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
set amountPaid(value) {
|
|
|
|
this.receipt.amountPaid = value;
|
|
|
|
}
|
2018-10-24 12:10:48 +00:00
|
|
|
|
2019-04-25 05:57:26 +00:00
|
|
|
get amountPaid() {
|
|
|
|
return this.receipt.amountPaid;
|
|
|
|
}
|
|
|
|
|
|
|
|
set clientFk(value) {
|
|
|
|
this.receipt.clientFk = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
get clientFk() {
|
|
|
|
return this.receipt.clientFk;
|
|
|
|
}
|
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
set companyFk(value) {
|
|
|
|
this.receipt.companyFk = value;
|
|
|
|
this.getAmountPaid();
|
2018-10-24 12:10:48 +00:00
|
|
|
}
|
|
|
|
|
2019-04-25 05:57:26 +00:00
|
|
|
set description(value) {
|
|
|
|
this.receipt.description = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
get description() {
|
|
|
|
return this.receipt.description;
|
|
|
|
}
|
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
getAmountPaid() {
|
2018-10-24 12:10:48 +00:00
|
|
|
let filter = {
|
|
|
|
where: {
|
2020-03-18 07:35:59 +00:00
|
|
|
clientFk: this.$params.id,
|
2018-10-24 12:10:48 +00:00
|
|
|
companyFk: this.receipt.companyFk
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
let query = `ClientRisks?filter=${JSON.stringify(filter)}`;
|
2018-10-24 12:10:48 +00:00
|
|
|
this.$http.get(query).then(res => {
|
|
|
|
this.receipt.amountPaid = (res.data.length && res.data[0].amount) || null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
show() {
|
|
|
|
this.$.dialog.show();
|
2018-10-24 12:10:48 +00:00
|
|
|
}
|
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
hide() {
|
|
|
|
this.$.dialog.hide();
|
2018-10-24 12:10:48 +00:00
|
|
|
}
|
|
|
|
|
2019-02-05 15:46:02 +00:00
|
|
|
save() {
|
2019-10-24 22:53:53 +00:00
|
|
|
let query = `receipts`;
|
2019-02-05 15:46:02 +00:00
|
|
|
this.$http.post(query, this.receipt).then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
|
|
this.hide();
|
|
|
|
if (this.onResponse)
|
|
|
|
this.onResponse();
|
|
|
|
});
|
2018-10-24 12:10:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-25 07:26:42 +00:00
|
|
|
ngModule.component('vnClientBalanceCreate', {
|
2018-10-24 12:10:48 +00:00
|
|
|
template: require('./index.html'),
|
2019-02-05 15:46:02 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
payed: '<?',
|
|
|
|
bankFk: '<?',
|
|
|
|
amountPaid: '<?',
|
|
|
|
onResponse: '&?',
|
2019-04-25 05:57:26 +00:00
|
|
|
companyFk: '<?',
|
|
|
|
description: '<?',
|
|
|
|
clientFk: '<?'
|
2019-02-05 15:46:02 +00:00
|
|
|
}
|
2018-10-24 12:10:48 +00:00
|
|
|
});
|