Skip to content

fix: project a month at 8760/12 hours so facility charges round-trip - #111

Open
marcus-beauregard wants to merge 1 commit into
defilantech:mainfrom
marcus-beauregard:fix/monthly-projection-average-month
Open

marcus-beauregard wants to merge 1 commit into
defilantech:mainfrom
marcus-beauregard:fix/monthly-projection-average-month

Conversation

@marcus-beauregard

Copy link
Copy Markdown

What

Monthly projections multiplied the hourly cost by 24 * 30 (720 hours) while facility charges are spread over 8760 / 12 (730). A profile whose only cost is a $7,300 monthly facility charge reports $10.00/hour and projected $7,200/month — about 1.4% below the contract it was configured from.

Change

internal/calculator now owns the length of a month: HoursPerYear = 8760, HoursPerMonth = HoursPerYear / 12 (730), with ProjectMonthly/ProjectYearly helpers. The four projection sites named in the issue use them, and the facility spread divides by the same constant, so a month has one definition:

  • internal/controller/costprofile_controller.go — REST MonthlyProjected/YearlyProjected
  • pkg/cli/status.go — the status projections
  • pkg/cli/compare.go — projected tokens and projected on-prem cost

Yearly figures were already 8760; they now share the constant too.

Test

TestProjectMonthlyReturnsTheConfiguredMonthlyCharge builds the issue's repro (facility $7,300, no hardware, no electricity), asserts the hourly facility cost is $10, then that ProjectMonthly returns $7,300 and ProjectYearly $87,600. With HoursPerMonth set back to 24 * 30 the test fails at facility per hour = 10.13888888888889, want 10.

go vet is clean; go test ./internal/calculator ./pkg/cli ./internal/api passes, and the controller envtest suite (k8s 1.37.0) passes.

Fixes #110

Monthly projections multiplied the hourly cost by 24 * 30 hours while the
facility spread uses 8760/12, so a profile whose only cost is a $7,300
monthly facility charge reported $7,200 a month.

The four projection sites and the facility spread now share
calculator.HoursPerMonth, so a month is one twelfth of a year everywhere.
compare.go also uses it for the projected token count.

Signed-off-by: Marcus Beauregard <marcus.beauregard.developer@gmail.com>

This branch has not been deployed

No deployments
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.

[BUG] Monthly projections use a 720-hour month while facility charges use 730

1 participant