Merge pull request #4656 from nabinhait/gle_rounding

[fix] Round off gle due to currency conversion
This commit is contained in:
Nabin Hait 2016-01-20 16:48:42 +05:30
commit dbbc3eb8a6
5 changed files with 23 additions and 9 deletions

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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"])

View File

@ -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") {