From d4e76bc1db229b8c801829a521e09280dab829ff Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 15 Jul 2013 18:10:51 +0530 Subject: [PATCH] [minor] [transaction] validate exchange rate in calculate taxes and totals --- controllers/accounts_controller.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index 70151a6e3e..7bcc92e118 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -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() @@ -66,7 +61,7 @@ class AccountsController(TransactionBase): "price_list_name": self.doc.price_list_name, "buying_or_selling": buying_or_selling })) - + if self.doc.price_list_currency: if not self.doc.plc_conversion_rate: company_currency = get_company_currency(self.doc.company) @@ -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})