source: docs/P3-UseCaseModel/UseCase0003.md@ b715712

main
Last change on this file since b715712 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
Line 
1# Use-case 0003 — Deposit virtual funds
2
3**Initiating actor:** Trader
4
5**Other actors:** —
6
7A 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
111. Trader chooses "Deposit virtual funds" from the authenticated menu.
122. System prompts for an amount in USD.
133. Trader enters an amount.
144. System validates: amount must parse as a positive number.
155. 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 ```
306. System confirms "Deposited X USD." and returns to the authenticated menu.
31
32### Alternate flow 4a — invalid input
33
34If the amount is non-positive or non-numeric, system responds "Invalid amount." and scenario returns to step 2.
35
36### Verification query
37
38To see the balance after the deposit, the Trader can trigger UC0006, or directly:
39
40```sql
41SELECT available_balance, invested_balance
42 FROM project.users
43 WHERE id = $1;
44```
Note: See TracBrowser for help on using the repository browser.