added Monthly Absence Report
This commit is contained in:
parent
51fd779a22
commit
ae7b0f5d17
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) 2024, Company and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.query_reports["Monthly Absence Report"] = {
|
||||
"filters": [
|
||||
{
|
||||
fieldname: "company",
|
||||
label: __("Şirkət"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_user_default("Company")
|
||||
},
|
||||
{
|
||||
fieldname: "from_date",
|
||||
label: __("Tarixdən"),
|
||||
fieldtype: "Date",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1)
|
||||
},
|
||||
{
|
||||
fieldname: "to_date",
|
||||
label: __("Tarixə qədər"),
|
||||
fieldtype: "Date",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.get_today()
|
||||
}
|
||||
],
|
||||
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (!data || column.fieldname !== "days_absent") return value;
|
||||
|
||||
if (data.days_absent > 10) {
|
||||
value = "<span style='color: #d62728; font-weight: bold;'>" + value + "</span>";
|
||||
} else if (data.days_absent >= 5) {
|
||||
value = "<span style='color: #ff7f0e; font-weight: bold;'>" + value + "</span>";
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"add_total_row": 0,
|
||||
"columns": [],
|
||||
"creation": "2026-03-19 00:00:00.000000",
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"filters": [],
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2026-03-19 00:00:00.000000",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Taxes Az",
|
||||
"name": "Monthly Absence Report",
|
||||
"owner": "Administrator",
|
||||
"ref_doctype": "Attendance",
|
||||
"report_name": "Monthly Absence Report",
|
||||
"report_type": "Script Report",
|
||||
"roles": []
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# Copyright (c) 2024, Company and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
|
||||
def execute(filters=None):
|
||||
columns = get_columns()
|
||||
data = get_data(filters)
|
||||
return columns, data
|
||||
|
||||
|
||||
def get_columns():
|
||||
return [
|
||||
{
|
||||
"label": _("Sıra №"),
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"options": "Employee",
|
||||
"width": 120
|
||||
},
|
||||
{
|
||||
"label": _("İşçi adı"),
|
||||
"fieldname": "employee_name",
|
||||
"fieldtype": "Data",
|
||||
"width": 200
|
||||
},
|
||||
{
|
||||
"label": _("Qayıb günlər"),
|
||||
"fieldname": "days_absent",
|
||||
"fieldtype": "Int",
|
||||
"width": 120
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def get_data(filters):
|
||||
if not filters:
|
||||
filters = {}
|
||||
|
||||
return frappe.db.sql("""
|
||||
SELECT
|
||||
a.employee,
|
||||
a.employee_name,
|
||||
COUNT(*) as days_absent
|
||||
FROM `tabAttendance` a
|
||||
WHERE
|
||||
a.docstatus = 1
|
||||
AND a.status = 'Absent'
|
||||
AND a.company = %(company)s
|
||||
AND a.attendance_date >= %(from_date)s
|
||||
AND a.attendance_date <= %(to_date)s
|
||||
GROUP BY a.employee, a.employee_name
|
||||
ORDER BY days_absent DESC, a.employee_name ASC
|
||||
""", filters, as_dict=1)
|
||||
Loading…
Reference in New Issue