From 28acaeb3456e31351e3dd32c0ba6d886c70a7442 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 Jan 2014 11:16:16 +0530 Subject: [PATCH 1/7] Fixes in valuation rate calculation in purchase receipt --- controllers/buying_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 4aa08d6c55..f014f72ee5 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -184,7 +184,7 @@ class BuyingController(StockController): for item in self.doclist.get({"parentfield": parentfield}): - if item.item_code and item.qty and item.item_code in stock_items: + if item.item_code and item.qty and stock_items_amount and item.item_code in stock_items: item.item_tax_amount = flt(flt(item.amount) * total_valuation_amount \ / stock_items_amount, self.precision("item_tax_amount", item)) From a4db83a934eb4fefd356ae6f55d88f97e3d45af9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 Jan 2014 12:13:18 +0530 Subject: [PATCH 2/7] Fixes in valuation rate calculation in purchase receipt --- .../purchase_invoice/purchase_invoice.py | 12 ------------ accounts/utils.py | 2 ++ controllers/buying_controller.py | 17 +++++++++++------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 404627af25..0b8ad46dd0 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -350,7 +350,6 @@ class DocType(BuyingController): # item gl entries stock_item_and_auto_accounting_for_stock = False stock_items = self.get_stock_items() - # rounding_diff = 0.0 for item in self.doclist.get({"parentfield": "entries"}): if auto_accounting_for_stock and item.item_code in stock_items: if flt(item.valuation_rate): @@ -361,11 +360,6 @@ class DocType(BuyingController): valuation_amt = item.amount + item.item_tax_amount + item.rm_supp_cost - # rounding_diff += (flt(item.amount, self.precision("amount", item)) + - # flt(item.item_tax_amount, self.precision("item_tax_amount", item)) + - # flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)) - - # valuation_amt) - gl_entries.append( self.get_gl_dict({ "account": item.expense_head, @@ -392,12 +386,6 @@ class DocType(BuyingController): # this will balance out valuation amount included in cost of goods sold expenses_included_in_valuation = \ self.get_company_default("expenses_included_in_valuation") - - # if rounding_diff: - # import operator - # cost_center_with_max_value = max(valuation_tax.iteritems(), - # key=operator.itemgetter(1))[0] - # valuation_tax[cost_center_with_max_value] -= flt(rounding_diff) for cost_center, amount in valuation_tax.items(): gl_entries.append( diff --git a/accounts/utils.py b/accounts/utils.py index 8971c80f99..a5fb390e9f 100644 --- a/accounts/utils.py +++ b/accounts/utils.py @@ -31,6 +31,8 @@ def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1): if not fy: error_msg = """%s %s not in any Fiscal Year""" % (label, formatdate(date)) + error_msg = """{msg}: {date}""".format(msg=_("Fiscal Year does not exist for date"), + date=formatdate(date)) if verbose: webnotes.msgprint(error_msg) raise FiscalYearError, error_msg diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index f014f72ee5..3c6981d6cb 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -174,9 +174,11 @@ class BuyingController(StockController): """ stock_items = self.get_stock_items() - stock_items_amount = sum([flt(d.amount) for d in - self.doclist.get({"parentfield": parentfield}) - if d.item_code and d.item_code in stock_items]) + stock_items_qty, stock_items_amount = 0, 0 + for d in self.doclist.get({"parentfield": parentfield}): + if d.item_code and d.item_code in stock_items: + stock_items_qty += flt(d.qty) + stock_items_amount += flt(d.amount) total_valuation_amount = sum([flt(d.tax_amount) for d in self.doclist.get({"parentfield": "purchase_tax_details"}) @@ -184,9 +186,12 @@ class BuyingController(StockController): for item in self.doclist.get({"parentfield": parentfield}): - if item.item_code and item.qty and stock_items_amount and item.item_code in stock_items: - item.item_tax_amount = flt(flt(item.amount) * total_valuation_amount \ - / stock_items_amount, self.precision("item_tax_amount", item)) + if item.item_code and item.qty and item.item_code in stock_items: + item_proportion = flt(item.amount) / stock_items_amount if stock_items_amount \ + else flt(item.qty) / stock_items_qty + + item.item_tax_amount = flt(item_proportion * total_valuation_amount, + self.precision("item_tax_amount", item)) self.round_floats_in(item) From 6472bdace2b67e023563c2ca00b41cdfb2c9683e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 Jan 2014 12:30:24 +0530 Subject: [PATCH 3/7] Fixes in general ledger report --- accounts/doctype/journal_voucher/journal_voucher.js | 3 ++- accounts/doctype/purchase_invoice/purchase_invoice.js | 3 ++- accounts/doctype/sales_invoice/sales_invoice.js | 3 ++- accounts/report/general_ledger/general_ledger.py | 2 +- public/js/controllers/stock_controller.js | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 6b94ba170a..e5cea8cc79 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -120,7 +120,8 @@ cur_frm.cscript.refresh = function(doc) { "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, - "company": doc.company + "company": doc.company, + group_by_voucher: 0 }; wn.set_route("query-report", "General Ledger"); }, "icon-table"); diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index 0bdc70e13d..1055bdd25d 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -35,7 +35,8 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, - "company": doc.company + "company": doc.company, + group_by_voucher: 0 }; wn.set_route("query-report", "General Ledger"); }, "icon-table"); diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index a390fb4ed7..3bdef5bb56 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -54,7 +54,8 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, - "company": doc.company + "company": doc.company, + group_by_voucher: 0 }; wn.set_route("query-report", "General Ledger"); }, "icon-table"); diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index 2efc8241c0..855b7d1c7a 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -136,7 +136,7 @@ def get_accountwise_gle(filters, gl_entries, gle_map): or cstr(gle.is_advance) == "Yes"): gle_map[gle.account].opening += amount opening += amount - elif gle.posting_date < filters.to_date: + elif gle.posting_date <= filters.to_date: gle_map[gle.account].entries.append(gle) gle_map[gle.account].total_debit += flt(gle.debit) gle_map[gle.account].total_credit += flt(gle.credit) diff --git a/public/js/controllers/stock_controller.js b/public/js/controllers/stock_controller.js index d2fb904419..6a4261c22a 100644 --- a/public/js/controllers/stock_controller.js +++ b/public/js/controllers/stock_controller.js @@ -28,7 +28,8 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({ voucher_no: me.frm.doc.name, from_date: me.frm.doc.posting_date, to_date: me.frm.doc.posting_date, - company: me.frm.doc.company + company: me.frm.doc.company, + group_by_voucher: false }; wn.set_route("query-report", "General Ledger"); }, "icon-table"); From b0a9581e59c6d7c8c1148afefb26c528bd464c2d Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 3 Jan 2014 12:44:00 +0530 Subject: [PATCH 4/7] fixed accounts receivable for customer name --- .../accounts_receivable.py | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py index 945bae434a..1c76f9baf1 100644 --- a/accounts/report/accounts_receivable/accounts_receivable.py +++ b/accounts/report/accounts_receivable/accounts_receivable.py @@ -18,16 +18,23 @@ class AccountsReceivableReport(object): return self.get_columns(), self.get_data() def get_columns(self): - return [ + columns = [ "Posting Date:Date:80", "Account:Link/Account:150", "Voucher Type::110", "Voucher No::120", "::30", "Due Date:Date:80", "Invoiced Amount:Currency:100", "Payment Received:Currency:100", "Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100", - "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100", - "Customer:Link/Customer:200", "Territory:Link/Territory:80", "Remarks::200" + "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100" ] + naming_by = self.get_selling_settings() + if naming_by[0].value == "Naming Series": + columns += ["Customer:Link/Customer:200"] + + columns += ["Customer Name::110", "Territory:Link/Territory:80", "Remarks::200"] + + return columns + def get_data(self): data = [] future_vouchers = self.get_entries_after(self.filters.report_date) @@ -42,10 +49,15 @@ class AccountsReceivableReport(object): gle.voucher_type, gle.voucher_no, due_date, invoiced_amount, payment_received, outstanding_amount] - entry_date = due_date if self.filters.ageing_based_on=="Due Date" \ + entry_date = due_date if self.filters.ageing_based_on == "Due Date" \ else gle.posting_date row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount) - row += [self.get_customer(gle.account), self.get_territory(gle.account), gle.remarks] + + naming_by = self.get_selling_settings() + if naming_by[0].value == "Naming Series": + row += [self.get_customer(gle.account)] + + row += [self.get_customer_name(gle.account), self.get_territory(gle.account), gle.remarks] data.append(row) for i in range(0,len(data)): @@ -53,7 +65,11 @@ class AccountsReceivableReport(object): % ("/".join(["#Form", data[i][2], data[i][3]]),)) return data - + + def get_selling_settings(self): + return webnotes.conn.sql("""select value from `tabSingles` where + doctype='Selling Settings' and field='cust_master_name'""", as_dict=1) + def get_entries_after(self, report_date): # returns a distinct list return list(set([(e.voucher_type, e.voucher_no) for e in self.get_gl_entries() @@ -77,18 +93,21 @@ class AccountsReceivableReport(object): return flt(gle.debit) - flt(gle.credit) - payment_received def get_customer(self, account): + return self.get_account_map().get(account).get("customer") or "" + + def get_customer_name(self, account): return self.get_account_map().get(account).get("customer_name") or "" - + def get_territory(self, account): return self.get_account_map().get(account).get("territory") or "" def get_account_map(self): if not hasattr(self, "account_map"): self.account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select - account.name, customer.name as customer_name, customer.territory - from `tabAccount` account, `tabCustomer` customer - where account.master_type="Customer" - and customer.name=account.master_name""", as_dict=True))) + acc.name, cust.name as customer, cust.customer_name, cust.territory + from `tabAccount` acc, `tabCustomer` cust + where acc.master_type="Customer" + and cust.name=acc.master_name""", as_dict=True))) return self.account_map @@ -164,4 +183,4 @@ def get_ageing_data(age_as_on, entry_date, outstanding_amount): if index is None: index = 3 outstanding_range[index] = outstanding_amount - return [age] + outstanding_range + return [age] + outstanding_range \ No newline at end of file From b4eba77f7b00d92a25335d6cfc2adf454763601d Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 3 Jan 2014 12:58:04 +0530 Subject: [PATCH 5/7] fixed accounts receivable --- .../accounts_receivable/accounts_receivable.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py index 1c76f9baf1..0407039e41 100644 --- a/accounts/report/accounts_receivable/accounts_receivable.py +++ b/accounts/report/accounts_receivable/accounts_receivable.py @@ -26,9 +26,8 @@ class AccountsReceivableReport(object): "Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100", "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100" ] - - naming_by = self.get_selling_settings() - if naming_by[0].value == "Naming Series": + + if self.get_customer_naming() == "Naming Series": columns += ["Customer:Link/Customer:200"] columns += ["Customer Name::110", "Territory:Link/Territory:80", "Remarks::200"] @@ -53,8 +52,7 @@ class AccountsReceivableReport(object): else gle.posting_date row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount) - naming_by = self.get_selling_settings() - if naming_by[0].value == "Naming Series": + if self.get_customer_naming() == "Naming Series": row += [self.get_customer(gle.account)] row += [self.get_customer_name(gle.account), self.get_territory(gle.account), gle.remarks] @@ -66,9 +64,8 @@ class AccountsReceivableReport(object): return data - def get_selling_settings(self): - return webnotes.conn.sql("""select value from `tabSingles` where - doctype='Selling Settings' and field='cust_master_name'""", as_dict=1) + def get_customer_naming(self): + return webnotes.conn.get_value("Selling Settings", None, "cust_master_name") def get_entries_after(self, report_date): # returns a distinct list From 8a0b7cece13a46b1f62f1dc7a70002f24a3f6731 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 3 Jan 2014 13:21:38 +0530 Subject: [PATCH 6/7] accounts receivable fixed --- .../accounts_receivable.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py index 0407039e41..781db2aaf3 100644 --- a/accounts/report/accounts_receivable/accounts_receivable.py +++ b/accounts/report/accounts_receivable/accounts_receivable.py @@ -15,26 +15,28 @@ class AccountsReceivableReport(object): else self.filters.report_date def run(self): - return self.get_columns(), self.get_data() + customer_naming_by = webnotes.conn.get_value("Selling Settings", None, "cust_master_name") + return self.get_columns(customer_naming_by), self.get_data(customer_naming_by) - def get_columns(self): + def get_columns(self, customer_naming_by): columns = [ "Posting Date:Date:80", "Account:Link/Account:150", "Voucher Type::110", "Voucher No::120", "::30", "Due Date:Date:80", "Invoiced Amount:Currency:100", "Payment Received:Currency:100", "Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100", - "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100" + "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100", + "Customer:Link/Customer:200" ] - if self.get_customer_naming() == "Naming Series": - columns += ["Customer:Link/Customer:200"] + if customer_naming_by == "Naming Series": + columns += ["Customer Name::110"] - columns += ["Customer Name::110", "Territory:Link/Territory:80", "Remarks::200"] + columns += ["Territory:Link/Territory:80", "Remarks::200"] return columns - def get_data(self): + def get_data(self, customer_naming_by): data = [] future_vouchers = self.get_entries_after(self.filters.report_date) for gle in self.get_entries_till(self.filters.report_date): @@ -50,23 +52,21 @@ class AccountsReceivableReport(object): outstanding_amount] entry_date = due_date if self.filters.ageing_based_on == "Due Date" \ else gle.posting_date - row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount) + row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount) + \ + [self.get_customer(gle.account)] - if self.get_customer_naming() == "Naming Series": - row += [self.get_customer(gle.account)] + if customer_naming_by == "Naming Series": + row += [self.get_customer_name(gle.account)] - row += [self.get_customer_name(gle.account), self.get_territory(gle.account), gle.remarks] + row += [self.get_territory(gle.account), gle.remarks] data.append(row) - for i in range(0,len(data)): + for i in range(0, len(data)): data[i].insert(4, """""" \ % ("/".join(["#Form", data[i][2], data[i][3]]),)) return data - def get_customer_naming(self): - return webnotes.conn.get_value("Selling Settings", None, "cust_master_name") - def get_entries_after(self, report_date): # returns a distinct list return list(set([(e.voucher_type, e.voucher_no) for e in self.get_gl_entries() @@ -163,7 +163,7 @@ class AccountsReceivableReport(object): def execute(filters=None): return AccountsReceivableReport(filters).run() - + def get_ageing_data(age_as_on, entry_date, outstanding_amount): # [0-30, 30-60, 60-90, 90-above] outstanding_range = [0.0, 0.0, 0.0, 0.0] From 866103bf666cd6bec9e96e478f8bf701207fb614 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Fri, 3 Jan 2014 13:57:06 +0600 Subject: [PATCH 7/7] bumped to version 3.4.5 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index e8955b178c..89c1332005 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.4.4", + "app_version": "3.4.5", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": {