This commit is contained in:
parent
4b021a5bdf
commit
d68220bf41
3 changed files with 25 additions and 1 deletions
|
|
@ -199,6 +199,7 @@ public class ValidationConfig {
|
|||
return new ValidatorImpl<>(context,
|
||||
Sdf57ValidationRule.CompanyDebOrCredPresent,
|
||||
Sdf57ValidationRule.AccountDebOrCredPresent,
|
||||
Sdf57ValidationRule.AccountAndCompanyMatch,
|
||||
Sdf57ValidationRule.CurrencyCodeCheck
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public enum ClearingError implements IErrorEnumId {
|
|||
IdentifiedFundsExceedObligations(5424L),
|
||||
ObligationsAlreadyCalculated(5425L),
|
||||
ActiveSessionIsPresent(5428L),
|
||||
AccountIsNotMatchedWithCompany(5429L),
|
||||
//ошибки "перенесенные" из balance-service,
|
||||
CompanyNotFoundB(5211L),
|
||||
CurrencyNotFound(5213L),
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
|
|||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public enum Sdf57ValidationRule implements IValidationRule<ImdgValidationContext<SDf57>> {
|
||||
CompanyDebOrCredPresent() {
|
||||
|
|
@ -64,7 +66,27 @@ public enum Sdf57ValidationRule implements IValidationRule<ImdgValidationContext
|
|||
return empty();
|
||||
}
|
||||
|
||||
}, CurrencyCodeCheck() {
|
||||
},
|
||||
AccountAndCompanyMatch() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<SDf57> context) {
|
||||
Company companyDeb = context.getStoredObject(ValidationStored.Sdf57CompanyDeb);
|
||||
Company companyCred = context.getStoredObject(ValidationStored.Sdf57CompanyCred);
|
||||
Account accountDeb = context.getStoredObject(ValidationStored.Sdf57AccountDeb);
|
||||
Account accountCred = context.getStoredObject(ValidationStored.Sdf57AccountCred);
|
||||
BiFunction<Company, Account, Optional<EnumMessage>> check = (cmp, acc) -> {
|
||||
if (cmp == null || acc == null) return empty();
|
||||
if (!Objects.equals(cmp.getId(), acc.getCompanyId())) {
|
||||
return of(ClearingError.AccountIsNotMatchedWithCompany, acc.getAccount(), cmp.getClearingCode());
|
||||
} else {
|
||||
return empty();
|
||||
}
|
||||
};
|
||||
return check.apply(companyDeb, accountDeb).or(() ->
|
||||
check.apply(companyCred, accountCred));
|
||||
}
|
||||
},
|
||||
CurrencyCodeCheck() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<SDf57> context) {
|
||||
SDf57 sdf57 = context.getValidatedObject();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue