Skip to content

Instantly share code, notes, and snippets.

@ahmadRagheb
Created July 27, 2017 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadRagheb/87496ff5fa7c76b0af71a12caa41a2cb to your computer and use it in GitHub Desktop.
Save ahmadRagheb/87496ff5fa7c76b0af71a12caa41a2cb to your computer and use it in GitHub Desktop.
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