@@ -248,16 +248,15 @@ func (s *CreditThenInvoiceStateMachine) startInvoiceCreatedRun(
248248 }
249249
250250 result , err := s .Runs .CreateRatedRun (ctx , usagebasedrun.CreateRatedRunInput {
251- Charge : s .Charge ,
252- CustomerOverride : s .CustomerOverride ,
253- FeatureMeter : s .FeatureMeter ,
254- Type : runType ,
255- StoredAtLT : storedAtLT ,
256- ServicePeriodTo : servicePeriodTo ,
257- LineID : lo .ToPtr (input .LineID ),
258- IgnoreMinimumCommitment : ignoreMinimumCommitmentForRunType (runType ),
259- CreditAllocation : usagebasedrun .CreditAllocationAvailable ,
260- CurrencyCalculator : s .CurrencyCalculator ,
251+ Charge : s .Charge ,
252+ CustomerOverride : s .CustomerOverride ,
253+ FeatureMeter : s .FeatureMeter ,
254+ Type : runType ,
255+ StoredAtLT : storedAtLT ,
256+ ServicePeriodTo : servicePeriodTo ,
257+ LineID : lo .ToPtr (input .LineID ),
258+ CreditAllocation : usagebasedrun .CreditAllocationAvailable ,
259+ CurrencyCalculator : s .CurrencyCalculator ,
261260 })
262261 if err != nil {
263262 return err
@@ -275,12 +274,6 @@ func (s *CreditThenInvoiceStateMachine) StartFinalInvoiceRun(ctx context.Context
275274 return s .startInvoiceCreatedRun (ctx , input , usagebased .RealizationRunTypeFinalRealization )
276275}
277276
278- func ignoreMinimumCommitmentForRunType (runType usagebased.RealizationRunType ) bool {
279- // Partial invoice runs are interim cumulative checkpoints. Minimum commitment is billed only on the
280- // final realization, so partial runs must suppress it during both creation and later snapshotting.
281- return runType == usagebased .RealizationRunTypePartialInvoice
282- }
283-
284277func resolveInvoiceCreatedTrigger (charge usagebased.Charge , billedPeriod timeutil.ClosedPeriod ) meta.Trigger {
285278 if meta .NormalizeTimestamp (billedPeriod .To ).Equal (meta .NormalizeTimestamp (charge .Intent .ServicePeriod .To )) {
286279 return meta .TriggerFinalInvoiceCreated
@@ -309,17 +302,15 @@ func (s *CreditThenInvoiceStateMachine) SnapshotInvoiceUsage(ctx context.Context
309302
310303 storedAtLT := meta .NormalizeTimestamp (currentRun .StoredAtLT )
311304
312- ratingResult , err := s .Rater .GetDetailedLinesForUsage (ctx , usagebasedrating.GetDetailedLinesForUsageInput {
313- Charge : s .Charge ,
314- PriorRuns : s .Charge .Realizations .Without (currentRun .ID ),
315- Customer : s .CustomerOverride ,
316- FeatureMeter : s .FeatureMeter ,
317- ServicePeriodTo : currentRun .ServicePeriodTo ,
318- StoredAtLT : storedAtLT ,
319- IgnoreMinimumCommitment : ignoreMinimumCommitmentForRunType (currentRun .Type ),
305+ ratingResult , err := s .Rater .GetDetailedRatingForUsage (ctx , usagebasedrating.GetDetailedRatingForUsageInput {
306+ Charge : s .Charge ,
307+ StoredAtLT : storedAtLT ,
308+ ServicePeriodTo : currentRun .ServicePeriodTo ,
309+ Customer : s .CustomerOverride ,
310+ FeatureMeter : s .FeatureMeter ,
320311 })
321312 if err != nil {
322- return fmt .Errorf ("get rating for usage: %w" , err )
313+ return fmt .Errorf ("get detailed rating for usage: %w" , err )
323314 }
324315
325316 currentTotals := ratingResult .Totals .RoundToPrecision (s .CurrencyCalculator )
0 commit comments