def parse_record(self, line):
        """Parse a single record."""
        # Skip header line
        if self.cur_record == 1:
            return None

        # Account id
        if not self.statement.account_id:
            self.statement.account_id = line[0]

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[3]

        # Save credit/debit on line[4]
        if line[4] == "0,00":
            line[4] = fix_amount_string(line[5])
        else:
            line[4] = "-{}".format(fix_amount_string(line[4]))

        # Create statement and fixup missing parts
        stmtline = super(IngDiBaCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Skip header line
        if self.cur_record == 1:
            return None

        # Account id
        if not self.statement.account_id:
            self.statement.account_id = line[0]

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[3]

        # Save credit/debit on line[4]
        if line[4] == "0,00":
            line[4] = fix_amount_string(line[5])
        else:
            line[4] = "-{}".format(fix_amount_string(line[4]))

        # Create statement and fixup missing parts
        stmtline = super(IngDiBaCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Skip header line
        if self.cur_record == 1:
            return None

        # Skip lines without amount
        if line[7] == "0,00":
            return None

        # Account id
        if not self.statement.account_id:
            self.statement.account_id = line[0]

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[6]

        # Cleanup parts
        line[7] = fix_amount_string(line[7])
        line[9] = clean_multiple_whitespaces(", ".join(line[9:]))

        # Create statement and fixup missing parts
        stmtline = super(LivebankCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Split the description into two parts and save it to the line list.
        parts = line[1].split('|')

        # 3 parts: Description, foreign language, transaction id
        # 2 parts: Description, transaction id
        if len(parts) == 3:
            line[1] = "{} ({})".format(parts[0], parts[1])
        else:
            line[1] = parts[0]
        line.insert(2, parts[-1])

        # Account id
        if not self.statement.account_id:
            self.statement.account_id = line[0]

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[6]

        # Cleanup amount
        line[5] = fix_amount_string(line[5])
        line[1] = clean_multiple_whitespaces(line[1])

        # Create statement and fixup missing parts
        stmtline = super(EasybankCreditCardCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Skip header line
        if self.cur_record == 1:
            return None

        # Skip lines without amount
        if line[7] == "0,00":
            return None

        # Account id
        if not self.statement.account_id:
            self.statement.account_id = line[0]

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[6]

        # Cleanup parts
        line[7] = fix_amount_string(line[7])
        line[9] = clean_multiple_whitespaces(", ".join(line[9:]))

        # Create statement and fixup missing parts
        stmtline = super(LivebankCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Extract check_no/id
        description = line[1]
        del line[1]

        # Get check_no from description
        line.insert(1, self.extract_check_no(description))

        # Get memo and payee from description
        tt = self.extract_description(description)
        line.insert(2, tt[0])
        line.insert(3, tt[1])
        # line.insert(2, self.extract_description(description))

        # Account id
        if not self.statement.account_id:
            self.statement.account_id = line[0]

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[7]

        # Cleanup parts
        line[6] = fix_amount_string(line[6])
        line[2] = clean_multiple_whitespaces(line[2])
        line[3] = clean_multiple_whitespaces(line[3])

        # Create statement and fixup missing parts
        stmtline = super(EasybankGiroCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Currency
        if not self.statement.currency:
            self.statement.currency = line[4]

        # Cleanup parts
        line[3] = fix_amount_string(line[3])
        line[1] = clean_multiple_whitespaces(line[1])

        # Create statement and fixup missing parts
        stmtline = super(RaiffeisenCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
Exemple #8
0
    def parse_record(self, line):
        """Parse a single record."""
        # Currency
        if not self.statement.currency:
            self.statement.currency = line[4]

        # Cleanup parts
        line[3] = fix_amount_string(line[3])
        line[1] = clean_multiple_whitespaces(line[1])

        # Create statement and fixup missing parts
        stmtline = super(RaiffeisenCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Skip header line
        if self.cur_record == 1:
            return None

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[3]

        # Cleanup parts
        line[2] = fix_amount_string(line[2])
        line[10] = clean_multiple_whitespaces(line[10])

        # Create statement and fixup missing parts
        stmtline = super(OberbankCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
    def parse_record(self, line):
        """Parse a single record."""
        # Skip header line
        if self.cur_record == 1:
            return None

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[3]

        # Cleanup parts
        line[2] = fix_amount_string(line[2])
        line[10] = clean_multiple_whitespaces(line[10])

        # Create statement and fixup missing parts
        stmtline = super(OberbankCsvParser, self).parse_record(line)
        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'
        stmtline.id = generate_transaction_id(stmtline)

        return stmtline
 def test_with_thousand_mark(self):
     self.assertEqual(fix_amount_string("100.234,23"), "100234.23")
 def test_no_thousand_mark(self):
     self.assertEqual(fix_amount_string("1,23"), "1.23")
 def test_integer_string(self):
     self.assertEqual(fix_amount_string("11"), "11")
 def test_no_thousand_mark(self):
     self.assertEqual(fix_amount_string("1,23"), "1.23")
 def test_integer_string(self):
     self.assertEqual(fix_amount_string("11"), "11")
Exemple #16
0
    def parse_record(self, line):
        """Parse a single record."""
        # Skip header line
        if self.cur_record == 1:
            return None

        # Fix German number format prior to parsing
        line[5] = format(fix_amount_string(line[5]))  # German number format

        # Create statement
        # Parse line elements using the mappings defined above
        #   (call parse_record() from parent class)
        stmtline = super(BankAustriaCsvParser, self).parse_record(line)

        stmtline.id = generate_transaction_id(stmtline)

        # manual date_user conversion as date_user has wrong format
        # TODO remove me when the following patch was released (v0.6.2?)
        # https://github.com/kedder/ofxstatement/commit/38af84d525f5c47c7fab67c02b36c32dcfc805b3
        stmtline.date_user = datetime.strptime(line[1], self.date_format)

        stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'

        # Account id
        # if not self.statement.account_id:
        #     self.statement.account_id = line[9]

        # Currency
        if not self.statement.currency:
            self.statement.currency = line[4]

        # .payee is imported as "Description" in GnuCash
        # .memo is imported as "Notes" in GnuCash
        #
        # When .payee is empty, GnuCash
        # imports .memo to "Description" and keeps "Notes" empty, see
        # https://github.com/archont00/ofxstatement-unicreditcz/blob/master/src/ofxstatement/plugins/unicreditcz.py#L100

        # Fixup Memo, Payee, and TRXTYPE
        if line[2].startswith('POS'):
            stmtline.trntype = 'POS'
            stmtline.memo = self.parsePosAtm(line[2])

        elif line[2].startswith('ATM'):
            stmtline.trntype = 'ATM'
            stmtline.memo = self.parsePosAtm(line[2])

        elif line[2].startswith('AUTOMAT') or line[2].startswith('BANKOMAT'):
            # > AUTOMAT   00011942 K1   14.01. 13:47     O
            # > BANKOMAT  00021241 K4   08.03. 09:43     O
            stmtline.trntype = 'ATM'
            # TODO stmtline.memo = self.parsePosAtm(line[2]) ?
            stmtline.memo = line[2]

        elif line[2].startswith('ABHEBUNG AUTOMAT'):
            # > ABHEBUNG AUTOMAT NR. 14547 AM 31.01. UM 15.53 UHR Fil.ABC BANKCARD 2    # noqa: E501
            # TODO stmtline.memo = self.parsePosAtm(line[2]) ?
            stmtline.trntype = 'ATM'
            stmtline.memo = line[2]

        elif line[2].startswith('EINZAHLUNG'):
            # > EINZAHLUNG AUTOMAT NR. 55145 AM 31.01. / 15.55 UHR Fil.ABC BANKCARD 2 EIGENERLAG    # noqa: E501
            stmtline.memo = line[2]

        elif line[2].startswith('Lastschrift JustinCase'):
            # > Lastschrift JustinCase MRefAT123123123123123123JIC Entgelt für Bank Austria 0,69 enth‰lt 20% Ust., das sind EUR 0,12.   # noqa: E501
            stmtline.memo = line[2]

        elif line[6].startswith('SEPA-AUFTRAGSBESTÄTIGUNG'):
            if not stmtline.memo:
                stmtline.memo = self.parseDocument(line[6])

        elif (line[6].startswith('GUTSCHRIFT') or line[6].startswith('SEPA') or
                line[6].startswith('ÜBERWEISUNG')):
            # Auftraggebername holds the information we want
            stmtline.payee = line[8]
            if not stmtline.memo:
                stmtline.memo = self.parseDocument(line[6])

        else:
            stmtline.memo = line[2]

        # Simple cleanup
        stmtline.payee = clean_multiple_whitespaces(stmtline.payee)
        stmtline.memo = clean_multiple_whitespaces(stmtline.memo)

        # Add Internal Note, if exists
        if line[3]:
            # Add trailing whitespace if memo exists
            if stmtline.memo:
                stmtline.memo = stmtline.memo + ' '
            stmtline.memo = stmtline.memo + '(NOTE: )' + line[3]

        return stmtline
 def test_with_thousand_mark(self):
     self.assertEqual(fix_amount_string("100.234,23"), "100234.23")