account-service BankAccount SameAccountValidationRule поле account не обязательное.

This commit is contained in:
AKurakin 2024-07-10 16:01:06 +03:00
parent 1b8e773f26
commit 18b94c71fe
2 changed files with 5 additions and 5 deletions

View file

@ -56,10 +56,6 @@ public class BankAccountValidationConfig {
AccountError.RequiredFieldEmpty,
AccountError.CompanyNotFound,
false),
FieldNotBlankRequiredRule.instance("account",
BankAccountNewRequest::getAccount,
AccountError.RequiredFieldEmpty
),
new SameAccountValidationRule<>(AccountType.Bank, BankAccountNewRequest::getAccount),
DictionaryPresentRule.instance("currency",
BankAccountNewRequest::getCurrency,

View file

@ -31,8 +31,12 @@ class SameAccountValidationRule<R> implements IValidationRule<ImdgValidationCont
R req = context.getValidatedObject();
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
String account = accountGetter.apply(req); // req.getAccount()
if (account == null) {
return empty();
}
ImdgPredicate query = pb.and(
pb.equals("account", accountGetter.apply(req)), // req.getAccount()
pb.equals("account", account),
// pb.equals("accountType", accountType), имена всех счетов уникальны, вне зависимости от типа
pb.in("status", ServiceStatus.Active.getKey(), ServiceStatus.Reopened.getKey(), ServiceStatus.Appl.getKey())
);