Merge pull request #3289 from nabinhait/develop
Multiple fixes
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index 1d60efa..9b97e4b 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -71,12 +71,11 @@
# check against budget
validate_expense_against_budget(entry)
-
# update total debit / credit
total_debit += flt(entry.debit)
total_credit += flt(entry.credit)
- validate_total_debit_credit(total_debit, total_credit)
+ validate_total_debit_credit(total_debit, total_credit, gl_map)
def make_entry(args, adv_adj, update_outstanding):
args.update({"doctype": "GL Entry"})
@@ -86,9 +85,9 @@
gle.run_method("on_update_with_args", adv_adj, update_outstanding)
gle.submit()
-def validate_total_debit_credit(total_debit, total_credit):
+def validate_total_debit_credit(total_debit, total_credit, gl_map):
if abs(total_debit - total_credit) > 0.005:
- frappe.throw(_("Debit and Credit not equal for this voucher. Difference is {0}.").format(total_debit - total_credit))
+ frappe.throw(_("Debit and Credit not equal for {0} #{1}. Difference is {2}.").format(gl_map[0].voucher_type, gl_map[0].voucher_no, total_debit - total_credit))
def validate_account_for_auto_accounting_for_stock(gl_map):
if gl_map[0].voucher_type=="Journal Entry":
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 3efb913..e77a9a6 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -282,6 +282,9 @@
last_tax.tax_amount += diff
last_tax.tax_amount_after_discount_amount += diff
last_tax.total += diff
+
+ self._set_in_company_currency(last_tax,
+ ["total", "tax_amount", "tax_amount_after_discount_amount"])
def calculate_totals(self):
self.doc.grand_total = flt(self.doc.get("taxes")[-1].total
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index fd99d80..4a26d6d 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -46,14 +46,19 @@
var company_currency = this.get_company_currency();
if(!this.frm.doc.conversion_rate) {
- frappe.throw(repl('%(conversion_rate_label)s' +
- __(' is mandatory. Maybe Currency Exchange record is not created for ') +
- '%(from_currency)s' + __(" to ") + '%(to_currency)s',
- {
- "conversion_rate_label": conversion_rate_label,
- "from_currency": this.frm.doc.currency,
- "to_currency": company_currency
- }));
+ if(this.frm.doc.currency == company_currency) {
+ this.frm.set_value("conversion_rate", 1);
+ } else {
+ frappe.throw(repl('%(conversion_rate_label)s' +
+ __(' is mandatory. Maybe Currency Exchange record is not created for ') +
+ '%(from_currency)s' + __(" to ") + '%(to_currency)s',
+ {
+ "conversion_rate_label": conversion_rate_label,
+ "from_currency": this.frm.doc.currency,
+ "to_currency": company_currency
+ }));
+ }
+
}
},
@@ -314,6 +319,8 @@
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
discount_amount_loss, precision("tax_amount", tax));
tax.total = flt(tax.total + discount_amount_loss, precision("total", tax));
+
+ this.set_in_company_currency(tax, ["total", "tax_amount_after_discount_amount"]);
},
manipulate_grand_total_for_inclusive_tax: function() {
@@ -333,6 +340,9 @@
last_tax.tax_amount += diff;
last_tax.tax_amount_after_discount += diff;
last_tax.total += diff;
+
+ this.set_in_company_currency(last_tax,
+ ["total", "tax_amount", "tax_amount_after_discount_amount"]);
}
}
}
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index c8b2b64..a3f1eca 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -75,7 +75,6 @@
callback: function(r) {
if(!r.exc) {
me.frm.set_value("taxes", r.message);
- me.calculate_taxes_and_totals();
}
}
});