From c518e8be12227088fef6cb9c4dd95d419371ce89 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 13 May 2013 15:59:50 +0530 Subject: [PATCH 1/3] [report] monthly attendance sheet --- hr/page/hr_home/hr_home.js | 4 + .../monthly_attendance_sheet/__init__.py | 0 .../monthly_attendance_sheet.js | 32 ++++++ .../monthly_attendance_sheet.py | 107 ++++++++++++++++++ .../monthly_attendance_sheet.txt | 22 ++++ 5 files changed, 165 insertions(+) create mode 100644 hr/report/monthly_attendance_sheet/__init__.py create mode 100644 hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js create mode 100644 hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py create mode 100644 hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js index 8a501846b1..e35a80849b 100644 --- a/hr/page/hr_home/hr_home.js +++ b/hr/page/hr_home/hr_home.js @@ -181,6 +181,10 @@ wn.module_page["HR"] = [ "label":wn._("Monthly Salary Register"), route: "query-report/Monthly Salary Register" }, + { + "label":wn._("Monthly Attendance Sheet"), + route: "query-report/Monthly Attendance Sheet" + }, ] } ]; diff --git a/hr/report/monthly_attendance_sheet/__init__.py b/hr/report/monthly_attendance_sheet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js new file mode 100644 index 0000000000..6dc8d78ea5 --- /dev/null +++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js @@ -0,0 +1,32 @@ +wn.query_reports["Monthly Attendance Sheet"] = { + "filters": [ + { + "fieldname":"month", + "label": "Month", + "fieldtype": "Select", + "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", + "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()], + }, + { + "fieldname":"fiscal_year", + "label": "Fiscal Year", + "fieldtype": "Link", + "options": "Fiscal Year", + "default": sys_defaults.fiscal_year, + }, + { + "fieldname":"employee", + "label": "Employee", + "fieldtype": "Link", + "options": "Employee" + }, + { + "fieldname":"company", + "label": "Company", + "fieldtype": "Link", + "options": "Company", + "default": sys_defaults.company + } + ] +} \ No newline at end of file diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py new file mode 100644 index 0000000000..520f6e93e6 --- /dev/null +++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py @@ -0,0 +1,107 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cstr, cint +from webnotes import msgprint, _ + +def execute(filters=None): + if not filters: filters = {} + + conditions, filters = get_conditions(filters) + columns = get_columns(filters) + att_map = get_attendance_list(conditions, filters) + emp_map = get_employee_details() + + data = [] + for emp in sorted(att_map): + emp_det = emp_map.get(emp) + row = [emp, emp_det.employee_name, emp_det.branch, emp_det.department, emp_det.designation, + emp_det.company] + + total_p = total_a = 0.0 + for day in range(filters["total_days_in_month"]): + status = att_map.get(emp).get(day + 1, "Absent") + status_map = {"Present": "P", "Absent": "A", "Half Day": "HD"} + row.append(status_map[status]) + + if status == "Present": + total_p += 1 + elif status == "Absent": + total_a += 1 + elif status == "Half Day": + total_p += 0.5 + total_a += 0.5 + + row += [total_p, total_a] + + data.append(row) + + return columns, data + +def get_columns(filters): + columns = [ + "Employee:Link/Employee:120", "Employee Name::140", "Branch:Link/Branch:120", + "Department:Link/Department:120", "Designation:Link/Designation:120", + "Company:Link/Company:120" + ] + + for day in range(filters["total_days_in_month"]): + columns.append(cstr(day+1) +"::20") + + columns += ["Total Present:Float:80", "Total Absent:Float:80"] + return columns + +def get_attendance_list(conditions, filters): + attendance_list = webnotes.conn.sql("""select employee, day(att_date) as day_of_month, + status from tabAttendance where docstatus < 2 %s order by employee, att_date""" % + conditions, filters, as_dict=1) + + att_map = {} + for d in attendance_list: + att_map.setdefault(d.employee, webnotes._dict()).setdefault(d.day_of_month, "") + att_map[d.employee][d.day_of_month] = d.status + + return att_map + +def get_conditions(filters): + if not (filters.get("month") and filters.get("fiscal_year")): + msgprint(_("Please select month and year"), raise_exception=1) + + filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"].index(filters["month"]) + 1 + + from calendar import monthrange + filters["total_days_in_month"] = monthrange(cint(filters["fiscal_year"].split("-")[-1]), + filters["month"])[1] + + conditions = " and month(att_date) = %(month)s and fiscal_year = %(fiscal_year)s" + + if filters.get("company"): conditions += " and company = %(company)s" + if filters.get("employee"): conditions += " and employee = %(employee)s" + + return conditions, filters + +def get_employee_details(): + employee = webnotes.conn.sql("""select name, employee_name, designation, department, + branch, company from tabEmployee where docstatus < 2 and status = 'Active'""", as_dict=1) + + emp_map = {} + for emp in employee: + emp_map[emp.name] = emp + + return emp_map \ No newline at end of file diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt new file mode 100644 index 0000000000..3c53aae8e4 --- /dev/null +++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-13 14:04:03", + "docstatus": 0, + "modified": "2013-05-13 14:32:42", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 0, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Attendance", + "report_name": "Monthly Attendance Sheet", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Monthly Attendance Sheet" + } +] \ No newline at end of file From da369d8eee25a7388c53b77fa12f9fe2fa7e33c3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 13 May 2013 16:29:28 +0530 Subject: [PATCH 2/3] [report] requested qty to be ordered --- buying/page/buying_home/buying_home.js | 4 ++++ .../requested_items_to_be_ordered/__init__.py | 0 .../requested_items_to_be_ordered.txt | 23 +++++++++++++++++++ .../monthly_attendance_sheet.py | 2 +- stock/page/stock_home/stock_home.js | 4 ++++ .../purchase_order_items_to_be_received.txt | 7 +++--- 6 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 buying/report/requested_items_to_be_ordered/__init__.py create mode 100644 buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index e7532dda2e..2070fd4e33 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -111,6 +111,10 @@ wn.module_page["Buying"] = [ "label":wn._("Purchase In Transit"), route: "query-report/Purchase In Transit", }, + { + "label":wn._("Requested Items To Be Ordered"), + route: "query-report/Requested Items To Be Ordered", + }, ] } ] diff --git a/buying/report/requested_items_to_be_ordered/__init__.py b/buying/report/requested_items_to_be_ordered/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt new file mode 100644 index 0000000000..49c747854a --- /dev/null +++ b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-13 16:10:02", + "docstatus": 0, + "modified": "2013-05-13 16:21:07", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Ordered Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc", + "ref_doctype": "Purchase Order", + "report_name": "Requested Items To Be Ordered", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Requested Items To Be Ordered" + } +] \ No newline at end of file diff --git a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py index 520f6e93e6..42a977025a 100644 --- a/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py +++ b/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py @@ -68,7 +68,7 @@ def get_columns(filters): def get_attendance_list(conditions, filters): attendance_list = webnotes.conn.sql("""select employee, day(att_date) as day_of_month, - status from tabAttendance where docstatus < 2 %s order by employee, att_date""" % + status from tabAttendance where docstatus = 1 %s order by employee, att_date""" % conditions, filters, as_dict=1) att_map = {} diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index bfcaf8acc1..75e4ee15b0 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -201,6 +201,10 @@ wn.module_page["Stock"] = [ "label":wn._("Purchase In Transit"), route: "query-report/Purchase In Transit", }, + { + "label":wn._("Requested Items To Be Transferred"), + route: "query-report/Requested Items To Be Transferred", + }, ] } ] diff --git a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt index 45e3a42dee..7a2f6365bf 100644 --- a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt +++ b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt @@ -1,16 +1,17 @@ [ { - "creation": "2013-02-21 14:26:49", + "creation": "2013-02-22 18:01:55", "docstatus": 0, - "modified": "2013-02-22 15:53:01", + "modified": "2013-05-13 16:11:27", "modified_by": "Administrator", "owner": "Administrator" }, { + "add_total_row": 1, "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n `tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n `tabPurchase Order`.`project_name` as \"Project\",\n `tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n `tabPurchase Order Item`.qty as \"Qty:Float:100\",\n `tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n (`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n `tabPurchase Order Item`.item_name as \"Item Name::150\",\n `tabPurchase Order Item`.description as \"Description::200\"\nfrom\n `tabPurchase Order`, `tabPurchase Order Item`\nwhere\n `tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n and `tabPurchase Order`.docstatus = 1\n and `tabPurchase Order`.status != \"Stopped\"\n and ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", + "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", "ref_doctype": "Purchase Receipt", "report_name": "Purchase Order Items To Be Received", "report_type": "Query Report" From ece32981597d436481a1bf91d82ccd0fc47da0c1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 13 May 2013 16:29:50 +0530 Subject: [PATCH 3/3] [report] requested qty to be transferred --- .../__init__.py | 0 .../requested_items_to_be_transferred.txt | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 stock/report/requested_items_to_be_transferred/__init__.py create mode 100644 stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt diff --git a/stock/report/requested_items_to_be_transferred/__init__.py b/stock/report/requested_items_to_be_transferred/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt b/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt new file mode 100644 index 0000000000..030ed242d8 --- /dev/null +++ b/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-13 16:23:05", + "docstatus": 0, + "modified": "2013-05-13 16:25:08", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Transferred Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Transfer:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Transfer\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc", + "ref_doctype": "Stock Entry", + "report_name": "Requested Items To Be Transferred", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Requested Items To Be Transferred" + } +] \ No newline at end of file