Beispiel #1
0
 def testThatParseTransactionReturnsATransaction(self):
     input = '''
     <STMTTRN><TRNTYPE>POS<DTPOSTED>20090401122017.000[-5:EST]<TRNAMT>-6.60<FITID>0000123456782009040100001<NAME>MCDONALD'S #112<MEMO>POS MERCHANDISE;MCDONALD'S #112</STMTTRN>
     '''
     txn = BeautifulStoneSoup(input)
     transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
     self.assertEquals('pos', transaction.type)
     self.assertEquals(datetime(2009, 4, 1, 12, 20, 17) - timedelta(hours=-5), transaction.date)
     self.assertEquals(Decimal('-6.60'), transaction.amount)
     self.assertEquals('0000123456782009040100001', transaction.id)
     self.assertEquals("MCDONALD'S #112", transaction.payee)
     self.assertEquals("POS MERCHANDISE;MCDONALD'S #112", transaction.memo)
Beispiel #2
0
 def testThatParseTransactionReturnsATransaction(self):
     input = '''
     <STMTTRN><TRNTYPE>POS<DTPOSTED>20090401122017.000[-5:EST]<TRNAMT>-6.60<FITID>0000123456782009040100001<NAME>MCDONALD'S #112<MEMO>POS MERCHANDISE;MCDONALD'S #112</STMTTRN>
     '''
     txn = BeautifulStoneSoup(input)
     transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
     self.assertEquals('pos', transaction.type)
     self.assertEquals(datetime(2009, 4, 1, 12, 20, 17) - timedelta(hours=-5), transaction.date)
     self.assertEquals(Decimal('-6.60'), transaction.amount)
     self.assertEquals('0000123456782009040100001', transaction.id)
     self.assertEquals("MCDONALD'S #112", transaction.payee)
     self.assertEquals("POS MERCHANDISE;MCDONALD'S #112", transaction.memo)
Beispiel #3
0
    def testThatParseTransactionWithFieldCheckNum(self):
        input = '''
<STMTTRN>
 <TRNTYPE>DEP
 <DTPOSTED>20130306
 <TRNAMT>1000.00
 <FITID>2013030601009100
 <CHECKNUM>700
 <MEMO>DEPOSITO ONLINE
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEquals('700', transaction.checknum)
Beispiel #4
0
    def testThatParseTransactionWithCommaAsDecimalPointAndDotAsSeparator(self):
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-1.006,60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
'''
        txn = soup_maker(input)
        with self.assertRaises(OfxParserException):
            transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
Beispiel #5
0
    def testThatParseTransactionWithCommaAsDecimalPoint(self):
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-1006,60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEquals(Decimal('-1006.60'), transaction.amount)
Beispiel #6
0
    def testThatParseTransactionWithFieldCheckNum(self):
        input = '''
<STMTTRN>
 <TRNTYPE>DEP
 <DTPOSTED>20130306
 <TRNAMT>1000.00
 <FITID>2013030601009100
 <CHECKNUM>700
 <MEMO>DEPOSITO ONLINE
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEquals('700', transaction.checknum)
Beispiel #7
0
    def testThatParseTransactionWithCommaAsDecimalPointAndDotAsSeparator(self):
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-1.006,60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEqual(Decimal('-1006.60'), transaction.amount)
Beispiel #8
0
    def testThatParseTransactionWithDotAsDecimalPointAndCommaAsSeparator(self):
        " The exact opposite of the previous test.  Why are numbers so hard?"
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-1,006.60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEqual(Decimal('-1006.60'), transaction.amount)
Beispiel #9
0
    def testThatParseTransactionWithDotAsDecimalPointAndCommaAsSeparator(self):
        " The exact opposite of the previous test.  Why are numbers so hard?"
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-1,006.60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEqual(Decimal('-1006.60'), transaction.amount)
Beispiel #10
0
    def testThatParseTransactionWithSpaces(self):
        " Parse numbers with a space separating the thousands. "
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>+1 006,60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEqual(Decimal('1006.60'), transaction.amount)
    def testThatParseTransactionWithFieldRefNum(self):
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-6.60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
 <REFNUM>123.456
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEquals("123.456", transaction.refnum)
Beispiel #12
0
    def testThatParseTransactionReturnsATransaction(self):
        input = """
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-6.60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
"""
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find("stmttrn"))
        self.assertEquals("pos", transaction.type)
        self.assertEquals(datetime(2009, 4, 1, 12, 20, 17) - timedelta(hours=-5), transaction.date)
        self.assertEquals(Decimal("-6.60"), transaction.amount)
        self.assertEquals("0000123456782009040100001", transaction.id)
        self.assertEquals("MCDONALD'S #112", transaction.payee)
        self.assertEquals("POS MERCHANDISE;MCDONALD'S #112", transaction.memo)
Beispiel #13
0
    def testThatParseTransactionWithNullAmountIgnored(self):
        """A null transaction value is converted to 0.

        Some banks use a null transaction to include interest
        rate changes on statements.
        """
        input_template = '''
<STMTTRN>
 <TRNTYPE>DEP
 <DTPOSTED>20130306
 <TRNAMT>{amount}
 <FITID>2013030601009100
 <CHECKNUM>700
 <MEMO>DEPOSITO ONLINE
</STMTTRN>
'''
        for amount in ("null", "-null"):
            input = input_template.format(amount=amount)
            txn = soup_maker(input)

            transaction = OfxParser.parseTransaction(txn.find('stmttrn'))

            self.assertEqual(0, transaction.amount)
Beispiel #14
0
    def testThatParseTransactionWithNullAmountIgnored(self):
        """A null transaction value is converted to 0.

        Some banks use a null transaction to include interest
        rate changes on statements.
        """
        input_template = '''
<STMTTRN>
 <TRNTYPE>DEP
 <DTPOSTED>20130306
 <TRNAMT>{amount}
 <FITID>2013030601009100
 <CHECKNUM>700
 <MEMO>DEPOSITO ONLINE
</STMTTRN>
'''
        for amount in ("null", "-null"):
            input = input_template.format(amount=amount)
            txn = soup_maker(input)

            transaction = OfxParser.parseTransaction(txn.find('stmttrn'))

            self.assertEqual(0, transaction.amount)