From 5cf2961998f46a232de86a4eaf180cfc8bbb6ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 27 Jul 2022 12:53:25 +0300 Subject: [PATCH] Fixed document item change tax ( #363ax08 ) --- resources/assets/js/views/common/documents.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index cb52d67d6..0c791449e 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -163,10 +163,17 @@ const app = new Vue({ sub_total += item.total; grand_total += item.grand_total; + let item_tax_ids = []; + + item.tax_ids.forEach(function(item_tax, item_tax_index) { + item_tax_ids.push(item_tax.id); + }); + this.form.items[index].name = item.name; this.form.items[index].description = item.description; this.form.items[index].quantity = item.quantity; this.form.items[index].price = item.price; + this.form.items[index].tax_ids = item_tax_ids; this.form.items[index].discount = item.discount; this.form.items[index].discount_type = item.discount_type; this.form.items[index].total = item.total; @@ -263,6 +270,7 @@ const app = new Vue({ if (inclusives.length) { inclusives.forEach(function(inclusive) { + item.tax_ids[inclusive.tax_index].name = inclusive.tax_name; item.tax_ids[inclusive.tax_index].price = item.grand_total - (item.grand_total / (1 + inclusive.tax_rate / 100)); inclusive_tax_total += item.tax_ids[inclusive.tax_index].price; @@ -275,6 +283,7 @@ const app = new Vue({ if (fixed.length) { fixed.forEach(function(fixed) { + item.tax_ids[fixed.tax_index].name = fixed.tax_name; item.tax_ids[fixed.tax_index].price = fixed.tax_rate * item.quantity; total_tax_amount += item.tax_ids[fixed.tax_index].price; @@ -291,6 +300,7 @@ const app = new Vue({ if (normal.length) { normal.forEach(function(normal) { + item.tax_ids[normal.tax_index].name = normal.tax_name; item.tax_ids[normal.tax_index].price = price_for_tax * (normal.tax_rate / 100); total_tax_amount += item.tax_ids[normal.tax_index].price; @@ -301,6 +311,7 @@ const app = new Vue({ if (withholding.length) { withholding.forEach(function(withholding) { + item.tax_ids[withholding.tax_index].name = withholding.tax_name; item.tax_ids[withholding.tax_index].price = -(price_for_tax * (withholding.tax_rate / 100)); total_tax_amount += item.tax_ids[withholding.tax_index].price; @@ -313,6 +324,7 @@ const app = new Vue({ if (compounds.length) { compounds.forEach(function(compound) { + item.tax_ids[compound.tax_index].name = compound.tax_name; item.tax_ids[compound.tax_index].price = (item.grand_total / 100) * compound.tax_rate; totals_taxes = this.calculateTotalsTax(totals_taxes, compound.tax_id, compound.tax_name, item.tax_ids[compound.tax_index].price); @@ -449,6 +461,7 @@ const app = new Vue({ }, onSelectedTax(item_index) { + if (! this.tax_id) { return; } @@ -477,6 +490,7 @@ const app = new Vue({ } this.tax_id = ''; + this.items[item_index].add_tax = false; this.onCalculateTotal(); },