diff --git a/erpnext/__init__.py b/erpnext/__init__.py index ee4ca0c791..b67d2bd28c 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '11.1.17' +__version__ = '11.1.20' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.js b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.js index eebd2dbd34..e12eae9c1c 100644 --- a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.js +++ b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.js @@ -1,5 +1,7 @@ -frappe.dashboard_chart_sources["Account Balance Timeline"] = { - method_path: "erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get", +frappe.provide('frappe.dashboards.chart_sources'); + +frappe.dashboards.chart_sources["Account Balance Timeline"] = { + method: "erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get", filters: [ { fieldname: "company", @@ -16,30 +18,5 @@ frappe.dashboard_chart_sources["Account Balance Timeline"] = { options: "Account", reqd: 1 }, - { - fieldname: "timespan", - label: __("Period"), - fieldtype: "Select", - options: [ - {value: "Last Year", label: __("Last Year")}, - {value: "Last Quarter", label: __("Last Quarter")}, - {value: "Last Month", label: __("Last Month")}, - {value: "Last Week", label: __("Last Week")} - ], - reqd: 1 - }, - { - fieldname: "timegrain", - label: __("Periodicity"), - fieldtype: "Select", - options: [ - {value: "Quarterly", label: __("Quarterly")}, - {value: "Monthly", label: __("Monthly")}, - {value: "Weekly", label: __("Weekly")}, - {value: "Daily", label: __("Daily")} - ], - reqd: 1 - }, - ], - is_time_series: true + ] }; \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.json b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.json index b7ea601564..02bc69f2ea 100644 --- a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.json +++ b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.json @@ -1,13 +1,13 @@ { - "config": "{\n \"method_path\": \"erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get\",\n\t\"filters\": [\n\t\t{\n\t\t\t\"fieldname\": \"company\",\n\t\t\t\"label\": \"Company\",\n\t\t\t\"fieldtype\": \"Link\",\n\t\t\t\"options\": \"Company\",\n\t\t\t\"reqd\": 1\n\t\t},\n\t\t{\n\t\t\t\"fieldname\": \"account\",\n\t\t\t\"label\": \"Account\",\n\t\t\t\"fieldtype\": \"Link\",\n\t\t\t\"options\": \"Account\",\n\t\t\t\"reqd\": 1\n\t\t},\n\t\t{\n\t\t\t\"fieldname\": \"timespan\",\n\t\t\t\"label\": \"Period\",\n\t\t\t\"fieldtype\": \"Select\",\n\t\t\t\"options\": [\n\t\t\t\t{\"value\": \"Last Year\", \"label\": \"Last Year\"},\n\t\t\t\t{\"value\": \"Last Quarter\", \"label\": \"Last Quarter\"},\n\t\t\t\t{\"value\": \"Last Month\", \"label\": \"Last Month\"},\n\t\t\t\t{\"value\": \"Last Week\", \"label\": \"Last Week\"}\n\t\t\t],\n\t\t\t\"reqd\": 1\n\t\t},\n\t\t{\n\t\t\t\"fieldname\": \"timegrain\",\n\t\t\t\"label\": \"Periodicity\",\n\t\t\t\"fieldtype\": \"Select\",\n\t\t\t\"options\": [\n\t\t\t\t{\"value\": \"Quarterly\", \"label\": \"Quarterly\"},\n\t\t\t\t{\"value\": \"Monthly\", \"label\": \"Monthly\"},\n\t\t\t\t{\"value\": \"Weekly\", \"label\": \"Weekly\"},\n\t\t\t\t{\"value\": \"Daily\", \"label\": \"Daily\"}\n\t\t\t],\n\t\t\t\"reqd\": 1\n\t\t}\n\t],\n\t\"is_time_series\": true\n}\n", "creation": "2019-02-06 07:57:10.377718", "docstatus": 0, "doctype": "Dashboard Chart Source", "idx": 0, - "modified": "2019-03-15 16:14:26.505986", + "modified": "2019-04-09 18:30:49.943174", "modified_by": "Administrator", "module": "Accounts", "name": "Account Balance Timeline", "owner": "Administrator", - "source_name": "Account Balance Timeline" + "source_name": "Account Balance Timeline", + "timeseries": 1 } \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py index 52c202386c..f2abb81dbb 100644 --- a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py +++ b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py @@ -2,31 +2,36 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -from itertools import groupby -from operator import itemgetter -import frappe -from frappe.core.page.dashboard.dashboard import cache_source -from frappe.utils import add_to_date, date_diff, getdate, nowdate +import frappe, json +from frappe.utils import add_to_date, date_diff, getdate, nowdate, get_last_day from erpnext.accounts.report.general_ledger.general_ledger import execute +from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan +from frappe.desk.doctype.dashboard_chart.dashboard_chart import get_period_ending from frappe.utils.nestedset import get_descendants_of @frappe.whitelist() @cache_source -def get(filters=None): - timespan = filters.get("timespan") - timegrain = filters.get("timegrain") +def get(chart_name=None, from_date = None, to_date = None): + chart = frappe.get_doc('Dashboard Chart', chart_name) + timespan = chart.timespan + timegrain = chart.time_interval + filters = json.loads(chart.filters_json) + account = filters.get("account") company = filters.get("company") - from_date = get_from_date_from_timespan(timespan) - to_date = nowdate() + if not to_date: + to_date = nowdate() + if not from_date: + if timegrain in ('Monthly', 'Quarterly'): + from_date = get_from_date_from_timespan(to_date, timespan) # fetch dates to plot dates = get_dates_from_timegrain(from_date, to_date, timegrain) # get all the entries for this account and its descendants - gl_entries = get_gl_entries(account, to_date) + gl_entries = get_gl_entries(account, get_period_ending(to_date, timegrain)) # compile balance values result = build_result(account, dates, gl_entries) @@ -63,7 +68,7 @@ def build_result(account, dates, gl_entries): # for balance sheet accounts, the totals are cumulative if root_type in ('Asset', 'Liability', 'Equity'): for i, r in enumerate(result): - if i < 0: + if i > 0: r[1] = r[1] + result[i-1][1] return result @@ -80,19 +85,6 @@ def get_gl_entries(account, to_date): ], order_by = 'posting_date asc') -def get_from_date_from_timespan(timespan): - days = months = years = 0 - if "Last Week" == timespan: - days = -7 - if "Last Month" == timespan: - months = -1 - elif "Last Quarter" == timespan: - months = -3 - elif "Last Year" == timespan: - years = -1 - return add_to_date(None, years=years, months=months, days=days, - as_string=True, as_datetime=True) - def get_dates_from_timegrain(from_date, to_date, timegrain): days = months = years = 0 if "Daily" == timegrain: @@ -104,7 +96,8 @@ def get_dates_from_timegrain(from_date, to_date, timegrain): elif "Quarterly" == timegrain: months = 3 - dates = [from_date] - while dates[-1] <= to_date: - dates.append(add_to_date(dates[-1], years=years, months=months, days=days)) + dates = [get_period_ending(from_date, timegrain)] + while getdate(dates[-1]) < getdate(to_date): + date = get_period_ending(add_to_date(dates[-1], years=years, months=months, days=days), timegrain) + dates.append(date) return dates diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json index 3ab73b717d..e2f967dacc 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json @@ -1,5 +1,6 @@ { "allow_copy": 1, + "allow_events_in_timeline": 0, "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, @@ -13,11 +14,14 @@ "fields": [ { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, "description": "Select account head of the bank where cheque was deposited.", + "fetch_from": "bank_account_no.account", + "fetch_if_empty": 1, "fieldname": "bank_account", "fieldtype": "Link", "hidden": 0, @@ -40,14 +44,17 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "account_currency", "fieldtype": "Link", "hidden": 1, @@ -70,14 +77,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "from_date", "fieldtype": "Date", "hidden": 0, @@ -99,14 +109,17 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "to_date", "fieldtype": "Date", "hidden": 0, @@ -128,14 +141,83 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, + "fieldname": "column_break_5", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "bank_account_no", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Bank Account No", + "length": 0, + "no_copy": 0, + "options": "Bank Account", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, "fieldname": "include_reconciled_entries", "fieldtype": "Check", "hidden": 0, @@ -157,14 +239,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "include_pos_transactions", "fieldtype": "Check", "hidden": 0, @@ -187,14 +272,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "get_payment_entries", "fieldtype": "Button", "hidden": 0, @@ -217,14 +305,49 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { - "allow_bulk_edit": 1, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, + "fieldname": "section_break_10", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 1, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, "fieldname": "payment_entries", "fieldtype": "Table", "hidden": 0, @@ -247,14 +370,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "update_clearance_date", "fieldtype": "Button", "hidden": 0, @@ -277,14 +403,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "total_amount", "fieldtype": "Currency", "hidden": 0, @@ -307,22 +436,21 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 } ], "has_web_view": 0, - "hide_heading": 1, "hide_toolbar": 1, "icon": "fa fa-check", "idx": 1, - "image_view": 0, "in_create": 0, "is_submittable": 0, "issingle": 1, "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2018-03-07 18:58:48.658687", + "modified": "2019-04-09 18:41:06.110453", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Reconciliation", @@ -330,7 +458,6 @@ "permissions": [ { "amend": 0, - "apply_user_permissions": 0, "cancel": 0, "create": 1, "delete": 0, @@ -351,9 +478,9 @@ ], "quick_entry": 1, "read_only": 1, - "read_only_onload": 0, "show_name_in_global_search": 0, "sort_order": "ASC", "track_changes": 0, - "track_seen": 0 + "track_seen": 0, + "track_views": 0 } \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index fae5213f23..28807c4118 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -19,8 +19,11 @@ class BankReconciliation(Document): condition = "" if not self.include_reconciled_entries: - condition = "and (clearance_date is null or clearance_date='0000-00-00')" + condition = " and (clearance_date is null or clearance_date='0000-00-00')" + account_cond = "" + if self.bank_account_no: + account_cond = " and t2.bank_account_no = {0}".format(frappe.db.escape(self.bank_account_no)) journal_entries = frappe.db.sql(""" select @@ -33,10 +36,13 @@ class BankReconciliation(Document): where t2.parent = t1.name and t2.account = %s and t1.docstatus=1 and t1.posting_date >= %s and t1.posting_date <= %s - and ifnull(t1.is_opening, 'No') = 'No' {0} + and ifnull(t1.is_opening, 'No') = 'No' {0} {1} group by t2.account, t1.name order by t1.posting_date ASC, t1.name DESC - """.format(condition), (self.bank_account, self.from_date, self.to_date), as_dict=1) + """.format(condition, account_cond), (self.bank_account, self.from_date, self.to_date), as_dict=1) + + if self.bank_account_no: + condition = " and bank_account = %(bank_account_no)s" payment_entries = frappe.db.sql(""" select @@ -53,7 +59,8 @@ class BankReconciliation(Document): order by posting_date ASC, name DESC """.format(condition), - {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1) + {"account":self.bank_account, "from":self.from_date, + "to":self.to_date, "bank_account_no": self.bank_account_no}, as_dict=1) pos_entries = [] if self.include_pos_transactions: diff --git a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py index 24cd3dda9b..d62ee9deeb 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py @@ -18,14 +18,14 @@ def create_or_update_cheque_print_format(template_name): "doc_type": "Payment Entry", "standard": "No", "custom_format": 1, - "print_format_type": "Server", + "print_format_type": "Jinja", "name": template_name }) else: cheque_print = frappe.get_doc("Print Format", template_name) - + doc = frappe.get_doc("Cheque Print Template", template_name) - + cheque_print.html = """