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.
The InvoiceDetail view's
billable_totals
andnonbillable_totals
make use of thesummaries
method on theHourGroupManager
. This serves up a sum of allhours
values on a bundle of entries by calling theSUM
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 functionSum
not to the rawhours
value but to the result ofFunc(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.