예제 #1
0
 def setUp(self):
     self.object = BasicActivity("NameA",
                                 description="DescriptionA",
                                 dt_account="Bank",
                                 cr_account="Sales",
                                 amount=5000,
                                 start=datetime(2016, 2, 1),
                                 end=datetime(2017, 2, 1),
                                 interval=3)
예제 #2
0
    def setUp(self):
        self.gl_structure = GeneralLedgerStructure("NameA",
                                                   description="DescriptionA")
        self.sales_acc = self.gl_structure._acci_sales_.create_account(
            "sales_default", "0000")
        self.cos_acc = self.gl_structure._acci_cos_.create_account(
            "cos_default", "0000")
        self.reva_acc = self.gl_structure["Other Income"].create_account(
            "RevA", number="011")
        self.expa_acc = self.gl_structure["Expense"].create_account(
            "ExpenseA", number="011")

        self.object = Entity("EntityA",
                             gl_structure=self.gl_structure,
                             description="DescriptionA")
        # Set up the needed objects
        self.comp1 = self.object.create_component("ComponentA1",
                                                  description="ca1")
        basic_activity = BasicActivity("BasicActivityA",
                                       description="DescriptionA",
                                       dt_account="Bank",
                                       cr_account="Sales",
                                       amount=5000,
                                       start=datetime(2016, 2, 1),
                                       end=datetime(2017, 2, 1),
                                       interval=1)
        self.comp1.add_activity(basic_activity)

        self.clock = Clock("NameA", start_datetime=datetime(2016, 1, 1))
예제 #3
0
파일: basic_test.py 프로젝트: SShilo/auxi.0
 def setUp(self):
     self.object = BasicActivity("NameA",
                                 description="DescriptionA",
                                 dt_account="Bank",
                                 cr_account="Sales",
                                 amount=5000,
                                 start=datetime(2016, 2, 1),
                                 end=datetime(2017, 2, 1),
                                 interval=3)
예제 #4
0
 def test_add_activity_invalid_account_name(self):
     basic_activity2 = BasicActivity("BasicActivityB",
                                     description="DescriptionB",
                                     dt_account="invalid_acc_name_a",
                                     cr_account="invalid_acc_name_b",
                                     amount=5000,
                                     start=datetime(2016, 2, 1),
                                     end=datetime(2017, 2, 1),
                                     interval=3)
     self.assertRaises(ValueError, self.object["ComponentA2"].add_activity,
                       basic_activity2)
예제 #5
0
    def test_add_activity_valid_account_name(self):
        basic_activity2 = BasicActivity("BasicActivityB",
                                        description="DescriptionB",
                                        dt_account="Bank/Default",
                                        cr_account="Sales/Default",
                                        amount=5000,
                                        start=datetime(2016, 2, 1),
                                        end=datetime(2017, 2, 1),
                                        interval=3)
        self.object["ComponentA2"].add_activity(basic_activity2)

        self.assertEqual(len(self.object["ComponentA2"].activities), 1)
        self.assertEqual(basic_activity2.path,
                         "/ComponentA/ComponentA2/BasicActivityB")
예제 #6
0
 def setUp(self):
     self.gl_structure = GeneralLedgerStructure("NameA",
                                                description="DescriptionA")
     self.gl_structure["Sales"].create_account("Default", number="0000")
     self.gl = GeneralLedger("NameA",
                             self.gl_structure,
                             description="DescriptionA")
     self.object = Component("ComponentA",
                             self.gl,
                             description="DescriptionA")
     # Set up the needed objects
     self.object.create_component("ComponentA1", description="ca1")
     self.object.create_component("ComponentA2", description="ca2")
     self.basic_activity = BasicActivity("BasicActivityA",
                                         description="DescriptionA",
                                         dt_account="Bank/Default",
                                         cr_account="Sales/Default",
                                         amount=5000,
                                         start=datetime(2016, 2, 1),
                                         end=datetime(2017, 2, 1),
                                         interval=3)
     self.object["ComponentA1"].add_activity(self.basic_activity)
예제 #7
0
 def setUp(self):
     self.object = TimeBasedModel("TimeBasedModelA",
                                  description="TimeBasedModel A",
                                  start_datetime=datetime(2016, 2, 1),
                                  period_duration=TimePeriod.day,
                                  period_count=200)
     # Set up the needed objects
     self.gl_structure = GeneralLedgerStructure("NameA",
                                                description="DescriptionA")
     entity = self.object.create_entity("EntityA",
                                        self.gl_structure,
                                        description="DescriptionA")
     # Set up the needed objects
     comp1 = entity.create_component("ComponentA1", description="ca1")
     basic_activity = BasicActivity("BasicActivityA",
                                    description="DescriptionA",
                                    dt_account="Bank",
                                    cr_account="Sales",
                                    amount=5000,
                                    start=datetime(2016, 2, 1),
                                    end=datetime(2016, 2, 14),
                                    interval=1)
     comp1.activities.append(basic_activity)
예제 #8
0
                       period_duration=TimePeriod.month, period_count=61)

courier_company = model.create_entity("CourierZA", gl_structure=gl_structure)
ops = courier_company.create_component("Operations")
hr = courier_company.create_component("HR")

# Create activities
loan = BasicLoanActivity("Loan",
    bank_account="Bank/Default", loan_account="Long Term Borrowing/Loan",
    interest_account="Expense/Interest Expense",
    amount=200000, interest_rate=0.15, start=start_datetime, duration=36,
    interval=1)
ops.add_activity(loan)

