From 9d6e10c910b3926d5d47e8342138b9e9882e0f49 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Dec 2013 14:45:55 +0530 Subject: [PATCH] [fix] [minor] precision in gl entry based on currency format --- .../doctype/sales_invoice/sales_invoice.py | 7 ++- .../sales_taxes_and_charges.txt | 57 ++++++++++--------- accounts/general_ledger.py | 4 -- controllers/selling_controller.py | 4 +- selling/sales_common.js | 1 - 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index b1834d5a5a..bfba30fa1b 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -399,9 +399,10 @@ class DocType(SellingController): if not self.doc.cash_bank_account and flt(self.doc.paid_amount): msgprint("Cash/Bank Account is mandatory for POS, for making payment entry") raise Exception - if (flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) - round(flt(self.doc.grand_total), 2))>0.001: - msgprint("(Paid amount + Write Off Amount) can not be greater than Grand Total") - raise Exception + if flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) \ + - flt(self.doc.grand_total) > 1/(10**(self.precision("grand_total") + 1)): + webnotes.throw(_("""(Paid amount + Write Off Amount) can not be \ + greater than Grand Total""")) def validate_item_code(self): diff --git a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt index fbba6437f2..b006c1d85c 100644 --- a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt +++ b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-24 11:39:32", "docstatus": 0, - "modified": "2013-07-10 14:54:21", + "modified": "2013-12-17 12:38:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -37,11 +37,20 @@ "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", "reqd": 1 }, + { + "doctype": "DocField", + "fieldname": "row_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Enter Row", + "oldfieldname": "row_id", + "oldfieldtype": "Data" + }, { "doctype": "DocField", "fieldname": "account_head", "fieldtype": "Link", - "in_list_view": 1, + "in_list_view": 0, "label": "Account Head", "oldfieldname": "account_head", "oldfieldtype": "Link", @@ -54,7 +63,7 @@ "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", - "in_list_view": 1, + "in_list_view": 0, "label": "Cost Center", "oldfieldname": "cost_center_other_charges", "oldfieldtype": "Link", @@ -72,6 +81,24 @@ "reqd": 1, "width": "300px" }, + { + "allow_on_submit": 0, + "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", + "doctype": "DocField", + "fieldname": "included_in_print_rate", + "fieldtype": "Check", + "label": "Is this Tax included in Basic Rate?", + "no_copy": 0, + "print_hide": 1, + "print_width": "150px", + "report_hide": 1, + "width": "150px" + }, + { + "doctype": "DocField", + "fieldname": "section_break_6", + "fieldtype": "Section Break" + }, { "doctype": "DocField", "fieldname": "rate", @@ -80,7 +107,7 @@ "label": "Rate", "oldfieldname": "rate", "oldfieldtype": "Currency", - "reqd": 0 + "reqd": 1 }, { "doctype": "DocField", @@ -104,15 +131,6 @@ "options": "Company:company:default_currency", "read_only": 1 }, - { - "doctype": "DocField", - "fieldname": "row_id", - "fieldtype": "Data", - "hidden": 0, - "label": "Enter Row", - "oldfieldname": "row_id", - "oldfieldtype": "Data" - }, { "doctype": "DocField", "fieldname": "item_wise_tax_detail", @@ -134,18 +152,5 @@ "oldfieldtype": "Data", "print_hide": 1, "search_index": 1 - }, - { - "allow_on_submit": 0, - "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", - "doctype": "DocField", - "fieldname": "included_in_print_rate", - "fieldtype": "Check", - "label": "Is this Tax included in Basic Rate?", - "no_copy": 0, - "print_hide": 1, - "print_width": "150px", - "report_hide": 1, - "width": "150px" } ] \ No newline at end of file diff --git a/accounts/general_ledger.py b/accounts/general_ledger.py index 87814b128f..bc0ac1d93c 100644 --- a/accounts/general_ledger.py +++ b/accounts/general_ledger.py @@ -24,10 +24,6 @@ def process_gl_map(gl_map, merge_entries=True): gl_map = merge_similar_entries(gl_map) for entry in gl_map: - # round off upto 2 decimal - entry.debit = flt(entry.debit, 2) - entry.credit = flt(entry.credit, 2) - # toggle debit, credit if negative entry if flt(entry.debit) < 0: entry.credit = flt(entry.credit) - flt(entry.debit) diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py index fd4ca40947..67c1462662 100644 --- a/controllers/selling_controller.py +++ b/controllers/selling_controller.py @@ -205,8 +205,8 @@ class SellingController(StockController): self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount", "paid_amount"]) total_amount_to_pay = self.doc.grand_total - self.doc.write_off_amount - self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount, - self.precision("outstanding_amount")) + self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance \ + - self.doc.paid_amount, self.precision("outstanding_amount")) def calculate_commission(self): if self.meta.get_field("commission_rate"): diff --git a/selling/sales_common.js b/selling/sales_common.js index d6c8fdd0e4..dddc2b568d 100644 --- a/selling/sales_common.js +++ b/selling/sales_common.js @@ -515,7 +515,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }); }; - setup_field_label_map(["net_total", "other_charges_total", "grand_total", "rounded_total", "in_words", "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"],