def test_creates_transactions(self): account = self.factory.make_one(Account) transactions = self.factory.prepare(5, Transaction, account=account) ofx = transactions_to_ofx_data(transactions, account) import_ofx(ofx, stdout=self.stdout) self.assertEqual(5, Transaction.objects.count())
def handle(self, *args, **kwargs): if len(args) != 1: raise CommandError("The ofx file is required.") filename = args[0] if not os.path.exists(filename): raise CommandError("The file {0} does not exist.".format(filename)) ofx = OfxParser.parse(file(filename)) import_ofx(ofx, self.stdout)
def test_re_import(self): account = self.factory.make_one(Account, account_id="123C") kwargs = dict( date=datetime.datetime(2013, 1, 28), amount=Decimal('-21.95'), memo="Whatever", tid="abc123", account=account) transaction = self.factory.make_one(Transaction, **kwargs) ofx = transactions_to_ofx_data([transaction], account) import_ofx(ofx, stdout=self.stdout) self.assertEqual(1, Transaction.objects.count())
def handle(self, *args, **kwargs): if len(args) != 1: raise CommandError("The directory containing the ofx files is required.") directory = args[0] if not os.path.exists(directory): raise CommandError("The directory {0} does not exist.".format( directory)) for filename in os.listdir(directory): if filename.endswith(".ofx") or filename.endswith("OFX"): filepath = os.path.join(directory, filename) ofx = OfxParser.parse(file(filepath)) self.stdout.write("Importing {}...".format(filename)) import_ofx(ofx, self.stdout)
def test_transaction_values(self): account = self.factory.make_one(Account) transaction = self.factory.prepare_one( Transaction, amount=Decimal('-1234.56'), date=datetime.datetime(2013, 2, 8), memo="ALDI sagt Danke") ofx = transactions_to_ofx_data([transaction], account) import_ofx(ofx, stdout=self.stdout) self.assertEqual(1, Transaction.objects.count()) transaction = Transaction.objects.get() self.assertEqual(Decimal('-1234.56'), transaction.amount) self.assertEqual(datetime.date(2013, 2, 8), transaction.date) self.assertEqual("ALDI sagt Danke", transaction.memo)