document fixed tax and discount calculation..
This commit is contained in:
parent
6892947149
commit
5a280becd1
17
resources/assets/js/views/common/documents.js
vendored
17
resources/assets/js/views/common/documents.js
vendored
@ -69,13 +69,14 @@ const app = new Vue({
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onCalculateTotal() {
|
onCalculateTotal() {
|
||||||
let global_discount = this.form.discount;
|
let global_discount = parseFloat(this.form.discount);
|
||||||
let discount_total = 0;
|
let discount_total = 0;
|
||||||
let line_item_discount_total = 0;
|
let line_item_discount_total = 0;
|
||||||
let taxes = document_taxes;
|
let taxes = document_taxes;
|
||||||
let sub_total = 0;
|
let sub_total = 0;
|
||||||
let totals_taxes = [];
|
let totals_taxes = [];
|
||||||
let grand_total = 0;
|
let grand_total = 0;
|
||||||
|
let inclusive_tax_total = 0;
|
||||||
|
|
||||||
// items calculate
|
// items calculate
|
||||||
this.items.forEach(function(item, index) {
|
this.items.forEach(function(item, index) {
|
||||||
@ -165,16 +166,17 @@ const app = new Vue({
|
|||||||
inclusive_total += inclusive.tax_rate;
|
inclusive_total += inclusive.tax_rate;
|
||||||
|
|
||||||
// tax price
|
// tax price
|
||||||
item.tax_ids[inclusive.tax_index].price = item.grand_total- (item.grand_total / (1 + inclusive.tax_rate / 100));
|
item.tax_ids[inclusive.tax_index].price = item.grand_total - (item.grand_total / (1 + inclusive.tax_rate / 100));
|
||||||
|
|
||||||
totals_taxes = this.calculateTotalsTax(totals_taxes, inclusive.tax_id, inclusive.tax_name, item.tax_ids[inclusive.tax_index].price);
|
totals_taxes = this.calculateTotalsTax(totals_taxes, inclusive.tax_id, inclusive.tax_name, item.tax_ids[inclusive.tax_index].price);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
let item_base_rate = item.grand_total / (1 + inclusive_total / 100);
|
let item_base_rate = parseFloat(item.grand_total / (1 + inclusive_total / 100));
|
||||||
|
|
||||||
//item.grand_total = item.grand_total + item_base_rate;
|
//item.grand_total = item.grand_total + item_base_rate;
|
||||||
|
|
||||||
item.total = item_base_rate + item_discount;
|
item.total = item_base_rate;
|
||||||
|
|
||||||
|
inclusive_tax_total += parseFloat(item.grand_total - item.total);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compounds.length) {
|
if (compounds.length) {
|
||||||
@ -192,7 +194,6 @@ const app = new Vue({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// set item total
|
// set item total
|
||||||
if (item.discount) {
|
if (item.discount) {
|
||||||
item.grand_total = item_discounted_total;
|
item.grand_total = item_discounted_total;
|
||||||
@ -213,11 +214,11 @@ const app = new Vue({
|
|||||||
|
|
||||||
// Apply discount to total
|
// Apply discount to total
|
||||||
if (global_discount) {
|
if (global_discount) {
|
||||||
discount_total = sub_total * (global_discount / 100);
|
discount_total = parseFloat(sub_total + inclusive_tax_total) * (global_discount / 100);
|
||||||
|
|
||||||
this.totals.discount = discount_total;
|
this.totals.discount = discount_total;
|
||||||
|
|
||||||
grand_total = sub_total - (sub_total * (global_discount / 100));
|
grand_total -= discount_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.totals.item_discount = line_item_discount_total;
|
this.totals.item_discount = line_item_discount_total;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user