blob: ae7a9ff51af55e5981de52c8f0d78f438fbbd21f [file] [log] [blame]
Anurag Mishra289c8222020-06-19 19:17:57 +05301# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4import frappe
5import erpnext
6from erpnext.hr.dashboard_fixtures import get_dashboards_chart_doc, get_number_cards_doc
7import json
8from frappe import _
9
10def get_data():
11 return frappe._dict({
12 "dashboards": get_dashboards(),
13 "charts": get_charts(),
14 "number_cards": get_number_cards(),
15 })
16
17def get_dashboards():
18 dashboards = []
19 dashboards.append(get_payroll_dashboard())
20 return dashboards
21
22def get_payroll_dashboard():
23 return {
24 "name": "Payroll",
25 "dashboard_name": "Payroll",
26 "is_default": 1,
27 "charts": [
28 { "chart": "Outgoing Salary", "width": "Full"},
29 { "chart": "Designation Wise Salary(Last Month)", "width": "Half"},
30 { "chart": "Department Wise Salary(Last Month)", "width": "Half"},
31 ],
32 "cards": [
33 {"card": "Total Declaration Submitted"},
34 {"card": "Total Salary Structure"},
35 {"card": "Total Incentive Given(Last month)"},
36 {"card": "Total Outgoing Salary(Last month)"},
37 ]
38 }
39
40def get_charts():
41 dashboard_charts= [
42 get_dashboards_chart_doc('Outgoing Salary', "Sum", "Line",
43 document_type = "Salary Slip", based_on="end_date",
44 value_based_on = "rounded_total", time_interval = "Monthly", timeseries = 1,
45 filters_json = json.dumps([["Salary Slip", "docstatus", "=", 1]]))
46 ]
47
48 dashboard_charts.append(
49 get_dashboards_chart_doc('Department Wise Salary(Last Month)', "Group By", "Bar",
50 document_type = "Salary Slip", group_by_type="Sum", group_by_based_on="department",
51 time_interval = "Monthly", aggregate_function_based_on = "rounded_total",
52 filters_json = json.dumps([
53 ["Salary Slip", "docstatus", "=", 1],
54 ["Salary Slip", "start_date", "Previous","1 month"]
55 ])
56 )
57 )
58
59 dashboard_charts.append(
60 get_dashboards_chart_doc('Designation Wise Salary(Last Month)', "Group By", "Bar",
61 document_type = "Salary Slip", group_by_type="Sum", group_by_based_on="designation",
62 time_interval = "Monthly", aggregate_function_based_on = "rounded_total",
63 filters_json = json.dumps([
64 ["Salary Slip", "docstatus", "=", 1],
65 ["Salary Slip", "start_date", "Previous","1 month"]
66 ])
67 )
68 )
69
70 return dashboard_charts
71
72def get_number_cards():
73 number_cards = [get_number_cards_doc("Employee Tax Exemption Declaration", "Total Declaration Submitted", filters_json = json.dumps([
74 ["Employee Tax Exemption Declaration", "docstatus", "=","1"],
75 ["Employee Tax Exemption Declaration","creation","Previous","1 year"]
76 ])
77 )]
78
79 number_cards.append(get_number_cards_doc("Employee Incentive", "Total Incentive Given(Last month)",
80 time_interval = "Monthly", func = "Sum", aggregate_function_based_on = "incentive_amount",
81 filters_json = json.dumps([
82 ["Employee Incentive", "docstatus", "=", 1],
83 ["Employee Incentive","payroll_date","Previous","1 year"]
84 ]))
85 )
86
87 number_cards.append(get_number_cards_doc("Salary Slip", "Total Outgoing Salary(Last month)",
88 time_interval = "Monthly", time_span= "Monthly", func = "Sum", aggregate_function_based_on = "rounded_total",
89 filters_json = json.dumps([
90 ["Salary Slip", "docstatus", "=", 1],
91 ["Salary Slip", "start_date","Previous","1 month"]
92 ]))
93 )
94 number_cards.append(get_number_cards_doc("Salary Structure", "Total Salary Structure",
95 filters_json = json.dumps([
96 ["Salary Structure", "docstatus", "=", 1]
97 ]))
98 )
99
100 return number_cards