コード例 #1
0
def ImportAccounts(model):
    """For each account in Mint, create one in wxBanker with all known transactions."""
    mintSettings = CsvImporterProfileManager().getProfile("mint")
    importer = CsvImporter()
    for mintId, item in Mint.GetAccounts().items():
        accountName, balance = item['name'], item['balance']
        # Create an account, grab the transactions, and add them.
        try:
            account = model.CreateAccount(accountName)
        except bankexceptions.AccountAlreadyExistsException:
            #account = model.CreateAccount("%s (%s)" % (accountName, mintId))
            print "Account '%s' already exists...skipping." % accountName
            continue
        csv = Mint.GetAccountTransactionsCSV(mintId)
        container = importer.getTransactionsFromCSV(csv, mintSettings)
        transactions = container.Transactions
        account.AddTransactions(transactions)

        # Now we have to add an initial transaction for the initial balance.
        if transactions:
            firstTransaction = sorted(transactions)[0]
            initialDate = firstTransaction.Date

            initialBalance = balance - account.Balance
            account.AddTransaction(initialBalance, "Initial Balance",
                                   initialDate)

        print "Imported account %s with %i transactions" % (accountName,
                                                            len(transactions))
コード例 #2
0
ファイル: mintwrapper.py プロジェクト: liu-chong/wxbanker
def ImportAccounts(model):
    """For each account in Mint, create one in wxBanker with all known transactions."""
    mintSettings = CsvImporterProfileManager().getProfile("mint")
    importer = CsvImporter()
    for mintId, item in Mint.GetAccounts().items():
        accountName, balance = item['name'], item['balance']
        # Create an account, grab the transactions, and add them.
        try:
            account = model.CreateAccount(accountName)
        except bankexceptions.AccountAlreadyExistsException:
            #account = model.CreateAccount("%s (%s)" % (accountName, mintId))
            print "Account '%s' already exists...skipping." % accountName
            continue
        csv = Mint.GetAccountTransactionsCSV(mintId)
        container = importer.getTransactionsFromCSV(csv, mintSettings)
        transactions = container.Transactions
        account.AddTransactions(transactions)
        
        # Now we have to add an initial transaction for the initial balance.
        if transactions:
            firstTransaction = sorted(transactions)[0]
            initialDate = firstTransaction.Date

            initialBalance = balance - account.Balance
            account.AddTransaction(initialBalance, "Initial Balance", initialDate)
        
        print "Imported account %s with %i transactions" % (accountName, len(transactions))
コード例 #3
0
ファイル: csvimportframe.py プロジェクト: assem-ch/wxbanker
    def runPreview(self):
        importer = CsvImporter()
        settings = self.getSettingsFromControls()

        file = self.filePickerCtrl.Path

        try:
            self.transactionContainer = importer.getTransactionsFromFile(file, settings)
            self.transactionCtrl.setAccount(self.transactionContainer)
        except UnicodeDecodeError,e:
            self.showErrorDialog(_("The file encoding does not seem to be '%s'.") % settings['encoding'], e)
コード例 #4
0
ファイル: csvimportframe.py プロジェクト: Karagul/wxbanker
    def runPreview(self):
        importer = CsvImporter()
        settings = self.getSettingsFromControls()

        file = self.filePickerCtrl.Path

        try:
            self.transactionContainer = importer.getTransactionsFromFile(
                file, settings)
            self.transactionCtrl.setAccount(self.transactionContainer)
        except UnicodeDecodeError, e:
            self.showErrorDialog(
                _("The file encoding does not seem to be '%s'.") %
                settings['encoding'], e)
