def setUp(self):
        self.ts = TransactionStore()

        origsd1 = date.today()
        origsd2 = date.today()+timedelta(days=2)
        self.t1 = Transaction(
            start=origsd1,
            description="Once, today",
            amount=1.00,
            frequency=Transaction.ONCE)
        self.t2 = Transaction(
            start=origsd2,
            description="Once, in two days",
            amount=1.01,
            frequency=Transaction.ONCE)
        self.t3 = Transaction(
            start=origsd1,
            description="Weekly",
            amount=1.02,
            frequency=Transaction.WEEKLY,
            skip=set([date.today()+timedelta(days=7)]),
            scheduled=True,
            cleared=True)
        self.t4 = Transaction(
            start=origsd2,
            description="Monthly",
            amount=1.03,
            frequency=Transaction.MONTHLY)

        self.ts.addTransactions(self.t1, self.t2, self.t3, self.t4)
 def loadTransactions(self, file=None):
     self.ts = TransactionStore()
     if file is not None:
         self.ts.loadTransactions(file)
     self.transactionManagement.ts = self.ts
     self.cashFlowDisplay.ts = self.ts
     self.updateChildren()
    def test_file_operations(self):
        self.assertEqual(len(self.ts.store), 2)

        t1 = next((t for t in self.ts.store if t.amount == 1.00),
                  None)
        self.assertIsNotNone(t1)

        t2 = next((t for t in self.ts.store if t.amount == 1.02),
                  None)
        self.assertIsNotNone(t2)

        self.ts.saveTransactions(self.file)

        ts = TransactionStore()
        ts.loadTransactions(self.file)

        self.assertEqual(len(ts.store), 2)

        t1_l = next((t for t in ts.store if t.amount == 1.00),
                    None)
        self.assertIsNotNone(t1_l)
        self.assertTransactionsEqual(t1_l, t1)

        t2_l = next((t for t in ts.store if t.amount == 1.02),
                    None)
        self.assertIsNotNone(t2_l)
        self.assertTransactionsEqual(t2_l, t2)
    def setUp(self):
        self.ts = TransactionStore()

        t1 = Transaction(
            start=date.today(),
            description="Once",
            amount=1.00,
            frequency=Transaction.ONCE)

        self.ts.addTransactions(t1)
    def test_add_multiple_transactions(self):
        d = date.today()
        ts = TransactionStore()
        t1 = Transaction(
            start=d,
            description="Once, today",
            amount=1.00,
            frequency=Transaction.ONCE)
        t2 = Transaction(
            start=d+timedelta(days=2),
            description="Once, in two days",
            amount=1.01,
            frequency=Transaction.ONCE)
        t3 = Transaction(
            start=d,
            end=d+timedelta(days=56),
            description="Weekly",
            amount=1.02,
            frequency=Transaction.WEEKLY,
            skip=set([d+timedelta(days=7)]),
            scheduled=True,
            cleared=True)

        self.assertEqual(len(ts.store), 0)

        ts.addTransactions(t1, t2, t3)

        t = next((t for t in ts.store if t.amount == 1.00),
                 None)
        self.assertIsNotNone(t)
        self.assertEqual(t.start, d)
        self.assertEqual(t.description, "Once, today")
        self.assertEqual(t.amount, 1.00)
        self.assertEqual(t.frequency, Transaction.ONCE)

        t = next((t for t in ts.store if t.amount == 1.01),
                 None)
        self.assertIsNotNone(t)
        self.assertEqual(t.start, d+timedelta(days=2))
        self.assertEqual(t.description, "Once, in two days")
        self.assertEqual(t.amount, 1.01)
        self.assertEqual(t.frequency, Transaction.ONCE)

        t = next((t for t in ts.store if t.amount == 1.02),
                 None)
        self.assertIsNotNone(t)
        self.assertEqual(t.start, d)
        self.assertEqual(t.description, "Weekly")
        self.assertEqual(t.amount, 1.02)
        self.assertEqual(t.frequency, Transaction.WEEKLY)
    def setUp(self):
        self.ts = TransactionStore()

        t1 = Transaction(
            start=date.today(),
            description="Once, today",
            amount=1.00,
            frequency=Transaction.ONCE)
        t2 = Transaction(
            start=date.today()+timedelta(days=2),
            description="Once, in two days",
            amount=1.01,
            frequency=Transaction.ONCE)

        self.ts.addTransactions(t1, t2)
 def test_contructor_string_balance(self):
     sd = date.today()
     sb = '100.00'
     ts = TransactionStore()
     cf = CashFlow(sd, sb, ts)
     self.assertIsInstance(cf.start_date, date)
     self.assertEqual(cf.start_date, sd)
     self.assertIsInstance(cf.start_balance, Money)
     self.assertEqual(cf.start_balance, Money(sb))
     self.assertIsInstance(cf.transaction_store, TransactionStore)
     self.assertEqual(len(cf.transaction_store.getTransactions()), 0)
     self.assertIsInstance(cf.current_date, date)
     self.assertEqual(cf.current_date, sd)
     self.assertIsInstance(cf.current_balance, Money)
     self.assertEqual(cf.current_balance, Money(sb))
    def setUp(self):
        self.ts = TransactionStore()

        sd = date.today()
        skipd = date.today() + timedelta(days=14)
        t1 = Transaction(
            start=sd,
            description="Weekly",
            amount=1.00,
            frequency=Transaction.WEEKLY,
            skip=set([skipd]))
        t2 = Transaction(
            start=sd+timedelta(days=2),
            description="Monthly",
            amount=1.01,
            frequency=Transaction.MONTHLY)

        self.ts.addTransactions(t1, t2)
 def test_add_single_transaction(self):
     d = date.today()
     ts = TransactionStore()
     self.assertEqual(len(ts.store), 0)
     t = Transaction(
         start=d,
         description="Once, today",
         amount=1.00,
         frequency=Transaction.ONCE)
     ts.addTransactions(t)
     self.assertEqual(len(ts.store), 1)
     t = next((t for t in ts.store if t.amount == 1.00),
              None)
     self.assertIsNotNone(t)
     self.assertEqual(t.start, d)
     self.assertEqual(t.description, "Once, today")
     self.assertEqual(t.amount, 1.00)
     self.assertEqual(t.frequency, Transaction.ONCE)
 def __init__(self):
     super().__init__(parent=None, title='Cash Flow Calculator')
     self.settingsFile = os.getcwd() + '/data/' + '.cash_flow_settings.yml'
     self.settings = AppSettings()
     self.ts = TransactionStore()
     self.defaultDir = os.getcwd() + '/data'
     self.notebook = wx.Notebook(self)
     self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
                        self.handleNotebookChange)
     self.transactionManagement = TransactionManagement(
         self.notebook, self.ts, self.settings)
     self.notebook.AddPage(self.transactionManagement,
                           "Transaction Management")
     self.cashFlowDisplay = CashFlowDisplay(self.notebook, self.ts,
                                            self.settings)
     self.notebook.AddPage(self.cashFlowDisplay, "Cash Flow")
     self.SetInitialSize(wx.Size(650, 650))
     self.create_menu()
     self.loadSettings()
     self.loadTransactions(self.settings.dataFile)
     self.Show()
    def setUp(self):
        self.file = f'./test-{time.time()}'

        t1 = Transaction(
            start=date.today(),
            description="Once, today",
            amount=1.00,
            frequency=Transaction.ONCE)
        t2 = Transaction(
            start=date.today(),
            original_start=date.today()-timedelta(days=1),
            end=date.today()+timedelta(days=56),
            description="Weekly",
            amount=1.02,
            frequency=Transaction.WEEKLY,
            skip=set([date.today()+timedelta(days=7)]),
            scheduled=True,
            cleared=True)

        self.ts = TransactionStore()
        self.ts.store.append(t1)
        self.ts.store.append(t2)
    def setUp(self):
        self.ts = TransactionStore()

        t1 = Transaction(
            start=date.today(),
            description="Once",
            amount=1.00,
            frequency=Transaction.ONCE)
        t2 = Transaction(
            start=date.today()+timedelta(days=2),
            description="Once, in two days",
            amount=1.01,
            frequency=Transaction.ONCE)
        t3 = Transaction(
            start=date.today(),
            end=date.today()+timedelta(days=56),
            description="Weekly",
            amount=1.02,
            frequency=Transaction.WEEKLY,
            skip=set([date.today()+timedelta(days=7)]),
            scheduled=True,
            cleared=True)

        self.ts.addTransactions(t1, t2, t3)
 def setUp(self):
     sd = date.today()
     sd2 = date.today()+timedelta(days=2)
     self.o1 = Transaction(
         start=sd,
         description="Once 1",
         amount=1.00,
         frequency=Transaction.ONCE)
     self.o2 = Transaction(
         start=sd2,
         description="Once 2",
         amount=1.01,
         frequency=Transaction.ONCE)
     self.w1 = Transaction(
         start=sd,
         description="Weekly 1",
         amount=1.03,
         frequency=Transaction.WEEKLY)
     self.w2 = Transaction(
         start=sd2,
         description="Weekly 2",
         amount=1.04,
         frequency=Transaction.WEEKLY)
     self.bw1 = Transaction(
         start=sd,
         description="BiWeekly 1",
         amount=1.05,
         frequency=Transaction.BIWEEKLY)
     self.bw2 = Transaction(
         start=sd2,
         description="BiWeekly 2",
         amount=1.06,
         frequency=Transaction.BIWEEKLY)
     self.m1 = Transaction(
         start=sd,
         description="Monthly 1",
         amount=1.07,
         frequency=Transaction.MONTHLY)
     self.m2 = Transaction(
         start=sd2,
         description="Monthly 2",
         amount=1.08,
         frequency=Transaction.MONTHLY)
     self.q1 = Transaction(
         start=sd,
         description="Quarterly 1",
         amount=1.09,
         frequency=Transaction.QUARTERLY)
     self.q2 = Transaction(
         start=sd2,
         description="Quarterly 2",
         amount=1.10,
         frequency=Transaction.QUARTERLY)
     self.a1 = Transaction(
         start=sd,
         description="Annually 1",
         amount=1.11,
         frequency=Transaction.ANNUALLY)
     self.a2 = Transaction(
         start=sd2,
         description="Annually 2",
         amount=1.12,
         frequency=Transaction.ANNUALLY)
     self.ts = TransactionStore()
     self.ts.addTransactions(self.o1, self.o2, self.w1, self.w2,
                             self.bw1, self.bw2, self.m1, self.m2,
                             self.q1, self.q2, self.a1, self.a2)
     random.shuffle(self.ts.store)
 def test_constructor(self):
     ts = TransactionStore()
     self.assertIsInstance(ts.store, list)
예제 #15
0
 def setUp(self):
     sd = date.today()
     sb = 100.00
     ts = TransactionStore()
     self.cf = CashFlow(sd, sb, ts)