Skip to content

payment / cod ​

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 đè.

5 bảng. Quay lại payment.

cod_collections ​

P3-06. One row per COD REMAINING obligation: DUE -> ASSIGNED -> DELIVERED -> COLLECTED -> REMITTED with set-once collection evidence; COLLECTED = delivered AND collected in full, never remitted by itself.

public.cod_collections · 28 cột · 12 check · 2 unique · 6 index · 1 policy · 5 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
obligation_iduuidNOT NULLFK → payment_obligations
order_iduuidNOT NULLFK → orders
order_cycle_iduuidFK → order_cycles
amount_due_vndbigintNOT NULL
statustextNOT NULL
shipment_iduuidFK → shipments
collector_carrier_codetext
assigned_attimestamptz
delivered_attimestamptz
collected_amount_vndbigint
collected_attimestamptz
collector_typetext
collector_reftext
collected_byuuidFK → accounts
collection_evidence_reftext
collection_proof_media_iduuidFK → media
collection_source_idtext
collection_payload_hashtext
collection_recorded_attimestamptz
completed_attimestamptz
change_sourcetextNOT NULL
change_source_idtextNOT NULL
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL
actor_labeltext
actor_rolestext[]

Khoá chính: id

Trỏ ra (6):

  • collected_by → accounts · ON DELETE RESTRICT
  • collection_proof_media_id → media · ON DELETE RESTRICT
  • obligation_id → payment_obligations · ON DELETE RESTRICT
  • order_cycle_id → order_cycles · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • shipment_id → shipments · ON DELETE RESTRICT

Được trỏ tới (3): cod_reconciliation_items, cod_remittances, order_return_cases

cod_reconciliation_runs ​

P3-14. One row per VN business date and rerun; immutable after COMPLETE/INCOMPLETE. Evidence and totals only: no tolerance, no COD/obligation/ledger write; collected is never remitted.

public.cod_reconciliation_runs · 20 cột · 11 check · 1 unique · 3 index · 4 policy · 4 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
run_date_vndateNOT NULL
run_versionintegerNOT NULL
timezonetextNOT NULL
window_starttimestamptzNOT NULL
window_endtimestamptzNOT NULL
trigger_kindtextNOT NULL
requested_byuuidFK → accounts
statustextNOT NULL
started_attimestamptzNOT NULL
finished_attimestamptz
dataset_hashbytea
totalsjsonb
error_codetext
lease_ownertext
lease_expires_attimestamptz
correlation_idcorrelation_refNOT NULL
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL

Khoá chính: id

Trỏ ra (1):

  • requested_by → accounts · ON DELETE RESTRICT

Được trỏ tới (2): cod_reconciliation_items, cod_remittance_gaps

cod_reconciliation_items ​

P3-14. One COD discrepancy of a run (the five sow/03 s12 types); evidence immutable, handling columns follow OPEN -> IN_PROGRESS -> RESOLVED (no handling command yet, GAP-102). Never edits COD/obligation/shipment rows.

public.cod_reconciliation_items · 21 cột · 11 check · 1 unique · 4 index · 3 policy · 5 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
run_iduuidNOT NULLFK → cod_reconciliation_runs
discrepancy_typetextNOT NULL
item_keytextNOT NULL
collection_iduuidNOT NULLFK → cod_collections
shipment_iduuidFK → shipments
local_statustextNOT NULL
carrier_statustext
local_amount_vndbigint
remote_amount_vndbigint
evidencejsonbNOT NULL
statustextNOT NULL
owner_account_iduuidFK → accounts
notetext
resolved_byuuidFK → accounts
resolved_attimestamptz
resolution_notetext
correlation_idcorrelation_refNOT NULL
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL

Khoá chính: id

Trỏ ra (5):

  • collection_id → cod_collections · ON DELETE RESTRICT
  • owner_account_id → accounts · ON DELETE RESTRICT
  • resolved_by → accounts · ON DELETE RESTRICT
  • run_id → cod_reconciliation_runs · ON DELETE RESTRICT
  • shipment_id → shipments · ON DELETE RESTRICT

Được trỏ tới: không có

cod_remittance_gaps ​

P3-14. Delivered / collected / remitted / awaiting-remittance counts and VND per carrier, collector and VN date of one run, as of its window end. Collected is not remitted; no overdue flag (no deadline sourced, GAP-78).

public.cod_remittance_gaps · 15 cột · 4 check · 1 unique · 3 index · 3 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
run_iduuidNOT NULLFK → cod_reconciliation_runs
carrier_codetextNOT NULL
collector_typetextNOT NULL
collector_reftextNOT NULL
event_date_vndateNOT NULL
delivered_not_collected_countintegerNOT NULL
delivered_not_collected_vndbigintNOT NULL
collected_countintegerNOT NULL
collected_vndbigintNOT NULL
remitted_countintegerNOT NULL
remitted_vndbigintNOT NULL
awaiting_remittance_countintegerNOT NULL
awaiting_remittance_vndbigintNOT NULL
created_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (1):

  • run_id → cod_reconciliation_runs · ON DELETE RESTRICT

Được trỏ tới: không có

cod_remittances ​

P3-06. Append-only remittance evidence of one COLLECTED COD row (who/when/amount/reference/document); separate from collection; no funds/cashbook/settlement effect.

public.cod_remittances · 10 cột · 3 check · 3 unique · 5 index · 1 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
collection_iduuidNOT NULLFK → cod_collections
remittance_reftextNOT NULL
amount_vndbigintNOT NULL
remitted_attimestamptzNOT NULL
recorded_byuuidNOT NULLFK → accounts
proof_media_iduuidFK → media
notetext
source_idtextNOT NULL
created_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (3):

  • collection_id → cod_collections · ON DELETE RESTRICT
  • proof_media_id → media · ON DELETE RESTRICT
  • recorded_by → accounts · ON DELETE RESTRICT

Được trỏ tới: không có

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17