diff --git a/erpnext/accounts/accounts_dashboard/accounts/accounts.json b/erpnext/accounts/accounts_dashboard/accounts/accounts.json new file mode 100644 index 0000000000..2fab50e917 --- /dev/null +++ b/erpnext/accounts/accounts_dashboard/accounts/accounts.json @@ -0,0 +1,58 @@ +{ + "cards": [ + { + "card": "Total Outgoing Bills" + }, + { + "card": "Total Incoming Bills" + }, + { + "card": "Total Incoming Payment" + }, + { + "card": "Total Outgoing Payment" + } + ], + "charts": [ + { + "chart": "Profit and Loss", + "width": "Full" + }, + { + "chart": "Incoming Bills (Purchase Invoice)", + "width": "Half" + }, + { + "chart": "Outgoing Bills (Sales Invoice)", + "width": "Half" + }, + { + "chart": "Accounts Receivable Ageing", + "width": "Half" + }, + { + "chart": "Accounts Payable Ageing", + "width": "Half" + }, + { + "chart": "Budget Variance", + "width": "Full" + }, + { + "chart": "Bank Balance", + "width": "Full" + } + ], + "creation": "2020-07-17 11:25:34.796608", + "dashboard_name": "Accounts", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 0, + "is_standard": 1, + "modified": "2020-07-22 13:07:34.540574", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart/accounts_payable_ageing/accounts_payable_ageing.json b/erpnext/accounts/dashboard_chart/accounts_payable_ageing/accounts_payable_ageing.json new file mode 100644 index 0000000000..fb5ee64545 --- /dev/null +++ b/erpnext/accounts/dashboard_chart/accounts_payable_ageing/accounts_payable_ageing.json @@ -0,0 +1,23 @@ +{ + "chart_name": "Accounts Payable Ageing", + "chart_type": "Report", + "creation": "2020-07-17 11:25:34.564015", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"report_date\":\"frappe.datetime.now_date()\"}", + "filters_json": "{\"ageing_based_on\":\"Due Date\",\"range1\":30,\"range2\":60,\"range3\":90,\"range4\":120,\"group_by_party\":0,\"based_on_payment_terms\":0}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 12:29:33.584419", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts Payable Ageing", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Accounts Payable", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart/accounts_receivable_ageing/accounts_receivable_ageing.json b/erpnext/accounts/dashboard_chart/accounts_receivable_ageing/accounts_receivable_ageing.json new file mode 100644 index 0000000000..48ec781f68 --- /dev/null +++ b/erpnext/accounts/dashboard_chart/accounts_receivable_ageing/accounts_receivable_ageing.json @@ -0,0 +1,23 @@ +{ + "chart_name": "Accounts Receivable Ageing", + "chart_type": "Report", + "creation": "2020-07-17 11:25:34.535388", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"report_date\":\"frappe.datetime.now_date()\"}", + "filters_json": "{\"ageing_based_on\":\"Due Date\",\"range1\":30,\"range2\":60,\"range3\":90,\"range4\":120,\"group_by_party\":0,\"based_on_payment_terms\":0,\"show_future_payments\":0,\"show_delivery_notes\":0,\"show_sales_person\":0}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 12:28:42.743551", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts Receivable Ageing", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Accounts Receivable", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart/bank_balance/bank_balance.json b/erpnext/accounts/dashboard_chart/bank_balance/bank_balance.json new file mode 100644 index 0000000000..6442c022c7 --- /dev/null +++ b/erpnext/accounts/dashboard_chart/bank_balance/bank_balance.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Bank Balance", + "chart_type": "Custom", + "creation": "2020-07-17 11:25:34.620221", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"account\":\"locals[\\\":Company\\\"][frappe.defaults.get_user_default(\\\"Company\\\")][\\\"default_bank_account\\\"]\"}", + "filters_json": "{}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 12:19:59.879476", + "modified": "2020-07-22 12:21:48.780513", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Bank Balance", + "number_of_groups": 0, + "owner": "Administrator", + "source": "Account Balance Timeline", + "time_interval": "Quarterly", + "timeseries": 0, + "timespan": "Last Year", + "type": "Line", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart/budget_variance/budget_variance.json b/erpnext/accounts/dashboard_chart/budget_variance/budget_variance.json new file mode 100644 index 0000000000..8631d3dc2a --- /dev/null +++ b/erpnext/accounts/dashboard_chart/budget_variance/budget_variance.json @@ -0,0 +1,23 @@ +{ + "chart_name": "Budget Variance", + "chart_type": "Report", + "creation": "2020-07-17 11:25:34.593061", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_fiscal_year\":\"frappe.sys_defaults.fiscal_year\",\"to_fiscal_year\":\"frappe.sys_defaults.fiscal_year\"}", + "filters_json": "{\"period\":\"Monthly\",\"budget_against\":\"Cost Center\",\"show_cumulative\":0}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 12:24:49.144210", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Budget Variance", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Budget Variance Report", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart/incoming_bills_(purchase_invoice)/incoming_bills_(purchase_invoice).json b/erpnext/accounts/dashboard_chart/incoming_bills_(purchase_invoice)/incoming_bills_(purchase_invoice).json new file mode 100644 index 0000000000..55f0d77f72 --- /dev/null +++ b/erpnext/accounts/dashboard_chart/incoming_bills_(purchase_invoice)/incoming_bills_(purchase_invoice).json @@ -0,0 +1,29 @@ +{ + "based_on": "posting_date", + "chart_name": "Incoming Bills (Purchase Invoice)", + "chart_type": "Sum", + "color": "#a83333", + "creation": "2020-07-17 11:25:34.479703", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Purchase Invoice", + "dynamic_filters_json": "", + "filters_json": "[[\"Purchase Invoice\",\"docstatus\",\"=\",1]]", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-21 17:37:30.727306", + "modified": "2020-07-21 17:51:07.374917", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Incoming Bills (Purchase Invoice)", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Monthly", + "timeseries": 1, + "timespan": "Last Year", + "type": "Bar", + "use_report_chart": 0, + "value_based_on": "base_net_total", + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart/outgoing_bills_(sales_invoice)/outgoing_bills_(sales_invoice).json b/erpnext/accounts/dashboard_chart/outgoing_bills_(sales_invoice)/outgoing_bills_(sales_invoice).json new file mode 100644 index 0000000000..45de667d58 --- /dev/null +++ b/erpnext/accounts/dashboard_chart/outgoing_bills_(sales_invoice)/outgoing_bills_(sales_invoice).json @@ -0,0 +1,28 @@ +{ + "based_on": "posting_date", + "chart_name": "Outgoing Bills (Sales Invoice)", + "chart_type": "Sum", + "color": "#7b933d", + "creation": "2020-07-17 11:25:34.507547", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Sales Invoice", + "filters_json": "[[\"Sales Invoice\",\"docstatus\",\"=\",1]]", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-21 17:37:31.574666", + "modified": "2020-07-21 17:52:03.970530", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Outgoing Bills (Sales Invoice)", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Monthly", + "timeseries": 1, + "timespan": "Last Year", + "type": "Bar", + "use_report_chart": 0, + "value_based_on": "base_net_total", + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_chart/profit_and_loss/profit_and_loss.json b/erpnext/accounts/dashboard_chart/profit_and_loss/profit_and_loss.json new file mode 100644 index 0000000000..3fa995bbe1 --- /dev/null +++ b/erpnext/accounts/dashboard_chart/profit_and_loss/profit_and_loss.json @@ -0,0 +1,23 @@ +{ + "chart_name": "Profit and Loss", + "chart_type": "Report", + "creation": "2020-07-17 11:25:34.448572", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_fiscal_year\":\"frappe.sys_defaults.fiscal_year\",\"to_fiscal_year\":\"frappe.sys_defaults.fiscal_year\"}", + "filters_json": "{\"filter_based_on\":\"Fiscal Year\",\"period_start_date\":\"2020-04-01\",\"period_end_date\":\"2021-03-31\",\"periodicity\":\"Yearly\",\"include_default_book_entries\":1}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 12:33:48.888943", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Profit and Loss", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Profit and Loss Statement", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/accounts/dashboard_fixtures.py b/erpnext/accounts/dashboard_fixtures.py deleted file mode 100644 index b2abffc79d..0000000000 --- a/erpnext/accounts/dashboard_fixtures.py +++ /dev/null @@ -1,284 +0,0 @@ -# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -import frappe -import json -from frappe.utils import nowdate, add_months, get_date_str -from frappe import _ -from erpnext.accounts.utils import get_fiscal_year, get_account_name, FiscalYearError - -def _get_fiscal_year(date=None): - try: - fiscal_year = get_fiscal_year(date=nowdate(), as_dict=True) - return fiscal_year - - except FiscalYearError: - #if no fiscal year for current date then get default fiscal year - try: - fiscal_year = get_fiscal_year(as_dict=True) - return fiscal_year - - except FiscalYearError: - #if still no fiscal year found then no accounting data created, return - return None - -def get_company_for_dashboards(): - company = frappe.defaults.get_defaults().company - if company: - return company - else: - company_list = frappe.get_list("Company") - if company_list: - return company_list[0].name - return None - -def get_data(): - - fiscal_year = _get_fiscal_year(nowdate()) - - if not fiscal_year: - return frappe._dict() - - return frappe._dict({ - "dashboards": get_dashboards(), - "charts": get_charts(fiscal_year), - "number_cards": get_number_cards(fiscal_year) - }) - -def get_dashboards(): - return [{ - "name": "Accounts", - "dashboard_name": "Accounts", - "doctype": "Dashboard", - "charts": [ - { "chart": "Profit and Loss" , "width": "Full"}, - { "chart": "Incoming Bills (Purchase Invoice)", "width": "Half"}, - { "chart": "Outgoing Bills (Sales Invoice)", "width": "Half"}, - { "chart": "Accounts Receivable Ageing", "width": "Half"}, - { "chart": "Accounts Payable Ageing", "width": "Half"}, - { "chart": "Budget Variance", "width": "Full"}, - { "chart": "Bank Balance", "width": "Full"} - ], - "cards": [ - {"card": "Total Outgoing Bills"}, - {"card": "Total Incoming Bills"}, - {"card": "Total Incoming Payment"}, - {"card": "Total Outgoing Payment"} - ] - }] - -def get_charts(fiscal_year): - company = frappe.get_doc("Company", get_company_for_dashboards()) - bank_account = company.default_bank_account or get_account_name("Bank", company=company.name) - default_cost_center = company.cost_center - - return [ - { - "doctype": "Dashboard Charts", - "name": "Profit and Loss", - "owner": "Administrator", - "report_name": "Profit and Loss Statement", - "filters_json": json.dumps({ - "company": company.name, - "filter_based_on": "Fiscal Year", - "from_fiscal_year": fiscal_year.get('name'), - "to_fiscal_year": fiscal_year.get('name'), - "periodicity": "Monthly", - "include_default_book_entries": 1 - }), - "type": "Bar", - 'timeseries': 0, - "chart_type": "Report", - "chart_name": _("Profit and Loss"), - "is_custom": 1, - "is_public": 1 - }, - { - "doctype": "Dashboard Chart", - "time_interval": "Monthly", - "name": "Incoming Bills (Purchase Invoice)", - "chart_name": _("Incoming Bills (Purchase Invoice)"), - "timespan": "Last Year", - "color": "#a83333", - "value_based_on": "base_net_total", - "filters_json": json.dumps([["Purchase Invoice", "docstatus", "=", 1]]), - "chart_type": "Sum", - "timeseries": 1, - "based_on": "posting_date", - "owner": "Administrator", - "document_type": "Purchase Invoice", - "type": "Bar", - "width": "Half", - "is_public": 1 - }, - { - "doctype": "Dashboard Chart", - "name": "Outgoing Bills (Sales Invoice)", - "time_interval": "Monthly", - "chart_name": _("Outgoing Bills (Sales Invoice)"), - "timespan": "Last Year", - "color": "#7b933d", - "value_based_on": "base_net_total", - "filters_json": json.dumps([["Sales Invoice", "docstatus", "=", 1]]), - "chart_type": "Sum", - "timeseries": 1, - "based_on": "posting_date", - "owner": "Administrator", - "document_type": "Sales Invoice", - "type": "Bar", - "width": "Half", - "is_public": 1 - }, - { - "doctype": "Dashboard Charts", - "name": "Accounts Receivable Ageing", - "owner": "Administrator", - "report_name": "Accounts Receivable", - "filters_json": json.dumps({ - "company": company.name, - "report_date": nowdate(), - "ageing_based_on": "Due Date", - "range1": 30, - "range2": 60, - "range3": 90, - "range4": 120 - }), - "type": "Donut", - 'timeseries': 0, - "chart_type": "Report", - "chart_name": _("Accounts Receivable Ageing"), - "is_custom": 1, - "is_public": 1 - }, - { - "doctype": "Dashboard Charts", - "name": "Accounts Payable Ageing", - "owner": "Administrator", - "report_name": "Accounts Payable", - "filters_json": json.dumps({ - "company": company.name, - "report_date": nowdate(), - "ageing_based_on": "Due Date", - "range1": 30, - "range2": 60, - "range3": 90, - "range4": 120 - }), - "type": "Donut", - 'timeseries': 0, - "chart_type": "Report", - "chart_name": _("Accounts Payable Ageing"), - "is_custom": 1, - "is_public": 1 - }, - { - "doctype": "Dashboard Charts", - "name": "Budget Variance", - "owner": "Administrator", - "report_name": "Budget Variance Report", - "filters_json": json.dumps({ - "company": company.name, - "from_fiscal_year": fiscal_year.get('name'), - "to_fiscal_year": fiscal_year.get('name'), - "period": "Monthly", - "budget_against": "Cost Center" - }), - "type": "Bar", - "timeseries": 0, - "chart_type": "Report", - "chart_name": _("Budget Variance"), - "is_custom": 1, - "is_public": 1 - }, - { - "doctype": "Dashboard Charts", - "name": "Bank Balance", - "time_interval": "Quarterly", - "chart_name": "Bank Balance", - "timespan": "Last Year", - "filters_json": json.dumps({ - "company": company.name, - "account": bank_account - }), - "source": "Account Balance Timeline", - "chart_type": "Custom", - "timeseries": 1, - "owner": "Administrator", - "type": "Line", - "width": "Half", - "is_public": 1 - }, - ] - -def get_number_cards(fiscal_year): - - year_start_date = get_date_str(fiscal_year.get("year_start_date")) - year_end_date = get_date_str(fiscal_year.get("year_end_date")) - return [ - { - "doctype": "Number Card", - "document_type": "Payment Entry", - "name": "Total Incoming Payment", - "filters_json": json.dumps([ - ['Payment Entry', 'docstatus', '=', 1], - ['Payment Entry', 'posting_date', 'between', [year_start_date, year_end_date]], - ['Payment Entry', 'payment_type', '=', 'Receive'] - ]), - "label": _("Total Incoming Payment"), - "function": "Sum", - "aggregate_function_based_on": "base_received_amount", - "is_public": 1, - "is_custom": 1, - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "doctype": "Number Card", - "document_type": "Payment Entry", - "name": "Total Outgoing Payment", - "filters_json": json.dumps([ - ['Payment Entry', 'docstatus', '=', 1], - ['Payment Entry', 'posting_date', 'between', [year_start_date, year_end_date]], - ['Payment Entry', 'payment_type', '=', 'Pay'] - ]), - "label": _("Total Outgoing Payment"), - "function": "Sum", - "aggregate_function_based_on": "base_paid_amount", - "is_public": 1, - "is_custom": 1, - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "doctype": "Number Card", - "document_type": "Sales Invoice", - "name": "Total Outgoing Bills", - "filters_json": json.dumps([ - ['Sales Invoice', 'docstatus', '=', 1], - ['Sales Invoice', 'posting_date', 'between', [year_start_date, year_end_date]] - ]), - "label": _("Total Outgoing Bills"), - "function": "Sum", - "aggregate_function_based_on": "base_net_total", - "is_public": 1, - "is_custom": 1, - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "doctype": "Number Card", - "document_type": "Purchase Invoice", - "name": "Total Incoming Bills", - "filters_json": json.dumps([ - ['Purchase Invoice', 'docstatus', '=', 1], - ['Purchase Invoice', 'posting_date', 'between', [year_start_date, year_end_date]] - ]), - "label": _("Total Incoming Bills"), - "function": "Sum", - "aggregate_function_based_on": "base_net_total", - "is_public": 1, - "is_custom": 1, - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - } - ] diff --git a/erpnext/accounts/desk_page/accounting/accounting.json b/erpnext/accounts/desk_page/accounting/accounting.json index 31315e4c71..a2497838ee 100644 --- a/erpnext/accounts/desk_page/accounting/accounting.json +++ b/erpnext/accounts/desk_page/accounting/accounting.json @@ -147,10 +147,15 @@ "link_to": "Trial Balance", "type": "Report" }, + { + "label": "Point of Sale", + "link_to": "point-of-sale", + "type": "Page" + }, { "label": "Dashboard", "link_to": "Accounts", "type": "Dashboard" } ] -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index c6de6410eb..164f120067 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -244,6 +244,8 @@ class Account(NestedSet): super(Account, self).on_trash(True) +@frappe.whitelist() +@frappe.validate_and_sanitize_search_inputs def get_parent_account(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name from tabAccount where is_group = 1 and docstatus != 2 and company = %s diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py index 1bf9196a4f..0e3b24cda3 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py @@ -225,7 +225,7 @@ def build_tree_from_json(chart_template, chart_data=None): account['parent_account'] = parent account['expandable'] = True if identify_is_group(child) else False - account['value'] = (child.get('account_number') + ' - ' + account_name) \ + account['value'] = (cstr(child.get('account_number')).strip() + ' - ' + account_name) \ if child.get('account_number') else account_name accounts.append(account) _import_accounts(child, account['value']) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 8ca8b71ef8..b2e8b090c7 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -225,7 +225,7 @@ "idx": 1, "issingle": 1, "links": [], - "modified": "2020-06-22 20:13:26.043092", + "modified": "2020-08-03 20:13:26.043092", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/bank/bank.json b/erpnext/accounts/doctype/bank/bank.json index 99978e657d..56bae72a15 100644 --- a/erpnext/accounts/doctype/bank/bank.json +++ b/erpnext/accounts/doctype/bank/bank.json @@ -13,7 +13,6 @@ "bank_name", "swift_number", "column_break_1", - "branch_code", "website", "address_and_contact", "address_html", @@ -51,15 +50,6 @@ "fieldtype": "Column Break", "search_index": 1 }, - { - "allow_in_quick_entry": 1, - "fieldname": "branch_code", - "fieldtype": "Data", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Branch Code", - "unique": 1 - }, { "fieldname": "address_and_contact", "fieldtype": "Section Break", @@ -111,7 +101,7 @@ } ], "links": [], - "modified": "2020-03-25 21:22:33.496264", + "modified": "2020-07-17 14:00:13.105433", "modified_by": "Administrator", "module": "Accounts", "name": "Bank", diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json index 65a0a5138c..b42f1f9d58 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.json +++ b/erpnext/accounts/doctype/bank_account/bank_account.json @@ -23,6 +23,7 @@ "account_details_section", "iban", "column_break_12", + "branch_code", "bank_account_no", "address_and_contact", "address_html", @@ -197,10 +198,16 @@ "fieldtype": "Data", "label": "Mask", "read_only": 1 + }, + { + "fieldname": "branch_code", + "fieldtype": "Data", + "in_global_search": 1, + "label": "Branch Code" } ], "links": [], - "modified": "2020-04-06 21:00:45.379804", + "modified": "2020-07-17 13:59:50.795412", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Account", diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py index 6fec3ab368..76d82e7339 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py @@ -60,12 +60,12 @@ class BankClearance(Document): """.format(condition=condition), {"account": self.account, "from":self.from_date, "to": self.to_date, "bank_account": self.bank_account}, as_dict=1) - pos_entries = [] + pos_sales_invoices, pos_purchase_invoices = [], [] if self.include_pos_transactions: - pos_entries = frappe.db.sql(""" + pos_sales_invoices = frappe.db.sql(""" select "Sales Invoice Payment" as payment_document, sip.name as payment_entry, sip.amount as debit, - si.posting_date, si.debit_to as against_account, sip.clearance_date, + si.posting_date, si.customer as against_account, sip.clearance_date, account.account_currency, 0 as credit from `tabSales Invoice Payment` sip, `tabSales Invoice` si, `tabAccount` account where @@ -75,7 +75,20 @@ class BankClearance(Document): si.posting_date ASC, si.name DESC """, {"account":self.account, "from":self.from_date, "to":self.to_date}, as_dict=1) - entries = sorted(list(payment_entries)+list(journal_entries+list(pos_entries)), + pos_purchase_invoices = frappe.db.sql(""" + select + "Purchase Invoice" as payment_document, pi.name as payment_entry, pi.paid_amount as credit, + pi.posting_date, pi.supplier as against_account, pi.clearance_date, + account.account_currency, 0 as debit + from `tabPurchase Invoice` pi, `tabAccount` account + where + pi.cash_bank_account=%(account)s and pi.docstatus=1 and account.name = pi.cash_bank_account + and pi.posting_date >= %(from)s and pi.posting_date <= %(to)s + order by + pi.posting_date ASC, pi.name DESC + """, {"account": self.account, "from": self.from_date, "to": self.to_date}, as_dict=1) + + entries = sorted(list(payment_entries) + list(journal_entries + list(pos_sales_invoices) + list(pos_purchase_invoices)), key=lambda k: k['posting_date'] or getdate(nowdate())) self.set('payment_entries', []) diff --git a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js index 065d25e6c3..febf85ca6c 100644 --- a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js +++ b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js @@ -4,7 +4,7 @@ cur_frm.add_fetch('bank_account','account','account'); cur_frm.add_fetch('bank_account','bank_account_no','bank_account_no'); cur_frm.add_fetch('bank_account','iban','iban'); -cur_frm.add_fetch('bank','branch_code','branch_code'); +cur_frm.add_fetch('bank_account','branch_code','branch_code'); cur_frm.add_fetch('bank','swift_number','swift_number'); frappe.ui.form.on('Bank Guarantee', { diff --git a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py index f28a07431f..88e1055beb 100644 --- a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py +++ b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py @@ -27,4 +27,4 @@ def get_vouchar_detials(column_list, doctype, docname): for col in column_list: sanitize_searchfield(col) return frappe.db.sql(''' select {columns} from `tab{doctype}` where name=%s''' - .format(columns=", ".join(json.loads(column_list)), doctype=doctype), docname, as_dict=1)[0] + .format(columns=", ".join(column_list), doctype=doctype), docname, as_dict=1)[0] diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js index 0b7cff3d63..2235298201 100644 --- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js +++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js @@ -135,7 +135,7 @@ var create_import_button = function(frm) { callback: function(r) { if(!r.exc) { clearInterval(frm.page["interval"]); - frm.page.set_indicator(__('Import Successfull'), 'blue'); + frm.page.set_indicator(__('Import Successful'), 'blue'); create_reset_button(frm); } } diff --git a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py index 990b896fde..340b9dd58a 100644 --- a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py +++ b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py @@ -9,6 +9,8 @@ from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_orde from erpnext.stock.get_item_details import get_item_details from frappe.test_runner import make_test_objects +test_dependencies = ['Item'] + def test_create_test_data(): frappe.set_user("Administrator") # create test item @@ -26,22 +28,22 @@ def test_create_test_data(): "item_group": "_Test Item Group", "item_name": "_Test Tesla Car", "apply_warehouse_wise_reorder_level": 0, - "warehouse":"_Test Warehouse - _TC", + "warehouse":"Stores - TCP1", "gst_hsn_code": "999800", "valuation_rate": 5000, "standard_rate":5000, "item_defaults": [{ - "company": "_Test Company", - "default_warehouse": "_Test Warehouse - _TC", + "company": "_Test Company with perpetual inventory", + "default_warehouse": "Stores - TCP1", "default_price_list":"_Test Price List", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "buying_cost_center": "_Test Cost Center - _TC", - "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC" + "expense_account": "Cost of Goods Sold - TCP1", + "buying_cost_center": "Main - TCP1", + "selling_cost_center": "Main - TCP1", + "income_account": "Sales - TCP1" }], "show_in_website": 1, "route":"-test-tesla-car", - "website_warehouse": "_Test Warehouse - _TC" + "website_warehouse": "Stores - TCP1" }) item.insert() # create test item price @@ -63,12 +65,12 @@ def test_create_test_data(): "items": [{ "item_code": "_Test Tesla Car" }], - "warehouse":"_Test Warehouse - _TC", + "warehouse":"Stores - TCP1", "coupon_code_based":1, "selling": 1, "rate_or_discount": "Discount Percentage", "discount_percentage": 30, - "company": "_Test Company", + "company": "_Test Company with perpetual inventory", "currency":"INR", "for_price_list":"_Test Price List" }) @@ -95,7 +97,6 @@ def test_create_test_data(): }) coupon_code.insert() - class TestCouponCode(unittest.TestCase): def setUp(self): test_create_test_data() @@ -112,7 +113,10 @@ class TestCouponCode(unittest.TestCase): self.assertEqual(coupon_code.get("used"),0) def test_2_sales_order_with_coupon_code(self): - so = make_sales_order(customer="_Test Customer",selling_price_list="_Test Price List",item_code="_Test Tesla Car", rate=5000,qty=1, do_not_submit=True) + so = make_sales_order(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', + customer="_Test Customer", selling_price_list="_Test Price List", item_code="_Test Tesla Car", rate=5000,qty=1, + do_not_submit=True) + so = frappe.get_doc('Sales Order', so.name) # check item price before coupon code is applied self.assertEqual(so.items[0].rate, 5000) @@ -120,7 +124,7 @@ class TestCouponCode(unittest.TestCase): so.sales_partner='_Test Coupon Partner' so.save() # check item price after coupon code is applied - self.assertEqual(so.items[0].rate, 3500) + self.assertEqual(so.items[0].rate, 3500) so.submit() def test_3_check_coupon_code_used_after_so(self): diff --git a/erpnext/accounts/page/pos/__init__.py b/erpnext/accounts/doctype/dunning/__init__.py similarity index 100% rename from erpnext/accounts/page/pos/__init__.py rename to erpnext/accounts/doctype/dunning/__init__.py diff --git a/erpnext/accounts/doctype/dunning/dunning.js b/erpnext/accounts/doctype/dunning/dunning.js new file mode 100644 index 0000000000..9909c6c2ab --- /dev/null +++ b/erpnext/accounts/doctype/dunning/dunning.js @@ -0,0 +1,162 @@ +// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on("Dunning", { + setup: function (frm) { + frm.set_query("sales_invoice", () => { + return { + filters: { + docstatus: 1, + company: frm.doc.company, + outstanding_amount: [">", 0], + status: "Overdue" + }, + }; + }); + frm.set_query("income_account", () => { + return { + filters: { + company: frm.doc.company, + root_type: "Income", + is_group: 0 + } + }; + }); + }, + refresh: function (frm) { + frm.set_df_property("company", "read_only", frm.doc.__islocal ? 0 : 1); + frm.set_df_property( + "sales_invoice", + "read_only", + frm.doc.__islocal ? 0 : 1 + ); + if (frm.doc.docstatus === 1 && frm.doc.status === "Unresolved") { + frm.add_custom_button(__("Resolve"), () => { + frm.set_value("status", "Resolved"); + }); + } + if (frm.doc.docstatus === 1 && frm.doc.status !== "Resolved") { + frm.add_custom_button( + __("Payment"), + function () { + frm.events.make_payment_entry(frm); + },__("Create") + ); + frm.page.set_inner_btn_group_as_primary(__("Create")); + } + + if(frm.doc.docstatus > 0) { + frm.add_custom_button(__('Ledger'), function() { + frappe.route_options = { + "voucher_no": frm.doc.name, + "from_date": frm.doc.posting_date, + "to_date": frm.doc.posting_date, + "company": frm.doc.company, + "show_cancelled_entries": frm.doc.docstatus === 2 + }; + frappe.set_route("query-report", "General Ledger"); + }, __('View')); + } + }, + overdue_days: function (frm) { + frappe.db.get_value( + "Dunning Type", + { + start_day: ["<", frm.doc.overdue_days], + end_day: [">=", frm.doc.overdue_days], + }, + "dunning_type", + (r) => { + if (r) { + frm.set_value("dunning_type", r.dunning_type); + } else { + frm.set_value("dunning_type", ""); + frm.set_value("rate_of_interest", ""); + frm.set_value("dunning_fee", ""); + } + } + ); + }, + dunning_type: function (frm) { + frm.trigger("get_dunning_letter_text"); + }, + language: function (frm) { + frm.trigger("get_dunning_letter_text"); + }, + get_dunning_letter_text: function (frm) { + if (frm.doc.dunning_type) { + frappe.call({ + method: + "erpnext.accounts.doctype.dunning.dunning.get_dunning_letter_text", + args: { + dunning_type: frm.doc.dunning_type, + language: frm.doc.language, + doc: frm.doc, + }, + callback: function (r) { + if (r.message) { + frm.set_value("body_text", r.message.body_text); + frm.set_value("closing_text", r.message.closing_text); + frm.set_value("language", r.message.language); + } else { + frm.set_value("body_text", ""); + frm.set_value("closing_text", ""); + } + }, + }); + } + }, + due_date: function (frm) { + frm.trigger("calculate_overdue_days"); + }, + posting_date: function (frm) { + frm.trigger("calculate_overdue_days"); + }, + rate_of_interest: function (frm) { + frm.trigger("calculate_interest_and_amount"); + }, + outstanding_amount: function (frm) { + frm.trigger("calculate_interest_and_amount"); + }, + interest_amount: function (frm) { + frm.trigger("calculate_interest_and_amount"); + }, + dunning_fee: function (frm) { + frm.trigger("calculate_interest_and_amount"); + }, + sales_invoice: function (frm) { + frm.trigger("calculate_overdue_days"); + }, + calculate_overdue_days: function (frm) { + if (frm.doc.posting_date && frm.doc.due_date) { + const overdue_days = moment(frm.doc.posting_date).diff( + frm.doc.due_date, + "days" + ); + frm.set_value("overdue_days", overdue_days); + } + }, + calculate_interest_and_amount: function (frm) { + const interest_per_year = frm.doc.outstanding_amount * frm.doc.rate_of_interest / 100; + const interest_amount = flt((interest_per_year * cint(frm.doc.overdue_days)) / 365 || 0, precision('interest_amount')); + const dunning_amount = flt(interest_amount + frm.doc.dunning_fee, precision('dunning_amount')); + const grand_total = flt(frm.doc.outstanding_amount + dunning_amount, precision('grand_total')); + frm.set_value("interest_amount", interest_amount); + frm.set_value("dunning_amount", dunning_amount); + frm.set_value("grand_total", grand_total); + }, + make_payment_entry: function (frm) { + return frappe.call({ + method: + "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry", + args: { + dt: frm.doc.doctype, + dn: frm.doc.name, + }, + callback: function (r) { + var doc = frappe.model.sync(r.message); + frappe.set_route("Form", doc[0].doctype, doc[0].name); + }, + }); + }, +}); diff --git a/erpnext/accounts/doctype/dunning/dunning.json b/erpnext/accounts/doctype/dunning/dunning.json new file mode 100644 index 0000000000..d55bfd1ac4 --- /dev/null +++ b/erpnext/accounts/doctype/dunning/dunning.json @@ -0,0 +1,370 @@ +{ + "actions": [], + "allow_events_in_timeline": 1, + "autoname": "naming_series:", + "creation": "2019-07-05 16:34:31.013238", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "title", + "naming_series", + "sales_invoice", + "customer", + "customer_name", + "outstanding_amount", + "currency", + "conversion_rate", + "column_break_3", + "company", + "posting_date", + "posting_time", + "due_date", + "overdue_days", + "address_and_contact_section", + "address_display", + "contact_display", + "contact_mobile", + "contact_email", + "column_break_18", + "company_address_display", + "section_break_6", + "dunning_type", + "dunning_fee", + "column_break_8", + "rate_of_interest", + "interest_amount", + "section_break_12", + "dunning_amount", + "grand_total", + "income_account", + "column_break_17", + "status", + "printing_setting_section", + "language", + "body_text", + "column_break_22", + "letter_head", + "closing_text", + "amended_from" + ], + "fields": [ + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "reqd": 1 + }, + { + "default": "DUNN-.MM.-.YY.-", + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "DUNN-.MM.-.YY.-" + }, + { + "fieldname": "sales_invoice", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Sales Invoice", + "options": "Sales Invoice", + "reqd": 1 + }, + { + "fetch_from": "sales_invoice.customer_name", + "fieldname": "customer_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Customer Name", + "read_only": 1 + }, + { + "fetch_from": "sales_invoice.outstanding_amount", + "fieldname": "outstanding_amount", + "fieldtype": "Currency", + "label": "Outstanding Amount", + "read_only": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "default": "Today", + "fieldname": "posting_date", + "fieldtype": "Date", + "label": "Date" + }, + { + "fieldname": "overdue_days", + "fieldtype": "Int", + "label": "Overdue Days", + "read_only": 1 + }, + { + "fieldname": "section_break_6", + "fieldtype": "Section Break" + }, + { + "fieldname": "dunning_type", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Dunning Type", + "options": "Dunning Type", + "reqd": 1 + }, + { + "default": "0", + "fieldname": "interest_amount", + "fieldtype": "Currency", + "label": "Interest Amount", + "precision": "2", + "read_only": 1 + }, + { + "fieldname": "column_break_8", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fetch_from": "dunning_type.dunning_fee", + "fetch_if_empty": 1, + "fieldname": "dunning_fee", + "fieldtype": "Currency", + "label": "Dunning Fee", + "precision": "2" + }, + { + "fieldname": "section_break_12", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_17", + "fieldtype": "Column Break" + }, + { + "fieldname": "printing_setting_section", + "fieldtype": "Section Break", + "label": "Printing Setting" + }, + { + "fieldname": "language", + "fieldtype": "Link", + "label": "Print Language", + "options": "Language" + }, + { + "fieldname": "letter_head", + "fieldtype": "Link", + "label": "Letter Head", + "options": "Letter Head" + }, + { + "fieldname": "column_break_22", + "fieldtype": "Column Break" + }, + { + "fetch_from": "sales_invoice.currency", + "fieldname": "currency", + "fieldtype": "Link", + "hidden": 1, + "label": "Currency", + "options": "Currency", + "read_only": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "label": "Amended From", + "no_copy": 1, + "options": "Dunning", + "print_hide": 1, + "read_only": 1 + }, + { + "allow_on_submit": 1, + "default": "{customer_name}", + "fieldname": "title", + "fieldtype": "Data", + "hidden": 1, + "label": "Title" + }, + { + "fieldname": "body_text", + "fieldtype": "Text Editor", + "label": "Body Text" + }, + { + "fieldname": "closing_text", + "fieldtype": "Text Editor", + "label": "Closing Text" + }, + { + "fetch_from": "sales_invoice.due_date", + "fieldname": "due_date", + "fieldtype": "Date", + "label": "Due Date", + "read_only": 1 + }, + { + "fieldname": "posting_time", + "fieldtype": "Time", + "label": "Posting Time" + }, + { + "default": "0", + "fetch_from": "dunning_type.rate_of_interest", + "fetch_if_empty": 1, + "fieldname": "rate_of_interest", + "fieldtype": "Float", + "label": "Rate of Interest (%) Yearly" + }, + { + "fieldname": "address_and_contact_section", + "fieldtype": "Section Break", + "label": "Address and Contact" + }, + { + "fetch_from": "sales_invoice.address_display", + "fieldname": "address_display", + "fieldtype": "Small Text", + "label": "Address", + "read_only": 1 + }, + { + "fetch_from": "sales_invoice.contact_display", + "fieldname": "contact_display", + "fieldtype": "Small Text", + "label": "Contact", + "read_only": 1 + }, + { + "fetch_from": "sales_invoice.contact_mobile", + "fieldname": "contact_mobile", + "fieldtype": "Small Text", + "label": "Mobile No", + "read_only": 1 + }, + { + "fieldname": "column_break_18", + "fieldtype": "Column Break" + }, + { + "fetch_from": "sales_invoice.company_address_display", + "fieldname": "company_address_display", + "fieldtype": "Small Text", + "label": "Company Address", + "read_only": 1 + }, + { + "fetch_from": "sales_invoice.contact_email", + "fieldname": "contact_email", + "fieldtype": "Data", + "label": "Contact Email", + "options": "Email", + "read_only": 1 + }, + { + "fetch_from": "sales_invoice.customer", + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "options": "Customer", + "read_only": 1 + }, + { + "default": "0", + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total", + "precision": "2", + "read_only": 1 + }, + { + "allow_on_submit": 1, + "default": "Unresolved", + "fieldname": "status", + "fieldtype": "Select", + "in_standard_filter": 1, + "label": "Status", + "options": "Draft\nResolved\nUnresolved\nCancelled" + }, + { + "fieldname": "dunning_amount", + "fieldtype": "Currency", + "hidden": 1, + "label": "Dunning Amount", + "read_only": 1 + }, + { + "fieldname": "income_account", + "fieldtype": "Link", + "label": "Income Account", + "options": "Account" + }, + { + "fetch_from": "sales_invoice.conversion_rate", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "hidden": 1, + "label": "Conversion Rate", + "read_only": 1 + } + ], + "is_submittable": 1, + "links": [], + "modified": "2020-08-03 18:55:43.683053", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Dunning", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "submit": 1, + "write": 1 + }, + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, + "submit": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "ASC", + "title_field": "customer_name", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/dunning/dunning.py b/erpnext/accounts/doctype/dunning/dunning.py new file mode 100644 index 0000000000..1a6dbedf56 --- /dev/null +++ b/erpnext/accounts/doctype/dunning/dunning.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +import json +from six import string_types +from frappe.utils import getdate, get_datetime, rounded, flt, cint +from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import days_in_year +from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions +from erpnext.controllers.accounts_controller import AccountsController + + +class Dunning(AccountsController): + def validate(self): + self.validate_overdue_days() + self.validate_amount() + if not self.income_account: + self.income_account = frappe.db.get_value('Company', self.company, 'default_income_account') + + def validate_overdue_days(self): + self.overdue_days = (getdate(self.posting_date) - getdate(self.due_date)).days or 0 + + def validate_amount(self): + amounts = calculate_interest_and_amount( + self.posting_date, self.outstanding_amount, self.rate_of_interest, self.dunning_fee, self.overdue_days) + if self.interest_amount != amounts.get('interest_amount'): + self.interest_amount = flt(amounts.get('interest_amount'), self.precision('interest_amount')) + if self.dunning_amount != amounts.get('dunning_amount'): + self.dunning_amount = flt(amounts.get('dunning_amount'), self.precision('dunning_amount')) + if self.grand_total != amounts.get('grand_total'): + self.grand_total = flt(amounts.get('grand_total'), self.precision('grand_total')) + + def on_submit(self): + self.make_gl_entries() + + def on_cancel(self): + if self.dunning_amount: + self.ignore_linked_doctypes = ('GL Entry', 'Stock Ledger Entry') + make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name) + + def make_gl_entries(self): + if not self.dunning_amount: + return + gl_entries = [] + invoice_fields = ["project", "cost_center", "debit_to", "party_account_currency", "conversion_rate", "cost_center"] + inv = frappe.db.get_value("Sales Invoice", self.sales_invoice, invoice_fields, as_dict=1) + + accounting_dimensions = get_accounting_dimensions() + invoice_fields.extend(accounting_dimensions) + + dunning_in_company_currency = flt(self.dunning_amount * inv.conversion_rate) + default_cost_center = frappe.get_cached_value('Company', self.company, 'cost_center') + + gl_entries.append( + self.get_gl_dict({ + "account": inv.debit_to, + "party_type": "Customer", + "party": self.customer, + "due_date": self.due_date, + "against": self.income_account, + "debit": dunning_in_company_currency, + "debit_in_account_currency": self.dunning_amount, + "against_voucher": self.name, + "against_voucher_type": "Dunning", + "cost_center": inv.cost_center or default_cost_center, + "project": inv.project + }, inv.party_account_currency, item=inv) + ) + gl_entries.append( + self.get_gl_dict({ + "account": self.income_account, + "against": self.customer, + "credit": dunning_in_company_currency, + "cost_center": inv.cost_center or default_cost_center, + "credit_in_account_currency": self.dunning_amount, + "project": inv.project + }, item=inv) + ) + make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding="No", merge_entries=False) + + +def resolve_dunning(doc, state): + for reference in doc.references: + if reference.reference_doctype == 'Sales Invoice' and reference.outstanding_amount <= 0: + dunnings = frappe.get_list('Dunning', filters={ + 'sales_invoice': reference.reference_name, 'status': ('!=', 'Resolved')}) + + for dunning in dunnings: + frappe.db.set_value("Dunning", dunning.name, "status", 'Resolved') + +def calculate_interest_and_amount(posting_date, outstanding_amount, rate_of_interest, dunning_fee, overdue_days): + interest_amount = 0 + grand_total = 0 + if rate_of_interest: + interest_per_year = flt(outstanding_amount) * flt(rate_of_interest) / 100 + interest_amount = (interest_per_year * cint(overdue_days)) / 365 + grand_total = flt(outstanding_amount) + flt(interest_amount) + flt(dunning_fee) + dunning_amount = flt(interest_amount) + flt(dunning_fee) + return { + 'interest_amount': interest_amount, + 'grand_total': grand_total, + 'dunning_amount': dunning_amount} + +@frappe.whitelist() +def get_dunning_letter_text(dunning_type, doc, language=None): + if isinstance(doc, string_types): + doc = json.loads(doc) + if language: + filters = {'parent': dunning_type, 'language': language} + else: + filters = {'parent': dunning_type, 'is_default_language': 1} + letter_text = frappe.db.get_value('Dunning Letter Text', filters, + ['body_text', 'closing_text', 'language'], as_dict=1) + if letter_text: + return { + 'body_text': frappe.render_template(letter_text.body_text, doc), + 'closing_text': frappe.render_template(letter_text.closing_text, doc), + 'language': letter_text.language + } diff --git a/erpnext/accounts/doctype/dunning/dunning_dashboard.py b/erpnext/accounts/doctype/dunning/dunning_dashboard.py new file mode 100644 index 0000000000..19a73ddfa4 --- /dev/null +++ b/erpnext/accounts/doctype/dunning/dunning_dashboard.py @@ -0,0 +1,17 @@ +from __future__ import unicode_literals +from frappe import _ + +def get_data(): + return { + 'fieldname': 'dunning', + 'non_standard_fieldnames': { + 'Journal Entry': 'reference_name', + 'Payment Entry': 'reference_name' + }, + 'transactions': [ + { + 'label': _('Payment'), + 'items': ['Payment Entry', 'Journal Entry'] + } + ] + } \ No newline at end of file diff --git a/erpnext/accounts/doctype/dunning/dunning_list.js b/erpnext/accounts/doctype/dunning/dunning_list.js new file mode 100644 index 0000000000..8dc0a8c857 --- /dev/null +++ b/erpnext/accounts/doctype/dunning/dunning_list.js @@ -0,0 +1,9 @@ +frappe.listview_settings["Dunning"] = { + get_indicator: function (doc) { + if (doc.status === "Resolved") { + return [__("Resolved"), "green", "status,=,Resolved"]; + } else { + return [__("Unresolved"), "red", "status,=,Unresolved"]; + } + }, +}; diff --git a/erpnext/accounts/doctype/dunning/test_dunning.py b/erpnext/accounts/doctype/dunning/test_dunning.py new file mode 100644 index 0000000000..cb18309e3c --- /dev/null +++ b/erpnext/accounts/doctype/dunning/test_dunning.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest +from frappe.utils import add_days, today, nowdate +from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unlink_payment_on_cancel_of_invoice +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice_against_cost_center +from erpnext.accounts.doctype.dunning.dunning import calculate_interest_and_amount +from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry + + +class TestDunning(unittest.TestCase): + @classmethod + def setUpClass(self): + create_dunning_type() + unlink_payment_on_cancel_of_invoice() + + @classmethod + def tearDownClass(self): + unlink_payment_on_cancel_of_invoice(0) + + def test_dunning(self): + dunning = create_dunning() + amounts = calculate_interest_and_amount( + dunning.posting_date, dunning.outstanding_amount, dunning.rate_of_interest, dunning.dunning_fee, dunning.overdue_days) + self.assertEqual(round(amounts.get('interest_amount'), 2), 0.44) + self.assertEqual(round(amounts.get('dunning_amount'), 2), 20.44) + self.assertEqual(round(amounts.get('grand_total'), 2), 120.44) + + def test_gl_entries(self): + dunning = create_dunning() + dunning.submit() + gl_entries = frappe.db.sql("""select account, debit, credit + from `tabGL Entry` where voucher_type='Dunning' and voucher_no=%s + order by account asc""", dunning.name, as_dict=1) + self.assertTrue(gl_entries) + expected_values = dict((d[0], d) for d in [ + ['Debtors - _TC', 20.44, 0.0], + ['Sales - _TC', 0.0, 20.44] + ]) + for gle in gl_entries: + self.assertEquals(expected_values[gle.account][0], gle.account) + self.assertEquals(expected_values[gle.account][1], gle.debit) + self.assertEquals(expected_values[gle.account][2], gle.credit) + + def test_payment_entry(self): + dunning = create_dunning() + dunning.submit() + pe = get_payment_entry("Dunning", dunning.name) + pe.reference_no = "1" + pe.reference_date = nowdate() + pe.paid_from_account_currency = dunning.currency + pe.paid_to_account_currency = dunning.currency + pe.source_exchange_rate = 1 + pe.target_exchange_rate = 1 + pe.insert() + pe.submit() + si_doc = frappe.get_doc('Sales Invoice', dunning.sales_invoice) + self.assertEqual(si_doc.outstanding_amount, 0) + + +def create_dunning(): + posting_date = add_days(today(), -20) + due_date = add_days(today(), -15) + sales_invoice = create_sales_invoice_against_cost_center( + posting_date=posting_date, due_date=due_date, status='Overdue') + dunning_type = frappe.get_doc("Dunning Type", 'First Notice') + dunning = frappe.new_doc("Dunning") + dunning.sales_invoice = sales_invoice.name + dunning.customer_name = sales_invoice.customer_name + dunning.outstanding_amount = sales_invoice.outstanding_amount + dunning.debit_to = sales_invoice.debit_to + dunning.currency = sales_invoice.currency + dunning.company = sales_invoice.company + dunning.posting_date = nowdate() + dunning.due_date = sales_invoice.due_date + dunning.dunning_type = 'First Notice' + dunning.rate_of_interest = dunning_type.rate_of_interest + dunning.dunning_fee = dunning_type.dunning_fee + dunning.save() + return dunning + +def create_dunning_type(): + dunning_type = frappe.new_doc("Dunning Type") + dunning_type.dunning_type = 'First Notice' + dunning_type.start_day = 10 + dunning_type.end_day = 20 + dunning_type.dunning_fee = 20 + dunning_type.rate_of_interest = 8 + dunning_type.append( + "dunning_letter_text", { + 'language': 'en', + 'body_text': 'We have still not received payment for our invoice ', + 'closing_text': 'We kindly request that you pay the outstanding amount immediately, including interest and late fees.' + } + ) + dunning_type.save() diff --git a/erpnext/buying/report/requested_items_to_order/__init__.py b/erpnext/accounts/doctype/dunning_letter_text/__init__.py similarity index 100% rename from erpnext/buying/report/requested_items_to_order/__init__.py rename to erpnext/accounts/doctype/dunning_letter_text/__init__.py diff --git a/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.json b/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.json new file mode 100644 index 0000000000..5ede3a1071 --- /dev/null +++ b/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.json @@ -0,0 +1,70 @@ +{ + "actions": [], + "creation": "2019-12-06 04:25:40.215625", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "language", + "is_default_language", + "section_break_4", + "body_text", + "closing_text", + "section_break_7", + "body_and_closing_text_help" + ], + "fields": [ + { + "fieldname": "language", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Language", + "options": "Language" + }, + { + "default": "0", + "fieldname": "is_default_language", + "fieldtype": "Check", + "label": "Is Default Language" + }, + { + "fieldname": "section_break_4", + "fieldtype": "Section Break" + }, + { + "description": "Letter or Email Body Text", + "fieldname": "body_text", + "fieldtype": "Text Editor", + "in_list_view": 1, + "label": "Body Text" + }, + { + "description": "Letter or Email Closing Text", + "fieldname": "closing_text", + "fieldtype": "Text Editor", + "in_list_view": 1, + "label": "Closing Text" + }, + { + "fieldname": "section_break_7", + "fieldtype": "Section Break" + }, + { + "fieldname": "body_and_closing_text_help", + "fieldtype": "HTML", + "label": "Body and Closing Text Help", + "options": "
The fieldnames you can use in your template are the fields in the document. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)
\n\nTemplates are compiled using the Jinja Templating Language. To learn more about Jinja, read this documentation.
" + } + ], + "istable": 1, + "links": [], + "modified": "2020-07-14 18:02:35.988958", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Dunning Letter Text", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.py b/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.py new file mode 100644 index 0000000000..426497b607 --- /dev/null +++ b/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class DunningLetterText(Document): + pass diff --git a/erpnext/healthcare/doctype/lab_test_groups/__init__.py b/erpnext/accounts/doctype/dunning_type/__init__.py similarity index 100% rename from erpnext/healthcare/doctype/lab_test_groups/__init__.py rename to erpnext/accounts/doctype/dunning_type/__init__.py diff --git a/erpnext/accounts/doctype/dunning_type/dunning_type.js b/erpnext/accounts/doctype/dunning_type/dunning_type.js new file mode 100644 index 0000000000..54156b488d --- /dev/null +++ b/erpnext/accounts/doctype/dunning_type/dunning_type.js @@ -0,0 +1,8 @@ +// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Dunning Type', { + // refresh: function(frm) { + + // } +}); diff --git a/erpnext/accounts/doctype/dunning_type/dunning_type.json b/erpnext/accounts/doctype/dunning_type/dunning_type.json new file mode 100644 index 0000000000..da43664472 --- /dev/null +++ b/erpnext/accounts/doctype/dunning_type/dunning_type.json @@ -0,0 +1,129 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:dunning_type", + "creation": "2019-12-04 04:59:08.003664", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "dunning_type", + "overdue_interval_section", + "start_day", + "column_break_4", + "end_day", + "section_break_6", + "dunning_fee", + "column_break_8", + "rate_of_interest", + "text_block_section", + "dunning_letter_text" + ], + "fields": [ + { + "fieldname": "dunning_type", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Dunning Type", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "dunning_fee", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Dunning Fee" + }, + { + "description": "This section allows the user to set the Body and Closing text of the Dunning Letter for the Dunning Type based on language, which can be used in Print.", + "fieldname": "text_block_section", + "fieldtype": "Section Break", + "label": "Dunning Letter" + }, + { + "fieldname": "dunning_letter_text", + "fieldtype": "Table", + "options": "Dunning Letter Text" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_6", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_8", + "fieldtype": "Column Break" + }, + { + "fieldname": "overdue_interval_section", + "fieldtype": "Section Break", + "label": "Overdue Interval" + }, + { + "fieldname": "start_day", + "fieldtype": "Int", + "label": "Start Day" + }, + { + "fieldname": "end_day", + "fieldtype": "Int", + "label": "End Day" + }, + { + "fieldname": "rate_of_interest", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate of Interest (%) Yearly" + } + ], + "links": [], + "modified": "2020-07-15 17:14:17.835074", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Dunning Type", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Administrator", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/dunning_type/dunning_type.py b/erpnext/accounts/doctype/dunning_type/dunning_type.py new file mode 100644 index 0000000000..8708748428 --- /dev/null +++ b/erpnext/accounts/doctype/dunning_type/dunning_type.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class DunningType(Document): + pass diff --git a/erpnext/accounts/doctype/dunning_type/test_dunning_type.py b/erpnext/accounts/doctype/dunning_type/test_dunning_type.py new file mode 100644 index 0000000000..b2fb26f34a --- /dev/null +++ b/erpnext/accounts/doctype/dunning_type/test_dunning_type.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestDunningType(unittest.TestCase): + pass diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year_dashboard.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year_dashboard.py index c7604ec7cc..58480df119 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year_dashboard.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year_dashboard.py @@ -13,7 +13,7 @@ def get_data(): }, { 'label': _('References'), - 'items': ['Period Closing Voucher', 'Request for Quotation', 'Tax Withholding Category'] + 'items': ['Period Closing Voucher', 'Tax Withholding Category'] }, { 'label': _('Target Details'), diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index a09face791..409c15f75c 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -638,20 +638,12 @@ $.extend(erpnext.journal_entry, { return { filters: filters }; }, - reverse_journal_entry: function(frm) { - var me = frm.doc; - for(var i=0; i{{ _("Account") }} | {{ _("Rate") }} | {{ _("Amount") }} | |
---|---|---|---|
{{ d.account_head }} | {{ d.rate }} % | -{{ d.amount }} {{ currency.symbol }} | +{{ frappe.utils.fmt_money(d.amount, currency=currency) }} |
{{ _("Date") }} | +{{ _("Ref") }} | +{{ _("Party") }} | +{{ _("Debit") }} | +{{ _("Credit") }} | +{{ _("Balance (Dr - Cr)") }} | +|||||
---|---|---|---|---|---|---|---|---|---|---|
{{ frappe.format(row.posting_date, 'Date') }} | +{{ row.voucher_type }}
+ {{ row.voucher_no }} |
+
+ {% if not (filters.party or filters.account) %}
+ {{ row.party or row.account }}
+ + {% endif %} + + {{ _("Against") }}: {{ row.against }} + {{ _("Remarks") }}: {{ row.remarks }} + {% if row.bill_no %} + {{ _("Supplier Invoice No") }}: {{ row.bill_no }} + {% endif %} + |
+ + {{ frappe.utils.fmt_money(row.debit, filters.presentation_currency) }} | ++ {{ frappe.utils.fmt_money(row.credit, filters.presentation_currency) }} | + {% else %} ++ | + | {{ frappe.format(row.account, {fieldtype: "Link"}) or " " }} | ++ {{ row.account and frappe.utils.fmt_money(row.debit, filters.presentation_currency) }} + | ++ {{ row.account and frappe.utils.fmt_money(row.credit, filters.presentation_currency) }} + | + {% endif %} ++ {{ frappe.utils.fmt_money(row.balance, filters.presentation_currency) }} + | +
30 Days | +60 Days | +90 Days | +120 Days | +
---|---|---|---|
{{ aging.range1 }} | +{{ aging.range2 }} | +{{ aging.range3 }} | +{{ aging.range4 }} | +
Printed On {{ frappe.format(frappe.utils.get_datetime(), 'Datetime') }}
\ No newline at end of file diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js new file mode 100644 index 0000000000..7425132c46 --- /dev/null +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js @@ -0,0 +1,132 @@ +// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Process Statement Of Accounts', { + view_properties: function(frm) { + frappe.route_options = {doc_type: 'Customer'}; + frappe.set_route("Form", "Customize Form"); + }, + refresh: function(frm){ + if(!frm.doc.__islocal) { + frm.add_custom_button('Send Emails',function(){ + frappe.call({ + method: "erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.send_emails", + args: { + "document_name": frm.doc.name, + }, + callback: function(r) { + if(r && r.message) { + frappe.show_alert({message: __('Emails Queued'), indicator: 'blue'}); + } + else{ + frappe.msgprint('No Records for these settings.') + } + } + }); + }); + frm.add_custom_button('Download',function(){ + var url = frappe.urllib.get_full_url( + '/api/method/erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.download_statements?' + + 'document_name='+encodeURIComponent(frm.doc.name)) + $.ajax({ + url: url, + type: 'GET', + success: function(result) { + if(jQuery.isEmptyObject(result)){ + frappe.msgprint('No Records for these settings.'); + } + else{ + window.location = url; + } + } + }); + }); + } + }, + onload: function(frm) { + frm.set_query('currency', function(){ + return { + filters: { + 'enabled': 1 + } + } + }); + if(frm.doc.__islocal){ + frm.set_value('from_date', frappe.datetime.add_months(frappe.datetime.get_today(), -1)); + frm.set_value('to_date', frappe.datetime.get_today()); + } + }, + customer_collection: function(frm){ + frm.set_value('collection_name', ''); + if(frm.doc.customer_collection){ + frm.get_field('collection_name').set_label(frm.doc.customer_collection); + } + }, + frequency: function(frm){ + if(frm.doc.frequency != ''){ + frm.set_value('start_date', frappe.datetime.get_today()); + } + else{ + frm.set_value('start_date', ''); + } + }, + fetch_customers: function(frm){ + if(frm.doc.collection_name){ + frappe.call({ + method: "erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.fetch_customers", + args: { + 'customer_collection': frm.doc.customer_collection, + 'collection_name': frm.doc.collection_name, + 'primary_mandatory': frm.doc.primary_mandatory + }, + callback: function(r) { + if(!r.exc) { + if(r.message.length){ + frm.clear_table('customers'); + for (const customer of r.message){ + var row = frm.add_child('customers'); + row.customer = customer.name; + row.primary_email = customer.primary_email; + row.billing_email = customer.billing_email; + } + frm.refresh_field('customers'); + } + else{ + frappe.msgprint('No Customers found with selected options.'); + } + } + } + }); + } + else { + frappe.throw('Enter ' + frm.doc.customer_collection + ' name.'); + } + } +}); + +frappe.ui.form.on('Process Statement Of Accounts Customer', { + customer: function(frm, cdt, cdn){ + var row = locals[cdt][cdn]; + if (!row.customer){ + return; + } + frappe.call({ + method: 'erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.get_customer_emails', + args: { + 'customer_name': row.customer, + 'primary_mandatory': frm.doc.primary_mandatory + }, + callback: function(r){ + if(!r.exe){ + if(r.message.length){ + frappe.model.set_value(cdt, cdn, "primary_email", r.message[0]) + frappe.model.set_value(cdt, cdn, "billing_email", r.message[1]) + } + else { + return + } + } + } + }) + } +}); \ No newline at end of file diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json new file mode 100644 index 0000000000..4be0e2ec06 --- /dev/null +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json @@ -0,0 +1,310 @@ +{ + "actions": [], + "allow_workflow": 1, + "autoname": "Prompt", + "creation": "2020-05-22 16:46:18.712954", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "section_break_11", + "from_date", + "company", + "account", + "group_by", + "cost_center", + "column_break_14", + "to_date", + "finance_book", + "currency", + "project", + "section_break_3", + "customer_collection", + "collection_name", + "fetch_customers", + "column_break_6", + "primary_mandatory", + "column_break_17", + "customers", + "preferences", + "orientation", + "section_break_14", + "include_ageing", + "ageing_based_on", + "section_break_1", + "enable_auto_email", + "section_break_18", + "frequency", + "filter_duration", + "column_break_21", + "start_date", + "section_break_33", + "subject", + "column_break_28", + "cc_to", + "section_break_30", + "body", + "help_text" + ], + "fields": [ + { + "fieldname": "frequency", + "fieldtype": "Select", + "label": "Frequency", + "options": "Weekly\nMonthly\nQuarterly" + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Company", + "options": "Company", + "reqd": 1 + }, + { + "depends_on": "eval:doc.enable_auto_email == 0;", + "fieldname": "from_date", + "fieldtype": "Date", + "label": "From Date", + "mandatory_depends_on": "eval:doc.frequency == '';" + }, + { + "depends_on": "eval:doc.enable_auto_email == 0;", + "fieldname": "to_date", + "fieldtype": "Date", + "label": "To Date", + "mandatory_depends_on": "eval:doc.frequency == '';" + }, + { + "fieldname": "cost_center", + "fieldtype": "Table MultiSelect", + "label": "Cost Center", + "options": "PSOA Cost Center" + }, + { + "fieldname": "project", + "fieldtype": "Table MultiSelect", + "label": "Project", + "options": "PSOA Project" + }, + { + "fieldname": "section_break_3", + "fieldtype": "Section Break", + "label": "Customers" + }, + { + "fieldname": "column_break_6", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_11", + "fieldtype": "Section Break", + "label": "General Ledger Filters" + }, + { + "fieldname": "column_break_14", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_17", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "fieldname": "customer_collection", + "fieldtype": "Select", + "label": "Select Customers By", + "options": "\nCustomer Group\nTerritory\nSales Partner\nSales Person" + }, + { + "depends_on": "eval: doc.customer_collection !== ''", + "fieldname": "collection_name", + "fieldtype": "Dynamic Link", + "label": "Recipient", + "options": "customer_collection" + }, + { + "fieldname": "section_break_1", + "fieldtype": "Section Break", + "label": "Email Settings" + }, + { + "fieldname": "account", + "fieldtype": "Link", + "label": "Account", + "options": "Account" + }, + { + "fieldname": "finance_book", + "fieldtype": "Link", + "label": "Finance Book", + "options": "Finance Book" + }, + { + "fieldname": "preferences", + "fieldtype": "Section Break", + "label": "Print Preferences" + }, + { + "fieldname": "orientation", + "fieldtype": "Select", + "label": "Orientation", + "options": "Landscape\nPortrait" + }, + { + "default": "Today", + "fieldname": "start_date", + "fieldtype": "Date", + "label": "Start Date" + }, + { + "default": "Group by Voucher (Consolidated)", + "fieldname": "group_by", + "fieldtype": "Select", + "label": "Group By", + "options": "\nGroup by Voucher\nGroup by Voucher (Consolidated)" + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "options": "Currency" + }, + { + "default": "0", + "fieldname": "include_ageing", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Include Ageing Summary" + }, + { + "default": "Due Date", + "depends_on": "eval:doc.include_ageing === 1", + "fieldname": "ageing_based_on", + "fieldtype": "Select", + "label": "Ageing Based On", + "options": "Due Date\nPosting Date" + }, + { + "default": "0", + "fieldname": "enable_auto_email", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Enable Auto Email" + }, + { + "fieldname": "section_break_14", + "fieldtype": "Column Break", + "hide_border": 1 + }, + { + "depends_on": "eval: doc.enable_auto_email ==1", + "fieldname": "section_break_18", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "fieldname": "column_break_21", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval: doc.customer_collection !== ''", + "fieldname": "fetch_customers", + "fieldtype": "Button", + "label": "Fetch Customers", + "options": "fetch_customers", + "print_hide": 1, + "report_hide": 1 + }, + { + "default": "1", + "fieldname": "primary_mandatory", + "fieldtype": "Check", + "label": "Send To Primary Contact" + }, + { + "fieldname": "cc_to", + "fieldtype": "Link", + "label": "CC To", + "options": "User" + }, + { + "default": "1", + "fieldname": "filter_duration", + "fieldtype": "Int", + "label": "Filter Duration (Months)" + }, + { + "fieldname": "customers", + "fieldtype": "Table", + "label": "Customers", + "options": "Process Statement Of Accounts Customer", + "reqd": 1 + }, + { + "fieldname": "column_break_28", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_30", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "fieldname": "section_break_33", + "fieldtype": "Section Break", + "hide_border": 1 + }, + { + "fieldname": "help_text", + "fieldtype": "HTML", + "label": "Help Text", + "options": "Statement Of Accounts for {{ customer.name }}
Hello {{ customer.name }},
PFA your Statement Of Accounts from {{ doc.from_date }} to {{ doc.to_date }}.
' + html + '
') - .get(0); - } - }); - - this.prepare_customer_mapper() - this.autocomplete_customers(); - - this.party_field.$input - .on('input', function (e) { - if(me.customers_mapper.length <= 1) { - me.prepare_customer_mapper(e.target.value); - } - me.party_field.awesomeplete.list = me.customers_mapper; - }) - .on('awesomplete-select', function (e) { - var customer = me.party_field.awesomeplete - .get_item(e.originalEvent.text.value); - if (!customer) return; - // create customer link - if (customer.action) { - customer.action.apply(me); - return; - } - me.toggle_list_customer(false); - me.toggle_edit_button(true); - me.update_customer_data(customer); - me.refresh(); - me.set_focus(); - me.list_customers_btn.removeClass("view_customer"); - }) - .on('focus', function (e) { - $(e.target).val('').trigger('input'); - me.toggle_edit_button(false); - - if(me.frm.doc.items.length) { - me.toggle_list_customer(false) - me.toggle_item_cart(true) - } else { - me.toggle_list_customer(true) - me.toggle_item_cart(false) - } - }) - .on("awesomplete-selectcomplete", function (e) { - var item = me.party_field.awesomeplete - .get_item(e.originalEvent.text.value); - // clear text input if item is action - if (item.action) { - $(this).val(""); - } - me.make_item_list(item.customer_name); - }); - }, - - prepare_customer_mapper: function(key) { - var me = this; - var customer_data = ''; - - if (key) { - key = key.toLowerCase().trim(); - var re = new RegExp('%', 'g'); - var reg = new RegExp(key.replace(re, '\\w*\\s*[a-zA-Z0-9]*')); - - customer_data = $.grep(this.customers, function(data) { - contact = me.contacts[data.name]; - if(reg.test(data.name.toLowerCase()) - || reg.test(data.customer_name.toLowerCase()) - || (contact && reg.test(contact["phone"])) - || (contact && reg.test(contact["mobile_no"])) - || (data.customer_group && reg.test(data.customer_group.toLowerCase()))){ - return data; - } - }) - } else { - customer_data = this.customers; - } - - this.customers_mapper = []; - - customer_data.forEach(function (c, index) { - if(index < 30) { - contact = me.contacts[c.name]; - if(contact && !c['phone']) { - c["phone"] = contact["phone"]; - c["email_id"] = contact["email_id"]; - c["mobile_no"] = contact["mobile_no"]; - } - - me.customers_mapper.push({ - label: c.name, - value: c.name, - customer_name: c.customer_name, - customer_group: c.customer_group, - territory: c.territory, - phone: contact ? contact["phone"] : '', - mobile_no: contact ? contact["mobile_no"] : '', - email_id: contact ? contact["email_id"] : '', - searchtext: ['customer_name', 'customer_group', 'name', 'value', - 'label', 'email_id', 'phone', 'mobile_no'] - .map(key => c[key]).join(' ') - .toLowerCase() - }); - } else { - return; - } - }); - - this.customers_mapper.push({ - label: "" - + " " - + __("Create a new Customer") - + "", - value: 'is_action', - action: me.add_customer - }); - }, - - autocomplete_customers: function() { - this.party_field.awesomeplete.list = this.customers_mapper; - }, - - toggle_edit_button: function(flag) { - this.page.wrapper.find('.edit-customer-btn').toggle(flag); - }, - - toggle_list_customer: function(flag) { - this.list_customers.toggle(flag); - }, - - toggle_item_cart: function(flag) { - this.wrapper.find('.pos-bill-wrapper').toggle(flag); - }, - - add_customer: function() { - this.frm.doc.customer = ""; - this.update_customer(true); - this.numeric_keypad.show(); - }, - - update_customer: function (new_customer) { - var me = this; - - this.customer_doc = new frappe.ui.Dialog({ - 'title': 'Customer', - fields: [ - { - "label": __("Full Name"), - "fieldname": "full_name", - "fieldtype": "Data", - "reqd": 1 - }, - { - "fieldtype": "Section Break" - }, - { - "label": __("Email Id"), - "fieldname": "email_id", - "fieldtype": "Data" - }, - { - "fieldtype": "Column Break" - }, - { - "label": __("Contact Number"), - "fieldname": "phone", - "fieldtype": "Data" - }, - { - "fieldtype": "Section Break" - }, - { - "label": __("Address Name"), - "read_only": 1, - "fieldname": "name", - "fieldtype": "Data" - }, - { - "label": __("Address Line 1"), - "fieldname": "address_line1", - "fieldtype": "Data" - }, - { - "label": __("Address Line 2"), - "fieldname": "address_line2", - "fieldtype": "Data" - }, - { - "fieldtype": "Column Break" - }, - { - "label": __("City"), - "fieldname": "city", - "fieldtype": "Data" - }, - { - "label": __("State"), - "fieldname": "state", - "fieldtype": "Data" - }, - { - "label": __("ZIP Code"), - "fieldname": "pincode", - "fieldtype": "Data" - }, - { - "label": __("Customer POS Id"), - "fieldname": "customer_pos_id", - "fieldtype": "Data", - "hidden": 1 - } - ] - }) - this.customer_doc.show() - this.render_address_data() - - this.customer_doc.set_primary_action(__("Save"), function () { - me.make_offline_customer(new_customer); - me.pos_bill.show(); - me.list_customers.hide(); - }); - }, - - render_address_data: function() { - var me = this; - this.address_data = this.address[this.frm.doc.customer] || {}; - if(!this.address_data.email_id || !this.address_data.phone) { - this.address_data = this.contacts[this.frm.doc.customer]; - } - - this.customer_doc.set_values(this.address_data) - if(!this.customer_doc.fields_dict.full_name.$input.val()) { - this.customer_doc.set_value("full_name", this.frm.doc.customer) - } - - if(!this.customer_doc.fields_dict.customer_pos_id.value) { - this.customer_doc.set_value("customer_pos_id", frappe.datetime.now_datetime()) - } - }, - - get_address_from_localstorage: function() { - this.address_details = this.get_customers_details() - return this.address_details[this.frm.doc.customer] - }, - - make_offline_customer: function(new_customer) { - this.frm.doc.customer = this.frm.doc.customer || this.customer_doc.get_values().full_name; - this.frm.doc.customer_pos_id = this.customer_doc.fields_dict.customer_pos_id.value; - this.customer_details = this.get_customers_details(); - this.customer_details[this.frm.doc.customer] = this.get_prompt_details(); - this.party_field.$input.val(this.frm.doc.customer); - this.update_address_and_customer_list(new_customer) - this.autocomplete_customers(); - this.update_customer_in_localstorage() - this.update_customer_in_localstorage() - this.customer_doc.hide() - }, - - update_address_and_customer_list: function(new_customer) { - var me = this; - if(new_customer) { - this.customers_mapper.push({ - label: this.frm.doc.customer, - value: this.frm.doc.customer, - customer_group: "", - territory: "" - }); - } - - this.address[this.frm.doc.customer] = JSON.parse(this.get_prompt_details()) - }, - - get_prompt_details: function() { - this.prompt_details = this.customer_doc.get_values(); - this.prompt_details['country'] = this.pos_profile_data.country; - this.prompt_details['territory'] = this.pos_profile_data["territory"]; - this.prompt_details['customer_group'] = this.pos_profile_data["customer_group"]; - this.prompt_details['customer_pos_id'] = this.customer_doc.fields_dict.customer_pos_id.value; - return JSON.stringify(this.prompt_details) - }, - - update_customer_data: function (doc) { - var me = this; - this.frm.doc.customer = doc.label || doc.name; - this.frm.doc.customer_name = doc.customer_name; - this.frm.doc.customer_group = doc.customer_group; - this.frm.doc.territory = doc.territory; - this.pos_bill.show(); - this.numeric_keypad.show(); - }, - - make_item_list: function (customer) { - var me = this; - if (!this.price_list) { - frappe.msgprint(__("Price List not found or disabled")); - return; - } - - me.item_timeout = null; - - var $wrap = me.wrapper.find(".item-list"); - me.wrapper.find(".item-list").empty(); - - if (this.items.length > 0) { - $.each(this.items, function(index, obj) { - let customer_price_list = me.customer_wise_price_list[customer]; - let item_price - if (customer && customer_price_list && customer_price_list[obj.name]) { - item_price = format_currency(customer_price_list[obj.name], me.frm.doc.currency); - } else { - item_price = format_currency(me.price_list_data[obj.name], me.frm.doc.currency); - } - if(index < me.page_len) { - $(frappe.render_template("pos_item", { - item_code: obj.name, - item_price: item_price, - item_name: obj.name === obj.item_name ? "" : obj.item_name, - item_image: obj.image, - item_stock: __('Stock Qty') + ": " + me.get_actual_qty(obj), - item_uom: obj.stock_uom, - color: frappe.get_palette(obj.item_name), - abbr: frappe.get_abbr(obj.item_name) - })).tooltip().appendTo($wrap); - } - }); - - $wrap.append(` -" - +__("Not items found")+"
").appendTo($wrap) - } - - if (this.items.length == 1 - && this.search_item.$input.val()) { - this.search_item.$input.val(""); - this.add_to_cart(); - } - }, - - get_items: function (item_code) { - // To search item as per the key enter - - var me = this; - this.item_serial_no = {}; - this.item_batch_no = {}; - - if (item_code) { - return $.grep(this.item_data, function (item) { - if (item.item_code == item_code) { - return true - } - }) - } - - this.items_list = this.apply_category(); - - key = this.search_item.$input.val().toLowerCase().replace(/[&\/\\#,+()\[\]$~.'":*?<>{}]/g, '\\$&'); - var re = new RegExp('%', 'g'); - var reg = new RegExp(key.replace(re, '[\\w*\\s*[a-zA-Z0-9]*]*')) - search_status = true - - if (key) { - return $.grep(this.items_list, function (item) { - if (search_status) { - if (me.batch_no_data[item.item_code] && - in_list(me.batch_no_data[item.item_code], me.search_item.$input.val())) { - search_status = false; - return me.item_batch_no[item.item_code] = me.search_item.$input.val() - } else if (me.serial_no_data[item.item_code] - && in_list(Object.keys(me.serial_no_data[item.item_code]), me.search_item.$input.val())) { - search_status = false; - me.item_serial_no[item.item_code] = [me.search_item.$input.val(), me.serial_no_data[item.item_code][me.search_item.$input.val()]] - return true - } else if (me.barcode_data[item.item_code] && - in_list(me.barcode_data[item.item_code], me.search_item.$input.val())) { - search_status = false; - return true; - } else if (reg.test(item.item_code.toLowerCase()) || (item.description && reg.test(item.description.toLowerCase())) || - reg.test(item.item_name.toLowerCase()) || reg.test(item.item_group.toLowerCase())) { - return true - } - } - }) - } else { - return this.items_list; - } - }, - - apply_category: function() { - var me = this; - category = this.selected_item_group || "All Item Groups"; - if(category == 'All Item Groups') { - return this.item_data - } else { - return this.item_data.filter(function(element, index, array){ - return element.item_group == category; - }); - } - }, - - bind_items_event: function() { - var me = this; - $(this.wrapper).on('click', '.pos-bill-item', function() { - $(me.wrapper).find('.pos-bill-item').removeClass('active'); - $(this).addClass('active'); - me.numeric_val = ""; - me.numeric_id = "" - me.item_code = $(this).attr("data-item-code"); - me.render_selected_item() - me.bind_qty_event() - me.update_rate() - $(me.wrapper).find(".selected-item").scrollTop(1000); - }) - }, - - bind_qty_event: function () { - var me = this; - - $(this.wrapper).on("change", ".pos-item-qty", function () { - var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code"); - var qty = $(this).val(); - me.update_qty(item_code, qty); - me.update_value(); - }) - - $(this.wrapper).on("focusout", ".pos-item-qty", function () { - var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code"); - var qty = $(this).val(); - me.update_qty(item_code, qty, true); - me.update_value(); - }) - - $(this.wrapper).find("[data-action='increase-qty']").on("click", function () { - var item_code = $(this).parents(".pos-bill-item").attr("data-item-code"); - var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) + 1; - me.update_qty(item_code, qty); - }) - - $(this.wrapper).find("[data-action='decrease-qty']").on("click", function () { - var item_code = $(this).parents(".pos-bill-item").attr("data-item-code"); - var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1; - me.update_qty(item_code, qty); - }) - - $(this.wrapper).on("change", ".pos-item-disc", function () { - var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code"); - var discount = $(this).val(); - if(discount > 100){ - discount = $(this).val(''); - frappe.show_alert({ - indicator: 'red', - message: __('Discount amount cannot be greater than 100%') - }); - me.update_discount(item_code, discount); - }else{ - me.update_discount(item_code, discount); - me.update_value(); - } - }) - }, - - bind_events: function() { - var me = this; - // if form is local then allow this function - // $(me.wrapper).find(".pos-item-wrapper").on("click", function () { - $(this.wrapper).on("click", ".pos-item-wrapper", function () { - me.item_code = ''; - me.customer_validate(); - if($(me.pos_bill).is(":hidden")) return; - - if (me.frm.doc.docstatus == 0) { - me.items = me.get_items($(this).attr("data-item-code")) - me.add_to_cart(); - me.clear_selected_row(); - } - }); - - me.bind_delete_event() - }, - - update_qty: function (item_code, qty, remove_zero_qty_items) { - var me = this; - this.items = this.get_items(item_code); - this.validate_serial_no() - this.set_item_details(item_code, "qty", qty, remove_zero_qty_items); - }, - - update_discount: function(item_code, discount) { - var me = this; - this.items = this.get_items(item_code); - this.set_item_details(item_code, "discount_percentage", discount); - }, - - update_rate: function () { - var me = this; - $(this.wrapper).on("change", ".pos-item-price", function () { - var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code"); - me.set_item_details(item_code, "rate", $(this).val()); - me.update_value() - }) - }, - - update_value: function() { - var me = this; - var fields = {qty: ".pos-item-qty", "discount_percentage": ".pos-item-disc", - "rate": ".pos-item-price", "amount": ".pos-amount"} - this.child_doc = this.get_child_item(this.item_code); - - if(me.child_doc.length) { - $.each(fields, function(key, field) { - $(me.selected_row).find(field).val(me.child_doc[0][key]) - }) - } else { - this.clear_selected_row(); - } - }, - - clear_selected_row: function() { - $(this.wrapper).find('.selected-item').empty(); - }, - - render_selected_item: function() { - this.child_doc = this.get_child_item(this.item_code); - $(this.wrapper).find('.selected-item').empty(); - if(this.child_doc.length) { - this.child_doc[0]["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false, - this.child_doc[0]["allow_user_to_edit_discount"] = this.pos_profile_data["allow_user_to_edit_discount"] ? true : false; - this.selected_row = $(frappe.render_template("pos_selected_item", this.child_doc[0])) - $(this.wrapper).find('.selected-item').html(this.selected_row) - } - - $(this.selected_row).find('.form-control').click(function(){ - $(this).select(); - }) - }, - - get_child_item: function(item_code) { - var me = this; - return $.map(me.frm.doc.items, function(doc){ - if(doc.item_code == item_code) { - return doc - } - }) - }, - - set_item_details: function (item_code, field, value, remove_zero_qty_items) { - var me = this; - if (value < 0) { - frappe.throw(__("Enter value must be positive")); - } - - this.remove_item = [] - $.each(this.frm.doc["items"] || [], function (i, d) { - if (d.item_code == item_code) { - if (d.serial_no && field == 'qty') { - me.validate_serial_no_qty(d, item_code, field, value) - } - - d[field] = flt(value); - d.amount = flt(d.rate) * flt(d.qty); - if (d.qty == 0 && remove_zero_qty_items) { - me.remove_item.push(d.idx) - } - - if(field=="discount_percentage" && value == 0) { - d.rate = d.price_list_rate; - } - } - }); - - if (field == 'qty') { - this.remove_zero_qty_items_from_cart(); - } - - this.update_paid_amount_status(false) - }, - - remove_zero_qty_items_from_cart: function () { - var me = this; - var idx = 0; - this.items = [] - $.each(this.frm.doc["items"] || [], function (i, d) { - if (!in_list(me.remove_item, d.idx)) { - d.idx = idx; - me.items.push(d); - idx++; - } - }); - - this.frm.doc["items"] = this.items; - }, - - make_discount_field: function () { - var me = this; - - this.wrapper.find('input.discount-percentage').on("change", function () { - me.frm.doc.additional_discount_percentage = flt($(this).val(), precision("additional_discount_percentage")); - - if(me.frm.doc.additional_discount_percentage && me.frm.doc.discount_amount) { - // Reset discount amount - me.frm.doc.discount_amount = 0; - } - - var total = me.frm.doc.grand_total - - if (me.frm.doc.apply_discount_on == 'Net Total') { - total = me.frm.doc.net_total - } - - me.frm.doc.discount_amount = flt(total * flt(me.frm.doc.additional_discount_percentage) / 100, precision("discount_amount")); - me.refresh(); - me.wrapper.find('input.discount-amount').val(me.frm.doc.discount_amount) - }); - - this.wrapper.find('input.discount-amount').on("change", function () { - me.frm.doc.discount_amount = flt($(this).val(), precision("discount_amount")); - me.frm.doc.additional_discount_percentage = 0.0; - me.refresh(); - me.wrapper.find('input.discount-percentage').val(0); - }); - }, - - customer_validate: function () { - var me = this; - if (!this.frm.doc.customer || this.party_field.get_value() == "") { - frappe.throw(__("Please select customer")) - } - }, - - add_to_cart: function () { - var me = this; - var caught = false; - var no_of_items = me.wrapper.find(".pos-bill-item").length; - - this.customer_validate(); - this.mandatory_batch_no(); - this.validate_serial_no(); - this.validate_warehouse(); - - if (no_of_items != 0) { - $.each(this.frm.doc["items"] || [], function (i, d) { - if (d.item_code == me.items[0].item_code) { - caught = true; - d.qty += 1; - d.amount = flt(d.rate) * flt(d.qty); - if (me.item_serial_no[d.item_code]) { - d.serial_no += '\n' + me.item_serial_no[d.item_code][0] - d.warehouse = me.item_serial_no[d.item_code][1] - } - - if (me.item_batch_no.length) { - d.batch_no = me.item_batch_no[d.item_code] - } - } - }); - } - - // if item not found then add new item - if (!caught) - this.add_new_item_to_grid(); - - this.update_paid_amount_status(false) - this.wrapper.find(".item-cart-items").scrollTop(1000); - }, - - add_new_item_to_grid: function () { - var me = this; - this.child = frappe.model.add_child(this.frm.doc, this.frm.doc.doctype + " Item", "items"); - this.child.item_code = this.items[0].item_code; - this.child.item_name = this.items[0].item_name; - this.child.stock_uom = this.items[0].stock_uom; - this.child.uom = this.items[0].sales_uom || this.items[0].stock_uom; - this.child.conversion_factor = this.items[0].conversion_factor || 1; - this.child.brand = this.items[0].brand; - this.child.description = this.items[0].description || this.items[0].item_name; - this.child.discount_percentage = 0.0; - this.child.qty = 1; - this.child.item_group = this.items[0].item_group; - this.child.cost_center = this.pos_profile_data['cost_center'] || this.items[0].cost_center; - this.child.income_account = this.pos_profile_data['income_account'] || this.items[0].income_account; - this.child.warehouse = (this.item_serial_no[this.child.item_code] - ? this.item_serial_no[this.child.item_code][1] : (this.pos_profile_data['warehouse'] || this.items[0].default_warehouse)); - - customer = this.frm.doc.customer; - let rate; - - customer_price_list = this.customer_wise_price_list[customer] - if (customer_price_list && customer_price_list[this.child.item_code]){ - rate = flt(this.customer_wise_price_list[customer][this.child.item_code] * this.child.conversion_factor, 9) / flt(this.frm.doc.conversion_rate, 9); - } - else{ - rate = flt(this.price_list_data[this.child.item_code] * this.child.conversion_factor, 9) / flt(this.frm.doc.conversion_rate, 9); - } - - this.child.price_list_rate = rate; - this.child.rate = rate; - this.child.actual_qty = me.get_actual_qty(this.items[0]); - this.child.amount = flt(this.child.qty) * flt(this.child.rate); - this.child.batch_no = this.item_batch_no[this.child.item_code]; - this.child.serial_no = (this.item_serial_no[this.child.item_code] - ? this.item_serial_no[this.child.item_code][0] : ''); - this.child.item_tax_rate = JSON.stringify(this.tax_data[this.child.item_code]); - }, - - update_paid_amount_status: function (update_paid_amount) { - if (this.frm.doc.offline_pos_name) { - update_paid_amount = update_paid_amount ? false : true; - } - - this.refresh(update_paid_amount); - }, - - refresh: function (update_paid_amount) { - var me = this; - this.refresh_fields(update_paid_amount); - this.set_primary_action(); - }, - - refresh_fields: function (update_paid_amount) { - this.apply_pricing_rule(); - this.discount_amount_applied = false; - this._calculate_taxes_and_totals(); - this.calculate_discount_amount(); - this.show_items_in_item_cart(); - this.set_taxes(); - this.calculate_outstanding_amount(update_paid_amount); - this.set_totals(); - this.update_total_qty(); - }, - - get_company_currency: function () { - return erpnext.get_currency(this.frm.doc.company); - }, - - show_items_in_item_cart: function () { - var me = this; - var $items = this.wrapper.find(".items").empty(); - var $no_items_message = this.wrapper.find(".no-items-message"); - $no_items_message.toggle(this.frm.doc.items.length === 0); - - var $totals_area = this.wrapper.find('.totals-area'); - $totals_area.toggle(this.frm.doc.items.length > 0); - - $.each(this.frm.doc.items || [], function (i, d) { - $(frappe.render_template("pos_bill_item_new", { - item_code: d.item_code, - item_name: (d.item_name === d.item_code || !d.item_name) ? "" : ("{{_(\\\"Description\\\")}} | \\n\\t{{_(\\\"Amount\\\")}} | \\n
---|---|
\\n {{_(\\\"Outstanding Amount\\\")}}\\n | \\n\\n {{doc.get_formatted(\\\"outstanding_amount\\\")}}\\n | \\n
\\n {{_(\\\"Interest \\\")}} {{doc.rate_of_interest}}% p.a. ({{doc.overdue_days}} {{_(\\\"days\\\")}})\\n | \\n\\n {{doc.get_formatted(\\\"interest_amount\\\")}}\\n | \\n
\\n {{_(\\\"Dunning Fee\\\")}}\\n | \\n\\n {{doc.get_formatted(\\\"dunning_fee\\\")}}\\n | \\n
\n\t{{ doc.company }}
\n\t{% if doc.company_address_display %}\n\t\t{% set company_address = doc.company_address_display.replace(\"\\n\", \" \").replace(\"
\", \" \") %}\n\t\t{% if \"GSTIN\" not in company_address %}\n\t\t\t{{ company_address }}\n\t\t\t{{ _(\"GSTIN\") }}:{{ doc.company_gstin }}\n\t\t{% else %}\n\t\t\t{{ company_address.replace(\"GSTIN\", \"
GSTIN\") }}\n\t\t{% endif %}\n\t{% endif %}\n\t
\n\t{% if doc.docstatus == 0 %}\n\t\t{{ doc.status + \" \"+ (doc.select_print_heading or _(\"Invoice\")) }}
\n\t{% else %}\n\t\t{{ doc.select_print_heading or _(\"Invoice\") }}
\n\t{% endif %}\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{% if doc.grand_total > 50000 %}\n\t\t{% set customer_address = doc.address_display.replace(\"\\n\", \" \").replace(\"
\", \" \") %}\n\t\t{{ _(\"Customer\") }}:
\n\t\t{{ doc.customer_name }}
\n\t\t{{ customer_address }}\n\t{% endif %}\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.gst_hsn_code -%}\n\t\t\t\t\t {{ _(\"HSN/SAC\") }}: {{ item.gst_hsn_code }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t {{ _(\"Serial No\") }}: {{ item.serial_no }}\n\t\t\t\t{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.rate }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t\t{{ row.description }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"change_amount\") }}\n\t\t\t | \n\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", + "html": "\n\n{% if letter_head %}\n {{ letter_head }}\n{% endif %}\n\n\t{{ doc.company }}
\n\t{% if doc.company_address_display %}\n\t\t{% set company_address = doc.company_address_display.replace(\"\\n\", \" \").replace(\"
\", \" \") %}\n\t\t{% if \"GSTIN\" not in company_address %}\n\t\t\t{{ company_address }}\n\t\t\t{{ _(\"GSTIN\") }}:{{ doc.company_gstin }}\n\t\t{% else %}\n\t\t\t{{ company_address.replace(\"GSTIN\", \"
GSTIN\") }}\n\t\t{% endif %}\n\t{% endif %}\n\t
\n\t{% if doc.docstatus == 0 %}\n\t\t{{ doc.status + \" \"+ (doc.select_print_heading or _(\"Invoice\")) }}
\n\t{% else %}\n\t\t{{ doc.select_print_heading or _(\"Invoice\") }}
\n\t{% endif %}\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{% if doc.grand_total > 50000 %}\n\t\t{% set customer_address = doc.address_display.replace(\"\\n\", \" \").replace(\"
\", \" \") %}\n\t\t{{ _(\"Customer\") }}:
\n\t\t{{ doc.customer_name }}
\n\t\t{{ customer_address }}\n\t{% endif %}\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.gst_hsn_code -%}\n\t\t\t\t\t {{ _(\"HSN/SAC\") }}: {{ item.gst_hsn_code }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t {{ _(\"Serial No\") }}: {{ item.serial_no }}\n\t\t\t\t{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.rate }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t\t{{ row.description }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"change_amount\") }}\n\t\t\t | \n\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", "idx": 0, "line_breaks": 0, - "modified": "2019-12-09 17:39:23.356573", + "modified": "2020-04-29 16:39:12.936215", "modified_by": "Administrator", "module": "Accounts", "name": "GST POS Invoice", diff --git a/erpnext/accounts/print_format/pos_invoice/pos_invoice.json b/erpnext/accounts/print_format/pos_invoice/pos_invoice.json index be699228c5..13a973d234 100644 --- a/erpnext/accounts/print_format/pos_invoice/pos_invoice.json +++ b/erpnext/accounts/print_format/pos_invoice/pos_invoice.json @@ -6,10 +6,10 @@ "doc_type": "Sales Invoice", "docstatus": 0, "doctype": "Print Format", - "html": "\n\n{% if letter_head %}\n {{ letter_head }}\n{% endif %}\n\n\n\t{{ doc.company }}
\n\t{{ doc.select_print_heading or _(\"Invoice\") }}
\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{{ _(\"Customer\") }}: {{ doc.customer_name }}\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.get_formatted(\"rate\") }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t\t{{ row.description }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"change_amount\") }}\n\t\t\t\t | \n\t\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", + "html": "\n\n{% if letter_head %}\n {{ letter_head }}\n{% endif %}\n\n\n\t{{ doc.company }}
\n\t{{ doc.select_print_heading or _(\"Invoice\") }}
\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{{ _(\"Customer\") }}: {{ doc.customer_name }}\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.get_formatted(\"rate\") }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t\t{{ row.description }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"change_amount\") }}\n\t\t\t\t | \n\t\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", "idx": 1, "line_breaks": 0, - "modified": "2019-12-09 17:40:53.183574", + "modified": "2020-04-29 16:35:07.043058", "modified_by": "Administrator", "module": "Accounts", "name": "POS Invoice", diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 66aa18058b..59117c8174 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -643,8 +643,10 @@ class ReceivablePayableReport(object): account_type = "Receivable" if self.party_type == "Customer" else "Payable" accounts = [d.name for d in frappe.get_all("Account", filters={"account_type": account_type, "company": self.filters.company})] - conditions.append("account in (%s)" % ','.join(['%s'] *len(accounts))) - values += accounts + + if accounts: + conditions.append("account in (%s)" % ','.join(['%s'] *len(accounts))) + values += accounts def add_customer_filters(self, conditions, values): if self.filters.get("customer_group"): diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index c2c7207e37..219871b1d6 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -378,7 +378,7 @@ def set_gl_entries_by_account(from_date, to_date, root_lft, root_rgt, filters, g if filters and filters.get('presentation_currency') != d.default_currency: currency_info['company'] = d.name currency_info['company_currency'] = d.default_currency - convert_to_presentation_currency(gl_entries, currency_info) + convert_to_presentation_currency(gl_entries, currency_info, filters.get('company')) for entry in gl_entries: key = entry.account_number or entry.account_name diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py index 2cb10b11e1..10b32fea56 100644 --- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py +++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py @@ -173,7 +173,7 @@ class PartyLedgerSummaryReport(object): from `tabGL Entry` gle {join} where - gle.docstatus < 2 and gle.party_type=%(party_type)s and ifnull(gle.party, '') != '' + gle.docstatus < 2 and gle.is_cancelled = 0 and gle.party_type=%(party_type)s and ifnull(gle.party, '') != '' and gle.posting_date <= %(to_date)s {conditions} order by gle.posting_date """.format(join=join, join_field=join_field, conditions=conditions), self.filters, as_dict=True) @@ -248,7 +248,7 @@ class PartyLedgerSummaryReport(object): from `tabGL Entry` where - docstatus < 2 + docstatus < 2 and is_cancelled = 0 and (voucher_type, voucher_no) in ( select voucher_type, voucher_no from `tabGL Entry` gle, `tabAccount` acc where acc.name = gle.account and acc.account_type = '{income_or_expense}' diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 3785ebf215..1b65a318b6 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -14,7 +14,7 @@ import frappe, erpnext from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency from erpnext.accounts.utils import get_fiscal_year from frappe import _ -from frappe.utils import (flt, getdate, get_first_day, add_months, add_days, formatdate, cstr) +from frappe.utils import (flt, getdate, get_first_day, add_months, add_days, formatdate, cstr, cint) from six import itervalues from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children @@ -46,7 +46,7 @@ def get_period_list(from_fiscal_year, to_fiscal_year, period_start_date, period_ start_date = year_start_date months = get_months(year_start_date, year_end_date) - for i in range(math.ceil(months / months_to_add)): + for i in range(cint(math.ceil(months / months_to_add))): period = frappe._dict({ "from_date": start_date }) @@ -423,7 +423,7 @@ def set_gl_entries_by_account( distributed_cost_center_query=distributed_cost_center_query), gl_filters, as_dict=True) #nosec if filters and filters.get('presentation_currency'): - convert_to_presentation_currency(gl_entries, get_currency(filters)) + convert_to_presentation_currency(gl_entries, get_currency(filters), filters.get('company')) for entry in gl_entries: gl_entries_by_account.setdefault(entry.account, []).append(entry) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.js b/erpnext/accounts/report/general_ledger/general_ledger.js index 1fc0f79478..fb0d359926 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.js +++ b/erpnext/accounts/report/general_ledger/general_ledger.js @@ -146,6 +146,12 @@ frappe.query_reports["General Ledger"] = { return frappe.db.get_link_options('Project', txt); } }, + { + "fieldname": "include_dimensions", + "label": __("Consider Accounting Dimensions"), + "fieldtype": "Check", + "default": 0 + }, { "fieldname": "show_opening_entries", "label": __("Show Opening Entries"), diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index fcd36e4e6e..0599707446 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -106,15 +106,20 @@ def set_account_currency(filters): return filters def get_result(filters, account_details): - gl_entries = get_gl_entries(filters) + accounting_dimensions = [] + if filters.get("include_dimensions"): + accounting_dimensions = get_accounting_dimensions() - data = get_data_with_opening_closing(filters, account_details, gl_entries) + gl_entries = get_gl_entries(filters, accounting_dimensions) + + data = get_data_with_opening_closing(filters, account_details, + accounting_dimensions, gl_entries) result = get_result_as_list(data, filters) return result -def get_gl_entries(filters): +def get_gl_entries(filters, accounting_dimensions): currency_map = get_currency(filters) select_fields = """, debit, credit, debit_in_account_currency, credit_in_account_currency """ @@ -128,6 +133,10 @@ def get_gl_entries(filters): filters['company_fb'] = frappe.db.get_value("Company", filters.get("company"), 'default_finance_book') + dimension_fields = "" + if accounting_dimensions: + dimension_fields = ', '.join(accounting_dimensions) + ',' + distributed_cost_center_query = "" if filters and filters.get('cost_center'): select_fields_with_percentage = """, debit*(DCC_allocation.percentage_allocation/100) as debit, credit*(DCC_allocation.percentage_allocation/100) as credit, debit_in_account_currency*(DCC_allocation.percentage_allocation/100) as debit_in_account_currency, @@ -141,7 +150,7 @@ def get_gl_entries(filters): party_type, party, voucher_type, - voucher_no, + voucher_no, {dimension_fields} cost_center, project, against_voucher_type, against_voucher, @@ -160,13 +169,14 @@ def get_gl_entries(filters): {conditions} AND posting_date <= %(to_date)s AND cost_center = DCC_allocation.parent - """.format(select_fields_with_percentage=select_fields_with_percentage, conditions=get_conditions(filters).replace("and cost_center in %(cost_center)s ", '')) + """.format(dimension_fields=dimension_fields,select_fields_with_percentage=select_fields_with_percentage, conditions=get_conditions(filters).replace("and cost_center in %(cost_center)s ", '')) gl_entries = frappe.db.sql( """ select name as gl_entry, posting_date, account, party_type, party, - voucher_type, voucher_no, cost_center, project, + voucher_type, voucher_no, {dimension_fields} + cost_center, project, against_voucher_type, against_voucher, account_currency, remarks, against, is_opening, creation {select_fields} from `tabGL Entry` @@ -174,13 +184,13 @@ def get_gl_entries(filters): {distributed_cost_center_query} {order_by_statement} """.format( - select_fields=select_fields, conditions=get_conditions(filters), distributed_cost_center_query=distributed_cost_center_query, + dimension_fields=dimension_fields, select_fields=select_fields, conditions=get_conditions(filters), distributed_cost_center_query=distributed_cost_center_query, order_by_statement=order_by_statement ), filters, as_dict=1) if filters.get('presentation_currency'): - return convert_to_presentation_currency(gl_entries, currency_map) + return convert_to_presentation_currency(gl_entries, currency_map, filters.get('company')) else: return gl_entries @@ -247,12 +257,12 @@ def get_conditions(filters): return "and {}".format(" and ".join(conditions)) if conditions else "" -def get_data_with_opening_closing(filters, account_details, gl_entries): +def get_data_with_opening_closing(filters, account_details, accounting_dimensions, gl_entries): data = [] gle_map = initialize_gle_map(gl_entries, filters) - totals, entries = get_accountwise_gle(filters, gl_entries, gle_map) + totals, entries = get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map) # Opening for filtered account data.append(totals.opening) @@ -318,7 +328,7 @@ def initialize_gle_map(gl_entries, filters): return gle_map -def get_accountwise_gle(filters, gl_entries, gle_map): +def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map): totals = get_totals_dict() entries = [] consolidated_gle = OrderedDict() @@ -350,8 +360,11 @@ def get_accountwise_gle(filters, gl_entries, gle_map): if filters.get("group_by") != _('Group by Voucher (Consolidated)'): gle_map[gle.get(group_by)].entries.append(gle) elif filters.get("group_by") == _('Group by Voucher (Consolidated)'): - key = (gle.get("voucher_type"), gle.get("voucher_no"), - gle.get("account"), gle.get("cost_center")) + keylist = [gle.get("voucher_type"), gle.get("voucher_no"), gle.get("account")] + for dim in accounting_dimensions: + keylist.append(gle.get(dim)) + keylist.append(gle.get("cost_center")) + key = tuple(keylist) if key not in consolidated_gle: consolidated_gle.setdefault(key, gle) else: @@ -478,7 +491,19 @@ def get_columns(filters): "options": "Project", "fieldname": "project", "width": 100 - }, + } + ]) + + if filters.get("include_dimensions"): + for dim in get_accounting_dimensions(as_list = False): + columns.append({ + "label": _(dim.label), + "options": dim.label, + "fieldname": dim.fieldname, + "width": 100 + }) + + columns.extend([ { "label": _("Cost Center"), "options": "Cost Center", diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 4e22b05a81..2563b66d1c 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -223,9 +223,9 @@ class GrossProfitGenerator(object): # IMP NOTE # stock_ledger_entries should already be filtered by item_code and warehouse and # sorted by posting_date desc, posting_time desc - if item_code in self.non_stock_items: + if item_code in self.non_stock_items and (row.project or row.cost_center): #Issue 6089-Get last purchasing rate for non-stock item - item_rate = self.get_last_purchase_rate(item_code) + item_rate = self.get_last_purchase_rate(item_code, row) return flt(row.qty) * item_rate else: @@ -253,38 +253,34 @@ class GrossProfitGenerator(object): def get_average_buying_rate(self, row, item_code): args = row if not item_code in self.average_buying_rate: - if item_code in self.non_stock_items: - self.average_buying_rate[item_code] = flt(frappe.db.sql(""" - select sum(base_net_amount) / sum(qty * conversion_factor) - from `tabPurchase Invoice Item` - where item_code = %s and docstatus=1""", item_code)[0][0]) - else: - args.update({ - 'voucher_type': row.parenttype, - 'voucher_no': row.parent, - 'allow_zero_valuation': True, - 'company': self.filters.company - }) + args.update({ + 'voucher_type': row.parenttype, + 'voucher_no': row.parent, + 'allow_zero_valuation': True, + 'company': self.filters.company + }) - average_buying_rate = get_incoming_rate(args) - self.average_buying_rate[item_code] = flt(average_buying_rate) + average_buying_rate = get_incoming_rate(args) + self.average_buying_rate[item_code] = flt(average_buying_rate) return self.average_buying_rate[item_code] - def get_last_purchase_rate(self, item_code): + def get_last_purchase_rate(self, item_code, row): + condition = '' + if row.project: + condition += " AND a.project='%s'" % (row.project) + elif row.cost_center: + condition += " AND a.cost_center='%s'" % (row.cost_center) if self.filters.to_date: - last_purchase_rate = frappe.db.sql(""" - select (a.base_rate / a.conversion_factor) - from `tabPurchase Invoice Item` a - where a.item_code = %s and a.docstatus=1 - and modified <= %s - order by a.modified desc limit 1""", (item_code, self.filters.to_date)) - else: - last_purchase_rate = frappe.db.sql(""" - select (a.base_rate / a.conversion_factor) - from `tabPurchase Invoice Item` a - where a.item_code = %s and a.docstatus=1 - order by a.modified desc limit 1""", item_code) + condition += " AND modified='%s'" % (self.filters.to_date) + + last_purchase_rate = frappe.db.sql(""" + select (a.base_rate / a.conversion_factor) + from `tabPurchase Invoice Item` a + where a.item_code = %s and a.docstatus=1 + {0} + order by a.modified desc limit 1""".format(condition), item_code) + return flt(last_purchase_rate[0][0]) if last_purchase_rate else 0 def load_invoice_items(self): @@ -321,7 +317,8 @@ class GrossProfitGenerator(object): `tabSales Invoice Item`.brand, `tabSales Invoice Item`.dn_detail, `tabSales Invoice Item`.delivery_note, `tabSales Invoice Item`.stock_qty as qty, `tabSales Invoice Item`.base_net_rate, `tabSales Invoice Item`.base_net_amount, - `tabSales Invoice Item`.name as "item_row", `tabSales Invoice`.is_return + `tabSales Invoice Item`.name as "item_row", `tabSales Invoice`.is_return, + `tabSales Invoice Item`.cost_center {sales_person_cols} from `tabSales Invoice` inner join `tabSales Invoice Item` diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index 4a9af490cf..9de8d19f2a 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -6,10 +6,6 @@ from erpnext.accounts.doctype.fiscal_year.fiscal_year import get_from_and_to_dat from frappe.utils import cint, get_datetime_str, formatdate, flt __exchange_rates = {} -P_OR_L_ACCOUNTS = list( - sum(frappe.get_list('Account', fields=['name'], or_filters=[{'root_type': 'Income'}, {'root_type': 'Expense'}], as_list=True), ()) -) - def get_currency(filters): """ @@ -73,18 +69,7 @@ def get_rate_as_at(date, from_currency, to_currency): return rate - -def is_p_or_l_account(account_name): - """ - Check if the given `account name` is an `Account` with `root_type` of either 'Income' - or 'Expense'. - :param account_name: - :return: Boolean - """ - return account_name in P_OR_L_ACCOUNTS - - -def convert_to_presentation_currency(gl_entries, currency_info): +def convert_to_presentation_currency(gl_entries, currency_info, company): """ Take a list of GL Entries and change the 'debit' and 'credit' values to currencies in `currency_info`. @@ -96,6 +81,9 @@ def convert_to_presentation_currency(gl_entries, currency_info): presentation_currency = currency_info['presentation_currency'] company_currency = currency_info['company_currency'] + pl_accounts = [d.name for d in frappe.get_list('Account', + filters={'report_type': 'Profit and Loss', 'company': company})] + for entry in gl_entries: account = entry['account'] debit = flt(entry['debit']) @@ -107,7 +95,7 @@ def convert_to_presentation_currency(gl_entries, currency_info): if account_currency != presentation_currency: value = debit or credit - date = currency_info['report_date'] if not is_p_or_l_account(account) else entry['posting_date'] + date = entry['posting_date'] if account in pl_accounts else currency_info['report_date'] converted_value = convert(value, presentation_currency, company_currency, date) if entry.get('debit'): diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 013c30d6ff..51ac7cfbfa 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -122,7 +122,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company cost_center = frappe.form_dict.get("cost_center") - cond = [] + cond = ["is_cancelled=0"] if date: cond.append("posting_date <= %s" % frappe.db.escape(cstr(date))) else: @@ -206,7 +206,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company return flt(bal) def get_count_on(account, fieldname, date): - cond = [] + cond = ["is_cancelled=0"] if date: cond.append("posting_date <= %s" % frappe.db.escape(cstr(date))) else: @@ -676,7 +676,8 @@ def get_outstanding_invoices(party_type, party, account, condition=None, filters invoice_list = frappe.db.sql(""" select voucher_no, voucher_type, posting_date, due_date, - ifnull(sum({dr_or_cr}), 0) as invoice_amount + ifnull(sum({dr_or_cr}), 0) as invoice_amount, + account_currency as currency from `tabGL Entry` where @@ -733,7 +734,8 @@ def get_outstanding_invoices(party_type, party, account, condition=None, filters 'invoice_amount': flt(d.invoice_amount), 'payment_amount': payment_amount, 'outstanding_amount': outstanding_amount, - 'due_date': d.due_date + 'due_date': d.due_date, + 'currency': d.currency }) ) diff --git a/erpnext/assets/assets_dashboard/asset/asset.json b/erpnext/assets/assets_dashboard/asset/asset.json new file mode 100644 index 0000000000..56b1e2a71c --- /dev/null +++ b/erpnext/assets/assets_dashboard/asset/asset.json @@ -0,0 +1,39 @@ +{ + "cards": [ + { + "card": "Total Assets" + }, + { + "card": "New Assets (This Year)" + }, + { + "card": "Asset Value" + } + ], + "charts": [ + { + "chart": "Asset Value Analytics", + "width": "Full" + }, + { + "chart": "Category-wise Asset Value", + "width": "Half" + }, + { + "chart": "Location-wise Asset Value", + "width": "Half" + } + ], + "creation": "2020-07-14 18:23:53.343082", + "dashboard_name": "Asset", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 0, + "is_standard": 1, + "modified": "2020-07-21 18:14:25.078929", + "modified_by": "Administrator", + "module": "Assets", + "name": "Asset", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/assets/dashboard_chart/asset_value_analytics/asset_value_analytics.json b/erpnext/assets/dashboard_chart/asset_value_analytics/asset_value_analytics.json new file mode 100644 index 0000000000..bc2edc9d7d --- /dev/null +++ b/erpnext/assets/dashboard_chart/asset_value_analytics/asset_value_analytics.json @@ -0,0 +1,27 @@ +{ + "chart_name": "Asset Value Analytics", + "chart_type": "Report", + "creation": "2020-07-14 18:23:53.091233", + "custom_options": "{\"type\": \"bar\", \"barOptions\": {\"stacked\": 1}, \"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"tooltipOptions\": {}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_fiscal_year\":\"frappe.sys_defaults.fiscal_year\",\"to_fiscal_year\":\"frappe.sys_defaults.fiscal_year\",\"from_date\":\"frappe.datetime.add_months(frappe.datetime.nowdate(), -12)\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"status\":\"In Location\",\"filter_based_on\":\"Fiscal Year\",\"period_start_date\":\"2020-04-01\",\"period_end_date\":\"2021-03-31\",\"date_based_on\":\"Purchase Date\",\"group_by\":\"--Select a group--\"}", + "group_by_type": "Count", + "idx": 0, + "is_public": 0, + "is_standard": 1, + "modified": "2020-07-23 13:53:33.211371", + "modified_by": "Administrator", + "module": "Assets", + "name": "Asset Value Analytics", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Fixed Asset Register", + "time_interval": "Yearly", + "timeseries": 0, + "timespan": "Last Year", + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/assets/dashboard_chart/category_wise_asset_value/category_wise_asset_value.json b/erpnext/assets/dashboard_chart/category_wise_asset_value/category_wise_asset_value.json new file mode 100644 index 0000000000..e79d2d7372 --- /dev/null +++ b/erpnext/assets/dashboard_chart/category_wise_asset_value/category_wise_asset_value.json @@ -0,0 +1,29 @@ +{ + "chart_name": "Category-wise Asset Value", + "chart_type": "Report", + "creation": "2020-07-14 18:23:53.146304", + "custom_options": "{\"type\": \"donut\", \"height\": 300, \"axisOptions\": {\"shortenYAxisNumbers\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.datetime.add_months(frappe.datetime.nowdate(), -12)\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"status\":\"In Location\",\"group_by\":\"Asset Category\",\"is_existing_asset\":0}", + "idx": 0, + "is_public": 0, + "is_standard": 1, + "modified": "2020-07-23 13:39:32.429240", + "modified_by": "Administrator", + "module": "Assets", + "name": "Category-wise Asset Value", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Fixed Asset Register", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 0, + "x_field": "asset_category", + "y_axis": [ + { + "y_field": "asset_value" + } + ] +} \ No newline at end of file diff --git a/erpnext/assets/dashboard_chart/location_wise_asset_value/location_wise_asset_value.json b/erpnext/assets/dashboard_chart/location_wise_asset_value/location_wise_asset_value.json new file mode 100644 index 0000000000..481586e7ca --- /dev/null +++ b/erpnext/assets/dashboard_chart/location_wise_asset_value/location_wise_asset_value.json @@ -0,0 +1,29 @@ +{ + "chart_name": "Location-wise Asset Value", + "chart_type": "Report", + "creation": "2020-07-14 18:23:53.195389", + "custom_options": "{\"type\": \"donut\", \"height\": 300, \"axisOptions\": {\"shortenYAxisNumbers\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.datetime.add_months(frappe.datetime.nowdate(), -12)\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"status\":\"In Location\",\"group_by\":\"Location\",\"is_existing_asset\":0}", + "idx": 0, + "is_public": 0, + "is_standard": 1, + "modified": "2020-07-23 13:42:44.912551", + "modified_by": "Administrator", + "module": "Assets", + "name": "Location-wise Asset Value", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Fixed Asset Register", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 0, + "x_field": "location", + "y_axis": [ + { + "y_field": "asset_value" + } + ] +} \ No newline at end of file diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index 97165a31d2..a3152abf20 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_import": 1, "allow_rename": 1, "autoname": "naming_series:", @@ -7,8 +8,9 @@ "document_type": "Document", "engine": "InnoDB", "field_order": [ + "is_existing_asset", + "section_break_2", "naming_series", - "asset_name", "item_code", "item_name", "asset_category", @@ -17,29 +19,31 @@ "supplier", "customer", "image", - "purchase_invoice", + "journal_entry_for_scrap", "column_break_3", "company", + "asset_name", "location", "custodian", "department", - "purchase_date", "disposal_date", - "journal_entry_for_scrap", - "purchase_receipt", "accounting_dimensions_section", "cost_center", "dimension_col_break", - "section_break_5", - "gross_purchase_amount", + "purchase_details_section", + "purchase_receipt", + "purchase_invoice", "available_for_use_date", - "column_break_18", + "column_break_23", + "gross_purchase_amount", + "purchase_date", + "section_break_23", "calculate_depreciation", "allow_monthly_depreciation", - "is_existing_asset", + "column_break_33", "opening_accumulated_depreciation", "number_of_depreciations_booked", - "section_break_23", + "section_break_36", "finance_books", "section_break_33", "depreciation_method", @@ -64,7 +68,6 @@ "status", "booked_fixed_asset", "column_break_51", - "purchase_receipt_amount", "default_finance_book", "amended_from" @@ -187,6 +190,8 @@ "fieldname": "purchase_date", "fieldtype": "Date", "label": "Purchase Date", + "read_only": 1, + "read_only_depends_on": "eval:!doc.is_existing_asset", "reqd": 1 }, { @@ -204,25 +209,20 @@ "print_hide": 1, "read_only": 1 }, - { - "fieldname": "section_break_5", - "fieldtype": "Section Break" - }, { "fieldname": "gross_purchase_amount", "fieldtype": "Currency", "label": "Gross Purchase Amount", "options": "Company:company:default_currency", + "read_only": 1, + "read_only_depends_on": "eval:!doc.is_existing_asset", "reqd": 1 }, { "fieldname": "available_for_use_date", "fieldtype": "Date", - "label": "Available-for-use Date" - }, - { - "fieldname": "column_break_18", - "fieldtype": "Column Break" + "label": "Available-for-use Date", + "reqd": 1 }, { "default": "0", @@ -252,12 +252,14 @@ "no_copy": 1 }, { - "depends_on": "calculate_depreciation", + "collapsible": 1, + "collapsible_depends_on": "eval:doc.calculate_depreciation || doc.is_existing_asset", "fieldname": "section_break_23", "fieldtype": "Section Break", "label": "Depreciation" }, { + "columns": 10, "fieldname": "finance_books", "fieldtype": "Table", "label": "Finance Books", @@ -305,8 +307,7 @@ { "depends_on": "calculate_depreciation", "fieldname": "section_break_14", - "fieldtype": "Section Break", - "label": "Depreciation Schedule" + "fieldtype": "Section Break" }, { "fieldname": "schedules", @@ -456,12 +457,37 @@ "fieldname": "allow_monthly_depreciation", "fieldtype": "Check", "label": "Allow Monthly Depreciation" + }, + { + "fieldname": "section_break_2", + "fieldtype": "Section Break" + }, + { + "collapsible": 1, + "collapsible_depends_on": "is_existing_asset", + "fieldname": "purchase_details_section", + "fieldtype": "Section Break", + "label": "Purchase Details" + }, + { + "fieldname": "column_break_23", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_33", + "fieldtype": "Column Break" + }, + { + "depends_on": "calculate_depreciation", + "fieldname": "section_break_36", + "fieldtype": "Section Break" } ], "idx": 72, "image_field": "image", "is_submittable": 1, - "modified": "2019-10-22 15:47:36.050828", + "links": [], + "modified": "2020-07-28 15:04:44.452224", "modified_by": "Administrator", "module": "Assets", "name": "Asset", diff --git a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py index 1869a29c8d..60c528bcc4 100644 --- a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py +++ b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py @@ -106,6 +106,7 @@ def update_maintenance_log(asset_maintenance, item_code, item_name, task): maintenance_log.save() @frappe.whitelist() +@frappe.validate_and_sanitize_search_inputs def get_team_members(doctype, txt, searchfield, start, page_len, filters): return frappe.db.get_values('Maintenance Team Member', { 'parent': filters.get("maintenance_team") }) diff --git a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py index f169f01616..34facd8d05 100644 --- a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py +++ b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py @@ -11,7 +11,7 @@ from erpnext.assets.doctype.asset_maintenance.asset_maintenance import calculate class AssetMaintenanceLog(Document): def validate(self): - if getdate(self.due_date) < getdate(nowdate()): + if getdate(self.due_date) < getdate(nowdate()) and self.maintenance_status not in ["Completed", "Cancelled"]: self.maintenance_status = "Overdue" if self.maintenance_status == "Completed" and not self.completion_date: @@ -41,6 +41,7 @@ class AssetMaintenanceLog(Document): asset_maintenance_doc.save() @frappe.whitelist() +@frappe.validate_and_sanitize_search_inputs def get_maintenance_tasks(doctype, txt, searchfield, start, page_len, filters): asset_maintenance_tasks = frappe.db.get_values('Asset Maintenance Task', {'parent':filters.get("asset_maintenance")}, 'maintenance_task') return asset_maintenance_tasks diff --git a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log_list.js b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log_list.js index b854413310..23000e60ef 100644 --- a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log_list.js +++ b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log_list.js @@ -1,14 +1,15 @@ frappe.listview_settings['Asset Maintenance Log'] = { add_fields: ["maintenance_status"], + has_indicator_for_draft: 1, get_indicator: function(doc) { - if(doc.maintenance_status=="Pending") { - return [__("Pending"), "orange"]; - } else if(doc.maintenance_status=="Completed") { - return [__("Completed"), "green"]; - } else if(doc.maintenance_status=="Cancelled") { - return [__("Cancelled"), "red"]; - } else if(doc.maintenance_status=="Overdue") { - return [__("Overdue"), "red"]; + if (doc.maintenance_status=="Planned") { + return [__(doc.maintenance_status), "orange", "status,=," + doc.maintenance_status]; + } else if (doc.maintenance_status=="Completed") { + return [__(doc.maintenance_status), "green", "status,=," + doc.maintenance_status]; + } else if (doc.maintenance_status=="Cancelled") { + return [__(doc.maintenance_status), "red", "status,=," + doc.maintenance_status]; + } else if (doc.maintenance_status=="Overdue") { + return [__(doc.maintenance_status), "red", "status,=," + doc.maintenance_status]; } } }; diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py index 155597e856..fd702c74c7 100644 --- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py +++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py @@ -8,6 +8,7 @@ from frappe import _ from frappe.utils import flt, getdate, cint, date_diff, formatdate from erpnext.assets.doctype.asset.depreciation import get_depreciation_accounts from frappe.model.document import Document +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts class AssetValueAdjustment(Document): def validate(self): @@ -53,17 +54,33 @@ class AssetValueAdjustment(Document): je.company = self.company je.remark = "Depreciation Entry against {0} worth {1}".format(self.asset, self.difference_amount) - je.append("accounts", { + credit_entry = { "account": accumulated_depreciation_account, "credit_in_account_currency": self.difference_amount, "cost_center": depreciation_cost_center or self.cost_center - }) + } - je.append("accounts", { + debit_entry = { "account": depreciation_expense_account, "debit_in_account_currency": self.difference_amount, "cost_center": depreciation_cost_center or self.cost_center - }) + } + + accounting_dimensions = get_checks_for_pl_and_bs_accounts() + + for dimension in accounting_dimensions: + if dimension.get('mandatory_for_bs'): + credit_entry.update({ + dimension['fieldname']: self.get(dimension['fieldname']) or dimension.get('default_dimension') + }) + + if dimension.get('mandatory_for_pl'): + debit_entry.update({ + dimension['fieldname']: self.get(dimension['fieldname']) or dimension.get('default_dimension') + }) + + je.append("accounts", credit_entry) + je.append("accounts", debit_entry) je.flags.ignore_permissions = True je.submit() diff --git a/erpnext/assets/number_card/asset_value/asset_value.json b/erpnext/assets/number_card/asset_value/asset_value.json new file mode 100644 index 0000000000..68e5f54c78 --- /dev/null +++ b/erpnext/assets/number_card/asset_value/asset_value.json @@ -0,0 +1,21 @@ +{ + "aggregate_function_based_on": "value_after_depreciation", + "creation": "2020-07-14 18:23:53.302457", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Asset", + "filters_json": "[]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Asset Value", + "modified": "2020-07-21 18:13:47.647997", + "modified_by": "Administrator", + "module": "Assets", + "name": "Asset Value", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/assets/number_card/new_assets_(this_year)/new_assets_(this_year).json b/erpnext/assets/number_card/new_assets_(this_year)/new_assets_(this_year).json new file mode 100644 index 0000000000..6c8fb35657 --- /dev/null +++ b/erpnext/assets/number_card/new_assets_(this_year)/new_assets_(this_year).json @@ -0,0 +1,20 @@ +{ + "creation": "2020-07-14 18:23:53.267919", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Asset", + "filters_json": "[[\"Asset\",\"creation\",\"Timespan\",\"this year\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "New Assets (This Year)", + "modified": "2020-07-23 13:45:20.418766", + "modified_by": "Administrator", + "module": "Assets", + "name": "New Assets (This Year)", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/assets/number_card/total_assets/total_assets.json b/erpnext/assets/number_card/total_assets/total_assets.json new file mode 100644 index 0000000000..d127de8f2c --- /dev/null +++ b/erpnext/assets/number_card/total_assets/total_assets.json @@ -0,0 +1,20 @@ +{ + "creation": "2020-07-14 18:23:53.233328", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Asset", + "filters_json": "[]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Assets", + "modified": "2020-07-21 18:12:51.664292", + "modified_by": "Administrator", + "module": "Assets", + "name": "Total Assets", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/buying/buying_dashboard/buying/buying.json b/erpnext/buying/buying_dashboard/buying/buying.json new file mode 100644 index 0000000000..ab7ebac146 --- /dev/null +++ b/erpnext/buying/buying_dashboard/buying/buying.json @@ -0,0 +1,46 @@ +{ + "cards": [ + { + "card": "Annual Purchase" + }, + { + "card": "Purchase Orders to Receive" + }, + { + "card": "Purchase Orders to Bill" + }, + { + "card": "Active Suppliers" + } + ], + "charts": [ + { + "chart": "Purchase Order Trends", + "width": "Full" + }, + { + "chart": "Material Request Analysis", + "width": "Half" + }, + { + "chart": "Purchase Order Analysis", + "width": "Half" + }, + { + "chart": "Top Suppliers", + "width": "Full" + } + ], + "creation": "2020-07-20 21:01:02.541065", + "dashboard_name": "Buying", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 1, + "is_standard": 1, + "modified": "2020-07-22 12:48:38.112744", + "modified_by": "Administrator", + "module": "Buying", + "name": "Buying", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/buying/dashboard_chart/material_request_analysis/material_request_analysis.json b/erpnext/buying/dashboard_chart/material_request_analysis/material_request_analysis.json new file mode 100644 index 0000000000..0b66f1f5e5 --- /dev/null +++ b/erpnext/buying/dashboard_chart/material_request_analysis/material_request_analysis.json @@ -0,0 +1,27 @@ +{ + "chart_name": "Material Request Analysis", + "chart_type": "Group By", + "creation": "2020-07-20 21:01:02.242563", + "custom_options": "{\"height\": 300}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Material Request", + "dynamic_filters_json": "[[\"Material Request\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Material Request\",\"status\",\"not in\",[\"Draft\",\"Cancelled\",\"Stopped\",null],false],[\"Material Request\",\"material_request_type\",\"=\",\"Purchase\",false],[\"Material Request\",\"docstatus\",\"=\",\"1\",false],[\"Material Request\",\"transaction_date\",\"Timespan\",\"last quarter\",false]]", + "group_by_based_on": "status", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 12:43:56.961250", + "modified": "2020-07-22 21:20:51.840194", + "modified_by": "Administrator", + "module": "Buying", + "name": "Material Request Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/buying/dashboard_chart/purchase_order_analysis/purchase_order_analysis.json b/erpnext/buying/dashboard_chart/purchase_order_analysis/purchase_order_analysis.json new file mode 100644 index 0000000000..020755b92d --- /dev/null +++ b/erpnext/buying/dashboard_chart/purchase_order_analysis/purchase_order_analysis.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Purchase Order Analysis", + "chart_type": "Report", + "creation": "2020-07-20 21:01:02.203880", + "custom_options": "{\"type\": \"donut\", \"height\": 300, \"axisOptions\": {\"shortenYAxisNumbers\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.datetime.add_months(frappe.datetime.nowdate(), -1)\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"group_by_po\":0}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 12:44:35.754973", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Purchase Order Analysis", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/buying/dashboard_chart/purchase_order_trends/purchase_order_trends.json b/erpnext/buying/dashboard_chart/purchase_order_trends/purchase_order_trends.json new file mode 100644 index 0000000000..6452ed2139 --- /dev/null +++ b/erpnext/buying/dashboard_chart/purchase_order_trends/purchase_order_trends.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Purchase Order Trends", + "chart_type": "Report", + "creation": "2020-07-20 21:01:02.295012", + "custom_options": "{\"type\": \"line\", \"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"tooltipOptions\": {}, \"lineOptions\": {\"regionFill\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"fiscal_year\":\"frappe.sys_defaults.fiscal_year\"}", + "filters_json": "{\"period\":\"Monthly\",\"period_based_on\":\"posting_date\",\"based_on\":\"Item\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-21 16:13:25.092287", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Trends", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Purchase Order Trends", + "timeseries": 0, + "type": "Line", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/buying/dashboard_chart/top_suppliers/top_suppliers.json b/erpnext/buying/dashboard_chart/top_suppliers/top_suppliers.json new file mode 100644 index 0000000000..6f7da8ea87 --- /dev/null +++ b/erpnext/buying/dashboard_chart/top_suppliers/top_suppliers.json @@ -0,0 +1,23 @@ +{ + "chart_name": "Top Suppliers", + "chart_type": "Report", + "creation": "2020-07-20 21:01:02.329519", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"fiscal_year\":\"frappe.sys_defaults.fiscal_year\"}", + "filters_json": "{\"period\":\"Monthly\",\"period_based_on\":\"posting_date\",\"based_on\":\"Supplier\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 12:43:40.829652", + "modified_by": "Administrator", + "module": "Buying", + "name": "Top Suppliers", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Purchase Receipt Trends", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/buying/dashboard_fixtures.py b/erpnext/buying/dashboard_fixtures.py deleted file mode 100644 index c6e2ffa634..0000000000 --- a/erpnext/buying/dashboard_fixtures.py +++ /dev/null @@ -1,211 +0,0 @@ -# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -import frappe -import json -from frappe import _ -from frappe.utils import nowdate -from erpnext.accounts.dashboard_fixtures import _get_fiscal_year - -def get_data(): - - fiscal_year = _get_fiscal_year(nowdate()) - - if not fiscal_year: - return frappe._dict() - - company = frappe.get_doc("Company", get_company_for_dashboards()) - fiscal_year_name = fiscal_year.get("name") - start_date = str(fiscal_year.get("year_start_date")) - end_date = str(fiscal_year.get("year_end_date")) - - return frappe._dict({ - "dashboards": get_dashboards(), - "charts": get_charts(company, fiscal_year_name, start_date, end_date), - "number_cards": get_number_cards(company, fiscal_year_name, start_date, end_date), - }) - -def get_company_for_dashboards(): - company = frappe.defaults.get_defaults().company - if company: - return company - else: - company_list = frappe.get_list("Company") - if company_list: - return company_list[0].name - return None - -def get_dashboards(): - return [{ - "name": "Buying", - "dashboard_name": "Buying", - "charts": [ - { "chart": "Purchase Order Trends", "width": "Full"}, - { "chart": "Material Request Analysis", "width": "Half"}, - { "chart": "Purchase Order Analysis", "width": "Half"}, - { "chart": "Top Suppliers", "width": "Full"} - ], - "cards": [ - { "card": "Annual Purchase"}, - { "card": "Purchase Orders to Receive"}, - { "card": "Purchase Orders to Bill"}, - { "card": "Active Suppliers"} - ] - }] - -def get_charts(company, fiscal_year_name, start_date, end_date): - return [ - { - "name": "Purchase Order Analysis", - "chart_name": _("Purchase Order Analysis"), - "chart_type": "Report", - "custom_options": json.dumps({ - "type": "donut", - "height": 300, - "axisOptions": {"shortenYAxisNumbers": 1} - }), - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "from_date": start_date, - "to_date": end_date - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Purchase Order Analysis", - "type": "Donut" - }, - { - "name": "Material Request Analysis", - "chart_name": _("Material Request Analysis"), - "chart_type": "Group By", - "custom_options": json.dumps({"height": 300}), - "doctype": "Dashboard Chart", - "document_type": "Material Request", - "filters_json": json.dumps( - [["Material Request", "status", "not in", ["Draft", "Cancelled", "Stopped", None], False], - ["Material Request", "material_request_type", "=", "Purchase", False], - ["Material Request", "company", "=", company.name, False], - ["Material Request", "docstatus", "=", 1, False], - ["Material Request", "transaction_date", "Between", [start_date, end_date], False]] - ), - "group_by_based_on": "status", - "group_by_type": "Count", - "is_custom": 0, - "is_public": 1, - "number_of_groups": 0, - "owner": "Administrator", - "type": "Donut" - }, - { - "name": "Purchase Order Trends", - "chart_name": _("Purchase Order Trends"), - "chart_type": "Report", - "custom_options": json.dumps({ - "type": "line", - "axisOptions": {"shortenYAxisNumbers": 1}, - "tooltipOptions": {}, - "lineOptions": { - "regionFill": 1 - } - }), - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "period": "Monthly", - "fiscal_year": fiscal_year_name, - "period_based_on": "posting_date", - "based_on": "Item" - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Purchase Order Trends", - "type": "Line" - }, - { - "name": "Top Suppliers", - "chart_name": _("Top Suppliers"), - "chart_type": "Report", - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "period": "Monthly", - "fiscal_year": fiscal_year_name, - "period_based_on": "posting_date", - "based_on": "Supplier" - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Purchase Receipt Trends", - "type": "Bar" - } - ] - -def get_number_cards(company, fiscal_year_name, start_date, end_date): - return [ - { - "name": "Annual Purchase", - "aggregate_function_based_on": "base_net_total", - "doctype": "Number Card", - "document_type": "Purchase Order", - "filters_json": json.dumps([ - ["Purchase Order", "transaction_date", "Between", [start_date, end_date], False], - ["Purchase Order", "status", "not in", ["Draft", "Cancelled", "Closed", None], False], - ["Purchase Order", "docstatus", "=", 1, False], - ["Purchase Order", "company", "=", company.name, False] - ]), - "function": "Sum", - "is_public": 1, - "label": _("Annual Purchase"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "name": "Purchase Orders to Receive", - "doctype": "Number Card", - "document_type": "Purchase Order", - "filters_json": json.dumps([ - ["Purchase Order", "status", "in", ["To Receive and Bill", "To Receive", None], False], - ["Purchase Order", "docstatus", "=", 1, False], - ["Purchase Order", "company", "=", company.name, False] - ]), - "function": "Count", - "is_public": 1, - "label": _("Purchase Orders to Receive"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Weekly" - }, - { - "name": "Purchase Orders to Bill", - "doctype": "Number Card", - "document_type": "Purchase Order", - "filters_json": json.dumps([ - ["Purchase Order", "status", "in", ["To Receive and Bill", "To Bill", None], False], - ["Purchase Order", "docstatus", "=", 1, False], - ["Purchase Order", "company", "=", company.name, False] - ]), - "function": "Count", - "is_public": 1, - "label": _("Purchase Orders to Bill"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Weekly" - }, - { - "name": "Active Suppliers", - "doctype": "Number Card", - "document_type": "Supplier", - "filters_json": json.dumps([["Supplier", "disabled", "=", "0"]]), - "function": "Count", - "is_public": 1, - "label": "Active Suppliers", - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - } - ] \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 84e3a31904..9f2b9714f7 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -7,12 +7,6 @@ frappe.provide("erpnext.buying"); frappe.ui.form.on("Purchase Order", { setup: function(frm) { - frm.custom_make_buttons = { - 'Purchase Receipt': 'Receipt', - 'Purchase Invoice': 'Invoice', - 'Stock Entry': 'Material to Supplier', - 'Payment Entry': 'Payment' - } frm.set_query("reserve_warehouse", "supplied_items", function() { return { @@ -36,20 +30,6 @@ frappe.ui.form.on("Purchase Order", { }, - refresh: function(frm) { - if(frm.doc.docstatus === 1 && frm.doc.status !== 'Closed' - && flt(frm.doc.per_received) < 100 && flt(frm.doc.per_billed) < 100) { - frm.add_custom_button(__('Update Items'), () => { - erpnext.utils.update_child_items({ - frm: frm, - child_docname: "items", - child_doctype: "Purchase Order Detail", - cannot_add_row: false, - }) - }); - } - }, - onload: function(frm) { set_schedule_date(frm); if (!frm.doc.transaction_date){ @@ -76,6 +56,18 @@ frappe.ui.form.on("Purchase Order Item", { }); erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({ + setup: function() { + this.frm.custom_make_buttons = { + 'Purchase Receipt': 'Receipt', + 'Purchase Invoice': 'Invoice', + 'Stock Entry': 'Material to Supplier', + 'Payment Entry': 'Payment', + } + + this._super(); + + }, + refresh: function(doc, cdt, cdn) { var me = this; this._super(); @@ -99,6 +91,16 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( if(doc.docstatus == 1) { if(!in_list(["Closed", "Delivered"], doc.status)) { + if(this.frm.doc.status !== 'Closed' && flt(this.frm.doc.per_received) < 100 && flt(this.frm.doc.per_billed) < 100) { + this.frm.add_custom_button(__('Update Items'), () => { + erpnext.utils.update_child_items({ + frm: this.frm, + child_docname: "items", + child_doctype: "Purchase Order Detail", + cannot_add_row: false, + }) + }); + } if (this.frm.has_perm("submit")) { if(flt(doc.per_billed, 6) < 100 || flt(doc.per_received, 6) < 100) { if (doc.status != "On Hold") { diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json index 13f5cb0c81..4201e0b635 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.json +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -137,9 +137,7 @@ { "fieldname": "supplier_section", "fieldtype": "Section Break", - "options": "fa fa-user", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-user" }, { "allow_on_submit": 1, @@ -149,9 +147,7 @@ "hidden": 1, "label": "Title", "no_copy": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "naming_series", @@ -163,9 +159,7 @@ "options": "PUR-ORD-.YYYY.-", "print_hide": 1, "reqd": 1, - "set_only_once": 1, - "show_days": 1, - "show_seconds": 1 + "set_only_once": 1 }, { "bold": 1, @@ -178,18 +172,14 @@ "options": "Supplier", "print_hide": 1, "reqd": 1, - "search_index": 1, - "show_days": 1, - "show_seconds": 1 + "search_index": 1 }, { "depends_on": "eval:doc.supplier && doc.docstatus===0 && (!(doc.items && doc.items.length) || (doc.items.length==1 && !doc.items[0].item_code))", "description": "Fetch items based on Default Supplier.", "fieldname": "get_items_from_open_material_requests", "fieldtype": "Button", - "label": "Get Items from Open Material Requests", - "show_days": 1, - "show_seconds": 1 + "label": "Get Items from Open Material Requests" }, { "bold": 1, @@ -198,9 +188,7 @@ "fieldtype": "Data", "in_global_search": 1, "label": "Supplier Name", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "company", @@ -212,17 +200,13 @@ "options": "Company", "print_hide": 1, "remember_last_selected_value": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "column_break1", "fieldtype": "Column Break", "oldfieldtype": "Column Break", "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -234,35 +218,27 @@ "oldfieldname": "transaction_date", "oldfieldtype": "Date", "reqd": 1, - "search_index": 1, - "show_days": 1, - "show_seconds": 1 + "search_index": 1 }, { "allow_on_submit": 1, "fieldname": "schedule_date", "fieldtype": "Date", - "label": "Required By", - "show_days": 1, - "show_seconds": 1 + "label": "Required By" }, { "allow_on_submit": 1, "depends_on": "eval:doc.docstatus===1", "fieldname": "order_confirmation_no", "fieldtype": "Data", - "label": "Order Confirmation No", - "show_days": 1, - "show_seconds": 1 + "label": "Order Confirmation No" }, { "allow_on_submit": 1, "depends_on": "eval:doc.order_confirmation_no", "fieldname": "order_confirmation_date", "fieldtype": "Date", - "label": "Order Confirmation Date", - "show_days": 1, - "show_seconds": 1 + "label": "Order Confirmation Date" }, { "fieldname": "amended_from", @@ -274,25 +250,19 @@ "oldfieldtype": "Data", "options": "Purchase Order", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "drop_ship", "fieldtype": "Section Break", - "label": "Drop Ship", - "show_days": 1, - "show_seconds": 1 + "label": "Drop Ship" }, { "fieldname": "customer", "fieldtype": "Link", "label": "Customer", "options": "Customer", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "bold": 1, @@ -300,41 +270,31 @@ "fieldtype": "Data", "label": "Customer Name", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_19", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "customer_contact_person", "fieldtype": "Link", "label": "Customer Contact", - "options": "Contact", - "show_days": 1, - "show_seconds": 1 + "options": "Contact" }, { "fieldname": "customer_contact_display", "fieldtype": "Small Text", "hidden": 1, "label": "Customer Contact", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "customer_contact_mobile", "fieldtype": "Small Text", "hidden": 1, "label": "Customer Mobile No", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "customer_contact_email", @@ -342,60 +302,46 @@ "hidden": 1, "label": "Customer Contact Email", "options": "Email", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, "fieldname": "section_addresses", "fieldtype": "Section Break", - "label": "Address and Contact", - "show_days": 1, - "show_seconds": 1 + "label": "Address and Contact" }, { "fieldname": "supplier_address", "fieldtype": "Link", "label": "Select Supplier Address", "options": "Address", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "contact_person", "fieldtype": "Link", "label": "Contact Person", "options": "Contact", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "address_display", "fieldtype": "Small Text", "label": "Address", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "contact_display", "fieldtype": "Small Text", "in_global_search": 1, "label": "Contact", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "contact_mobile", "fieldtype": "Small Text", "label": "Mobile No", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "contact_email", @@ -403,42 +349,32 @@ "label": "Contact Email", "options": "Email", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "col_break_address", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "shipping_address", "fieldtype": "Link", "label": "Select Shipping Address", "options": "Address", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "shipping_address_display", "fieldtype": "Small Text", "label": "Shipping Address", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "fieldname": "currency_and_price_list", "fieldtype": "Section Break", "label": "Currency and Price List", - "options": "fa fa-tag", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-tag" }, { "fieldname": "currency", @@ -448,9 +384,7 @@ "oldfieldtype": "Select", "options": "Currency", "print_hide": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "conversion_rate", @@ -460,24 +394,18 @@ "oldfieldtype": "Currency", "precision": "9", "print_hide": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "cb_price_list", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "buying_price_list", "fieldtype": "Link", "label": "Price List", "options": "Price List", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "price_list_currency", @@ -485,18 +413,14 @@ "label": "Price List Currency", "options": "Currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "plc_conversion_rate", "fieldtype": "Float", "label": "Price List Exchange Rate", "precision": "9", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "default": "0", @@ -505,15 +429,11 @@ "label": "Ignore Pricing Rule", "no_copy": 1, "permlevel": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "sec_warehouse", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "description": "Sets 'Warehouse' in each row of the Items table.", @@ -521,15 +441,11 @@ "fieldtype": "Link", "label": "Set Target Warehouse", "options": "Warehouse", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "col_break_warehouse", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "default": "No", @@ -538,33 +454,25 @@ "in_standard_filter": 1, "label": "Supply Raw Materials", "options": "No\nYes", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "depends_on": "eval:doc.is_subcontracted==\"Yes\"", "fieldname": "supplier_warehouse", "fieldtype": "Link", "label": "Supplier Warehouse", - "options": "Warehouse", - "show_days": 1, - "show_seconds": 1 + "options": "Warehouse" }, { "fieldname": "items_section", "fieldtype": "Section Break", "oldfieldtype": "Section Break", - "options": "fa fa-shopping-cart", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-shopping-cart" }, { "fieldname": "scan_barcode", "fieldtype": "Data", - "label": "Scan Barcode", - "show_days": 1, - "show_seconds": 1 + "label": "Scan Barcode" }, { "allow_bulk_edit": 1, @@ -574,34 +482,26 @@ "oldfieldname": "po_details", "oldfieldtype": "Table", "options": "Purchase Order Item", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "collapsible": 1, "fieldname": "section_break_48", "fieldtype": "Section Break", - "label": "Pricing Rules", - "show_days": 1, - "show_seconds": 1 + "label": "Pricing Rules" }, { "fieldname": "pricing_rules", "fieldtype": "Table", "label": "Purchase Order Pricing Rule", "options": "Pricing Rule Detail", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible_depends_on": "supplied_items", "fieldname": "raw_material_details", "fieldtype": "Section Break", - "label": "Raw Materials Supplied", - "show_days": 1, - "show_seconds": 1 + "label": "Raw Materials Supplied" }, { "fieldname": "supplied_items", @@ -611,23 +511,17 @@ "oldfieldtype": "Table", "options": "Purchase Order Item Supplied", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "sb_last_purchase", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "fieldname": "total_qty", "fieldtype": "Float", "label": "Total Quantity", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_total", @@ -635,9 +529,7 @@ "label": "Total (Company Currency)", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_net_total", @@ -648,24 +540,18 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_26", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "total", "fieldtype": "Currency", "label": "Total", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "net_total", @@ -675,26 +561,20 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "total_net_weight", "fieldtype": "Float", "label": "Total Net Weight", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "taxes_section", "fieldtype": "Section Break", "oldfieldtype": "Section Break", - "options": "fa fa-money", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-money" }, { "fieldname": "taxes_and_charges", @@ -703,30 +583,22 @@ "oldfieldname": "purchase_other_charges", "oldfieldtype": "Link", "options": "Purchase Taxes and Charges Template", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "column_break_50", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "shipping_rule", "fieldtype": "Link", "label": "Shipping Rule", "options": "Shipping Rule", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "section_break_52", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "fieldname": "taxes", @@ -734,17 +606,13 @@ "label": "Purchase Taxes and Charges", "oldfieldname": "purchase_tax_details", "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges", - "show_days": 1, - "show_seconds": 1 + "options": "Purchase Taxes and Charges" }, { "collapsible": 1, "fieldname": "sec_tax_breakup", "fieldtype": "Section Break", - "label": "Tax Breakup", - "show_days": 1, - "show_seconds": 1 + "label": "Tax Breakup" }, { "fieldname": "other_charges_calculation", @@ -753,17 +621,13 @@ "no_copy": 1, "oldfieldtype": "HTML", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "totals", "fieldtype": "Section Break", "oldfieldtype": "Section Break", - "options": "fa fa-money", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-money" }, { "fieldname": "base_taxes_and_charges_added", @@ -773,9 +637,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_taxes_and_charges_deducted", @@ -785,9 +647,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_total_taxes_and_charges", @@ -798,15 +658,11 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_39", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "taxes_and_charges_added", @@ -816,9 +672,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "taxes_and_charges_deducted", @@ -828,9 +682,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "total_taxes_and_charges", @@ -838,18 +690,14 @@ "label": "Total Taxes and Charges", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "collapsible_depends_on": "discount_amount", "fieldname": "discount_section", "fieldtype": "Section Break", - "label": "Additional Discount", - "show_days": 1, - "show_seconds": 1 + "label": "Additional Discount" }, { "default": "Grand Total", @@ -857,9 +705,7 @@ "fieldtype": "Select", "label": "Apply Additional Discount On", "options": "\nGrand Total\nNet Total", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "base_discount_amount", @@ -867,38 +713,28 @@ "label": "Additional Discount Amount (Company Currency)", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_45", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "additional_discount_percentage", "fieldtype": "Float", "label": "Additional Discount Percentage", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "discount_amount", "fieldtype": "Currency", "label": "Additional Discount Amount", "options": "currency", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "totals_section", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "fieldname": "base_grand_total", @@ -909,9 +745,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_rounding_adjustment", @@ -920,21 +754,18 @@ "no_copy": 1, "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "description": "In Words will be visible once you save the Purchase Order.", "fieldname": "base_in_words", "fieldtype": "Data", "label": "In Words (Company Currency)", + "length": 240, "oldfieldname": "in_words", "oldfieldtype": "Data", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_rounded_total", @@ -944,16 +775,12 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break4", "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Column Break" }, { "fieldname": "grand_total", @@ -963,9 +790,7 @@ "oldfieldname": "grand_total_import", "oldfieldtype": "Currency", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "rounding_adjustment", @@ -974,37 +799,30 @@ "no_copy": 1, "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "rounded_total", "fieldtype": "Currency", "label": "Rounded Total", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "default": "0", "fieldname": "disable_rounded_total", "fieldtype": "Check", - "label": "Disable Rounded Total", - "show_days": 1, - "show_seconds": 1 + "label": "Disable Rounded Total" }, { "fieldname": "in_words", "fieldtype": "Data", "label": "In Words", + "length": 240, "oldfieldname": "in_words_import", "oldfieldtype": "Data", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "advance_paid", @@ -1013,25 +831,19 @@ "no_copy": 1, "options": "party_account_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "fieldname": "payment_schedule_section", "fieldtype": "Section Break", - "label": "Payment Terms", - "show_days": 1, - "show_seconds": 1 + "label": "Payment Terms" }, { "fieldname": "payment_terms_template", "fieldtype": "Link", "label": "Payment Terms Template", - "options": "Payment Terms Template", - "show_days": 1, - "show_seconds": 1 + "options": "Payment Terms Template" }, { "fieldname": "payment_schedule", @@ -1039,9 +851,7 @@ "label": "Payment Schedule", "no_copy": 1, "options": "Payment Schedule", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, @@ -1050,9 +860,7 @@ "fieldtype": "Section Break", "label": "Terms and Conditions", "oldfieldtype": "Section Break", - "options": "fa fa-legal", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-legal" }, { "fieldname": "tc_name", @@ -1061,27 +869,21 @@ "oldfieldname": "tc_name", "oldfieldtype": "Link", "options": "Terms and Conditions", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "terms", "fieldtype": "Text Editor", "label": "Terms and Conditions", "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Text Editor" }, { "collapsible": 1, "fieldname": "more_info", "fieldtype": "Section Break", "label": "More Information", - "oldfieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Section Break" }, { "default": "Draft", @@ -1096,9 +898,7 @@ "print_hide": 1, "read_only": 1, "reqd": 1, - "search_index": 1, - "show_days": 1, - "show_seconds": 1 + "search_index": 1 }, { "fieldname": "ref_sq", @@ -1109,9 +909,7 @@ "oldfieldname": "ref_sq", "oldfieldtype": "Data", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "party_account_currency", @@ -1121,24 +919,18 @@ "no_copy": 1, "options": "Currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "inter_company_order_reference", "fieldtype": "Link", "label": "Inter Company Order Reference", "options": "Sales Order", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_74", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "depends_on": "eval:!doc.__islocal", @@ -1148,9 +940,7 @@ "label": "% Received", "no_copy": 1, "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "eval:!doc.__islocal", @@ -1160,9 +950,7 @@ "label": "% Billed", "no_copy": 1, "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, @@ -1172,8 +960,6 @@ "oldfieldtype": "Column Break", "print_hide": 1, "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -1184,9 +970,7 @@ "oldfieldname": "letter_head", "oldfieldtype": "Select", "options": "Letter Head", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "allow_on_submit": 1, @@ -1198,15 +982,11 @@ "oldfieldtype": "Link", "options": "Print Heading", "print_hide": 1, - "report_hide": 1, - "show_days": 1, - "show_seconds": 1 + "report_hide": 1 }, { "fieldname": "column_break_86", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "allow_on_submit": 1, @@ -1214,25 +994,19 @@ "fieldname": "group_same_items", "fieldtype": "Check", "label": "Group same items", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "language", "fieldtype": "Data", "label": "Print Language", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, "fieldname": "subscription_section", "fieldtype": "Section Break", - "label": "Subscription Section", - "show_days": 1, - "show_seconds": 1 + "label": "Subscription Section" }, { "allow_on_submit": 1, @@ -1240,9 +1014,7 @@ "fieldtype": "Date", "label": "From Date", "no_copy": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "allow_on_submit": 1, @@ -1250,15 +1022,11 @@ "fieldtype": "Date", "label": "To Date", "no_copy": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "column_break_97", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "auto_repeat", @@ -1267,72 +1035,56 @@ "no_copy": 1, "options": "Auto Repeat", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "allow_on_submit": 1, "depends_on": "eval: doc.auto_repeat", "fieldname": "update_auto_repeat_reference", "fieldtype": "Button", - "label": "Update Auto Repeat Reference", - "show_days": 1, - "show_seconds": 1 + "label": "Update Auto Repeat Reference" }, { "fieldname": "tax_category", "fieldtype": "Link", "label": "Tax Category", - "options": "Tax Category", - "show_days": 1, - "show_seconds": 1 + "options": "Tax Category" }, { "depends_on": "supplied_items", "fieldname": "set_reserve_warehouse", "fieldtype": "Link", "label": "Set Reserve Warehouse", - "options": "Warehouse", - "show_days": 1, - "show_seconds": 1 + "options": "Warehouse" }, { "collapsible": 1, "fieldname": "tracking_section", "fieldtype": "Section Break", - "label": "Tracking", - "show_days": 1, - "show_seconds": 1 + "label": "Tracking" }, { "fieldname": "column_break_75", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "billing_address", "fieldtype": "Link", "label": "Select Billing Address", - "options": "Address", - "show_days": 1, - "show_seconds": 1 + "options": "Address" }, { "fieldname": "billing_address_display", "fieldtype": "Small Text", "label": "Billing Address", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 } ], "icon": "fa fa-file-text", "idx": 105, "is_submittable": 1, "links": [], - "modified": "2020-06-13 22:25:47.333850", + "modified": "2020-07-31 14:13:44.610190", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order", @@ -1376,12 +1128,6 @@ "read": 1, "role": "Purchase Manager", "write": 1 - }, - { - "email": 1, - "print": 1, - "read": 1, - "role": "Accounts User" } ], "search_fields": "status, transaction_date, supplier,grand_total", @@ -1389,5 +1135,5 @@ "sort_field": "modified", "sort_order": "DESC", "timeline_field": "supplier", - "title_field": "title" + "title_field": "supplier" } \ No newline at end of file diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 4b852300e5..b54a585b97 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -207,6 +207,7 @@ def get_list_context(context=None): return list_context @frappe.whitelist() +@frappe.validate_and_sanitize_search_inputs def get_supplier_contacts(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select `tabContact`.name from `tabContact`, `tabDynamic Link` where `tabDynamic Link`.link_doctype = 'Supplier' and (`tabDynamic Link`.link_name=%(name)s diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index 4606395ebe..40362b1d40 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -97,7 +97,7 @@ { "fieldname": "default_bank_account", "fieldtype": "Link", - "label": "Default Bank Account", + "label": "Default Company Bank Account", "options": "Bank Account" }, { @@ -384,7 +384,7 @@ "idx": 370, "image_field": "image", "links": [], - "modified": "2020-03-17 09:48:30.578242", + "modified": "2020-06-17 23:18:20", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json index 7db1516ce1..660dcff34b 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json @@ -593,6 +593,7 @@ "fieldname": "base_in_words", "fieldtype": "Data", "label": "In Words (Company Currency)", + "length": 240, "oldfieldname": "in_words", "oldfieldtype": "Data", "print_hide": 1, @@ -642,6 +643,7 @@ "fieldname": "in_words", "fieldtype": "Data", "label": "In Words", + "length": 240, "oldfieldname": "in_words_import", "oldfieldtype": "Data", "print_hide": 1, @@ -803,7 +805,7 @@ "idx": 29, "is_submittable": 1, "links": [], - "modified": "2020-05-15 21:24:12.639482", + "modified": "2020-07-18 05:10:45.556792", "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation", diff --git a/erpnext/buying/number_card/active_suppliers/active_suppliers.json b/erpnext/buying/number_card/active_suppliers/active_suppliers.json new file mode 100644 index 0000000000..91d5b13b06 --- /dev/null +++ b/erpnext/buying/number_card/active_suppliers/active_suppliers.json @@ -0,0 +1,20 @@ +{ + "creation": "2020-07-20 21:01:02.499689", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Supplier", + "filters_json": "[[\"Supplier\",\"disabled\",\"=\",\"0\"]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Active Suppliers", + "modified": "2020-07-22 12:48:23.295193", + "modified_by": "Administrator", + "module": "Buying", + "name": "Active Suppliers", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/buying/number_card/annual_purchase/annual_purchase.json b/erpnext/buying/number_card/annual_purchase/annual_purchase.json new file mode 100644 index 0000000000..79f1b65388 --- /dev/null +++ b/erpnext/buying/number_card/annual_purchase/annual_purchase.json @@ -0,0 +1,22 @@ +{ + "aggregate_function_based_on": "base_net_total", + "creation": "2020-07-20 21:01:02.367127", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Purchase Order", + "dynamic_filters_json": "[[\"Purchase Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Purchase Order\",\"transaction_date\",\"Timespan\",\"this year\",false],[\"Purchase Order\",\"status\",\"not in\",[\"Draft\",\"Cancelled\",\"Closed\",null],false],[\"Purchase Order\",\"docstatus\",\"=\",\"1\",false]]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Annual Purchase", + "modified": "2020-07-22 21:21:58.755188", + "modified_by": "Administrator", + "module": "Buying", + "name": "Annual Purchase", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/buying/number_card/purchase_orders_to_bill/purchase_orders_to_bill.json b/erpnext/buying/number_card/purchase_orders_to_bill/purchase_orders_to_bill.json new file mode 100644 index 0000000000..44a0456390 --- /dev/null +++ b/erpnext/buying/number_card/purchase_orders_to_bill/purchase_orders_to_bill.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 21:01:02.468514", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Purchase Order", + "dynamic_filters_json": "[[\"Purchase Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Purchase Order\",\"status\",\"in\",[\"To Receive and Bill\",\"To Bill\",null],false],[\"Purchase Order\",\"docstatus\",\"=\",1,false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Purchase Orders to Bill", + "modified": "2020-07-22 12:48:10.300711", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Orders to Bill", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/buying/number_card/purchase_orders_to_receive/purchase_orders_to_receive.json b/erpnext/buying/number_card/purchase_orders_to_receive/purchase_orders_to_receive.json new file mode 100644 index 0000000000..442dab4b0c --- /dev/null +++ b/erpnext/buying/number_card/purchase_orders_to_receive/purchase_orders_to_receive.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 21:01:02.438012", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Purchase Order", + "dynamic_filters_json": "[[\"Purchase Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Purchase Order\",\"status\",\"in\",[\"To Receive and Bill\",\"To Receive\",null],false],[\"Purchase Order\",\"docstatus\",\"=\",1,false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Purchase Orders to Receive", + "modified": "2020-07-22 12:47:47.460080", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Orders to Receive", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js index a76ffeec2e..518d665e7e 100644 --- a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js +++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js @@ -12,7 +12,22 @@ frappe.query_reports["Quoted Item Comparison"] = { "reqd": 1 }, { - reqd: 1, + "fieldname":"from_date", + "label": __("From Date"), + "fieldtype": "Date", + "width": "80", + "reqd": 1, + "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), + }, + { + "fieldname":"to_date", + "label": __("To Date"), + "fieldtype": "Date", + "width": "80", + "reqd": 1, + "default": frappe.datetime.get_today() + }, + { default: "", options: "Item", label: __("Item"), @@ -45,13 +60,12 @@ frappe.query_reports["Quoted Item Comparison"] = { } }, { - fieldtype: "Link", + fieldtype: "MultiSelectList", label: __("Supplier Quotation"), - options: "Supplier Quotation", fieldname: "supplier_quotation", default: "", - get_query: () => { - return { filters: { "docstatus": ["<", 2] } } + get_data: function(txt) { + return frappe.db.get_link_options('Supplier Quotation', txt, {'docstatus': ["<", 2]}); } }, { @@ -63,9 +77,30 @@ frappe.query_reports["Quoted Item Comparison"] = { get_query: () => { return { filters: { "docstatus": ["<", 2] } } } + }, + { + fieldtype: "Check", + label: __("Include Expired"), + fieldname: "include_expired", + default: 0 } ], + formatter: (value, row, column, data, default_formatter) => { + value = default_formatter(value, row, column, data); + + if(column.fieldname === "valid_till" && data.valid_till){ + if(frappe.datetime.get_diff(data.valid_till, frappe.datetime.nowdate()) <= 1){ + value = `Name of Test | \nResult | \nNormal Range | \n
---|---|---|
{{ doc.lab_test_name }} | ||
\n {%- if doc.normal_test_items|length > 1 %} {%- endif -%}\n {%- if row.lab_test_name -%}{{ row.lab_test_name }}\n {%- else -%} {%- endif -%}\n {%- if row.lab_test_event -%} {{ row.lab_test_event }}{%- endif -%}\n | \n\n\n {%- if row.result_value -%}{{ row.result_value }}{%- endif -%} \n {%- if row.lab_test_uom -%}{{ row.lab_test_uom }}{%- endif -%}\n | \n\n\n \n {%- if row.normal_range -%}{{ row.normal_range }}{%- endif -%}\n \n | \n
Name of Test | \nResult | \n
---|---|
{{ doc.lab_test_name }} | |
{{ row.lab_test_particulars }} | \n\n {%- if row.result_value -%}{{ row.result_value }}{%- endif -%}\n | \n
Antibiotic | \nSensitivity | \n
{{ row.antibiotic }} | \n{{ row.antibiotic_sensitivity }} | \n
Name of Test | \nResult | \nNormal Range | \n
---|---|---|
{{ doc.lab_test_name }} | ||
\n {%- if doc.normal_test_items|length > 1 %} {%- endif -%}\n {%- if row.lab_test_name -%}{{ row.lab_test_name }}\n {%- else -%} {%- endif -%}\n {%- if row.lab_test_event -%} {{ row.lab_test_event }}{%- endif -%}\n | \n\n\n {%- if row.lab_test_uom -%} {{ row.lab_test_uom }}{%- endif -%}\n | \n\n\n \n {%- if row.normal_range -%}{{ row.normal_range }}{%- endif -%}\n \n | \n
Name of Test | \nResult | \n
---|---|
{{ doc.lab_test_name }} | |
{{ row.lab_test_name }} | \n\t\t\t\t\n\t\t\t |
{{ row.lab_test_particulars }} | \n\n |
Name of Test | \nResult | \nNormal Range | \n
---|---|---|
{{ doc.lab_test_name }} | ||
\n {%- if doc.normal_test_items|length > 1 %} {%- endif -%}\n {%- if row.lab_test_name -%}{{ row.lab_test_name }}\n {%- else -%} {%- endif -%}\n {%- if row.lab_test_event -%} {{ row.lab_test_event }}{%- endif -%}\n | \n\n\n\t\t\t\t\t{%- if row.result_value -%}\n\t\t\t\t\t\t{%- if row.bold -%}{% endif %}\n\t\t\t\t\t\t{%- if row.underline -%}{% endif %}\n\t\t\t\t\t\t{%- if row.italic -%}{% endif %}\n {{ row.result_value }}\n {%- if row.lab_test_uom -%} {{ row.lab_test_uom }}{%- endif -%}\n\t\t\t\t\t\t{%- if row.italic -%}{% endif %}\n\t\t\t\t\t\t{%- if row.underline -%}{% endif %}\n\t\t\t\t\t\t{%- if row.bold -%}{% endif %}\n\t\t\t\t\t{%- endif -%}\n \n\t\t\t\t\t{%- if row.secondary_uom and row.conversion_factor and row.secondary_uom_result -%}\n\t\t\t\t\t\t \n\t\t\t\t\t\t{%- if row.bold -%}{% endif %}\n\t\t\t\t\t\t{%- if row.underline -%}{% endif %}\n\t\t\t\t\t\t{%- if row.italic -%}{% endif %}\n {{ row.secondary_uom_result }}\n {{ row.secondary_uom }}\n\t\t\t\t\t\t{%- if row.italic -%}{% endif %}\n\t\t\t\t\t\t{%- if row.underline -%}{% endif %}\n\t\t\t\t\t\t{%- if row.bold -%}{% endif %}\n\t\t\t\t\t\t \n\t\t\t\t\t{%- endif -%}\n | \n\n \n \n {%- if row.normal_range -%}{{ row.normal_range }}{%- endif -%}\n \n | \n
Name of Test | \nResult | \n
---|---|
{{ doc.lab_test_name }} | |
{{ row.lab_test_name }} | \n\t\t\t\t\n\t\t\t |
{{ row.lab_test_particulars }} | \n\n {%- if row.result_value -%}{{ row.result_value }}{%- endif -%}\n | \n
Organism | \n\t\t\t\tColony Population | \n\t\t\t
{{ row.organism }} | \n\t\t\t\t\n\t\t\t\t\t{{ row.colony_population }}\n\t\t\t\t\t{% if row.colony_uom %}\n\t\t\t\t\t\t{{ row.colony_uom }}\n\t\t\t\t\t{% endif %}\n\t\t\t\t | \n\t\t\t
Antibiotic | \n\t\t\t\tSensitivity | \n\t\t\t
{{ row.antibiotic }} | \n\t\t\t\t{{ row.antibiotic_sensitivity }} | \n\t\t\t
Notes:
\n\nbase
for using base salary of the EmployeeBS = Basic Salary
Employment Type = employment_type
Branch = branch
Payment Days = payment_days
Leave without pay = leave_without_pay
base
\nCondition: base < 10000
\nFormula: base * .2
BS
\nCondition: BS > 2000
\nFormula: BS * .1
employment_type
\nCondition: employment_type==\"Intern\"
\nAmount: 1000
\n\t{{ doc.company }}
\n\t{% if doc.company_address_display %}\n\t\t{% set company_address = doc.company_address_display.replace(\"\\n\", \" \").replace(\"
\", \" \") %}\n\t\t{% if \"GSTIN\" not in company_address %}\n\t\t\t{{ company_address }}\n\t\t\t{{ _(\"GSTIN\") }}:{{ doc.company_gstin }}\n\t\t{% else %}\n\t\t\t{{ company_address.replace(\"GSTIN\", \"
GSTIN\") }}\n\t\t{% endif %}\n\t{% endif %}\n\t
\n\t{% if doc.docstatus == 0 %}\n\t\t{{ doc.status + \" \"+ (doc.select_print_heading or _(\"Invoice\")) }}
\n\t{% else %}\n\t\t{{ doc.select_print_heading or _(\"Invoice\") }}
\n\t{% endif %}\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{% if doc.grand_total > 50000 %}\n\t\t{% set customer_address = doc.address_display.replace(\"\\n\", \" \").replace(\"
\", \" \") %}\n\t\t{{ _(\"Customer\") }}:
\n\t\t{{ doc.customer_name }}
\n\t\t{{ customer_address }}\n\t{% endif %}\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.gst_hsn_code -%}\n\t\t\t\t\t {{ _(\"HSN/SAC\") }}: {{ item.gst_hsn_code }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t {{ _(\"SR.No\") }}: \n\t\t\t\t\t{{ item.serial_no | replace(\"\\n\", \", \") }}\n\t\t\t\t{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.rate }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t\t{% if '%' in row.description %}\n\t\t\t\t\t {{ row.description }}\n\t\t\t\t\t{% else %}\n\t\t\t\t\t {{ row.description }}@{{ row.rate }}%\n\t\t\t\t\t{% endif %}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"change_amount\") }}\n\t\t\t | \n\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", + "idx": 0, + "line_breaks": 0, + "modified": "2020-04-29 16:47:02.743246", + "modified_by": "Administrator", + "module": "Selling", + "name": "GST POS Invoice", + "owner": "Administrator", + "print_format_builder": 0, + "print_format_type": "Jinja", + "raw_printing": 0, + "show_section_headings": 0, + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/print_format/pos_invoice/__init__.py b/erpnext/selling/print_format/pos_invoice/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/selling/print_format/pos_invoice/pos_invoice.json b/erpnext/selling/print_format/pos_invoice/pos_invoice.json new file mode 100644 index 0000000000..99094ed9b0 --- /dev/null +++ b/erpnext/selling/print_format/pos_invoice/pos_invoice.json @@ -0,0 +1,22 @@ +{ + "align_labels_right": 0, + "creation": "2011-12-21 11:08:55", + "custom_format": 1, + "disabled": 0, + "doc_type": "POS Invoice", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n{% if letter_head %}\n {{ letter_head }}\n{% endif %}\n\n\n\t{{ doc.company }}
\n\t{{ doc.select_print_heading or _(\"Invoice\") }}
\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{{ _(\"Customer\") }}: {{ doc.customer_name }}\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t {{ _(\"SR.No\") }}: \n\t\t\t\t\t{{ item.serial_no | replace(\"\\n\", \", \") }}\n\t\t\t\t{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.get_formatted(\"rate\") }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t {% if '%' in row.description %}\n\t\t\t\t\t {{ row.description }}\n\t\t\t\t\t{% else %}\n\t\t\t\t\t {{ row.description }}@{{ row.rate }}%\n\t\t\t\t\t{% endif %}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"change_amount\") }}\n\t\t\t\t | \n\t\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", + "idx": 1, + "line_breaks": 0, + "modified": "2020-04-29 16:45:58.942375", + "modified_by": "Administrator", + "module": "Selling", + "name": "POS Invoice", + "owner": "Administrator", + "print_format_builder": 0, + "print_format_type": "Jinja", + "raw_printing": 0, + "show_section_headings": 0, + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/print_format/return_pos_invoice/__init__.py b/erpnext/selling/print_format/return_pos_invoice/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/selling/print_format/return_pos_invoice/return_pos_invoice.json b/erpnext/selling/print_format/return_pos_invoice/return_pos_invoice.json new file mode 100644 index 0000000000..d7f335059c --- /dev/null +++ b/erpnext/selling/print_format/return_pos_invoice/return_pos_invoice.json @@ -0,0 +1,24 @@ +{ + "align_labels_right": 0, + "creation": "2020-05-14 17:02:44.207166", + "custom_format": 1, + "default_print_language": "en", + "disabled": 0, + "doc_type": "POS Invoice", + "docstatus": 0, + "doctype": "Print Format", + "font": "Default", + "html": "\n\n{% if letter_head %}\n {{ letter_head }}\n{% endif %}\n\n\n\t{{ doc.company }}
\n\t{{ doc.select_print_heading or _(\"Return Invoice\") }}
\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Original Invoice\") }}: {{ doc.return_against }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{{ _(\"Customer\") }}: {{ doc.customer_name }}\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t {{ _(\"SR.No\") }}: \n\t\t\t\t\t{{ item.serial_no | replace(\"\\n\", \", \") }}\n\t\t\t\t{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.get_formatted(\"rate\") }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t {% if '%' in row.description %}\n\t\t\t\t\t {{ row.description }}\n\t\t\t\t\t{% else %}\n\t\t\t\t\t {{ row.description }}@{{ row.rate }}%\n\t\t\t\t\t{% endif %}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc)}}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"change_amount\")}}\n\t\t\t\t | \n\t\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", + "idx": 0, + "line_breaks": 0, + "modified": "2020-05-14 17:13:29.354015", + "modified_by": "Administrator", + "module": "Selling", + "name": "Return POS Invoice", + "owner": "Administrator", + "print_format_builder": 0, + "print_format_type": "Jinja", + "raw_printing": 0, + "show_section_headings": 0, + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py index 1bc4657f29..0a70b97648 100644 --- a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py +++ b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.py @@ -191,7 +191,7 @@ def get_conditions(filters): conditions += "AND so_item.item_code = '%s'" %frappe.db.escape(filters.item_code) if filters.get("customer"): - conditions += "AND so.customer = '%s'" %frappe.db.escape(filters.customer) + conditions += "AND so.customer = %s" %frappe.db.escape(filters.customer) return conditions diff --git a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py index 7e8e6e9e8b..f5feb95f1a 100644 --- a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py +++ b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py @@ -96,7 +96,7 @@ def prepare_data(data, filters): # prepare data for report view row["qty_to_bill"] = flt(row["qty"]) - flt(row["billed_qty"]) - row["delay"] = 0 if row["delay"] < 0 else row["delay"] + row["delay"] = 0 if row["delay"] and row["delay"] < 0 else row["delay"] if filters.get("group_by_so"): so_name = row["sales_order"] diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 4a7dd5ad9b..002cfe41e1 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -142,7 +142,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]); // check if child doctype is Sales Order Item/Qutation Item and calculate the rate - if(in_list(["Quotation Item", "Sales Order Item", "Delivery Note Item", "Sales Invoice Item"]), cdt) + if(in_list(["Quotation Item", "Sales Order Item", "Delivery Note Item", "Sales Invoice Item", "POS Invoice Item"]), cdt) this.apply_pricing_rule_on_item(item); else item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0), @@ -312,6 +312,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ batch_no: function(doc, cdt, cdn) { var me = this; var item = frappe.get_doc(cdt, cdn); + + if (item.serial_no) { + return; + } + item.serial_no = null; var has_serial_no; frappe.db.get_value('Item', {'item_code': item.item_code}, 'has_serial_no', (r) => { @@ -489,13 +494,18 @@ frappe.ui.form.on(cur_frm.doctype, { var dialog = new frappe.ui.Dialog({ title: __("Set as Lost"), fields: [ - {"fieldtype": "Table MultiSelect", - "label": __("Lost Reasons"), - "fieldname": "lost_reason", - "options": "Lost Reason Detail", - "reqd": 1}, - - {"fieldtype": "Text", "label": __("Detailed Reason"), "fieldname": "detailed_reason"}, + { + "fieldtype": "Table MultiSelect", + "label": __("Lost Reasons"), + "fieldname": "lost_reason", + "options": frm.doctype === 'Opportunity' ? 'Opportunity Lost Reason Detail': 'Quotation Lost Reason Detail', + "reqd": 1 + }, + { + "fieldtype": "Text", + "label": __("Detailed Reason"), + "fieldname": "detailed_reason" + }, ], primary_action: function() { var values = dialog.get_values(); diff --git a/erpnext/selling/selling_dashboard/selling/selling.json b/erpnext/selling/selling_dashboard/selling/selling.json new file mode 100644 index 0000000000..52e6714965 --- /dev/null +++ b/erpnext/selling/selling_dashboard/selling/selling.json @@ -0,0 +1,46 @@ +{ + "cards": [ + { + "card": "Annual Sales" + }, + { + "card": "Sales Orders to Deliver" + }, + { + "card": "Sales Orders to Bill" + }, + { + "card": "Active Customers" + } + ], + "charts": [ + { + "chart": "Sales Order Trends", + "width": "Full" + }, + { + "chart": "Top Customers", + "width": "Half" + }, + { + "chart": "Sales Order Analysis", + "width": "Half" + }, + { + "chart": "Item-wise Annual Sales", + "width": "Full" + } + ], + "creation": "2020-07-20 20:17:16.688162", + "dashboard_name": "Selling", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 0, + "is_standard": 1, + "modified": "2020-07-22 15:31:22.299903", + "modified_by": "Administrator", + "module": "Selling", + "name": "Selling", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 7ae5385a23..f882db60c5 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -34,6 +34,16 @@ frappe.ui.form.on("Company", { frm.set_query("default_buying_terms", function() { return { filters: { buying: 1 } }; }); + + frm.set_query("default_in_transit_warehouse", function() { + return { + filters:{ + 'warehouse_type' : 'Transit', + 'is_group': 0, + 'company': frm.doc.company + } + }; + }); }, company_name: function(frm) { diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 221044df3a..4a26a71970 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -25,6 +25,7 @@ "default_selling_terms", "default_buying_terms", "default_warehouse_for_sales_return", + "default_in_transit_warehouse", "column_break_10", "country", "create_chart_of_accounts_based_on", @@ -242,7 +243,7 @@ { "fieldname": "default_warehouse_for_sales_return", "fieldtype": "Link", - "label": "Default warehouse for Sales Return", + "label": "Default Warehouse for Sales Return", "options": "Warehouse" }, { @@ -733,6 +734,12 @@ "fieldname": "enable_perpetual_inventory_for_non_stock_items", "fieldtype": "Check", "label": "Enable Perpetual Inventory For Non Stock Items" + }, + { + "fieldname": "default_in_transit_warehouse", + "fieldtype": "Link", + "label": "Default In Transit Warehouse", + "options": "Warehouse" } ], "icon": "fa fa-building", @@ -740,7 +747,7 @@ "image_field": "company_logo", "is_tree": 1, "links": [], - "modified": "2020-06-24 12:45:31.462195", + "modified": "2020-08-06 00:38:08.311216", "modified_by": "Administrator", "module": "Setup", "name": "Company", @@ -801,4 +808,4 @@ "sort_field": "modified", "sort_order": "ASC", "track_changes": 1 -} \ No newline at end of file +} diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 47b41a97ad..8e707fe3f4 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -140,7 +140,8 @@ class Company(NestedSet): {"warehouse_name": _("All Warehouses"), "is_group": 1}, {"warehouse_name": _("Stores"), "is_group": 0}, {"warehouse_name": _("Work In Progress"), "is_group": 0}, - {"warehouse_name": _("Finished Goods"), "is_group": 0}]: + {"warehouse_name": _("Finished Goods"), "is_group": 0}, + {"warehouse_name": _("Goods In Transit"), "is_group": 0, "warehouse_type": "Transit"}]: if not frappe.db.exists("Warehouse", "{0} - {1}".format(wh_detail["warehouse_name"], self.abbr)): warehouse = frappe.get_doc({ @@ -149,7 +150,8 @@ class Company(NestedSet): "is_group": wh_detail["is_group"], "company": self.name, "parent_warehouse": "{0} - {1}".format(_("All Warehouses"), self.abbr) \ - if not wh_detail["is_group"] else "" + if not wh_detail["is_group"] else "", + "warehouse_type" : wh_detail["warehouse_type"] if "warehouse_type" in wh_detail else None }) warehouse.flags.ignore_permissions = True warehouse.flags.ignore_mandatory = True diff --git a/erpnext/setup/doctype/company/delete_company_transactions.py b/erpnext/setup/doctype/company/delete_company_transactions.py index 8ecc13b2fb..c94831ef93 100644 --- a/erpnext/setup/doctype/company/delete_company_transactions.py +++ b/erpnext/setup/doctype/company/delete_company_transactions.py @@ -26,7 +26,8 @@ def delete_company_transactions(company_name): tabDocField where fieldtype='Link' and options='Company'"""): if doctype not in ("Account", "Cost Center", "Warehouse", "Budget", "Party Account", "Employee", "Sales Taxes and Charges Template", - "Purchase Taxes and Charges Template", "POS Profile", 'BOM'): + "Purchase Taxes and Charges Template", "POS Profile", "BOM", + "Company", "Bank Account"): delete_for_doctype(doctype, company_name) # reset company values diff --git a/erpnext/setup/doctype/party_type/party_type.py b/erpnext/setup/doctype/party_type/party_type.py index b29c305ee7..96e60936a4 100644 --- a/erpnext/setup/doctype/party_type/party_type.py +++ b/erpnext/setup/doctype/party_type/party_type.py @@ -10,6 +10,7 @@ class PartyType(Document): pass @frappe.whitelist() +@frappe.validate_and_sanitize_search_inputs def get_party_type(doctype, txt, searchfield, start, page_len, filters): cond = '' if filters and filters.get('account'): diff --git a/erpnext/setup/doctype/quotation_lost_reason_detail/__init__.py b/erpnext/setup/doctype/quotation_lost_reason_detail/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/setup/doctype/quotation_lost_reason_detail/quotation_lost_reason_detail.json b/erpnext/setup/doctype/quotation_lost_reason_detail/quotation_lost_reason_detail.json new file mode 100644 index 0000000000..543214101a --- /dev/null +++ b/erpnext/setup/doctype/quotation_lost_reason_detail/quotation_lost_reason_detail.json @@ -0,0 +1,31 @@ +{ + "actions": [], + "creation": "2020-07-14 09:21:44.057724", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "lost_reason" + ], + "fields": [ + { + "fieldname": "lost_reason", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Quotation Lost Reason", + "options": "Quotation Lost Reason" + } + ], + "istable": 1, + "links": [], + "modified": "2020-07-26 17:58:56.373775", + "modified_by": "Administrator", + "module": "Setup", + "name": "Quotation Lost Reason Detail", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason_detail/quotation_lost_reason_detail.py b/erpnext/setup/doctype/quotation_lost_reason_detail/quotation_lost_reason_detail.py new file mode 100644 index 0000000000..7bb8d02670 --- /dev/null +++ b/erpnext/setup/doctype/quotation_lost_reason_detail/quotation_lost_reason_detail.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class QuotationLostReasonDetail(Document): + pass diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index aa9fbc0a92..4f0f5721c2 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -7,6 +7,7 @@ import frappe from erpnext.accounts.doctype.cash_flow_mapper.default_cash_flow_mapper import DEFAULT_MAPPERS from .default_success_action import get_default_success_action from frappe import _ +from frappe.utils import cint from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to from frappe.custom.doctype.custom_field.custom_field import create_custom_field from erpnext.setup.default_energy_point_rules import get_default_energy_point_rules @@ -25,12 +26,13 @@ def after_install(): create_default_success_action() create_default_energy_point_rules() add_company_to_session_defaults() + add_standard_navbar_items() frappe.db.commit() def check_setup_wizard_not_completed(): - if frappe.db.get_default('desktop:home_page') != 'setup-wizard': - message = """ERPNext can only be installed on a fresh site where the setup wizard is not completed. + if cint(frappe.db.get_single_value('System Settings', 'setup_complete') or 0): + message = """ERPNext can only be installed on a fresh site where the setup wizard is not completed. You can reinstall this site (after saving your data) using: bench --site [sitename] reinstall""" frappe.throw(message) @@ -103,3 +105,45 @@ def add_company_to_session_defaults(): "ref_doctype": "Company" }) settings.save() + +def add_standard_navbar_items(): + navbar_settings = frappe.get_single("Navbar Settings") + + erpnext_navbar_items = [ + { + 'item_label': 'Documentation', + 'item_type': 'Route', + 'route': 'https://erpnext.com/docs/user/manual', + 'is_standard': 1 + }, + { + 'item_label': 'User Forum', + 'item_type': 'Route', + 'route': 'https://discuss.erpnext.com', + 'is_standard': 1 + }, + { + 'item_label': 'Report an Issue', + 'item_type': 'Route', + 'route': 'https://github.com/frappe/erpnext/issues', + 'is_standard': 1 + } + ] + + current_nabvar_items = navbar_settings.help_dropdown + navbar_settings.set('help_dropdown', []) + + for item in erpnext_navbar_items: + navbar_settings.append('help_dropdown', item) + + for item in current_nabvar_items: + navbar_settings.append('help_dropdown', { + 'item_label': item.item_label, + 'item_type': item.item_type, + 'route': item.route, + 'action': item.action, + 'is_standard': item.is_standard, + 'hidden': item.hidden + }) + + navbar_settings.save() diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index ad063cfc9d..72ed00293e 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -95,8 +95,6 @@ def install(country=None): {'doctype': 'Stock Entry Type', 'name': 'Send to Subcontractor', 'purpose': 'Send to Subcontractor'}, {'doctype': 'Stock Entry Type', 'name': 'Material Transfer for Manufacture', 'purpose': 'Material Transfer for Manufacture'}, {'doctype': 'Stock Entry Type', 'name': 'Material Consumption for Manufacture', 'purpose': 'Material Consumption for Manufacture'}, - {'doctype': 'Stock Entry Type', 'name': 'Send to Warehouse', 'purpose': 'Send to Warehouse'}, - {'doctype': 'Stock Entry Type', 'name': 'Receive at Warehouse', 'purpose': 'Receive at Warehouse'}, # Designation {'doctype': 'Designation', 'designation_name': _('CEO')}, @@ -244,7 +242,10 @@ def install(country=None): {"doctype": "Sales Stage", "stage_name": _("Identifying Decision Makers")}, {"doctype": "Sales Stage", "stage_name": _("Perception Analysis")}, {"doctype": "Sales Stage", "stage_name": _("Proposal/Price Quote")}, - {"doctype": "Sales Stage", "stage_name": _("Negotiation/Review")} + {"doctype": "Sales Stage", "stage_name": _("Negotiation/Review")}, + + # Warehouse Type + {'doctype': 'Warehouse Type', 'name': 'Transit'}, ] from erpnext.setup.setup_wizard.data.industry_type import get_industry_types diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js index ffc5daba62..21fa4c3065 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js @@ -1,31 +1,22 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -$.extend(cur_frm.cscript, { - onload: function() { - if(cur_frm.doc.__onload && cur_frm.doc.__onload.quotation_series) { - cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__onload.quotation_series; - cur_frm.refresh_field("quotation_series"); +frappe.ui.form.on("Shopping Cart Settings", { + onload: function(frm) { + if(frm.doc.__onload && frm.doc.__onload.quotation_series) { + frm.fields_dict.quotation_series.df.options = frm.doc.__onload.quotation_series; + frm.refresh_field("quotation_series"); } }, - refresh: function(){ - toggle_mandatory(cur_frm) - }, - enable_checkout: function(){ - toggle_mandatory(cur_frm) - }, - enabled: function() { - if (cur_frm.doc.enabled === 1) { - cur_frm.doc.show_configure_button = 1; - cur_frm.refresh_field('show_configure_button'); + enabled: function(frm) { + if (frm.doc.enabled === 1) { + frm.set_value('enable_variants', 1); + } + else { + frm.set_value('company', ''); + frm.set_value('price_list', ''); + frm.set_value('default_customer_group', ''); + frm.set_value('quotation_series', ''); } } }); - - -function toggle_mandatory (cur_frm){ - cur_frm.toggle_reqd("payment_gateway_account", false); - if(cur_frm.doc.enabled && cur_frm.doc.enable_checkout) { - cur_frm.toggle_reqd("payment_gateway_account", true); - } -} diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json index e828f54878..32004efdca 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json @@ -1,750 +1,193 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, - "creation": "2013-06-19 15:57:32", - "custom": 0, - "description": "Default settings for Shopping Cart", - "docstatus": 0, - "doctype": "DocType", - "document_type": "System", - "editable_grid": 0, - "fields": [ - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "enabled", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Enable Shopping Cart", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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, - "depends_on": "", - "description": "", - "fieldname": "display_settings", - "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, - "label": "Display Settings", - "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, - "depends_on": "", - "description": "", - "fieldname": "show_attachments", - "fieldtype": "Check", - "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": "Show Public Attachments", - "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, - "depends_on": "", - "description": "", - "fieldname": "show_price", - "fieldtype": "Check", - "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": "Show Price", - "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, - "fieldname": "show_stock_availability", - "fieldtype": "Check", - "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": "Show Stock Availability", - "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, - "fieldname": "show_configure_button", - "fieldtype": "Check", - "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": "Show Configure Button", - "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, - "fieldname": "show_contact_us_button", - "fieldtype": "Check", - "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": "Show Contact Us Button", - "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, - "depends_on": "show_stock_availability", - "fieldname": "show_quantity_in_website", - "fieldtype": "Check", - "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": "Show Stock Quantity", - "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, - "depends_on": "", - "fetch_if_empty": 0, - "fieldname": "show_apply_coupon_code_in_website", - "fieldtype": "Check", - "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": "Show Apply Coupon Code", - "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": "allow_items_not_in_stock", - "fieldtype": "Check", - "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": "Allow items not in stock to be added to cart", - "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, - "depends_on": "enabled", - "fieldname": "section_break_2", - "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, - "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, - "depends_on": "", - "fieldname": "company", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Company", - "length": 0, - "no_copy": 0, - "options": "Company", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 1, - "report_hide": 0, - "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, - "description": "Prices will not be shown if Price List is not set", - "fieldname": "price_list", - "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": "Price List", - "length": 0, - "no_copy": 0, - "options": "Price List", - "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, - "fieldname": "column_break_4", - "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, - "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, - "description": "", - "fieldname": "default_customer_group", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Default Customer Group", - "length": 0, - "no_copy": 0, - "options": "Customer Group", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "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, - "fieldname": "quotation_series", - "fieldtype": "Select", - "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": "Quotation Series", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "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": 1, - "collapsible_depends_on": "eval:doc.enable_checkout", - "columns": 0, - "depends_on": "enabled", - "fieldname": "section_break_8", - "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, - "label": "Checkout Settings", - "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, - "collapsible_depends_on": "", - "columns": 0, - "depends_on": "", - "fieldname": "enable_checkout", - "fieldtype": "Check", - "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": "Enable Checkout", - "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, - "default": "Orders", - "description": "After payment completion redirect user to selected page.", - "fieldname": "payment_success_url", - "fieldtype": "Select", - "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": "Payment Success Url", - "length": 0, - "no_copy": 0, - "options": "\nOrders\nInvoices\nMy 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, - "fieldname": "column_break_11", - "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, - "fieldname": "payment_gateway_account", - "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": "Payment Gateway Account", - "length": 0, - "no_copy": 0, - "options": "Payment Gateway 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 - } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "icon": "fa fa-shopping-cart", - "idx": 1, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 1, - "istable": 0, - "max_attachments": 0, - "modified": "2019-10-14 13:54:24.575322", - "modified_by": "Administrator", - "module": "Shopping Cart", - "name": "Shopping Cart Settings", - "owner": "Administrator", - "permissions": [ - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 0, - "email": 1, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "role": "Website Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 1 - } - ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_order": "ASC", - "track_changes": 0, - "track_seen": 0, - "track_views": 0 - } \ No newline at end of file + "actions": [], + "creation": "2013-06-19 15:57:32", + "description": "Default settings for Shopping Cart", + "doctype": "DocType", + "document_type": "System", + "engine": "InnoDB", + "field_order": [ + "enabled", + "display_settings", + "show_attachments", + "show_price", + "show_stock_availability", + "enable_variants", + "column_break_7", + "show_contact_us_button", + "show_quantity_in_website", + "show_apply_coupon_code_in_website", + "allow_items_not_in_stock", + "section_break_2", + "company", + "price_list", + "column_break_4", + "default_customer_group", + "quotation_series", + "section_break_8", + "enable_checkout", + "payment_success_url", + "column_break_11", + "payment_gateway_account" + ], + "fields": [ + { + "default": "0", + "fieldname": "enabled", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Enable Shopping Cart" + }, + { + "fieldname": "display_settings", + "fieldtype": "Section Break", + "label": "Display Settings" + }, + { + "default": "0", + "fieldname": "show_attachments", + "fieldtype": "Check", + "label": "Show Public Attachments" + }, + { + "default": "0", + "fieldname": "show_price", + "fieldtype": "Check", + "label": "Show Price" + }, + { + "default": "0", + "fieldname": "show_stock_availability", + "fieldtype": "Check", + "label": "Show Stock Availability" + }, + { + "default": "0", + "fieldname": "show_contact_us_button", + "fieldtype": "Check", + "label": "Show Contact Us Button" + }, + { + "default": "0", + "depends_on": "show_stock_availability", + "fieldname": "show_quantity_in_website", + "fieldtype": "Check", + "label": "Show Stock Quantity" + }, + { + "default": "0", + "fieldname": "show_apply_coupon_code_in_website", + "fieldtype": "Check", + "label": "Show Apply Coupon Code" + }, + { + "default": "0", + "fieldname": "allow_items_not_in_stock", + "fieldtype": "Check", + "label": "Allow items not in stock to be added to cart" + }, + { + "depends_on": "enabled", + "fieldname": "section_break_2", + "fieldtype": "Section Break" + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Company", + "mandatory_depends_on": "eval: doc.enabled === 1", + "options": "Company", + "remember_last_selected_value": 1 + }, + { + "description": "Prices will not be shown if Price List is not set", + "fieldname": "price_list", + "fieldtype": "Link", + "label": "Price List", + "mandatory_depends_on": "eval: doc.enabled === 1", + "options": "Price List" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "fieldname": "default_customer_group", + "fieldtype": "Link", + "ignore_user_permissions": 1, + "label": "Default Customer Group", + "mandatory_depends_on": "eval: doc.enabled === 1", + "options": "Customer Group" + }, + { + "fieldname": "quotation_series", + "fieldtype": "Select", + "label": "Quotation Series", + "mandatory_depends_on": "eval: doc.enabled === 1" + }, + { + "collapsible": 1, + "collapsible_depends_on": "eval:doc.enable_checkout", + "depends_on": "enabled", + "fieldname": "section_break_8", + "fieldtype": "Section Break", + "label": "Checkout Settings" + }, + { + "default": "0", + "fieldname": "enable_checkout", + "fieldtype": "Check", + "label": "Enable Checkout" + }, + { + "default": "Orders", + "description": "After payment completion redirect user to selected page.", + "fieldname": "payment_success_url", + "fieldtype": "Select", + "label": "Payment Success Url", + "options": "\nOrders\nInvoices\nMy Account" + }, + { + "fieldname": "column_break_11", + "fieldtype": "Column Break" + }, + { + "fieldname": "payment_gateway_account", + "fieldtype": "Link", + "label": "Payment Gateway Account", + "options": "Payment Gateway Account" + }, + { + "fieldname": "column_break_7", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "enable_variants", + "fieldtype": "Check", + "label": "Enable Variants" + } + ], + "icon": "fa fa-shopping-cart", + "idx": 1, + "issingle": 1, + "links": [], + "modified": "2020-08-02 18:21:43.873303", + "modified_by": "Administrator", + "module": "Shopping Cart", + "name": "Shopping Cart Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "Website Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "ASC" +} \ No newline at end of file diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py index 3098190383..c069b90e98 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py @@ -80,6 +80,7 @@ def get_shopping_cart_settings(): return frappe.local.shopping_cart_settings +@frappe.whitelist(allow_guest=True) def is_cart_enabled(): return get_shopping_cart_settings().enabled diff --git a/erpnext/startup/leaderboard.py b/erpnext/startup/leaderboard.py index 90ecd46259..5545f13e8c 100644 --- a/erpnext/startup/leaderboard.py +++ b/erpnext/startup/leaderboard.py @@ -50,11 +50,12 @@ def get_leaderboards(): return leaderboards @frappe.whitelist() -def get_all_customers(from_date, company, field, limit = None): +def get_all_customers(date_range, company, field, limit = None): if field == "outstanding_amount": filters = [['docstatus', '=', '1'], ['company', '=', company]] - if from_date: - filters.append(['posting_date', '>=', from_date]) + if date_range: + date_range = frappe.parse_json(date_range) + filters.append(['posting_date', '>=', 'between', [date_range[0], date_range[1]]]) return frappe.db.get_all('Sales Invoice', fields = ['customer as name', 'sum(outstanding_amount) as value'], filters = filters, @@ -68,18 +69,20 @@ def get_all_customers(from_date, company, field, limit = None): elif field == "total_qty_sold": select_field = "sum(so_item.stock_qty)" + date_condition = get_date_condition(date_range, 'so.transaction_date') + return frappe.db.sql(""" select so.customer as name, {0} as value FROM `tabSales Order` as so JOIN `tabSales Order Item` as so_item ON so.name = so_item.parent - where so.docstatus = 1 and so.transaction_date >= %s and so.company = %s + where so.docstatus = 1 {1} and so.company = %s group by so.customer order by value DESC limit %s - """.format(select_field), (from_date, company, cint(limit)), as_dict=1) #nosec + """.format(select_field, date_condition), (company, cint(limit)), as_dict=1) @frappe.whitelist() -def get_all_items(from_date, company, field, limit = None): +def get_all_items(date_range, company, field, limit = None): if field in ("available_stock_qty", "available_stock_value"): select_field = "sum(actual_qty)" if field=="available_stock_qty" else "sum(stock_value)" return frappe.db.get_all('Bin', @@ -102,23 +105,25 @@ def get_all_items(from_date, company, field, limit = None): select_field = "sum(order_item.stock_qty)" select_doctype = "Purchase Order" + date_condition = get_date_condition(date_range, 'sales_order.transaction_date') + return frappe.db.sql(""" select order_item.item_code as name, {0} as value from `tab{1}` sales_order join `tab{1} Item` as order_item on sales_order.name = order_item.parent where sales_order.docstatus = 1 - and sales_order.company = %s and sales_order.transaction_date >= %s + and sales_order.company = %s {2} group by order_item.item_code order by value desc limit %s - """.format(select_field, select_doctype), (company, from_date, cint(limit)), as_dict=1) #nosec + """.format(select_field, select_doctype, date_condition), (company, cint(limit)), as_dict=1) #nosec @frappe.whitelist() -def get_all_suppliers(from_date, company, field, limit = None): +def get_all_suppliers(date_range, company, field, limit = None): if field == "outstanding_amount": filters = [['docstatus', '=', '1'], ['company', '=', company]] - if from_date: - filters.append(['posting_date', '>=', from_date]) + if date_range: + filters.append(['posting_date', 'between' [date_range[0], date_range[1]]]) return frappe.db.get_all('Purchase Invoice', fields = ['supplier as name', 'sum(outstanding_amount) as value'], filters = filters, @@ -132,18 +137,22 @@ def get_all_suppliers(from_date, company, field, limit = None): elif field == "total_qty_purchased": select_field = "sum(purchase_order_item.stock_qty)" + date_condition = get_date_condition(date_range, 'purchase_order.modified') + return frappe.db.sql(""" select purchase_order.supplier as name, {0} as value FROM `tabPurchase Order` as purchase_order LEFT JOIN `tabPurchase Order Item` as purchase_order_item ON purchase_order.name = purchase_order_item.parent - where purchase_order.docstatus = 1 and purchase_order.modified >= %s + where + purchase_order.docstatus = 1 + {1} and purchase_order.company = %s group by purchase_order.supplier order by value DESC - limit %s""".format(select_field), (from_date, company, cint(limit)), as_dict=1) #nosec + limit %s""".format(select_field, date_condition), (company, cint(limit)), as_dict=1) #nosec @frappe.whitelist() -def get_all_sales_partner(from_date, company, field, limit = None): +def get_all_sales_partner(date_range, company, field, limit = None): if field == "total_sales_amount": select_field = "sum(`base_net_total`)" elif field == "total_commission": @@ -154,8 +163,9 @@ def get_all_sales_partner(from_date, company, field, limit = None): 'docstatus': 1, 'company': company } - if from_date: - filters['transaction_date'] = ['>=', from_date] + if date_range: + date_range = frappe.parse_json(date_range) + filters['transaction_date'] = ['between', [date_range[0], date_range[1]]] return frappe.get_list('Sales Order', fields=[ '`sales_partner` as name', @@ -163,15 +173,27 @@ def get_all_sales_partner(from_date, company, field, limit = None): ], filters=filters, group_by='sales_partner', order_by='value DESC', limit=limit) @frappe.whitelist() -def get_all_sales_person(from_date, company, field = None, limit = 0): +def get_all_sales_person(date_range, company, field = None, limit = 0): + date_condition = get_date_condition(date_range, 'sales_order.transaction_date') + return frappe.db.sql(""" select sales_team.sales_person as name, sum(sales_order.base_net_total) as value from `tabSales Order` as sales_order join `tabSales Team` as sales_team on sales_order.name = sales_team.parent and sales_team.parenttype = 'Sales Order' where sales_order.docstatus = 1 - and sales_order.transaction_date >= %s and sales_order.company = %s + {date_condition} group by sales_team.sales_person order by value DESC limit %s - """, (from_date, company, cint(limit)), as_dict=1) + """.format(date_condition=date_condition), (company, cint(limit)), as_dict=1) + +def get_date_condition(date_range, field): + date_condition = '' + if date_range: + date_range = frappe.parse_json(date_range) + from_date, to_date = date_range + date_condition = "and {0} between {1} and {2}".format( + field, frappe.db.escape(from_date), frappe.db.escape(to_date) + ) + return date_condition \ No newline at end of file diff --git a/erpnext/stock/dashboard_chart/delivery_trends/delivery_trends.json b/erpnext/stock/dashboard_chart/delivery_trends/delivery_trends.json new file mode 100644 index 0000000000..b3f6e35012 --- /dev/null +++ b/erpnext/stock/dashboard_chart/delivery_trends/delivery_trends.json @@ -0,0 +1,27 @@ +{ + "based_on": "posting_date", + "chart_name": "Delivery Trends", + "chart_type": "Sum", + "color": "#4d4da8", + "creation": "2020-07-20 21:01:04.255291", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Delivery Note", + "filters_json": "[[\"Delivery Note\",\"docstatus\",\"=\",1]]", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 13:03:24.937045", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Trends", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Monthly", + "timeseries": 1, + "timespan": "Last Year", + "type": "Bar", + "use_report_chart": 0, + "value_based_on": "base_net_total", + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/stock/dashboard_chart/item_shortage_summary/item_shortage_summary.json b/erpnext/stock/dashboard_chart/item_shortage_summary/item_shortage_summary.json new file mode 100644 index 0000000000..ce711247e7 --- /dev/null +++ b/erpnext/stock/dashboard_chart/item_shortage_summary/item_shortage_summary.json @@ -0,0 +1,23 @@ +{ + "chart_name": "Item Shortage Summary", + "chart_type": "Report", + "creation": "2020-07-20 21:01:04.383451", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\"}", + "filters_json": "{}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 13:07:01.905334", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Shortage Summary", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Item Shortage Report", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json b/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json new file mode 100644 index 0000000000..9c10a5346b --- /dev/null +++ b/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Oldest Items", + "chart_type": "Report", + "creation": "2020-07-20 21:01:04.336845", + "custom_options": "{\"colors\": [\"#5e64ff\"]}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"range1\":30,\"range2\":60,\"range3\":90,\"show_warehouse_wise_stock\":0}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-29 14:50:26.846482", + "modified_by": "Administrator", + "module": "Stock", + "name": "Oldest Items", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Stock Ageing", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/stock/dashboard_chart/purchase_receipt_trends/purchase_receipt_trends.json b/erpnext/stock/dashboard_chart/purchase_receipt_trends/purchase_receipt_trends.json new file mode 100644 index 0000000000..584a6cc867 --- /dev/null +++ b/erpnext/stock/dashboard_chart/purchase_receipt_trends/purchase_receipt_trends.json @@ -0,0 +1,27 @@ +{ + "based_on": "posting_date", + "chart_name": "Purchase Receipt Trends", + "chart_type": "Sum", + "color": "#78d6ff", + "creation": "2020-07-20 21:01:04.205230", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Purchase Receipt", + "filters_json": "[[\"Purchase Receipt\",\"docstatus\",\"=\",1]]", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 13:05:25.923130", + "modified_by": "Administrator", + "module": "Stock", + "name": "Purchase Receipt Trends", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Monthly", + "timeseries": 1, + "timespan": "Last Year", + "type": "Bar", + "use_report_chart": 0, + "value_based_on": "base_net_total", + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/stock/dashboard_chart/warehouse_wise_stock_value/warehouse_wise_stock_value.json b/erpnext/stock/dashboard_chart/warehouse_wise_stock_value/warehouse_wise_stock_value.json new file mode 100644 index 0000000000..a07b55382c --- /dev/null +++ b/erpnext/stock/dashboard_chart/warehouse_wise_stock_value/warehouse_wise_stock_value.json @@ -0,0 +1,22 @@ +{ + "chart_name": "Warehouse wise Stock Value", + "chart_type": "Custom", + "creation": "2020-07-20 21:01:04.296157", + "docstatus": 0, + "doctype": "Dashboard Chart", + "filters_json": "{}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 13:01:01.815123", + "modified_by": "Administrator", + "module": "Stock", + "name": "Warehouse wise Stock Value", + "number_of_groups": 0, + "owner": "Administrator", + "source": "Warehouse wise Stock Value", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/stock/dashboard_fixtures.py b/erpnext/stock/dashboard_fixtures.py deleted file mode 100644 index 7625b1ad28..0000000000 --- a/erpnext/stock/dashboard_fixtures.py +++ /dev/null @@ -1,170 +0,0 @@ -# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -import frappe -import json -from frappe import _ -from frappe.utils import nowdate -from erpnext.accounts.dashboard_fixtures import _get_fiscal_year -from erpnext.buying.dashboard_fixtures import get_company_for_dashboards - -def get_data(): - fiscal_year = _get_fiscal_year(nowdate()) - - if not fiscal_year: - return frappe._dict() - - company = frappe.get_doc("Company", get_company_for_dashboards()) - fiscal_year_name = fiscal_year.get("name") - start_date = str(fiscal_year.get("year_start_date")) - end_date = str(fiscal_year.get("year_end_date")) - - return frappe._dict({ - "dashboards": get_dashboards(), - "charts": get_charts(company, fiscal_year_name, start_date, end_date), - "number_cards": get_number_cards(company, fiscal_year_name, start_date, end_date), - }) - -def get_dashboards(): - return [{ - "name": "Stock", - "dashboard_name": "Stock", - "charts": [ - { "chart": "Warehouse wise Stock Value", "width": "Full"}, - { "chart": "Purchase Receipt Trends", "width": "Half"}, - { "chart": "Delivery Trends", "width": "Half"}, - { "chart": "Oldest Items", "width": "Half"}, - { "chart": "Item Shortage Summary", "width": "Half"} - ], - "cards": [ - { "card": "Total Active Items"}, - { "card": "Total Warehouses"}, - { "card": "Total Stock Value"} - ] - }] - -def get_charts(company, fiscal_year_name, start_date, end_date): - return [ - { - "doctype": "Dashboard Chart", - "name": "Purchase Receipt Trends", - "time_interval": "Monthly", - "chart_name": _("Purchase Receipt Trends"), - "timespan": "Last Year", - "color": "#7b933d", - "value_based_on": "base_net_total", - "filters_json": json.dumps([["Purchase Receipt", "docstatus", "=", 1]]), - "chart_type": "Sum", - "timeseries": 1, - "based_on": "posting_date", - "owner": "Administrator", - "document_type": "Purchase Receipt", - "type": "Bar", - "width": "Half", - "is_public": 1 - }, - { - "doctype": "Dashboard Chart", - "name": "Delivery Trends", - "time_interval": "Monthly", - "chart_name": _("Delivery Trends"), - "timespan": "Last Year", - "color": "#7b933d", - "value_based_on": "base_net_total", - "filters_json": json.dumps([["Delivery Note", "docstatus", "=", 1]]), - "chart_type": "Sum", - "timeseries": 1, - "based_on": "posting_date", - "owner": "Administrator", - "document_type": "Delivery Note", - "type": "Bar", - "width": "Half", - "is_public": 1 - }, - { - "name": "Warehouse wise Stock Value", - "chart_name": _("Warehouse wise Stock Value"), - "chart_type": "Custom", - "doctype": "Dashboard Chart", - "filters_json": json.dumps({}), - "is_custom": 0, - "is_public": 1, - "owner": "Administrator", - "source": "Warehouse wise Stock Value", - "type": "Bar" - }, - { - "name": "Oldest Items", - "chart_name": _("Oldest Items"), - "chart_type": "Report", - "custom_options": json.dumps({ - "colors": ["#5e64ff"] - }), - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "to_date": nowdate(), - "show_warehouse_wise_stock": 0 - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Stock Ageing", - "type": "Bar" - }, - { - "name": "Item Shortage Summary", - "chart_name": _("Item Shortage Summary"), - "chart_type": "Report", - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Item Shortage Report", - "type": "Bar" - } - ] - -def get_number_cards(company, fiscal_year_name, start_date, end_date): - return [ - { - "name": "Total Active Items", - "label": _("Total Active Items"), - "function": "Count", - "doctype": "Number Card", - "document_type": "Item", - "filters_json": json.dumps([["Item", "disabled", "=", 0]]), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "name": "Total Warehouses", - "label": _("Total Warehouses"), - "function": "Count", - "doctype": "Number Card", - "document_type": "Warehouse", - "filters_json": json.dumps([["Warehouse", "disabled", "=", 0]]), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "name": "Total Stock Value", - "label": _("Total Stock Value"), - "function": "Sum", - "aggregate_function_based_on": "stock_value", - "doctype": "Number Card", - "document_type": "Bin", - "filters_json": json.dumps([]), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - } - ] \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index 84d2057f96..ea385c8b2a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -175,7 +175,7 @@ "no_copy": 1, "oldfieldname": "naming_series", "oldfieldtype": "Select", - "options": "MAT-DN-.YYYY.-", + "options": "MAT-DN-.YYYY.-\nMAT-DN-RET-.YYYY.-", "print_hide": 1, "reqd": 1, "set_only_once": 1 @@ -801,6 +801,7 @@ "fieldname": "base_in_words", "fieldtype": "Data", "label": "In Words (Company Currency)", + "length": 240, "oldfieldname": "in_words", "oldfieldtype": "Data", "print_hide": 1, @@ -851,6 +852,7 @@ "fieldname": "in_words", "fieldtype": "Data", "label": "In Words", + "length": 240, "oldfieldname": "in_words_export", "oldfieldtype": "Data", "print_hide": 1, @@ -1253,7 +1255,7 @@ "idx": 146, "is_submittable": 1, "links": [], - "modified": "2020-05-19 17:03:45.880106", + "modified": "2020-08-03 23:18:47.739997", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note", diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 735f35f36f..38e5fe53a7 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -117,7 +117,7 @@ frappe.ui.form.on("Item", { const stock_exists = (frm.doc.__onload && frm.doc.__onload.stock_exists) ? 1 : 0; - ['is_stock_item', 'has_serial_no', 'has_batch_no'].forEach((fieldname) => { + ['is_stock_item', 'has_serial_no', 'has_batch_no', 'has_variants'].forEach((fieldname) => { frm.set_df_property(fieldname, 'read_only', stock_exists); }); diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 963c87a0af..d07b3dc4fe 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -123,6 +123,7 @@ "weightage", "slideshow", "website_image", + "website_image_alt", "thumbnail", "cb72", "website_warehouse", @@ -473,6 +474,7 @@ }, { "default": "0", + "depends_on": "has_batch_no", "fieldname": "retain_sample", "fieldtype": "Check", "label": "Retain Sample" @@ -499,7 +501,7 @@ "oldfieldtype": "Select" }, { - "depends_on": "eval:doc.is_stock_item || doc.is_fixed_asset", + "depends_on": "has_serial_no", "description": "Example: ABCD.#####\nIf series is set and Serial No is not mentioned in transactions, then automatic serial number will be created based on this series. If you always want to explicitly mention Serial Nos for this item. leave this blank.", "fieldname": "serial_no_series", "fieldtype": "Data", @@ -1053,15 +1055,21 @@ "fieldtype": "Data", "label": "Default Manufacturer Part No", "read_only": 1 + }, + { + "fieldname": "website_image_alt", + "fieldtype": "Data", + "label": "Image Description" } ], "has_web_view": 1, "icon": "fa fa-tag", "idx": 2, "image_field": "image", + "index_web_pages_for_search": 1, "links": [], "max_attachments": 1, - "modified": "2020-06-30 12:01:07.534447", + "modified": "2020-08-07 14:24:58.384992", "modified_by": "Administrator", "module": "Stock", "name": "Item", @@ -1123,4 +1131,4 @@ "sort_order": "DESC", "title_field": "item_name", "track_changes": 1 -} \ No newline at end of file +} diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index a75ee67ec4..d22fda85f4 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -13,7 +13,7 @@ from erpnext.controllers.item_variant import (ItemVariantExistsError, from erpnext.setup.doctype.item_group.item_group import (get_parent_item_groups, invalidate_cache_for) from frappe import _, msgprint from frappe.utils import (cint, cstr, flt, formatdate, get_timestamp, getdate, - now_datetime, random_string, strip) + now_datetime, random_string, strip, get_link_to_form, nowtime) from frappe.utils.html_utils import clean_html from frappe.website.doctype.website_slideshow.website_slideshow import \ get_slideshow @@ -111,6 +111,7 @@ class Item(WebsiteGenerator): self.synced_with_hub = 0 self.validate_has_variants() + self.validate_attributes_in_variants() self.validate_stock_exists_for_template_item() self.validate_attributes() self.validate_variant_attributes() @@ -194,7 +195,7 @@ class Item(WebsiteGenerator): if default_warehouse: stock_entry = make_stock_entry(item_code=self.name, target=default_warehouse, qty=self.opening_stock, - rate=self.valuation_rate, company=default.company) + rate=self.valuation_rate, company=default.company, posting_date=getdate(), posting_time=nowtime()) stock_entry.add_comment("Comment", _("Opening Stock")) @@ -343,7 +344,7 @@ class Item(WebsiteGenerator): if variant: context.variant = frappe.get_doc("Item", variant) - for fieldname in ("website_image", "web_long_description", "description", + for fieldname in ("website_image", "website_image_alt", "web_long_description", "description", "website_specifications"): if context.variant.get(fieldname): value = context.variant.get(fieldname) @@ -634,6 +635,9 @@ class Item(WebsiteGenerator): + ": \n" + ", ".join([self.meta.get_label(fld) for fld in field_list])) def after_rename(self, old_name, new_name, merge): + if merge: + self.validate_duplicate_item_in_stock_reconciliation(old_name, new_name) + if self.route: invalidate_cache_for_item(self) clear_cache(self.route) @@ -656,6 +660,27 @@ class Item(WebsiteGenerator): frappe.db.set_value(dt, d.name, "item_wise_tax_detail", json.dumps(item_wise_tax_detail), update_modified=False) + def validate_duplicate_item_in_stock_reconciliation(self, old_name, new_name): + records = frappe.db.sql(""" SELECT parent, COUNT(*) as records + FROM `tabStock Reconciliation Item` + WHERE item_code = %s and docstatus = 1 + GROUP By item_code, warehouse, parent + HAVING records > 1 + """, new_name, as_dict=1) + + if not records: return + document = _("Stock Reconciliation") if len(records) == 1 else _("Stock Reconciliations") + + msg = _("The items {0} and {1} are present in the following {2} :{1} | +{2} | + + {3} +