### Start Server via Console Source: https://github.com/jkazama/ddd-java/blob/master/README.md Command to launch the application using Gradle with the development profile. ```bash ./gradlew bootRun --args='--spring.profiles.active=dev' ``` -------------------------------- ### GET /asset/cio/unprocessedOut Source: https://context7.com/jkazama/ddd-java/llms.txt Retrieves all pending withdrawal requests for the authenticated customer. ```APIDOC ## GET /asset/cio/unprocessedOut ### Description Retrieves all pending withdrawal requests for the authenticated customer that haven't been processed or cancelled yet. ### Method GET ### Endpoint /asset/cio/unprocessedOut ### Response #### Success Response (200) - **Array** (object) - List of unprocessed withdrawal request objects ``` -------------------------------- ### Health Endpoint Response Source: https://context7.com/jkazama/ddd-java/llms.txt Example JSON response indicating the application's health status is 'UP'. ```json { "status": "UP" } ``` -------------------------------- ### GET /admin/asset/cio Source: https://context7.com/jkazama/ddd-java/llms.txt Administrative endpoint to search deposit and withdrawal requests. ```APIDOC ## GET /admin/asset/cio ### Description Administrative endpoint to search deposit and withdrawal requests with optional filtering. ### Method GET ### Endpoint /admin/asset/cio ### Query Parameters - **updFromDay** (string) - Optional - Start date for search (YYYY-MM-DD) - **updToDay** (string) - Optional - End date for search (YYYY-MM-DD) - **statusTypes** (string) - Optional - Comma-separated list of status types ### Response #### Success Response (200) - **Array** (object) - List of cash in/out request records ``` -------------------------------- ### Project Resource Structure Source: https://github.com/jkazama/ddd-java/blob/master/README.md Overview of the package and resource directory layout for the ddd-java project. ```text main java sample context … Infrastructure Layer controller … UI Layer model … Domain Layer usecase … Application Layer util … Utilities - Application.java … Bootstrap resources - application.yml … Spring Boot Configuration - messages-validation.properties … Validation Message Resources - messages.properties … Label Message Resources ``` -------------------------------- ### Realize Cash Flow Source: https://github.com/jkazama/ddd-java/blob/master/README.md Execute this command to realize cash flow. This operation reflects changes to the balance on the delivery date. ```bash curl -X POST http://localhost:8080/system/job/daily/realizeCashflow ``` -------------------------------- ### POST /system/job/daily/realizeCashflow Source: https://github.com/jkazama/ddd-java/blob/master/README.md Triggers the batch job to realize cash flow and reflect it to the balance on the delivery date. ```APIDOC ## POST /system/job/daily/realizeCashflow ### Description Realizes cash flow. Reflects to the balance on the delivery date. ### Method POST ### Endpoint http://localhost:8080/system/job/daily/realizeCashflow ``` -------------------------------- ### Configure Spring Boot Application Source: https://context7.com/jkazama/ddd-java/llms.txt Standard application configuration for data sources, server ports, and management endpoints. ```yaml # application.yml spring: application.name: ddd-java messages.basename: messages-validation, messages jackson.serialization: indent-output: true datasource: driver-class-name: ${JDBC_DRIVER:org.h2.Driver} url: ${JDBC_URL:jdbc:h2:mem:maindb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE} username: ${JDBC_USERNAME:} password: ${JDBC_PASSWORD:} sql: init: mode: never schema-locations: classpath:schema/schema.sql data-locations: classpath:schema/data.sql server: port: ${SERVER_PORT:8080} management: endpoints.web: exposure.include: ${MANAGEMENT_EXPOSURE:health,info} ``` -------------------------------- ### POST /system/job/daily/realizeCashflow Source: https://context7.com/jkazama/ddd-java/llms.txt Applies matured cashflows to account balances. ```APIDOC ## POST /system/job/daily/realizeCashflow ### Description Applies matured cashflows (those whose value date has been reached) to account balances. ### Method POST ### Endpoint /system/job/daily/realizeCashflow ``` -------------------------------- ### Configure Development Profile Source: https://context7.com/jkazama/ddd-java/llms.txt Sets the active Spring profile to 'dev' and enables SQL initialization and management endpoints. ```yaml spring: config.activate.on-profile: "dev" spring.sql.init.mode: always management.endpoints.web.exposure.include: "*" ``` -------------------------------- ### POST /system/job/daily/processDay Source: https://context7.com/jkazama/ddd-java/llms.txt Advances the system business day by one day. ```APIDOC ## POST /system/job/daily/processDay ### Description Moves the system business day forward by one day, affecting date-based operations. ### Method POST ### Endpoint /system/job/daily/processDay ``` -------------------------------- ### Implement AssetAdminService Administrative Tasks Source: https://context7.com/jkazama/ddd-java/llms.txt Manages batch operations for closing withdrawals and realizing cashflows with error handling and locking. ```java @Service @RequiredArgsConstructor public class AssetAdminService { private final OrmRepository rep; private final PlatformTransactionManager txm; private final AuditHandler audit; private final IdLockHandler idLock; // Close all pending withdrawals for the day public void closingCashOut() { audit.audit("Closing cash out.", () -> { TxTemplate.of(txm).tx(() -> { CashInOut.findUnprocessed(rep).forEach(cio -> { idLock.call(cio.accountId(), LockType.WRITE, () -> { try { cio.process(rep); } catch (Exception e) { cio.error(rep); // Mark as error on failure } }); }); }); }); } // Realize matured cashflows public void realizeCashflow() { audit.audit("Realize cashflow.", () -> { TxTemplate.of(txm).tx(() -> { var day = rep.dh().time().day(); for (final Cashflow cf : Cashflow.findDoRealize(rep, day)) { idLock.call(cf.accountId(), LockType.WRITE, () -> { try { cf.realize(rep); } catch (Exception e) { cf.error(rep); } return null; }); } }); }); } } ``` -------------------------------- ### Implement AssetService Customer Operations Source: https://context7.com/jkazama/ddd-java/llms.txt Handles customer-facing withdrawals and lookups using transaction templates, ID locking, and audit logging. ```java @Service @RequiredArgsConstructor public class AssetService { private final OrmRepository rep; private final PlatformTransactionManager txm; private final AuditHandler audit; private final IdLockHandler idLock; private final ApplicationEventPublisher event; // Find unprocessed withdrawals with read lock public List findUnprocessedCashOut() { final String accId = actor().id(); return TxTemplate.of(txm).readOnly().readIdLock(idLock, accId).tx(() -> { return CashInOut.findUnprocessed(rep, accId); }); } // Process withdrawal with write lock and audit public String withdraw(final RegCashOut p) { return audit.audit("Requesting a withdrawal", () -> { CashInOut cio = TxTemplate.of(txm).writeIdLock(idLock, actor().id()).tx(() -> { return CashInOut.withdraw(rep, p); }); // Publish email notification event this.event.publishEvent(AppMailEvent.of(AppMailType.FINISH_REQUEST_WITHDRAW, cio)); return cio.id(); }); } } ``` -------------------------------- ### Perform OrmRepository Data Access Operations Source: https://context7.com/jkazama/ddd-java/llms.txt Demonstrates CRUD, criteria queries, and pagination using the OrmRepository data access layer. ```java // Basic CRUD operations Account account = repository.load(Account.class, "sample"); // Throws if not found Account accountOrNull = repository.get(Account.class, "sample"); // Returns null if not found boolean exists = repository.exists(Account.class, "sample"); // Save operations CashInOut saved = repository.save(cashInOut); // Insert new CashInOut updated = repository.update(cashInOut); // Update existing CashInOut upserted = repository.saveOrUpdate(cashInOut); // Insert or update // Delete operations repository.delete(cashInOut); repository.deleteById(CashInOut.class, "id-123"); // Using OrmTemplate for criteria queries List results = repository.tmpl().find(CashInOut.class, criteria -> criteria .and("accountId").is("sample") .and("currency").is("JPY") .and("statusType").in(ActionStatusType.UNPROCESSED_TYPES), Sort.by(Sort.Direction.DESC, "updateDate")); // Pagination support Page page = repository.findAll(CashBalance.class, PageRequest.of(0, 10, Sort.by("baseDay"))); ``` -------------------------------- ### POST /system/job/daily/processDay Source: https://github.com/jkazama/ddd-java/blob/master/README.md Triggers the batch job to advance the business day to the next day. ```APIDOC ## POST /system/job/daily/processDay ### Description Advances the business day to the next day. ### Method POST ### Endpoint http://localhost:8080/system/job/daily/processDay ``` -------------------------------- ### Advance Business Day Source: https://github.com/jkazama/ddd-java/blob/master/README.md Use this command to advance the business day to the next day, typically executed after other daily closing operations. ```bash curl -X POST http://localhost:8080/system/job/daily/processDay ``` -------------------------------- ### Manage Account CashBalance Source: https://context7.com/jkazama/ddd-java/llms.txt Tracks account balances by currency and business day, supporting automatic rollover and precision-based adjustments. ```java // Get or create balance for an account (with automatic rollover) CashBalance balance = CashBalance.getOrNew(repository, "sample", "JPY"); // If no balance exists for today: // - Creates new record with previous day's amount (rollover) // - Or creates with zero if no previous balance // Add amount to balance (called during cashflow realization) CashBalance updated = balance.add(repository, new BigDecimal("-1000")); // - Applies currency-specific decimal precision // - Uses RoundingMode.DOWN for fractional amounts ``` -------------------------------- ### Handle CashInOut Withdrawal Requests Source: https://context7.com/jkazama/ddd-java/llms.txt Manages the lifecycle of deposit and withdrawal requests, including creation, processing, cancellation, and searching. ```java // Creating a withdrawal request RegCashOut request = RegCashOut.builder() .accountId("sample") .currency("JPY") .absAmount(new BigDecimal("1000")) .build(); CashInOut cashInOut = CashInOut.withdraw(repository, request); // Returns CashInOut with: // - statusType: UNPROCESSED // - eventDay: current business day // - valueDay: T+3 settlement date // - withdrawal: true // Processing a withdrawal (called by batch job) CashInOut processed = cashInOut.process(repository); // - statusType changes to PROCESSED // - cashflowId is populated with generated Cashflow ID // Cancelling a withdrawal (before event day) CashInOut cancelled = cashInOut.cancel(repository); // - statusType changes to CANCELLED // - Throws ValidationException if eventDay has passed // Finding unprocessed requests for an account List pending = CashInOut.findUnprocessed(repository, "sample"); // Search with criteria FindCashInOut criteria = FindCashInOut.builder() .currency("JPY") .statusTypes(Set.of(ActionStatusType.UNPROCESSED)) .updFromDay(LocalDate.of(2024, 1, 1)) .updToDay(LocalDate.of(2024, 1, 31)) .build(); List results = CashInOut.find(repository, criteria); ``` -------------------------------- ### Realize Cashflow Batch Job Source: https://context7.com/jkazama/ddd-java/llms.txt Applies matured cashflows to account balances. Marks cashflows as PROCESSED and updates CashBalance records. Handles balance rollovers. ```bash # Realize all cashflows that have reached their value day curl -X POST http://localhost:8080/system/job/daily/realizeCashflow # Response: HTTP 200 (no body) # Side effects: # - Cashflow records with valueDay <= today are marked PROCESSED # - CashBalance records are updated with the cashflow amounts # - New CashBalance records are created with rollover if needed ``` -------------------------------- ### Manage Account Cashflow Activity Source: https://context7.com/jkazama/ddd-java/llms.txt Handles confirmed account activity and balance realization from processed requests. ```java // Register a new cashflow (typically called from CashInOut.process) RegCashflow regCashflow = RegCashflow.builder() .accountId("sample") .currency("JPY") .amount(new BigDecimal("-1000")) // negative for withdrawal .cashflowType(CashflowType.CASH_OUT) .remark("cashOut") .eventDay(LocalDate.of(2024, 1, 15)) .valueDay(LocalDate.of(2024, 1, 18)) .build(); Cashflow cashflow = Cashflow.register(repository, regCashflow); // If valueDay <= today, automatically realizes to balance // Realize cashflow to balance (called by batch job) Cashflow realized = cashflow.realize(repository); // - statusType changes to PROCESSED // - CashBalance is updated with the amount // Find unrealized cashflows for an account List unrealized = Cashflow.findUnrealize( repository, "sample", "JPY", LocalDate.of(2024, 1, 18)); // Find all cashflows ready for realization on a specific day List toRealize = Cashflow.findDoRealize( repository, LocalDate.of(2024, 1, 18)); ``` -------------------------------- ### Request Withdrawal API Source: https://context7.com/jkazama/ddd-java/llms.txt Submit a withdrawal request for an account. Requires currency and amount. Handles insufficient funds with a 400 error. ```bash # Request a withdrawal of 1000 JPY from the sample account curl -X POST \ -H "Content-Type: application/json" \ -d '{"currency": "JPY", "absAmount": 1000}' \ http://localhost:8080/asset/cio/withdraw # Response (success): { "id": "CashInOut-20141118-001" } # Response (insufficient funds - HTTP 400): { "type": "about:blank", "title": "Bad Request", "status": 400, "detail": "error.CashInOut.withdrawAmount", "errors": [ { "field": "absAmount", "message": "error.CashInOut.withdrawAmount" } ] } ``` -------------------------------- ### Verify Server Health Source: https://github.com/jkazama/ddd-java/blob/master/README.md Command to check the health status of the running Spring Boot application. ```bash curl http://localhost:8080/actuator/health ``` -------------------------------- ### Search Internal Deposit/Withdrawal Requests Source: https://github.com/jkazama/ddd-java/blob/master/README.md REST API call for internal administrative search of deposit and withdrawal requests. ```bash curl 'http://localhost:8080/admin/asset/cio?updFromDay=yyyy-MM-dd&updToDay=yyyy-MM-dd' ``` -------------------------------- ### POST /system/job/daily/closingCashOut Source: https://github.com/jkazama/ddd-java/blob/master/README.md Triggers the batch job to close withdrawal requests. ```APIDOC ## POST /system/job/daily/closingCashOut ### Description Closes withdrawal requests. ### Method POST ### Endpoint http://localhost:8080/system/job/daily/closingCashOut ``` -------------------------------- ### Find Unprocessed Withdrawal Requests API Source: https://context7.com/jkazama/ddd-java/llms.txt Retrieve all pending withdrawal requests for the authenticated customer. Returns a list of unprocessed requests. ```bash # Get all unprocessed withdrawal requests for current user curl http://localhost:8080/asset/cio/unprocessedOut # Response: [ { "id": "CashInOut-20141118-001", "currency": "JPY", "absAmount": 1000, "requestDay": "2024-01-15", "requestDate": "2024-01-15T10:30:00", "eventDay": "2024-01-15", "valueDay": "2024-01-18", "statusType": "UNPROCESSED", "updateDate": "2024-01-15T10:30:00", "cashflowId": null } ] ``` -------------------------------- ### Advance Business Day Batch Job Source: https://context7.com/jkazama/ddd-java/llms.txt Moves the system business day forward by one day. This impacts date-based operations like balance rollover and cashflow processing. ```bash # Advance the business day to the next day curl -X POST http://localhost:8080/system/job/daily/processDay # Response: HTTP 200 (no body) # Side effects: # - Business day advances by 1 # - Triggers balance rollover when balances are accessed ``` -------------------------------- ### POST /asset/cio/withdraw Source: https://context7.com/jkazama/ddd-java/llms.txt Submits a withdrawal request for the authenticated customer's account. ```APIDOC ## POST /asset/cio/withdraw ### Description Submits a withdrawal request for the authenticated customer's account. The system validates sufficient balance and creates a record with T+3 delivery. ### Method POST ### Endpoint /asset/cio/withdraw ### Request Body - **currency** (string) - Required - The currency code (e.g., JPY) - **absAmount** (number) - Required - The absolute amount to withdraw ### Request Example { "currency": "JPY", "absAmount": 1000 } ### Response #### Success Response (200) - **id** (string) - The generated withdrawal request ID #### Response Example { "id": "CashInOut-20141118-001" } ``` -------------------------------- ### POST /system/job/daily/closingCashOut Source: https://context7.com/jkazama/ddd-java/llms.txt Processes all unprocessed withdrawal requests that have reached their event day. ```APIDOC ## POST /system/job/daily/closingCashOut ### Description Processes all unprocessed withdrawal requests that have reached their event day, generating corresponding Cashflow records. ### Method POST ### Endpoint /system/job/daily/closingCashOut ``` -------------------------------- ### Customer Withdrawal API Source: https://github.com/jkazama/ddd-java/blob/master/README.md REST API call to request a withdrawal for a specific account. ```bash curl -X POST -H "Content-Type: application/json" -d '{"accountId" : "sample" , "currency" : "JPY", "absAmount": 1000}' http://localhost:8080/asset/cio/withdraw ``` -------------------------------- ### Search Cash In/Out Requests API Source: https://context7.com/jkazama/ddd-java/llms.txt Administrative endpoint to search deposit and withdrawal requests. Supports filtering by currency, status, and date range. ```bash # Search for all cash in/out requests in a date range curl 'http://localhost:8080/admin/asset/cio?updFromDay=2024-01-01&updToDay=2024-01-31' # Search with specific status filter curl 'http://localhost:8080/admin/asset/cio?updFromDay=2024-01-01&updToDay=2024-01-31&statusTypes=UNPROCESSED,PROCESSING' # Response: [ { "id": "CashInOut-20240115-001", "accountId": "sample", "currency": "JPY", "absAmount": 1000.0000, "withdrawal": true, "requestDay": "2024-01-15", "requestDate": "2024-01-15T10:30:00", "eventDay": "2024-01-15", "valueDay": "2024-01-18", "targetFiCode": "cashOut-JPY", "targetFiAccountId": "FIsample", "selfFiCode": "cashOut-JPY", "selfFiAccountId": "xxxxxx", "statusType": "UNPROCESSED", "updateActor": "sample", "updateDate": "2024-01-15T10:30:00", "cashflowId": null } ] ``` -------------------------------- ### Search Outstanding Withdrawals Source: https://github.com/jkazama/ddd-java/blob/master/README.md REST API call to retrieve a list of unprocessed withdrawal requests. ```bash curl 'http://localhost:8080/asset/cio/unprocessedOut' ``` -------------------------------- ### Close Withdrawal Requests Source: https://github.com/jkazama/ddd-java/blob/master/README.md Execute this command to close pending withdrawal requests as part of the daily batch process. ```bash curl -X POST http://localhost:8080/system/job/daily/closingCashOut ``` -------------------------------- ### Validate Asset Withdrawals Source: https://context7.com/jkazama/ddd-java/llms.txt Checks if a withdrawal is permissible by evaluating current balances, pending cashflows, and existing requests. ```java // Check if withdrawal is allowed Asset asset = Asset.of("sample"); boolean canWithdraw = asset.canWithdraw( repository, "JPY", new BigDecimal("1000"), LocalDate.of(2024, 1, 18) // valueDay ); // Calculation considers: // - Current cash balance // - Unrealized cashflows up to valueDay // - Unprocessed withdrawal requests // - The requested withdrawal amount ``` -------------------------------- ### Close Withdrawal Requests Batch Job Source: https://context7.com/jkazama/ddd-java/llms.txt Processes unprocessed withdrawal requests that have reached their event day. Marks records as PROCESSED and creates Cashflow records. Handles individual record processing errors. ```bash # Execute the closing cash out batch job curl -X POST http://localhost:8080/system/job/daily/closingCashOut # Response: HTTP 200 (no body) # Side effects: # - CashInOut records with eventDay <= today are marked PROCESSED # - Corresponding Cashflow records are created with status UNPROCESSED # - Error status is set if processing fails for individual records ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.