Skip to content

Commit

Permalink
Draft template for VTB statement import: currency list load.
Browse files Browse the repository at this point in the history
  • Loading branch information
titov-vv committed Jan 28, 2024
1 parent b0ea5ec commit 5a4de51
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
26 changes: 26 additions & 0 deletions jal/data_import/broker_statements/vtb.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import logging
from jal.data_import.statement_xls import StatementXLS


JAL_STATEMENT_CLASS = "StatementVTB"

# ----------------------------------------------------------------------------------------------------------------------
class StatementVTB(StatementXLS):
PeriodPattern = (7, 1, r"Отчет Банка ВТБ \(ПАО\) за период с (?P<S>\d\d\.\d\d\.\d\d\d\d) по (?P<E>\d\d\.\d\d\.\d\d\d\d) о сделках, .*")
AccountPattern = (9, 7, None)
HeaderCol = 1
money_section = "Отчет об остатках денежных средств"
money_columns = {
"name": "Валюта",
"cash_end": "Плановый",
}

def __init__(self):
super().__init__()
Expand All @@ -14,6 +22,24 @@ def __init__(self):
self.filename_filter = self.tr("VTB statement (*.xls)")
self.asset_withdrawal = []

def _load_currencies(self):
cnt = 0
row, headers = self.find_section_start(self.money_section, self.money_columns, header_height=3)
if row < 0:
return False
while row < self._statement.shape[0]:
if self._statement[self.HeaderCol][row].startswith('Сумма') or self._statement[self.HeaderCol][row] == '':
break
currency = self._statement[headers['name']][row]
try:
code = self.currency_substitutions[currency]
except KeyError:
code = currency
self.currency_id(code)
cnt += 1
row += 1
logging.info(self.tr("Account currencies loaded: ") + f"{cnt}")

def _load_deals(self):
pass

Expand Down
15 changes: 12 additions & 3 deletions tests/test_data/vtb.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{
"period": [1704067200, 1705535999],
"accounts": [],
"assets": [],
"symbols": [],
"accounts": [
{"id": 1, "number": "111ABC", "currency": 1},
{"id": 2, "number": "111ABC", "currency": 2}
],
"assets": [
{"id": 1, "name": "", "type": "money"},
{"id": 2, "name": "", "type": "money"}
],
"symbols": [
{"id": 1, "asset": 1, "symbol": "RUB"},
{"id": 2, "asset": 2, "symbol": "USD"}
],
"assets_data": [],
"trades": [],
"income_spending": [],
Expand Down

0 comments on commit 5a4de51

Please sign in to comment.