Rounding Off individual taxes

Hi,

Here in India,We are supposed to round off individual taxes to full rupees.

I have had enough from my accountant and I started to dig into code to see if I can do this.

All tax calculations are done in the controller - taxes_and_totals.

All our transactions are in one currency i.e INR and we dont use “inclusive tax” feature.

Actual calculation of taxes happen in the function “calculate_taxes” in the controller.

I am adding my code at the end of this function and it seems to work fine.

	var1 = self.doc.get("taxes")
	for i, tax in enumerate(self.doc.get("taxes")):
		if i == 0:
			tax.tax_amount = flt(tax.tax_amount,0)
			tax.total = flt(tax.total,0)
			tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount,0)
			tax.base_tax_amount = flt(tax.base_tax_amount,0)
			tax.base_total = flt(tax.base_total,0)
			tax.base_tax_amount_after_discount_amount = flt(tax.base_tax_amount_after_discount_amount,0)
		else:
			tax.tax_amount = flt(tax.tax_amount,0)
			tax.total = var1[i-1].total + tax.tax_amount
			tax.total = flt(tax.total,0)
			tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount,0)
			tax.base_tax_amount = flt(tax.base_tax_amount,0)
			tax.base_total = flt(tax.base_total,0)
			tax.base_tax_amount_after_discount_amount = flt(tax.base_tax_amount_after_discount_amount,0)

Can someone who is interested in rounding off individual tax rounding off test this?

We can add a check box in accounts settings “Round off individual taxes” and if it is ticked we can run this code.

(Your grand total may be wrong, for now please ignore that for now)

2 Likes

i will test it today and tell you what happen , i’m very interested , and i think we should but the check inside the tax itself because there is some countries do it for one tax or to not all the taxes .

It should work for simple case like yours. :+1:
But if you want to contribute back, you have to figure out for all the scenarios like inclusive tax, additional discount etc.

it works after saving the document .

i add a function , so when tax amount fraction > .5 would be 1 and if fraction< .5 its .5

how do apply this to a certain tax not all of them just >???