Exemple #1
0
    def get(self, request):
        project_id = request.GET.get('project_id')

        response = []
        sections = ProjectSections.objects.filter(
            Q(project_id=project_id) & Q(section__parent_section=None))
        for section in sections:

            temp_json = {
                "project_section_id": section.id,
                "project_section_name": section.section.section_name,
                "project_section_status": section.status,
                "inner_sections": []
            }
            inner_sections = ProjectSections.objects.filter(
                Q(project_id=project_id)
                & Q(section__parent_section__id=section.section.id))
            for inner_section in inner_sections:
                temp_json["inner_sections"].append({
                    "project_section_id":
                    inner_section.id,
                    "project_section_name":
                    inner_section.section.section_name,
                    "project_section_status":
                    inner_section.status,
                })
            response.append(temp_json)

        return HttpResponse(Utilities.json_to_dumps(response),
                            'application/json; charset=utf-8')
Exemple #2
0
    def get(self, request, *args, **kwargs):
        fiscal_period_year = request.GET.get('fiscal_period_year')

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

        employee_key = request.GET.get('employee_key')
        name = request.GET.get('name')
        rfc = request.GET.get('rfc')

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

        engine = TransactionsEngine(
            fiscal_period_year=fiscal_period_year,
            fiscal_period_month=fiscal_period_month,
            employee_key=employee_key,
            name=name,
            rfc=rfc,
            only_with_transactions=False,
        )

        transactions = engine.search_transactions()

        # Grouping all the transactions by accounts.
        grouped_transactions = self.get_values_PayrollProcessedDetail(
            transactions)

        response = {'accounts': []}

        'payroll_receip_processed__payroll_period__year', 'payroll_receip_processed__payroll_period__month', 'payroll_receip_processed__payroll_period__name',
        'payroll_receip_processed__employee__employee_key', 'payroll_receip_processed__employee__name', 'payroll_receip_processed__employee__rfc',
        'name', 'amount', 'type'

        for account in grouped_transactions:
            response['accounts'].append({
                'payroll_period_year':
                account['payroll_receip_processed__payroll_period__year'],
                'payroll_period_month':
                account['payroll_receip_processed__payroll_period__month'],
                'payroll_period_name':
                str(account['payroll_receip_processed__payroll_period__name']),
                'employee_key':
                account['payroll_receip_processed__employee__employee_key'],
                'employee_name':
                account['payroll_receip_processed__employee__name'],
                'employee_rfc':
                account['payroll_receip_processed__employee__rfc'],
                'payrollprocesseddetail_name':
                account['name'],
                'amount':
                account['amount'],
                'type':
                account['type'],
            })

        return HttpResponse(
            Utilities.json_to_dumps(response),
            'application/json; charset=utf-8',
        )
Exemple #3
0
    def get(self, request):
        number = request.GET.get('number')
        name = request.GET.get('name')
        subsidiary_account_array = get_array_or_none(
            request.GET.get('subsidiary_account_array'))
        nature_account_array = get_array_or_none(
            request.GET.get('nature_account_array'))
        grouping_code_array = get_array_or_none(
            request.GET.get('grouping_code_array'))
        level = request.GET.get('level')
        #item = request.GET.get('item')
        internal_company = request.GET.get('internal_company')

        engine = AccountSearchEngine(number, name, subsidiary_account_array,
                                     nature_account_array, grouping_code_array,
                                     level, internal_company)

        results = engine.search()

        response = {'accounts': []}

        for account in results:
            response['accounts'].append({
                'id':
                account.id,
                'number':
                str(account.number),
                'name':
                account.name,
                'status':
                account.status,
                'nature_account':
                account.nature_account,
                'internal_company_id':
                account.internal_company_id,
                'internal_company':
                str(account.internal_company),
                'grouping_code_id':
                account.grouping_code_id,
                'grouping_code':
                str(account.grouping_code),
                'subsidiary_account_id':
                account.subsidiary_account_id,
                'subsidiary_account':
                str(account.subsidiary_account),
                'type_account':
                account.type_account,
                'nature_account_display':
                account.get_nature_account_display()
            })

        return HttpResponse(
            Utilities.json_to_dumps(response['accounts']),
            'application/json; charset=utf-8',
        )
Exemple #4
0
    def get(self, request):
        qry = Project.objects.values('id', 'key',
                                     'nombreProyecto').order_by('key')
        the_list = []
        for register in qry:
            the_list.append(register)

        return HttpResponse(
            Utilities.json_to_dumps(the_list),
            'application/json',
        )
