Entity invoice
Subject areas: Billing
Attributes
| # | Name | Type | Null | Default | Key | Terms | Description |
|---|---|---|---|---|---|---|---|
| 1 | id | bigint | no | PK | |||
| 2 | tenant_id | domain tenant_ref (bigint) | yes | UQ, FK | |||
| 3 | subscription_id | bigint | no | FK | |||
| 4 | number | text(30) | no | UQ | |||
| 5 | issued_on | date | no | ||||
| 6 | total | decimal(12, 2) | no | 0 |
Keys
| Kind | Name | Attributes |
|---|---|---|
| primary | pk_invoice | id |
| unique | uq_invoice_tenant_number | tenant_id, number |
Relationships
| Name | Role | Other entity | Cardinality | Attributes | Identifying | On delete | On update |
|---|---|---|---|---|---|---|---|
| invoice_line_invoice | parent | invoice_line | one to one_or_many | invoice_line.invoice_id -> invoice.id | yes | cascade | no_action |
| invoice_subscription | child | subscription | one to many | invoice.subscription_id -> subscription.id | no | no_action | no_action |
| invoice_tenant | child | tenant | one to many | invoice.tenant_id -> tenant.id | no | cascade | no_action |
Physical
lite (sqlite): main.invoice
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
|---|---|---|---|---|---|---|---|---|
| 1 | id | integer | no | by_default | id | |||
| 2 | tenant_id | integer | no | tenant_id | ||||
| 3 | subscription_id | integer | no | subscription_id | ||||
| 4 | number | text | no | number | ||||
| 5 | issued_on | text | no | issued_on | ||||
| 6 | total | numeric | no | 0 | total |
- primary key pk_invoice (id)
- unique uq_invoice_tenant_number (tenant_id, number)
- foreign key fk_invoice_subscription (subscription_id) references subscription (id)
- foreign key fk_invoice_tenant (tenant_id) references tenant (id) on delete cascade
- index ix_invoice_subscription (subscription_id)
pg (postgresql): app.invoice
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
|---|---|---|---|---|---|---|---|---|
| 1 | id | bigint | no | always | id | |||
| 2 | tenant_id | bigint | no | tenant_id | ||||
| 3 | subscription_id | bigint | no | subscription_id | ||||
| 4 | number | varchar(30) | no | number | ||||
| 5 | issued_on | date | no | issued_on | ||||
| 6 | total | numeric(12, 2) | no | 0 | total |
- primary key pk_invoice (id)
- unique uq_invoice_tenant_number (tenant_id, number)
- foreign key fk_invoice_subscription (subscription_id) references subscription (id)
- foreign key fk_invoice_tenant (tenant_id) references tenant (id) on delete cascade
- index ix_invoice_subscription (subscription_id)