From 17fbafa390b806b0053da1c713b07743033e956d Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Tue, 9 Apr 2019 11:31:11 +0530 Subject: [PATCH 1/3] 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 }, ] From 3e8b8a4359415cc2741c1a37e5ece45fae5c27cd Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Tue, 9 Apr 2019 14:34:56 +0530 Subject: [PATCH 2/3] fix: filters and some conditions --- erpnext/projects/report/billing_summary.py | 2 +- .../report/employee_billing_summary/employee_billing_summary.js | 2 +- .../report/project_billing_summary/project_billing_summary.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/projects/report/billing_summary.py b/erpnext/projects/report/billing_summary.py index e17a88951d..d6801c87c3 100644 --- a/erpnext/projects/report/billing_summary.py +++ b/erpnext/projects/report/billing_summary.py @@ -71,7 +71,7 @@ def get_data(filters): from_date = frappe.utils.get_datetime(filters.from_date) to_date = frappe.utils.get_datetime(filters.to_date) - if time_start <= from_date and time_end <= to_date: + if time_start <= from_date and time_end >= from_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) 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 87a043c80d..13f49ed6be 100644 --- a/erpnext/projects/report/employee_billing_summary/employee_billing_summary.js +++ b/erpnext/projects/report/employee_billing_summary/employee_billing_summary.js @@ -22,7 +22,7 @@ frappe.query_reports["Employee Billing Summary"] = { fieldname:"to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.month_start(), + default: frappe.datetime.add_days(frappe.datetime.month_start(), -1), 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 614903c032..caac1d86b4 100644 --- a/erpnext/projects/report/project_billing_summary/project_billing_summary.js +++ b/erpnext/projects/report/project_billing_summary/project_billing_summary.js @@ -22,7 +22,7 @@ frappe.query_reports["Project Billing Summary"] = { fieldname:"to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.month_start(), + default: frappe.datetime.add_days(frappe.datetime.month_start(),-1), reqd: 1 }, ] From 22867f7fa5ee6a3c9e3c1768ece6d2f14197e58f Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Tue, 9 Apr 2019 15:06:49 +0530 Subject: [PATCH 3/3] fix: added currency --- erpnext/projects/report/billing_summary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/projects/report/billing_summary.py b/erpnext/projects/report/billing_summary.py index d6801c87c3..80bf926a54 100644 --- a/erpnext/projects/report/billing_summary.py +++ b/erpnext/projects/report/billing_summary.py @@ -44,7 +44,7 @@ def get_columns(): }, { "label": _("Amount"), - "fieldtype": "Float", + "fieldtype": "Currency", "fieldname": "amount", "width": 100 }