Exemplo n.º 1
0
    def get_context_data(self, **kwargs):
        context = super(LineItemListView, self).get_context_data(**kwargs)
        context['title_list'] = LineItemListView.title_list + LineItemListView.current_type_full
        context['project_id'] = LineItemListView.project_id
        context['query'] = LineItemListView.query
        context['query_string'] = '&q=' + LineItemListView.query
        context['has_query'] = (LineItemListView.query is not None) and (LineItemListView.query != "")
        context['current_type_full'] = LineItemListView.current_type_full

        # Getting the concept inputs for the selected Line Item parent.
        ciqs = Concept_Input.objects.filter(
            Q(line_item=LineItemListView.parent_id) & Q(type=LineItemListView.current_type))

        for item in ciqs:
            item.total = Utilities.number_to_currency(item.quantity * item.unit_price)

        context['concepts_inputs'] = ciqs

        if LineItemListView.parent_id is not None:
            context['parent_line_item'] = LineItem.objects.get(pk=LineItemListView.parent_id)

        if LineItemListView.current_type == 'C':
            context['add_url'] = LineItemListView.add_url + LineItemListView.url_c + str(LineItemListView.project_id)
        else:
            context['add_url'] = LineItemListView.add_url + LineItemListView.url_i + str(LineItemListView.project_id)

        print "Concept / Inputs"
        print context['concepts_inputs']
        return context
Exemplo n.º 2
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')
Exemplo n.º 3
0
    def get_context_data(self, **kwargs):
        context = super(ContractorContractDetailView, self).get_context_data(**kwargs)
        contract_id = self.kwargs['pk']
        context['concepts'] = ContractConcepts.objects.filter(Q(contract__id=contract_id))
        # Getting, if exists, the advance payment for the contract
        try:
            estimate = Estimate.objects.get(contract__id=contract_id)
        except Estimate.DoesNotExist:
            estimate = None

        advance_payment = None
        advance_payment_status = ""

        if estimate:
            advance_payment = estimate.advance_payment_amount

        if advance_payment == None:
            advance_payment = "No se ha registrado un anticipo."
            advance_payment_status = "Estatus no disponible."
        else:
            advance_payment = Utilities.number_to_currency(advance_payment)
            advance_payment_status = estimate.get_advance_payment_status_display()

        context['advance_payment'] = advance_payment
        context['advance_payment_status'] = advance_payment_status

        return context
Exemplo n.º 4
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',
        )
Exemplo n.º 5
0
    def process_exception(self):
        obj = SystemLogEntry(label=self.type,
                             information=Utilities.json_to_safe_string(
                                 self.get_information()),
                             priority=self.priority,
                             user_id=self.user_id)

        obj.save()
Exemplo n.º 6
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',
        )
Exemplo n.º 7
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',
        )
Exemplo n.º 8
0
    def post(self, request, *args, **kwargs):
        pel_id = request.POST.get(
            'pel_id')  # Reading the Progress Estimate Log Id to filter by.
        print "Received Id: " + str(pel_id)
        log_files = LogFile.objects.filter(
            Q(progress_estimate_log__id=pel_id))  # Filtering the log files.

        json_files = Utilities.query_set_to_json_string(log_files)
        return HttpResponse(
            json_files,
            'application/json',
        )
Exemplo n.º 9
0
def progress_estimate_log_view(request):
    project = request.GET.get('project')
    concept = request.GET.get('concept')
    estimate = request.GET.get('estimate')
    progress_estimate = request.GET.get('progress_estimate')

    # Retrieving data from the model to be rendered.
    if progress_estimate is None:
        logs_queryset = ProgressEstimateLog.objects.all()
    else:
        logs_queryset = ProgressEstimateLog.objects.first(Q(progress_estimate=progress_estimate))

    if logs_queryset:
        # As both cases where treated as querysets, we can retrieve the first id.
        progress_estimate_id = logs_queryset.first().progress_estimate.id
        logs = []
        for log in logs_queryset:
            user_fullname = log.user.user.first_name + " " + log.user.user.last_name
            log = log.to_serializable_dict()
            log['user_fullname'] = user_fullname
            logs.append(log)

        log_files = []
        if logs:
            log_files = LogFile.objects.filter(Q(progress_estimate_log__id=logs[0]['id']))

        params = {
            'logs': Utilities.json_to_safe_string(logs),
            'log_files': Utilities.query_set_to_json_string(log_files),
            'progress_estimate_id': progress_estimate_id
        }

    else:
        params = {
            'logs': [],
            'log_files': [],
            'progress_estimate_id': ProgressEstimate.objects.all().first().id
        }

    return render(request, 'ProgressEstimateLog/progress_estimate_log_form.html', params)
