PhoenixKit.Modules.Billing.BillingProfile (phoenix_kit v1.7.38)

Copy Markdown View Source

Billing profile schema for PhoenixKit Billing system.

Stores user billing information for individuals and companies (EU Standard). Used for generating invoices and order billing snapshots.

Schema Fields

Profile Identity

  • user_id: Foreign key to the user
  • type: Profile type - "individual" or "company"
  • is_default: Whether this is the user's default billing profile
  • name: Display name for the profile

Individual Fields

  • first_name, last_name, middle_name: Person's name
  • phone: Contact phone number
  • email: Billing email (can differ from user email)

Company Fields (EU Standard)

  • company_name: Legal company name
  • company_vat_number: EU VAT Number (e.g., "EE123456789")
  • company_registration_number: Company registration number
  • company_legal_address: Registered legal address

Billing Address

  • address_line1, address_line2: Street address
  • city, state, postal_code, country: Location

Usage Examples

# Create individual billing profile
{:ok, profile} = Billing.create_billing_profile(user, %{
  type: "individual",
  first_name: "John",
  last_name: "Doe",
  email: "john@example.com",
  address_line1: "123 Main St",
  city: "Tallinn",
  country: "EE",
  is_default: true
})

# Create company billing profile
{:ok, profile} = Billing.create_billing_profile(user, %{
  type: "company",
  company_name: "Acme Corp OÜ",
  company_vat_number: "EE123456789",
  company_registration_number: "12345678",
  address_line1: "Business Park 1",
  city: "Tallinn",
  country: "EE"
})

Summary

Functions

Creates a changeset for billing profile creation and updates.

Returns the display name for the billing profile.

Returns formatted address as a multi-line string.

Returns a snapshot of billing profile for order/invoice storage.

Functions

changeset(profile, attrs)

Creates a changeset for billing profile creation and updates.

display_name(arg1)

Returns the display name for the billing profile.

formatted_address(profile)

Returns formatted address as a multi-line string.

to_snapshot(profile)

Returns a snapshot of billing profile for order/invoice storage.

This creates an immutable copy of billing details at a point in time.