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
|
"width": 150
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Total Billable Hours"),
|
"label": _("Billable Hours"),
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Float",
|
||||||
"fieldname": "total_billable_hours",
|
"fieldname": "total_billable_hours",
|
||||||
"width": 50
|
"width": 50
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Total Hours"),
|
"label": _("Working Hours"),
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Float",
|
||||||
"fieldname": "total_hours",
|
"fieldname": "total_hours",
|
||||||
"width": 50
|
"width": 50
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Amount"),
|
"label": _("Amount"),
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Float",
|
||||||
"fieldname": "amount",
|
"fieldname": "amount",
|
||||||
"width": 100
|
"width": 100
|
||||||
}
|
}
|
||||||
@ -54,12 +54,16 @@ def get_data(filters):
|
|||||||
data = []
|
data = []
|
||||||
record = get_records(filters)
|
record = get_records(filters)
|
||||||
|
|
||||||
|
billable_hours_worked = 0
|
||||||
|
hours_worked = 0
|
||||||
|
working_cost = 0
|
||||||
for entries in record:
|
for entries in record:
|
||||||
total_hours = 0
|
total_hours = 0
|
||||||
total_billable_hours = 0
|
total_billable_hours = 0
|
||||||
total_amount = 0
|
total_amount = 0
|
||||||
entries_exists = False
|
entries_exists = False
|
||||||
timesheet_details = get_timesheet_details(filters, entries.name)
|
timesheet_details = get_timesheet_details(filters, entries.name)
|
||||||
|
|
||||||
for activity in timesheet_details:
|
for activity in timesheet_details:
|
||||||
entries_exists = True
|
entries_exists = True
|
||||||
time_start = activity.from_time
|
time_start = activity.from_time
|
||||||
@ -70,13 +74,25 @@ def get_data(filters):
|
|||||||
if time_start <= from_date and time_end <= to_date:
|
if time_start <= from_date and time_end <= to_date:
|
||||||
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
||||||
time_end, from_date, total_hours, total_billable_hours, total_amount)
|
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:
|
elif time_start >= from_date and time_end >= to_date:
|
||||||
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
||||||
to_date, time_start, total_hours, total_billable_hours, total_amount)
|
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:
|
elif time_start >= from_date and time_end <= to_date:
|
||||||
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
||||||
time_end, time_start, total_hours, total_billable_hours, total_amount)
|
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 = {
|
row = {
|
||||||
"employee": entries.employee,
|
"employee": entries.employee,
|
||||||
"employee_name": entries.employee_name,
|
"employee_name": entries.employee_name,
|
||||||
@ -90,12 +106,20 @@ def get_data(filters):
|
|||||||
data.append(row)
|
data.append(row)
|
||||||
entries_exists = False
|
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
|
return data
|
||||||
|
|
||||||
def get_records(filters):
|
def get_records(filters):
|
||||||
record_filters = [
|
record_filters = [
|
||||||
["start_date", "<=", filters.to_date],
|
["start_date", "<=", filters.to_date],
|
||||||
["end_date", ">=", filters.from_date]
|
["end_date", ">=", filters.from_date],
|
||||||
|
["docstatus", "=", 1]
|
||||||
]
|
]
|
||||||
|
|
||||||
if "employee" in filters:
|
if "employee" in filters:
|
||||||
|
@ -15,14 +15,14 @@ frappe.query_reports["Employee Billing Summary"] = {
|
|||||||
fieldname:"from_date",
|
fieldname:"from_date",
|
||||||
label: __("From Date"),
|
label: __("From Date"),
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: frappe.datetime.get_today(),
|
default: frappe.datetime.add_months(frappe.datetime.month_start(), -1),
|
||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname:"to_date",
|
fieldname:"to_date",
|
||||||
label: __("To Date"),
|
label: __("To Date"),
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: frappe.datetime.add_days(frappe.datetime.get_today(), 30),
|
default: frappe.datetime.month_start(),
|
||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -15,14 +15,14 @@ frappe.query_reports["Project Billing Summary"] = {
|
|||||||
fieldname:"from_date",
|
fieldname:"from_date",
|
||||||
label: __("From Date"),
|
label: __("From Date"),
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: frappe.datetime.get_today(),
|
default: frappe.datetime.add_months(frappe.datetime.month_start(), -1),
|
||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname:"to_date",
|
fieldname:"to_date",
|
||||||
label: __("To Date"),
|
label: __("To Date"),
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: frappe.datetime.add_days(frappe.datetime.get_today(), 30),
|
default: frappe.datetime.month_start(),
|
||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user