Giao diện
payment / bảng đơn lẻ (5)
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.
provider_transactions
P3-01. Provider CAPTURE/REFUND records in integer VND; unique (provider, provider_txn_id); immutable except UNKNOWN -> SUCCEEDED|FAILED; a refund returns one full original capture.
public.provider_transactions · 18 cột · 10 check · 2 unique · 7 index · 1 policy · 5 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
intent_id | uuid | NOT NULL | FK → payment_intents | |
kind | text | NOT NULL | ||
provider | text | NOT NULL | ||
provider_mode | text | NOT NULL | ||
provider_txn_id | text | NOT NULL | ||
original_transaction_id | uuid | FK → provider_transactions | ||
amount_vnd | bigint | NOT NULL | ||
currency | text | NOT NULL | ||
status | text | NOT NULL | ||
source_id | text | NOT NULL | ||
payload_hash | bytea | NOT NULL | ||
provider_recorded_at | timestamptz | |||
recorded_at | timestamptz | NOT NULL | ||
status_changed_at | timestamptz | NOT NULL | ||
change_source_id | text | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL | ||
version | integer | NOT NULL |
Khoá chính: id
Trỏ ra (2):
intent_id→payment_intents·ON DELETE RESTRICToriginal_transaction_id→provider_transactions·ON DELETE RESTRICT
Được trỏ tới (7): cashbook_entries, payment_allocations, payment_reconciliation_items, provider_transactions, refund_branches, refund_branches, vouchers
cashbook_entries
P3-08/P3-09. Append-only cashbook: automatic receipts/reversals of SUCCEEDED provider transactions (PROVIDER_TRANSACTION) and the effect of APPROVED manual vouchers (MANUAL_VOUCHER); no number, fund or balance.
public.cashbook_entries · 18 cột · 7 check · 2 unique · 5 index · 1 policy · 3 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
entry_type | text | NOT NULL | ||
source | text | NOT NULL | ||
source_id | text | NOT NULL | ||
transaction_id | uuid | FK → provider_transactions | ||
reverses_entry_id | uuid | FK → cashbook_entries | ||
intent_id | uuid | FK → payment_intents | ||
obligation_id | uuid | FK → payment_obligations | ||
order_id | uuid | FK → orders | ||
obligation_kind | text | |||
provider | text | |||
provider_mode | text | |||
amount_vnd | bigint | NOT NULL | ||
currency | text | NOT NULL | ||
occurred_at | timestamptz | NOT NULL | ||
posted_by_source_id | text | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL | ||
created_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (5):
intent_id→payment_intents·ON DELETE RESTRICTobligation_id→payment_obligations·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTreverses_entry_id→cashbook_entries·ON DELETE RESTRICTtransaction_id→provider_transactions·ON DELETE RESTRICT
Được trỏ tới (2): cashbook_entries, vouchers
cancellation_decisions
P3-12. Versioned cancellation / forfeiture policy decision of one Order (REFUND_FULL | FORFEIT | POLICY_UNDECIDED) with the stored facts and the prior delivered cycles kept. Immutable; moves no money.
public.cancellation_decisions · 23 cột · 9 check · 1 unique · 4 index · 2 policy · 3 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
order_id | uuid | NOT NULL | FK → orders | |
owner_account_id | uuid | NOT NULL | FK → accounts | |
campaign_id | uuid | NOT NULL | FK → campaigns | |
campaign_type | text | NOT NULL | ||
cause | text | NOT NULL | ||
timing | text | NOT NULL | ||
policy_version | text | NOT NULL | ||
outcome | text | NOT NULL | ||
cash_disposition | text | NOT NULL | ||
points_disposition | text | NOT NULL | ||
residual_pending | text | NOT NULL | ||
undecided_ref | text | |||
basis | text[] | NOT NULL | ||
order_version | integer | NOT NULL | ||
held_cash_vnd | bigint | |||
held_points | integer | |||
retained_cycle_count | integer | NOT NULL | ||
retained_deliveries | jsonb | NOT NULL | ||
evidence | jsonb | NOT NULL | ||
source_type | text | NOT NULL | ||
source_id | text | NOT NULL | ||
decided_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (3):
campaign_id→campaigns·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTowner_account_id→accounts·ON DELETE RESTRICT
Được trỏ tới (1): mission_reversal_evidence
deposit_checkouts
P3-04 / #479. One saga per order attempt: optional REDEEM, cash deposit (P3-02 intent), compensation by one full REVERSE_REDEEM, or (COMPENSATED_MANUALLY) by Finance's ACCEPTED CREDIT ADJUST after a rejected reversal. Orchestration record only: no balance, no ledger, no amount (the cash amount is the DEPOSIT obligation). SYSTEM_ONLY; EXECUTE-only access through payment.* functions.
public.deposit_checkouts · 26 cột · 12 check · 5 unique · 8 index · 0 policy · 12 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
order_id | uuid | NOT NULL | FK → orders | |
owner_account_id | uuid | NOT NULL | FK → accounts | |
deposit_obligation_id | uuid | NOT NULL | FK → payment_obligations | |
point_obligation_id | uuid | FK → payment_obligations | ||
points | integer | |||
rate_snapshot_vnd | numeric | |||
rate_policy_version | text | |||
redeem_request_id | text | |||
reverse_request_id | text | |||
cash_request_id | text | NOT NULL | ||
redeem_business_date | date | |||
reverse_business_date | date | |||
status | text | NOT NULL | ||
reason_code | text | |||
source_id | text | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL | ||
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL | ||
point_cap_bp | integer | |||
point_cap_policy_version | text | |||
max_points | integer | |||
points_value_vnd | bigint | P3-19. VND value of the points at the frozen rate (points x rate). A snapshot of the point tender, NOT the cash deposit (that is the DEPOSIT obligation) and never subtracted from it. | ||
attempt_no | integer | NOT NULL | #377. 1 for the first deposit attempt of the order, +1 per retry after a REDEEM_REJECTED / CASH_FAILED / COMPENSATED attempt. Names the PiPoint business source of attempts after the first (deposit:<order>:<n>). | |
method | text | NOT NULL | G1S-P0-03 (BR-DC-08). Payment method of this attempt (SDL DepositPaymentMethod), chosen last on U-31; MOMO_WALLET for every attempt before G1S. Stored by payment.buyer_open_checkout from P1-05. |
Khoá chính: id
Trỏ ra (4):
deposit_obligation_id→payment_obligations·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTowner_account_id→accounts·ON DELETE RESTRICTpoint_obligation_id→payment_obligations·ON DELETE RESTRICT
Được trỏ tới: không có
funds
FU-713 DEC-FIN-FUNDS. The funds of manual vouchers: one CASH row (seeded) + one BANK row per company bank account (operator script). Bank name + last digits only. No balance, never linked to a bank statement in R1.
public.funds · 8 cột · 5 check · 0 unique · 3 index · 1 policy · 3 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
code | text | NOT NULL | PK | |
kind | text | NOT NULL | ||
name | text | NOT NULL | ||
bank_name | text | |||
account_tail | text | |||
status | text | NOT NULL | ||
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL |
Khoá chính: code
Trỏ ra: không có
Được trỏ tới: không có