コード例 #1
0
ファイル: handler.py プロジェクト: sand8080/helixbilling
 def loader():
     if new_overdraft_limit is not None:
         for b in balances:
             d = {'new_overdraft_limit': new_overdraft_limit}
             amount_fields = ['new_overdraft_limit']
             currency = currencies_id_idx[b.currency_id]
             d = decimal_texts_to_cents(d, currency, amount_fields)
             b.overdraft_limit = d['new_overdraft_limit']
     return balances
コード例 #2
0
ファイル: handler.py プロジェクト: sand8080/helixbilling
 def loader():
     if new_overdraft_limit is not None:
         for b in balances:
             d = {'new_overdraft_limit': new_overdraft_limit}
             amount_fields = ['new_overdraft_limit']
             currency = currencies_id_idx[b.currency_id]
             d = decimal_texts_to_cents(d, currency, amount_fields)
             b.overdraft_limit = d['new_overdraft_limit']
     return balances
コード例 #3
0
ファイル: handler.py プロジェクト: sand8080/helixbilling
    def add_balance(self, data, session, curs=None):
        user_id = data['user_id']
        check_user_exist = data.get('check_user_exist', False)
        if check_user_exist:
            self._check_user_exist(session, user_id)
        currs_code_idx = self._get_currs_idx(curs, 'code')
        curr_code = data['currency_code']
        if curr_code not in currs_code_idx:
            raise CurrencyNotFound(currency_code=curr_code)
        curr = currs_code_idx[curr_code]

        try:
            u_curr_f = UsedCurrencyFilter(session, {}, {}, None)
            u_currs = u_curr_f.filter_one_obj(curs)
            u_currs_ids = u_currs.currencies_ids
        except ObjectNotFound:
            u_currs_ids = []

        if curr.id not in u_currs_ids:
            raise UsedCurrencyNotFound(currency_code=curr_code)

        b_data = dict(data)
        b_data.pop('currency_code', None)
        b_data.pop('session_id', None)
        b_data.pop('check_user_exist', None)
        b_data.pop('subject_users_ids', None)

        b_data['environment_id'] = session.environment_id
        b_data['currency_id'] = curr.id
        amount_fields = ['overdraft_limit']
        balance = Balance(
            **decimal_texts_to_cents(b_data, curr, amount_fields))
        try:
            mapping.insert(curs, balance)
        except ObjectCreationError:
            raise BalanceAlreadyExists()
        return response_ok(id=balance.id)
コード例 #4
0
ファイル: handler.py プロジェクト: sand8080/helixbilling
    def add_balance(self, data, session, curs=None):
        user_id = data['user_id']
        check_user_exist = data.get('check_user_exist', False)
        if check_user_exist:
            self._check_user_exist(session, user_id)
        currs_code_idx = self._get_currs_idx(curs, 'code')
        curr_code = data['currency_code']
        if curr_code not in currs_code_idx:
            raise CurrencyNotFound(currency_code=curr_code)
        curr = currs_code_idx[curr_code]

        try:
            u_curr_f = UsedCurrencyFilter(session, {}, {}, None)
            u_currs = u_curr_f.filter_one_obj(curs)
            u_currs_ids = u_currs.currencies_ids
        except ObjectNotFound:
            u_currs_ids = []

        if curr.id not in u_currs_ids:
            raise UsedCurrencyNotFound(currency_code=curr_code)

        b_data = dict(data)
        b_data.pop('currency_code', None)
        b_data.pop('session_id', None)
        b_data.pop('check_user_exist', None)
        b_data.pop('subject_users_ids', None)

        b_data['environment_id'] = session.environment_id
        b_data['currency_id'] = curr.id
        amount_fields = ['overdraft_limit']
        balance = Balance(**decimal_texts_to_cents(b_data, curr, amount_fields))
        try:
            mapping.insert(curs, balance)
        except ObjectCreationError:
            raise BalanceAlreadyExists()
        return response_ok(id=balance.id)