From b5de68ae1e6590d2f5c40214ec4b6e93cb58ca48 Mon Sep 17 00:00:00 2001 From: etreschenkov Date: Wed, 24 May 2023 19:25:45 +0300 Subject: [PATCH] SDF57 processing --- .../service/executors/Sdf57Executor.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/executors/Sdf57Executor.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/executors/Sdf57Executor.java index 9881cb698..de6cb2ef5 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/executors/Sdf57Executor.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/executors/Sdf57Executor.java @@ -121,22 +121,23 @@ public class Sdf57Executor extends AbstractExecutor { return Optional.of(statement); }; //create by companyDeb - Company companyDeb = validator.getStored(ValidationStored.Sdf57CompanyDeb); + Company companyDeb = validator.getStored(ValidationStored.Sdf57CompanyDeb); //плательщик Account accountDeb = validator.getStored(ValidationStored.Sdf57AccountDeb); - Company companyCred = validator.getStored(ValidationStored.Sdf57CompanyCred); + Company companyCred = validator.getStored(ValidationStored.Sdf57CompanyCred);//получатель Account accountCred = validator.getStored(ValidationStored.Sdf57AccountCred); //адресат CREDIT / владелец DEBIT - Optional statementDeb = createStatementIfNeeded.apply(companyCred, accountDeb, InOutDirection.out); + Optional statementDeb = createStatementIfNeeded.apply(companyCred, accountCred, InOutDirection.in); //адресат DEBIT / владелец CREDIT - Optional statementCred = createStatementIfNeeded.apply(companyDeb, accountCred, InOutDirection.in); + Optional statementCred = createStatementIfNeeded.apply(companyDeb, accountDeb, InOutDirection.out); Consumer createRegistryIfNeeded = stmtCmpAcc -> { Statement stmt = stmtCmpAcc.statement(); - Statement counterStmt = stmtCmpAcc.counterStatement(); Company company = stmtCmpAcc.company(); Account account = stmtCmpAcc.account(); - Optional err = validateActiveness(company, account, stmt); + if (account == null) + return; + Optional err = validateActiveness(company, account); if (err.isEmpty()) { Consumer update = rgs -> { updateReg(stmt, rgs); @@ -157,17 +158,16 @@ public class Sdf57Executor extends AbstractExecutor { statementImdg.update(stmt); } }; - statementDeb.ifPresent(stmt -> createRegistryIfNeeded.accept(new StmtCmpAcc(stmt, statementCred.orElse(null), companyDeb, accountDeb))); - statementCred.ifPresent(stmt -> createRegistryIfNeeded.accept(new StmtCmpAcc(stmt, statementDeb.orElse(null), companyCred, accountCred))); + statementDeb.ifPresent(stmt -> createRegistryIfNeeded.accept(new StmtCmpAcc(stmt, companyDeb, accountDeb))); + statementCred.ifPresent(stmt -> createRegistryIfNeeded.accept(new StmtCmpAcc(stmt, companyCred, accountCred))); } return result; } - private static record StmtCmpAcc(Statement statement, Statement counterStatement, Company company, - Account account) { + private record StmtCmpAcc(Statement statement, Company company, Account account) { } - private Optional validateActiveness(Company company, Account account, Statement statement) { + private Optional validateActiveness(Company company, Account account) { if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) { return Optional.of(new EnumMessage(ClearingError.CompanyNotActive, company.getId())); }