Skip to content

Discount and invoice-line wire-shape gaps (metadata, total_discount_amounts, expand, discount events, resume invoices) #21

Open

Description

@scosman

What happens

While working on #17, we found several gaps in the shapes the API returns. They predate #17 and don't change any totals.

  1. Plan-line metadata. Plan lines always return metadata: {}. Stripe copies the subscription's metadata onto the plan line (probed through the Stripe MCP, 2026-10-16). The line builder is in billing/invoicing.py (~490).
  2. total_discount_amounts. compute_totals leaves zero-amount discounts out of the invoice's total_discount_amounts. Lines now list {amount: 0, discount} entries as Stripe's do; whether Stripe's invoice-level total keeps the zero entry is unprobed.
  3. Expanding discounts. expand[]=discounts silently does nothing (serialize/expand.py), so a discount's start/end can't be read through the API. Stripe's discount object has [id, object, checkout_session, customer, customer_account, end, invoice, invoice_item, promotion_code, source{coupon,type}, start, subscription, subscription_item] (probed).
  4. Discount events. No customer.discount.created, customer.discount.updated or customer.discount.deleted events are emitted, including when a repeating discount ends. They are listed in spec/event_types.py but never fired.
  5. Resume invoices. Resume invoices don't record their discounts or tax rates (no discounts= and no tax_rate_ids= on create_invoice). The totals list a di_ that invoice.discounts lacks, and a draft rebuild would drop both.

Impact on the company fixtures

  • Item 1 would change the metadata on every plan line in both fixtures.
  • Item 4 would add events.
  • The other items have no fixture impact known.

Suggested next steps

Fix item 1 and item 5 first. Item 1 is visible on every invoice, and item 5 can drop a discount on rebuild. Then decide whether expand and discount events belong in scope.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions