def test_setControlAccount(self): portal = self.getPortal() id = 'upfrontbooks' books = getattr(portal, id) ledger = getattr(books, 'ledger') accounts = getattr(ledger, 'accounts') self.failUnless(isinstance(accounts, AccountFolder)) subsidiaryLedger = getattr(books, 'receivables') self.failUnless(ISubsidiaryLedger.providedBy(subsidiaryLedger)) control = subsidiaryLedger.getControlAccount() self.failUnless(control) acc = None for acc in accounts.objectValues(): if acc != control: break self.failUnless(acc is not None) self.assertRaises(RuntimeError, subsidiaryLedger.setControlAccount, acc.UID()) self.failUnless(control.getSubsidiaryLedger() == subsidiaryLedger)
def initializeLedger(ob, event): """ Initialize Ledger """ # add transaction catalog if not ob.hasObject('transaction_catalog'): ob.manage_addProduct['ZCatalog'].manage_addZCatalog( 'transaction_catalog', 'Transaction Catalog') catalog = ob.transaction_catalog catalog.addIndex('effective', 'DateIndex', extra=None) catalog.addIndex('review_state', 'FieldIndex', extra=None) # Don't execute the following steps in the context of a # SubsidiaryLedger if ISubsidiaryLedger.providedBy(ob): return if 'accounts' not in ob.objectIds(): ob._setObject('accounts', AccountFolder('accounts')) ob._getOb('accounts').edit( title=ob.translate( 'account_folder_title', domain=PROJECTNAME, default='Accounts', ) ) if 'transactions' not in ob.objectIds(): ob._setObject('transactions', TransactionFolder('transactions')) ob._getOb('transactions').edit( title=ob.translate( 'transaction_folder_title', domain=PROJECTNAME, default='Transactions', ) )