示例#1
0
文件: admin.py 项目: 5l1v3r1/stoq-1
def register_accounts(store):
    # FIXME: If you need to run this in a patch, you need to
    #        make sure that .find().one() is fixed bellow, as accounts
    #        with the same names are allowed.
    #        It's for now okay to run this when creating a new
    #        database.

    from stoqlib.domain.account import Account
    log.info("Creating Accounts")
    for name, atype in [
        (_(u"Assets"), Account.TYPE_ASSET),
        (_(u"Banks"), Account.TYPE_BANK),
        (_(u"Equity"), Account.TYPE_EQUITY),
        (_(u"Expenses"), Account.TYPE_EXPENSE),
        (_(u"Imbalance"), Account.TYPE_BANK),
        (_(u"Income"), Account.TYPE_INCOME),
        (_(u"Tills"), Account.TYPE_CASH),
    ]:
        # FIXME: This needs to rewritten to not use .find().one(),
        #        see comment above.
        account = store.find(Account, description=name).one()
        if not account:
            account = Account(store=store, description=name)
        account.account_type = atype

    sysparam.set_object(store, 'BANKS_ACCOUNT',
                        store.find(Account, description=_(u"Banks")).one())
    sysparam.set_object(store, 'TILLS_ACCOUNT',
                        store.find(Account, description=_(u"Tills")).one())
    sysparam.set_object(store, 'IMBALANCE_ACCOUNT',
                        store.find(Account, description=_(u"Imbalance")).one())
示例#2
0
 def before_start(self, store):
     account = store.find(Account, code=unicode(self.tp.account_id)).one()
     if account is None:
         account = Account(description=self.get_account_id(),
                           code=unicode(self.tp.account_id),
                           account_type=Account.TYPE_BANK,
                           parent=sysparam(store).BANKS_ACCOUNT,
                           store=store)
     self.account_id = account.id
     self.source_account_id = sysparam(store).IMBALANCE_ACCOUNT.id
     self.skipped = 0
示例#3
0
 def _import_account(self, store, node):
     account_id = self._get_text(node, _actns('id'))
     account_name = self._get_text(node, _actns('name'))
     account_type = self._get_text(node, _actns('type'))
     parent = self._get_text(node, _actns('parent'))
     parent_account = self._accounts.get(parent)
     if account_type == 'ROOT':
         account = None
     else:
         account = store.find(Account, description=account_name).one()
         if account is None:
             account = Account(account_type=_account_types.get(
                 account_type, Account.TYPE_CASH),
                               description=account_name,
                               code=self._get_text(node, _actns('code')),
                               parent=parent_account,
                               store=store)
     self._accounts[account_id] = account
示例#4
0
    def process_one(self, data, fields, store):
        if data.parent_account:
            name = _(data.parent_account)
            parent = store.find(Account, description=name).one()
        else:
            parent = None
        account = Account(description=data.description,
                          parent=parent,
                          code=None,
                          station=api.get_current_station(store),
                          account_type=data.account_type,
                          store=store)

        if data.bank_number:
            BankAccount(account=account,
                        bank_account=data.bank_account,
                        bank_number=int(data.bank_number),
                        bank_branch=data.bank_branch,
                        store=store)
示例#5
0
 def create_model(self, store):
     return Account(description=u"",
                    account_type=Account.TYPE_CASH,
                    store=store)
示例#6
0
 def create_account(self):
     from stoqlib.domain.account import Account
     return Account(description=u"Test Account",
                    account_type=Account.TYPE_CASH,
                    store=self.store)