From 01c19d3b933907d124e112e5cb8f30dff8f126dd Mon Sep 17 00:00:00 2001 From: Saqib Date: Wed, 6 Nov 2019 14:41:16 +0530 Subject: [PATCH] internal issues (#19496) * fix: user remark mandatory in quick entry but not in form * fix: preview salary slip btn showing in draft and unsaved states * minor: removed unecessay comma * fix: department analytics report showing departments of all companies --- .../accounts/doctype/journal_entry/journal_entry.js | 2 +- .../hr/doctype/salary_structure/salary_structure.js | 10 ++++++---- .../hr/doctype/salary_structure/salary_structure.py | 7 ++++++- .../department_analytics/department_analytics.js | 10 ++++++++++ .../department_analytics/department_analytics.py | 9 ++++++++- .../doctype/production_plan/production_plan.js | 2 +- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 11d847d821e..221e3a72803 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -570,7 +570,7 @@ $.extend(erpnext.journal_entry, { }, {fieldtype: "Date", fieldname: "posting_date", label: __("Date"), reqd: 1, default: frm.doc.posting_date}, - {fieldtype: "Small Text", fieldname: "user_remark", label: __("User Remark"), reqd: 1}, + {fieldtype: "Small Text", fieldname: "user_remark", label: __("User Remark")}, {fieldtype: "Select", fieldname: "naming_series", label: __("Series"), reqd: 1, options: naming_series_options, default: naming_series_default}, ] diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js index d56320a0732..dd34ef2ae2c 100755 --- a/erpnext/hr/doctype/salary_structure/salary_structure.js +++ b/erpnext/hr/doctype/salary_structure/salary_structure.js @@ -46,10 +46,12 @@ frappe.ui.form.on('Salary Structure', { frm.trigger("toggle_fields"); frm.fields_dict['earnings'].grid.set_column_disp("default_amount", false); frm.fields_dict['deductions'].grid.set_column_disp("default_amount", false); - - frm.add_custom_button(__("Preview Salary Slip"), function() { - frm.trigger('preview_salary_slip'); - }); + + if(frm.doc.docstatus === 1) { + frm.add_custom_button(__("Preview Salary Slip"), function() { + frm.trigger('preview_salary_slip'); + }); + } if(frm.doc.docstatus==1) { frm.add_custom_button(__("Assign Salary Structure"), function() { diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index f7d712d3f16..0e1a74f3702 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -169,5 +169,10 @@ def make_salary_slip(source_name, target_doc = None, employee = None, as_print = @frappe.whitelist() def get_employees(salary_structure): employees = frappe.get_list('Salary Structure Assignment', - filters={'salary_structure': salary_structure}, fields=['employee']) + filters={'salary_structure': salary_structure, 'docstatus': 1}, fields=['employee']) + + if not employees: + frappe.throw(_("There's no Employee with Salary Structure: {0}. \ + Assign {1} to an Employee to preview Salary Slip").format(salary_structure, salary_structure)) + return list(set([d.employee for d in employees])) diff --git a/erpnext/hr/report/department_analytics/department_analytics.js b/erpnext/hr/report/department_analytics/department_analytics.js index a0b6fc76412..29fedcd7350 100644 --- a/erpnext/hr/report/department_analytics/department_analytics.js +++ b/erpnext/hr/report/department_analytics/department_analytics.js @@ -2,4 +2,14 @@ // For license information, please see license.txt frappe.query_reports["Department Analytics"] = { + "filters": [ + { + "fieldname":"company", + "label": __("Company"), + "fieldtype": "Link", + "options": "Company", + "default": frappe.defaults.get_user_default("Company"), + "reqd": 1 + }, + ] }; \ No newline at end of file diff --git a/erpnext/hr/report/department_analytics/department_analytics.py b/erpnext/hr/report/department_analytics/department_analytics.py index c4a9030c591..b28eac43f8b 100644 --- a/erpnext/hr/report/department_analytics/department_analytics.py +++ b/erpnext/hr/report/department_analytics/department_analytics.py @@ -7,6 +7,10 @@ from frappe import _ def execute(filters=None): if not filters: filters = {} + + if not filters["company"]: + frappe.throw(_('{0} is mandatory').format(_('Company'))) + columns = get_columns() employees = get_employees(filters) departments_result = get_department(filters) @@ -28,6 +32,9 @@ def get_conditions(filters): conditions = "" if filters.get("department"): conditions += " and department = '%s'" % \ filters["department"].replace("'", "\\'") + + if filters.get("company"): conditions += " and company = '%s'" % \ + filters["company"].replace("'", "\\'") return conditions def get_employees(filters): @@ -37,7 +44,7 @@ def get_employees(filters): gender, company from `tabEmployee` where status = 'Active' %s""" % conditions, as_list=1) def get_department(filters): - return frappe.db.sql("""select name from `tabDepartment`""" , as_list=1) + return frappe.db.sql("""select name from `tabDepartment` where company = %s""", (filters["company"]), as_list=1) def get_chart_data(departments,employees): if not departments: diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js index 4b654b47e67..96bb0ae37f9 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.js +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js @@ -233,7 +233,7 @@ frappe.ui.form.on('Production Plan', { if (item_wise_qty) { for (var key in item_wise_qty) { - title += __('Item {0}: {1} qty produced, ', [key, item_wise_qty[key]]); + title += __('Item {0}: {1} qty produced. ', [key, item_wise_qty[key]]); } }