This commit is contained in:
parent
684190cfa1
commit
622c811a17
2 changed files with 54 additions and 15 deletions
|
|
@ -117,6 +117,24 @@ public enum GatewayEksClientCodeValidationRule implements IValidationRule<ImdgVa
|
|||
return Optional.empty();
|
||||
}
|
||||
},
|
||||
DepoAccountsNotLinkedToTkr() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<TkrAccount> context) {
|
||||
TkrAccount validatedObject = context.getValidatedObject();
|
||||
Optional<DepoAccount> depoAccount = context.getStoredObject(ClientCodeStoreObjects.DEPO_ACCOUNT);
|
||||
if (depoAccount.isPresent()) {
|
||||
Imdg<TradingClearingRegistry> tradingClearingRegistryImdg = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
ImdgPredicateBuilder predicateBuilder = tradingClearingRegistryImdg.predicateBuilder();
|
||||
Collection<Long> tkrIds = tradingClearingRegistryImdg.getCollectionIdsByPredicate(
|
||||
predicateBuilder.equals("depoAccountId", depoAccount.get().getId())
|
||||
);
|
||||
if (tkrIds != null && !tkrIds.isEmpty()) {
|
||||
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, depoAccount.get().getId());
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
},
|
||||
ClsAccountsPresent() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<TkrAccount> context) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ru.spcex.clearing.account.validation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
|
@ -97,7 +98,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
);
|
||||
if (depoAccount == null) {
|
||||
context.storeObject(ClientCodeStoreObjects.DEPO_ACCOUNT, Optional.empty());
|
||||
return of(AccountError.AccountNotFound, "depo_account");
|
||||
return of(AccountError.DepoAccountNotFound, "depo_account");
|
||||
}
|
||||
if (!depoAccount.getAccountId().equals(tkr.getDepoAccountId())) {
|
||||
return of(AccountError.DepoAccountChangeNotAllowed, depoAccount.getAccountId());
|
||||
|
|
@ -116,7 +117,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
&& CurrencyCode.RUB.equalsByKey(moneyAccountMsgRequest.getCurrCode()))
|
||||
.toList();
|
||||
if (!accounts.isEmpty()) {
|
||||
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, accounts.stream().findFirst().get().getAccount());
|
||||
return of(AccountError.CurrencyForTradingClearingRegistryListAlreadyUsed, accounts.stream().findFirst().get().getAccount());
|
||||
}
|
||||
return empty();
|
||||
}
|
||||
|
|
@ -150,6 +151,8 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<TkrAccount> context) {
|
||||
TkrAccount validatedObject = context.getValidatedObject();
|
||||
TradingClearingRegistry tkr = context.getStoredObject(ClientCodeStoreObjects.TRADING_CLEARING_REGISTRY);
|
||||
Company company = context.getStoredObject(ClientCodeStoreObjects.COMPANY);
|
||||
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<TradingClearingRegistryList> tkrList = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistryList, TradingClearingRegistryList.class);
|
||||
ImdgPredicateBuilder predicateBuilder = accountImdg.predicateBuilder();
|
||||
|
|
@ -168,17 +171,29 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
Account account = accountImdg.getFirstObjectByPredicate(
|
||||
predicateBuilder.and(
|
||||
predicateBuilder.equals("account", request.getAccount()),
|
||||
predicateBuilder.equals("accountType", AccountType.Clrn.getKey())
|
||||
predicateBuilder.equals("accountType", AccountType.Clrn.getKey()),
|
||||
predicateBuilder.equals("companyId", company.getId())
|
||||
)
|
||||
);
|
||||
|
||||
if (account == null) {
|
||||
return of(AccountError.AccountNotFound, request.getAccount());
|
||||
}
|
||||
TradingClearingRegistryList tkrListByAccount = tkrList.getSingleObjectByPredicate(
|
||||
predicateBuilder.equals("accountId", account.getId())
|
||||
Collection<Long> tkrListByCurrency = tkrList.getCollectionIdsByPredicate(
|
||||
predicateBuilder.and(
|
||||
predicateBuilder.equals("currency", account.getCurrency()),
|
||||
predicateBuilder.equals("tradingClearingRegistryId", tkr.getId())
|
||||
)
|
||||
);
|
||||
if (tkrListByAccount != null) {
|
||||
if (tkrListByCurrency != null && !tkrListByCurrency.isEmpty()) {
|
||||
return of(AccountError.CurrencyForTradingClearingRegistryListAlreadyUsed, account.getId());
|
||||
}
|
||||
Collection<Long> tkrListByAccount = tkrList.getCollectionIdsByPredicate(
|
||||
predicateBuilder.and(
|
||||
predicateBuilder.equals("accountId", account.getId())
|
||||
)
|
||||
);
|
||||
if (tkrListByAccount != null && !tkrListByAccount.isEmpty()) {
|
||||
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, account.getId());
|
||||
}
|
||||
clrnAccounts.add(account);
|
||||
|
|
@ -188,20 +203,22 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
Account account = accountImdg.getFirstObjectByPredicate(
|
||||
predicateBuilder.and(
|
||||
predicateBuilder.equals("account", request.getAccount()),
|
||||
predicateBuilder.equals("accountType", AccountType.Clrn.getKey())
|
||||
predicateBuilder.equals("accountType", AccountType.Clrn.getKey()),
|
||||
predicateBuilder.equals("companyId", company.getId())
|
||||
|
||||
)
|
||||
);
|
||||
if (account == null) {
|
||||
return of(AccountError.AccountNotFound, request.getAccount());
|
||||
}
|
||||
TradingClearingRegistryList tkrListByAccount = tkrList.getSingleObjectByPredicate(
|
||||
Collection<Long> tkrListByAccount = tkrList.getCollectionIdsByPredicate(
|
||||
predicateBuilder.and(
|
||||
predicateBuilder.equals("accountId", account.getId()),
|
||||
predicateBuilder.equals("currency", account.getCurrency())
|
||||
predicateBuilder.equals("tradingClearingRegistryId", tkr.getId())
|
||||
)
|
||||
);
|
||||
if (tkrListByAccount == null) {
|
||||
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, account.getId());
|
||||
if (tkrListByAccount == null || tkrListByAccount.isEmpty()) {
|
||||
return of(AccountError.AccountNotFound, account.getId());
|
||||
}
|
||||
}
|
||||
context.storeObject(ClientCodeStoreObjects.CLRN_ACCS, clrnAccounts);
|
||||
|
|
@ -212,6 +229,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<TkrAccount> context) {
|
||||
TkrAccount validatedObject = context.getValidatedObject();
|
||||
TradingClearingRegistry tkr = context.getStoredObject(ClientCodeStoreObjects.TRADING_CLEARING_REGISTRY);
|
||||
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<TradingClearingRegistryList> tkrList = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistryList, TradingClearingRegistryList.class);
|
||||
ImdgPredicateBuilder predicateBuilder = accountImdg.predicateBuilder();
|
||||
|
|
@ -232,11 +250,14 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
if (account == null) {
|
||||
return of(AccountError.AccountNotFound, request.getAccount());
|
||||
}
|
||||
TradingClearingRegistryList tkrListByAccount = tkrList.getSingleObjectByPredicate(
|
||||
predicateBuilder.equals("currency", account.getCurrency())
|
||||
Collection<Long> tkrListByAccount = tkrList.getCollectionIdsByPredicate(
|
||||
predicateBuilder.and(
|
||||
predicateBuilder.equals("currency", account.getCurrency()),
|
||||
predicateBuilder.equals("tradingClearingRegistryId", tkr.getId())
|
||||
)
|
||||
);
|
||||
if (tkrListByAccount != null) {
|
||||
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, account.getId());
|
||||
if (tkrListByAccount != null && !tkrListByAccount.isEmpty()) {
|
||||
return of(AccountError.CurrencyForTradingClearingRegistryListAlreadyUsed, account.getId());
|
||||
}
|
||||
anltAccounts.add(account);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue