def run(): # parse command line options args = parse_args() # set up user interface ui = UI() try: process(args, ui) except Abort as e: ui.error(e)
def test_parse_visa(): plugin = SberBankTxtPlugin(UI(), {}) s = plugin.get_parser(file_sample('sberbank_visa.txt')).parse() assert s is not None assert s.account_id == 'VISA GOLD XXXX XXXX XXX4 6122 ОСНОВНАЯ' assert s.currency == 'RUR' assert s.bank_id == 'SberBank' assert s.end_balance == 20877.29 assert s.start_balance == 318.3 assert len(s.lines) == 34 assert all(l.amount for l in s.lines) assert s.lines[2].memo == 'ПОПОЛНЕНИЕ СЧЕТА' assert s.lines[2].trntype == 'DEBIT' assert s.lines[7].memo == 'PEREKRESTOK KRYLATSKOY E NOGINSK RU' assert s.lines[7].trntype == 'CREDIT' assert s.lines[7].amount == -1699.0 assert s.lines[7].date == datetime.datetime(2018, 10, 4, 0, 0) assert s.lines[14].memo == 'TINKOFF BANK CARD2CARD Visa Direct RU' assert s.lines[25].memo == 'Rocketbank.ru Card2Car d MOSCOW RU' assert s.lines[25].trntype == 'CREDIT' assert abs( sum(l.amount for l in s.lines) + s.start_balance - s.end_balance) < 0.001
def test_parse_davider80() -> None: # GIVEN config = {"currency": "CHF"} plugin = Iso20022Plugin(UI(), config) parser = plugin.get_parser(os.path.join(SAMPLES_DIR, "davider80.xml")) # WHEN stmt = parser.parse() # THEN assert stmt is not None assert stmt.account_id == "CHxxxxxxxxxxxxxxxxxxx" assert stmt.currency is "CHF" assert stmt.bank_id == "Raiffeisen" assert stmt.end_balance == Decimal("5753.46") assert stmt.end_date == datetime.datetime(2017, 4, 11, 0, 0) assert stmt.start_balance == Decimal("9433.31") assert stmt.start_date == datetime.datetime(2017, 4, 1, 0, 0) assert len(stmt.lines) == 16 assert all(l.amount for l in stmt.lines) line0 = stmt.lines[0] assert line0.amount == Decimal("-905.3") assert line0.memo == "Sistema di addebitamento diretto xxxxxxxxxxxxxxxxxxxxxx AG" assert line0.date == datetime.datetime(2017, 4, 3, 0, 0) assert line0.date_user == datetime.datetime(2017, 4, 1, 0, 0) assert line0.payee is None assert line0.refnum == "210564431020000000024556150000"
def test_parse_gcamp6() -> None: # GIVEN config = {"currency": "XXX"} plugin = Iso20022Plugin(UI(), config) parser = plugin.get_parser(os.path.join(SAMPLES_DIR, "gcamp6.xml")) # WHEN stmt = parser.parse() # THEN assert stmt is not None assert stmt.account_id == "CH2609000000924238861" assert stmt.currency is "XXX" assert stmt.bank_id is None assert stmt.end_balance == Decimal("10000.0") assert stmt.end_date == datetime.datetime(2017, 1, 31, 0, 0) assert stmt.start_balance == Decimal("0.0") assert stmt.start_date == datetime.datetime(2015, 12, 31, 0, 0) assert len(stmt.lines) == 5 assert all(l.amount for l in stmt.lines) line0 = stmt.lines[0] assert line0.amount == Decimal("10000.0") assert line0.memo == "Account Transfer" assert line0.date == datetime.datetime(2016, 4, 23, 0, 0) assert line0.date_user == datetime.datetime(2016, 4, 23, 0, 0) assert line0.payee is None assert line0.refnum == "20160423000805545979476000000012"
def test_parse_simple() -> None: # GIVEN plugin = Iso20022Plugin(UI(), {}) parser = plugin.get_parser(os.path.join(SAMPLES_DIR, "simple.xml")) # WHEN stmt = parser.parse() # THEN assert stmt is not None assert stmt.account_id == "LT000000000000000000" assert stmt.currency == "EUR" assert stmt.bank_id == "AGBLLT2XXXX" assert stmt.end_balance == Decimal("125.52") assert stmt.end_date == datetime.datetime(2015, 12, 31, 0, 0) assert stmt.start_balance == Decimal("306.53") assert stmt.start_date == datetime.datetime(2015, 12, 1, 0, 0) assert len(stmt.lines) == 4 assert all(l.amount for l in stmt.lines) line0 = stmt.lines[0] assert line0.amount == Decimal("-0.29") assert line0.memo == u"Sąskaitos aptarnavimo mokestis" assert line0.date == datetime.datetime(2016, 1, 1, 0, 0) assert line0.date_user == datetime.datetime(2015, 12, 31, 0, 0) assert line0.payee == u"AB DNB Bankas" assert line0.refnum == "FC1261858984"
def test_parse_camt052() -> None: # GIVEN config = {"currency": "CHF"} plugin = Iso20022Plugin(UI(), config) parser = plugin.get_parser(os.path.join(SAMPLES_DIR, "camt052.xml")) # WHEN stmt = parser.parse() # THEN assert stmt is not None assert stmt.account_type == "CHECKING" assert stmt.bank_id == "PZHSDE66XXX" assert stmt.currency == "EUR" assert stmt.end_balance == Decimal("16.95") assert stmt.end_date == datetime.datetime(2021, 2, 5, 0, 0) assert stmt.start_balance == Decimal("268.35") assert stmt.start_date == datetime.datetime(2021, 2, 4, 0, 0) assert len(stmt.lines) == 5 line0 = stmt.lines[0] assert line0.check_no is None assert line0.date == datetime.datetime(2021, 2, 5, 0, 0) assert line0.date_user == datetime.datetime(2021, 2, 5, 0, 0) assert line0.id is None assert line0.memo == "Something" assert line0.payee == "SPARKASSE PFORZHEIM CALW" assert line0.refnum == "NONREF"
def test_parse_simple(): # GIVEN plugin = Iso20022Plugin(UI(), {}) parser = plugin.get_parser(os.path.join(SAMPLES_DIR, 'simple.xml')) # WHEN stmt = parser.parse() # THEN assert stmt is not None assert stmt.account_id == 'LT000000000000000000' assert stmt.currency == 'EUR' assert stmt.bank_id == 'AGBLLT2XXXX' assert stmt.end_balance == 125.52 assert stmt.end_date == datetime.datetime(2015, 12, 31, 0, 0) assert stmt.start_balance == 306.53 assert stmt.start_date == datetime.datetime(2015, 12, 1, 0, 0) assert len(stmt.lines) == 4 assert all(l.amount for l in stmt.lines) line0 = stmt.lines[0] assert line0.amount == -0.29 assert line0.memo == u'Sąskaitos aptarnavimo mokestis' assert line0.date == datetime.datetime(2016, 1, 1, 0, 0) assert line0.date_user == datetime.datetime(2015, 12, 31, 0, 0) assert line0.payee == u'AB DNB Bankas' assert line0.refnum == 'FC1261858984'
def test_parse_unconfigured_currency() -> None: # GIVEN plugin = Iso20022Plugin(UI(), {}) parser = plugin.get_parser(os.path.join(SAMPLES_DIR, "gcamp6.xml")) # WHEN with pytest.raises(exceptions.ParseError): stmt = parser.parse()
def test_sample() -> None: plugin = SamplePlugin(UI(), {}) here = os.path.dirname(__file__) sample_filename = os.path.join(here, "sample-statement.csv") parser = plugin.get_parser(sample_filename) statement = parser.parse() assert statement is not None
def test_unsupported() -> None: # GIVEN config = {"currency": "CHF"} plugin = Iso20022Plugin(UI(), config) # WHEN parser = plugin.get_parser(os.path.join(SAMPLES_DIR, "unsupported.xml")) # THEN with pytest.raises(exceptions.ParseError): parser.parse()
def test_sberbank(): plugin = SberBankCSVPlugin(UI(), {'currency': 'RUR'}) s = plugin.get_parser(os.path.join(SAMPLES_DIR, 'sberbank.csv')).parse() assert s is not None assert s.account_id == u'Основная *6833' assert s.currency == 'RUR' assert s.bank_id == 'SberBank' assert len(s.lines) == 11 assert all(l.amount for l in s.lines) assert s.lines[0].__dict__ == { 'amount': -4320.4, 'check_no': None, 'date': datetime.datetime(2019, 10, 31, 0, 0), 'date_user': datetime.datetime(2019, 10, 31, 0, 0), 'id': None, 'memo': 'SBOL перевод 4276****1234 И. ИВАН ИВАНОВИЧ, MOSCOW, RUS, 4829', 'payee': None, 'refnum': None, 'trntype': 'CREDIT' } assert s.lines[3].__dict__ == { 'amount': 9.01, 'check_no': None, 'date': datetime.datetime(2019, 6, 17, 0, 0), 'date_user': datetime.datetime(2019, 6, 16, 0, 0), 'id': None, 'memo': 'SBERBANK ONL@IN VKLAD-KARTA , Moscow, RUS', 'payee': None, 'refnum': None, 'trntype': 'DEBIT' } assert sum(l.amount for l in s.lines) == 7338.83
def test_parse_maestro(): plugin = SberBankTxtPlugin(UI(), {}) s = plugin.get_parser(file_sample('sberbank_maestro.txt')).parse() assert s is not None assert s.account_id == 'СБЕРБАНК - MAESTRO XXXXXXXXX XXXX40696 ОСНОВНАЯ' assert s.currency == 'RUR' assert s.bank_id == 'SberBank' assert s.end_balance == 0 assert s.start_balance == 0 assert len(s.lines) == 4 assert all(l.amount for l in s.lines) line0 = s.lines[0] assert line0.amount == 10000.0 assert line0.memo == 'SBOL MOSCOW RUS' assert line0.date == datetime.datetime(2019, 3, 26, 0, 0) assert line0.trntype == 'DEBIT'