Giao diện
order_fulfillment / stock
Trang sinh tự động
Sinh từ ad83b0aea — chạy 820 migration lên PostgreSQL 17 rồi đọc pg_catalog. Mô tả bảng và cột lấy từ COMMENT ON. Không sửa tay: lần chạy docgen sau sẽ ghi đè.
2 bảng. Quay lại order_fulfillment.
stock_shortage_cases
P2-19. Ops shortage decision (A-OD-07, interim AS-02): source Campaign Product (+ cycle), reason, private evidence, the affected whole Orders (child rows). Born CONFIRMED with the cancellations; immutable.
public.stock_shortage_cases · 14 cột · 9 check · 1 unique · 4 index · 1 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
case_type | text | NOT NULL | ||
status | text | NOT NULL | ||
campaign_id | uuid | NOT NULL | FK → campaign_products | |
campaign_product_id | uuid | NOT NULL | FK → campaign_products | |
cycle_no | integer | |||
reason | text | NOT NULL | ||
evidence_media_ids | uuid[] | NOT NULL | ||
policy_ref | text | NOT NULL | ||
order_count | integer | NOT NULL | ||
recorded_by | uuid | NOT NULL | FK → accounts | |
source_event_id | text | NOT NULL | ||
recorded_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL |
Khoá chính: id
Trỏ ra (3):
campaign_id→campaigns·ON DELETE RESTRICTcampaign_product_id, campaign_id→campaign_products·ON DELETE RESTRICTrecorded_by→accounts·ON DELETE RESTRICT
Được trỏ tới (4): payment_remaining_recalcs, point_reward_partial_cancels, refund_cases, stock_shortage_case_orders
stock_shortage_case_orders
P2-19. Whole affected Order of a shortage case: missing quantity, delivered/undelivered evidence, refund snapshot (FULL_ORDER, P3 executes), applied interim rules, LOCKED -> CANCELLED version step. Immutable.
public.stock_shortage_case_orders · 27 cột · 7 check · 1 unique · 5 index · 2 policy · 4 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
case_id | uuid | NOT NULL | FK → stock_shortage_cases | |
order_id | uuid | NOT NULL | FK → orders | |
owner_account_id | uuid | NOT NULL | FK → accounts | |
campaign_type | text | NOT NULL | ||
policy_version_id | uuid | NOT NULL | FK → campaign_policy_versions | |
missing_quantity | integer | NOT NULL | ||
line_quantity | integer | NOT NULL | ||
ordered_units | bigint | NOT NULL | ||
committed_cycles | integer | NOT NULL | ||
delivered_cycles | integer | NOT NULL | ||
undelivered_units | bigint | NOT NULL | ||
deposit_vnd | bigint | NOT NULL | ||
points_used | integer | NOT NULL | ||
points_value_vnd | bigint | NOT NULL | ||
applied_rules | text[] | NOT NULL | ||
from_version | integer | NOT NULL | ||
to_version | integer | NOT NULL | ||
refund_scope | text | NOT NULL | ||
recorded_at | timestamptz | NOT NULL | ||
outcome | text | NOT NULL | FU-575. WHOLE_ORDER (AS-01/AS-02: nothing remains, or Recurring) or PARTIAL_UNITS (DEC-CP-SHORTAGE: the Order stays LOCKED). | |
cancelled_before | integer | NOT NULL | ||
remaining_after | integer | NOT NULL | ||
refund_cash_vnd | bigint | NOT NULL | FU-575. Deposit share to refund for this row, server-computed (cumulative rounding, deposit kept rounded up). | |
refund_points | integer | NOT NULL | FU-575. Points share to reverse for this row, server-computed (cumulative floor). | |
remaining_obligation | text | NOT NULL | FU-575. REMAINING payment obligation of the Order when recorded (NONE | OPEN | SETTLED): its amount is NOT recalculated (GAP-850). | |
cycle_units | jsonb | FU-SHORTAGE2. Recurring only: [{cycleNo, units}] the units this row cancelled per undelivered cycle (last cycle first, PAY-BRULE-26). |
Khoá chính: id
Trỏ ra (4):
case_id→stock_shortage_cases·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTowner_account_id→accounts·ON DELETE RESTRICTpolicy_version_id→campaign_policy_versions·ON DELETE RESTRICT
Được trỏ tới: không có