Migrating customer balances and subscriptions from legacy billing platforms requires exact ISO-4217 minor-unit math, consistent status enum mapping, month-end anchor clamping, and deterministic idempotency keys so retries never double-credit balances.
| Billing Field | Migration Hazard | Creem Ledger Compilation |
|---|---|---|
unit_amount & proration_credit |
Float math introduces penny drift or 100x scaling errors between USD (2 decimals) and JPY (0 decimals). | Parses strictly with decimal.Decimal and quantizes minor units using ISO-4217 currency exponents. |
status spelling variants |
canceled vs cancelled or incomplete_expired silently drop entitlements. |
Normalizes all status variants into explicit Creem entitlement states while preserving audit metadata. |
idempotency_key |
Re-running an import script without a unique constraint credits prepaid balances twice. | Preserves source idempotency_key or synthesizes a deterministic SHA-256 key enforced as UNIQUE in SQLite/Postgres. |
creem_ledger via RESTcurl -sS -X POST https://migrate.fastmesh.dev/v1/migrate \
-H "Content-Type: application/json" \
-d '{
"source_format": "billing_csv",
"target_format": "creem_ledger",
"table_name": "creem_prepaid_ledger",
"source_data": "customer_ref,subscription_id,plan_sku,status,currency,unit_amount,billing_cycle_anchor,current_period_start,current_period_end,proration_credit,idempotency_key\ncust_901,sub_001,sku_b05_growth_79,active,USD,$79.00,1,2026-12-01T00:00:00Z,2027-01-01T00:00:00Z,$0.00,idem_901_dec\ncust_902,sub_002,sku_b05_starter_19,cancelled,USD,$19.00,15,2026-11-15T00:00:00Z,2026-12-15T00:00:00Z,$4.50,idem_902_nov"
}'