コード例 #5
0
ファイル: csvimportertests.py プロジェクト: Karagul/wxbanker
class CsvImporterTest(unittest.TestCase):
    def setUp(self):
        self.importer = CsvImporter()

    def getTransactions(self, csvtype):
        path = testbase.fixturefile("%s.csv" % csvtype)
        profile = CsvImporterProfileManager().getProfile(csvtype)
        container = CsvImporter().getTransactionsFromFile(path, profile)
        return container.Transactions

    def testParseAmountWithSpaceAsThousandsSep(self):
        # Regression test for LP: #370571
        decimalSeparator = ','
        self.assertEquals(
            self.importer.parseAmount('-1 000,00', decimalSeparator), -1000.0)
        self.assertEquals(
            self.importer.parseAmount('$ -1 000,00 ', decimalSeparator),
            -1000.0)

    def testCanImportMintData(self):
        transactions = self.getTransactions("mint")
        transactions.sort()
        self.assertEqual(len(transactions), 3)
        self.assertAlmostEqual(sum(t.Amount for t in transactions), 29.46)
        self.assertEqual(transactions[-1].Date, datetime.date(2009, 7, 21))
        self.assertEqual(transactions[-1].Description, "Teavana San Mateo")

    def testCanImportSparkasseData(self):
        transactions = self.getTransactions("Sparkasse")
        self.assertEqual(len(transactions), 5)

        tran = transactions[1]
        self.assertEqual(tran.Date, datetime.date(2009, 7, 17))
        self.assertEqual(tran.Description, "PHONE CORP, ### , LASTSCHRIFT")
        self.assertEqual(tran.Amount, -31.24)

    def testCanImportComdirectData(self):
        transactions = self.getTransactions("comdirect")
        self.assertEqual(len(transactions), 5)

        tran = transactions[2]
        self.assertEqual(tran.Date, datetime.date(2010, 3, 8))
        self.assertEqual(
            tran.Description,
            "Auftraggeber: XYZ SAGT DANKE Buchungstext: XYZ SAGT DANKE EC 123456789 06.03 14.53 CE0 Ref. ABCDFER213456789/1480  (Lastschrift Einzug)"
        )
        self.assertEqual(tran.Amount, -32.27)
コード例 #6
0
ファイル: csvimportertests.py プロジェクト: assem-ch/wxbanker
class CsvImporterTest(unittest.TestCase):
    def setUp(self):
        self.importer = CsvImporter()
        
    def getTransactions(self, csvtype):
        path = testbase.fixturefile("%s.csv"%csvtype)
        profile = CsvImporterProfileManager().getProfile(csvtype)
        container = CsvImporter().getTransactionsFromFile(path, profile)
        return container.Transactions

    def testParseAmountWithSpaceAsThousandsSep(self):
        # Regression test for LP: #370571
        decimalSeparator = ','
        self.assertEquals(self.importer.parseAmount('-1 000,00', decimalSeparator), -1000.0)
        self.assertEquals(self.importer.parseAmount('$ -1 000,00 ', decimalSeparator), -1000.0)
        
    def testCanImportMintData(self):
        transactions = self.getTransactions("mint")
        transactions.sort()
        self.assertEqual(len(transactions), 3)
        self.assertAlmostEqual(sum(t.Amount for t in transactions), 29.46)
        self.assertEqual(transactions[-1].Date, datetime.date(2009, 7, 21))
        self.assertEqual(transactions[-1].Description, "Teavana San Mateo")
        
    def testCanImportSparkasseData(self):
        transactions = self.getTransactions("Sparkasse")
        self.assertEqual(len(transactions), 5)
        
        tran = transactions[1]
        self.assertEqual(tran.Date, datetime.date(2009, 7, 17))
        self.assertEqual(tran.Description, "PHONE CORP, ### , LASTSCHRIFT")
        self.assertEqual(tran.Amount, -31.24)
       
    def testCanImportComdirectData(self):
        transactions = self.getTransactions("comdirect")
        self.assertEqual(len(transactions), 5)
        
        tran = transactions[2]
        self.assertEqual(tran.Date, datetime.date(2010, 3, 8))
        self.assertEqual(tran.Description, "Auftraggeber: XYZ SAGT DANKE Buchungstext: XYZ SAGT DANKE EC 123456789 06.03 14.53 CE0 Ref. ABCDFER213456789/1480  (Lastschrift Einzug)")
        self.assertEqual(tran.Amount, -32.27)   
コード例 #7
0
ファイル: csvimportertests.py プロジェクト: Karagul/wxbanker
 def getTransactions(self, csvtype):
     path = testbase.fixturefile("%s.csv" % csvtype)
     profile = CsvImporterProfileManager().getProfile(csvtype)
     container = CsvImporter().getTransactionsFromFile(path, profile)
     return container.Transactions
コード例 #8
0
ファイル: csvimportertests.py プロジェクト: Karagul/wxbanker
 def setUp(self):
     self.importer = CsvImporter()
コード例 #9
0
ファイル: csvimportertests.py プロジェクト: assem-ch/wxbanker
 def setUp(self):
     self.importer = CsvImporter()