Skip to content

Commit dcbe3d5

Browse files
authored
Merge pull request #17 from spacious-team/develop
Релиз 2021.9
2 parents 87346ab + 9bfbe74 commit dcbe3d5

File tree

9 files changed

+34
-29
lines changed

9 files changed

+34
-29
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<groupId>org.spacious-team</groupId>
2626
<artifactId>broker-report-parser-api</artifactId>
27-
<version>2021.8</version>
27+
<version>2021.9</version>
2828
<packaging>jar</packaging>
2929

3030
<name>Broker Report Parser API</name>

src/main/java/org/spacious_team/broker/pojo/PortfolioPropertyType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020

2121
public enum PortfolioPropertyType {
2222
TOTAL_ASSETS_RUB,
23-
TOTAL_ASSETS_USD, // use one of TOTAL_ASSETS_RUB or TOTAL_ASSETS_USD
23+
TOTAL_ASSETS_USD, // if TOTAL_ASSETS_RUB and TOTAL_ASSETS_USD exists for same date, total assets is sum of them
2424
CASH
2525
}

src/main/java/org/spacious_team/broker/pojo/Transaction.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.spacious_team.broker.pojo;
2020

21+
import com.fasterxml.jackson.annotation.JsonProperty;
2122
import io.swagger.v3.oas.annotations.media.Schema;
2223
import lombok.Builder;
2324
import lombok.EqualsAndHashCode;
@@ -37,9 +38,14 @@
3738
@EqualsAndHashCode(cacheStrategy = LAZY)
3839
@Schema(name = "Сделка")
3940
public class Transaction {
41+
//@Nullable // autoincrement
42+
@Schema(description = "Внутренний идентификатор сделки", example = "123", required = true)
43+
private final Integer id;
44+
4045
@NotNull
46+
@JsonProperty("trade-id")
4147
@Schema(description = "Номер сделки в системе учета брокера", example = "123SP", required = true)
42-
private final String id;
48+
private final String tradeId;
4349

4450
@NotNull
4551
@Schema(description = "Номер счета в системе учета брокера", example = "10200I", required = true)

src/main/java/org/spacious_team/broker/pojo/TransactionCashFlow.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
@EqualsAndHashCode(cacheStrategy = LAZY)
4040
@Schema(name = "Движение ДС по сделке")
4141
public class TransactionCashFlow {
42-
@NotNull
43-
@JsonProperty("transaction-id")
44-
@Schema(description = "Номер сделки в системе учета брокера", example = "123SP", required = true)
45-
private final String transactionId;
42+
//@Nullable // autoincrement
43+
@Schema(description = "Внутренний идентификатор записи", example = "1", required = true)
44+
private final Integer id;
4645

4746
@NotNull
48-
@Schema(description = "Номер счета в системе учета брокера", example = "10200I", required = true)
49-
private final String portfolio;
47+
@JsonProperty("transaction-id")
48+
@Schema(description = "Внутренний идентификатор сделки", example = "123", required = true)
49+
private final Integer transactionId;
5050

5151
@NotNull
5252
@JsonProperty("event-type")

src/main/java/org/spacious_team/broker/report_parser/api/AbstractBrokerReportFactory.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,8 @@ public abstract class AbstractBrokerReportFactory implements BrokerReportFactory
2929
/**
3030
* @param expectedFileNamePattern used for fast report check without input stream reading
3131
*/
32-
protected BrokerReport create(Pattern expectedFileNamePattern,
33-
String excelFileName,
34-
InputStream is,
35-
BiFunction<String, InputStream, BrokerReport> brokerReportProvider) {
36-
if (expectedFileNamePattern.matcher(excelFileName).matches()) {
37-
return create(excelFileName, is, brokerReportProvider);
38-
}
39-
return null;
32+
protected boolean canCreate(Pattern expectedFileNamePattern, String excelFileName, InputStream is) {
33+
return expectedFileNamePattern.matcher(excelFileName).matches();
4034
}
4135

4236
/**

src/main/java/org/spacious_team/broker/report_parser/api/AbstractTransaction.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
@EqualsAndHashCode(cacheStrategy = LAZY)
4141
public abstract class AbstractTransaction {
4242
protected static final BigDecimal minValue = BigDecimal.valueOf(0.01);
43-
protected final String transactionId;
43+
protected final Integer id;
44+
protected final String tradeId;
4445
protected final String portfolio;
4546
protected final String security;
4647
protected final Instant timestamp;
@@ -52,7 +53,8 @@ public abstract class AbstractTransaction {
5253

5354
public Transaction getTransaction() {
5455
return Transaction.builder()
55-
.id(transactionId)
56+
.id(id)
57+
.tradeId(tradeId)
5658
.portfolio(portfolio)
5759
.security(security)
5860
.timestamp(timestamp)
@@ -70,8 +72,7 @@ public List<TransactionCashFlow> getTransactionCashFlows() {
7072
protected Optional<TransactionCashFlow> getValueCashFlow(CashFlowType type) {
7173
if (value != null && value.abs().compareTo(minValue) >= 0) {
7274
return Optional.of(TransactionCashFlow.builder()
73-
.transactionId(transactionId)
74-
.portfolio(portfolio)
75+
.transactionId(id)
7576
.eventType(type)
7677
.value(value)
7778
.currency(valueCurrency)
@@ -83,8 +84,7 @@ protected Optional<TransactionCashFlow> getValueCashFlow(CashFlowType type) {
8384
protected Optional<TransactionCashFlow> getCommissionCashFlow() {
8485
if (commission != null && commission.abs().compareTo(minValue) >= 0) {
8586
return Optional.of(TransactionCashFlow.builder()
86-
.transactionId(transactionId)
87-
.portfolio(portfolio)
87+
.transactionId(id)
8888
.eventType(CashFlowType.COMMISSION)
8989
.value(commission)
9090
.currency(commissionCurrency)

src/main/java/org/spacious_team/broker/report_parser/api/BrokerReportFactory.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222

2323
public interface BrokerReportFactory {
2424

25+
/**
26+
* Fast check if this factory can't parse report.
27+
* Method should always reset input stream mark to original position.
28+
* @return false when can't parse, true when parsing maybe possible
29+
* @throws IllegalArgumentException if InputStream is not supports mark
30+
*/
31+
boolean canCreate(String excelFileName, InputStream is);
32+
2533
/**
2634
* Checks input stream and returns broker report if can, otherwise reset input stream mark to original position
2735
* and returns null

src/main/java/org/spacious_team/broker/report_parser/api/DerivativeTransaction.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public List<TransactionCashFlow> getTransactionCashFlows() {
5151
protected Optional<TransactionCashFlow> getValueInPointsCashFlow() {
5252
if (valueInPoints != null) {
5353
return Optional.of(TransactionCashFlow.builder()
54-
.transactionId(transactionId)
55-
.portfolio(portfolio)
54+
.transactionId(id)
5655
.eventType(CashFlowType.DERIVATIVE_QUOTE)
5756
.value(valueInPoints)
5857
.currency(QUOTE_CURRENCY)
@@ -65,8 +64,7 @@ protected Optional<TransactionCashFlow> getValueInPointsCashFlow() {
6564
protected Optional<TransactionCashFlow> getValueCashFlow(CashFlowType type) {
6665
if (value != null) {
6766
return Optional.of(TransactionCashFlow.builder()
68-
.transactionId(transactionId)
69-
.portfolio(portfolio)
67+
.transactionId(id)
7068
.eventType(type)
7169
.value(value)
7270
.currency(valueCurrency)

src/main/java/org/spacious_team/broker/report_parser/api/SecurityTransaction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ private Optional<TransactionCashFlow> getAccruedInterestCashFlow() {
5151
// for securities accrued interest = 0
5252
if (accruedInterest != null && accruedInterest.abs().compareTo(minValue) >= 0) {
5353
return Optional.of(TransactionCashFlow.builder()
54-
.transactionId(transactionId)
55-
.portfolio(portfolio)
54+
.transactionId(id)
5655
.eventType(CashFlowType.ACCRUED_INTEREST)
5756
.value(accruedInterest)
5857
.currency(valueCurrency)

0 commit comments

Comments
 (0)