source: docs/P4-Prototype/UseCase0003Implementation.md@ 9e6d8a2

main
Last change on this file since 9e6d8a2 was b715712, checked in by Stefan <trsunovstefan@…>, 8 weeks ago

Add the server side and configuration

  • Property mode set to 100644
File size: 1.1 KB
Line 
1# Use-case 0003 Implementation — Deposit
2
3**Initiating actor:** Trader. **Source file:** `server/account.go`, function `Deposit`.
4
5## Scenario (implemented)
6
71. **User** chooses `[2] Deposit virtual funds`.
82. **System** prompts for an amount in USD.
93. **User** enters `2500`.
104. **System** opens a database transaction and runs:
11
12 ```sql
13 BEGIN;
14 UPDATE users
15 SET available_balance = available_balance + $1,
16 updated_at = now()
17 WHERE id = $2;
18 INSERT INTO transactions (user_id, type, amount, currency, description)
19 VALUES ($2, 'deposit', $1, 'USD', 'Virtual deposit');
20 COMMIT;
21 ```
22
23 ![Depositing 2500 USD, then checking the balance](screenshots/uc0003_deposit.png)
24
255. **System** confirms: `Deposited 2500.0000 USD.`
26
27## Verification
28
29Right after the deposit, `[1] View balance` runs:
30
31```sql
32SELECT available_balance, invested_balance FROM users WHERE id = $1;
33```
34
35In the screenshot above, alice starts from the seed state (available 8250.00,
36invested 1750.00) and ends at available **10750.00** — increased by exactly the
372500.00 deposited, with `invested_balance` untouched.
Note: See TracBrowser for help on using the repository browser.