uselotus / lotus

Open Source Pricing & Packaging Infrastructure
https://www.uselotus.io
MIT License
1.73k stars 126 forks source link

Bulk tiers broke plan creation with components #766

Closed yusmpgroup closed 1 year ago

yusmpgroup commented 1 year ago

Describe the bug When creating a new plan with a single component (bulk price is Off) server responds with error 500:

To Reproduce Steps to reproduce the behavior:

  1. Following instructions on website (https://docs.uselotus.io/overview/self-hosting):
  2. Install a fresh copy of Lotus (branch main, commit=760831722c344a825ff1b6549fdca73223e39e6a)
  3. Create a metric
  4. Create a plan
  5. Add Component with the created Metric
  6. Click publish Request payload:
    {"plan_name":"test2","plan_duration":"monthly","initial_version":{"version":1,"localized_name":null,"recurring_charges":[],"components":[{"metric_id":"metric_368864360fc147a08302d1cd6001571b","tiers":[{"type":"per_unit","range_start":0,"batch_rounding_type":"no_rounding","metric_units_per_batch":1,"cost_per_batch":1,"range_end":1000},{"range_start":1000,"type":"per_unit","cost_per_batch":1,"batch_rounding_type":"no_rounding","metric_units_per_batch":1}],"prepaid_charge":null}],"features":[],"usage_billing_frequency":"monthly","currency_code":"USD","plan_name":"test2","day_anchor":1}}

    Server response:

    'NoneType' object has no attribute 'tiers'

Expected behavior Plan is created

Details

The error occurs in file backend/metering_billing/models.py Screenshot from 2023-04-14 11-33-17

mnida commented 1 year ago

Sorry for the late comment on this. Will take a look!

mnida commented 1 year ago

This was fixed by @diego-escobedo last week.