99 lines
2.1 KiB
JavaScript
99 lines
2.1 KiB
JavaScript
import ngModule from '../../module';
|
|
import Section from 'salix/components/section';
|
|
import './style.scss';
|
|
|
|
class Controller extends Section {
|
|
constructor($element, $) {
|
|
super($element, $);
|
|
this.receipt = {
|
|
payed: new Date(),
|
|
clientFk: this.$params.id,
|
|
companyFk: this.vnConfig.companyFk,
|
|
bankFk: this.vnConfig.bankFk
|
|
};
|
|
}
|
|
|
|
set payed(value) {
|
|
this.receipt.payed = value;
|
|
}
|
|
|
|
set bankFk(value) {
|
|
this.receipt.bankFk = value;
|
|
}
|
|
|
|
set amountPaid(value) {
|
|
this.receipt.amountPaid = value;
|
|
}
|
|
|
|
get amountPaid() {
|
|
return this.receipt.amountPaid;
|
|
}
|
|
|
|
set clientFk(value) {
|
|
this.receipt.clientFk = value;
|
|
}
|
|
|
|
get clientFk() {
|
|
return this.receipt.clientFk;
|
|
}
|
|
|
|
set companyFk(value) {
|
|
this.receipt.companyFk = value;
|
|
this.getAmountPaid();
|
|
}
|
|
|
|
set description(value) {
|
|
this.receipt.description = value;
|
|
}
|
|
|
|
get description() {
|
|
return this.receipt.description;
|
|
}
|
|
|
|
getAmountPaid() {
|
|
let filter = {
|
|
where: {
|
|
clientFk: this.$params.id,
|
|
companyFk: this.receipt.companyFk
|
|
}
|
|
};
|
|
|
|
let query = `ClientRisks?filter=${JSON.stringify(filter)}`;
|
|
this.$http.get(query).then(res => {
|
|
this.receipt.amountPaid = (res.data.length && res.data[0].amount) || null;
|
|
});
|
|
}
|
|
|
|
show() {
|
|
this.$.dialog.show();
|
|
}
|
|
|
|
hide() {
|
|
this.$.dialog.hide();
|
|
}
|
|
|
|
save() {
|
|
let query = `receipts`;
|
|
this.$http.post(query, this.receipt).then(() => {
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
this.hide();
|
|
if (this.onResponse)
|
|
this.onResponse();
|
|
});
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnClientBalanceCreate', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
payed: '<?',
|
|
bankFk: '<?',
|
|
amountPaid: '<?',
|
|
onResponse: '&?',
|
|
companyFk: '<?',
|
|
description: '<?',
|
|
clientFk: '<?'
|
|
}
|
|
});
|