示例#1
0
 class CSVImporter(Base):
     date = Date(0)
     narration = Column(1)
     amount = Amount(2)
     balance = Amount(3)
     currency = Column(4)
     names = False
示例#2
0
        class CSVImporter(Base):
            date = Date(0)
            narration = Column(1)
            amount = Amount(2)
            meta = Column(3)
            data = Amount(4)
            names = False

            def metadata(self, filepath, lineno, row):
                meta = super().metadata(filepath, lineno, row)
                for field in 'meta', 'data':
                    meta[field] = getattr(row, field)
                return meta
示例#3
0
 class CSVImporter(Base):
     date = Date(0)
     narration = Column(1)
     amount = Amount(2)
     link = Column(3)
     tag = Column(4)
     names = False
示例#4
0
        class CSVImporter(Base):
            date = Date(0)
            narration = Column(1)
            amount = Amount(2)
            category = Column(3)
            names = False

            def finalize(self, txn, row):
                posting = data.Posting(
                    'Expenses:' + row.category,
                    # This could be None in a real importer. However,
                    # the trsting framework accepts only complete
                    # transactions, thus we do the booking manually.
                    -txn.postings[0].units,
                    None,
                    None,
                    None,
                    None)
                txn.postings.append(posting)
                return txn
示例#5
0
 def test_parse_decimal(self):
     column = Amount(0)
     func = column.getter(None)
     value = func(('1.0', ))
     self.assertIsInstance(value, decimal.Decimal)
     self.assertEqual(value, decimal.Decimal('1.0'))
示例#6
0
 class CSVImporter(Base):
     date = Date(0)
     narration = Column(1)
     account = Column(2)
     amount = Amount(3)
     names = False
示例#7
0
 def test_parse_subs_currency(self):
     column = Amount(0, subs={'\\$(.*)': '\\1', ',': ''})
     func = column.getter(None)
     value = func(('$1,000.00', ))
     self.assertIsInstance(value, decimal.Decimal)
     self.assertEqual(value, decimal.Decimal('1000.00'))
示例#8
0
 def test_parse_subs_two(self):
     column = Amount(0, subs={'\\.': '', ',': '.'})
     func = column.getter(None)
     value = func(('1.000,00', ))
     self.assertIsInstance(value, decimal.Decimal)
     self.assertEqual(value, decimal.Decimal('1000.00'))