Repository navigation
fix: project a month at 8760/12 hours so facility charges round-trip - #111
Open
marcus-beauregard wants to merge 1 commit into
Open
marcus-beauregard wants to merge 1 commit into
marcus-beauregard wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Monthly projections multiplied the hourly cost by
24 * 30(720 hours) while facility charges are spread over8760 / 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/calculatornow owns the length of a month:HoursPerYear = 8760,HoursPerMonth = HoursPerYear / 12(730), withProjectMonthly/ProjectYearlyhelpers. 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— RESTMonthlyProjected/YearlyProjectedpkg/cli/status.go— the status projectionspkg/cli/compare.go— projected tokens and projected on-prem costYearly figures were already 8760; they now share the constant too.
Test
TestProjectMonthlyReturnsTheConfiguredMonthlyChargebuilds the issue's repro (facility $7,300, no hardware, no electricity), asserts the hourly facility cost is $10, then thatProjectMonthlyreturns $7,300 andProjectYearly$87,600. WithHoursPerMonthset back to24 * 30the test fails atfacility per hour = 10.13888888888889, want 10.go vetis clean;go test ./internal/calculator ./pkg/cli ./internal/apipasses, and the controller envtest suite (k8s 1.37.0) passes.Fixes #110