[minor] [transaction] validate exchange rate in calculate taxes and totals

This commit is contained in:
Anand Doshi 2013-07-15 18:10:51 +05:30
parent 1ffc5b576c
commit d4e76bc1db

View File

@ -30,11 +30,6 @@ class AccountsController(TransactionBase):
self.validate_date_with_fiscal_year()
if self.meta.get_field("currency"):
self.company_currency = get_company_currency(self.doc.company)
validate_conversion_rate(self.doc.currency, self.doc.conversion_rate,
self.meta.get_label("conversion_rate"), self.doc.company)
self.calculate_taxes_and_totals()
self.validate_value("grand_total", ">=", 0)
self.set_total_in_words()
@ -129,6 +124,14 @@ class AccountsController(TransactionBase):
self.doclist.append(tax)
def calculate_taxes_and_totals(self):
# validate conversion rate
if not self.doc.currency:
self.doc.currency = get_company_currency(self.doc.company)
self.doc.conversion_rate = 1.0
else:
validate_conversion_rate(self.doc.currency, self.doc.conversion_rate,
self.meta.get_label("conversion_rate"), self.doc.company)
self.doc.conversion_rate = flt(self.doc.conversion_rate)
self.item_doclist = self.doclist.get({"parentfield": self.fname})
self.tax_doclist = self.doclist.get({"parentfield": self.other_fname})