caelum0x 6849c587e4 feat(rago): apply credit notes to later invoices, interval-aware backfill, safe downgrade cancel
Finalized invoices draw available credit-note balance (oldest first, partial,
locked, once per invoice) on every finalization path; voids restore balance.
Invoices expose a Lago-style credits array; console shows applied notes.
Draft-grace termination credits become draft credit notes finalized with the
invoice; termination credit issued before the final invoice. Backfill uses the
plan interval via SubscriptionSpan::window (InvalidPeriod on boundary cross).
Scheduled downgrade is cancelled only after the final invoice succeeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 00:23:35 +03:00

38 lines
1.2 KiB
TOML

[package]
name = "rago-db"
version.workspace = true
edition.workspace = true
license.workspace = true
rust-version.workspace = true
description = "Rago persistence: sqlx Postgres repositories + migrations for the Lago billing schema"
[dependencies]
rago-core.workspace = true
sqlx.workspace = true
rust_decimal.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
uuid.workspace = true
chrono.workspace = true
tracing.workspace = true
sha2.workspace = true
base64.workspace = true
ring = "0.17"
# Credit-note allocation math (`credit_note_credits`). rago-billing depends
# only on rago-core, so there is no cycle.
rago-billing.workspace = true
[dev-dependencies]
tokio.workspace = true
# Live-Postgres aggregator parity suite (tests/aggregator_parity.rs): fetches
# events through the repo, then aggregates via rago-billing to compare against
# Lago's asserted numbers. rago-billing depends only on rago-core, so this adds
# no dependency cycle.
rust_decimal_macros.workspace = true
[features]
# Opt-in Postgres-backed #[sqlx::test] suites (need DATABASE_URL; see README
# "Running the tests"). Plain `cargo test` skips them.
pg-tests = []