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))
def setUp(self): self.structure = GeneralLedgerStructure("NameA", description="DescriptionA") self.structure["Retained Income"].create_account( "TestA", description="TestA_Desc", number="010") self.object = GeneralLedger("NameA", self.structure, description="DescriptionA")
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_run(self): """ Test that the component runs its activities. """ # Set up the general ledger so that an activity can create a # transaction. structure = GeneralLedgerStructure("NameA", description="DescriptionA") gl = GeneralLedger("NameA", structure, description="DescriptionA") # Prepare the component for a run. Tick the clock to the correct place # for the activity to create a transaction. 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) # If the activity has been run, then a transaction should have # been generated. self.assertEqual(len(gl.transactions), 1)
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)
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)
def setUp(self): self.gl_structure = GeneralLedgerStructure( "GL Structure", description="General Ledger Structure") self.gl_structure["Account Payable"].create_account( "Capital Loan", "0000") self.gl_structure["Expense"].create_account("Interest Expense", "0000") self.gl = GeneralLedger("GL", self.gl_structure, description="General Ledger") self.clock = Clock("NameA", start_datetime=datetime(2016, 2, 1)) self.object = BasicLoanActivity( "Capital Loan", bank_account="Bank/Default", loan_account="Account Payable/Capital Loan", interest_account="Expense/Interest Expense", amount=180000, interest_rate=0.15, start=datetime(2016, 2, 1), duration=36, interval=1, description="Loan for Capital")
def setUp(self): self.object = GeneralLedgerStructure("NameA", description="DescriptionA")
class GeneralLedgerStructureUnitTester(unittest.TestCase): """ Tester for the auxi.modelling.financial.des.generalledgerstructure class. """ def setUp(self): self.object = GeneralLedgerStructure("NameA", description="DescriptionA") def test_constructor(self): """ Test the the variables has been initialised and that the default accounts has been created. """ self.assertEqual(self.object.name, "NameA") self.assertEqual(self.object.description, "DescriptionA") self.assertNotEqual(self.object["Bank"], None) self.assertEqual( self.object['Unallocated Income Statement'].account_type, AccountType.revenue) self.assertEqual(self.object["Sales"].number, "I10") self.assertEqual(self.object["Sales"].account_type, AccountType.revenue) self.assertEqual(self.object["Cost of Sales"].number, "I15") self.assertEqual(self.object["Cost of Sales"].account_type, AccountType.expense) self.assertEqual(self.object["Other Income"].number, "I20") self.assertEqual(self.object["Other Income"].account_type, AccountType.revenue) self.assertEqual(self.object["Expense"].number, "I25") self.assertEqual(self.object["Expense"].account_type, AccountType.expense) self.assertEqual(self.object["Tax"].number, "I30") self.assertEqual(self.object["Tax"].account_type, AccountType.expense) self.assertEqual(self.object["Dividends"].number, "I35") self.assertEqual(self.object["Dividends"].account_type, AccountType.expense) self.assertEqual(self.object["Share Capital"].number, "B10") self.assertEqual(self.object["Share Capital"].account_type, AccountType.asset) self.assertEqual(self.object["Retained Income"].number, "B15") self.assertEqual(self.object["Retained Income"].account_type, AccountType.equity) self.assertEqual(self.object["Shareholders Loan"].number, "B20") self.assertEqual(self.object["Shareholders Loan"].account_type, AccountType.liability) self.assertEqual(self.object["Long Term Borrowing"].number, "B25") self.assertEqual(self.object["Long Term Borrowing"].account_type, AccountType.liability) self.assertEqual(self.object["Other Long Term Liabilities"].number, "B30") self.assertEqual( self.object["Other Long Term Liabilities"].account_type, AccountType.liability) self.assertEqual(self.object["Fixed Assets"].number, "B35") self.assertEqual(self.object["Fixed Assets"].account_type, AccountType.asset) self.assertEqual(self.object["Investments"].number, "B40") self.assertEqual(self.object["Investments"].account_type, AccountType.asset) self.assertEqual(self.object["Other Fixed Assets"].number, "B45") self.assertEqual(self.object["Other Fixed Assets"].account_type, AccountType.asset) self.assertEqual(self.object["Inventory"].number, "B50") self.assertEqual(self.object["Inventory"].account_type, AccountType.asset) self.assertEqual(self.object["Accounts Receivable"].number, "B55") self.assertEqual(self.object["Accounts Receivable"].account_type, AccountType.asset) self.assertEqual(self.object["Bank"].number, "B60") self.assertEqual(self.object["Bank"].account_type, AccountType.asset) self.assertEqual(self.object["Bank"]["Default"].number, "0000") self.assertEqual(self.object["Bank"]["Default"].account_type, AccountType.asset) self.assertEqual(self.object["Other Current Assets"].number, "B65") self.assertEqual(self.object["Other Current Assets"].account_type, AccountType.asset) self.assertEqual(self.object["Account Payable"].number, "B70") self.assertEqual(self.object["Account Payable"].account_type, AccountType.liability) self.assertEqual(self.object["Taxation"].number, "B75") self.assertEqual(self.object["Taxation"].account_type, AccountType.liability) self.assertEqual(self.object["Other Current Liabilities"].number, "B80") self.assertEqual(self.object["Other Current Liabilities"].account_type, AccountType.liability) self.assertEqual( self.object['Unallocated Income Statement']["Gross Profit"].number, "0000") self.assertEqual( self.object['Unallocated Income Statement'] ["Gross Profit"].account_type, AccountType.revenue) self.assertEqual( self.object['Unallocated Income Statement'] ["Income Summary"].number, "0010") self.assertEqual( self.object['Unallocated Income Statement'] ["Income Summary"].account_type, AccountType.revenue) self.assertEqual( self.object['Retained Income']["Retained Earnings"].number, "0000") self.assertEqual( self.object['Retained Income']["Retained Earnings"].account_type, AccountType.equity) self.assertEqual(self.object['Tax']["Income Tax Expense"].number, "0000") self.assertEqual(self.object['Tax']["Income Tax Expense"].account_type, AccountType.expense) self.assertEqual(self.object.tax_payment_account, "Bank/Default") def test_get_account(self): self.object["Retained Income"].create_account("TestA", number="010") acc = self.object["Bank"].create_account("TestB", number="020") sub_acc = acc.create_account("TestB1", description="TestB1_Desc", number="010") sub_acc.create_account("TestB1.1", description="TestB1.1_Desc", number="010") orig = sub_acc.create_account("TestB1.2", description="TestB1.1_Desc", number="011") result = self.object.get_account("Bank/TestB/TestB1/TestB1.2") self.assertEqual(result.name, orig.name) self.assertEqual(result.description, orig.description) self.assertEqual(result.number, orig.number) def test_get_account_descendants(self): # Set up this test. self.sales_fish_acc = self.object["Sales"].create_account( "SalesFish", description="Sales of Fish", number="010") self.sales_barracuda_acc = self.sales_fish_acc.create_account( "SalesBarracuda", description="Sales of Barracudas", number="010") self.sales_nemo_acc = self.sales_fish_acc.create_account( "SalesNemo", description="Sales of Nemos", number="020") # perform the test. result = self.object.get_account_descendants(self.object["Sales"]) self.assertEqual(len(result), 3) self.assertEqual(result[0], self.sales_fish_acc) self.assertEqual(result[1], self.sales_barracuda_acc) self.assertEqual(result[2], self.sales_nemo_acc) def test_validate_account_name_valid(self): self.object.validate_account_names( ["Bank/Default", "Retained Income/Retained Earnings"]) def test_validate_account_name_invalid(self): self.assertRaises(ValueError, self.object.validate_account_names, ["invalid_acc_name_a", "invalid_acc_name_b"]) def test_report(self): report = self.object.report(ReportFormat.string) line1 = report.split("\n")[0] self.assertEqual(line1.replace(" ", ""), "TypeNumberNameDescription")
def setUp(self): self.object = GeneralLedgerStructure("NameA", description="DescriptionA")
class GeneralLedgerStructureUnitTester(unittest.TestCase): """ Tester for the auxi.modelling.financial.des.generalledgerstructure class. """ def setUp(self): self.object = GeneralLedgerStructure("NameA", description="DescriptionA") def test_constructor(self): """ Test the the variables has been initialised and that the default accounts has been created. """ self.assertEqual(self.object.name, "NameA") self.assertEqual(self.object.description, "DescriptionA") self.assertNotEqual(self.object["Bank"], None) self.assertEqual( self.object['Unallocated Income Statement'].account_type, AccountType.revenue) self.assertEqual(self.object["Sales"].number, "I10") self.assertEqual( self.object["Sales"].account_type, AccountType.revenue) self.assertEqual(self.object["Cost of Sales"].number, "I15") self.assertEqual( self.object["Cost of Sales"].account_type, AccountType.expense) self.assertEqual(self.object["Other Income"].number, "I20") self.assertEqual( self.object["Other Income"].account_type, AccountType.revenue) self.assertEqual(self.object["Expense"].number, "I25") self.assertEqual( self.object["Expense"].account_type, AccountType.expense) self.assertEqual(self.object["Tax"].number, "I30") self.assertEqual( self.object["Tax"].account_type, AccountType.expense) self.assertEqual(self.object["Dividends"].number, "I35") self.assertEqual( self.object["Dividends"].account_type, AccountType.expense) self.assertEqual(self.object["Share Capital"].number, "B10") self.assertEqual( self.object["Share Capital"].account_type, AccountType.asset) self.assertEqual(self.object["Retained Income"].number, "B15") self.assertEqual( self.object["Retained Income"].account_type, AccountType.equity) self.assertEqual(self.object["Shareholders Loan"].number, "B20") self.assertEqual( self.object["Shareholders Loan"].account_type, AccountType.liability) self.assertEqual(self.object["Long Term Borrowing"].number, "B25") self.assertEqual( self.object["Long Term Borrowing"].account_type, AccountType.liability) self.assertEqual( self.object["Other Long Term Liabilities"].number, "B30") self.assertEqual( self.object["Other Long Term Liabilities"].account_type, AccountType.liability) self.assertEqual(self.object["Fixed Assets"].number, "B35") self.assertEqual( self.object["Fixed Assets"].account_type, AccountType.asset) self.assertEqual(self.object["Investments"].number, "B40") self.assertEqual( self.object["Investments"].account_type, AccountType.asset) self.assertEqual(self.object["Other Fixed Assets"].number, "B45") self.assertEqual( self.object["Other Fixed Assets"].account_type, AccountType.asset) self.assertEqual(self.object["Inventory"].number, "B50") self.assertEqual( self.object["Inventory"].account_type, AccountType.asset) self.assertEqual(self.object["Accounts Receivable"].number, "B55") self.assertEqual( self.object["Accounts Receivable"].account_type, AccountType.asset) self.assertEqual(self.object["Bank"].number, "B60") self.assertEqual( self.object["Bank"].account_type, AccountType.asset) self.assertEqual(self.object["Bank"]["Default"].number, "0000") self.assertEqual( self.object["Bank"]["Default"].account_type, AccountType.asset) self.assertEqual(self.object["Other Current Assets"].number, "B65") self.assertEqual( self.object["Other Current Assets"].account_type, AccountType.asset) self.assertEqual(self.object["Account Payable"].number, "B70") self.assertEqual( self.object["Account Payable"].account_type, AccountType.liability) self.assertEqual(self.object["Taxation"].number, "B75") self.assertEqual( self.object["Taxation"].account_type, AccountType.liability) self.assertEqual( self.object["Other Current Liabilities"].number, "B80") self.assertEqual( self.object["Other Current Liabilities"].account_type, AccountType.liability) self.assertEqual( self.object['Unallocated Income Statement']["Gross Profit"].number, "0000") self.assertEqual( self.object['Unallocated Income Statement'] ["Gross Profit"].account_type, AccountType.revenue) self.assertEqual( self.object['Unallocated Income Statement'] ["Income Summary"].number, "0010") self.assertEqual( self.object['Unallocated Income Statement'] ["Income Summary"].account_type, AccountType.revenue) self.assertEqual( self.object['Retained Income'] ["Retained Earnings"].number, "0000") self.assertEqual( self.object['Retained Income'] ["Retained Earnings"].account_type, AccountType.equity) self.assertEqual( self.object['Tax'] ["Income Tax Expense"].number, "0000") self.assertEqual( self.object['Tax'] ["Income Tax Expense"].account_type, AccountType.expense) self.assertEqual(self.object.tax_payment_account, "Bank/Default") def test_get_account(self): self.object["Retained Income"].create_account( "TestA", number="010") acc = self.object["Bank"].create_account( "TestB", number="020") sub_acc = acc.create_account( "TestB1", description="TestB1_Desc", number="010") sub_acc.create_account( "TestB1.1", description="TestB1.1_Desc", number="010") orig = sub_acc.create_account( "TestB1.2", description="TestB1.1_Desc", number="011") result = self.object.get_account("Bank/TestB/TestB1/TestB1.2") self.assertEqual(result.name, orig.name) self.assertEqual(result.description, orig.description) self.assertEqual(result.number, orig.number) def test_get_account_decendants(self): # Set up this test. self.sales_fish_acc = self.object["Sales"].create_account( "SalesFish", description="Sales of Fish", number="010") self.sales_barracuda_acc = self.sales_fish_acc.create_account( "SalesBarracuda", description="Sales of Barracudas", number="010") self.sales_nemo_acc = self.sales_fish_acc.create_account( "SalesNemo", description="Sales of Nemos", number="020") # perform the test. result = self.object.get_account_decendants(self.object["Sales"]) self.assertEqual(len(result), 3) self.assertEqual(result[0], self.sales_fish_acc) self.assertEqual(result[1], self.sales_barracuda_acc) self.assertEqual(result[2], self.sales_nemo_acc) def test_validate_account_name_valid(self): self.object.validate_account_names( ["Bank/Default", "Retained Income/Retained Earnings"]) def test_validate_account_name_invalid(self): self.assertRaises( ValueError, self.object.validate_account_names, ["invalid_acc_name_a", "invalid_acc_name_b"]) def test_report(self): report = self.object.report(ReportFormat.string) line1 = report.split("\n")[0] self.assertEqual(line1.replace(" ", ""), "TypeNumberNameDescription")
from datetime import datetime from dateutil.relativedelta import relativedelta from auxi.core.time import TimePeriod from auxi.modelling.business.models import TimeBasedModel from auxi.modelling.business.basic import BasicActivity, BasicLoanActivity from auxi.modelling.financial.des import GeneralLedgerStructure from auxi.core.reporting import ReportFormat # Create general ledger structure and accounts. gl_structure = GeneralLedgerStructure("Courier GL Structure") gl_structure["Long Term Borrowing"].create_account("Loan", "0000") gl_structure["Expense"].create_account("Interest Expense", "0000") gl_structure["Fixed Assets"].create_account("Vehicle Asset", "0000") gl_structure["Sales"].create_account("Sales Delivery", "0000") gl_structure["Cost of Sales"].create_account("Fuel", "0000") gl_structure["Expense"].create_account("Wages", "0000") # Create the business model, entity and components. start_datetime = datetime(2016, 2, 1) end_datetime = datetime(2021, 1, 1) model = TimeBasedModel("Business Model", start_datetime=start_datetime, 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