-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
19 changes: 19 additions & 0 deletions
19
one_fm/uniform_management/report/uniform_expiry_report/uniform_expiry_report.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2024, omar jaber and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.query_reports["Uniform Expiry Report"] = { | ||
"filters": [ | ||
{ | ||
"fieldname":"employee", | ||
"label": __("Employee"), | ||
"fieldtype": "Link", | ||
"options": "Employee" | ||
}, | ||
{ | ||
"fieldname":"issued_before", | ||
"label": __("Issued Before"), | ||
"fieldtype": "Date", | ||
"default": frappe.datetime.now_date() | ||
} | ||
] | ||
}; |
38 changes: 38 additions & 0 deletions
38
one_fm/uniform_management/report/uniform_expiry_report/uniform_expiry_report.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"add_total_row": 1, | ||
"columns": [], | ||
"creation": "2024-11-11 22:02:06.810863", | ||
"disabled": 0, | ||
"docstatus": 0, | ||
"doctype": "Report", | ||
"filters": [], | ||
"idx": 0, | ||
"is_standard": "Yes", | ||
"letterhead": null, | ||
"modified": "2024-11-11 22:02:13.596538", | ||
"modified_by": "Administrator", | ||
"module": "Uniform Management", | ||
"name": "Uniform Expiry Report", | ||
"owner": "Administrator", | ||
"prepared_report": 0, | ||
"ref_doctype": "Employee Uniform", | ||
"report_name": "Uniform Expiry Report", | ||
"report_type": "Script Report", | ||
"roles": [ | ||
{ | ||
"role": "System Manager" | ||
}, | ||
{ | ||
"role": "Purchase Manager" | ||
}, | ||
{ | ||
"role": "Accounts Manager" | ||
}, | ||
{ | ||
"role": "Warehouse Maintainer" | ||
}, | ||
{ | ||
"role": "Purchase Officer" | ||
} | ||
] | ||
} |
60 changes: 60 additions & 0 deletions
60
one_fm/uniform_management/report/uniform_expiry_report/uniform_expiry_report.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright (c) 2024, omar jaber and contributors | ||
# For license information, please see license.txt | ||
|
||
from __future__ import unicode_literals | ||
import frappe | ||
from frappe import _ | ||
from frappe.utils import today, getdate, month_diff, date_diff | ||
|
||
def execute(filters=None): | ||
filters = frappe._dict(filters or {}) | ||
columns, data = get_columns(), get_data(filters) | ||
return columns, data | ||
|
||
def get_columns(): | ||
return [ | ||
_("Employee ID") + ":Data:130", | ||
_("Employee Name") + ":Data:180", | ||
_("Employee Status") + ":Data:140", | ||
_("Designation") + ":Link/Designation:120", | ||
_("Item Code") + ":Link/Item:180", | ||
_("Item Name") + ":Data:180", | ||
_("Issued On") + ":Date:130", | ||
_("Warehouse") + ":Link/Warehouse:120", | ||
_("Expire On") + ":Date:120", | ||
_("Days Left for Expiry") + ":Data:180", | ||
_("Issued Qty") + ":Data:120", | ||
_("Returned Qty") + ":Data:120" | ||
] | ||
|
||
def get_data(filters): | ||
data=[] | ||
conditions = [] | ||
|
||
query = """ | ||
select | ||
u.employee, u.employee_id, u.employee_name, ui.item, ui.item_name, ui.issued_on, ui.quantity, | ||
ui.returned, ui.rate, ui.expire_on, u.designation, u.warehouse | ||
from | ||
`tabEmployee Uniform` u, `tabEmployee Uniform Item` ui | ||
where | ||
u.name = ui.parent and u.type='Issue' and u.docstatus = 1 and ui.quantity > ui.returned | ||
""" | ||
|
||
if filters.employee: | ||
query += "and u.employee = '%s' "%filters.employee | ||
|
||
if filters.issued_before: | ||
query += "and u.issued_on <= '%s' "%filters.issued_before | ||
|
||
uniform_list=frappe.db.sql(query,as_dict=1) | ||
for uniform in uniform_list: | ||
employee_status = frappe.db.get_value("Employee", uniform.employee, "status") | ||
days_left_for_expiry = date_diff(uniform.expire_on, getdate()) | ||
row = [ | ||
uniform.employee_id, uniform.employee_name, employee_status, uniform.designation, uniform.item, uniform.item_name, | ||
uniform.issued_on, uniform.warehouse, uniform.expire_on, days_left_for_expiry, uniform.quantity, uniform.returned | ||
] | ||
data.append(row) | ||
|
||
return data |