Accrue.Billing.SubscriptionScheduleProjection (accrue v1.0.0)

Copy Markdown View Source

Decomposes a Stripe/Fake SubscriptionSchedule payload into the flat attrs map consumed by Accrue.Billing.SubscriptionSchedule.changeset/2 and force_status_changeset/2.

Handles both atom-keyed (Fake) and string-keyed (Stripe) payloads via SubscriptionProjection.get/2 dual-key lookup (Pattern §I).

Computes current_phase_index by matching current_phase.start_date against the phases[] list (Pitfall 4 — index-less diff anchor so out-of-order webhook updates settle correctly).

Summary

Functions

decompose(schedule)

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