def create(self, data):
        title = data['OrganisationName']
        data['title'] = title
        id = queryUtility(IIDNormalizer).normalize(title)
        self.contentName = id

        folder = AccountingFolder(id, title=title)
        # wrap the folder to allow edits
        folder = folder.__of__(self.context)
        folder.edit(**data)
        return folder
    def afterSetUp(self):
        """
        """
        self.setRoles(('Manager',))
        portal = self.getPortal()
        portal.error_log._ignored_exceptions = ()

        portal_url = portal.absolute_url()

        id = 'upfrontbooks'

        upfrontbooks = AccountingFolder(id, id=id,
            AccountingCurrency=CURRENCY_DISPLAY_LIST[0])

        upfrontbooks.setAccountingCurrency(CURRENCY_DISPLAY_LIST[0])

        rval = portal._setObject(id, upfrontbooks)
        newid = isinstance(rval, basestring) and rval or id

        upfrontbooks = portal._getOb(newid)
        taxaccount = self.portal.portal_catalog(
            Title='Sales Tax Control Account',
            portal_type='Account')[0].getObject()
        upfrontbooks.setSalesTaxAccount(taxaccount)
        upfrontbooks.setSalesTaxPercentage(10)
        self.accountingfolder = upfrontbooks

        # add a few cashbookentries to the cashbook, making sure the
        # values are unique and nonzero
        self.cashbook = self.accountingfolder.cashbook
        for i in range(1, 4):
            self._add_cashbookentry(i*100)
    def _afterSetup(self):
        """
        """
        self.setRoles(('Manager',))
        portal = self.getPortal()
        portal.error_log._ignored_exceptions = ()

        portal_url = portal.absolute_url()

        id = 'upfrontbooks'

        upfrontbooks = AccountingFolder(id, id=id,
            AccountingCurrency=CURRENCY_DISPLAY_LIST[0])

        upfrontbooks.setAccountingCurrency(CURRENCY_DISPLAY_LIST[0])

        rval = portal._setObject(id, upfrontbooks)
        newid = isinstance(rval, basestring) and rval or id

        upfrontbooks = portal._getOb(newid)