public.bills
Description
Labels
svc-smarttab
Columns
| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| id | uuid | false | public.loyalty_transactions public.splits public.payments public.receipts public.bill_operation_histories | Bill identifier (UUID). | ||
| order_id | uuid | true | public.orders | Source order ID. | ||
| customer_id | integer | true | public.customers | Customer ID. | ||
| coupon_id | integer | true | public.coupons | Applied coupon ID. | ||
| staff_code | varchar(50) | true | Staff code who created/modified bill. | |||
| bill_number | varchar(50) | false | Bill number (globally unique). | |||
| subtotal | numeric(12,2) | 0.00 | false | Bill subtotal amount. | ||
| discount_amount | numeric(12,2) | 0.00 | false | Discount amount. | ||
| tax | numeric(12,2) | 0.00 | false | Tax amount. | ||
| total_amount | numeric(12,2) | false | Bill total amount. | |||
| status | varchar(50) | true | Bill status: PENDING, PAID, CANCELLED. | |||
| is_split | boolean | false | true | Bill has been split flag. | ||
| is_combined | boolean | false | true | Bill is combined from multiple orders. | ||
| combined_order_ids | jsonb | true | Combined order IDs. | |||
| combined_table_numbers | jsonb | true | Combined table numbers. | |||
| created_at | timestamp with time zone | now() | true | Record creation timestamp. | ||
| updated_at | timestamp with time zone | now() | true | Record last update timestamp. | ||
| paid_at | timestamp with time zone | true | Bill payment timestamp. | |||
| merchant_id | integer | false | public.merchants | Parent merchant ID. | ||
| store_id | integer | false | public.stores | Parent store ID. | ||
| table_number | varchar(50) | true | Table number. | |||
| split_count | integer | true | Number of splits. | |||
| is_deleted | boolean | false | false | Soft delete flag. | ||
| combined_bill_ids | jsonb | true | Combined bill IDs. | |||
| description | text | true | Bill description. | |||
| customer_name | varchar(100) | true | Customer name (snapshot). |
Viewpoints
| Name | Definition |
|---|---|
| Order & Billing | Order lifecycle — Orders → Bills → Payments → Settlements |
Constraints
| Name | Type | Definition |
|---|---|---|
| bills_total_check | CHECK | CHECK ((total_amount >= (0)::numeric)) |
| bills_merchant_id_fkey | FOREIGN KEY | FOREIGN KEY (merchant_id) REFERENCES merchants(id) ON DELETE RESTRICT |
| bills_coupon_id_fkey | FOREIGN KEY | FOREIGN KEY (coupon_id) REFERENCES coupons(id) ON DELETE SET NULL |
| bills_customer_id_fkey | FOREIGN KEY | FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE SET NULL |
| bills_store_id_fkey | FOREIGN KEY | FOREIGN KEY (store_id) REFERENCES stores(id) ON DELETE RESTRICT |
| bills_order_id_fkey | FOREIGN KEY | FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE RESTRICT |
| bills_pkey | PRIMARY KEY | PRIMARY KEY (id) |
Indexes
| Name | Definition |
|---|---|
| bills_pkey | CREATE UNIQUE INDEX bills_pkey ON public.bills USING btree (id) |
| ix_bills_bill_number | CREATE UNIQUE INDEX ix_bills_bill_number ON public.bills USING btree (bill_number) |
| ix_bills_created_at | CREATE INDEX ix_bills_created_at ON public.bills USING btree (created_at) |
| ix_bills_customer_id | CREATE INDEX ix_bills_customer_id ON public.bills USING btree (customer_id) |
| ix_bills_order_id | CREATE INDEX ix_bills_order_id ON public.bills USING btree (order_id) |
| ix_bills_status | CREATE INDEX ix_bills_status ON public.bills USING btree (status) |
| ix_bills_merchant_id | CREATE INDEX ix_bills_merchant_id ON public.bills USING btree (merchant_id) |
| ix_bills_store_id | CREATE INDEX ix_bills_store_id ON public.bills USING btree (store_id) |
Relations
Generated by tbls