Skip to content

[NU-498] Stepped billing: consider discounts and minimum cost - #6444

Open
joaquinco wants to merge 10 commits into
masterfrom
nu-498/stepped-billing-fixes
Open

[NU-498] Stepped billing: consider discounts and minimum cost#6444
joaquinco wants to merge 10 commits into
masterfrom
nu-498/stepped-billing-fixes

Conversation

@joaquinco

@joaquinco joaquinco commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Notes

Consider discounts and minimum cost when calculating stepped billing.

Changes:

  • Move discount and minimum cost handling to base strategy class
  • Unify raw duration and (end - start) duration cases
  • Unify estimate and non-estimate calculations
  • Time based estimate calculations now consider minimum costs
  • PricePolicies::Strategy::PerMinute logic is included in PricePolicies::Strategy::SteppedRate, might be worth just keeping the latter down the road

NU-498 | Stepped billing fixes

@joaquinco
joaquinco force-pushed the nu-498/stepped-billing-fixes branch from ebe905b to 4e7d3e9 Compare August 27, 2026 19:17
@joaquinco
joaquinco force-pushed the nu-498/stepped-billing-fixes branch 2 times, most recently from b6265e3 to 8bc3cd9 Compare August 28, 2026 18:45
@joaquinco
joaquinco marked this pull request as ready for review August 31, 2026 12:15
Comment thread app/services/price_policies/strategy.rb Outdated

# Charge usage per minute with a stepped (or tiered) rate
#
# If price policy does not have rates then it's equivalen to PerMinute

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*equivalent

Comment thread app/services/price_policies/strategy.rb Outdated
subsidy: subsidy || 0,
cost: duration_days * usage_rate_daily,
cost: duration * usage_rate_daily,
subsidy: duration * price_policy.usage_subsidy_daily.to_f,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I think you can remove the explicit call to price_policy here as usage_subsidy_daily is already delegated to it

@duration = duration
@raw_duration = duration

if [start_at, end_at, duration].all?(&:nil?)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is already checked before calling this class.

https://github.com/wyeworks/nucore-open/pull/6444/changes#diff-f8fd7a0d301cd4ee9074fe3e2bff05a5541d33ea141637e441a39022aaa85d01L16

Maybe leave it here and remove the check from time_based_price_calculator.rb?

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.

2 participants