report-service fixes

This commit is contained in:
akulikov 2024-06-21 18:47:39 +03:00
parent 41cf940f42
commit 1d0f669c41

View file

@ -127,8 +127,6 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
} }
boolean invalid = false; boolean invalid = false;
BigDecimal currencyNettoCmt = BigDecimal.ZERO;
BigDecimal currencyNettoLmt = BigDecimal.ZERO;
if (!cmtRegistries.isEmpty() || !lmtRegistries.isEmpty()) { if (!cmtRegistries.isEmpty() || !lmtRegistries.isEmpty()) {
String sourceTradingCode = null; String sourceTradingCode = null;
String sourceTkr = null; String sourceTkr = null;
@ -153,9 +151,6 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
log.warn("Invalid CM_T registries set, tradingClearingRegistry not equals. Registries was skipped"); log.warn("Invalid CM_T registries set, tradingClearingRegistry not equals. Registries was skipped");
break; break;
} }
if (currRegistry.getBalance().compareTo(ReportConst.DB_ZERO) != 0) {
currencyNettoCmt = currencyNettoCmt.add(currRegistry.getBalance());
}
} }
for (Registry currRegistry : lmtRegistries) { for (Registry currRegistry : lmtRegistries) {
if (!Objects.equals(sourceTradingCode, currRegistry.getTradingCode())) { if (!Objects.equals(sourceTradingCode, currRegistry.getTradingCode())) {
@ -168,9 +163,6 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
log.warn("Invalid CM_T registries set, tradingClearingRegistry not equals. Registries was skipped"); log.warn("Invalid CM_T registries set, tradingClearingRegistry not equals. Registries was skipped");
break; break;
} }
if (currRegistry.getBalance().compareTo(ReportConst.DB_ZERO) != 0) {
currencyNettoLmt = currencyNettoLmt.add(currRegistry.getBalance());
}
} }
if (invalid) continue; if (invalid) continue;
} }
@ -204,37 +196,45 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
BigDecimal lmtBalance = BigDecimal.ZERO; BigDecimal lmtBalance = BigDecimal.ZERO;
BigDecimal oblValue = BigDecimal.ZERO; BigDecimal oblValue = BigDecimal.ZERO;
BigDecimal reqValue = BigDecimal.ZERO; BigDecimal reqValue = BigDecimal.ZERO;
BigDecimal cmtCurrencyNetto = BigDecimal.ZERO;
BigDecimal lmtCurrencyNetto = BigDecimal.ZERO;
boolean withValue = false; boolean withValue = false;
boolean withOblReqValue = false; boolean withOblReqValue = false;
boolean forUnitSession = false; boolean withCurrencyNettoValue = false;
Set<SessionType> sessionTypeForValue = Set.of( Set<SessionType> sessionTypeForValue = Set.of(
SessionType.IPOT, SessionType.IPOT,
SessionType.TRDT, SessionType.TRDT,
SessionType.LIQU, SessionType.LIQU,
SessionType.IPOB, SessionType.IPOB,
SessionType.IPO0, SessionType.IPO0
SessionType.UNIT
); );
Set<SessionType> sessionTypeForOblReqValue = Set.of( Set<SessionType> sessionTypeForOblReqValue = Set.of(
SessionType.FINL, SessionType.FINL,
SessionType.MEDM, SessionType.MEDM,
SessionType.XDEP, SessionType.XDEP
SessionType.UNIT
); );
for (Registry cmtRegistry : cmtRegistries) { for (Registry cmtRegistry : cmtRegistries) {
if (cmtRegistry.getBalance() != null) { if (cmtRegistry.getBalance() != null) {
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, cmtRegistry.getSessionType()); SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, cmtRegistry.getSessionType());
Section section = IEnumKey.getEnumByKey(Section.class, cmtRegistry.getSection()); Section section = IEnumKey.getEnumByKey(Section.class, cmtRegistry.getSection());
if (sessionType == null || section == null) continue; if (sessionType == null || section == null) continue;
if (sessionTypeForValue.contains(sessionType)) { if (section == Section.FOND || sessionTypeForValue.contains(sessionType)) {
cmtBalance = cmtBalance.add(cmtRegistry.getBalance()); if (ReportConst.DB_ZERO.compareTo(cmtRegistry.getBalance()) != 0) {
if (sessionType == SessionType.UNIT && section == Section.CURR) forUnitSession = true; cmtBalance = cmtBalance.add(cmtRegistry.getBalance());
else withValue = true; withValue = true;
}
} }
if (sessionTypeForOblReqValue.contains(sessionType)) { if (section == Section.MKR || sessionTypeForOblReqValue.contains(sessionType)) {
reqValue = reqValue.add(cmtRegistry.getBalance()); if (ReportConst.DB_ZERO.compareTo(cmtRegistry.getBalance()) != 0) {
if (sessionType == SessionType.UNIT && section == Section.CURR) forUnitSession = true; reqValue = reqValue.add(cmtRegistry.getBalance());
else withOblReqValue = true; withOblReqValue = true;
}
}
if (section == Section.CURR || sessionType == SessionType.CURR) {
if (ReportConst.DB_ZERO.compareTo(cmtRegistry.getBalance()) != 0) {
cmtCurrencyNetto = cmtCurrencyNetto.add(cmtBalance);
withCurrencyNettoValue = true;
}
} }
} }
} }
@ -243,23 +243,22 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, lmtRegistry.getSessionType()); SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, lmtRegistry.getSessionType());
Section section = IEnumKey.getEnumByKey(Section.class, lmtRegistry.getSection()); Section section = IEnumKey.getEnumByKey(Section.class, lmtRegistry.getSection());
if (sessionType == null) continue; if (sessionType == null) continue;
if (sessionTypeForValue.contains(sessionType)) { if (section == Section.FOND || sessionTypeForValue.contains(sessionType)) {
lmtBalance = lmtBalance.add(lmtRegistry.getBalance()); lmtBalance = lmtBalance.add(lmtRegistry.getBalance());
if (section == Section.CURR) forUnitSession = true; withValue = true;
else withValue = true;
} }
if (sessionTypeForOblReqValue.contains(sessionType)) { if (section == Section.MKR || sessionTypeForOblReqValue.contains(sessionType)) {
oblValue = oblValue.add(lmtRegistry.getBalance()); oblValue = oblValue.add(lmtRegistry.getBalance());
if (section == Section.CURR) forUnitSession = true; withOblReqValue = true;
else withOblReqValue = true; }
if (section == Section.CURR && sessionType == SessionType.UNIT) {
lmtCurrencyNetto = lmtCurrencyNetto.add(lmtCurrencyNetto);
withCurrencyNettoValue = true;
} }
} }
} }
BigDecimal value; BigDecimal value = cmtBalance.subtract(lmtBalance);
value = cmtBalance.subtract(lmtBalance); BigDecimal currencyNetto = cmtCurrencyNetto.subtract(lmtCurrencyNetto);
ksRepCashNettoReport.setValue(withValue ? value : null);
ksRepCashNettoReport.setOblValue(withOblReqValue ? oblValue : null);
ksRepCashNettoReport.setReqValue(withOblReqValue ? reqValue : null);
ksRepCashNettoReport.setLotCurrency(registry.getSecuritySymbol()); ksRepCashNettoReport.setLotCurrency(registry.getSecuritySymbol());
if (withValue) { if (withValue) {
KSRepCashNettoReport withoutValueClone = ksRepCashNettoReport.cloneWithoutValues(); KSRepCashNettoReport withoutValueClone = ksRepCashNettoReport.cloneWithoutValues();
@ -272,9 +271,9 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
withoutValueClone.setReqValue(reqValue); withoutValueClone.setReqValue(reqValue);
rows.add(withoutValueClone); rows.add(withoutValueClone);
} }
if (forUnitSession) { if (withCurrencyNettoValue) {
KSRepCashNettoReport withoutValueClone = ksRepCashNettoReport.cloneWithoutValues(); KSRepCashNettoReport withoutValueClone = ksRepCashNettoReport.cloneWithoutValues();
withoutValueClone.setCurrencyNetto(currencyNettoCmt.subtract(currencyNettoLmt)); withoutValueClone.setCurrencyNetto(currencyNetto);
withoutValueClone.setTrExecDate(LocalDate.now()); withoutValueClone.setTrExecDate(LocalDate.now());
rows.add(withoutValueClone); rows.add(withoutValueClone);
} }