diff --git a/modules/client/front/balance/create/index.html b/modules/client/front/balance/create/index.html index 89ec3b049..f975b06ba 100644 --- a/modules/client/front/balance/create/index.html +++ b/modules/client/front/balance/create/index.html @@ -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"> @@ -78,6 +77,12 @@ on-change="$ctrl.accountShortToStandard(value)"> + + + + diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 22426a269..95f9d72a8 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -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,