Exemplo n.º 10
0
    def get_context_data(self, **kwargs):
        context = super(EstimateDetailView, self).get_context_data(**kwargs)

        # Shallow copy for the main object.
        estimate = context['estimate']
        estimate.deduction_amount = Utilities.number_to_currency(estimate.deduction_amount)
        contract_amount = estimate.contract.monto_contrato
        estimate.contract.monto_contrato = Utilities.number_to_currency(estimate.contract.monto_contrato)
        estimate.contract_amount_override = Utilities.number_to_currency(estimate.contract_amount_override)

        progress_estimates = ProgressEstimate.objects.filter(Q(estimate_id=estimate.id))

        total = estimate.advance_payment_amount
        context['advance_percentage'] = "{0:.0f}%".format(total / contract_amount * 100)

        #estimate.advance_payment_amount = locale.currency(estimate.advance_payment_amount, grouping=True)
        estimate.advance_payment_amount = Utilities.number_to_currency(estimate.advance_payment_amount)

        current_user_can_approve = estimate.user_can_approve(self.request.user.id)
        context['current_user_can_approve'] = current_user_can_approve
        estimate.show_approval_button = not estimate.has_been_approved_by(
            self.request.user.id) and current_user_can_approve

        for record in progress_estimates:
            total += record.amount
            record.amount = Utilities.number_to_currency(record.amount)
            percentage = total / contract_amount
            record.progress = "{0:.0f}%".format(percentage * 100)

            record.show_approval_button = not record.has_been_approved_by(
                self.request.user.id) and current_user_can_approve

        context['progress_estimates'] = progress_estimates

        # Get the concepts specified for the contract
        concepts = estimate.contract.contractconcepts_set.all()

        context['contract_concepts'] = concepts

        return context
Exemplo n.º 11
0
    def get(self, request, *args, **kwargs):
        line_item_id = request.GET.get(
            'line_item')  # Getting the type fpr the request.
        type = request.GET.get('type')  # Getting the type fpr the request.

        qs = Concept_Input.objects.filter(
            Q(type=type) & Q(line_item=line_item_id)).values(
                'id', 'description')
        cleaned_qs = Utilities.clean_generic_queryset(qs)

        return HttpResponse(
            cleaned_qs,
            'application/json',
        )
Exemplo n.º 12
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')
Exemplo n.º 13
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')
Exemplo n.º 14
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',
        )
Exemplo n.º 15
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',
            )
Exemplo n.º 16
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',
        )
Exemplo n.º 17
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',
        )
Exemplo n.º 18
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')
Exemplo n.º 19
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')

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

        # 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_set = engine.search_transactions()

        # Getting the account number.
        account_number = account_number_array[0]

        # Getting the account object.
        account_object = Account.objects.get(number=account_number)

        # Creating the general structure for the response.
        general_structure = self.create_general_structure(
            report_title, fiscal_period_year, fiscal_period_month,
            account_object)

        # Accumulated amounts.
        total_debit = 0
        total_credit = 0

        # Creating the structure for each of the accounts.
        for transaction in transactions_set:
            total_debit += transaction.debit
            total_credit += transaction.credit
            transaction_structure = self.create_transaction_structure(
                transaction)
            general_structure['transactions'].append(transaction_structure)

        # Assigning the accumulated amounts.
        general_structure['total_debit'] = total_debit
        general_structure['total_credit'] = total_credit

        return engine.generate_report(general_structure)