purchase_vehicle = BasicActivity("Purchase Vehicle",
    dt_account="Fixed Assets/Vehicle Asset", cr_account="Bank/Default",
    amount=177000, start=start_datetime, end=start_datetime + relativedelta(months=1),
    interval=1)
ops.add_activity(purchase_vehicle)

make_delivery_sale = BasicActivity("Make Delivery",
    dt_account="Bank/Default", cr_account="Sales/Sales Delivery",
    amount=15000, start=start_datetime, end=end_datetime, interval=1)
ops.add_activity(make_delivery_sale)

pay_delivery_costs = BasicActivity("Pay for Fuel",
    dt_account="Cost of Sales/Fuel", cr_account="Bank/Default",
    amount=1000, start=start_datetime, end=end_datetime, interval=1)
ops.add_activity(pay_delivery_costs)

pay_wages = BasicActivity("Pay Wages", dt_account="Expense/Wages", cr_account="Bank/Default",
    amount=10000, start=start_datetime, end=end_datetime, interval=1)
예제 #9
0
class BasicActivityUnitTester(unittest.TestCase):
    """
    Tester for the auxi.modelling.business.basic.BasicActivity class.
    """
    def setUp(self):
        self.object = BasicActivity("NameA",
                                    description="DescriptionA",
                                    dt_account="Bank",
                                    cr_account="Sales",
                                    amount=5000,
                                    start=datetime(2016, 2, 1),
                                    end=datetime(2017, 2, 1),
                                    interval=3)

    def test_constructor(self):
        self.assertEqual(self.object.name, "NameA")
        self.assertEqual(self.object.description, "DescriptionA")
        self.assertEqual(self.object.start_datetime, datetime(2016, 2, 1))
        self.assertEqual(self.object.end_datetime, datetime(2017, 2, 1))
        self.assertEqual(self.object.interval, 3)
        self.assertEqual(self.object.amount, 5000)
        self.assertEqual(self.object.dt_account, "Bank")
        self.assertEqual(self.object.cr_account, "Sales")

    def test__meet_execution_criteria(self):
        """
        Test that the activity only meets the execution criteria when
        it's amount is greater than 0.
        """

        clock = Clock("NameA", start_datetime=datetime(2016, 1, 1))
        self.object.prepare_to_run(clock, 13)
        self.assertEqual(self.object._meet_execution_criteria(5), True)
        self.object.amount = 0
        self.assertEqual(self.object._meet_execution_criteria(5), False)

    def test_run(self):
        """
        Test that the activity run method creates a transaction with an amount
        of 5000.
        """

        structure = GeneralLedgerStructure("NameA", description="DescriptionA")
        gl = GeneralLedger("NameA", structure, description="DescriptionA")
        clock = Clock("NameA", start_datetime=datetime(2016, 1, 1))
        clock.tick()
        clock.tick()
        self.object.prepare_to_run(clock, 20)
        self.object.run(clock, gl)
        self.assertEqual(len(gl.transactions), 1)
        self.assertEqual(gl.transactions[0].amount, 5000)

    def test_get_referenced_accounts(self):
        """
        Test that the activity run method get_referenced_accounts accounts
        matches the debit and credit accounts self.object was initialised with.
        """

        result = self.object.get_referenced_accounts()
        self.assertEqual(self.object.dt_account, result[0])
        self.assertEqual(self.object.cr_account, result[1])
예제 #10
0
파일: basic_test.py 프로젝트: SShilo/auxi.0
class BasicActivityUnitTester(unittest.TestCase):
    """
    Tester for the auxi.modelling.business.basic.BasicActivity class.
    """

    def setUp(self):
        self.object = BasicActivity("NameA",
                                    description="DescriptionA",
                                    dt_account="Bank",
                                    cr_account="Sales",
                                    amount=5000,
                                    start=datetime(2016, 2, 1),
                                    end=datetime(2017, 2, 1),
                                    interval=3)

    def test_constructor(self):
        self.assertEqual(self.object.name, "NameA")
        self.assertEqual(self.object.description, "DescriptionA")
        self.assertEqual(self.object.start_datetime, datetime(2016, 2, 1))
        self.assertEqual(self.object.end_datetime, datetime(2017, 2, 1))
        self.assertEqual(self.object.interval, 3)
        self.assertEqual(self.object.amount, 5000)
        self.assertEqual(self.object.dt_account, "Bank")
        self.assertEqual(self.object.cr_account, "Sales")

    def test__meet_exection_criteria(self):
        """
        Test that the activity only meets the execution criteria when
        it's amount is greater than 0.
        """

        clock = Clock("NameA", start_datetime=datetime(2016, 1, 1))
        self.object.prepare_to_run(clock, 13)
        self.assertEqual(self.object._meet_execution_criteria(5), True)
        self.object.amount = 0
        self.assertEqual(self.object._meet_execution_criteria(5), False)

    def test_run(self):
        """
        Test that the activity run method creates a transaction with an amount
        of 5000.
        """

        structure = GeneralLedgerStructure("NameA", description="DescriptionA")
        gl = GeneralLedger("NameA", structure, description="DescriptionA")
        clock = Clock("NameA", start_datetime=datetime(2016, 1, 1))
        clock.tick()
        clock.tick()
        self.object.prepare_to_run(clock, 20)
        self.object.run(clock, gl)
        self.assertEqual(len(gl.transactions), 1)
        self.assertEqual(gl.transactions[0].amount, 5000)

    def test_get_referenced_accounts(self):
        """
        Test that the activity run method get_referenced_accounts accounts
        matches the debit and credit accounts self.object was initialised with.
        """

        result = self.object.get_referenced_accounts()
        self.assertEqual(self.object.dt_account, result[0])
        self.assertEqual(self.object.cr_account, result[1])