Accrue.Billing.SubscriptionProjection (accrue v0.3.0)

Copy Markdown View Source

Decomposes a processor (Stripe- or Fake-shaped) subscription map into a flat attrs map ready for Accrue.Billing.Subscription.changeset/2 (D3-02).

Handles both the atom-keyed shape produced by Accrue.Processor.Fake and the string-keyed shape produced by Accrue.Processor.Stripe (after Map.from_struct/1).

Summary

Functions

Recursively converts atom-keyed maps to string-keyed maps and DateTimes to ISO8601 strings so the result is jsonb round-trip safe.

Functions

decompose(stripe_sub)

@spec decompose(map()) :: {:ok, map()}

to_string_keys(dt)

@spec to_string_keys(term()) :: term()

Recursively converts atom-keyed maps to string-keyed maps and DateTimes to ISO8601 strings so the result is jsonb round-trip safe.

Public so Accrue.Billing.InvoiceProjection can reuse the same normalization (WR-11) rather than storing atom-keyed data and getting shape drift on reload.