fix: Estimated earnings now accurate to two decimal places instead of float64 max precision #33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
mainbranch of tmpo.Closes #30
Description
This pull request updates the way earnings are calculated for time entries by introducing a new
RoundedHoursmethod on theTimeEntrystruct. Instead of using the raw duration in hours, all earnings calculations now use hours rounded to two decimal places, ensuring consistency between what is displayed and what is billed. The change also adds comprehensive unit tests for the new rounding logic.Earnings calculation improvements:
RoundedHoursmethod to theTimeEntrystruct inmodels.go, which returns the duration in hours rounded to two decimal places for transparent and consistent billing.manual.goandstats.goto useentry.RoundedHours()instead ofduration.Hours(), ensuring displayed and billed hours match. [1] [2] [3]Testing and reliability:
TestTimeEntryRoundedHours, indb_test.goto verify the correctness of theRoundedHoursmethod with various time entry scenarios.Code organization:
models.goto include themathpackage for rounding calculations.