Skip to content

Commit

Permalink
Update procreditbank business & Sensebank due to latest format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OSadovy committed Feb 16, 2024
1 parent 88bbe4f commit 93d59a1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/uabean/importers/procredit_business.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Imports statement csv files exported from Procredit Business Online web app.
The CSV header is the following:
The CSV header is one of the following:
ЄДРПОУ;Код ID НБУ;Рахунок;Валюта;Дата операції;Код операції;МФО банка;Назва банка;Рахунок кореспондента;ЄДРПОУ кореспондента;Кореспондент;Номер документа;Дата документа;Дебет;Кредит;Призначення платежу;Гривневе покриття
ЄДРПОУ;Код ID НБУ;Рахунок;Валюта;Дата операції;Код операції;Код ID НБУ;Надавач платіжних послуг;Рахунок кореспондента;ЄДРПОУ кореспондента;Кореспондент;Номер документа;Дата документа;Дебет;Кредит;Призначення платежу;Гривневе покриття
"""

import csv
Expand All @@ -18,7 +19,7 @@

class Importer(IdentifyMixin, beangulp.Importer):
matchers = [
("content", __doc__.split("\n")[-2]),
("content", __doc__.split("\n")[-2][:59]),
("mime", "text/csv"),
]
fee_regexes = ("Сплата комісії", "Комісія за переказ в національній валюті")
Expand Down
8 changes: 7 additions & 1 deletion src/uabean/importers/procredit_xls.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ def row_to_dict(cls, header_cols, row):

def balance_from_row(self, meta, account, currency, row, index):
dt = dateutil.parser.parse(row[index].value.split(" ")[-1], dayfirst=True)
num = self.get_number(next(cell for cell in row[index + 1 :] if cell.value))
num = self.get_number(
next(
cell
for cell in row[index + 1 :]
if (cell.value is not None or cell.value != "")
)
)
return data.Balance(
meta,
dt.date(),
Expand Down
4 changes: 3 additions & 1 deletion src/uabean/importers/sensebank.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class Importer(IdentifyMixin, beangulp.Importer):
("content", "Виписка за рахунком;;;;;;;"),
("mime", "text/csv"),
]
converter = lambda unused, fname: open(fname, encoding="windows-1251").read()
converter = lambda unused, fname: open(
fname, encoding="windows-1251", errors="replace"
).read()
DATE_COL = 0
STATUS_COL = 1
TYPE_COL = 2
Expand Down

0 comments on commit 93d59a1

Please sign in to comment.