From 37cd1b8021fc82f982871df8c150f625b936c524 Mon Sep 17 00:00:00 2001 From: michellealva Date: Mon, 20 Jul 2020 13:04:46 +0530 Subject: [PATCH 01/22] fix: Heatmap in Vehicle --- erpnext/hr/doctype/vehicle/vehicle.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/vehicle/vehicle.py b/erpnext/hr/doctype/vehicle/vehicle.py index a75cfa6125..57e2594d1b 100644 --- a/erpnext/hr/doctype/vehicle/vehicle.py +++ b/erpnext/hr/doctype/vehicle/vehicle.py @@ -13,4 +13,11 @@ class Vehicle(Document): if getdate(self.start_date) > getdate(self.end_date): frappe.throw(_("Insurance Start date should be less than Insurance End date")) if getdate(self.carbon_check_date) > getdate(): - frappe.throw(_("Last carbon check date cannot be a future date")) \ No newline at end of file + frappe.throw(_("Last carbon check date cannot be a future date")) + +def get_timeline_data(doctype, name): + '''Return timeline for vehicle log''' + return dict(frappe.db.sql('''select unix_timestamp(date), count(*) + from `tabVehicle Log` where license_plate=%s + and date > date_sub(curdate(), interval 1 year) + group by date''', name)) From 8c7d8ba917ffc623e75e099330cdd09d035a7eec Mon Sep 17 00:00:00 2001 From: michellealva Date: Mon, 20 Jul 2020 13:12:17 +0530 Subject: [PATCH 02/22] fix: remove tab in code --- erpnext/hr/doctype/vehicle/vehicle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/vehicle/vehicle.py b/erpnext/hr/doctype/vehicle/vehicle.py index 57e2594d1b..1df5068268 100644 --- a/erpnext/hr/doctype/vehicle/vehicle.py +++ b/erpnext/hr/doctype/vehicle/vehicle.py @@ -15,7 +15,7 @@ class Vehicle(Document): if getdate(self.carbon_check_date) > getdate(): frappe.throw(_("Last carbon check date cannot be a future date")) -def get_timeline_data(doctype, name): +def get_timeline_data(doctype, name): '''Return timeline for vehicle log''' return dict(frappe.db.sql('''select unix_timestamp(date), count(*) from `tabVehicle Log` where license_plate=%s From 493b581862d0a767016cbcf90ecc0366a1ca1dba Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 21 Jul 2020 12:47:16 +0530 Subject: [PATCH 03/22] fix: Ignore cancelled entries in trial balance opening --- erpnext/accounts/report/trial_balance/trial_balance.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 5a699b6580..3cf08703f8 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -152,6 +152,7 @@ def get_rootwise_opening_balances(filters, report_type): {additional_conditions} and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes') and account in (select name from `tabAccount` where report_type=%(report_type)s) + and is_cancelled = 0 group by account""".format(additional_conditions=additional_conditions), query_filters , as_dict=True) opening = frappe._dict() From a5b83e85c3290c95423458277092948bf502a28f Mon Sep 17 00:00:00 2001 From: Abhishek Balam Date: Tue, 21 Jul 2020 12:54:59 +0530 Subject: [PATCH 04/22] feat: dashboard for timesheet (#22750) --- .../doctype/timesheet/timesheet_dashboard.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 erpnext/projects/doctype/timesheet/timesheet_dashboard.py diff --git a/erpnext/projects/doctype/timesheet/timesheet_dashboard.py b/erpnext/projects/doctype/timesheet/timesheet_dashboard.py new file mode 100644 index 0000000000..acff97a226 --- /dev/null +++ b/erpnext/projects/doctype/timesheet/timesheet_dashboard.py @@ -0,0 +1,13 @@ +from __future__ import unicode_literals +from frappe import _ + +def get_data(): + return { + 'fieldname': 'time_sheet', + 'transactions': [ + { + 'label': _('References'), + 'items': ['Sales Invoice', 'Salary Slip'] + } + ] + } \ No newline at end of file From 09b8caf866b3d68e3dc832955464f91a98ae41eb Mon Sep 17 00:00:00 2001 From: Diksha Jadhav Date: Tue, 21 Jul 2020 17:35:10 +0530 Subject: [PATCH 05/22] fix(report): fix alignment in script report that extends financial_statements.js --- erpnext/public/js/financial_statements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js index d89d4712e6..459c01b269 100644 --- a/erpnext/public/js/financial_statements.js +++ b/erpnext/public/js/financial_statements.js @@ -3,7 +3,7 @@ frappe.provide("erpnext.financial_statements"); erpnext.financial_statements = { "filters": get_filters(), "formatter": function(value, row, column, data, default_formatter) { - if (column.fieldname=="account") { + if (data && column.fieldname=="account") { value = data.account_name || value; column.link_onclick = @@ -13,7 +13,7 @@ erpnext.financial_statements = { value = default_formatter(value, row, column, data); - if (!data.parent_account) { + if (data && !data.parent_account) { value = $(`${value}`); var $value = $(value).css("font-weight", "bold"); From 66d4b42df0f9807ff42f508526289ca30e1c0204 Mon Sep 17 00:00:00 2001 From: Afshan <33727827+AfshanKhan@users.noreply.github.com> Date: Tue, 21 Jul 2020 19:59:30 +0530 Subject: [PATCH 06/22] fix: update set query for warehouse after changing the company (#22632) * fix: update set query for warehouse after changing the company * fix: changed set_query to get_query * fix: variable filter doesn't get updated once set on load hence removed Co-authored-by: Marica --- .../doctype/material_request/material_request.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 60f5ff3629..3c4e35349e 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -49,17 +49,21 @@ frappe.ui.form.on('Material Request', { // set schedule_date set_schedule_date(frm); - let filters = {'company': frm.doc.company} - - frm.set_query("warehouse", "items", function() { + frm.set_query("warehouse", "items", function(doc) { return { - filters: filters + filters: {'company': doc.company} }; }); - frm.set_query("set_warehouse", function(){ + frm.set_query("set_warehouse", function(doc){ return { - filters: filters + filters: {'company': doc.company} + }; + }); + + frm.set_query("set_from_warehouse", function(doc){ + return { + filters: {'company': doc.company} }; }); }, From 871889220b31994d06bac90f87b33354b2066acf Mon Sep 17 00:00:00 2001 From: Afshan <33727827+AfshanKhan@users.noreply.github.com> Date: Tue, 21 Jul 2020 20:39:00 +0530 Subject: [PATCH 07/22] =?UTF-8?q?style:=20moved=20parent=20warehouse=20to?= =?UTF-8?q?=20top=20section=20also=20added=20a=20section=20bre=E2=80=A6=20?= =?UTF-8?q?(#22708)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * style: moved parent warehouse to top section also added a section break for better look * style: changes display depends on for HTML field Co-authored-by: Marica --- erpnext/stock/doctype/warehouse/warehouse.json | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/warehouse/warehouse.json b/erpnext/stock/doctype/warehouse/warehouse.json index 5d534af157..3b49c4ca52 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.json +++ b/erpnext/stock/doctype/warehouse/warehouse.json @@ -10,12 +10,14 @@ "field_order": [ "warehouse_detail", "warehouse_name", + "column_break_3", + "warehouse_type", + "parent_warehouse", "is_group", - "company", - "disabled", "column_break_4", "account", - "warehouse_type", + "company", + "disabled", "address_and_contact", "address_html", "column_break_10", @@ -31,7 +33,6 @@ "state", "pin", "tree_details", - "parent_warehouse", "lft", "rgt", "old_parent" @@ -91,6 +92,7 @@ "options": "Account" }, { + "depends_on": "eval:!doc.__islocal", "fieldname": "address_and_contact", "fieldtype": "Section Break", "label": "Address and Contact" @@ -224,13 +226,17 @@ "fieldtype": "Link", "label": "Warehouse Type", "options": "Warehouse Type" + }, + { + "fieldname": "column_break_3", + "fieldtype": "Section Break" } ], "icon": "fa fa-building", "idx": 1, "is_tree": 1, "links": [], - "modified": "2020-03-18 18:11:53.282358", + "modified": "2020-07-16 15:43:50.653256", "modified_by": "Administrator", "module": "Stock", "name": "Warehouse", From de417d2774fdca03dee38dcb67ef14a8a5cb58f9 Mon Sep 17 00:00:00 2001 From: Anupam K Date: Wed, 22 Jul 2020 00:58:13 +0530 Subject: [PATCH 08/22] feat: Provision to make RFQ against Opportunity --- erpnext/crm/doctype/opportunity/opportunity.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index f1b8171349..28aedde122 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -76,6 +76,11 @@ frappe.ui.form.on("Opportunity", { function() { frm.trigger("make_supplier_quotation") }, __('Create')); + + frm.add_custom_button(__('Request For Quotation'), + function() { + frm.trigger("make_request_for_quotation") + }, __('Create')); } frm.add_custom_button(__('Quotation'), @@ -126,6 +131,13 @@ frappe.ui.form.on("Opportunity", { }) }, + make_request_for_quotation: function(frm) { + frappe.model.open_mapped_doc({ + method: "erpnext.crm.doctype.opportunity.opportunity.make_request_for_quotation", + frm: cur_frm + }) + }, + toggle_mandatory: function(frm) { frm.toggle_reqd("items", frm.doc.with_items ? 1:0); } From 8d28eacb0978667e3317a74f59f20e87ab2d5914 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 22 Jul 2020 15:57:33 +0530 Subject: [PATCH 09/22] chore: Exported Healthcare Module Dashboard (#22775) --- .../clinical_procedures.json | 26 ++ .../clinical_procedures_status.json | 26 ++ .../department_wise_patient_appointments.json | 25 ++ .../dashboard_chart/diagnoses/diagnoses.json | 25 ++ .../in_patient_status/in_patient_status.json | 26 ++ .../dashboard_chart/lab_tests/lab_tests.json | 26 ++ .../patient_appointments.json | 27 ++ .../dashboard_chart/symptoms/symptoms.json | 26 ++ erpnext/healthcare/dashboard_fixtures.py | 245 ------------------ .../healthcare/healthcare.json | 62 +++++ .../appointments_to_bill.json | 21 ++ .../open_appointments/open_appointments.json | 21 ++ .../total_patients/total_patients.json | 20 ++ .../total_patients_admitted.json | 20 ++ 14 files changed, 351 insertions(+), 245 deletions(-) create mode 100644 erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json create mode 100644 erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json create mode 100644 erpnext/healthcare/dashboard_chart/department_wise_patient_appointments/department_wise_patient_appointments.json create mode 100644 erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json create mode 100644 erpnext/healthcare/dashboard_chart/in_patient_status/in_patient_status.json create mode 100644 erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json create mode 100644 erpnext/healthcare/dashboard_chart/patient_appointments/patient_appointments.json create mode 100644 erpnext/healthcare/dashboard_chart/symptoms/symptoms.json delete mode 100644 erpnext/healthcare/dashboard_fixtures.py create mode 100644 erpnext/healthcare/healthcare_dashboard/healthcare/healthcare.json create mode 100644 erpnext/healthcare/number_card/appointments_to_bill/appointments_to_bill.json create mode 100644 erpnext/healthcare/number_card/open_appointments/open_appointments.json create mode 100644 erpnext/healthcare/number_card/total_patients/total_patients.json create mode 100644 erpnext/healthcare/number_card/total_patients_admitted/total_patients_admitted.json diff --git a/erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json b/erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json new file mode 100644 index 0000000000..a59f149ee5 --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Clinical Procedures", + "chart_type": "Group By", + "creation": "2020-07-14 18:17:54.601236", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Clinical Procedure", + "dynamic_filters_json": "[[\"Clinical Procedure\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Clinical Procedure\",\"docstatus\",\"=\",\"1\",false]]", + "group_by_based_on": "procedure_template", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 13:22:47.008622", + "modified": "2020-07-22 13:36:48.114479", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Clinical Procedures", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Percentage", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json b/erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json new file mode 100644 index 0000000000..6d560f74bf --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Clinical Procedure Status", + "chart_type": "Group By", + "creation": "2020-07-14 18:17:54.654325", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Clinical Procedure", + "dynamic_filters_json": "[[\"Clinical Procedure\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Clinical Procedure\",\"docstatus\",\"=\",\"1\",false]]", + "group_by_based_on": "status", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 13:22:46.691764", + "modified": "2020-07-22 13:40:17.215775", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Clinical Procedures Status", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Pie", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/department_wise_patient_appointments/department_wise_patient_appointments.json b/erpnext/healthcare/dashboard_chart/department_wise_patient_appointments/department_wise_patient_appointments.json new file mode 100644 index 0000000000..b24bb345ac --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/department_wise_patient_appointments/department_wise_patient_appointments.json @@ -0,0 +1,25 @@ +{ + "chart_name": "Department wise Patient Appointments", + "chart_type": "Custom", + "creation": "2020-07-17 11:25:37.190130", + "custom_options": "{\"colors\": [\"#7CD5FA\", \"#5F62F6\", \"#7544E2\", \"#EE5555\"], \"barOptions\": {\"stacked\": 1}, \"height\": 300}", + "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, + "last_synced_on": "2020-07-22 15:32:05.827566", + "modified": "2020-07-22 15:35:12.798035", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Department wise Patient Appointments", + "number_of_groups": 0, + "owner": "Administrator", + "source": "Department wise Patient Appointments", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json b/erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json new file mode 100644 index 0000000000..0195aac8b7 --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json @@ -0,0 +1,25 @@ +{ + "chart_name": "Diagnoses", + "chart_type": "Group By", + "creation": "2020-07-14 18:17:54.705698", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Patient Encounter Diagnosis", + "filters_json": "[]", + "group_by_based_on": "diagnosis", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 13:22:47.895521", + "modified": "2020-07-22 13:43:32.369481", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Diagnoses", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Percentage", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/in_patient_status/in_patient_status.json b/erpnext/healthcare/dashboard_chart/in_patient_status/in_patient_status.json new file mode 100644 index 0000000000..77b47c9e15 --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/in_patient_status/in_patient_status.json @@ -0,0 +1,26 @@ +{ + "chart_name": "In-Patient Status", + "chart_type": "Group By", + "creation": "2020-07-14 18:17:54.629199", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Inpatient Record", + "dynamic_filters_json": "[[\"Inpatient Record\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[]", + "group_by_based_on": "status", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 13:22:46.792131", + "modified": "2020-07-22 13:33:16.008150", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "In-Patient Status", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json b/erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json new file mode 100644 index 0000000000..052483533e --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Lab Tests", + "chart_type": "Group By", + "creation": "2020-07-14 18:17:54.574903", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Lab Test", + "dynamic_filters_json": "[[\"Lab Test\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Lab Test\",\"docstatus\",\"=\",\"1\",false]]", + "group_by_based_on": "template", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 13:22:47.344055", + "modified": "2020-07-22 13:37:34.490129", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Lab Tests", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Percentage", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/patient_appointments/patient_appointments.json b/erpnext/healthcare/dashboard_chart/patient_appointments/patient_appointments.json new file mode 100644 index 0000000000..19bfb7256f --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/patient_appointments/patient_appointments.json @@ -0,0 +1,27 @@ +{ + "based_on": "appointment_datetime", + "chart_name": "Patient Appointments", + "chart_type": "Count", + "creation": "2020-07-14 18:17:54.525082", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Patient Appointment", + "dynamic_filters_json": "[[\"Patient Appointment\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Patient Appointment\",\"status\",\"!=\",\"Cancelled\",false]]", + "idx": 0, + "is_public": 0, + "is_standard": 1, + "last_synced_on": "2020-07-22 13:22:46.830491", + "modified": "2020-07-22 13:38:02.254190", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Patient Appointments", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Daily", + "timeseries": 1, + "timespan": "Last Month", + "type": "Line", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/symptoms/symptoms.json b/erpnext/healthcare/dashboard_chart/symptoms/symptoms.json new file mode 100644 index 0000000000..8fc86a1c59 --- /dev/null +++ b/erpnext/healthcare/dashboard_chart/symptoms/symptoms.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Symptoms", + "chart_type": "Group By", + "creation": "2020-07-14 18:17:54.680852", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Patient Encounter Symptom", + "dynamic_filters_json": "", + "filters_json": "[]", + "group_by_based_on": "complaint", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 13:22:47.296748", + "modified": "2020-07-22 13:40:59.655129", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Symptoms", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Percentage", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_fixtures.py b/erpnext/healthcare/dashboard_fixtures.py deleted file mode 100644 index 94668a16d9..0000000000 --- a/erpnext/healthcare/dashboard_fixtures.py +++ /dev/null @@ -1,245 +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 _ - -def get_data(): - return frappe._dict({ - "dashboards": get_dashboards(), - "charts": get_charts(), - "number_cards": get_number_cards(), - }) - -def get_company(): - company = frappe.defaults.get_defaults().company - if company: - return company - else: - company = frappe.get_list("Company", limit=1) - if company: - return company[0].name - return None - -def get_dashboards(): - return [{ - "name": "Healthcare", - "dashboard_name": "Healthcare", - "charts": [ - { "chart": "Patient Appointments", "width": "Full"}, - { "chart": "In-Patient Status", "width": "Half"}, - { "chart": "Clinical Procedures Status", "width": "Half"}, - { "chart": "Lab Tests", "width": "Half"}, - { "chart": "Clinical Procedures", "width": "Half"}, - { "chart": "Symptoms", "width": "Half"}, - { "chart": "Diagnoses", "width": "Half"}, - { "chart": "Department wise Patient Appointments", "width": "Full"} - ], - "cards": [ - { "card": "Total Patients" }, - { "card": "Total Patient Admitted" }, - { "card": "Open Appointments" }, - { "card": "Appointments to Bill" } - ] - }] - -def get_charts(): - company = get_company() - return [ - { - "doctype": "Dashboard Chart", - "time_interval": "Daily", - "name": "Patient Appointments", - "chart_name": _("Patient Appointments"), - "timespan": "Last Month", - "filters_json": json.dumps([ - ["Patient Appointment", "company", "=", company, False], - ["Patient Appointment", "status", "!=", "Cancelled"] - ]), - "chart_type": "Count", - "timeseries": 1, - "based_on": "appointment_datetime", - "owner": "Administrator", - "document_type": "Patient Appointment", - "type": "Line", - "width": "Half" - }, - { - "doctype": "Dashboard Chart", - "name": "Department wise Patient Appointments", - "chart_name": _("Department wise Patient Appointments"), - "chart_type": "Custom", - "source": "Department wise Patient Appointments", - "filters_json": json.dumps([]), - 'is_public': 1, - "owner": "Administrator", - "type": "Bar", - "width": "Full", - "custom_options": json.dumps({ - "colors": ["#7CD5FA", "#5F62F6", "#7544E2", "#EE5555"], - "barOptions":{ - "stacked":1 - }, - "height": 300 - }) - }, - { - "doctype": "Dashboard Chart", - "name": "Lab Tests", - "chart_name": _("Lab Tests"), - "chart_type": "Group By", - "document_type": "Lab Test", - "group_by_type": "Count", - "group_by_based_on": "template", - "filters_json": json.dumps([ - ["Lab Test", "company", "=", company, False], - ["Lab Test", "docstatus", "=", 1] - ]), - 'is_public': 1, - "owner": "Administrator", - "type": "Percentage", - "width": "Half", - }, - { - "doctype": "Dashboard Chart", - "name": "Clinical Procedures", - "chart_name": _("Clinical Procedures"), - "chart_type": "Group By", - "document_type": "Clinical Procedure", - "group_by_type": "Count", - "group_by_based_on": "procedure_template", - "filters_json": json.dumps([ - ["Clinical Procedure", "company", "=", company, False], - ["Clinical Procedure", "docstatus", "=", 1] - ]), - 'is_public': 1, - "owner": "Administrator", - "type": "Percentage", - "width": "Half", - }, - { - "doctype": "Dashboard Chart", - "name": "In-Patient Status", - "chart_name": _("In-Patient Status"), - "chart_type": "Group By", - "document_type": "Inpatient Record", - "group_by_type": "Count", - "group_by_based_on": "status", - "filters_json": json.dumps([ - ["Inpatient Record", "company", "=", company, False] - ]), - 'is_public': 1, - "owner": "Administrator", - "type": "Bar", - "width": "Half", - }, - { - "doctype": "Dashboard Chart", - "name": "Clinical Procedures Status", - "chart_name": _("Clinical Procedure Status"), - "chart_type": "Group By", - "document_type": "Clinical Procedure", - "group_by_type": "Count", - "group_by_based_on": "status", - "filters_json": json.dumps([ - ["Clinical Procedure", "company", "=", company, False], - ["Clinical Procedure", "docstatus", "=", 1] - ]), - 'is_public': 1, - "owner": "Administrator", - "type": "Pie", - "width": "Half", - }, - { - "doctype": "Dashboard Chart", - "name": "Symptoms", - "chart_name": _("Symptoms"), - "chart_type": "Group By", - "document_type": "Patient Encounter Symptom", - "group_by_type": "Count", - "group_by_based_on": "complaint", - "filters_json": json.dumps([]), - 'is_public': 1, - "owner": "Administrator", - "type": "Percentage", - "width": "Half", - }, - { - "doctype": "Dashboard Chart", - "name": "Diagnoses", - "chart_name": _("Diagnoses"), - "chart_type": "Group By", - "document_type": "Patient Encounter Diagnosis", - "group_by_type": "Count", - "group_by_based_on": "diagnosis", - "filters_json": json.dumps([]), - 'is_public': 1, - "owner": "Administrator", - "type": "Percentage", - "width": "Half", - } - ] - -def get_number_cards(): - company = get_company() - return [ - { - "name": "Total Patients", - "label": _("Total Patients"), - "function": "Count", - "doctype": "Number Card", - "document_type": "Patient", - "filters_json": json.dumps( - [["Patient","status","=","Active",False]] - ), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "name": "Total Patients Admitted", - "label": _("Total Patients Admitted"), - "function": "Count", - "doctype": "Number Card", - "document_type": "Patient", - "filters_json": json.dumps( - [["Patient","inpatient_status","=","Admitted",False]] - ), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "name": "Open Appointments", - "label": _("Open Appointments"), - "function": "Count", - "doctype": "Number Card", - "document_type": "Patient Appointment", - "filters_json": json.dumps( - [["Patient Appointment","company","=",company,False], - ["Patient Appointment","status","=","Open",False]] - ), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "name": "Appointments to Bill", - "label": _("Appointments To Bill"), - "function": "Count", - "doctype": "Number Card", - "document_type": "Patient Appointment", - "filters_json": json.dumps( - [["Patient Appointment","company","=",company,False], - ["Patient Appointment","invoiced","=",0,False]] - ), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - } - ] \ No newline at end of file diff --git a/erpnext/healthcare/healthcare_dashboard/healthcare/healthcare.json b/erpnext/healthcare/healthcare_dashboard/healthcare/healthcare.json new file mode 100644 index 0000000000..2fea6682ed --- /dev/null +++ b/erpnext/healthcare/healthcare_dashboard/healthcare/healthcare.json @@ -0,0 +1,62 @@ +{ + "cards": [ + { + "card": "Total Patients" + }, + { + "card": "Total Patients Admitted" + }, + { + "card": "Open Appointments" + }, + { + "card": "Appointments to Bill" + } + ], + "charts": [ + { + "chart": "Patient Appointments", + "width": "Full" + }, + { + "chart": "In-Patient Status", + "width": "Half" + }, + { + "chart": "Clinical Procedures Status", + "width": "Half" + }, + { + "chart": "Lab Tests", + "width": "Half" + }, + { + "chart": "Clinical Procedures", + "width": "Half" + }, + { + "chart": "Symptoms", + "width": "Half" + }, + { + "chart": "Diagnoses", + "width": "Half" + }, + { + "chart": "Department wise Patient Appointments", + "width": "Full" + } + ], + "creation": "2020-07-14 18:17:54.823311", + "dashboard_name": "Healthcare", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 0, + "is_standard": 1, + "modified": "2020-07-22 15:36:34.220387", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Healthcare", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/healthcare/number_card/appointments_to_bill/appointments_to_bill.json b/erpnext/healthcare/number_card/appointments_to_bill/appointments_to_bill.json new file mode 100644 index 0000000000..3e4d4e27df --- /dev/null +++ b/erpnext/healthcare/number_card/appointments_to_bill/appointments_to_bill.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-14 18:17:54.792773", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Patient Appointment", + "dynamic_filters_json": "[[\"Patient Appointment\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Patient Appointment\",\"invoiced\",\"=\",0,false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Appointments To Bill", + "modified": "2020-07-22 13:27:58.038577", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Appointments to Bill", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/healthcare/number_card/open_appointments/open_appointments.json b/erpnext/healthcare/number_card/open_appointments/open_appointments.json new file mode 100644 index 0000000000..8d121cc58a --- /dev/null +++ b/erpnext/healthcare/number_card/open_appointments/open_appointments.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-14 18:17:54.771092", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Patient Appointment", + "dynamic_filters_json": "[[\"Patient Appointment\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Patient Appointment\",\"status\",\"=\",\"Open\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Open Appointments", + "modified": "2020-07-22 13:27:09.542122", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Open Appointments", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/healthcare/number_card/total_patients/total_patients.json b/erpnext/healthcare/number_card/total_patients/total_patients.json new file mode 100644 index 0000000000..75441a6842 --- /dev/null +++ b/erpnext/healthcare/number_card/total_patients/total_patients.json @@ -0,0 +1,20 @@ +{ + "creation": "2020-07-14 18:17:54.727946", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Patient", + "filters_json": "[[\"Patient\",\"status\",\"=\",\"Active\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Patients", + "modified": "2020-07-22 13:26:02.643534", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Total Patients", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/healthcare/number_card/total_patients_admitted/total_patients_admitted.json b/erpnext/healthcare/number_card/total_patients_admitted/total_patients_admitted.json new file mode 100644 index 0000000000..69a967df93 --- /dev/null +++ b/erpnext/healthcare/number_card/total_patients_admitted/total_patients_admitted.json @@ -0,0 +1,20 @@ +{ + "creation": "2020-07-14 18:17:54.749754", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Patient", + "filters_json": "[[\"Patient\",\"inpatient_status\",\"=\",\"Admitted\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Patients Admitted", + "modified": "2020-07-22 13:26:20.027788", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Total Patients Admitted", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file From 1fddc6d126a6b0233408b87f8f0d73ae79336813 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 22 Jul 2020 16:11:06 +0530 Subject: [PATCH 10/22] chore: Exported Accounts Module Dashboard (#22769) * chore: Exported Accounts Module Dashboards * chore: deleted dashboard fixtures for Accounts module --- .../accounts_dashboard/accounts/accounts.json | 58 ++++ .../accounts_payable_ageing.json | 23 ++ .../accounts_receivable_ageing.json | 23 ++ .../bank_balance/bank_balance.json | 26 ++ .../budget_variance/budget_variance.json | 23 ++ .../incoming_bills_(purchase_invoice).json | 29 ++ .../outgoing_bills_(sales_invoice).json | 28 ++ .../profit_and_loss/profit_and_loss.json | 23 ++ erpnext/accounts/dashboard_fixtures.py | 284 ------------------ .../total_incoming_bills.json | 21 ++ .../total_incoming_payment.json | 21 ++ .../total_outgoing_bills.json | 21 ++ .../total_outgoing_payment.json | 21 ++ 13 files changed, 317 insertions(+), 284 deletions(-) create mode 100644 erpnext/accounts/accounts_dashboard/accounts/accounts.json create mode 100644 erpnext/accounts/dashboard_chart/accounts_payable_ageing/accounts_payable_ageing.json create mode 100644 erpnext/accounts/dashboard_chart/accounts_receivable_ageing/accounts_receivable_ageing.json create mode 100644 erpnext/accounts/dashboard_chart/bank_balance/bank_balance.json create mode 100644 erpnext/accounts/dashboard_chart/budget_variance/budget_variance.json create mode 100644 erpnext/accounts/dashboard_chart/incoming_bills_(purchase_invoice)/incoming_bills_(purchase_invoice).json create mode 100644 erpnext/accounts/dashboard_chart/outgoing_bills_(sales_invoice)/outgoing_bills_(sales_invoice).json create mode 100644 erpnext/accounts/dashboard_chart/profit_and_loss/profit_and_loss.json delete mode 100644 erpnext/accounts/dashboard_fixtures.py create mode 100644 erpnext/accounts/number_card/total_incoming_bills/total_incoming_bills.json create mode 100644 erpnext/accounts/number_card/total_incoming_payment/total_incoming_payment.json create mode 100644 erpnext/accounts/number_card/total_outgoing_bills/total_outgoing_bills.json create mode 100644 erpnext/accounts/number_card/total_outgoing_payment/total_outgoing_payment.json 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/number_card/total_incoming_bills/total_incoming_bills.json b/erpnext/accounts/number_card/total_incoming_bills/total_incoming_bills.json new file mode 100644 index 0000000000..283e187b54 --- /dev/null +++ b/erpnext/accounts/number_card/total_incoming_bills/total_incoming_bills.json @@ -0,0 +1,21 @@ +{ + "aggregate_function_based_on": "base_net_total", + "creation": "2020-07-17 11:25:34.748329", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Purchase Invoice", + "filters_json": "[[\"Purchase Invoice\",\"docstatus\",\"=\",\"1\",false],[\"Purchase Invoice\",\"posting_date\",\"Timespan\",\"this year\",false]]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Incoming Bills", + "modified": "2020-07-22 13:06:46.045344", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Total Incoming Bills", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/accounts/number_card/total_incoming_payment/total_incoming_payment.json b/erpnext/accounts/number_card/total_incoming_payment/total_incoming_payment.json new file mode 100644 index 0000000000..bc23c15b6a --- /dev/null +++ b/erpnext/accounts/number_card/total_incoming_payment/total_incoming_payment.json @@ -0,0 +1,21 @@ +{ + "aggregate_function_based_on": "base_received_amount", + "creation": "2020-07-17 11:25:34.673195", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Payment Entry", + "filters_json": "[[\"Payment Entry\",\"docstatus\",\"=\",\"1\",false],[\"Payment Entry\",\"posting_date\",\"Timespan\",\"this year\",false],[\"Payment Entry\",\"payment_type\",\"=\",\"Receive\",false]]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Incoming Payment", + "modified": "2020-07-22 13:06:20.237689", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Total Incoming Payment", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/accounts/number_card/total_outgoing_bills/total_outgoing_bills.json b/erpnext/accounts/number_card/total_outgoing_bills/total_outgoing_bills.json new file mode 100644 index 0000000000..fe91618210 --- /dev/null +++ b/erpnext/accounts/number_card/total_outgoing_bills/total_outgoing_bills.json @@ -0,0 +1,21 @@ +{ + "aggregate_function_based_on": "base_net_total", + "creation": "2020-07-17 11:25:34.725416", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Sales Invoice", + "filters_json": "[[\"Sales Invoice\",\"docstatus\",\"=\",\"1\",false],[\"Sales Invoice\",\"posting_date\",\"Timespan\",\"this year\",false]]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Outgoing Bills", + "modified": "2020-07-22 13:07:19.633101", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Total Outgoing Bills", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/accounts/number_card/total_outgoing_payment/total_outgoing_payment.json b/erpnext/accounts/number_card/total_outgoing_payment/total_outgoing_payment.json new file mode 100644 index 0000000000..d27be88350 --- /dev/null +++ b/erpnext/accounts/number_card/total_outgoing_payment/total_outgoing_payment.json @@ -0,0 +1,21 @@ +{ + "aggregate_function_based_on": "base_paid_amount", + "creation": "2020-07-17 11:25:34.700137", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Payment Entry", + "filters_json": "[[\"Payment Entry\",\"docstatus\",\"=\",\"1\",false],[\"Payment Entry\",\"posting_date\",\"Timespan\",\"this year\",false],[\"Payment Entry\",\"payment_type\",\"=\",\"Pay\",false]]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Outgoing Payment", + "modified": "2020-07-22 12:49:34.942896", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Total Outgoing Payment", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file From f50312b6d249ae68b743d75b060e852e732267d7 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 22 Jul 2020 16:17:11 +0530 Subject: [PATCH 11/22] fix: button sizing (#22777) --- erpnext/templates/includes/footer/footer_extension.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/templates/includes/footer/footer_extension.html b/erpnext/templates/includes/footer/footer_extension.html index 8cf3081dec..6171b61e38 100644 --- a/erpnext/templates/includes/footer/footer_extension.html +++ b/erpnext/templates/includes/footer/footer_extension.html @@ -6,7 +6,7 @@ aria-label="{{ _('Your email address...') }}" aria-describedby="footer-subscribe-button">
-
From 53646cb360f239948dd80cfd9ffe5a64926dda05 Mon Sep 17 00:00:00 2001 From: Marica Date: Wed, 22 Jul 2020 16:17:40 +0530 Subject: [PATCH 12/22] chore: Export Stock Dashboard (#22768) --- .../delivery_trends/delivery_trends.json | 27 +++ .../item_shortage_summary.json | 23 +++ .../oldest_items/oldest_items.json | 24 +++ .../purchase_receipt_trends.json | 27 +++ .../warehouse_wise_stock_value.json | 22 +++ erpnext/stock/dashboard_fixtures.py | 170 ------------------ .../total_active_items.json | 20 +++ .../total_stock_value/total_stock_value.json | 21 +++ .../total_warehouses/total_warehouses.json | 20 +++ .../stock/stock_dashboard/stock/stock.json | 47 +++++ 10 files changed, 231 insertions(+), 170 deletions(-) create mode 100644 erpnext/stock/dashboard_chart/delivery_trends/delivery_trends.json create mode 100644 erpnext/stock/dashboard_chart/item_shortage_summary/item_shortage_summary.json create mode 100644 erpnext/stock/dashboard_chart/oldest_items/oldest_items.json create mode 100644 erpnext/stock/dashboard_chart/purchase_receipt_trends/purchase_receipt_trends.json create mode 100644 erpnext/stock/dashboard_chart/warehouse_wise_stock_value/warehouse_wise_stock_value.json delete mode 100644 erpnext/stock/dashboard_fixtures.py create mode 100644 erpnext/stock/number_card/total_active_items/total_active_items.json create mode 100644 erpnext/stock/number_card/total_stock_value/total_stock_value.json create mode 100644 erpnext/stock/number_card/total_warehouses/total_warehouses.json create mode 100644 erpnext/stock/stock_dashboard/stock/stock.json 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..6da3b28baf --- /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": "{\"show_warehouse_wise_stock\":0}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 13:04:36.271198", + "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/number_card/total_active_items/total_active_items.json b/erpnext/stock/number_card/total_active_items/total_active_items.json new file mode 100644 index 0000000000..f6863b96d7 --- /dev/null +++ b/erpnext/stock/number_card/total_active_items/total_active_items.json @@ -0,0 +1,20 @@ +{ + "creation": "2020-07-20 21:01:04.422436", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Item", + "filters_json": "[[\"Item\",\"disabled\",\"=\",0]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Active Items", + "modified": "2020-07-22 13:08:30.430677", + "modified_by": "Administrator", + "module": "Stock", + "name": "Total Active Items", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/stock/number_card/total_stock_value/total_stock_value.json b/erpnext/stock/number_card/total_stock_value/total_stock_value.json new file mode 100644 index 0000000000..8e480a6b3e --- /dev/null +++ b/erpnext/stock/number_card/total_stock_value/total_stock_value.json @@ -0,0 +1,21 @@ +{ + "aggregate_function_based_on": "stock_value", + "creation": "2020-07-20 21:01:04.495481", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Bin", + "filters_json": "[]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Stock Value", + "modified": "2020-07-22 13:08:48.412001", + "modified_by": "Administrator", + "module": "Stock", + "name": "Total Stock Value", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/stock/number_card/total_warehouses/total_warehouses.json b/erpnext/stock/number_card/total_warehouses/total_warehouses.json new file mode 100644 index 0000000000..ab0836a3af --- /dev/null +++ b/erpnext/stock/number_card/total_warehouses/total_warehouses.json @@ -0,0 +1,20 @@ +{ + "creation": "2020-07-20 21:01:04.457598", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Warehouse", + "filters_json": "[[\"Warehouse\",\"disabled\",\"=\",0]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Total Warehouses", + "modified": "2020-07-22 13:08:40.258927", + "modified_by": "Administrator", + "module": "Stock", + "name": "Total Warehouses", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/stock/stock_dashboard/stock/stock.json b/erpnext/stock/stock_dashboard/stock/stock.json new file mode 100644 index 0000000000..dee7fed6c2 --- /dev/null +++ b/erpnext/stock/stock_dashboard/stock/stock.json @@ -0,0 +1,47 @@ +{ + "cards": [ + { + "card": "Total Active Items" + }, + { + "card": "Total Warehouses" + }, + { + "card": "Total Stock Value" + } + ], + "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" + } + ], + "creation": "2020-07-20 21:01:04.549136", + "dashboard_name": "Stock", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 1, + "is_standard": 1, + "modified": "2020-07-22 13:09:33.096694", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock", + "owner": "Administrator" +} \ No newline at end of file From 514366654ecae413b7d72afabef3bff58cea3218 Mon Sep 17 00:00:00 2001 From: Marica Date: Wed, 22 Jul 2020 16:40:24 +0530 Subject: [PATCH 13/22] fix: Serial No Rename does not affect Stock Ledger Entry (#22746) * Revert "fix: Remove rename related code from Serial No (#22627)" This reverts commit 1ec2d962dbcc7ccee30e0d0a35727aa890910203. * fix: Rename fails on Stock Ledger Entry * fix: Allow Rename in Serial No --- erpnext/stock/doctype/serial_no/serial_no.json | 3 ++- erpnext/stock/doctype/serial_no/serial_no.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/serial_no/serial_no.json b/erpnext/stock/doctype/serial_no/serial_no.json index 2be14c8006..3acf3a9316 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.json +++ b/erpnext/stock/doctype/serial_no/serial_no.json @@ -1,6 +1,7 @@ { "actions": [], "allow_import": 1, + "allow_rename": 1, "autoname": "field:serial_no", "creation": "2013-05-16 10:59:15", "description": "Distinct unit of an Item", @@ -426,7 +427,7 @@ "icon": "fa fa-barcode", "idx": 1, "links": [], - "modified": "2020-06-25 15:53:50.900855", + "modified": "2020-07-20 20:50:16.660433", "modified_by": "Administrator", "module": "Stock", "name": "Serial No", diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index 90f0f5881d..153ce2fb67 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -190,6 +190,23 @@ class SerialNo(StockController): if sle_exists: frappe.throw(_("Cannot delete Serial No {0}, as it is used in stock transactions").format(self.name)) + def before_rename(self, old, new, merge=False): + if merge: + frappe.throw(_("Sorry, Serial Nos cannot be merged")) + + def after_rename(self, old, new, merge=False): + """rename serial_no text fields""" + for dt in frappe.db.sql("""select parent from tabDocField + where fieldname='serial_no' and fieldtype in ('Text', 'Small Text', 'Long Text')"""): + + for item in frappe.db.sql("""select name, serial_no from `tab%s` + where serial_no like %s""" % (dt[0], frappe.db.escape('%' + old + '%'))): + + serial_nos = map(lambda i: new if i.upper()==old.upper() else i, item[1].split('\n')) + frappe.db.sql("""update `tab%s` set serial_no = %s + where name=%s""" % (dt[0], '%s', '%s'), + ('\n'.join(list(serial_nos)), item[0])) + def update_serial_no_reference(self, serial_no=None): last_sle = self.get_last_sle(serial_no) self.set_purchase_details(last_sle.get("purchase_sle")) From 3d3c922d7fdd7a5e91b13e9ba87f74402ea9499d Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Wed, 22 Jul 2020 16:42:31 +0530 Subject: [PATCH 14/22] fix(patch): handle duplicate entry error while inserting account (#22745) --- .../v12_0/move_item_tax_to_item_tax_template.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/patches/v12_0/move_item_tax_to_item_tax_template.py b/erpnext/patches/v12_0/move_item_tax_to_item_tax_template.py index 8889056e2d..06331d7ff7 100644 --- a/erpnext/patches/v12_0/move_item_tax_to_item_tax_template.py +++ b/erpnext/patches/v12_0/move_item_tax_to_item_tax_template.py @@ -100,8 +100,10 @@ def get_item_tax_template(item_tax_templates, item_tax_map, item_code, parenttyp tax_type = None else: company = get_company(parts[-1], parenttype, parent) - parent_account = frappe.db.get_value("Account", - filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company}, fieldname="parent_account") + parent_account = frappe.get_value("Account", {"account_name": account_name, "company": company}, "parent_account") + if not parent_account: + parent_account = frappe.db.get_value("Account", + filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company}, fieldname="parent_account") if not parent_account: parent_account = frappe.db.get_value("Account", filters={"account_type": "Tax", "root_type": "Liability", "is_group": 1, "company": company}) @@ -115,8 +117,11 @@ def get_item_tax_template(item_tax_templates, item_tax_map, item_code, parenttyp if not tax_type: account = frappe.new_doc("Account") account.update(filters) - account.insert() - tax_type = account.name + try: + account.insert() + tax_type = account.name + except frappe.DuplicateEntryError: + tax_type = frappe.db.get_value("Account", {"account_name": account_name, "company": company}, "name") account_type = frappe.get_cached_value("Account", tax_type, "account_type") From f098221550bdcf6a6d329022a2a22219f396bd6d Mon Sep 17 00:00:00 2001 From: Prssanna Desai Date: Wed, 22 Jul 2020 16:58:17 +0530 Subject: [PATCH 15/22] feat: Exported manufacturing dashboard (#22626) * feat: exported Manufacturing Dashboard * fix: update use_report_chart fieldname * fix: add dynamic filter for company in Produced Quantity chart --- .../completed_operation.json | 28 +++++++++ .../job_card_analysis/job_card_analysis.json | 26 ++++++++ .../last_month_downtime_analysis.json | 26 ++++++++ .../pending_work_order.json | 26 ++++++++ .../produced_quantity/produced_quantity.json | 30 +++++++++ .../quality_inspection_analysis.json | 25 ++++++++ .../work_order_analysis.json | 26 ++++++++ .../work_order_qty_analysis.json | 26 ++++++++ .../manufacturing/manufacturing.json | 62 +++++++++++++++++++ .../monthly_completed_work_order.json | 19 ++++++ .../monthly_quality_inspection.json | 19 ++++++ .../monthly_total_work_order.json | 19 ++++++ .../ongoing_job_card/ongoing_job_card.json | 19 ++++++ 13 files changed, 351 insertions(+) create mode 100644 erpnext/manufacturing/dashboard_chart/completed_operation/completed_operation.json create mode 100644 erpnext/manufacturing/dashboard_chart/job_card_analysis/job_card_analysis.json create mode 100644 erpnext/manufacturing/dashboard_chart/last_month_downtime_analysis/last_month_downtime_analysis.json create mode 100644 erpnext/manufacturing/dashboard_chart/pending_work_order/pending_work_order.json create mode 100644 erpnext/manufacturing/dashboard_chart/produced_quantity/produced_quantity.json create mode 100644 erpnext/manufacturing/dashboard_chart/quality_inspection_analysis/quality_inspection_analysis.json create mode 100644 erpnext/manufacturing/dashboard_chart/work_order_analysis/work_order_analysis.json create mode 100644 erpnext/manufacturing/dashboard_chart/work_order_qty_analysis/work_order_qty_analysis.json create mode 100644 erpnext/manufacturing/manufacturing_dashboard/manufacturing/manufacturing.json create mode 100644 erpnext/manufacturing/number_card/monthly_completed_work_order/monthly_completed_work_order.json create mode 100644 erpnext/manufacturing/number_card/monthly_quality_inspection/monthly_quality_inspection.json create mode 100644 erpnext/manufacturing/number_card/monthly_total_work_order/monthly_total_work_order.json create mode 100644 erpnext/manufacturing/number_card/ongoing_job_card/ongoing_job_card.json diff --git a/erpnext/manufacturing/dashboard_chart/completed_operation/completed_operation.json b/erpnext/manufacturing/dashboard_chart/completed_operation/completed_operation.json new file mode 100644 index 0000000000..d74ae2faf4 --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/completed_operation/completed_operation.json @@ -0,0 +1,28 @@ +{ + "based_on": "creation", + "chart_name": "Completed Operation", + "chart_type": "Sum", + "creation": "2020-07-08 22:40:22.441658", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Work Order Operation", + "filters_json": "[[\"Work Order Operation\",\"docstatus\",\"=\",1,false]]", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-21 16:57:09.767009", + "modified": "2020-07-21 16:57:55.719802", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Completed Operation", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Quarterly", + "timeseries": 1, + "timespan": "Last Year", + "type": "Line", + "use_report_chart": 0, + "value_based_on": "completed_qty", + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/manufacturing/dashboard_chart/job_card_analysis/job_card_analysis.json b/erpnext/manufacturing/dashboard_chart/job_card_analysis/job_card_analysis.json new file mode 100644 index 0000000000..e3cbba6e81 --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/job_card_analysis/job_card_analysis.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Job Card Analysis", + "chart_type": "Report", + "creation": "2020-07-08 22:40:22.549096", + "custom_options": "{\"barOptions\": {\"stacked\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.defaults.get_user_default(\\\"year_start_date\\\")\",\"to_date\":\"frappe.defaults.get_user_default(\\\"year_end_date\\\")\"}", + "filters_json": "{\"docstatus\":1,\"range\":\"Monthly\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-21 17:47:06.537924", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Job Card Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Job Card Summary", + "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/manufacturing/dashboard_chart/last_month_downtime_analysis/last_month_downtime_analysis.json b/erpnext/manufacturing/dashboard_chart/last_month_downtime_analysis/last_month_downtime_analysis.json new file mode 100644 index 0000000000..46d2215a00 --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/last_month_downtime_analysis/last_month_downtime_analysis.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Last Month Downtime Analysis", + "chart_type": "Report", + "creation": "2020-07-08 22:40:22.516460", + "custom_options": "", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{}", + "filters_json": "{\"from_date\":\"2020-06-21 00:00:00\",\"to_date\":\"2020-07-21 18:46:45\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-21 18:46:50.767333", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Last Month Downtime Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Downtime Analysis", + "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/manufacturing/dashboard_chart/pending_work_order/pending_work_order.json b/erpnext/manufacturing/dashboard_chart/pending_work_order/pending_work_order.json new file mode 100644 index 0000000000..91cd12b366 --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/pending_work_order/pending_work_order.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Pending Work Order", + "chart_type": "Report", + "creation": "2020-07-08 22:40:22.499217", + "custom_options": "{\"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"height\": 300}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.defaults.get_user_default(\\\"year_start_date\\\")\",\"to_date\":\"frappe.defaults.get_user_default(\\\"year_end_date\\\")\"}", + "filters_json": "{\"charts_based_on\":\"Age\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-21 17:46:42.917598", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Pending Work Order", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Work Order Summary", + "time_interval": "Yearly", + "timeseries": 0, + "timespan": "Last Year", + "type": "Donut", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/manufacturing/dashboard_chart/produced_quantity/produced_quantity.json b/erpnext/manufacturing/dashboard_chart/produced_quantity/produced_quantity.json new file mode 100644 index 0000000000..ba1a29d25b --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/produced_quantity/produced_quantity.json @@ -0,0 +1,30 @@ +{ + "based_on": "modified", + "chart_name": "Produced Quantity", + "chart_type": "Sum", + "creation": "2020-07-08 22:40:22.416285", + "custom_options": "", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Work Order", + "dynamic_filters_json": "[[\"Work Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Work Order\",\"docstatus\",\"=\",\"1\",false]]", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-21 17:46:34.058882", + "modified": "2020-07-21 17:54:11.233531", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Produced Quantity", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Monthly", + "timeseries": 1, + "timespan": "Last Year", + "type": "Line", + "use_report_chart": 0, + "value_based_on": "produced_qty", + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/manufacturing/dashboard_chart/quality_inspection_analysis/quality_inspection_analysis.json b/erpnext/manufacturing/dashboard_chart/quality_inspection_analysis/quality_inspection_analysis.json new file mode 100644 index 0000000000..8388f3d72b --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/quality_inspection_analysis/quality_inspection_analysis.json @@ -0,0 +1,25 @@ +{ + "chart_name": "Quality Inspection Analysis", + "chart_type": "Report", + "creation": "2020-07-08 22:40:22.483617", + "custom_options": "{\"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"height\": 300}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "filters_json": "{\"from_date\":\"2019-07-09\",\"to_date\":\"2020-07-09\"}", + "idx": 0, + "use_report_chart": 1, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-09 12:15:51.564487", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Quality Inspection Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Quality Inspection Summary", + "time_interval": "Yearly", + "timeseries": 0, + "timespan": "Last Year", + "type": "Donut", + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/manufacturing/dashboard_chart/work_order_analysis/work_order_analysis.json b/erpnext/manufacturing/dashboard_chart/work_order_analysis/work_order_analysis.json new file mode 100644 index 0000000000..879826a7ad --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/work_order_analysis/work_order_analysis.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Work Order Analysis", + "chart_type": "Report", + "creation": "2020-07-08 22:40:22.465459", + "custom_options": "{\"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"height\": 300}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.defaults.get_user_default(\\\"year_start_date\\\")\",\"to_date\":\"frappe.defaults.get_user_default(\\\"year_end_date\\\")\"}", + "filters_json": "{\"charts_based_on\":\"Status\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-21 17:50:23.806007", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Work Order Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Work Order Summary", + "time_interval": "Yearly", + "timeseries": 0, + "timespan": "Last Year", + "type": "Donut", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/manufacturing/dashboard_chart/work_order_qty_analysis/work_order_qty_analysis.json b/erpnext/manufacturing/dashboard_chart/work_order_qty_analysis/work_order_qty_analysis.json new file mode 100644 index 0000000000..93572799d6 --- /dev/null +++ b/erpnext/manufacturing/dashboard_chart/work_order_qty_analysis/work_order_qty_analysis.json @@ -0,0 +1,26 @@ +{ + "chart_name": "Work Order Qty Analysis", + "chart_type": "Report", + "creation": "2020-07-08 22:40:22.532889", + "custom_options": "{\"barOptions\": {\"stacked\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"from_date\":\"frappe.defaults.get_user_default(\\\"year_start_date\\\")\",\"to_date\":\"frappe.defaults.get_user_default(\\\"year_end_date\\\")\"}", + "filters_json": "{\"charts_based_on\":\"Quantity\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-21 17:46:59.020709", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Work Order Qty Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Work Order Summary", + "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/manufacturing/manufacturing_dashboard/manufacturing/manufacturing.json b/erpnext/manufacturing/manufacturing_dashboard/manufacturing/manufacturing.json new file mode 100644 index 0000000000..314efe7a80 --- /dev/null +++ b/erpnext/manufacturing/manufacturing_dashboard/manufacturing/manufacturing.json @@ -0,0 +1,62 @@ +{ + "cards": [ + { + "card": "Monthly Total Work Order" + }, + { + "card": "Monthly Completed Work Order" + }, + { + "card": "Ongoing Job Card" + }, + { + "card": "Monthly Quality Inspection" + } + ], + "charts": [ + { + "chart": "Produced Quantity", + "width": "Half" + }, + { + "chart": "Completed Operation", + "width": "Half" + }, + { + "chart": "Work Order Analysis", + "width": "Half" + }, + { + "chart": "Quality Inspection Analysis", + "width": "Half" + }, + { + "chart": "Pending Work Order", + "width": "Half" + }, + { + "chart": "Last Month Downtime Analysis", + "width": "Half" + }, + { + "chart": "Work Order Qty Analysis", + "width": "Full" + }, + { + "chart": "Job Card Analysis", + "width": "Full" + } + ], + "creation": "2020-07-08 22:40:22.626607", + "dashboard_name": "Manufacturing", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 0, + "is_standard": 1, + "modified": "2020-07-09 12:39:39.455039", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Manufacturing", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/manufacturing/number_card/monthly_completed_work_order/monthly_completed_work_order.json b/erpnext/manufacturing/number_card/monthly_completed_work_order/monthly_completed_work_order.json new file mode 100644 index 0000000000..36c0b9ae75 --- /dev/null +++ b/erpnext/manufacturing/number_card/monthly_completed_work_order/monthly_completed_work_order.json @@ -0,0 +1,19 @@ +{ + "creation": "2020-07-08 22:40:22.575086", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Work Order", + "filters_json": "[[\"Work Order\",\"status\",\"=\",\"Completed\"],[\"Work Order\",\"docstatus\",\"=\",1],[\"Work Order\",\"creation\",\"between\",[\"2020-06-08\",\"2020-07-08\"]]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Monthly Completed Work Orders", + "modified": "2020-07-09 12:22:54.809813", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Monthly Completed Work Order", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly" +} \ No newline at end of file diff --git a/erpnext/manufacturing/number_card/monthly_quality_inspection/monthly_quality_inspection.json b/erpnext/manufacturing/number_card/monthly_quality_inspection/monthly_quality_inspection.json new file mode 100644 index 0000000000..91a45365c0 --- /dev/null +++ b/erpnext/manufacturing/number_card/monthly_quality_inspection/monthly_quality_inspection.json @@ -0,0 +1,19 @@ +{ + "creation": "2020-07-08 22:40:22.606867", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Quality Inspection", + "filters_json": "[[\"Quality Inspection\",\"docstatus\",\"=\",1],[\"Quality Inspection\",\"creation\",\"between\",[\"2020-06-08\",\"2020-07-08\"]]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Monthly Quality Inspections", + "modified": "2020-07-09 12:23:34.838154", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Monthly Quality Inspection", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly" +} \ No newline at end of file diff --git a/erpnext/manufacturing/number_card/monthly_total_work_order/monthly_total_work_order.json b/erpnext/manufacturing/number_card/monthly_total_work_order/monthly_total_work_order.json new file mode 100644 index 0000000000..80d3b1520a --- /dev/null +++ b/erpnext/manufacturing/number_card/monthly_total_work_order/monthly_total_work_order.json @@ -0,0 +1,19 @@ +{ + "creation": "2020-07-08 22:40:22.562715", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Work Order", + "filters_json": "[[\"Work Order\",\"docstatus\",\"=\",1],[\"Work Order\",\"creation\",\"between\",[\"2020-06-08\",\"2020-07-08\"]]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Monthly Total Work Orders", + "modified": "2020-07-09 12:22:25.698795", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Monthly Total Work Order", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly" +} \ No newline at end of file diff --git a/erpnext/manufacturing/number_card/ongoing_job_card/ongoing_job_card.json b/erpnext/manufacturing/number_card/ongoing_job_card/ongoing_job_card.json new file mode 100644 index 0000000000..ba23ff3453 --- /dev/null +++ b/erpnext/manufacturing/number_card/ongoing_job_card/ongoing_job_card.json @@ -0,0 +1,19 @@ +{ + "creation": "2020-07-08 22:40:22.592042", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Job Card", + "filters_json": "[[\"Job Card\",\"status\",\"!=\",\"Completed\"],[\"Job Card\",\"docstatus\",\"=\",1]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Ongoing Job Cards", + "modified": "2020-07-09 12:23:18.218233", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Ongoing Job Card", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly" +} \ No newline at end of file From c7eadfceb0e794b070d2b22e4f70d7ac2edd5612 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 22 Jul 2020 17:59:37 +0530 Subject: [PATCH 16/22] fix: Multi currency payment reconciliation (#22738) * fix: Multi currency payment reconciliation * fix: Hide currency link fields --- .../payment_reconciliation.js | 4 + .../payment_reconciliation.py | 10 +- .../payment_reconciliation_invoice.json | 243 +++++------------- .../payment_reconciliation_payment.json | 18 +- .../sales_invoice_item.json | 2 +- erpnext/accounts/utils.py | 6 +- erpnext/controllers/accounts_controller.py | 12 +- 7 files changed, 110 insertions(+), 185 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index d3992d5111..355fe96c96 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -73,6 +73,10 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext }; } }); + + this.frm.set_value('party_type', ''); + this.frm.set_value('party', ''); + this.frm.set_value('receivable_payable_account', ''); }, refresh: function() { diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 35d8d34c51..2f8b634664 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -48,7 +48,8 @@ class PaymentReconciliation(Document): select "Journal Entry" as reference_type, t1.name as reference_name, t1.posting_date, t1.remark as remarks, t2.name as reference_row, - {dr_or_cr} as amount, t2.is_advance + {dr_or_cr} as amount, t2.is_advance, + t2.account_currency as currency from `tabJournal Entry` t1, `tabJournal Entry Account` t2 where @@ -88,7 +89,8 @@ class PaymentReconciliation(Document): if self.party_type == 'Customer' else "Purchase Invoice") return frappe.db.sql(""" SELECT `tab{doc}`.name as reference_name, %(voucher_type)s as reference_type, - (sum(`tabGL Entry`.{dr_or_cr}) - sum(`tabGL Entry`.{reconciled_dr_or_cr})) as amount + (sum(`tabGL Entry`.{dr_or_cr}) - sum(`tabGL Entry`.{reconciled_dr_or_cr})) as amount, + account_currency as currency FROM `tab{doc}`, `tabGL Entry` WHERE (`tab{doc}`.name = `tabGL Entry`.against_voucher or `tab{doc}`.name = `tabGL Entry`.voucher_no) @@ -141,6 +143,7 @@ class PaymentReconciliation(Document): ent.invoice_number = e.get('voucher_no') ent.invoice_date = e.get('posting_date') ent.amount = flt(e.get('invoice_amount')) + ent.currency = e.get('currency') ent.outstanding_amount = e.get('outstanding_amount') def reconcile(self, args): @@ -269,11 +272,14 @@ def reconcile_dr_cr_note(dr_cr_notes, company): reconcile_dr_or_cr = ('debit_in_account_currency' if d.dr_or_cr == 'credit_in_account_currency' else 'credit_in_account_currency') + company_currency = erpnext.get_company_currency(company) + jv = frappe.get_doc({ "doctype": "Journal Entry", "voucher_type": voucher_type, "posting_date": today(), "company": company, + "multi_currency": 1 if d.currency != company_currency else 0, "accounts": [ { 'account': d.account, diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json index ce7ce98edb..6a79a85c34 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json @@ -1,183 +1,80 @@ { - "allow_copy": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, - "creation": "2014-07-09 16:14:23.672922", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, + "actions": [], + "creation": "2014-07-09 16:14:23.672922", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "invoice_type", + "invoice_number", + "invoice_date", + "col_break1", + "amount", + "outstanding_amount", + "currency" + ], "fields": [ { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "invoice_type", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Invoice Type", - "length": 0, - "no_copy": 0, - "options": "Sales Invoice\nPurchase Invoice\nJournal Entry", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "invoice_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Invoice Type", + "options": "Sales Invoice\nPurchase Invoice\nJournal Entry", + "read_only": 1 + }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "invoice_number", - "fieldtype": "Dynamic Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Invoice Number", - "length": 0, - "no_copy": 0, - "options": "invoice_type", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "invoice_number", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "label": "Invoice Number", + "options": "invoice_type", + "read_only": 1 + }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "invoice_date", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Invoice Date", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "invoice_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Invoice Date", + "read_only": 1 + }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "col_break1", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "col_break1", + "fieldtype": "Column Break" + }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "amount", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "options": "currency", + "read_only": 1 + }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "outstanding_amount", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Outstanding Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 + "fieldname": "outstanding_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Outstanding Amount", + "options": "currency", + "read_only": 1 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "hidden": 1, + "label": "Currency", + "options": "Currency" } - ], - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - - "is_submittable": 0, - "issingle": 0, - "istable": 1, - "max_attachments": 0, - "modified": "2016-07-11 03:28:03.588476", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Payment Reconciliation Invoice", - "name_case": "", - "owner": "Administrator", - "permissions": [], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_seen": 0 + ], + "istable": 1, + "links": [], + "modified": "2020-07-19 18:12:27.964073", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Reconciliation Invoice", + "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/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json index 018bfd028a..925a6f10a5 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json @@ -1,7 +1,9 @@ { + "actions": [], "creation": "2014-07-09 16:13:35.452759", "doctype": "DocType", "editable_grid": 1, + "engine": "InnoDB", "field_order": [ "reference_type", "reference_name", @@ -16,7 +18,8 @@ "difference_account", "difference_amount", "sec_break1", - "remark" + "remark", + "currency" ], "fields": [ { @@ -73,6 +76,7 @@ "fieldtype": "Currency", "in_list_view": 1, "label": "Amount", + "options": "currency", "read_only": 1 }, { @@ -81,6 +85,7 @@ "fieldtype": "Currency", "in_list_view": 1, "label": "Allocated amount", + "options": "currency", "reqd": 1 }, { @@ -106,16 +111,25 @@ "fieldname": "difference_amount", "fieldtype": "Currency", "label": "Difference Amount", + "options": "currency", "print_hide": 1, "read_only": 1 }, { "fieldname": "section_break_10", "fieldtype": "Section Break" + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "hidden": 1, + "label": "Currency", + "options": "Currency" } ], "istable": 1, - "modified": "2019-06-24 00:08:11.150796", + "links": [], + "modified": "2020-07-19 18:12:41.682347", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Payment", diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index 9bc24664d1..004d358ef9 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -795,7 +795,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2020-03-11 12:24:41.749986", + "modified": "2020-07-18 12:24:41.749986", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 013c30d6ff..824b2f2efb 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -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/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ead503ed09..89c38c710b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1014,6 +1014,7 @@ def get_advance_journal_entries(party_type, party, party_account, amount_field, def get_advance_payment_entries(party_type, party, party_account, order_doctype, order_list=None, include_unallocated=True, against_all_orders=False, limit=None): party_account_field = "paid_from" if party_type == "Customer" else "paid_to" + currency_field = "paid_from_account_currency" if party_type == "Customer" else "paid_to_account_currency" payment_type = "Receive" if party_type == "Customer" else "Pay" payment_entries_against_order, unallocated_payment_entries = [], [] limit_cond = "limit %s" % limit if limit else "" @@ -1030,14 +1031,15 @@ def get_advance_payment_entries(party_type, party, party_account, order_doctype, select "Payment Entry" as reference_type, t1.name as reference_name, t1.remarks, t2.allocated_amount as amount, t2.name as reference_row, - t2.reference_name as against_order, t1.posting_date + t2.reference_name as against_order, t1.posting_date, + t1.{0} as currency from `tabPayment Entry` t1, `tabPayment Entry Reference` t2 where - t1.name = t2.parent and t1.{0} = %s and t1.payment_type = %s + t1.name = t2.parent and t1.{1} = %s and t1.payment_type = %s and t1.party_type = %s and t1.party = %s and t1.docstatus = 1 - and t2.reference_doctype = %s {1} - order by t1.posting_date {2} - """.format(party_account_field, reference_condition, limit_cond), + and t2.reference_doctype = %s {2} + order by t1.posting_date {3} + """.format(currency_field, party_account_field, reference_condition, limit_cond), [party_account, payment_type, party_type, party, order_doctype] + order_list, as_dict=1) From 93afbe143b0bd6f2b678366f5060ef3ffde40333 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Wed, 22 Jul 2020 18:07:39 +0530 Subject: [PATCH 17/22] feat: Export Selling Dashboard (#22776) * feat:Export Stock Dashboard * Export Selling Dashboard * Export Selling Dashboard --- .../item_wise_annual_sales.json | 24 +++ .../sales_order_analysis.json | 24 +++ .../sales_order_trends.json | 24 +++ .../top_customers/top_customers.json | 24 +++ erpnext/selling/dashboard_fixtures.py | 198 ------------------ .../active_customers/active_customers.json | 21 ++ .../annual_sales/annual_sales.json | 22 ++ .../sales_orders_to_bill.json | 21 ++ .../sales_orders_to_deliver.json | 21 ++ .../selling_dashboard/selling/selling.json | 46 ++++ 10 files changed, 227 insertions(+), 198 deletions(-) create mode 100644 erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json create mode 100644 erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json create mode 100644 erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json create mode 100644 erpnext/selling/dashboard_chart/top_customers/top_customers.json delete mode 100644 erpnext/selling/dashboard_fixtures.py create mode 100644 erpnext/selling/number_card/active_customers/active_customers.json create mode 100644 erpnext/selling/number_card/annual_sales/annual_sales.json create mode 100644 erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json create mode 100644 erpnext/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json create mode 100644 erpnext/selling/selling_dashboard/selling/selling.json diff --git a/erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json b/erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json new file mode 100644 index 0000000000..290e526f11 --- /dev/null +++ b/erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Item-wise Annual Sales", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.474566", + "custom_options": "", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"from_date\":\"2020-06-22\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 14:42:25.512675", + "modified_by": "Administrator", + "module": "Selling", + "name": "Item-wise Annual Sales", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Item-wise Sales History", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json b/erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json new file mode 100644 index 0000000000..5e1a0d9258 --- /dev/null +++ b/erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Sales Order Analysis", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.440393", + "custom_options": "{\"type\": \"donut\", \"height\": 300, \"axisOptions\": {\"shortenYAxisNumbers\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"status\":[\"To Bill\",\"To Deliver\"],\"group_by_so\":0,\"from_date\":\"2020-06-22\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 17:06:05.750660", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Sales Order Analysis", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json b/erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json new file mode 100644 index 0000000000..914d915d94 --- /dev/null +++ b/erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Sales Order Trends", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.508240", + "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\",\"based_on\":\"Item\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 16:24:45.726270", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Trends", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Sales Order Trends", + "timeseries": 0, + "type": "Line", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_chart/top_customers/top_customers.json b/erpnext/selling/dashboard_chart/top_customers/top_customers.json new file mode 100644 index 0000000000..59a2ba37dd --- /dev/null +++ b/erpnext/selling/dashboard_chart/top_customers/top_customers.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Top Customers", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.539281", + "custom_options": "", + "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\":\"Yearly\",\"based_on\":\"Customer\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 17:03:10.320147", + "modified_by": "Administrator", + "module": "Selling", + "name": "Top Customers", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Delivery Note Trends", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_fixtures.py b/erpnext/selling/dashboard_fixtures.py deleted file mode 100644 index 889cb88dce..0000000000 --- a/erpnext/selling/dashboard_fixtures.py +++ /dev/null @@ -1,198 +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.utils import get_fiscal_year - -def get_data(): - return frappe._dict({ - "dashboards": get_dashboards(), - "charts": get_charts(), - "number_cards": get_number_cards(), - }) - -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 - -company = frappe.get_doc("Company", get_company_for_dashboards()) -fiscal_year = get_fiscal_year(nowdate(), as_dict=1) -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")) - -def get_dashboards(): - return [{ - "name": "Selling", - "dashboard_name": "Selling", - "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"} - ], - "cards": [ - { "card": "Annual Sales"}, - { "card": "Sales Orders to Deliver"}, - { "card": "Sales Orders to Bill"}, - { "card": "Active Customers"} - ] - }] - -def get_charts(): - return [ - { - "name": "Sales Order Analysis", - "chart_name": _("Sales 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": "Sales Order Analysis", - "type": "Donut" - }, - { - "name": "Item-wise Annual Sales", - "chart_name": _("Item-wise Annual Sales"), - "chart_type": "Report", - "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": "Item-wise Sales History", - "type": "Bar" - }, - { - "name": "Sales Order Trends", - "chart_name": _("Sales 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, - "based_on": "Item" - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Sales Order Trends", - "type": "Line" - }, - { - "name": "Top Customers", - "chart_name": _("Top Customers"), - "chart_type": "Report", - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "period": "Monthly", - "fiscal_year": fiscal_year_name, - "based_on": "Customer" - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Delivery Note Trends", - "type": "Bar" - } - ] - -def get_number_cards(): - return [ - { - "name": "Annual Sales", - "aggregate_function_based_on": "base_net_total", - "doctype": "Number Card", - "document_type": "Sales Order", - "filters_json": json.dumps([ - ["Sales Order", "transaction_date", "Between", [start_date, end_date], False], - ["Sales Order", "status", "not in", ["Draft", "Cancelled", "Closed", None], False], - ["Sales Order", "docstatus", "=", 1, False], - ["Sales Order", "company", "=", company.name, False] - ]), - "function": "Sum", - "is_public": 1, - "label": _("Annual Sales"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "name": "Sales Orders to Deliver", - "doctype": "Number Card", - "document_type": "Sales Order", - "filters_json": json.dumps([ - ["Sales Order", "status", "in", ["To Deliver and Bill", "To Deliver", None], False], - ["Sales Order", "docstatus", "=", 1, False], - ["Sales Order", "company", "=", company.name, False] - ]), - "function": "Count", - "is_public": 1, - "label": _("Sales Orders to Deliver"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Weekly" - }, - { - "name": "Sales Orders to Bill", - "doctype": "Number Card", - "document_type": "Sales Order", - "filters_json": json.dumps([ - ["Sales Order", "status", "in", ["To Deliver and Bill", "To Bill", None], False], - ["Sales Order", "docstatus", "=", 1, False], - ["Sales Order", "company", "=", company.name, False] - ]), - "function": "Count", - "is_public": 1, - "label": _("Sales Orders to Bill"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Weekly" - }, - { - "name": "Active Customers", - "doctype": "Number Card", - "document_type": "Customer", - "filters_json": json.dumps([["Customer", "disabled", "=", "0"]]), - "function": "Count", - "is_public": 1, - "label": "Active Customers", - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - } - ] \ No newline at end of file diff --git a/erpnext/selling/number_card/active_customers/active_customers.json b/erpnext/selling/number_card/active_customers/active_customers.json new file mode 100644 index 0000000000..3377634847 --- /dev/null +++ b/erpnext/selling/number_card/active_customers/active_customers.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:16.653866", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Customer", + "dynamic_filters_json": "", + "filters_json": "[[\"Customer\",\"disabled\",\"=\",\"0\"]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Active Customers", + "modified": "2020-07-22 14:20:32.268103", + "modified_by": "Administrator", + "module": "Selling", + "name": "Active Customers", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/selling/number_card/annual_sales/annual_sales.json b/erpnext/selling/number_card/annual_sales/annual_sales.json new file mode 100644 index 0000000000..8746ee4c6a --- /dev/null +++ b/erpnext/selling/number_card/annual_sales/annual_sales.json @@ -0,0 +1,22 @@ +{ + "aggregate_function_based_on": "base_net_total", + "creation": "2020-07-20 20:17:16.568132", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Sales Order", + "dynamic_filters_json": "[[\"Sales Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Sales Order\",\"status\",\"not in\",[\"Draft\",\"Cancelled\",\"Closed\",null],false],[\"Sales Order\",\"docstatus\",\"=\",\"1\",false],[\"Sales Order\",\"modified\",\"Timespan\",\"this year\",false]]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Annual Sales", + "modified": "2020-07-22 16:56:33.747156", + "modified_by": "Administrator", + "module": "Selling", + "name": "Annual Sales", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json b/erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json new file mode 100644 index 0000000000..27fea45723 --- /dev/null +++ b/erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:16.625001", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Sales Order", + "dynamic_filters_json": "[[\"Sales Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Sales Order\",\"status\",\"in\",[\"To Deliver and Bill\",\"To Bill\",null],false],[\"Sales Order\",\"docstatus\",\"=\",\"1\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Sales Orders to Bill", + "modified": "2020-07-22 14:20:09.918626", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales 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/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json b/erpnext/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json new file mode 100644 index 0000000000..6e19cf4d3e --- /dev/null +++ b/erpnext/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:16.596857", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Sales Order", + "dynamic_filters_json": "[[\"Sales Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Sales Order\",\"status\",\"in\",[\"To Deliver and Bill\",\"To Deliver\",null],false],[\"Sales Order\",\"docstatus\",\"=\",\"1\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Sales Orders to Deliver", + "modified": "2020-07-22 14:19:28.833784", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Orders to Deliver", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly", + "type": "Document Type" +} \ No newline at end of file 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 From 5bd0b93acf632845135762950c809cc496140a54 Mon Sep 17 00:00:00 2001 From: Anupam K Date: Wed, 22 Jul 2020 18:10:57 +0530 Subject: [PATCH 18/22] fix: cur_frm -> frm --- erpnext/crm/doctype/opportunity/opportunity.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 28aedde122..7bae803508 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -127,14 +127,14 @@ frappe.ui.form.on("Opportunity", { make_supplier_quotation: function(frm) { frappe.model.open_mapped_doc({ method: "erpnext.crm.doctype.opportunity.opportunity.make_supplier_quotation", - frm: cur_frm + frm: frm }) }, make_request_for_quotation: function(frm) { frappe.model.open_mapped_doc({ method: "erpnext.crm.doctype.opportunity.opportunity.make_request_for_quotation", - frm: cur_frm + frm: frm }) }, From e519334dfcf7916f25cb0e25bda39c62f9fba78f Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Wed, 22 Jul 2020 18:16:57 +0530 Subject: [PATCH 19/22] feat: Export CRM dashboard (#22778) * feat: Exported CRM dashboard * feat: Export CRM Dashboard * fix: adding company in all dashboard and number card --- erpnext/crm/crm_dashboard/crm/crm.json | 58 +++++ .../incoming_leads/incoming_leads.json | 28 +++ .../lead_source/lead_source.json | 27 +++ .../opportunities_via_campaigns.json | 27 +++ .../opportunity_trends.json | 28 +++ .../territory_wise_opportunity_count.json | 27 +++ .../territory_wise_sales.json | 28 +++ .../won_opportunities/won_opportunities.json | 27 +++ erpnext/crm/dashboard_fixtures.py | 221 ------------------ .../new_lead_(last_1_month).json | 21 ++ .../new_opportunity_(last_1_month).json | 21 ++ .../open_opportunity/open_opportunity.json | 21 ++ .../won_opportunity_(last_1_month).json | 21 ++ 13 files changed, 334 insertions(+), 221 deletions(-) create mode 100644 erpnext/crm/crm_dashboard/crm/crm.json create mode 100644 erpnext/crm/dashboard_chart/incoming_leads/incoming_leads.json create mode 100644 erpnext/crm/dashboard_chart/lead_source/lead_source.json create mode 100644 erpnext/crm/dashboard_chart/opportunities_via_campaigns/opportunities_via_campaigns.json create mode 100644 erpnext/crm/dashboard_chart/opportunity_trends/opportunity_trends.json create mode 100644 erpnext/crm/dashboard_chart/territory_wise_opportunity_count/territory_wise_opportunity_count.json create mode 100644 erpnext/crm/dashboard_chart/territory_wise_sales/territory_wise_sales.json create mode 100644 erpnext/crm/dashboard_chart/won_opportunities/won_opportunities.json delete mode 100644 erpnext/crm/dashboard_fixtures.py create mode 100644 erpnext/crm/number_card/new_lead_(last_1_month)/new_lead_(last_1_month).json create mode 100644 erpnext/crm/number_card/new_opportunity_(last_1_month)/new_opportunity_(last_1_month).json create mode 100644 erpnext/crm/number_card/open_opportunity/open_opportunity.json create mode 100644 erpnext/crm/number_card/won_opportunity_(last_1_month)/won_opportunity_(last_1_month).json diff --git a/erpnext/crm/crm_dashboard/crm/crm.json b/erpnext/crm/crm_dashboard/crm/crm.json new file mode 100644 index 0000000000..69c2c8a351 --- /dev/null +++ b/erpnext/crm/crm_dashboard/crm/crm.json @@ -0,0 +1,58 @@ +{ + "cards": [ + { + "card": "New Lead (Last 1 Month)" + }, + { + "card": "New Opportunity (Last 1 Month)" + }, + { + "card": "Won Opportunity (Last 1 Month)" + }, + { + "card": "Open Opportunity" + } + ], + "charts": [ + { + "chart": "Incoming Leads", + "width": "Full" + }, + { + "chart": "Opportunity Trends", + "width": "Full" + }, + { + "chart": "Won Opportunities", + "width": "Full" + }, + { + "chart": "Territory Wise Opportunity Count", + "width": "Half" + }, + { + "chart": "Opportunities via Campaigns", + "width": "Half" + }, + { + "chart": "Territory Wise Sales", + "width": "Full" + }, + { + "chart": "Lead Source", + "width": "Half" + } + ], + "creation": "2020-07-20 20:17:15.985657", + "dashboard_name": "CRM", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 0, + "is_standard": 1, + "modified": "2020-07-21 18:56:47.230053", + "modified_by": "Administrator", + "module": "CRM", + "name": "CRM", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/crm/dashboard_chart/incoming_leads/incoming_leads.json b/erpnext/crm/dashboard_chart/incoming_leads/incoming_leads.json new file mode 100644 index 0000000000..82398ebd99 --- /dev/null +++ b/erpnext/crm/dashboard_chart/incoming_leads/incoming_leads.json @@ -0,0 +1,28 @@ +{ + "based_on": "creation", + "chart_name": "Incoming Leads", + "chart_type": "Count", + "creation": "2020-07-20 20:17:15.639164", + "custom_options": "{\"type\": \"line\", \"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"tooltipOptions\": {}, \"lineOptions\": {\"regionFill\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Lead", + "dynamic_filters_json": "[[\"Lead\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[]", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 15:49:19.896501", + "modified": "2020-07-22 16:06:34.941729", + "modified_by": "Administrator", + "module": "CRM", + "name": "Incoming Leads", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Weekly", + "timeseries": 1, + "timespan": "Last Quarter", + "type": "Bar", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/crm/dashboard_chart/lead_source/lead_source.json b/erpnext/crm/dashboard_chart/lead_source/lead_source.json new file mode 100644 index 0000000000..f25fea5751 --- /dev/null +++ b/erpnext/crm/dashboard_chart/lead_source/lead_source.json @@ -0,0 +1,27 @@ +{ + "chart_name": "Lead Source", + "chart_type": "Group By", + "creation": "2020-07-20 20:17:15.842106", + "custom_options": "{\"truncateLegends\": 1, \"maxSlices\": 8}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Lead", + "dynamic_filters_json": "[[\"Lead\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[]", + "group_by_based_on": "source", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 16:11:14.170636", + "modified": "2020-07-22 16:13:38.696710", + "modified_by": "Administrator", + "module": "CRM", + "name": "Lead Source", + "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/crm/dashboard_chart/opportunities_via_campaigns/opportunities_via_campaigns.json b/erpnext/crm/dashboard_chart/opportunities_via_campaigns/opportunities_via_campaigns.json new file mode 100644 index 0000000000..4adda9a1c5 --- /dev/null +++ b/erpnext/crm/dashboard_chart/opportunities_via_campaigns/opportunities_via_campaigns.json @@ -0,0 +1,27 @@ +{ + "chart_name": "Opportunities via Campaigns", + "chart_type": "Group By", + "creation": "2020-07-20 20:17:15.705402", + "custom_options": "{\"truncateLegends\": 1, \"maxSlices\": 8}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[]", + "group_by_based_on": "campaign", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 15:45:32.572011", + "modified": "2020-07-22 16:10:02.497726", + "modified_by": "Administrator", + "module": "CRM", + "name": "Opportunities via Campaigns", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Pie", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/crm/dashboard_chart/opportunity_trends/opportunity_trends.json b/erpnext/crm/dashboard_chart/opportunity_trends/opportunity_trends.json new file mode 100644 index 0000000000..08e26cd3e3 --- /dev/null +++ b/erpnext/crm/dashboard_chart/opportunity_trends/opportunity_trends.json @@ -0,0 +1,28 @@ +{ + "based_on": "creation", + "chart_name": "Opportunity Trends", + "chart_type": "Count", + "creation": "2020-07-20 20:17:15.672124", + "custom_options": "", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[]", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 15:45:32.590967", + "modified": "2020-07-22 16:08:33.100532", + "modified_by": "Administrator", + "module": "CRM", + "name": "Opportunity Trends", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Weekly", + "timeseries": 1, + "timespan": "Last Quarter", + "type": "Bar", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/crm/dashboard_chart/territory_wise_opportunity_count/territory_wise_opportunity_count.json b/erpnext/crm/dashboard_chart/territory_wise_opportunity_count/territory_wise_opportunity_count.json new file mode 100644 index 0000000000..8b15ec93e2 --- /dev/null +++ b/erpnext/crm/dashboard_chart/territory_wise_opportunity_count/territory_wise_opportunity_count.json @@ -0,0 +1,27 @@ +{ + "chart_name": "Territory Wise Opportunity Count", + "chart_type": "Group By", + "creation": "2020-07-20 20:17:15.774176", + "custom_options": "{\"truncateLegends\": 1, \"maxSlices\": 8}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[]", + "group_by_based_on": "territory", + "group_by_type": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 15:45:32.134026", + "modified": "2020-07-22 16:09:42.921547", + "modified_by": "Administrator", + "module": "CRM", + "name": "Territory Wise Opportunity Count", + "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/crm/dashboard_chart/territory_wise_sales/territory_wise_sales.json b/erpnext/crm/dashboard_chart/territory_wise_sales/territory_wise_sales.json new file mode 100644 index 0000000000..fe142b4344 --- /dev/null +++ b/erpnext/crm/dashboard_chart/territory_wise_sales/territory_wise_sales.json @@ -0,0 +1,28 @@ +{ + "aggregate_function_based_on": "opportunity_amount", + "chart_name": "Territory Wise Sales", + "chart_type": "Group By", + "creation": "2020-07-20 20:17:15.809008", + "custom_options": "", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Opportunity\",\"status\",\"=\",\"Converted\",false]]", + "group_by_based_on": "territory", + "group_by_type": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 15:45:32.501313", + "modified": "2020-07-22 16:10:28.308110", + "modified_by": "Administrator", + "module": "CRM", + "name": "Territory Wise Sales", + "number_of_groups": 0, + "owner": "Administrator", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/crm/dashboard_chart/won_opportunities/won_opportunities.json b/erpnext/crm/dashboard_chart/won_opportunities/won_opportunities.json new file mode 100644 index 0000000000..2b5576b3a4 --- /dev/null +++ b/erpnext/crm/dashboard_chart/won_opportunities/won_opportunities.json @@ -0,0 +1,27 @@ +{ + "based_on": "modified", + "chart_name": "Won Opportunities", + "chart_type": "Count", + "creation": "2020-07-20 20:17:15.738889", + "docstatus": 0, + "doctype": "Dashboard Chart", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Opportunity\",\"status\",\"=\",\"Converted\",false]]", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "last_synced_on": "2020-07-22 15:45:32.575964", + "modified": "2020-07-22 16:09:14.265231", + "modified_by": "Administrator", + "module": "CRM", + "name": "Won Opportunities", + "number_of_groups": 0, + "owner": "Administrator", + "time_interval": "Monthly", + "timeseries": 1, + "timespan": "Last Year", + "type": "Bar", + "use_report_chart": 0, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/crm/dashboard_fixtures.py b/erpnext/crm/dashboard_fixtures.py deleted file mode 100644 index 901c0581f4..0000000000 --- a/erpnext/crm/dashboard_fixtures.py +++ /dev/null @@ -1,221 +0,0 @@ -# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -import frappe, erpnext, json -from frappe import _ - -def get_data(): - return frappe._dict({ - "dashboards": get_dashboards(), - "charts": get_charts(), - "number_cards": get_number_cards() - }) - -def get_dashboards(): - return [{ - "doctype": "Dashboard", - "name": "CRM", - "dashboard_name": "CRM", - "charts": [ - { "chart": "Incoming Leads", "width": "Full" }, - { "chart": "Opportunity Trends", "width": "Full"}, - { "chart": "Won Opportunities", "width": "Full" }, - { "chart": "Territory Wise Opportunity Count", "width": "Half"}, - { "chart": "Opportunities via Campaigns", "width": "Half" }, - { "chart": "Territory Wise Sales", "width": "Full"}, - { "chart": "Lead Source", "width": "Half"} - ], - "cards": [ - { "card": "New Lead (Last 1 Month)" }, - { "card": "New Opportunity (Last 1 Month)" }, - { "card": "Won Opportunity (Last 1 Month)" }, - { "card": "Open Opportunity"}, - ] - }] - -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_charts(): - company = get_company_for_dashboards() - - return [{ - "name": "Incoming Leads", - "doctype": "Dashboard Chart", - "time_interval": "Yearly", - "chart_type": "Count", - "chart_name": _("Incoming Leads"), - "timespan": "Last Quarter", - "time_interval": "Weekly", - "document_type": "Lead", - "based_on": "creation", - 'is_public': 1, - 'timeseries': 1, - "owner": "Administrator", - "filters_json": json.dumps([]), - "type": "Bar" - }, - { - "name": "Opportunity Trends", - "doctype": "Dashboard Chart", - "time_interval": "Yearly", - "chart_type": "Count", - "chart_name": _("Opportunity Trends"), - "timespan": "Last Quarter", - "time_interval": "Weekly", - "document_type": "Opportunity", - "based_on": "creation", - 'is_public': 1, - 'timeseries': 1, - "owner": "Administrator", - "filters_json": json.dumps([["Opportunity", "company", "=", company, False]]), - "type": "Bar" - }, - { - "name": "Opportunities via Campaigns", - "chart_name": _("Opportunities via Campaigns"), - "doctype": "Dashboard Chart", - "chart_type": "Group By", - "group_by_type": "Count", - "group_by_based_on": "campaign", - "document_type": "Opportunity", - 'is_public': 1, - 'timeseries': 1, - "owner": "Administrator", - "filters_json": json.dumps([["Opportunity", "company", "=", company, False]]), - "type": "Pie", - "custom_options": json.dumps({ - "truncateLegends": 1, - "maxSlices": 8 - }) - }, - { - "name": "Won Opportunities", - "doctype": "Dashboard Chart", - "time_interval": "Yearly", - "chart_type": "Count", - "chart_name": _("Won Opportunities"), - "timespan": "Last Year", - "time_interval": "Monthly", - "document_type": "Opportunity", - "based_on": "modified", - 'is_public': 1, - 'timeseries': 1, - "owner": "Administrator", - "filters_json": json.dumps([ - ["Opportunity", "company", "=", company, False], - ["Opportunity", "status", "=", "Converted", False]]), - "type": "Bar" - }, - { - "name": "Territory Wise Opportunity Count", - "doctype": "Dashboard Chart", - "chart_type": "Group By", - "group_by_type": "Count", - "group_by_based_on": "territory", - "chart_name": _("Territory Wise Opportunity Count"), - "document_type": "Opportunity", - 'is_public': 1, - "filters_json": json.dumps([ - ["Opportunity", "company", "=", company, False] - ]), - "owner": "Administrator", - "type": "Donut", - "custom_options": json.dumps({ - "truncateLegends": 1, - "maxSlices": 8 - }) - }, - { - "name": "Territory Wise Sales", - "doctype": "Dashboard Chart", - "chart_type": "Group By", - "group_by_type": "Sum", - "group_by_based_on": "territory", - "chart_name": _("Territory Wise Sales"), - "aggregate_function_based_on": "opportunity_amount", - "document_type": "Opportunity", - 'is_public': 1, - "owner": "Administrator", - "filters_json": json.dumps([ - ["Opportunity", "company", "=", company, False], - ["Opportunity", "status", "=", "Converted", False] - ]), - "type": "Bar" - }, - { - "name": "Lead Source", - "doctype": "Dashboard Chart", - "chart_type": "Group By", - "group_by_type": "Count", - "group_by_based_on": "source", - "chart_name": _("Lead Source"), - "document_type": "Lead", - 'is_public': 1, - "owner": "Administrator", - "type": "Pie", - "custom_options": json.dumps({ - "truncateLegends": 1, - "maxSlices": 8 - }) - }] - -def get_number_cards(): - return [{ - "doctype": "Number Card", - "document_type": "Lead", - "name": "New Lead (Last 1 Month)", - "filters_json": json.dumps([ - ["Lead", "creation", "Timespan", "last month"] - ]), - "function": "Count", - "is_public": 1, - "label": _("New Lead (Last 1 Month)"), - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "doctype": "Number Card", - "document_type": "Opportunity", - "name": "New Opportunity (Last 1 Month)", - "filters_json": json.dumps([ - ["Opportunity", "creation", "Timespan", "last month"] - ]), - "function": "Count", - "is_public": 1, - "label": _("New Opportunity (Last 1 Month)"), - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "doctype": "Number Card", - "document_type": "Opportunity", - "name": "Won Opportunity (Last 1 Month)", - "filters_json": json.dumps([ - ["Opportunity", "status", "=", "Converted",False], - ["Opportunity", "creation", "Timespan", "last month"] - ]), - "function": "Count", - "is_public": 1, - "label": _("Won Opportunity (Last 1 Month)"), - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "doctype": "Number Card", - "document_type": "Opportunity", - "name": "Open Opportunity", - "filters_json": json.dumps([["Opportunity","status","=","Open",False]]), - "function": "Count", - "is_public": 1, - "label": _("Open Opportunity"), - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }] \ No newline at end of file diff --git a/erpnext/crm/number_card/new_lead_(last_1_month)/new_lead_(last_1_month).json b/erpnext/crm/number_card/new_lead_(last_1_month)/new_lead_(last_1_month).json new file mode 100644 index 0000000000..4511f54007 --- /dev/null +++ b/erpnext/crm/number_card/new_lead_(last_1_month)/new_lead_(last_1_month).json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:15.870736", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Lead", + "dynamic_filters_json": "[[\"Lead\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Lead\",\"creation\",\"Timespan\",\"last month\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "New Lead (Last 1 Month)", + "modified": "2020-07-22 16:15:17.274972", + "modified_by": "Administrator", + "module": "CRM", + "name": "New Lead (Last 1 Month)", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/crm/number_card/new_opportunity_(last_1_month)/new_opportunity_(last_1_month).json b/erpnext/crm/number_card/new_opportunity_(last_1_month)/new_opportunity_(last_1_month).json new file mode 100644 index 0000000000..90997b7033 --- /dev/null +++ b/erpnext/crm/number_card/new_opportunity_(last_1_month)/new_opportunity_(last_1_month).json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:15.897112", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Opportunity\",\"creation\",\"Timespan\",\"last month\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "New Opportunity (Last 1 Month)", + "modified": "2020-07-22 16:07:27.910432", + "modified_by": "Administrator", + "module": "CRM", + "name": "New Opportunity (Last 1 Month)", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/crm/number_card/open_opportunity/open_opportunity.json b/erpnext/crm/number_card/open_opportunity/open_opportunity.json new file mode 100644 index 0000000000..6e06ed64da --- /dev/null +++ b/erpnext/crm/number_card/open_opportunity/open_opportunity.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:15.948113", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"status\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Opportunity\",\"company\",\"=\",null,false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Open Opportunity", + "modified": "2020-07-22 16:16:16.420446", + "modified_by": "Administrator", + "module": "CRM", + "name": "Open Opportunity", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/crm/number_card/won_opportunity_(last_1_month)/won_opportunity_(last_1_month).json b/erpnext/crm/number_card/won_opportunity_(last_1_month)/won_opportunity_(last_1_month).json new file mode 100644 index 0000000000..ba0c07e4b0 --- /dev/null +++ b/erpnext/crm/number_card/won_opportunity_(last_1_month)/won_opportunity_(last_1_month).json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:15.922486", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Opportunity", + "dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Opportunity\",\"creation\",\"Timespan\",\"last month\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Won Opportunity (Last 1 Month)", + "modified": "2020-07-22 16:15:53.088837", + "modified_by": "Administrator", + "module": "CRM", + "name": "Won Opportunity (Last 1 Month)", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Daily", + "type": "Document Type" +} \ No newline at end of file From 3e4b5e5496443b38d5fd9f1058ab38a37791e837 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Wed, 22 Jul 2020 18:17:58 +0530 Subject: [PATCH 20/22] fix: item-wise sales history report (#22783) --- .../report/item_wise_sales_history/item_wise_sales_history.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 7c50f421e19992b8a8022b851e6fb566febd2f1f Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 22 Jul 2020 18:21:04 +0530 Subject: [PATCH 21/22] fix: Move branch code back to bank account (#22725) * fix: Move branch code back to bank account * fix: Patch --- erpnext/accounts/doctype/bank/bank.json | 12 +----------- .../doctype/bank_account/bank_account.json | 9 ++++++++- .../doctype/bank_guarantee/bank_guarantee.js | 2 +- .../payment_request/payment_request.json | 4 ++-- erpnext/patches.txt | 1 + .../move_bank_account_swift_number_to_bank.py | 3 +-- .../v13_0/move_branch_code_to_bank_account.py | 17 +++++++++++++++++ 7 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 erpnext/patches/v13_0/move_branch_code_to_bank_account.py 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_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/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json index eef6be1a7a..8eadfd0b24 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.json +++ b/erpnext/accounts/doctype/payment_request/payment_request.json @@ -211,7 +211,7 @@ "label": "IBAN" }, { - "fetch_from": "bank.branch_code", + "fetch_from": "bank_account.branch_code", "fetch_if_empty": 1, "fieldname": "branch_code", "fieldtype": "Read Only", @@ -352,7 +352,7 @@ "in_create": 1, "is_submittable": 1, "links": [], - "modified": "2020-05-29 17:38:49.392713", + "modified": "2020-07-17 14:06:42.185763", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Request", diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 566b979ade..474c343e1f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -709,3 +709,4 @@ erpnext.patches.v13_0.move_payroll_setting_separately_from_hr_settings #22-06-20 erpnext.patches.v13_0.check_is_income_tax_component #22-06-2020 erpnext.patches.v12_0.add_taxjar_integration_field erpnext.patches.v12_0.update_item_tax_template_company +erpnext.patches.v13_0.move_branch_code_to_bank_account diff --git a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py index 1ddbae6cd2..a670adebfd 100644 --- a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py +++ b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py @@ -7,8 +7,7 @@ def execute(): if frappe.db.table_exists('Bank') and frappe.db.table_exists('Bank Account') and frappe.db.has_column('Bank Account', 'swift_number'): frappe.db.sql(""" UPDATE `tabBank` b, `tabBank Account` ba - SET b.swift_number = ba.swift_number, b.branch_code = ba.branch_code - WHERE b.name = ba.bank + SET b.swift_number = ba.swift_number WHERE b.name = ba.bank """) frappe.reload_doc('accounts', 'doctype', 'bank_account') diff --git a/erpnext/patches/v13_0/move_branch_code_to_bank_account.py b/erpnext/patches/v13_0/move_branch_code_to_bank_account.py new file mode 100644 index 0000000000..833ae2a48f --- /dev/null +++ b/erpnext/patches/v13_0/move_branch_code_to_bank_account.py @@ -0,0 +1,17 @@ +# Copyright (c) 2019, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +import frappe + +def execute(): + + frappe.reload_doc('accounts', 'doctype', 'bank_account') + frappe.reload_doc('accounts', 'doctype', 'bank') + + if frappe.db.has_column('Bank', 'branch_code') and frappe.db.has_column('Bank Account', 'branch_code'): + frappe.db.sql("""UPDATE `tabBank` b, `tabBank Account` ba + SET ba.branch_code = b.branch_code + WHERE ba.bank = b.name AND + ifnull(b.branch_code, '') != '' AND ifnull(ba.branch_code, '') = ''""") \ No newline at end of file From d45ff31ff08465f19fd263889499bcd993e355ab Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 22 Jul 2020 18:24:01 +0530 Subject: [PATCH 22/22] fix: incorrect stock after merging the items (#22526) * fix: incorrect stock after merging items * fix: Readability fix Co-authored-by: Marica --- erpnext/stock/doctype/item/item.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index a75ee67ec4..d5f479ff82 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) from frappe.utils.html_utils import clean_html from frappe.website.doctype.website_slideshow.website_slideshow import \ get_slideshow @@ -634,6 +634,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 +659,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} :
" + .format(frappe.bold(old_name), frappe.bold(new_name), document)) + + msg += ', '.join([get_link_to_form("Stock Reconciliation", d.parent) for d in records]) + "

" + + msg += _("Note: To merge the items, create a separate Stock Reconciliation for the old item {0}" + .format(frappe.bold(old_name))) + + frappe.throw(_(msg), title=_("Merge not allowed")) + def set_last_purchase_rate(self, new_name): last_purchase_rate = get_last_purchase_details(new_name).get("base_net_rate", 0) frappe.db.set_value("Item", new_name, "last_purchase_rate", last_purchase_rate)