From daf344e5fdb8a1008a26e9361713513c5960f719 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sun, 12 Oct 2014 17:40:43 +0530 Subject: [PATCH 1/4] Precision fixed in batch-wise balance report --- .../batch_wise_balance_history.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py index 9b94ee61e1..3679457136 100644 --- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py +++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import flt +from frappe.utils import flt, cint def execute(filters=None): if not filters: filters = {} @@ -57,6 +57,7 @@ def get_stock_ledger_entries(filters): conditions, as_dict=1) def get_item_warehouse_batch_map(filters): + float_precision = cint(frappe.db.get_default("float_precision")) or 3 sle = get_stock_ledger_entries(filters) iwb_map = {} @@ -67,14 +68,14 @@ def get_item_warehouse_batch_map(filters): })) qty_dict = iwb_map[d.item_code][d.warehouse][d.batch_no] if d.posting_date < filters["from_date"]: - qty_dict.opening_qty += flt(d.actual_qty) + qty_dict.opening_qty += flt(d.actual_qty, float_precision) elif d.posting_date >= filters["from_date"] and d.posting_date <= filters["to_date"]: if flt(d.actual_qty) > 0: - qty_dict.in_qty += flt(d.actual_qty) + qty_dict.in_qty += flt(d.actual_qty, float_precision) else: - qty_dict.out_qty += abs(flt(d.actual_qty)) + qty_dict.out_qty += abs(flt(d.actual_qty, float_precision)) - qty_dict.bal_qty += flt(d.actual_qty) + qty_dict.bal_qty += flt(d.actual_qty, float_precision) return iwb_map From bc8b20ae3c539600fc91a075793e691816e91e0f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 13 Oct 2014 10:47:14 +0530 Subject: [PATCH 2/4] Allocate entire advance amount if advance against SO/PO --- erpnext/controllers/accounts_controller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 9a62fc299e..af0a96ef67 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -387,7 +387,7 @@ class AccountsController(TransactionBase): res = frappe.db.sql(""" select - t1.name as jv_no, t1.remark, t2.%s as amount, t2.name as jv_detail_no + t1.name as jv_no, t1.remark, t2.%s as amount, t2.name as jv_detail_no, `against_%s` as against_order from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where @@ -400,7 +400,7 @@ class AccountsController(TransactionBase): and ifnull(t2.against_purchase_order, '') = '' ) %s) order by t1.posting_date""" % - (dr_or_cr, '%s', cond), + (dr_or_cr, against_order_field, '%s', cond), tuple([account_head] + so_list), as_dict= True) self.set(parentfield, []) @@ -411,7 +411,7 @@ class AccountsController(TransactionBase): "jv_detail_no": d.jv_detail_no, "remarks": d.remark, "advance_amount": flt(d.amount), - "allocate_amount": 0 + "allocated_amount": flt(d.amount) if d.against_order else 0 }) def validate_advance_jv(self, advance_table_fieldname, against_order_field): From 3d3f0bcf549ddcd9416a3e20ff1e688472c723e1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 13 Oct 2014 11:32:41 +0530 Subject: [PATCH 3/4] Minor fix in setup wizard --- erpnext/setup/page/setup_wizard/setup_wizard.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index d3942e47c5..bf643ddcf9 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -78,9 +78,10 @@ def setup_account(args=None): frappe.db.commit() except: - traceback = frappe.get_traceback() - for hook in frappe.get_hooks("setup_wizard_exception"): - frappe.get_attr(hook)(traceback, args) + if args: + traceback = frappe.get_traceback() + for hook in frappe.get_hooks("setup_wizard_exception"): + frappe.get_attr(hook)(traceback, args) raise From 17a16eeaf4f8be85a9c4dadc90f1fbe7c3160a64 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 13 Oct 2014 11:43:14 +0530 Subject: [PATCH 4/4] Tets case fixed for payment tool --- .../doctype/payment_tool/test_payment_tool.py | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/erpnext/accounts/doctype/payment_tool/test_payment_tool.py b/erpnext/accounts/doctype/payment_tool/test_payment_tool.py index c91a5de2e1..2192aebaae 100644 --- a/erpnext/accounts/doctype/payment_tool/test_payment_tool.py +++ b/erpnext/accounts/doctype/payment_tool/test_payment_tool.py @@ -31,9 +31,10 @@ class TestPaymentTool(unittest.TestCase): "customer": "_Test Customer 3" }) - jv_against_so1 = self.create_against_jv(jv_test_records[0], { + jv_against_so1 = self.create_against_jv(jv_test_records[0], { "account": "_Test Customer 3 - _TC", - "against_sales_order": so1.name + "against_sales_order": so1.name, + "is_advance": "Yes" }) @@ -42,10 +43,11 @@ class TestPaymentTool(unittest.TestCase): "customer": "_Test Customer 3" }) - jv_against_so2 = self.create_against_jv(jv_test_records[0], { + jv_against_so2 = self.create_against_jv(jv_test_records[0], { "account": "_Test Customer 3 - _TC", "against_sales_order": so2.name, - "credit": 1000 + "credit": 1000, + "is_advance": "Yes" }) po = self.create_voucher(po_test_records[1], { "supplier": "_Test Supplier 1" @@ -54,20 +56,20 @@ class TestPaymentTool(unittest.TestCase): #Create SI with partial outstanding si1 = self.create_voucher(si_test_records[0], { "customer": "_Test Customer 3", - "debit_to": "_Test Customer 3 - _TC" + "debit_to": "_Test Customer 3 - _TC" }) - - jv_against_si1 = self.create_against_jv(jv_test_records[0], { + + jv_against_si1 = self.create_against_jv(jv_test_records[0], { "account": "_Test Customer 3 - _TC", "against_invoice": si1.name }) #Create SI with no outstanding si2 = self.create_voucher(si_test_records[0], { "customer": "_Test Customer 3", - "debit_to": "_Test Customer 3 - _TC" + "debit_to": "_Test Customer 3 - _TC" }) - - jv_against_si2 = self.create_against_jv(jv_test_records[0], { + + jv_against_si2 = self.create_against_jv(jv_test_records[0], { "account": "_Test Customer 3 - _TC", "against_invoice": si2.name, "credit": 561.80 @@ -75,7 +77,7 @@ class TestPaymentTool(unittest.TestCase): pi = self.create_voucher(pi_test_records[0], { "supplier": "_Test Supplier 1", - "credit_to": "_Test Supplier 1 - _TC" + "credit_to": "_Test Supplier 1 - _TC" }) #Create a dict containing properties and expected values @@ -137,7 +139,7 @@ class TestPaymentTool(unittest.TestCase): payment_tool_doc.set(k, v) self.check_outstanding_vouchers(payment_tool_doc, args, expected_outstanding) - + def check_outstanding_vouchers(self, doc, args, expected_outstanding): from erpnext.accounts.doctype.payment_tool.payment_tool import get_outstanding_vouchers @@ -161,7 +163,7 @@ class TestPaymentTool(unittest.TestCase): new_jv = paytool.make_journal_voucher() - #Create a list of expected values as [party account, payment against, against_jv, against_invoice, + #Create a list of expected values as [party account, payment against, against_jv, against_invoice, #against_voucher, against_sales_order, against_purchase_order] expected_values = [ [paytool.party_account, 100.00, expected_outstanding.get("Journal Voucher")[0], None, None, None, None], @@ -171,7 +173,7 @@ class TestPaymentTool(unittest.TestCase): [paytool.party_account, 100.00, None, None, None, None, expected_outstanding.get("Purchase Order")[0]] ] - for jv_entry in new_jv.get("entries"): + for jv_entry in new_jv.get("entries"): if paytool.party_account == jv_entry.get("account"): row = [ jv_entry.get("account"), @@ -183,11 +185,11 @@ class TestPaymentTool(unittest.TestCase): jv_entry.get("against_purchase_order"), ] self.assertTrue(row in expected_values) - + self.assertEquals(new_jv.get("cheque_no"), paytool.reference_no) self.assertEquals(new_jv.get("cheque_date"), paytool.reference_date) def clear_table_entries(self): frappe.db.sql("""delete from `tabGL Entry` where (account = "_Test Customer 3 - _TC" or account = "_Test Supplier 1 - _TC")""") frappe.db.sql("""delete from `tabSales Order` where customer_name = "_Test Customer 3" """) - frappe.db.sql("""delete from `tabPurchase Order` where supplier_name = "_Test Supplier 1" """) + frappe.db.sql("""delete from `tabPurchase Order` where supplier_name = "_Test Supplier 1" """)