http://jira.mfd.msk:8088/browse/CLS-497 KSRepCashNettoReport
This commit is contained in:
parent
4e431ee798
commit
4581592380
6 changed files with 80 additions and 13 deletions
|
|
@ -41,6 +41,16 @@ public class KSRepCashNettoReport {
|
||||||
@CsvDate(value = "dd.MM.yyyy")
|
@CsvDate(value = "dd.MM.yyyy")
|
||||||
private LocalDate date;
|
private LocalDate date;
|
||||||
|
|
||||||
|
@CsvBindByName(column = "OBL_VALUE")
|
||||||
|
@CsvBindByPosition(position = 7)
|
||||||
|
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||||
|
private BigDecimal oblValue;
|
||||||
|
|
||||||
|
@CsvBindByName(column = "REQ_VALUE")
|
||||||
|
@CsvBindByPosition(position = 8)
|
||||||
|
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||||
|
private BigDecimal reqValue;
|
||||||
|
|
||||||
|
|
||||||
public String getFirmId() {
|
public String getFirmId() {
|
||||||
return firmId;
|
return firmId;
|
||||||
|
|
@ -98,4 +108,19 @@ public class KSRepCashNettoReport {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getOblValue() {
|
||||||
|
return oblValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOblValue(BigDecimal oblValue) {
|
||||||
|
this.oblValue = oblValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getReqValue() {
|
||||||
|
return reqValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReqValue(BigDecimal reqValue) {
|
||||||
|
this.reqValue = reqValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,7 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
|
@ -180,13 +177,39 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
||||||
|
|
||||||
BigDecimal cmtBalance = BigDecimal.ZERO;
|
BigDecimal cmtBalance = BigDecimal.ZERO;
|
||||||
BigDecimal lmtBalance = BigDecimal.ZERO;
|
BigDecimal lmtBalance = BigDecimal.ZERO;
|
||||||
|
BigDecimal oblValue = BigDecimal.ZERO;
|
||||||
|
BigDecimal reqValue = BigDecimal.ZERO;
|
||||||
|
Set<SessionType> sessionTypeForValue = Set.of(
|
||||||
|
SessionType.IPOT,
|
||||||
|
SessionType.TRDT,
|
||||||
|
SessionType.LIQU,
|
||||||
|
SessionType.IPOB,
|
||||||
|
SessionType.IPO0
|
||||||
|
);
|
||||||
|
Set<SessionType> sessionTypeForOblReqValue = Set.of(
|
||||||
|
SessionType.FINL,
|
||||||
|
SessionType.MEDM,
|
||||||
|
SessionType.XDEP
|
||||||
|
);
|
||||||
for (Registry cmtRegistry : cmtRegistries) {
|
for (Registry cmtRegistry : cmtRegistries) {
|
||||||
if (cmtRegistry.getBalance() != null) cmtBalance = cmtBalance.add(cmtRegistry.getBalance());
|
if (cmtRegistry.getBalance() != null) {
|
||||||
|
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, cmtRegistry.getSessionType());
|
||||||
|
if (sessionType == null) continue;
|
||||||
|
if (sessionTypeForValue.contains(sessionType)) cmtBalance = cmtBalance.add(cmtRegistry.getBalance());
|
||||||
|
if (sessionTypeForOblReqValue.contains(sessionType)) reqValue = reqValue.add(cmtRegistry.getBalance());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (Registry lmtRegistry : lmtRegistries) {
|
for (Registry lmtRegistry : lmtRegistries) {
|
||||||
if (lmtRegistry.getBalance() != null) lmtBalance = lmtBalance.add(lmtRegistry.getBalance());
|
if (lmtRegistry.getBalance() != null) {
|
||||||
|
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, lmtRegistry.getSessionType());
|
||||||
|
if (sessionType == null) continue;
|
||||||
|
if (sessionTypeForValue.contains(sessionType)) lmtBalance = lmtBalance.add(lmtRegistry.getBalance());
|
||||||
|
if (sessionTypeForOblReqValue.contains(sessionType)) oblValue = oblValue.add(lmtRegistry.getBalance());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ksRepCashNettoReport.setValue(cmtBalance.subtract(lmtBalance));
|
ksRepCashNettoReport.setValue(cmtBalance.subtract(lmtBalance));
|
||||||
|
ksRepCashNettoReport.setOblValue(oblValue);
|
||||||
|
ksRepCashNettoReport.setReqValue(reqValue);
|
||||||
|
|
||||||
rows.add(ksRepCashNettoReport);
|
rows.add(ksRepCashNettoReport);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
|
||||||
|
|
@ -729,6 +729,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_1.setClearingDate(LocalDate.now());
|
registry_1.setClearingDate(LocalDate.now());
|
||||||
registry_1.setRegistryCode("LM_T");
|
registry_1.setRegistryCode("LM_T");
|
||||||
registry_1.setTradingClearingRegistry("TKR");
|
registry_1.setTradingClearingRegistry("TKR");
|
||||||
|
registry_1.setSessionType(SessionType.IPO0.getKey());
|
||||||
registry_1.setRegistryStatus(RegistryStatus.PROC.getKey());
|
registry_1.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||||
registry_1.setRegistryDesignation(RegistryDesignation.L.getKey());
|
registry_1.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||||
registry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
registry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||||
|
|
@ -744,6 +745,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_2.setSettlementDate(LocalDate.now());
|
registry_2.setSettlementDate(LocalDate.now());
|
||||||
registry_2.setGroupId(Long.MAX_VALUE);
|
registry_2.setGroupId(Long.MAX_VALUE);
|
||||||
registry_2.setClearingDate(LocalDate.now());
|
registry_2.setClearingDate(LocalDate.now());
|
||||||
|
registry_2.setSessionType(SessionType.IPO0.getKey());
|
||||||
registry_2.setRegistryCode("CM_T");
|
registry_2.setRegistryCode("CM_T");
|
||||||
registry_2.setTradingClearingRegistry("TKR");
|
registry_2.setTradingClearingRegistry("TKR");
|
||||||
registry_2.setRegistryStatus(RegistryStatus.PROC.getKey());
|
registry_2.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||||
|
|
@ -768,6 +770,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_3.setGroupId(Long.MAX_VALUE);
|
registry_3.setGroupId(Long.MAX_VALUE);
|
||||||
registry_3.setClearingDate(LocalDate.now());
|
registry_3.setClearingDate(LocalDate.now());
|
||||||
registry_3.setRegistryCode("LM_T");
|
registry_3.setRegistryCode("LM_T");
|
||||||
|
registry_3.setSessionType(SessionType.FINL.getKey());
|
||||||
registry_3.setTradingClearingRegistry("TKR");
|
registry_3.setTradingClearingRegistry("TKR");
|
||||||
registry_3.setRegistryStatus(RegistryStatus.PROC.getKey());
|
registry_3.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||||
registry_3.setRegistryDesignation(RegistryDesignation.L.getKey());
|
registry_3.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||||
|
|
@ -783,6 +786,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_4.setTradingCode("TRADING_CODE");
|
registry_4.setTradingCode("TRADING_CODE");
|
||||||
registry_4.setSettlementDate(LocalDate.now());
|
registry_4.setSettlementDate(LocalDate.now());
|
||||||
registry_4.setGroupId(Long.MAX_VALUE);
|
registry_4.setGroupId(Long.MAX_VALUE);
|
||||||
|
registry_4.setSessionType(SessionType.FINL.getKey());
|
||||||
registry_4.setClearingDate(LocalDate.now());
|
registry_4.setClearingDate(LocalDate.now());
|
||||||
registry_4.setRegistryCode("CM_T");
|
registry_4.setRegistryCode("CM_T");
|
||||||
registry_4.setTradingClearingRegistry("TKR");
|
registry_4.setTradingClearingRegistry("TKR");
|
||||||
|
|
@ -1121,7 +1125,21 @@ public class ReportServiceTest_KS {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (findEqual) continue;
|
if (findEqual) continue;
|
||||||
Assertions.fail("For actual line '%s' not found expected line".formatted(String.join(",", actualLine)));
|
Assertions.fail("For actual line '%s' not found expected line".formatted(String.join(", ", actualLine)));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> errors = new ArrayList<>();
|
||||||
|
for (int idx = 0; idx < expectedHeaders.length; idx++) {
|
||||||
|
if (!Objects.equals(expectedHeaders[idx], actualHeaders[idx])) {
|
||||||
|
errors.add("expected header (%s) for idx = %d not equal actual header (%s)".formatted(
|
||||||
|
expectedHeaders[idx],
|
||||||
|
idx,
|
||||||
|
actualHeaders[idx])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
|
Assertions.fail("Files equal, but header sequence broken, cause: %s".formatted(String.join(",", errors)));
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedCSVReader.close();
|
expectedCSVReader.close();
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
"FIRM_ID","FIRM_ID_INITIATOR","SECCODE","CLASS_CODE","AGREEMENT_NUMBER","AGREEMENT_NUMBER_POSTFIX","AGREEMENT_DATE","SUM","AGREEMENT_SETTLEMENT_DATE","REPAYM_DATE","EXEC_STATUS"
|
"FIRM_ID","FIRM_ID_INITIATOR","SECCODE","CLASS_CODE","AGREEMENT_NUMBER","AGREEMENT_NUMBER_POSTFIX","AGREEMENT_DATE","AGREEMENT_SETTLEMENT_DATE","SUM","REPAYM_DATE","EXEC_STATUS"
|
||||||
"CLEARING_CODE","TRADING_CODE","CONT~RACT","market","CONT","CONT~RACT","01.01.1991","-77.78","02.01.2022","10.11.2023","Исполнен"
|
"CLEARING_CODE","TRADING_CODE","CONT~RACT","market","CONT","CONT~RACT","01.01.1991","06.11.2023","-77.78","16.11.2023","Исполнен"
|
||||||
|
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
"FIRMID","SESSION_ID","SESSION_DATE","ACCOUNT","TKR","VALUE","DATE"
|
"FIRMID","SESSION_ID","SESSION_DATE","ACCOUNT","TKR","VALUE","DATE","OBL_VALUE","REQ_VALUE"
|
||||||
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT","TKR","22.22","01.11.2023"
|
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT","TKR","22.22","16.11.2023","0.00","0.00"
|
||||||
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT_FROM_ACCOUNT","TKR","22.22","01.11.2023"
|
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT_FROM_ACCOUNT","TKR","0.00","16.11.2023","22.22","44.44"
|
||||||
|
|
|
||||||
|
|
|
@ -3,7 +3,8 @@ package ru.spcex.platform.enumeration;
|
||||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||||
|
|
||||||
public enum SessionType implements IEnumKey {
|
public enum SessionType implements IEnumKey {
|
||||||
IPOB("IPOB"), IPO0("IPO0"), IPOT("IPOT"), TRDT("TRDT"), MEDM("MEDM"), FINL("FINL"), XDEP("XDEP"),
|
IPOB("IPOB"), IPO0("IPO0"), IPOT("IPOT"), TRDT("TRDT"),
|
||||||
|
MEDM("MEDM"), FINL("FINL"), XDEP("XDEP"), LIQU("LIQU"),
|
||||||
;
|
;
|
||||||
|
|
||||||
SessionType(String key) {
|
SessionType(String key) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue