Fix bugs in report generation

This commit is contained in:
Tanner Collin 2018-06-22 18:05:27 +00:00
parent 18510cc0b2
commit 3fac4591a1

View File

@ -130,7 +130,7 @@ def shift_filter(get_self):
| Q(price__management__provider__user__username=user)) \
.order_by('provider_approved', 'set_start')
if completed is not 'unspecified':
shifts = shifts.exclude(actual_end__isnull=completed)
shifts = shifts.exclude(actual_end__isnull=completed) # leave actual_end
if provider_approved is not 'unspecified':
shifts = shifts.filter(provider_approved=provider_approved)
if manage:
@ -183,13 +183,13 @@ def gen_timesheets(user, payday, manage=None):
timesheets = []
shifts = Shift.objects.filter(deleted=False) \
.exclude(actual_end__isnull=True) \
.exclude(approved_end__isnull=True) \
.filter(
Q(price__management__client__user__username=user)
| Q(price__management__provider__user__username=user)) \
.filter(approved_date=paystart) \
.filter(approved_date=payend) \
.order_by('price__management', 'actual_start')
.filter(approved_date__gte=paystart) \
.filter(approved_date__lte=payend) \
.order_by('price__management', 'approved_start')
if manage:
shifts = shifts.filter(price__management__uuid=manage)
@ -208,8 +208,8 @@ def gen_timesheets(user, payday, manage=None):
for s in shifts:
shift = {}
shift['date'] = s.approved_date
shift['start'] = s.actual_start
shift['end'] = s.actual_end
shift['start'] = s.approved_start
shift['end'] = s.approved_end
shift['hours'] = (shift['end'] - shift['start']).total_seconds() / 3600
shift['rate'] = s.set_price
shift['amount'] = Decimal(shift['hours']) * shift['rate']