Invoicing Schema
settings
Section titled “settings”Per-user invoicing configuration.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
user_id | uuid | NO | — |
invoice_prefix | text | NO | 'INV-' |
quotation_prefix | text | NO | 'QUO-' |
payment_prefix | text | NO | 'PAY-' |
next_invoice_number | integer | NO | 1 |
next_quotation_number | integer | NO | 1 |
next_payment_number | integer | NO | 1 |
default_currency | text | NO | 'USD' |
default_tax_method | text | NO | 'exclusive' |
default_due_days | integer | NO | 30 |
default_note | text | YES | — |
metadata | jsonb | YES | '{}' |
created_at | timestamptz | NO | now() |
updated_at | timestamptz | NO | now() |
customers
Section titled “customers”Invoicing customer records.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
user_id | uuid | NO | — |
profile_id | uuid | YES | — |
name | text | NO | — |
company | text | YES | — |
email | text | YES | — |
phone | text | YES | — |
address | text | YES | — |
city | text | YES | — |
state | text | YES | — |
postal_code | text | YES | — |
country | text | YES | — |
balance | numeric | NO | 0 |
metadata | jsonb | YES | '{}' |
created_at | timestamptz | NO | now() |
updated_at | timestamptz | NO | now() |
catalog_items
Section titled “catalog_items”Reusable product/service catalog.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
user_id | uuid | NO | — |
name | text | NO | — |
description | text | YES | — |
price | numeric | NO | 0 |
tax_method | text | NO | 'exclusive' |
metadata | jsonb | YES | '{}' |
created_at | timestamptz | NO | now() |
updated_at | timestamptz | NO | now() |
tax_rates
Section titled “tax_rates”User-defined tax rates.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
user_id | uuid | NO | — |
name | text | NO | — |
rate | numeric | NO | 0 |
is_fixed | boolean | NO | false |
created_at | timestamptz | NO | now() |
invoices
Section titled “invoices”Invoice records with totals, payment tracking, and recurrence.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
user_id | uuid | NO | — |
customer_id | uuid | NO | — |
platform_payment_id | uuid | YES | — |
number | text | NO | — |
reference | text | YES | — |
hash | text | NO | substr(gen_random_uuid(), 1, 12) |
date | date | NO | CURRENT_DATE |
due_date | date | YES | — |
status | text | NO | 'draft' |
subtotal | numeric | NO | 0 |
total_tax | numeric | NO | 0 |
total_discount | numeric | NO | 0 |
shipping | numeric | NO | 0 |
grand_total | numeric | NO | 0 |
paid_amount | numeric | NO | 0 |
note | text | YES | — |
tax_method | text | NO | 'exclusive' |
receipt_url | text | YES | — |
is_recurring | boolean | NO | false |
recurring_interval | text | YES | — |
next_recurrence_date | date | YES | — |
metadata | jsonb | YES | '{}' |
sent_at | timestamptz | YES | — |
viewed_at | timestamptz | YES | — |
paid_at | timestamptz | YES | — |
created_at | timestamptz | NO | now() |
updated_at | timestamptz | NO | now() |
invoice_items
Section titled “invoice_items”Invoice line items.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
invoice_id | uuid | NO | — |
catalog_item_id | uuid | YES | — |
name | text | NO | — |
description | text | YES | — |
quantity | numeric | NO | 1 |
unit_price | numeric | NO | 0 |
discount | numeric | NO | 0 |
discount_amount | numeric | NO | 0 |
tax_amount | numeric | NO | 0 |
subtotal | numeric | NO | 0 |
total | numeric | NO | 0 |
sort_order | smallint | NO | 0 |
metadata | jsonb | YES | '{}' |
invoice_item_taxes
Section titled “invoice_item_taxes”Tax rates applied to invoice items.
| Column | Type | Nullable | Default |
|---|---|---|---|
invoice_item_id | uuid | NO | — |
tax_rate_id | uuid | NO | — |
invoice_payments
Section titled “invoice_payments”Payments against invoices.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
invoice_id | uuid | NO | — |
user_id | uuid | NO | — |
platform_payment_id | uuid | YES | — |
number | text | NO | — |
amount | numeric | NO | — |
method | text | NO | 'stripe' |
date | date | NO | CURRENT_DATE |
note | text | YES | — |
receipt_url | text | YES | — |
metadata | jsonb | YES | '{}' |
created_at | timestamptz | NO | now() |
quotations
Section titled “quotations”Price quotations (convertible to invoices).
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
user_id | uuid | NO | — |
customer_id | uuid | NO | — |
number | text | NO | — |
reference | text | YES | — |
hash | text | NO | substr(gen_random_uuid(), 1, 12) |
date | date | NO | CURRENT_DATE |
expiry_date | date | YES | — |
status | text | NO | 'draft' |
subtotal | numeric | NO | 0 |
total_tax | numeric | NO | 0 |
total_discount | numeric | NO | 0 |
shipping | numeric | NO | 0 |
grand_total | numeric | NO | 0 |
note | text | YES | — |
tax_method | text | NO | 'exclusive' |
converted_invoice_id | uuid | YES | — |
metadata | jsonb | YES | '{}' |
sent_at | timestamptz | YES | — |
viewed_at | timestamptz | YES | — |
created_at | timestamptz | NO | now() |
updated_at | timestamptz | NO | now() |
quotation_items
Section titled “quotation_items”Quotation line items.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
quotation_id | uuid | NO | — |
catalog_item_id | uuid | YES | — |
name | text | NO | — |
description | text | YES | — |
quantity | numeric | NO | 1 |
unit_price | numeric | NO | 0 |
discount | numeric | NO | 0 |
discount_amount | numeric | NO | 0 |
tax_amount | numeric | NO | 0 |
subtotal | numeric | NO | 0 |
total | numeric | NO | 0 |
sort_order | smallint | NO | 0 |
metadata | jsonb | YES | '{}' |
Polymorphic notes on invoicing entities.
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | NO | gen_random_uuid() |
user_id | uuid | NO | — |
notable_id | uuid | NO | — |
notable_type | text | NO | — |
content | text | NO | — |
created_at | timestamptz | NO | now() |