fix: filters,added total,only submitted doc,considered fraction
This commit is contained in:
parent
79c9d5d24a
commit
17fbafa390
@ -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:
|
||||
|
@ -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
|
||||
},
|
||||
]
|
||||
|
@ -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
|
||||
},
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user