Skip to content

Conversation

@DylanDevelops
Copy link
Owner

Pull Request Checklist

  • I have read and followed the contribution guidelines.
  • My pull request targets the main branch of tmpo.
  • I have tested these changes locally on my machine.

Closes #30

Description

This pull request updates the way earnings are calculated for time entries by introducing a new RoundedHours method on the TimeEntry struct. 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:

  • Added a RoundedHours method to the TimeEntry struct in models.go, which returns the duration in hours rounded to two decimal places for transparent and consistent billing.
  • Updated all earnings calculations in manual.go and stats.go to use entry.RoundedHours() instead of duration.Hours(), ensuring displayed and billed hours match. [1] [2] [3]

Testing and reliability:

  • Added a new unit test, TestTimeEntryRoundedHours, in db_test.go to verify the correctness of the RoundedHours method with various time entry scenarios.

Code organization:

  • Updated imports in models.go to include the math package for rounding calculations.

Earnings are now calculated using durations rounded to the nearest minute to better align with typical invoicing practices. Added TimeEntry.RoundedDuration method and corresponding unit tests to ensure correct rounding behavior.
Replaces usage of RoundedDuration with a new RoundedHours method for earnings calculations, ensuring hours are rounded to two decimal places for transparency and consistency in billing. Updates related tests and documentation to reflect this change.
@DylanDevelops DylanDevelops merged commit b849bff into main Dec 23, 2025
6 checks passed
@DylanDevelops DylanDevelops deleted the ravel/financial-calculation-improvement branch December 23, 2025 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Financial Calculations Too Accurate to seconds and milliseconds

2 participants