Merge pull request #4656 from nabinhait/gle_rounding
[fix] Round off gle due to currency conversion
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index b4c81df..5d91426 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -261,15 +261,19 @@
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 a0ce980..e87794a 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -531,14 +531,18 @@
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 49a7bd0..6488288 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -141,6 +141,8 @@
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 b5b3e53..6a0b3c0 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -408,8 +408,9 @@
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 a8cdf83..3ccc648 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -504,8 +504,11 @@
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") {