def test_get_accounting_object(self): p = Parser(self.acc) p.accounting_object('1', '0123', 'Serviceavdelningen') obj = p.get_accounting_object('1', '0123') assert obj.name == ['Serviceavdelningen']
def test_dim_subdim(self): p = Parser(self.acc) p.dim('2', 'Godis') dim, = blm.accounting.Dimension._query(number='2').run() assert dim.name == ['Godis'] assert dim.subdim_of == [] p.sub_dim('6', 'Polkagrisar', '2') subdim, = blm.accounting.Dimension._query(number='6').run() assert subdim.name == ['Polkagrisar'] assert subdim.subdim_of == [dim] p.dim('21', 'Lokaler') p.sub_dim('22', 'Rum', '21') dim, = blm.accounting.Dimension._query(number='21').run() subdim, = blm.accounting.Dimension._query(number='22').run() assert dim.accounting == subdim.accounting == [self.acc] assert subdim.subdim_of == [dim] assert dim.name == ['Lokaler'] assert subdim.name == ['Rum'] p.accounting_object('21', '1', 'Byggnad 1') p.accounting_object('22', '11', 'Rum 1') ao1, = blm.accounting.AccountingObject._query(number='1').run() assert ao1.dimension == [dim] assert ao1.name == ['Byggnad 1'] ao11, = blm.accounting.AccountingObject._query(number='11').run() assert ao11.dimension == [subdim] assert ao11.name == ['Rum 1']
def test_opening_balance(self): account = self.mkAccount('1910') p = Parser(self.acc) p.opening_balance(0, '1910', Decimal('123.45')) balance = account.account_balances['0'] assert balance is account assert balance.year == [0] assert balance.opening_balance == [Decimal('123.45')] assert account.opening_balance == [Decimal('123.45')] p.opening_balance(-1, '1910', Decimal('1234.45'), Decimal('2.2')) balance = account.account_balances['-1'] assert balance is not account assert balance.year == [-1] assert balance.opening_balance == [Decimal('1234.45')] assert account.opening_balance == [Decimal('123.45')] assert balance.opening_quantity == [Decimal('2.2')] acctobj = p.accounting_object('1', '2', 'two') p.object_opening_balance(-1, '1910', ['1', '2'], Decimal('2123.45'), Decimal('-2.2')) assert account.account_balances['-1'] is balance obj_balance = balance.object_balance_budgets[0] assert obj_balance.accounting_object == [acctobj] assert obj_balance.period == [''] assert obj_balance.opening_balance == [Decimal('2123.45')] assert account.opening_balance == [Decimal('123.45')] assert obj_balance.opening_quantity == [Decimal('-2.2')] p.object_opening_balance(-2, '1910', ['1', '2'], Decimal('1000')) balance = account.account_balances['-2'] assert balance.object_balance_budgets[0].opening_balance == [ Decimal('1000') ]
def test_period_budget(self): account = self.mkAccount('1910') p = Parser(self.acc) p.period_budget(-1, '201303', '1910', [], Decimal('123.45'), Decimal('-2.2')) balance = account.account_balances['-1'] assert balance.year == [-1] balancebudget = balance.balance_budgets[0] assert balancebudget.period == ['201303'] assert balancebudget.budget == [Decimal('123.45')] assert balancebudget.budget_quantity == [Decimal('-2.2')] p.accounting_object('1', '2', 'two') p.period_budget(-1, '201303', '1910', ['1', '2'], Decimal('123.45'), Decimal('-2.2')) assert balance is account.account_balances['-1'] objectbalancebudget = balance.object_balance_budgets[0] assert objectbalancebudget.period == ['201303'] assert objectbalancebudget.budget == [Decimal('123.45')] assert objectbalancebudget.budget_quantity == [Decimal('-2.2')]
def test_object_of_undefined(self): p = Parser(self.acc) obj = p.accounting_object('9999', '0123', 'Serviceavdelningen') assert len(p.parse_warnings) == 1 assert '9999' in p.parse_warnings[0] assert obj.dimension[0].number == ['9999']
def test_accounting_object(self): p = Parser(self.acc) p.accounting_object('1', '0123', 'Serviceavdelningen') obj, = blm.accounting.AccountingObject._query().run() assert obj.dimension[0].number == ['1'] assert obj.dimension[0].accounting[0] == self.acc