SDF57 processing

This commit is contained in:
ialbert 2023-05-24 16:54:13 +03:00
parent 3619329137
commit 0bb9990a6e

View file

@ -30,6 +30,7 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
@ -103,16 +104,22 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
log.error("error while validating sdf57.id={} - {}", sdf57.getId(), messageResolver.resolve(error.get()));
continue;
}
BiFunction<Company, Account, Optional<Statement>> createStatementIfNeeded = (company, account) -> {
if (company == null || account == null) {
return Optional.empty();
}
Statement statement = create(sdf57, company, account);
statementImdg.insert(statement);
return Optional.of(statement);
};
//create by companyDeb
Company companyDeb = validator.getStored(ValidationStored.Sdf57CompanyDeb);
Account accountDeb = validator.getStored(ValidationStored.Sdf57AccountDeb);
Statement statementDeb = create(sdf57, companyDeb, accountDeb);
statementImdg.insert(statementDeb);
Optional<Statement> statementDeb = createStatementIfNeeded.apply(companyDeb, accountDeb);
//create by companyCred
Company companyCred = validator.getStored(ValidationStored.Sdf57CompanyCred);
Account accountCred = validator.getStored(ValidationStored.Sdf57AccountCred);
Statement statementCred = create(sdf57, companyCred, accountCred);
statementImdg.insert(statementCred);
Optional<Statement> statementCred = createStatementIfNeeded.apply(companyCred, accountCred);
Consumer<StmtCmpAcc> createRegistryIfNeeded = stmtCmpAcc -> {
Statement stmt = stmtCmpAcc.statement();
@ -135,8 +142,8 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
statementImdg.update(stmt);
}
};
createRegistryIfNeeded.accept(new StmtCmpAcc(statementDeb, companyDeb, accountDeb));
createRegistryIfNeeded.accept(new StmtCmpAcc(statementCred, companyCred, accountCred));
statementDeb.ifPresent(stmt -> createRegistryIfNeeded.accept(new StmtCmpAcc(stmt, companyDeb, accountDeb)));
statementCred.ifPresent(stmt -> createRegistryIfNeeded.accept(new StmtCmpAcc(stmt, companyCred, accountCred)));
}
return result;
}
@ -195,7 +202,7 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
// rgstrPredicate = pb.and(rgstrPredicate, pb.equals("contract", s.getContract()));
// }
// return Optional.ofNullable(registryImdg.getSingleObjectByPredicate(rgstrPredicate));
return null;
return Optional.empty();
}
DateTimeFormatter payDateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");