Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Релиз 2024.1.3 #606

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Investbook в сравнении с [Intelinvest](https://intelinvest.ru) и [Sn
при необходимости позволит безболезненно перенести накопленные данные в другое приложение учета инвестиций.

### Брокеры
Приложение анализирует отчеты брокеров Тинькофф (xlsx), Сбербанк (xlsx), ВТБ (xls), Промсвязьбанк (xlsx, xml)
Приложение анализирует отчеты брокеров ТБанк / Тинькофф (xlsx), Сбербанк (xlsx), ВТБ (xls), Промсвязьбанк (xlsx, xml)
и Твой Брокер / Уралсиб (zip с xls). Если ваш счет открыт у другого брокера,
напишите [нам](https://t.me/investbook_support). Также вы можете уже на вашей версии приложения воспользоваться
[формами](src/main/asciidoc/investbook-forms.adoc) ввода информации или
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</parent>
<groupId>ru.investbook</groupId>
<artifactId>investbook</artifactId>
<version>2024.1.2</version>
<version>2024.1.3</version>

<name>investbook</name>
<description>Investor Accounting Book</description>
Expand Down Expand Up @@ -62,7 +62,7 @@

<properties>
<!-- Valid version is (0-255).(0-255).(0-65535) -->
<win.msi.version>24.1.2</win.msi.version>
<win.msi.version>24.1.3</win.msi.version>
<java.version>21</java.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class TinkoffBrokerReport extends AbstractExcelBrokerReport {
private static final String PORTFOLIO_MARKER = "Инвестор:";
private static final Predicate<Object> tinkoffReportPredicate = cell ->
(cell instanceof String) && ((String) cell).contains("Тинькофф");
private static final Predicate<Object> tbankReportPredicate = cell ->
(cell instanceof String) && ((String) cell).contains("ТБанк");
private static final Predicate<Object> dateMarkerPredicate = cell ->
(cell instanceof String) && ((String) cell).contains("за период");

Expand All @@ -61,8 +63,9 @@ public TinkoffBrokerReport(String excelFileName, InputStream is, SecurityRegistr
}

public static void checkReportFormat(String excelFileName, ReportPage reportPage) {
if (reportPage.find(0, 2, tinkoffReportPredicate) == TableCellAddress.NOT_FOUND) {
throw new RuntimeException("В файле " + excelFileName + " не содержится отчет брокера Тинькофф");
if (reportPage.find(0, 2, tbankReportPredicate) == TableCellAddress.NOT_FOUND &&
reportPage.find(0, 2, tinkoffReportPredicate) == TableCellAddress.NOT_FOUND) {
throw new RuntimeException("В файле " + excelFileName + " не содержится отчет брокера ТБанк (Тинькофф)");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.math.BigDecimal;
import java.time.Instant;

import static org.springframework.util.StringUtils.hasLength;
import static ru.investbook.parser.tinkoff.TinkoffSecurityTransactionTable.TransactionTableHeader.*;

@Slf4j
Expand Down Expand Up @@ -77,12 +78,20 @@ private TinkoffSecurityTransactionTable(String tableNamePrefix,

@Override
protected AbstractTransaction parseRow(TableRow row) {
long _tradeId = row.getLongCellValueOrDefault(TRADE_ID, -1);
if (_tradeId == -1) return null;
String tradeId = String.valueOf(_tradeId);
String tradeId = row.getStringCellValueOrDefault(TRADE_ID, "");
if (!hasLength(tradeId)) return null;
String operation = row.getStringCellValue(OPERATION).toLowerCase();
boolean isBuy = operation.contains("покупка");
boolean isRepo = operation.contains("репо");
if (isRepo) {
// Сделки переноса РЕПО "РЕПО 1 Покупка" и "РЕПО 2 Продажа" имеют одинаковый tradeId и timestamp.
// Это синтетические сделки, но эти сделки имеют комиссии, поэтому их нужно иметь возможность сохранить в БД.
// Требуется уникальный tradeId для обоих РЕПО сделок.
String tradeIdSuffix = isBuy ? "repobuy" : "reposell";
tradeId += tradeIdSuffix;
}

int securityId = transactionTableHelper.getSecurityId(row, codeAndIsin, getReport().getSecurityRegistrar());
boolean isBuy = row.getStringCellValue(OPERATION).toLowerCase().contains("покупка");
int count = Math.abs(row.getIntCellValue(COUNT));
BigDecimal amount = row.getBigDecimalCellValue(AMOUNT).abs();
amount = isBuy ? amount.negate() : amount;
Expand Down