2974 - Client balance default company and fixes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-06-22 11:57:43 +02:00
parent 7d93f0ac0e
commit 79296ac857
2 changed files with 43 additions and 5 deletions

View File

@ -20,9 +20,8 @@
label="Company"
show-field="code"
value-field="id"
ng-model="$ctrl.receipt.companyFk"
required="true"
rule>
ng-model="$ctrl.companyFk"
required="true">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
@ -78,6 +77,12 @@
on-change="$ctrl.accountShortToStandard(value)">
</vn-textfield>
</vn-vertical>
<vn-horizontal>
<vn-check
label="View receipt"
ng-model="$ctrl.viewReceipt">
</vn-check>
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>

View File

@ -2,9 +2,10 @@ import ngModule from '../../module';
import Dialog from 'core/components/dialog';
class Controller extends Dialog {
constructor($element, $, $transclude) {
constructor($element, $, $transclude, vnReport) {
super($element, $, $transclude);
this.vnReport = vnReport;
this.receipt = {
payed: new Date()
};
@ -31,6 +32,12 @@ class Controller extends Dialog {
return this.receipt.clientFk;
}
get companyFk() {
if (!this.receipt.companyFk)
this.receipt.companyFk = this.vnConfig.companyFk;
return this.receipt.companyFk;
}
set companyFk(value) {
this.receipt.companyFk = value;
this.getAmountPaid();
@ -62,6 +69,22 @@ class Controller extends Dialog {
this.amountToReturn = value - this.receipt.amountPaid;
}
get amountToReturn() {
return this._amountToReturn;
}
set amountToReturn(value) {
if (!value) return;
value = value.toFixed(2);
if (Number.isInteger(value))
value = parseInt(value);
else value = parseFloat(value);
this._amountToReturn = value;
}
get deliveredAmount() {
return this._deliveredAmount;
}
@ -100,10 +123,20 @@ class Controller extends Dialog {
return this.$http.post(`Clients/${this.clientFk}/createReceipt`, this.receipt)
.then(() => super.responseHandler(response))
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
.then(() => {
if (this.viewReceipt) {
this.vnReport.show('receipt', {
receiptId: 1,
companyId: 442
});
}
});
}
}
Controller.$inject = ['$element', '$scope', '$transclude', 'vnReport'];
ngModule.vnComponent('vnClientBalanceCreate', {
slotTemplate: require('./index.html'),
controller: Controller,