Beispiel #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
Beispiel #2
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
Beispiel #3
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