caktus / django-timepiece

A multi-user Django application for tracking people's time on projects.
MIT License
361 stars 112 forks source link

Adding backend rounding function to HourGroupManager summaries method #863

Closed nmashton closed 8 years ago

nmashton commented 8 years ago

The InvoiceDetail view's billable_totals and nonbillable_totals make use of the summaries method on the HourGroupManager. This serves up a sum of all hours values on a bundle of entries by calling the SUM function in the DB.

We want the hours in the (non)billable_totals to reflect the rounding of those hours to two decimal places. Since the summation is happening on the backend, it makes sense to do the rounding there, too.

This change to the summaries function performs that rounding on the backend values. It applies the db function Sum not to the raw hours value but to the result of Func(F('hours'), Value(2), function='ROUND').

Since summaries is only used in that one view, and since there are no tests for it, this change is self-contained and, in theory, complete.

rlconley commented 8 years ago

:green_apple: