Billing data model
erd
Imported straight from schema.prisma — five models and an enum, on their own database
/
Fit
SVG
PNG
account · accountId → id · many ↔ one
invoice · invoiceId → id · many ↔ one · on delete cascade
invoice · invoiceId → id · many ↔ one
account · accountId → id · many ↔ one
accounts
accounts
id · String · primary key · default uuid(
PK
id
String
merchantId · String · column merchant_id
UQ
merchantId
String
name · String
name
String
currency · String
currency
String
termsDays · Int · default 30 · column terms_days
termsDays
Int
createdAt · DateTime · default now( · column created_at
createdAt
DateTime
invoices
invoices
id · String · primary key · default uuid(
PK
id
String
accountId · String · → account.id · column account_id
FK
accountId
String
number · String
UQ
number
String
status · InvoiceStatus · default draft
status
InvoiceStatus
issuedAt · DateTime · nullable · column issued_at
issuedAt?
DateTime
dueAt · DateTime · nullable · column due_at
dueAt?
DateTime
totalMinor · Int · column total_minor
totalMinor
Int
invoice_lines
invoice_lines
id · String · primary key · default uuid(
PK
id
String
invoiceId · String · → invoice.id · column invoice_id
FK
invoiceId
String
parcelId · String · column parcel_id
parcelId
String
description · String
description
String
amountMinor · Int · column amount_minor
amountMinor
Int
surcharge · Boolean · default false
surcharge
Boolean
payments
payments
id · String · primary key · default uuid(
PK
id
String
invoiceId · String · → invoice.id · column invoice_id
FK
invoiceId
String
reference · String
UQ
reference
String
amountMinor · Int · column amount_minor
amountMinor
Int
receivedAt · DateTime · column received_at
receivedAt
DateTime
rate_cards
rate_cards
id · String · primary key · default uuid(
PK
id
String
accountId · String · → account.id · column account_id
FK
accountId
String
service · String
service
String
perKgMinor · Int · column per_kg_minor
perKgMinor
Int
validFrom · DateTime · column valid_from
validFrom
DateTime
validTo · DateTime · nullable · column valid_to
validTo?
DateTime
InvoiceStatus
InvoiceStatus
enum
draft
draft
issued
issued
part_paid
part_paid
paid
paid
overdue
overdue
written_off
written_off
account · accountId → id · many ↔ one
account
accountId → id
invoice · invoiceId → id · many ↔ one · on delete cascade
invoice
invoiceId → id
invoice · invoiceId → id · many ↔ one
invoice
invoiceId → id
account · accountId → id · many ↔ one
account
accountId → id
drag to pan · wheel to zoom · click a node · Esc clears
Source
Imported from showcase/prisma/schema.prisma
Cardinality: FK side = many unless the FK column is @unique