From becbcfa1e6e751d4f6f96233b25f86b7f7da55d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 8 Sep 2020 10:58:52 +0300 Subject: [PATCH] close #1509 Fixed: Items are not shown in Edit Invoice page --- resources/assets/js/views/purchases/bills.js | 14 +++++++++++++- resources/assets/js/views/sales/invoices.js | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/resources/assets/js/views/purchases/bills.js b/resources/assets/js/views/purchases/bills.js index 4c667b778..0e389181d 100644 --- a/resources/assets/js/views/purchases/bills.js +++ b/resources/assets/js/views/purchases/bills.js @@ -46,6 +46,7 @@ const app = new Vue({ edit: { status: false, currency: false, + items: false, }, } }, @@ -54,6 +55,7 @@ const app = new Vue({ if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) { this.colspan = document.getElementById("items").rows[0].cells.length - 1; } + this.form.items = []; if (this.form.method) { @@ -92,6 +94,10 @@ const app = new Vue({ methods: { onChangeContact(contact_id) { + if (!contact_id) { + return; + } + if (this.edit.status && !this.edit.currency) { this.edit.currency = true; @@ -226,7 +232,7 @@ const app = new Vue({ // set global total variable. this.totals.sub = sub_total; - this.totals.tax = tax_total; + this.totals.tax = Math.abs(tax_total); this.totals.item_discount = line_item_discount_total; // Apply discount to total @@ -285,6 +291,12 @@ const app = new Vue({ }, onSelectItem(item, index) { + if (this.edit.status && !this.edit.items) { + this.edit.items = true; + + return; + } + let tax_id = (item.tax_id) ? [item.tax_id.toString()] : ''; this.form.items[index].item_id = item.id; diff --git a/resources/assets/js/views/sales/invoices.js b/resources/assets/js/views/sales/invoices.js index 69403c717..d92434d30 100644 --- a/resources/assets/js/views/sales/invoices.js +++ b/resources/assets/js/views/sales/invoices.js @@ -46,6 +46,7 @@ const app = new Vue({ edit: { status: false, currency: false, + items: false, }, } }, @@ -93,6 +94,10 @@ const app = new Vue({ methods: { onChangeContact(contact_id) { + if (!contact_id) { + return; + } + if (this.edit.status && !this.edit.currency) { this.edit.currency = true; @@ -286,6 +291,12 @@ const app = new Vue({ }, onSelectItem(item, index) { + if (this.edit.status && !this.edit.items) { + this.edit.items = true; + + return; + } + let tax_id = (item.tax_id) ? [item.tax_id.toString()] : ''; this.form.items[index].item_id = item.id;