# `PhoenixKit.Migrations.Postgres.V31`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.63/lib/phoenix_kit/migrations/postgres/v31.ex#L1)

PhoenixKit V31 Migration: Billing System - Phase 1

This migration introduces the core billing infrastructure including currencies,
billing profiles, orders, and invoices. This is Phase 1 of the billing module,
focused on manual bank transfer payments.

## Changes

### Currencies Table (phoenix_kit_currencies)
- Multi-currency support with ISO 4217 codes
- Exchange rates for currency conversion
- Default currency configuration

### Billing Profiles Table (phoenix_kit_billing_profiles)
- User billing information storage
- Support for individuals and companies (EU Standard)
- VAT number and company registration for B2B
- Billing address management

### Orders Table (phoenix_kit_orders)
- Order management with line items (JSONB)
- Status tracking (draft, pending, confirmed, paid, cancelled, refunded)
- Multi-currency support
- Billing snapshot at order time

### Invoices Table (phoenix_kit_invoices)
- Invoice generation from orders
- Status tracking (draft, sent, paid, void, overdue)
- Receipt functionality integrated
- Bank details for payment

### Settings Seeds
- Billing module enable/disable
- Default currency and tax settings
- Invoice/order number prefixes

## PostgreSQL Support
- Leverages PostgreSQL's native JSONB for flexible data
- Decimal precision for financial calculations
- Supports prefix for schema isolation
- Optimized indexes for common queries

# `down`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.63/lib/phoenix_kit/migrations/postgres/v31.ex#L533)

Rollback the V31 migration.

# `up`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.63/lib/phoenix_kit/migrations/postgres/v31.ex#L52)

Run the V31 migration to add the billing system.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
