From 246c1ab5ffce1a1bb3c0534868b29f6e4c862a62 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 9 Oct 2026 10:18:41 +0300 Subject: 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. --- ui-desktop/src/main/java/market/guess/ui/desktop/ServiceEngine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui-desktop/src/main') 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 { Loader loader = new XMLLoaderV2(eventRepo, userRepo, mapper, validator); this.catalogContext = new LocalCatalogContext(loader, marketContextInfrastructure, eventRepo); - this.accountContext = new LocalAccountContext(userRepo); - LedgerContext ledgerContext = new LedgerContext(userRepo, clock); + this.accountContext = new LocalAccountContext(userRepo, ledgerContext); + RiskEngine risk = new LocalRiskEngine(eventRepo); MatchingEngine matching = new LocalMatchingEngine(clock); FulfillmentContext fulfillment = new LocalFulfillmentContext(ledgerContext); -- cgit v1.2.3