Skip to content

Commit

Permalink
fix(chargebee): ensure multiple addons are counted to subscription li…
Browse files Browse the repository at this point in the history
…mits (#2741)
  • Loading branch information
matthewelwell committed Sep 5, 2023
1 parent 00d9887 commit 2ac23a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/organisations/chargebee/chargebee.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def extract_subscription_metadata(
subscription_metadata.chargebee_email = customer_email

for addon in chargebee_addons:
quantity = getattr(addon, "quantity", None) or 1
quantity = addon.get("quantity") or 1
addon_metadata: ChargebeeObjMetadata = (
chargebee_cache.addons[addon["id"]] * quantity
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,11 @@ def test_extract_subscription_metadata(
)

# Then
assert subscription_metadata.seats == chargebee_object_metadata.seats * 2
assert subscription_metadata.api_calls == chargebee_object_metadata.api_calls * 2
assert subscription_metadata.projects == chargebee_object_metadata.projects * 2
# Note that we multiply by 3 since the plan and the addons carry the same limits,
# so we have 1 plan + 2 addons.
assert subscription_metadata.seats == chargebee_object_metadata.seats * 3
assert subscription_metadata.api_calls == chargebee_object_metadata.api_calls * 3
assert subscription_metadata.projects == chargebee_object_metadata.projects * 3
assert subscription_metadata.chargebee_email == customer_email


Expand Down

1 comment on commit 2ac23a8

@vercel
Copy link

@vercel vercel bot commented on 2ac23a8 Sep 5, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.