-
-
Save ahmadRagheb/87496ff5fa7c76b0af71a12caa41a2cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var1 = self.doc.get("taxes") | |
for i, tax in enumerate(self.doc.get("taxes")): | |
if i == 0: | |
tax.tax_amount = self.get_rounded_numbo(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) | |
else: | |
tax.tax_amount = self.get_rounded_numbo(tax.tax_amount) | |
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) | |
def get_rounded_numbo(self,n): | |
numbo=float(str(n - int(n))[1:]) | |
numbo_int=int(n) | |
if 0<numbo<=.5: | |
final=numbo_int+.5 | |
elif .5<numbo<1: | |
final=numbo_int+1 | |
return final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment