[WIP] remove to_time_preserves_timezone #4132
Open
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.
As a follow up on Rails 7.1 upgrade, lets remove this.
The only place I identified us using
#to_timeis inContract#intersect_with_unpaid_periodwhich is used for variable cost calculations.This is tested from
Finance::VariableCostCalculationTest#variable line items are created.In that instance the period is actually dates. So
#to_timereturns the dates in the server local timezone regardless of theto_time_preserves_timezonesetting. So the behavior shouldn't change.But there is still a small chance where
#to_timeis called somewhere internally. And since providers should be billed in their local timezones,I think we should simulate that - create a provider with a very different timezone from current and ensure it is billed in that specified timezone.
That's why I leave this a WIP. I'm going away for a week so feel free to pick this up 👼
P.S. there is also
Finance::BillVariableForPlanChangedTestwhere we check whether variable billing would happen in certain timezone conditions. But it doesn't seem to test an actual provider being actually billed on a server with a different time zone.there is also a test
Finance::VariableCostCalculationTest##calculate_variable_cost does the calculations in the timezone of the providerbut it is also heavily stubbed so I wouldn't call it trustworthy.