Caleb Smith avatar Caleb Smith committed f987e48

Added invoiced hours to payroll report and summaries on my ledger page.

Comments (0)

Files changed (3)

timepiece/models.py

     def hours_in_week(self, date):
         left, right = utils.get_week_window(date)
         entries = Entry.worked.filter(user=self.user)
-        entries = entries.filter(end_time__gt=left,
-            end_time__lt=right, status='approved')
+        entries = entries.filter(
+            (Q(status='invoiced') | Q(status='approved')),
+            end_time__gt=left, end_time__lt=right,)
         return entries.aggregate(s=Sum('hours'))['s']
 
     def overtime_hours_in_week(self, date):
         """
         projects = getattr(settings, 'TIMEPIECE_PROJECTS', {})
         user = self.user
-        entries = user.timepiece_entries.filter(end_time__gt=date,
-                                                end_time__lte=end_date,
-                                                status='approved')
+        entries = user.timepiece_entries.filter(
+            (Q(status='invoiced') | Q(status='approved')),
+            end_time__gt=date, end_time__lte=end_date)
         data = {'billable': Decimal('0'), 'non_billable': Decimal('0')}
+        data['invoiced'] = entries.filter(
+            status='invoiced').aggregate(i=Sum('hours'))['i']
         data['total'] = entries.aggregate(s=Sum('hours'))['s']
+        data['uninvoiced'] = entries.exclude(
+            status='invoiced').aggregate(uninv=Sum('hours'))['uninv']
         billable = entries.exclude(project__in=projects.values())
         billable = billable.values(
             'billable',

timepiece/templates/timepiece/time-sheet/people/view.html

     </table>
 {% endif %}
 
-{% if activity_entries %}
-    <table id='activity-summary'>
-        <caption>Billable Summary</caption>
-    {% for row in activity_entries %}
-        <tr>
-            <td>{% if row.billable %}Billable{% else %}Non-billable{% endif %}</td>
-            <td>{{ row.sum }}</td>
-        </tr>
-    {% endfor %}        
-    </table>
-{% endif %}
+<table id='activity-summary'>
+    <caption>Billable Summary</caption>
+    <tr>
+        <td>Billable</td><td>{{summary.billable}}</td>
+    </tr>
+    <tr>
+        <td>Non-billable</td><td>{{summary.non_billable}}</td>
+    </tr>
+    <tr>
+        <td>Invoiced</td><td>{{summary.invoiced}}</td>
+    </tr>
+    <tr>
+        <td>Uninvoiced</td><td>{{summary.uninvoiced}}</td>
+    </tr>
+</table>
 
 <br style='clear: both' />
 

timepiece/views.py

     project_entries = entries.order_by().values(
         'project__name',
     ).annotate(sum=Sum('hours')).order_by('-sum')
-    activity_entries = entries.order_by().values(
-        'billable',
-    ).annotate(sum=Sum('hours')).order_by('-sum')
 
     show_approve = show_verify = False
     if request.user.has_perm('timepiece.edit_person_time_sheet') or \
         show_approve = verified_count + approved_count == total_statuses \
         and verified_count > 0 and total_statuses != 0
 
+    summary = time_sheet.summary(window.date, window.end_date)
+
     context = {
         'show_verify': show_verify,
         'show_approve': show_approve,
         'entries': entries,
         'total': total_hours,
         'project_entries': project_entries,
-        'activity_entries': activity_entries,
+        'summary': summary,
     }
     return context
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.