This commit is contained in:
akulikov 2023-05-30 13:34:46 +03:00
parent 23efed8caa
commit c505292247
3 changed files with 317 additions and 244 deletions

View file

@ -60,39 +60,59 @@ public abstract class ExecutedDealReportBuilderCommon<T> extends CSVReportBuilde
lines = new ArrayList<>(executionFonds.size()); lines = new ArrayList<>(executionFonds.size());
for (ExecutionFond executionFond : executionFonds) { for (ExecutionFond executionFond : executionFonds) {
Company company = companyImdg.getSingleObjectByID(executionFond.getCompanyId()); try {
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue; Company company = companyImdg.getSingleObjectByID(executionFond.getCompanyId());
STrades sTrade = sTradesImdg.getSingleObjectByFieldValues( if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;
Map.of(
"tradeNum", executionFond.getExchangeExecutionId(),
"operation", executionFond.getSide()
)
);
String id = String.valueOf(executionFond.getId()); STrades sTrade = null;
String securityId = String.valueOf(executionFond.getSecurityId()); if (executionFond.getSide() != null && executionFond.getExchangeExecutionId() != null) {
String tradeNo = String.valueOf(executionFond.getExchangeExecutionId()); sTrade = sTradesImdg.getSingleObjectByFieldValues(
String tradeDate = dateFormatter.format(executionFond.getTradingDate()); Map.of(
String tradeTime = dateFormatter.format(LocalDate.ofInstant(executionFond.getCreated(), ZoneId.systemDefault())); "tradeNum", executionFond.getExchangeExecutionId(),
String settleDate = dateFormatter.format(executionFond.getSettlementDate()); "operation", executionFond.getSide()
String settleCode = sTrade != null ? sTrade.getSettleCode() : ""; )
String quantity = String.valueOf(executionFond.getQuantity()); );
String value = String.valueOf(executionFond.getSettlementAmount()); }
String price = String.valueOf(executionFond.getSettlementAmount().divide(executionFond.getQuantity(), RoundingMode.HALF_UP));
int valueIdx = 0; String id = String.valueOf(executionFond.getId());
String[] line = new String[getHeaders().length]; String securityId = String.valueOf(executionFond.getSecurityId());
line[valueIdx++] = id; String tradeNo = String.valueOf(executionFond.getExchangeExecutionId());
line[valueIdx++] = securityId; String tradeDate = "";
line[valueIdx++] = tradeNo; String tradeTime = "";
line[valueIdx++] = tradeDate; String settleDate = "";
line[valueIdx++] = tradeTime; if (executionFond.getTradingDate() != null) {
line[valueIdx++] = settleDate; tradeDate = dateFormatter.format(executionFond.getTradingDate());
line[valueIdx++] = settleCode; }
line[valueIdx++] = price; if (executionFond.getCreated() != null) {
line[valueIdx++] = quantity; tradeTime = dateFormatter.format(LocalDate.ofInstant(executionFond.getCreated(), ZoneId.systemDefault()));
line[valueIdx++] = value; }
lines.add(line); if (executionFond.getSettlementDate() != null) {
settleDate = dateFormatter.format(executionFond.getSettlementDate());
}
String settleCode = sTrade != null ? sTrade.getSettleCode() : "";
String quantity = String.valueOf(executionFond.getQuantity());
String value = String.valueOf(executionFond.getSettlementAmount());
String price = "";
if (executionFond.getSettlementAmount() != null && executionFond.getQuantity() != null) {
price = String.valueOf(executionFond.getSettlementAmount().divide(executionFond.getQuantity(), RoundingMode.HALF_UP));
}
int valueIdx = 0;
String[] line = new String[getHeaders().length];
line[valueIdx++] = id;
line[valueIdx++] = securityId;
line[valueIdx++] = tradeNo;
line[valueIdx++] = tradeDate;
line[valueIdx++] = tradeTime;
line[valueIdx++] = settleDate;
line[valueIdx++] = settleCode;
line[valueIdx++] = price;
line[valueIdx++] = quantity;
line[valueIdx++] = value;
lines.add(line);
} catch (Throwable e) {
log.error("Can't create report row for execution_fond (id = %d), skipped".formatted(executionFond.getId()), e);
}
} }
} }

View file