Exemple #5
0
    def get(self, request):

        response_by_project = []
        access_set = AccessToProject.objects.filter(user__id=request.user.id)
        for access in access_set:

            structured_response = {}

            response = api.PhysicalFinancialAdvanceReport.get_biddings_report(access.project.id)

            total_programmed = 0
            total_estimated = 0
            total_paid_estimated = 0
            for year in response:
                for month in year['months']:
                    total_programmed += month['month_program']
                    total_estimated += month['month_estimate']
                    total_paid_estimated += month['month_paid_estimate']

            percentaje_paid_estimated = 0
            percentaje_estimated = 0
            if total_programmed > 0:
                percentaje_paid_estimated = round((total_paid_estimated * 100 / total_programmed), 2)
                percentaje_estimated = round((total_estimated * 100 / total_programmed), 2)

            structured_response['schedule'] = response
            structured_response['general'] = {
                "general_programmed": total_programmed,
                "general_estimated": total_estimated,
                "general_paid_estimated": total_paid_estimated,
                "percentaje_paid_estimated": percentaje_paid_estimated,
                "percentaje_estimated": percentaje_estimated,
                "project_name" : access.project.nombreProyecto,
                "project_key" : access.project.key,
                "project_latitud" : access.project.latitud,
                "project_longitud" : access.project.longitud,
                "project_id" : access.project.id
            }

            response_by_project.append(structured_response)


        return HttpResponse(Utilities.json_to_dumps(response_by_project), 'application/json; charset=utf-8')
Exemple #6
0
    def get(self, request):

        project_id = request.GET.get('project_id')
        response = api.EstimatesReport.getReport(project_id)

        return HttpResponse(Utilities.json_to_dumps(response), 'application/json; charset=utf-8')
