Exemplo n.º 1
0
    def fillresponse_body(self):
        self.get_components("title").colspan = 2
        row_id = self.get_max_row() + 1
        lbl = XferCompLabelForm('title_exp')
        lbl.set_value_as_headername(_("Expense"))
        lbl.set_location(0, row_id, 2)
        self.add_component(lbl)
        lbl = XferCompLabelForm('title_rev')
        lbl.set_value_as_headername(_("Revenue"))
        lbl.set_location(2, row_id, 2)
        self.add_component(lbl)

        row_id = self.get_max_row()
        self.fill_grid(row_id, self.model, 'budget_revenue', self.model.objects.filter(self.filter & Q(code__regex=current_system_account().get_revenue_mask())))
        self.move_components('budget_revenue', 2, 0)
        self.fill_grid(row_id, self.model, 'budget_expense', self.model.objects.filter(self.filter & Q(code__regex=current_system_account().get_expence_mask())))
        self.remove_component('nb_budget_expense')
        self.remove_component('nb_budget_revenue')

        resultat_budget = Budget.get_total(self.getparam('year'), self.getparam('cost_accounting'))
        if abs(resultat_budget) > 0.0001:
            row_id = self.get_max_row() + 1
            lbl = XferCompLabelForm('title_result')
            if resultat_budget > 0:
                lbl.set_value_as_name(_('result (profit)'))
            else:
                lbl.set_value_as_name(_('result (deficit)'))
            lbl.set_location(0, row_id)
            self.add_component(lbl)
            lbl = XferCompLabelForm('result')
            lbl.set_value(format_devise(resultat_budget, 5))
            lbl.set_location(1, row_id)
            self.add_component(lbl)