@ -89,177 +89,207 @@ public abstract class LiabilitiesClaimsReportBuilder<P> extends CSVReportBuilder
lines = new ArrayList<>(executions.size()); lines = new ArrayList<>(executions.size());
for (ExecutionCommon execution : executions) { for (ExecutionCommon execution : executions) {
Company company = companyImdg.getSingleObjectByID(execution.getCompanyId()); try {
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue; Company company = companyImdg.getSingleObjectByID(execution.getCompanyId());
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;
if (execution.getSessionId() == null) { if (execution.getSessionId() == null) {
log.warn("On Execution[{}] sessionId was null. Skip in report.", execution.getId()); log.warn("On Execution[{}] sessionId was null. Skip in report.", execution.getId());
continue; continue;
}
Registry registry = registryImdg.getSingleObjectByFieldValues(Map.of("companyId", execution.getCompanyId()));
Collection<Registry> registriesForSessionId = registryImdg.getCollectionObjectsByFieldValues(
Map.of("sessionId", execution.getSessionId())
);
Listing listing = listingImdg.getSingleObjectByFieldValues(Map.of("securityId", execution.getSecurityId()));
FixedIncomeSecurity fixedIncomeSecurity = fixedIncomeSecurityImdg.getSingleObjectByFieldValues(
Map.of("securityId", execution.getSecurityId())
);
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryImdg.getSingleObjectByID(
execution.getTradingClearingRegistryId()
);
if (registry == null) {
log.warn("registry not found for companyId={}", execution.getCompanyId());
}
String id = String.valueOf(execution.getId());
String docDate = dateFormatter.format(nowDate);
String docTime = timeFormatter.format(nowTime);
String docName = "Отчет об обязательствах/требованиях Участника клиринга";
String docType = "KS_FIRMID_LIABILITIES";
String firmId = String.valueOf(execution.getCompanyId());
String firName = company.getFullName();
String sessionId = String.valueOf(execution.getSessionId());
String clearingDate = dateFormatter.format(execution.getClearingDate());
String clearingTime = dateFormatter.format(execution.getClearingDate());
String trdAccId = registry == null? null : registry.getTradingClearingRegistry();
String account = String.valueOf(tradingClearingRegistry.getMoneyAccountId());
String depoAccount = String.valueOf(tradingClearingRegistry.getDepoAccountId());
String currency = execution.getSettlementCurrency();
String trId = String.valueOf(execution.getExchangeExecutionId());
String securityId = String.valueOf(execution.getSecurityId());
String trBuySell = "";
if (Side.BUY.equalsByKey(execution.getSide()))
trBuySell = "B";
else if (Side.SELL.equalsByKey(execution.getSide()))
trBuySell = "S";
String trDate = dateFormatter.format(execution.getTradingDate());
String trExecDate = "";
String execStatus = "";
String repaymDate = "";
String trPrice = "";
String nominal = "";
String trQuantity = "";
String trValue = "";
String trAccruedInt = "";
String accruedInt = "";
String cashLiability = "";
String depoLiability = "";
if (execution instanceof ExecutionDeposit executionDeposit) {
trExecDate = dateFormatter.format(executionDeposit.getSecondLegSettlementDate());
if (Market.mkrs.equalsByKey(execution.getMarket())) {
String coverageStatus = executionDeposit.getCoverageStatus();
if (Allowed.ALLOWED.equalsByKey(coverageStatus)) execStatus = "Y";
else if (Allowed.DENIED.equalsByKey(coverageStatus)) execStatus = "N";
else execStatus = "W";
repaymDate = dateFormatter.format(executionDeposit.getSecondLegSettlementDate());
trPrice = String.valueOf(executionDeposit.getPrice());
trValue = String.valueOf(executionDeposit.getFirstLegAmount());
cashLiability = String.valueOf(executionDeposit.getFirstLegAmount());
} }
} else if (execution instanceof ExecutionFond executionFond) { Registry registry = null;
trExecDate = dateFormatter.format(executionFond.getSettlementDate()); if (execution.getCompanyId() != null) {
if (Market.fond.equalsByKey(execution.getMarket())) { registry = registryImdg.getSingleObjectByFieldValues(Map.of("companyId", execution.getCompanyId()));
trPrice = String.valueOf( }
executionFond.getSettlementAmount().divide(executionFond.getQuantity(), RoundingMode.HALF_UP) Collection<Registry> registriesForSessionId = null;
if (execution.getSessionId() != null) {
registriesForSessionId = registryImdg.getCollectionObjectsByFieldValues(
Map.of("sessionId", execution.getSessionId())
); );
trQuantity = String.valueOf(executionFond.getQuantity()); }
nominal = String.valueOf(fixedIncomeSecurity.getNominalValue()); Listing listing = null;
trValue = String.valueOf(executionFond.getSettlementAmount()); FixedIncomeSecurity fixedIncomeSecurity = null;
trAccruedInt = String.valueOf(fixedIncomeSecurity.getCoupon()); if (execution.getSecurityId() != null) {
accruedInt = String.valueOf( listing = listingImdg.getSingleObjectByFieldValues(Map.of("securityId", execution.getSecurityId()));
fixedIncomeSecurity.getCoupon().divide(executionFond.getQuantity(), RoundingMode.HALF_UP) fixedIncomeSecurity = fixedIncomeSecurityImdg.getSingleObjectByFieldValues(
Map.of("securityId", execution.getSecurityId())
); );
cashLiability = String.valueOf(executionFond.getSettlementAmount());
depoLiability = String.valueOf(executionFond.getQuantity());
} }
} TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryImdg.getSingleObjectByID(
execution.getTradingClearingRegistryId()
);
String lotValue = String.valueOf(listing.getLotSize()); if (registry == null) {
String trLot = String.valueOf(execution.getLots()); log.warn("registry not found for companyId={}", execution.getCompanyId());
String trClrComm = ""; }
String trExhComm = "";
Registry tm_tRegistry = null; String id = String.valueOf(execution.getId());
Registry om_tRegistry = null; String docDate = dateFormatter.format(nowDate);
Registry ts_tRegistry = null; String docTime = timeFormatter.format(nowTime);
Registry os_tRegistry = null; String docName = "Отчет об обязательствах/требованиях Участника клиринга";
for (Registry currRegistry : registriesForSessionId) { String docType = "KS_FIRMID_LIABILITIES";
String registryCode = currRegistry.getRegistryCode(); String firmId = String.valueOf(execution.getCompanyId());
if (registryCode.endsWith("T")) { String firName = company.getFullName();
if (registryCode.startsWith("TM")) { String sessionId = String.valueOf(execution.getSessionId());
if (tm_tRegistry != null && tm_tRegistry.getUpdated().isAfter(currRegistry.getUpdated())) continue; String clearingDate = dateFormatter.format(execution.getClearingDate());
tm_tRegistry = currRegistry; String clearingTime = dateFormatter.format(execution.getClearingDate());
String trdAccId = registry == null ? null : registry.getTradingClearingRegistry();
String account = String.valueOf(tradingClearingRegistry.getMoneyAccountId());
String depoAccount = String.valueOf(tradingClearingRegistry.getDepoAccountId());
String currency = execution.getSettlementCurrency();
String trId = String.valueOf(execution.getExchangeExecutionId());
String securityId = String.valueOf(execution.getSecurityId());
String trBuySell = "";
if (Side.BUY.equalsByKey(execution.getSide()))
trBuySell = "B";
else if (Side.SELL.equalsByKey(execution.getSide()))
trBuySell = "S";
String trDate = dateFormatter.format(execution.getTradingDate());
String trExecDate = "";
String execStatus = "";
String repaymDate = "";
String trPrice = "";
String nominal = "";
String trQuantity = "";
String trValue = "";
String trAccruedInt = "";
String accruedInt = "";
String cashLiability = "";
String depoLiability = "";
if (execution instanceof ExecutionDeposit executionDeposit) {
trExecDate = dateFormatter.format(executionDeposit.getSecondLegSettlementDate());
if (Market.mkrs.equalsByKey(execution.getMarket())) {
String coverageStatus = executionDeposit.getCoverageStatus();
if (Allowed.ALLOWED.equalsByKey(coverageStatus)) execStatus = "Y";
else if (Allowed.DENIED.equalsByKey(coverageStatus)) execStatus = "N";
else execStatus = "W";
repaymDate = dateFormatter.format(executionDeposit.getSecondLegSettlementDate());
trPrice = String.valueOf(executionDeposit.getPrice());
trValue = String.valueOf(executionDeposit.getFirstLegAmount());
cashLiability = String.valueOf(executionDeposit.getFirstLegAmount());
} }
if (registryCode.startsWith("OM")) { } else if (execution instanceof ExecutionFond executionFond) {
if (om_tRegistry != null && om_tRegistry.getUpdated().isAfter(currRegistry.getUpdated())) continue; trExecDate = dateFormatter.format(executionFond.getSettlementDate());
om_tRegistry = currRegistry; if (Market.fond.equalsByKey(execution.getMarket())) {
} if (executionFond.getSettlementAmount() != null && executionFond.getQuantity() != null) {
if (registryCode.startsWith("TS")) { trPrice = String.valueOf(
if (ts_tRegistry != null && ts_tRegistry.getUpdated().isAfter(currRegistry.getUpdated())) continue; executionFond.getSettlementAmount().divide(executionFond.getQuantity(), RoundingMode.HALF_UP)
ts_tRegistry = currRegistry; );
} }
if (registryCode.startsWith("OS")) { trQuantity = String.valueOf(executionFond.getQuantity());
if (os_tRegistry != null && os_tRegistry.getUpdated().isAfter(currRegistry.getUpdated())) continue; if (fixedIncomeSecurity != null) {
os_tRegistry = currRegistry; nominal = String.valueOf(fixedIncomeSecurity.getNominalValue());
if (executionFond.getQuantity() != null) {
accruedInt = String.valueOf(
fixedIncomeSecurity.getCoupon().divide(executionFond.getQuantity(), RoundingMode.HALF_UP)
);
}
trAccruedInt = String.valueOf(fixedIncomeSecurity.getCoupon());
}
trValue = String.valueOf(executionFond.getSettlementAmount());
cashLiability = String.valueOf(executionFond.getSettlementAmount());
depoLiability = String.valueOf(executionFond.getQuantity());
} }
} }
}
String cashNetto = "";
if (tm_tRegistry != null && om_tRegistry != null) {
cashNetto = String.valueOf(tm_tRegistry.getBalance().subtract(om_tRegistry.getBalance()));
}
String depoNetto = ""; String lotValue = "";
if (ts_tRegistry != null && os_tRegistry != null) { if (listing != null) {
depoNetto = String.valueOf(ts_tRegistry.getBalance().subtract(os_tRegistry.getBalance())); lotValue = String.valueOf(listing.getLotSize());
} }
String trLot = String.valueOf(execution.getLots());
String trClrComm = "";
String trExhComm = "";
Registry tm_tRegistry = null;
Registry om_tRegistry = null;
Registry ts_tRegistry = null;
Registry os_tRegistry = null;
if (registriesForSessionId != null) {
for (Registry currRegistry : registriesForSessionId) {
String registryCode = currRegistry.getRegistryCode();
if (registryCode.endsWith("T")) {
if (registryCode.startsWith("TM")) {
if (tm_tRegistry != null && tm_tRegistry.getUpdated().isAfter(currRegistry.getUpdated()))
continue;
tm_tRegistry = currRegistry;
}
if (registryCode.startsWith("OM")) {
if (om_tRegistry != null && om_tRegistry.getUpdated().isAfter(currRegistry.getUpdated()))
continue;
om_tRegistry = currRegistry;
}
if (registryCode.startsWith("TS")) {
if (ts_tRegistry != null && ts_tRegistry.getUpdated().isAfter(currRegistry.getUpdated()))
continue;
ts_tRegistry = currRegistry;
}
if (registryCode.startsWith("OS")) {
if (os_tRegistry != null && os_tRegistry.getUpdated().isAfter(currRegistry.getUpdated()))
continue;
os_tRegistry = currRegistry;
}
}
}
}
String cashNetto = "";
if (tm_tRegistry != null && om_tRegistry != null) {
cashNetto = String.valueOf(tm_tRegistry.getBalance().subtract(om_tRegistry.getBalance()));
}
String depoNetto = "";
if (ts_tRegistry != null && os_tRegistry != null) {
depoNetto = String.valueOf(ts_tRegistry.getBalance().subtract(os_tRegistry.getBalance()));
}
int valueIdx = 0; int valueIdx = 0;
String[] line = new String[getHeaders().length]; String[] line = new String[getHeaders().length];
line[valueIdx++] = id; line[valueIdx++] = id;
line[valueIdx++] = docDate; line[valueIdx++] = docDate;
line[valueIdx++] = docTime; line[valueIdx++] = docTime;
line[valueIdx++] = docName; line[valueIdx++] = docName;
line[valueIdx++] = docType; line[valueIdx++] = docType;
line[valueIdx++] = clearingHouse; line[valueIdx++] = clearingHouse;
line[valueIdx++] = firmId; line[valueIdx++] = firmId;
line[valueIdx++] = firName; line[valueIdx++] = firName;
line[valueIdx++] = sessionId; line[valueIdx++] = sessionId;
line[valueIdx++] = clearingDate; line[valueIdx++] = clearingDate;
line[valueIdx++] = clearingTime; line[valueIdx++] = clearingTime;
line[valueIdx++] = trdAccId; line[valueIdx++] = trdAccId;
line[valueIdx++] = account; line[valueIdx++] = account;
line[valueIdx++] = depoAccount; line[valueIdx++] = depoAccount;
line[valueIdx++] = currency; line[valueIdx++] = currency;
line[valueIdx++] = trId; line[valueIdx++] = trId;
line[valueIdx++] = securityId; line[valueIdx++] = securityId;
line[valueIdx++] = trBuySell; line[valueIdx++] = trBuySell;
line[valueIdx++] = trDate; line[valueIdx++] = trDate;
line[valueIdx++] = trExecDate; line[valueIdx++] = trExecDate;
line[valueIdx++] = execStatus; line[valueIdx++] = execStatus;
line[valueIdx++] = repaymDate; line[valueIdx++] = repaymDate;
line[valueIdx++] = trPrice; line[valueIdx++] = trPrice;
line[valueIdx++] = nominal; line[valueIdx++] = nominal;
line[valueIdx++] = lotValue; line[valueIdx++] = lotValue;
line[valueIdx++] = trLot; line[valueIdx++] = trLot;
line[valueIdx++] = trQuantity; line[valueIdx++] = trQuantity;
line[valueIdx++] = trValue; line[valueIdx++] = trValue;
line[valueIdx++] = trAccruedInt; line[valueIdx++] = trAccruedInt;
line[valueIdx++] = accruedInt; line[valueIdx++] = accruedInt;
line[valueIdx++] = trClrComm; line[valueIdx++] = trClrComm;
line[valueIdx++] = trExhComm; line[valueIdx++] = trExhComm;
line[valueIdx++] = cashLiability; line[valueIdx++] = cashLiability;
line[valueIdx++] = depoLiability; line[valueIdx++] = depoLiability;
line[valueIdx++] = cashNetto; line[valueIdx++] = cashNetto;
line[valueIdx] = depoNetto; line[valueIdx] = depoNetto;
lines.add(line); lines.add(line);
} catch (Throwable e) {
log.error("Can't create report row for execution (id = %d), skipped".formatted(execution.getId()), e);
}
} }
} }
} }

