diff --git a/clearing-parent/account-service/src/main/java/ru/spcex/clearing/account/service/TradingClearingRegistryService.java b/clearing-parent/account-service/src/main/java/ru/spcex/clearing/account/service/TradingClearingRegistryService.java index 675c3d7bb..646decd21 100644 --- a/clearing-parent/account-service/src/main/java/ru/spcex/clearing/account/service/TradingClearingRegistryService.java +++ b/clearing-parent/account-service/src/main/java/ru/spcex/clearing/account/service/TradingClearingRegistryService.java @@ -49,7 +49,9 @@ import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender; import ru.spcex.clearing.util.security.UserRoleVerification; import ru.spcex.clearing.util.services.RequestHelper; import ru.spcex.clearing.validation.common.ValidationHelper; +import ru.spcex.platform.enumeration.AccountType; import ru.spcex.platform.enumeration.CompanySymbol; +import ru.spcex.platform.enumeration.CurrencyCode; import ru.spcex.platform.enumeration.ServiceStatus; import ru.spcex.platform.enumeration.Status; import static ru.spcex.platform.enumeration.Task.makeFiles_MTCR; @@ -460,13 +462,13 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "MoneyAccountId", req.getMoneyAccountId()); } if (tradingClearingRegistry.getDepoAccountId() != null && // но можно с null заменить - req.getDepoAccountId() != null && !req.getDepoAccountId().equals(tradingClearingRegistry.getDepoAccountId())) { + req.getDepoAccountId() != null && !req.getDepoAccountId().equals(tradingClearingRegistry.getDepoAccountId())) { return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "DepoAccountId", req.getDepoAccountId()); } // tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId()); if (req.getStatus() != null && !Objects.equals(req.getStatus(), tradingClearingRegistry.getStatus()) - || req.getDepoAccountId() != null && !req.getDepoAccountId().equals(tradingClearingRegistry.getDepoAccountId()) + || req.getDepoAccountId() != null && !req.getDepoAccountId().equals(tradingClearingRegistry.getDepoAccountId()) ) { Instant now = Instant.now(); tradingClearingRegistry.setUpdated(now); @@ -586,6 +588,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini MoneyAccountMsgResponse moneyAccountMsg = new MoneyAccountMsgResponse(); moneyAccountMsg.setAccount(moneyAccount.getAccount()); moneyAccountMsg.setCurrCode(StringUtils.hasText(moneyAccount.getCurrency()) ? moneyAccount.getCurrency() : "RUB"); + getEksAccount(moneyAccount).ifPresent(moneyAccountMsg::setEksAccount); moneyAccountMsg.setActive(Status.Active.equalsByKey(moneyAccount.getStatus())); tkr.getMoneyAccounts().add(moneyAccountMsg); } @@ -600,6 +603,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini Account additionalAcc = accountImdg.getSingleObjectByID(tkrList.getAccountId()); MoneyAccountMsgResponse moneyAccountMsg = new MoneyAccountMsgResponse(); moneyAccountMsg.setAccount(additionalAcc.getAccount()); + getEksAccount(additionalAcc).ifPresent(moneyAccountMsg::setEksAccount); moneyAccountMsg.setCurrCode(StringUtils.hasText(additionalAcc.getCurrency()) ? additionalAcc.getCurrency() : "RUB"); moneyAccountMsg.setActive(Status.Active.equalsByKey(additionalAcc.getStatus())); tkr.getMoneyAccounts().add(moneyAccountMsg); @@ -610,6 +614,22 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini return Optional.empty(); } + private Optional getEksAccount(Account account) { + if (AccountType.Info.equalsByKey(account.getAccountType())) { + String currency = StringUtils.hasText(account.getCurrency()) ? account.getCurrency() : CurrencyCode.RUB.getKey(); + Account anltAcc = accountImdg.getFirstObjectByFieldValues( + Map.of( + "currency", currency, + "accountType", AccountType.Anlt.getKey() + ) + ); + if (anltAcc != null) { + return Optional.of(anltAcc.getAccount()); + } + } + return Optional.empty(); + } + /** * company-service сообщение об успешном добавлении ТКР клиента с параметром tradingClearingRegistry.code */