Skip to content

Commit

Permalink
Merge pull request #1833 from openmeterio/feat/plan-api-impl
Browse files Browse the repository at this point in the history
fix: Plan API
  • Loading branch information
tothandras authored Nov 12, 2024
2 parents 4d54451 + 09587ca commit 4ea4a49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions openmeter/productcatalog/plan/adapter/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,15 @@ func (a *adapter) UpdatePhase(ctx context.Context, params plan.UpdatePhaseInput)
SetOrClearDescription(rateCardInput.Description).
SetOrClearFeatureKey(rateCardInput.FeatureKey).
SetEntitlementTemplate(rateCardInput.EntitlementTemplate).
SetTaxConfig(rateCardInput.TaxConfig).
SetOrClearBillingCadence(rateCardInput.BillingCadence).
SetPrice(rateCardInput.Price)
SetOrClearBillingCadence(rateCardInput.BillingCadence)

if rateCardInput.TaxConfig != nil {
q.SetTaxConfig(rateCardInput.TaxConfig)
}

if rateCardInput.Price != nil {
q.SetPrice(rateCardInput.Price)
}

if rateCardInput.FeatureID == nil {
q.ClearFeatureID()
Expand Down
4 changes: 2 additions & 2 deletions openmeter/productcatalog/plan/httpdriver/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func AsFlatFeeRateCard(flat api.RateCardFlatFee, namespace string) (plan.FlatFee
case api.PricePaymentTermInArrears:
paymentTerm = plan.InArrearsPaymentTerm
case api.PricePaymentTermInAdvance:
fallthrough
paymentTerm = plan.InAdvancePaymentTerm
default:
paymentTerm = plan.DefaultPaymentTerm
}
Expand Down Expand Up @@ -557,7 +557,7 @@ func AsPrice(p api.RateCardUsageBasedPrice) (plan.Price, error) {
case api.PricePaymentTermInArrears:
flatPrice.PaymentTerm = plan.InArrearsPaymentTerm
case api.PricePaymentTermInAdvance:
fallthrough
flatPrice.PaymentTerm = plan.InAdvancePaymentTerm
default:
flatPrice.PaymentTerm = plan.DefaultPaymentTerm
}
Expand Down

0 comments on commit 4ea4a49

Please sign in to comment.