コード例 #1
0
ファイル: utils.py プロジェクト: JBalloonist/django-ledger
def populate_default_coa(entity_model: EntityModel, activate_accounts: bool = False):
    acc_objs = [AccountModel(
        code=a['code'],
        name=a['name'],
        role=a['role'],
        balance_type=a['balance_type'],
        active=activate_accounts,
        coa=entity_model.coa,
    ) for a in CHART_OF_ACCOUNTS]

    for acc in acc_objs:
        acc.full_clean()
        acc.save()
コード例 #2
0
    def populate_default_coa(self, activate_accounts: bool = False):
        # pylint: disable=no-member
        coa: ChartOfAccountModel = self.coa
        has_accounts = coa.accounts.all().exists()
        if not has_accounts:
            acc_objs = [
                AccountModel(
                    code=a['code'],
                    name=a['name'],
                    role=a['role'],
                    balance_type=a['balance_type'],
                    active=activate_accounts,
                    coa=coa,
                ) for a in CHART_OF_ACCOUNTS
            ]

            for acc in acc_objs:
                acc.clean()
            AccountModel.on_coa.bulk_create(acc_objs)
コード例 #3
0
 def add_account(self,
                 account_code: str,
                 account_role: str,
                 account_name: str,
                 balance_type: str,
                 is_active: bool = False,
                 is_locked: bool = False) -> AccountModel:
     validate_roles(account_role)
     account_model = AccountModel(
         code=account_code,
         role=account_role,
         name=account_name,
         balance_type=balance_type,
         coa_id=self.coa.uuid,
         active=is_active,
         locked=is_locked
     )
     account_model.clean()
     account_model.save()
     return account_model