fetch: add support for Irish account numbers, improve error reporting
parent
f212be7223
commit
1457f91531
|
@ -109,6 +109,9 @@ class IBRow(RawTransfer):
|
|||
self.on_account = own_account
|
||||
|
||||
other_account = IBParser.parse_account_number(row[IBField.other_account])
|
||||
if other_account is None:
|
||||
raise IBParseError("other_account {} could not be parsed".format(row[IBField.other_account]))
|
||||
|
||||
other_name = row[IBField.other_name]
|
||||
|
||||
|
||||
|
@ -154,7 +157,7 @@ class IBRow(RawTransfer):
|
|||
raise IBParseError("Can't figure out transfer type for current row", row)
|
||||
|
||||
if None in (self.type, self.to_account, self.from_account, self.to_name, self.from_name):
|
||||
raise IBParseError("Something went wrong - one of the mandatory values empty")
|
||||
raise IBParseError("Something went wrong - one of the mandatory values empty",self.type, self.to_account, self.from_account, self.to_name, self.from_name)
|
||||
|
||||
class IBField(enum.Enum):
|
||||
#Data waluty;Data zlecenia;Numer rachunku nadawcy;Numer banku nadawcy;Kwota w walucie rachunku;Waluta;Kurs;Kwota w walucie zlecenia;Numer rachunku odbiorcy;Odbiorca;Numer banku odbiorcy;Tytuł;Obciążenie/uznanie;Numer transakcji w systemie centralnym;
|
||||
|
@ -217,6 +220,7 @@ class IBParser(object):
|
|||
def parse_account_number(s):
|
||||
formats = [
|
||||
"((?:[A-Za-z]{2})?[0-9]{2})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})", # 26 digits, optional country code - Poland
|
||||
"((?:[A-Za-z]{2})?[0-9]{2})[ ]?([A-Z]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{2})", # 22 characters including BIC bank code - Ireland
|
||||
]
|
||||
for f in formats:
|
||||
m = re.search(f, s)
|
||||
|
|
Loading…
Reference in New Issue