示例#1
0
    def get_dict_by_firm_id(self, firm_id):
        corp_wallet_interval = self.get_interval_list()
        persons = Person.get_dict_by_firm_id(firm_id)

        result = {}
        for key in persons:
            wallet = self.query.filter_by(person_id=key).first()
            if not wallet:
                continue

            result[key] = dict(
                interval=corp_wallet_interval[wallet.interval]['name'],
                limit=wallet.limit,
                balance=wallet.balance)
        return result
示例#2
0
    def _get_person(self, result):
        '''Формируем отчет по всем пользователям из белого списка'''

        result.col_keys = ReportResult.get_person_keys()
        result.col_name = ReportResult.get_person_col_name()

        persons = Person.get_dict_by_firm_id(result.firm.id)

        for row in result.report:
            result.set_terms(row[2])
            if row.person_id not in result.persons:
                result.persons.append(row.person_id)

            if row[0] not in result.data:
                if row[0] in persons:
                    result.data[row[0]] = {
                        'amount': 0,
                        'name': persons[row[0]]['name'],
                        'tabel_id': persons[row[0]]['tabel_id'],
                        'card': persons[row[0]]['card']
                    }
                else:
                    result.data[row[0]] = {
                        'amount': 0,
                        'name': row[3],
                        'tabel_id': 0,
                        'card': 0
                    }

            data = result.data[row[0]]

            amount = row[1] / 100
            data['amount'] = data['amount'] + amount

            result.all['summ'] += amount
            result.terms[row[2]]['amount'] = result.terms[
                row[2]]['amount'] + amount

            if 'term' not in data:
                data['term'] = {}
            data['term'][row[2]] = row[1] / 100

            result.data[row[0]] = data

        return result
示例#3
0
    def _get_corp(self, result):
        '''Формируем отчет по пользователям с корпоративными кошельками'''

        result.col_keys = ReportResult.get_corp_keys()
        result.col_name = ReportResult.get_corp_col_name()

        persons = Person.get_dict_by_firm_id(result.firm.id)
        corp_wallets = TermCorpWallet().get_dict_by_firm_id(
            result.firm.id)

        for row in result.report:
            result.set_terms(row[2])
            if row.person_id not in result.persons:
                result.persons.append(row.person_id)

            if row[0] not in result.data:
                tabel_id = persons[row[0]]['tabel_id'] or ''
                card = persons[row[0]]['card'] or ''

                result.data[row[0]] = {
                    'amount': 0,
                    'name': persons[row[0]]['name'],
                    'tabel_id': tabel_id,
                    'card': card
                }

            data = result.data[row[0]]
            if row[0] in corp_wallets:
                data['wallet_interval'] = corp_wallets[row[0]]['interval']
                data['wallet_limit'] = corp_wallets[row[0]]['limit'] / 100

            amount = row[1] / 100
            data['amount'] = data['amount'] + amount

            result.all['summ'] += amount
            result.terms[row[2]]['amount'] = result.terms[
                row[2]]['amount'] + amount

            if 'term' not in data:
                data['term'] = {}
            data['term'][row[2]] = row[1] / 100

            result.data[row[0]] = data

        return result
    def get_dict_by_firm_id(self, firm_id):
        corp_wallet_interval = self.get_interval_list()
        persons = Person.get_dict_by_firm_id(firm_id)

        result = {}
        for key in persons:
            wallet = self.query.filter_by(person_id=key).first()
            if not wallet:
                continue

            result[key] = dict(
                interval=corp_wallet_interval[
                    wallet.interval][
                        'name'],
                limit=wallet.limit,
                balance=wallet.balance
            )
        return result