From c4edcf1532ca06181ccef3cfc513bab863b27cc0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 Dec 2015 16:27:42 +0530 Subject: [PATCH 1/4] [fix] Recurring test case fixed for the 1st day of the month --- erpnext/controllers/recurring_document.py | 9 +++----- .../tests/test_recurring_document.py | 22 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py index fa6c1cca40..d34002bbd4 100644 --- a/erpnext/controllers/recurring_document.py +++ b/erpnext/controllers/recurring_document.py @@ -85,12 +85,9 @@ def make_new_document(ref_wrapper, date_field, posting_date): # get last day of the month to maintain period if the from date is first day of its own month # and to date is the last day of its own month - if (cstr(get_first_day(ref_wrapper.from_date)) == \ - cstr(ref_wrapper.from_date)) and \ - (cstr(get_last_day(ref_wrapper.to_date)) == \ - cstr(ref_wrapper.to_date)): - to_date = get_last_day(get_next_date(ref_wrapper.to_date, - mcount)) + if (cstr(get_first_day(ref_wrapper.from_date)) == cstr(ref_wrapper.from_date)) and \ + (cstr(get_last_day(ref_wrapper.to_date)) == cstr(ref_wrapper.to_date)): + to_date = get_last_day(get_next_date(ref_wrapper.to_date, mcount)) else: to_date = get_next_date(ref_wrapper.to_date, mcount) diff --git a/erpnext/controllers/tests/test_recurring_document.py b/erpnext/controllers/tests/test_recurring_document.py index 3d005ffdc6..ef8d5fbf08 100644 --- a/erpnext/controllers/tests/test_recurring_document.py +++ b/erpnext/controllers/tests/test_recurring_document.py @@ -5,11 +5,10 @@ from __future__ import unicode_literals import frappe import frappe.permissions from erpnext.controllers.recurring_document import date_field_map -from frappe.utils import getdate +from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days +from erpnext.accounts.utils import get_fiscal_year def test_recurring_document(obj, test_records): - from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days - from erpnext.accounts.utils import get_fiscal_year frappe.db.set_value("Print Settings", "Print Settings", "send_print_as_pdf", 1) today = nowdate() base_doc = frappe.copy_doc(test_records[0]) @@ -38,14 +37,15 @@ def test_recurring_document(obj, test_records): _test_recurring_document(obj, doc1, date_field, True) # monthly without a first and last day period - doc2 = frappe.copy_doc(base_doc) - doc2.update({ - "from_date": today, - "to_date": add_to_date(today, days=30) - }) - doc2.insert() - doc2.submit() - _test_recurring_document(obj, doc2, date_field, False) + if getdate(today).day != 1: + doc2 = frappe.copy_doc(base_doc) + doc2.update({ + "from_date": today, + "to_date": add_to_date(today, days=30) + }) + doc2.insert() + doc2.submit() + _test_recurring_document(obj, doc2, date_field, False) # quarterly doc3 = frappe.copy_doc(base_doc) From 5b73dea9f6bc6dd16ac0acac693abd39f63e97ab Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Nov 2015 15:42:32 +0530 Subject: [PATCH 2/4] [fix] Get items in stock reconciliation based on default warehouse or existing bin --- .../stock_reconciliation.py | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 22946b70b9..b0aff019f5 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -249,18 +249,26 @@ class StockReconciliation(StockController): @frappe.whitelist() def get_items(warehouse, posting_date, posting_time): - items = frappe.get_list("Item", fields=["name"], filters= - {"is_stock_item": 1, "has_serial_no": 0, "has_batch_no": 0, "has_variants": 0}) - for item in items: - item.item_code = item.name - item.warehouse = warehouse - item.qty, item.valuation_rate = get_stock_balance(item.name, warehouse, - posting_date, posting_time, with_valuation_rate=True) - item.current_qty = item.qty - item.current_valuation_rate = item.valuation_rate - del item["name"] + items = frappe.get_list("Bin", fields=["item_code"], filters={"warehouse": warehouse}, as_list=1) + + items += frappe.get_list("Item", fields=["name"], filters= {"is_stock_item": 1, "has_serial_no": 0, + "has_batch_no": 0, "has_variants": 0, "default_warehouse": warehouse}, as_list=1) + + res = [] + for item in set(items): + stock_bal = get_stock_balance(item[0], warehouse, posting_date, posting_time, + with_valuation_rate=True) + + res.append({ + "item_code": item[0], + "warehouse": warehouse, + "qty": stock_bal[0], + "valuation_rate": stock_bal[1], + "current_qty": stock_bal[0], + "current_valuation_rate": stock_bal[1] + }) - return items + return res @frappe.whitelist() def get_stock_balance_for(item_code, warehouse, posting_date, posting_time): From 29cca2352c3fe4184a48f963d15a56ca6a64bcb7 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 1 Dec 2015 18:17:18 +0530 Subject: [PATCH 3/4] [hot] [fix] trial balance report --- .../accounts/report/financial_statements.py | 12 +++---- .../report/trial_balance/trial_balance.py | 34 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 15e0553b0b..5cdf553de1 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -80,12 +80,12 @@ def get_data(company, root_type, balance_must_be, period_list, ignore_closing_en return None accounts, accounts_by_name = filter_accounts(accounts) - + gl_entries_by_account = {} - for root in frappe.db.sql("""select lft, rgt from tabAccount + for root in frappe.db.sql("""select lft, rgt from tabAccount where root_type=%s and ifnull(parent_account, '') = ''""", root_type, as_dict=1): - set_gl_entries_by_account(company, period_list[0]["from_date"], - period_list[-1]["to_date"],root.lft, root.rgt, gl_entries_by_account, + set_gl_entries_by_account(company, period_list[0]["from_date"], + period_list[-1]["to_date"],root.lft, root.rgt, gl_entries_by_account, ignore_closing_entries=ignore_closing_entries) calculate_values(accounts_by_name, gl_entries_by_account, period_list) @@ -151,7 +151,7 @@ def add_total_row(out, balance_must_be, period_list): "account_name": "'" + _("Total ({0})").format(balance_must_be) + "'", "account": None } - + for row in out: if not row.get("parent_account"): for period in period_list: @@ -209,7 +209,7 @@ def sort_root_accounts(roots): roots.sort(compare_roots) -def set_gl_entries_by_account(company, from_date, to_date, root_lft, root_rgt, gl_entries_by_account, +def set_gl_entries_by_account(company, from_date, to_date, root_lft, root_rgt, gl_entries_by_account, ignore_closing_entries=False): """Returns a dict like { "account": [gl entries], ... }""" additional_conditions = [] diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index fdbed9018c..13e87432b3 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.utils import cint, flt, getdate, formatdate, cstr -from erpnext.accounts.report.financial_statements import filter_accounts, get_gl_entries +from erpnext.accounts.report.financial_statements import filter_accounts, set_gl_entries_by_account value_fields = ("opening_debit", "opening_credit", "debit", "credit", "closing_debit", "closing_credit") @@ -45,7 +45,7 @@ def validate_filters(filters): filters.to_date = filters.year_end_date def get_data(filters): - accounts = frappe.db.sql("""select name, parent_account, account_name, root_type, report_type, lft, rgt + accounts = frappe.db.sql("""select name, parent_account, account_name, root_type, report_type, lft, rgt from `tabAccount` where company=%s order by lft""", filters.company, as_dict=True) if not accounts: @@ -56,8 +56,10 @@ def get_data(filters): min_lft, max_rgt = frappe.db.sql("""select min(lft), max(rgt) from `tabAccount` where company=%s""", (filters.company,))[0] - gl_entries_by_account = get_gl_entries(filters.company, filters.from_date, filters.to_date, min_lft, max_rgt, - ignore_closing_entries=not flt(filters.with_period_closing_entry)) + gl_entries_by_account = {} + + set_gl_entries_by_account(filters.company, filters.from_date, + filters.to_date, min_lft, max_rgt, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry)) opening_balances = get_opening_balances(filters) @@ -67,27 +69,27 @@ def get_data(filters): data = prepare_data(accounts, filters, total_row) return data - + def get_opening_balances(filters): balance_sheet_opening = get_rootwise_opening_balances(filters, "Balance Sheet") pl_opening = get_rootwise_opening_balances(filters, "Profit and Loss") - + balance_sheet_opening.update(pl_opening) return balance_sheet_opening - - + + def get_rootwise_opening_balances(filters, report_type): additional_conditions = " and posting_date >= %(year_start_date)s" \ if report_type == "Profit and Loss" else "" - + if not flt(filters.with_period_closing_entry): additional_conditions += " and ifnull(voucher_type, '')!='Period Closing Voucher'" - + gle = frappe.db.sql(""" - select - account, sum(debit) as opening_debit, sum(credit) as opening_credit + select + account, sum(debit) as opening_debit, sum(credit) as opening_credit from `tabGL Entry` - where + where company=%(company)s {additional_conditions} and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes') @@ -100,11 +102,11 @@ def get_rootwise_opening_balances(filters, report_type): "year_start_date": filters.year_start_date }, as_dict=True) - + opening = frappe._dict() for d in gle: opening.setdefault(d.account, d) - + return opening def calculate_values(accounts, gl_entries_by_account, opening_balances, filters): @@ -139,7 +141,7 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances, filters) total_row["debit"] += d["debit"] total_row["credit"] += d["credit"] - + return total_row From 4496cc1e80c86d2ccd64657579ba3146fe3ca5dd Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 1 Dec 2015 18:48:28 +0600 Subject: [PATCH 4/4] bumped to version 6.12.1 --- erpnext/__version__.py | 2 +- erpnext/hooks.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/__version__.py b/erpnext/__version__.py index c41d1d2585..1d96984a3e 100644 --- a/erpnext/__version__.py +++ b/erpnext/__version__.py @@ -1,2 +1,2 @@ from __future__ import unicode_literals -__version__ = '6.12.0' +__version__ = '6.12.1' diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 3a9a3b56a0..f4d24d8c5c 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -7,7 +7,7 @@ app_publisher = "Frappe Technologies Pvt. Ltd." app_description = """ERP made simple""" app_icon = "icon-th" app_color = "#e74c3c" -app_version = "6.12.0" +app_version = "6.12.1" app_email = "info@erpnext.com" app_license = "GNU General Public License (v3)" source_link = "https://github.com/frappe/erpnext" diff --git a/setup.py b/setup.py index d4c485ad8d..8ef1565e5c 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = "6.12.0" +version = "6.12.1" with open("requirements.txt", "r") as f: install_requires = f.readlines()