Esempio n. 1
0
    def get(self, request):
        lower_fiscal_period_year = request.GET.get('lower_fiscal_period_year')
        upper_fiscal_period_year = request.GET.get('upper_fiscal_period_year')

        lower_fiscal_period_month = request.GET.get(
            'lower_fiscal_period_month')
        upper_fiscal_period_month = request.GET.get(
            'upper_fiscal_period_month')

        type_policy_array = get_array_or_none(
            request.GET.get('type_policy_array'))

        lower_folio = request.GET.get('lower_folio')
        upper_folio = request.GET.get('upper_folio')

        lower_registry_date = Utilities.string_to_date(
            request.GET.get('lower_registry_date'))
        upper_registry_date = Utilities.string_to_date(
            request.GET.get('upper_registry_date'))

        description = request.GET.get('description')

        lower_account_number = request.GET.get('lower_account_number')
        upper_account_number = request.GET.get('upper_account_number')

        lower_debit = request.GET.get('lower_debit')
        upper_debit = request.GET.get('upper_debit')

        lower_credit = request.GET.get('lower_credit')
        upper_credit = request.GET.get('upper_credit')

        reference = request.GET.get('reference')

        # If the account number is set, the range is ignored.
        account_number_array = get_array_or_none(request.GET.get('account'))

        internal_company = request.GET.get('internal_company')

        engine = PolicySearchEngine(
            lower_fiscal_period_year=lower_fiscal_period_year,
            upper_fiscal_period_year=upper_fiscal_period_year,
            lower_fiscal_period_month=lower_fiscal_period_month,
            upper_fiscal_period_month=upper_fiscal_period_month,
            type_policy_array=type_policy_array,
            lower_folio=lower_folio,
            upper_folio=upper_folio,
            lower_registry_date=lower_registry_date,
            upper_registry_date=upper_registry_date,
            description=description,
            lower_account_number=lower_account_number,
            upper_account_number=upper_account_number,
            lower_debit=lower_debit,
            upper_debit=upper_debit,
            lower_credit=lower_credit,
            upper_credit=upper_credit,
            reference=reference,
            only_with_transactions=False,
            account_array=account_number_array,
            internal_company=internal_company)

        result = engine.search_policies()

        return HttpResponse(
            Utilities.query_set_to_dumps(result),
            'application/json; charset=utf-8',
        )
Esempio n. 2
0
    def get(self, request):
        user_id = request.GET.get('user_id')
        accesses = AccessToProject.objects.filter(user_id=user_id)

        return HttpResponse(Utilities.query_set_to_dumps(accesses),
                            'application/json; charset=utf-8')
Esempio n. 3
0
    def get(self, request):

        if request.GET.get('export_excel') is not None:
            export_excel = True
        else:
            print(' not excel')
            export_excel = False

        type = request.GET.get('type')

        if type is None:
            return HttpResponse(
                Utilities.json_to_dumps({
                    "error": {
                        "message": "The parameter 'type' is required."
                    }
                }),
                'application/json; charset=utf-8',
            )

        # Make it uppercase so that it's easier to compare.
        type = type.upper()

        if type not in ('PROVIDER', 'CREDITOR', 'THIRD_PARTY'):
            return HttpResponse(
                Utilities.json_to_dumps({
                    "error": {
                        "message":
                        "The parameter 'type' must be PROVIDER, CREDITOR or THIRD_PARTY."
                    }
                }),
                'application/json; charset=utf-8',
            )

        name = request.GET.get('name')
        rfc = request.GET.get('rfc')
        email = request.GET.get('email')
        phone_number = request.GET.get('phone_number')
        accounting_account_number = request.GET.get(
            'accounting_account_number')
        bank_account = request.GET.get('bank_account')
        register_date_lower = Utilities.string_to_date(
            request.GET.get('register_date_lower'))
        register_date_upper = Utilities.string_to_date(
            request.GET.get('register_date_upper'))
        services = request.GET.get('services')

        engine = ProviderSearchEngine(type, name, rfc, email, phone_number,
                                      accounting_account_number, bank_account,
                                      register_date_lower, register_date_upper,
                                      services)

        results = engine.search()

        if export_excel:
            values = [
                'name', 'country', 'colony', 'street', 'outdoor_number',
                'indoor_number', 'zip_code', 'rfc', 'curp', 'phone_number',
                'phone_number_2', 'email', 'cellphone_number', 'office_number',
                'extension_number'
            ]
            return createCSVResponseFromQueryset(results, values)
        else:
            return HttpResponse(
                Utilities.query_set_to_dumps(results),
                'application/json; charset=utf-8',
            )