main
|
Last change
on this file since 1549dae was ef1c1c7, checked in by Stefan <trsunovstefan@…>, 6 days ago |
|
Wiki docs, phase 6 and phase 7 added
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Rev | Line | |
|---|
| [ef1c1c7] | 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 | {{{
|
|---|
| 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 |
|
|---|
| 31 | 6. System confirms "Deposited X USD." and returns to the authenticated menu.
|
|---|
| 32 |
|
|---|
| 33 | === Alternate flow 4a — invalid input ===
|
|---|
| 34 |
|
|---|
| 35 | If the amount is non-positive or non-numeric, system responds "Invalid amount." and scenario returns to step 2.
|
|---|
| 36 |
|
|---|
| 37 | === Verification query ===
|
|---|
| 38 |
|
|---|
| 39 | To see the balance after the deposit, the Trader can trigger UC0006, or directly:
|
|---|
| 40 |
|
|---|
| 41 | {{{
|
|---|
| 42 | SELECT available_balance, invested_balance
|
|---|
| 43 | FROM project.users
|
|---|
| 44 | WHERE id = $1;
|
|---|
| 45 | }}}
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.