Add migration to enhance session_payments table with payment_method_uuid and reference fields for split-payment details
This commit is contained in:
+10
-3
@@ -531,8 +531,8 @@ transaction**. If any step fails nothing is committed.
|
||||
{
|
||||
"version": 3,
|
||||
"payments": [
|
||||
{ "method": "cash", "amount_rials": 2000000 },
|
||||
{ "method": "pos", "amount_rials": 3000000 }
|
||||
{ "method": "pos", "amount_rials": 3000000, "payment_method_uuid": "…pos-uuid…", "reference": "TRX-42" },
|
||||
{ "method": "cash", "amount_rials": 2000000 }
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -540,7 +540,14 @@ transaction**. If any step fails nothing is committed.
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `version` | integer | ❌ | Optimistic lock version; defaults to the stored one |
|
||||
| `payments` | array | ❌ | Empty/absent = confirm without payment. Each row: `method` ∈ `wallet\|pos\|cash\|card` and `amount_rials` > 0. Several rows are allowed (split payment). |
|
||||
| `payments` | array | ❌ | Empty/absent = confirm without payment. Several rows allowed (split payment). |
|
||||
| `payments[].method` | string | ✅ | ∈ `wallet\|pos\|cash\|card` |
|
||||
| `payments[].amount_rials` | integer | ✅ | > 0 |
|
||||
| `payments[].payment_method_uuid` | string | ❌ | uuid of a registered POS device (`pos`) or bank account (`card`) from `/api/v1/my/payment-methods/*`. Stored as-is (max 36). |
|
||||
| `payments[].reference` | string | ❌ | Transaction / tracking id (max 255). |
|
||||
|
||||
Each stored payment keeps its `method`, `amount_rials`, `payment_method_uuid`, `reference`,
|
||||
and `paid_at` (see the `session_payments[]` in the visit response).
|
||||
|
||||
The sum of `payments` may not exceed the visit's payable amount → `ERR_SESSION_PAYMENT_EXCEEDS`.
|
||||
Partial payment is normal: the remainder stays as `remaining_rials` on the visit and can be
|
||||
|
||||
+2
-1
@@ -612,11 +612,12 @@ POST /api/v1/session/{uuid}/payments
|
||||
"patient_debt_rials": 0,
|
||||
"paid_at": 1770000000,
|
||||
"payments": [
|
||||
{ "uuid": "...", "method": "cash", "amount_rials": 200000, "paid_at": 1770000000, "created_by_name": "...", "created_at": 1770000000 }
|
||||
{ "uuid": "...", "method": "cash", "amount_rials": 200000, "payment_method_uuid": null, "reference": null, "paid_at": 1770000000, "created_by_name": "...", "created_at": 1770000000 }
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
> `payment_method_uuid` (uuid کارتخوان/حساب بانکیِ ثبتشده) و `reference` (شناسه تراکنش) از مسیرِ split-paymentِ «قطعی کردن نوبت» (`POST /api/v1/appointment/{uuid}/confirm`) پر میشوند؛ در پرداختِ تکروشیِ `POST /api/v1/session/{uuid}/payments` معمولاً `null` میمانند.
|
||||
|
||||
**Errors:**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user