main
|
Last change
on this file since 0cee8ec was b715712, checked in by Stefan <trsunovstefan@…>, 8 weeks ago |
|
Add the server side and configuration
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Rev | Line | |
|---|
| [d8ce4e2] | 1 | # Use-case 0003 — Deposit virtual funds
|
|---|
| 2 |
|
|---|
| 3 | **Initiating actor:** Trader
|
|---|
| 4 |
|
|---|
| 5 | **Other actors:** —
|
|---|
| 6 |
|
|---|
| 7 | A logged-in Trader tops up their virtual cash balance. This is a simulation-only operation; no real money changes hands. The operation writes to two tables — the user row and the ledger — inside a single transaction.
|
|---|
| 8 |
|
|---|
| 9 | ## Scenario
|
|---|
| 10 |
|
|---|
| 11 | 1. Trader chooses "Deposit virtual funds" from the authenticated menu.
|
|---|
| 12 | 2. System prompts for an amount in USD.
|
|---|
| 13 | 3. Trader enters an amount.
|
|---|
| 14 | 4. System validates: amount must parse as a positive number.
|
|---|
| 15 | 5. System opens a transaction and increments the balance:
|
|---|
| 16 |
|
|---|
| 17 | ```sql
|
|---|
| 18 | BEGIN;
|
|---|
| 19 |
|
|---|
| 20 | UPDATE project.users
|
|---|
| 21 | SET available_balance = available_balance + $1,
|
|---|
| 22 | updated_at = now()
|
|---|
| 23 | WHERE id = $2;
|
|---|
| 24 |
|
|---|
| 25 | INSERT INTO project.transactions (user_id, type, amount, currency, description)
|
|---|
| 26 | VALUES ($2, 'deposit', $1, 'USD', 'Virtual deposit');
|
|---|
| 27 |
|
|---|
| 28 | COMMIT;
|
|---|
| 29 | ```
|
|---|
| 30 | 6. System confirms "Deposited X USD." and returns to the authenticated menu.
|
|---|
| 31 |
|
|---|
| 32 | ### Alternate flow 4a — invalid input
|
|---|
| 33 |
|
|---|
| 34 | If the amount is non-positive or non-numeric, system responds "Invalid amount." and scenario returns to step 2.
|
|---|
| 35 |
|
|---|
| 36 | ### Verification query
|
|---|
| 37 |
|
|---|
| 38 | To see the balance after the deposit, the Trader can trigger UC0006, or directly:
|
|---|
| 39 |
|
|---|
| 40 | ```sql
|
|---|
| 41 | SELECT available_balance, invested_balance
|
|---|
| 42 | FROM project.users
|
|---|
| 43 | WHERE id = $1;
|
|---|
| 44 | ```
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.