From a4d556f41e2101183ebca533e68d54b61c85b023 Mon Sep 17 00:00:00 2001 From: Mohit Panjwani Date: Fri, 22 Jan 2021 14:15:44 +0530 Subject: [PATCH] fix tax rounding issues --- resources/assets/js/views/estimates/Create.vue | 11 +++++++---- resources/assets/js/views/estimates/EstimateTax.vue | 6 ++++-- resources/assets/js/views/invoices/Create.vue | 9 ++++++--- resources/assets/js/views/invoices/InvoiceTax.vue | 6 ++++-- resources/assets/js/views/invoices/Tax.vue | 6 ++++-- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/resources/assets/js/views/estimates/Create.vue b/resources/assets/js/views/estimates/Create.vue index 8dd40ab4..0b7f968a 100644 --- a/resources/assets/js/views/estimates/Create.vue +++ b/resources/assets/js/views/estimates/Create.vue @@ -954,12 +954,15 @@ export default { let amount = 0 if (selectedTax.compound_tax && this.subtotalWithDiscount) { - amount = + amount = Math.round( ((this.subtotalWithDiscount + this.totalSimpleTax) * selectedTax.percent) / - 100 + 100 + ) } else if (this.subtotalWithDiscount && selectedTax.percent) { - amount = (this.subtotalWithDiscount * selectedTax.percent) / 100 + amount = Math.round( + (this.subtotalWithDiscount * selectedTax.percent) / 100 + ) } this.newEstimate.taxes.push({ @@ -972,7 +975,7 @@ export default { amount, }) - if (this.$$refs) { + if (this.$refs) { this.$refs.taxModal.close() } }, diff --git a/resources/assets/js/views/estimates/EstimateTax.vue b/resources/assets/js/views/estimates/EstimateTax.vue index 4ffee87a..d374ea7e 100644 --- a/resources/assets/js/views/estimates/EstimateTax.vue +++ b/resources/assets/js/views/estimates/EstimateTax.vue @@ -45,11 +45,13 @@ export default { computed: { taxAmount() { if (this.tax.compound_tax && this.total) { - return ((this.total + this.totalTax) * this.tax.percent) / 100 + return Math.round( + ((this.total + this.totalTax) * this.tax.percent) / 100 + ) } if (this.total && this.tax.percent) { - return (this.total * this.tax.percent) / 100 + return Math.round((this.total * this.tax.percent) / 100) } return 0 diff --git a/resources/assets/js/views/invoices/Create.vue b/resources/assets/js/views/invoices/Create.vue index 0eb23679..97b5b3dc 100644 --- a/resources/assets/js/views/invoices/Create.vue +++ b/resources/assets/js/views/invoices/Create.vue @@ -957,12 +957,15 @@ export default { let amount = 0 if (selectedTax.compound_tax && this.subtotalWithDiscount) { - amount = + amount = Math.round( ((this.subtotalWithDiscount + this.totalSimpleTax) * selectedTax.percent) / - 100 + 100 + ) } else if (this.subtotalWithDiscount && selectedTax.percent) { - amount = (this.subtotalWithDiscount * selectedTax.percent) / 100 + amount = Math.round( + (this.subtotalWithDiscount * selectedTax.percent) / 100 + ) } this.newInvoice.taxes.push({ diff --git a/resources/assets/js/views/invoices/InvoiceTax.vue b/resources/assets/js/views/invoices/InvoiceTax.vue index 4ffee87a..d374ea7e 100644 --- a/resources/assets/js/views/invoices/InvoiceTax.vue +++ b/resources/assets/js/views/invoices/InvoiceTax.vue @@ -45,11 +45,13 @@ export default { computed: { taxAmount() { if (this.tax.compound_tax && this.total) { - return ((this.total + this.totalTax) * this.tax.percent) / 100 + return Math.round( + ((this.total + this.totalTax) * this.tax.percent) / 100 + ) } if (this.total && this.tax.percent) { - return (this.total * this.tax.percent) / 100 + return Math.round((this.total * this.tax.percent) / 100) } return 0 diff --git a/resources/assets/js/views/invoices/Tax.vue b/resources/assets/js/views/invoices/Tax.vue index 680f1e59..51f08c10 100644 --- a/resources/assets/js/views/invoices/Tax.vue +++ b/resources/assets/js/views/invoices/Tax.vue @@ -105,11 +105,13 @@ export default { }, taxAmount() { if (this.tax.compound_tax && this.total) { - return ((this.total + this.totalTax) * this.tax.percent) / 100 + return Math.round( + ((this.total + this.totalTax) * this.tax.percent) / 100 + ) } if (this.total && this.tax.percent) { - return (this.total * this.tax.percent) / 100 + return Math.round((this.total * this.tax.percent) / 100) } return 0