aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/main/java/market/guess
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-10-09 10:18:41 +0300
committerKostya <mail@sartin.in>2026-10-09 10:19:12 +0300
commit246c1ab5ffce1a1bb3c0534868b29f6e4c862a62 (patch)
tree2418952c9844205d7f003b130f39fc1738a952f1 /api/src/main/java/market/guess
parent95eb4ff500defc4e34d043bbc096593ffcadecea (diff)
downloadguess-market-246c1ab5ffce1a1bb3c0534868b29f6e4c862a62.tar.gz
guess-market-246c1ab5ffce1a1bb3c0534868b29f6e4c862a62.tar.xz
guess-market-246c1ab5ffce1a1bb3c0534868b29f6e4c862a62.zip
account: let users deposit cash into their account
Exercise 3 replaces the fixed initial cash of Exercise 2 with accounts that users top up themselves. Add AccountContext.deposit, which credits a DEPOSIT entry through LedgerContext so it carries a timestamp and a running balance like every other ledger movement, and return the updated account. The amount crosses the api boundary as a string, like all money values. Reject anything that is not a positive number with at most two decimal places instead of rounding it, so a user is never credited a different amount than they asked for. A deposit can bring a negative account back above zero, which lifts the block.
Diffstat (limited to 'api/src/main/java/market/guess')
-rw-r--r--api/src/main/java/market/guess/api/AccountContext.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/api/src/main/java/market/guess/api/AccountContext.java b/api/src/main/java/market/guess/api/AccountContext.java
index 8d880aa..e43760a 100644
--- a/api/src/main/java/market/guess/api/AccountContext.java
+++ b/api/src/main/java/market/guess/api/AccountContext.java
@@ -7,4 +7,7 @@ public interface AccountContext {
7 Result<List<LedgerDTO>> getAllAccounts(); 7 Result<List<LedgerDTO>> getAllAccounts();
8 8
9 Result<LedgerDTO> getAccount(String owner); 9 Result<LedgerDTO> getAccount(String owner);
10
11 /** Credits a positive amount (decimal string, e.g. "250.00") to the owner's account. */
12 Result<LedgerDTO> deposit(String owner, String amount);
10} 13}