Skip to content

Conversation

@reshmabidikar
Copy link
Contributor

@reshmabidikar reshmabidikar commented Dec 16, 2024

There is a bug in the code due to which it is currently not possible to override a usage price by itself, it is necessary to update either a fixed or a recurring price too. This PR attempts to address this bug.

See this comment.

@reshmabidikar
Copy link
Contributor Author

If you agree that this is a bug, I can write a test for this fix.

Copy link
Member

@sbrossie sbrossie left a comment

Choose a reason for hiding this comment

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

OK with the fix.

  1. I would suggest to even throw if we end up with null currency as it will break down the line
  2. Is there a way add a small test (if easy)

@reshmabidikar
Copy link
Contributor Author

For 2/- above, I've added a test See c29ce39.
For 1/ above, I was not sure where to throw an exception. So I've added a validation to check that there is at least one overridden price and a test for this. With this change, there is now no need for this check. See e941bba. If this is not what you meant please let me know and I can make changes accordingly.

@reshmabidikar reshmabidikar marked this pull request as ready for review December 18, 2024 09:48
requestOptions);
callbackServlet.assertListenerStatus();
final Subscription subscription = subscriptionApi.getSubscription(entitlementJson.getSubscriptionId(), requestOptions);
Assert.assertEquals(subscription.getState(), EntitlementState.ACTIVE);
Copy link
Member

Choose a reason for hiding this comment

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

Any way we could check that price was correctly overridden - would subscription#getLastActivePlan() provide such info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 984a82d

for (final PhasePriceJson input : priceOverrides) {
Preconditions.checkNotNull(input);

Preconditions.checkArgument(input.getFixedPrice() != null || input.getRecurringPrice() != null || input.getUsagePrices() != null || (input.getUsagePrices() != null && !input.getUsagePrices().isEmpty()),
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove the input.getUsagePrices() != null and simply keep the (input.getUsagePrices() != null && !input.getUsagePrices().isEmpty()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 984a82d

final PlanPhaseSpecifier planPhaseSpecifier = spec.getPlanName() != null ?
new PlanPhaseSpecifier(spec.getPlanName(), phaseType) :
new PlanPhaseSpecifier(spec.getProductName(), spec.getBillingPeriod(), spec.getPriceListName(), phaseType);
final Currency resolvedCurrency = input.getFixedPrice() != null || input.getRecurringPrice() != null || (input.getUsagePrices() != null && !input.getUsagePrices().isEmpty()) ? currency : null;
Copy link
Member

Choose a reason for hiding this comment

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

Good point, I don't think this is needed.

@reshmabidikar reshmabidikar merged commit bbe8e95 into killbill:master Dec 20, 2024
11 checks passed
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