Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testThatParseTransactionWithCommaAsDecimalPoint(self):
input = '''
POS
20090401122017.000[-5:EST]
-1006,60
0000123456782009040100001
MCDONALD'S #112
POS MERCHANDISE;MCDONALD'S #112
'''
txn = soup_maker(input)
transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
self.assertEqual(Decimal('-1006.60'), transaction.amount)
"""
input_template = '''
DEP
20130306
{amount}
2013030601009100
700
DEPOSITO ONLINE
'''
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)
def testThatParseTransactionReturnsATransaction(self):
input = '''
POS
20090131
20090401122017.000[-5:EST]
-6.60
0000123456782009040100001
MCDONALD'S #112
POS MERCHANDISE;MCDONALD'S #112
'''
txn = soup_maker(input)
transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
self.assertEqual('pos', transaction.type)
self.assertEqual(datetime(
2009, 4, 1, 12, 20, 17) - timedelta(hours=-5), transaction.date)
self.assertEqual(datetime(2009, 1, 31, 0, 0), transaction.user_date)
self.assertEqual(Decimal('-6.60'), transaction.amount)
self.assertEqual('0000123456782009040100001', transaction.id)
self.assertEqual("MCDONALD'S #112", transaction.payee)
self.assertEqual("POS MERCHANDISE;MCDONALD'S #112", transaction.memo)
def testThatParseTransactionWithFieldCheckNum(self):
input = '''
DEP
20130306
1000.00
2013030601009100
700
DEPOSITO ONLINE
'''
txn = soup_maker(input)
transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
self.assertEqual('700', transaction.checknum)
def testThatParseTransactionWithCommaAsDecimalPointAndDotAsSeparator(self):
input = '''
POS
20090401122017.000[-5:EST]
-1.006,60
0000123456782009040100001
MCDONALD'S #112
POS MERCHANDISE;MCDONALD'S #112
'''
txn = soup_maker(input)
transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
self.assertEqual(Decimal('-1006.60'), transaction.amount)
def testThatParseTransactionWithDotAsDecimalPointAndCommaAsSeparator(self):
" The exact opposite of the previous test. Why are numbers so hard?"
input = '''
POS
20090401122017.000[-5:EST]
-1,006.60
0000123456782009040100001
MCDONALD'S #112
POS MERCHANDISE;MCDONALD'S #112
'''
txn = soup_maker(input)
transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
self.assertEqual(Decimal('-1006.60'), transaction.amount)