diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index b4c81df7c3..5d91426b22 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -261,15 +261,19 @@ class PurchaseInvoice(BuyingController): gl_entries = [] # parent's gl entry - if self.base_grand_total: + if self.grand_total: + # Didnot use base_grand_total to book rounding loss gle + grand_total_in_company_currency = flt(self.grand_total * self.conversion_rate, + self.precision("grand_total")) + gl_entries.append( self.get_gl_dict({ "account": self.credit_to, "party_type": "Supplier", "party": self.supplier, "against": self.against_expense_account, - "credit": self.base_grand_total, - "credit_in_account_currency": self.base_grand_total \ + "credit": grand_total_in_company_currency, + "credit_in_account_currency": grand_total_in_company_currency \ if self.party_account_currency==self.company_currency else self.grand_total, "against_voucher": self.return_against if cint(self.is_return) else self.name, "against_voucher_type": self.doctype, diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index a0ce980bcc..e87794a979 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -531,14 +531,18 @@ class SalesInvoice(SellingController): def make_customer_gl_entry(self, gl_entries): if self.grand_total: + # Didnot use base_grand_total to book rounding loss gle + grand_total_in_company_currency = flt(self.grand_total * self.conversion_rate, + self.precision("grand_total")) + gl_entries.append( self.get_gl_dict({ "account": self.debit_to, "party_type": "Customer", "party": self.customer, "against": self.against_income_account, - "debit": self.base_grand_total, - "debit_in_account_currency": self.base_grand_total \ + "debit": grand_total_in_company_currency, + "debit_in_account_currency": grand_total_in_company_currency \ if self.party_account_currency==self.company_currency else self.grand_total, "against_voucher": self.return_against if cint(self.is_return) else self.name, "against_voucher_type": self.doctype diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index 49a7bd0fd6..64882886d4 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -141,6 +141,8 @@ def make_round_off_gle(gl_map, debit_credit_diff): round_off_gle.update({ "account": round_off_account, + "debit_in_account_currency": abs(debit_credit_diff) if debit_credit_diff < 0 else 0, + "credit_in_account_currency": debit_credit_diff if debit_credit_diff > 0 else 0, "debit": abs(debit_credit_diff) if debit_credit_diff < 0 else 0, "credit": debit_credit_diff if debit_credit_diff > 0 else 0, "cost_center": round_off_cost_center, diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index b5b3e53412..6a0b3c025f 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -408,8 +408,9 @@ class calculate_taxes_and_totals(object): total_amount_to_pay = flt(self.doc.grand_total - self.doc.total_advance - flt(self.doc.write_off_amount), self.doc.precision("grand_total")) else: - total_amount_to_pay = flt(self.doc.base_grand_total - self.doc.total_advance - - flt(self.doc.base_write_off_amount), self.doc.precision("grand_total")) + total_amount_to_pay = flt(flt(self.doc.grand_total * + self.doc.conversion_rate, self.doc.precision("grand_total")) - self.doc.total_advance + - flt(self.doc.base_write_off_amount), self.doc.precision("grand_total")) if self.doc.doctype == "Sales Invoice": self.doc.round_floats_in(self.doc, ["paid_amount"]) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index a8cdf83a29..3ccc648aaa 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -504,8 +504,11 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ var total_amount_to_pay = flt((this.frm.doc.grand_total - this.frm.doc.total_advance - this.frm.doc.write_off_amount), precision("grand_total")); } else { - var total_amount_to_pay = flt((this.frm.doc.base_grand_total - this.frm.doc.total_advance - - this.frm.doc.base_write_off_amount), precision("base_grand_total")); + var total_amount_to_pay = flt( + (flt(this.frm.doc.grand_total*this.frm.doc.conversion_rate, precision("grand_total")) + - this.frm.doc.total_advance - this.frm.doc.base_write_off_amount), + precision("base_grand_total") + ); } if(this.frm.doc.doctype == "Sales Invoice") {