Skip to content

Commit

Permalink
feat: sort timesheets by start time
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra authored and sagarvora committed Oct 2, 2021
1 parent 49a765f commit 536e0e8
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions erpnext/projects/doctype/timesheet/timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ def update_time_rates(self, ts_detail):

@frappe.whitelist()
def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to_time=None):
condition = ''
condition = ""
if project:
condition += "and tsd.project = %(project)s"
condition += "AND tsd.project = %(project)s "
if parent:
condition += "AND tsd.parent = %(parent)s"
condition += "AND tsd.parent = %(parent)s "
if from_time and to_time:
condition += "AND CAST(tsd.from_time as DATE) BETWEEN %(from_time)s AND %(to_time)s"

return frappe.db.sql("""
query = f"""
SELECT
tsd.name as name,
Expand All @@ -241,16 +241,25 @@ def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to
INNER JOIN `tabTimesheet` ts
ON ts.name = tsd.parent
WHERE tsd.parenttype = 'Timesheet'
AND tsd.docstatus=1 {0}
WHERE
tsd.parenttype = 'Timesheet'
AND tsd.docstatus = 1
AND tsd.is_billable = 1
AND tsd.sales_invoice is null
""".format(condition), {
'project': project,
'parent': parent,
'from_time': from_time,
'to_time': to_time
}, as_dict=1)
AND tsd.sales_invoice is NULL
{condition}
ORDER BY tsd.from_time ASC
"""

filters = {
"project": project,
"parent": parent,
"from_time": from_time,
"to_time": to_time
}

return frappe.db.sql(query, filters, as_dict=1)

@frappe.whitelist()
def get_timesheet_detail_rate(timelog, currency):
Expand Down

0 comments on commit 536e0e8

Please sign in to comment.