From 17fbafa390b806b0053da1c713b07743033e956d Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Tue, 9 Apr 2019 11:31:11 +0530 Subject: [PATCH] fix: filters,added total,only submitted doc,considered fraction --- erpnext/projects/report/billing_summary.py | 36 +++++++++++++++---- .../employee_billing_summary.js | 4 +-- .../project_billing_summary.js | 4 +-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/erpnext/projects/report/billing_summary.py b/erpnext/projects/report/billing_summary.py index 214dcef8fd..e17a88951d 100644 --- a/erpnext/projects/report/billing_summary.py +++ b/erpnext/projects/report/billing_summary.py @@ -31,20 +31,20 @@ def get_columns(): "width": 150 }, { - "label": _("Total Billable Hours"), - "fieldtype": "Int", + "label": _("Billable Hours"), + "fieldtype": "Float", "fieldname": "total_billable_hours", "width": 50 }, { - "label": _("Total Hours"), - "fieldtype": "Int", + "label": _("Working Hours"), + "fieldtype": "Float", "fieldname": "total_hours", "width": 50 }, { "label": _("Amount"), - "fieldtype": "Int", + "fieldtype": "Float", "fieldname": "amount", "width": 100 } @@ -54,12 +54,16 @@ def get_data(filters): data = [] record = get_records(filters) + billable_hours_worked = 0 + hours_worked = 0 + working_cost = 0 for entries in record: total_hours = 0 total_billable_hours = 0 total_amount = 0 entries_exists = False timesheet_details = get_timesheet_details(filters, entries.name) + for activity in timesheet_details: entries_exists = True time_start = activity.from_time @@ -70,13 +74,25 @@ def get_data(filters): if time_start <= from_date and time_end <= to_date: total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity, time_end, from_date, total_hours, total_billable_hours, total_amount) + + billable_hours_worked += total_billable_hours + hours_worked += total_hours + working_cost += total_amount elif time_start >= from_date and time_end >= to_date: total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity, to_date, time_start, total_hours, total_billable_hours, total_amount) + + billable_hours_worked += total_billable_hours + hours_worked += total_hours + working_cost += total_amount elif time_start >= from_date and time_end <= to_date: total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity, time_end, time_start, total_hours, total_billable_hours, total_amount) + billable_hours_worked += total_billable_hours + hours_worked += total_hours + working_cost += total_amount + row = { "employee": entries.employee, "employee_name": entries.employee_name, @@ -90,12 +106,20 @@ def get_data(filters): data.append(row) entries_exists = False + total = { + "total_billable_hours": billable_hours_worked, + "total_hours": hours_worked, + "amount": working_cost + } + if billable_hours_worked !=0 or hours_worked !=0 or working_cost !=0: + data.append(total) return data def get_records(filters): record_filters = [ ["start_date", "<=", filters.to_date], - ["end_date", ">=", filters.from_date] + ["end_date", ">=", filters.from_date], + ["docstatus", "=", 1] ] if "employee" in filters: diff --git a/erpnext/projects/report/employee_billing_summary/employee_billing_summary.js b/erpnext/projects/report/employee_billing_summary/employee_billing_summary.js index 65c2a690cf..87a043c80d 100644 --- a/erpnext/projects/report/employee_billing_summary/employee_billing_summary.js +++ b/erpnext/projects/report/employee_billing_summary/employee_billing_summary.js @@ -15,14 +15,14 @@ frappe.query_reports["Employee Billing Summary"] = { fieldname:"from_date", label: __("From Date"), fieldtype: "Date", - default: frappe.datetime.get_today(), + default: frappe.datetime.add_months(frappe.datetime.month_start(), -1), reqd: 1 }, { fieldname:"to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.add_days(frappe.datetime.get_today(), 30), + default: frappe.datetime.month_start(), reqd: 1 }, ] diff --git a/erpnext/projects/report/project_billing_summary/project_billing_summary.js b/erpnext/projects/report/project_billing_summary/project_billing_summary.js index 62362c35cf..614903c032 100644 --- a/erpnext/projects/report/project_billing_summary/project_billing_summary.js +++ b/erpnext/projects/report/project_billing_summary/project_billing_summary.js @@ -15,14 +15,14 @@ frappe.query_reports["Project Billing Summary"] = { fieldname:"from_date", label: __("From Date"), fieldtype: "Date", - default: frappe.datetime.get_today(), + default: frappe.datetime.add_months(frappe.datetime.month_start(), -1), reqd: 1 }, { fieldname:"to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.add_days(frappe.datetime.get_today(), 30), + default: frappe.datetime.month_start(), reqd: 1 }, ]