View file

@ -66,65 +66,88 @@ public abstract class MoneyChangeReportBuilder<P> extends CSVReportBuilder<P> {
LocalTime nowTime = LocalTime.now(); LocalTime nowTime = LocalTime.now();
lines = new ArrayList<>(registries.size()); lines = new ArrayList<>(registries.size());
for (Registry registry : registries) { for (Registry registry : registries) {
Company company = companyImdg.getSingleObjectByID(registry.getCompanyId()); try {
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue; Company company = companyImdg.getSingleObjectByID(registry.getCompanyId());
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;
Listing listing = listingImdg.getSingleObjectByFieldValues(Map.of("securityId", registry.getSecurityId())); Listing listing = null;
Statement statement = statementImdg.getSingleObjectByFieldValues(Map.of("addresseeId", registry.getCompanyId())); if (registry.getSecurityId() != null) {
PaymentInstruction paymentInstruction = paymentInstructionImdg.getSingleObjectByFieldValues( listing = listingImdg.getSingleObjectByFieldValues(Map.of("securityId", registry.getSecurityId()));
Map.of( }
"id", registry.getPaymentId(),
"creditLeg_direction", InOutDirection.out.getKey()
)
);
String id = String.valueOf(registry.getId()); Statement statement = null;
String docDate = dateFormatter.format(nowDate); if (registry.getCompanyId() != null) {
String docTime = timeFormatter.format(nowTime); statement = statementImdg.getSingleObjectByFieldValues(Map.of("addresseeId", registry.getCompanyId()));
String docName = "Отчет об изменении суммы денежных средств и (или) количества иного имущества Участника клиринга"; }
String docType = "KS_FIRMID_ASSETS";
String firmId = String.valueOf(registry.getCompanyId());
String firName = company.getFullName();
String trdAccId = registry.getTradingClearingRegistry();
String account = String.valueOf(registry.getAccountId());
String currency = listing.getTradingCurrency();
String registryCode = String.valueOf(registry.getId());
String registryName = registry.getRegistryCode();
String openBalance = String.valueOf(registry.getOpenBalance());
String changeBalance = String.valueOf(registry.getCloseBalance().subtract(registry.getOpenBalance()));
String addWithdraw = String.valueOf(registry.getCredit().subtract(registry.getDebit()));
String closeBalance = String.valueOf(registry.getCloseBalance());
String remarks = "";
String addSum = String.valueOf(registry.getCredit());
String addTime = dateTimeFormatter.format(LocalDateTime.ofInstant(statement.getCreated(), ZoneId.systemDefault()));
String withdrawSum = String.valueOf(registry.getDebit());
String withdrawTime = dateTimeFormatter.format(LocalDateTime.ofInstant(paymentInstruction.getPaymentDate(), ZoneId.systemDefault()));
int valueIdx = 0; PaymentInstruction paymentInstruction = null;
String[] line = new String[getHeaders().length]; if (registry.getPaymentId() != null) {
line[valueIdx++] = id; paymentInstruction = paymentInstructionImdg.getSingleObjectByFieldValues(
line[valueIdx++] = docDate; Map.of(
line[valueIdx++] = docTime; "id", registry.getPaymentId(),
line[valueIdx++] = docName; "creditLeg_direction", InOutDirection.out.getKey()
line[valueIdx++] = docType; )
line[valueIdx++] = clearingHouse; );
line[valueIdx++] = firmId; }
line[valueIdx++] = firName;
line[valueIdx++] = trdAccId; String id = String.valueOf(registry.getId());
line[valueIdx++] = account; String docDate = dateFormatter.format(nowDate);
line[valueIdx++] = currency; String docTime = timeFormatter.format(nowTime);
line[valueIdx++] = registryCode; String docName = "Отчет об изменении суммы денежных средств и (или) количества иного имущества Участника клиринга";
line[valueIdx++] = registryName; String docType = "KS_FIRMID_ASSETS";
line[valueIdx++] = openBalance; String firmId = String.valueOf(registry.getCompanyId());
line[valueIdx++] = changeBalance; String firName = company.getFullName();
line[valueIdx++] = addWithdraw; String trdAccId = registry.getTradingClearingRegistry();
line[valueIdx++] = closeBalance; String account = String.valueOf(registry.getAccountId());
line[valueIdx++] = remarks; String currency = listing != null ? listing.getTradingCurrency() : "";
line[valueIdx++] = addSum; String registryCode = String.valueOf(registry.getId());
line[valueIdx++] = addTime; String registryName = registry.getRegistryCode();
line[valueIdx++] = withdrawSum; String openBalance = String.valueOf(registry.getOpenBalance());
line[valueIdx++] = withdrawTime; String changeBalance = String.valueOf(registry.getCloseBalance().subtract(registry.getOpenBalance()));
lines.add(line); String addWithdraw = String.valueOf(registry.getCredit().subtract(registry.getDebit()));
String closeBalance = String.valueOf(registry.getCloseBalance());
String remarks = "";
String addSum = String.valueOf(registry.getCredit());
String addTime = "";
if (statement != null && statement.getCreated() != null) {
addTime = dateTimeFormatter.format(LocalDateTime.ofInstant(statement.getCreated(), ZoneId.systemDefault()));
}
String withdrawSum = String.valueOf(registry.getDebit());
String withdrawTime = "";
if (paymentInstruction != null) {
withdrawTime = dateTimeFormatter.format(LocalDateTime.ofInstant(paymentInstruction.getPaymentDate(), ZoneId.systemDefault()));
} else if (registry.getClearingDate() != null) {
withdrawTime = dateTimeFormatter.format(registry.getClearingDate());
}
int valueIdx = 0;
String[] line = new String[getHeaders().length];
line[valueIdx++] = id;
line[valueIdx++] = docDate;
line[valueIdx++] = docTime;
line[valueIdx++] = docName;
line[valueIdx++] = docType;
line[valueIdx++] = clearingHouse;
line[valueIdx++] = firmId;
line[valueIdx++] = firName;
line[valueIdx++] = trdAccId;
line[valueIdx++] = account;
line[valueIdx++] = currency;
line[valueIdx++] = registryCode;
line[valueIdx++] = registryName;
line[valueIdx++] = openBalance;
line[valueIdx++] = changeBalance;
line[valueIdx++] = addWithdraw;
line[valueIdx++] = closeBalance;
line[valueIdx++] = remarks;
line[valueIdx++] = addSum;
line[valueIdx++] = addTime;
line[valueIdx++] = withdrawSum;
line[valueIdx++] = withdrawTime;
lines.add(line);
} catch (Throwable e) {
log.error("Can't create report row for registry (id = %d), skipped".formatted(registry.getId()), e);
}
} }
} }