diff options
| author | Kostya <mail@sartin.in> | 2026-10-09 10:18:41 +0300 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-10-09 10:19:12 +0300 |
| commit | 246c1ab5ffce1a1bb3c0534868b29f6e4c862a62 (patch) | |
| tree | 2418952c9844205d7f003b130f39fc1738a952f1 /ui-desktop/src/main/java/market/guess/ui/desktop | |
| parent | 95eb4ff500defc4e34d043bbc096593ffcadecea (diff) | |
| download | guess-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 'ui-desktop/src/main/java/market/guess/ui/desktop')
| -rw-r--r-- | ui-desktop/src/main/java/market/guess/ui/desktop/ServiceEngine.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ui-desktop/src/main/java/market/guess/ui/desktop/ServiceEngine.java b/ui-desktop/src/main/java/market/guess/ui/desktop/ServiceEngine.java index 549991e..6921735 100644 --- a/ui-desktop/src/main/java/market/guess/ui/desktop/ServiceEngine.java +++ b/ui-desktop/src/main/java/market/guess/ui/desktop/ServiceEngine.java | |||
| @@ -44,9 +44,9 @@ public final class ServiceEngine { | |||
| 44 | Loader loader = new XMLLoaderV2(eventRepo, userRepo, mapper, validator); | 44 | Loader loader = new XMLLoaderV2(eventRepo, userRepo, mapper, validator); |
| 45 | 45 | ||
| 46 | this.catalogContext = new LocalCatalogContext(loader, marketContextInfrastructure, eventRepo); | 46 | this.catalogContext = new LocalCatalogContext(loader, marketContextInfrastructure, eventRepo); |
| 47 | this.accountContext = new LocalAccountContext(userRepo); | ||
| 48 | |||
| 49 | LedgerContext ledgerContext = new LedgerContext(userRepo, clock); | 47 | LedgerContext ledgerContext = new LedgerContext(userRepo, clock); |
| 48 | this.accountContext = new LocalAccountContext(userRepo, ledgerContext); | ||
| 49 | |||
| 50 | RiskEngine risk = new LocalRiskEngine(eventRepo); | 50 | RiskEngine risk = new LocalRiskEngine(eventRepo); |
| 51 | MatchingEngine matching = new LocalMatchingEngine(clock); | 51 | MatchingEngine matching = new LocalMatchingEngine(clock); |
| 52 | FulfillmentContext fulfillment = new LocalFulfillmentContext(ledgerContext); | 52 | FulfillmentContext fulfillment = new LocalFulfillmentContext(ledgerContext); |