def test_account2(self): p = Parser(self.acc) p.account('1024', 'Kassa') account, = blm.accounting.Account._query().run() assert account.accounting == [self.acc] assert account.number == ['1024'] assert account.name == ['Kassa']
def test_address(self): p = Parser(self.acc) p.address('Sven Svensson', 'Box 21', u'211 20 MALMÖ', '040-123 45') assert self.acc.contact == ['Sven Svensson'] assert self.acc.mail_address == ['Box 21'] assert self.acc.zip_city == [u'211 20 MALMÖ'] assert self.acc.telephone == ['040-123 45']
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_get_undefined_acct_object(self): p = Parser(self.acc) obj = p.get_accounting_object('9999', '4711') assert obj.number == ['4711'] assert obj.dimension[0].number == ['9999'] assert len(p.parse_warnings) == 2 assert '9999' in p.parse_warnings[0] assert '4711' in p.parse_warnings[1]
def test_account(self): p = Parser(self.acc) p.parse(b'#KONTO 1024 "Kassa"\n') account, = blm.accounting.Account._query().run() assert account.accounting == [self.acc] assert account.number == ['1024'] assert account.name == ['Kassa'] py.test.raises(ValueError, p.parse, b'#KONTO 1024 "Kassa"\n')
def test_ver(self): dimension = blm.accounting.Dimension._query(number=['1']).run()[0] accounting_object = blm.accounting.AccountingObject( number=['2'], name=['bar'], dimension=[dimension]) self.acc.dimensions = [dimension] account1910 = self.mkAccount('1910') account2640 = self.mkAccount('2640') account6250 = self.mkAccount('6250') p = Parser(self.acc) p.verification('A', 1, '2012-01-24', '', '2012-01-25', 'Gurra') p.transaction('1910', [], Decimal('-1000')) p.transaction('2640', [], Decimal('200'), '', 'Text1') p.transaction('6250', ['1', '2'], Decimal('800'), '', 'Text2') v, = blm.accounting.Verification._query().run() assert v.accounting == [self.acc] assert v.version == [0] assert v.series[0].name == ['A'] assert v.number == [1] assert v.transaction_date == ['2012-01-24'] assert v.registration_date == ['2012-01-25'] assert len(v.transactions) == 3 t = v.transactions[0] assert t.version == [0] assert t.transtype == ['normal'] assert t.account == [account1910] assert t.amount == [Decimal('-1000.00')] assert t.text == [u''] t = v.transactions[1] assert t.version == [0] assert t.transtype == ['normal'] assert t.account == [account2640] assert t.amount == [Decimal('200.00')] assert t.text == ['Text1'] t = v.transactions[2] assert t.version == [0] assert t.transtype == ['normal'] assert t.account == [account6250] assert t.amount == [Decimal('800.00')] assert t.text == ['Text2'] assert t.accounting_objects == [accounting_object]
def test_accounting_period(self): p = Parser(self.acc) p.accounting_period(0, '2012-01-01', '2012-12-31') p.accounting_period(-2, '2010-01-01', '2010-12-31') year = self.acc.years['0'] assert year == ['2012-01-01', '2012-12-31'] assert self.acc.start == ['2012-01-01'] assert self.acc.end == ['2012-12-31'] year = self.acc.years['-2'] assert year == ['2010-01-01', '2010-12-31']
def test_vatcode(self): p = Parser(self.acc) blm.accounting.bootstrap() # Set up vat codes p.account('2610', 'Mums!') p.vatcode('2610', '05') a, = blm.accounting.Account._query().run() assert a.vatCode[0] == '05'
def test_turnover(self): account = self.mkAccount('1910') p = Parser(self.acc) p.turnover(0, '1910', Decimal('123.45')) balance = account.account_balances['0'] assert balance.year == [0] assert balance.balance == [Decimal('123.45')] p.turnover(-1, '1910', Decimal('123.45'), Decimal('2.2')) balance = account.account_balances['-1'] assert balance.year == [-1] assert balance.balance == [Decimal('123.45')] assert balance.balance_quantity == [Decimal('2.2')]
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_closing_balance(self): account = self.mkAccount('1910') p = Parser(self.acc) p.closing_balance(-1, '1910', Decimal('123.45'), Decimal('2.2')) balance = account.account_balances['-1'] assert balance.year == [-1] assert balance.balance == [Decimal('123.45')] assert balance.balance_quantity == [Decimal('2.2')] acctobj = p.accounting_object('1', '2', 'two') p.object_closing_balance(-1, '1910', ['1', '2'], Decimal('123.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.balance == [Decimal('123.45')] assert obj_balance.balance_quantity == [Decimal('-2.2')]
def test_series(self): p = Parser(self.acc) p.series('A') p.series('B', 'And a descr') series = blm.accounting.VerificationSeries._query().run() a, b = sorted(series, key=lambda toi: toi.name[0]) assert a.name == ['A'] assert a.description == [] assert b.name == ['B'] assert b.description == ['And a descr'] # find existing series c = blm.accounting.VerificationSeries(accounting=self.acc, name='C') series = p.series('C', 'C descr') assert series is c assert series.description == ['C descr']
def test_unit(self): account = self.mkAccount('1910') p = Parser(self.acc) p.unit('1910', 'st') assert account.unit == ['st']
def test_undefined_account(self): p = Parser(self.acc) acct = p.get_account('4711') assert acct.number == ['4711'] assert len(p.parse_warnings) == 1 assert '4711' in p.parse_warnings[0]
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
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_account_type(self): account = self.mkAccount() p = Parser(self.acc) p.account_type('1024', 'T') assert account.type == ['T']
def test_sru(self): account = self.mkAccount('1910') p = Parser(self.acc) p.sru('1910', '123') assert account.sru == ['123']
def test_subdim_of_undefined(self): p = Parser(self.acc) dim = p.sub_dim('22', 'Rum', '21') assert len(p.parse_warnings) == 1 assert '21' in p.parse_warnings[0] assert dim.subdim_of[0].number == ['21']
def test_layout(self): p = Parser(self.acc) p.account_layout('Bas1998') assert self.acc.layout == ['Bas1998']
def test_closed(self): p = Parser(self.acc) assert self.acc.closed == [False] # sanity p.closed() assert self.acc.closed == [True]
def test_industry_code(self): p = Parser(self.acc) p.industry_code('82300') assert self.acc.industry_code == ['82300']
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_sie_type(self): p = Parser(self.acc) py.test.raises(UnsupportedSIEVersion, p.sie_type, '1') py.test.raises(UnsupportedSIEVersion, p.sie_type, '2') py.test.raises(UnsupportedSIEVersion, p.sie_type, '3') p.sie_type('4') # we support version 4