Exemple #7
0
    def get(self, request, *args, **kwargs):
        project_id = request.GET.get(
            'project')  # Getting the type fpr the request.

        project = Project.objects.filter(id=project_id)[0]
        response = {
            "id": project.id,
            "key": project.key,
            "propietario": project.propietario.nombrePropietario,
            "nombreProyecto": project.nombreProyecto,
            "fecha_inicial": str(project.fecha_inicial),
            "fecha_final": str(project.fecha_final),
            "tipo_construccion":
            project.tipo_construccion.nombreTipoConstruccion,
            "ubicacion_calle": project.ubicacion_calle,
            "ubicacion_numero": project.ubicacion_numero,
            "ubicacion_colonia": project.ubicacion_colonia,
            "ubicacion_pais": project.ubicacion_pais.nombrePais,
            "ubicacion_estado": project.ubicacion_estado.nombreEstado,
            "ubicacion_municipio": project.ubicacion_municipio.nombreMunicipio,
            "ubicacion_cp": project.ubicacion_cp,
            "area_superficie_escritura": project.area_superficie_escritura,
            "area_superficie_levantamiento":
            project.area_superficie_levantamiento,
            "estadolegal_documento_propiedad":
            project.estadolegal_documento_propiedad,
            "estadolegal_gravamen": project.estadolegal_gravamen,
            "estadolegal_predial": project.estadolegal_predial,
            "estadolegal_agua": project.estadolegal_agua,
            #"documento_propiedad": project.documento_propiedad,
            #"documento_gravamen": project.documento_gravamen,
            #"documento_agua": project.documento_agua,
            #"documento_predial": project.documento_predial,
            "restriccion_vial": project.restriccion_vial,
            "restriccion_cna": project.restriccion_cna,
            "restriccion_cfe": project.restriccion_cfe,
            "restriccion_pemex": project.restriccion_pemex,
            "restriccion_inha": project.restriccion_inha,
            "restriccion_otros": project.restriccion_otros,
            "restriccion_observaciones": project.restriccion_observaciones,
            "usosuelo_pmdu": project.usosuelo_pmdu,
            "usosuelo_densidad": project.usosuelo_densidad,
            "usosuelo_loteminimo": project.usosuelo_loteminimo,
            "usosuelo_m2construccion": project.usosuelo_m2construccion,
            "usosuelo_arealibre": project.usosuelo_arealibre,
            "usosuelo_altura": project.usosuelo_altura,
            "usosuelo_densidadrequerida": project.usosuelo_densidadrequerida,
            "hidraulica_fuente": project.hidraulica_fuente,
            "hidraulica_distancia": project.hidraulica_distancia,
            "hidraulica_observaciones": project.hidraulica_observaciones,
            #hidraulica_documento": project.hidraulica_documento,
            "sanitaria_tipo": project.sanitaria_tipo,
            "sanitaria_responsable": project.sanitaria_responsable,
            "sanitaria_observaciones": project.sanitaria_observaciones,
            #"sanitaria_documento": project.sanitaria_documento,
            "pluvial_tipo": project.pluvial_tipo,
            "pluvial_responsable": project.pluvial_responsable,
            "pluvial_observaciones": project.pluvial_observaciones,
            #"pluvial_documento": project.pluvial_documento.name,
            "vial_viaacceso": project.vial_viaacceso,
            "vial_distancia": project.vial_distancia,
            "vial_carriles": project.vial_carriles,
            "vial_seccion": project.vial_seccion,
            "vial_tipopavimento": project.vial_tipopavimento,
            "vial_estadoconstruccion": project.vial_estadoconstruccion,
            "vial_observaciones": project.vial_observaciones,
            #"vial_documento": project.vial_documento,
            "electricidad_tipo": project.electricidad_tipo,
            "electricidad_distancia": project.electricidad_distancia,
            "electricidad_observaciones": project.electricidad_observaciones,
            #"electricidad_documento": project.electricidad_documento,
            "alumbradopublico_tipo": project.alumbradopublico_tipo,
            "alumbradopublico_distancia": project.alumbradopublico_distancia,
            "alumbradopublico_observaciones":
            project.alumbradopublico_observaciones,
            #"alumbradopublico_documento": project.alumbradopublico_documento,
            "telefonia_distancia": project.telefonia_distancia,
            "telefonia_observaciones": project.telefonia_observaciones,
            #"telefonia_documento": project.telefonia_documento.name,
            "tvcable_distancia": project.tvcable_distancia,
            "tvcable_observaciones": project.tvcable_observaciones,
            "equipamiento_a100": project.equipamiento_a100,
            "equipamiento_a200": project.equipamiento_a200,
            "equipamiento_a500": project.equipamiento_a500,
            "equipamiento_regional": project.equipamiento_regional,
            "costo_predio": project.costo_predio,
            "costo_m2": project.costo_m2,
            "costo_escrituras": project.costo_escrituras,
            "costo_levantamiento": project.costo_levantamiento,
            "estudiomercado_demanda": project.estudiomercado_demanda,
            "estudiomercado_oferta": project.estudiomercado_oferta,
            "estudiomercado_conclusiones": project.estudiomercado_conclusiones,
            "estudiomercado_recomendaciones":
            project.estudiomercado_recomendaciones,
            "definicionproyecto_alternativa":
            project.definicionproyecto_alternativa,
            "definicionproyecto_tamano": project.definicionproyecto_tamano,
            "definicionproyecto_programa": project.definicionproyecto_programa,
            #"programayarea_areaprivativa": project.programayarea_areaprivativa,
            #"programayarea_caseta": project.programayarea_caseta,
            #"programayarea_jardin": project.programayarea_jardin,
            #"programayarea_vialidad": project.programayarea_vialidad,
            #"programayarea_areaverde": project.programayarea_areaverde,
            #"programayarea_estacionamientovisita": project.programayarea_estacionamientovisita,
            #"programayarea_afectacion": project.programayarea_afectacion,
            #"programayarea_documento": project.programayarea_documento,
            "latitud": project.latitud,
            "longitud": project.longitud
        }

        response = Utilities.clean_generic_queryset_from_nones(response)
        response = Utilities.clean_generic_queryset(response)

        print "Cleaned:"
        print response

        return HttpResponse(
            Utilities.json_to_dumps(response[0]),
            'application/json',
        )
Exemple #8
0
    def get(self, request, *args, **kwargs):
        fiscal_period_year = request.GET.get('fiscal_period_year')

        fiscal_period_month = request.GET.get('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')

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

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

        engine = TransactionsEngine(fiscal_period_year=fiscal_period_year,
                                    fiscal_period_month=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)

        transactions = engine.search_transactions()

        # Grouping all the transactions by accounts.
        grouped_transactions = self.group_transactions_by_account(transactions)

        # Excluding the accounts that overpass the debit limits.
        grouped_transactions = self.exclude_debit_limits(
            lower_debit, upper_debit, grouped_transactions)

        # Excluding the accounts that overpass the credit limits.
        grouped_transactions = self.exclude_credit_limits(
            lower_credit, upper_credit, grouped_transactions)

        response = {'accounts': []}

        for account in grouped_transactions:
            response['accounts'].append({
                'account_id':
                account['account__id'],
                'account_name':
                account['account__name'],
                'account_number':
                str(account['account__number']),
                'total_credit':
                account['total_credit'],
                'total_debit':
                account['total_debit']
            })

        return HttpResponse(
            Utilities.json_to_dumps(response),
            'application/json; charset=utf-8',
        )
Exemple #9
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',
            )