diff --git a/resources/assets/js/components/AkauntingConnectTransactions.vue b/resources/assets/js/components/AkauntingConnectTransactions.vue index 3b4b33078..0978c75a8 100644 --- a/resources/assets/js/components/AkauntingConnectTransactions.vue +++ b/resources/assets/js/components/AkauntingConnectTransactions.vue @@ -171,7 +171,7 @@
@@ -320,9 +320,45 @@ export default { }, transaction_amount: "", money: {}, + totalAmount: 0, + differenceAmount: 0, }; }, + created() { + this.totalAmount = this.total_amount; + this.differenceAmount = this.difference_amount; + }, + + computed: { + total_amount: function () { + let amount = 0; + + this.form.items.forEach(function(item) { + amount += this.convertMoneyToFloat(item.amount); + }, this); + + this.totalAmount = parseFloat(amount.toFixed(this.currency.precision)); + + return parseFloat(amount.toFixed(this.currency.precision)); + }, + + difference_amount: function () { + if (! this.transaction_amount) { + this.differenceAmount = 0; + + return 0; + } + + let transaction_amount = this.convertMoneyToFloat(this.transaction_amount); + let amount = parseFloat((this.total_amount - transaction_amount).toFixed(this.currency.precision)); + + this.differenceAmount = amount; + + return amount; + } + }, + mounted() { window.addEventListener('keyup',(e) => { if (e.key === 'Escape') { @@ -418,9 +454,11 @@ export default { this.form.items = []; } }, + transaction: function (transaction) { this.transaction_amount = transaction.amount; }, + currency: function (currency) { this.money = { decimal: currency.decimal_mark, @@ -431,26 +469,5 @@ export default { }; } }, - - computed: { - total_amount: function () { - let amount = 0; - - this.form.items.forEach(function(item) { - amount += this.convertMoneyToFloat(item.amount); - }, this); - - return parseFloat(amount.toFixed(this.currency.precision)); - }, - difference_amount: function () { - if (!this.transaction_amount) { - return 0; - } - - let transaction_amount = this.convertMoneyToFloat(this.transaction_amount); - - return parseFloat((this.total_amount - transaction_amount).toFixed(this.currency.precision)); - } - }, }