Example #1
0
 def get_statistics_article(self):
     art_list = []
     if self.fiscal_year is not None:
         total_art = 0
         articles = {}
         for det in Detail.objects.filter(Q(bill__fiscal_year=self.fiscal_year) & Q(
                 bill__bill_type__in=(1, 2, 3)) & Q(bill__status__in=(1, 3))):
             if det.article_id not in articles.keys():
                 articles[det.article_id] = [0, 0]
             if det.bill.bill_type == 2:
                 articles[det.article_id][0] -= det.get_total_excltax()
                 articles[det.article_id][1] -= float(det.quantity)
                 total_art -= det.get_total_excltax()
             else:
                 articles[det.article_id][0] += det.get_total_excltax()
                 articles[det.article_id][1] += float(det.quantity)
                 total_art += det.get_total_excltax()
         for art_id in articles.keys():
             if art_id is None:
                 art_text = "---"
             else:
                 art_text = six.text_type(Article.objects.get(id=art_id))
             if abs(articles[art_id][1]) > 0.0001:
                 art_list.append((art_text,
                                  format_devise(articles[art_id][0], 5),
                                  "%.2f" % articles[art_id][1],
                                  format_devise(
                                      articles[art_id][0] / articles[art_id][1], 5),
                                  "%.2f %%" % (100 * articles[art_id][0] / total_art), articles[art_id][0]))
         art_list.sort(key=lambda art_item: art_item[5], reverse=True)
         art_list.append(("{[b]}%s{[/b]}" % _('total'), "{[b]}%s{[/b]}" % format_devise(total_art, 5),
                          "{[b]}---{[/b]}", "{[b]}---{[/b]}",
                          "{[b]}%.2f %%{[/b]}" % 100, total_art))
     return art_list
Example #2
0
 def fill_part_of_grid(self,
                       current_filter,
                       query_budget,
                       index_begin,
                       title,
                       sign_value=None):
     data_line, total1, total2, totalb = convert_query_to_account(
         self.filter & current_filter,
         self.lastfilter & current_filter,
         query_budget=query_budget,
         sign_value=sign_value)
     add_cell_in_grid(self.grid, index_begin, 'design',
                      get_spaces(5) + '{[u]}%s{[/u]}' % title)
     line_idx = index_begin + 1
     for data_item in data_line:
         add_cell_in_grid(self.grid, line_idx, 'design', data_item[0])
         add_cell_in_grid(self.grid, line_idx, 'year_n',
                          format_devise(data_item[1], 5))
         add_cell_in_grid(self.grid, line_idx, 'budget_n',
                          format_devise(data_item[3], 5))
         if self.next_year is not None:
             add_cell_in_grid(self.grid, line_idx, 'budget_n1',
                              format_devise(data_item[4], 5))
         if self.next_year_again is not None:
             add_cell_in_grid(self.grid, line_idx, 'budget_n2',
                              format_devise(data_item[5], 5))
         if self.item.last_fiscalyear is not None:
             add_cell_in_grid(self.grid, line_idx, 'year_n_1',
                              format_devise(data_item[2], 5))
         line_idx += 1
     add_cell_in_grid(self.grid, line_idx, 'design', '')
     line_idx += 1
     add_cell_in_grid(self.grid, line_idx, 'design',
                      get_spaces(5) + "{[u]}%s{[/u]}" % _('total'))
     add_cell_in_grid(self.grid, line_idx, 'year_n',
                      "{[u]}%s{[/u]}" % format_devise(total1, 5))
     add_cell_in_grid(self.grid, line_idx, 'budget_n',
                      "{[u]}%s{[/u]}" % format_devise(totalb[0], 5))
     if self.next_year is not None:
         add_cell_in_grid(self.grid, line_idx, 'budget_n1',
                          "{[u]}%s{[/u]}" % format_devise(totalb[1], 5))
     if self.next_year_again is not None:
         add_cell_in_grid(self.grid, line_idx, 'budget_n2',
                          "{[u]}%s{[/u]}" % format_devise(totalb[2], 5))
     if self.item.last_fiscalyear is not None:
         add_cell_in_grid(self.grid, line_idx, 'year_n_1',
                          "{[u]}%s{[/u]}" % format_devise(total2, 5))
     line_idx += 1
     add_cell_in_grid(self.grid, line_idx, 'design', '')
     return line_idx, total1, total2, totalb
Example #3
0
 def get_payoff_not_deposit(cls, payer, reference, order_list):
     payoff_nodeposit = []
     entity_known = DepositDetail.objects.values_list(
         'payoff__entry_id', flat=True).distinct()
     entity_unknown = Payoff.objects.filter(supporting__is_revenu=True, mode=1).exclude(entry_id__in=entity_known).values(
         'entry_id', 'date', 'reference', 'payer').annotate(amount=Sum('amount'))
     if payer != '':
         entity_unknown = entity_unknown.filter(payer__contains=payer)
     if reference != '':
         entity_unknown = entity_unknown.filter(
             reference__contains=reference)
     if order_list is not None:
         entity_unknown = entity_unknown.order_by(*order_list)
     for values in entity_unknown:
         payoff = {}
         payoff['id'] = values['entry_id']
         bills = []
         for supporting in Supporting.objects.filter(payoff__entry=values['entry_id']):
             bills.append(six.text_type(supporting.get_final_child()))
         payoff['bill'] = '{[br/]}'.join(bills)
         payoff['payer'] = values['payer']
         payoff['amount'] = format_devise(values['amount'], 5)
         payoff['date'] = values['date']
         payoff['reference'] = values['reference']
         payoff_nodeposit.append(payoff)
     return payoff_nodeposit
Example #4
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)
Example #5
0
 def total(self):
     if Params.getvalue("invoice-vat-mode") == 2:
         return self.total_incltax
     elif Params.getvalue("invoice-vat-mode") == 1:
         return self.total_excltax
     else:
         return format_devise(self.get_total(), 5)
Example #6
0
 def fill_body(self):
     line_idx = 0
     total1 = 0
     total2 = 0
     totalb = [0]
     revenue_account = Params.getvalue(
         "condominium-exceptional-revenue-account")
     for classloaditem in Set.objects.filter(type_load=1, is_active=True):
         current_request = Q(account__code__regex=current_system_account().
                             get_expence_mask())
         current_request |= Q(account__code__regex=current_system_account(
         ).get_revenue_mask()) & ~Q(account__code=revenue_account)
         current_request &= Q(costaccounting__setcost__set=classloaditem)
         query_budget = [
             ~Q(code=revenue_account)
             & Q(cost_accounting=classloaditem.current_cost_accounting)
             & Q(year=self.item)
         ]
         line__current_dep, subtotal1, subtotal2, subtotalb = self.fill_part_of_grid(
             current_request,
             query_budget,
             line_idx,
             six.text_type(classloaditem),
             sign_value=False)
         total_call = classloaditem.get_total_calloffund(self.item)
         add_cell_in_grid(self.grid, line__current_dep - 1, 'calloffund',
                          "{[u]}%s{[/u]}" % format_devise(total_call, 5))
         add_cell_in_grid(
             self.grid, line__current_dep - 1, 'result',
             "{[u]}%s{[/u]}" % format_devise(total_call - subtotal1, 5))
         line_idx = line__current_dep + 1
         total1 += subtotal1
         total2 += subtotal2
         totalb[0] += subtotalb[0]
     add_cell_in_grid(self.grid, line_idx, 'design',
                      get_spaces(5) + "{[b]}%s{[/b]}" % _('total'))
     add_cell_in_grid(self.grid, line_idx, 'year_n',
                      "{[b]}%s{[/b]}" % format_devise(total1, 5))
     add_cell_in_grid(self.grid, line_idx, 'budget_n',
                      "{[b]}%s{[/b]}" % format_devise(totalb[0], 5))
Example #7
0
 def get_statistics_customer(self):
     cust_list = []
     if self.fiscal_year is not None:
         total_cust = 0
         costumers = {}
         for bill in Bill.objects.filter(Q(fiscal_year=self.fiscal_year) & Q(
                 bill_type__in=(1, 2, 3)) & Q(status__in=(1, 3))):
             if bill.third_id not in costumers.keys():
                 costumers[bill.third_id] = 0
             if bill.bill_type == 2:
                 costumers[bill.third_id] -= bill.get_total_excltax()
                 total_cust -= bill.get_total_excltax()
             else:
                 costumers[bill.third_id] += bill.get_total_excltax()
                 total_cust += bill.get_total_excltax()
         for cust_id in costumers.keys():
             cust_list.append((six.text_type(Third.objects.get(id=cust_id)),
                               format_devise(costumers[cust_id], 5),
                               "%.2f %%" % (100 * costumers[cust_id] / total_cust), costumers[cust_id]))
         cust_list.sort(
             key=lambda cust_item: (-1 * cust_item[3], cust_item[0]))
         cust_list.append(("{[b]}%s{[/b]}" % _('total'), "{[b]}%s{[/b]}" % format_devise(total_cust, 5),
                           "{[b]}%.2f %%{[/b]}" % 100, total_cust))
     return cust_list
Example #8
0
 def get_txt(self, content_item):
     item = Adherent.objects.get(id=content_item["adherent"])
     cmd_value = {}
     cmd_value["adherent"] = six.text_type(item)
     cmd_value["type"] = SubscriptionType.objects.get(id=content_item["type"]).get_text_value()
     cmd_value["age"] = item.age_category
     teams = []
     for team in Team.objects.filter(id__in=content_item["team"]):
         teams.append(six.text_type(team))
     cmd_value["team"] = '{[br/]}'.join(teams)
     activities = []
     for team in Activity.objects.filter(id__in=content_item["activity"]):
         activities.append(six.text_type(team))
     cmd_value["activity"] = '{[br/]}'.join(activities)
     cmd_value["licence"] = '{[br/]}'.join(content_item["licence"])
     cmd_value["reduce"] = format_devise(content_item["reduce"], 5)
     return cmd_value
Example #9
0
def finalizeyear_condo(xfer):
    year = FiscalYear.get_current(xfer.getparam('year'))
    if year is not None:
        ventilate = xfer.getparam("ventilate", 0)
        if xfer.observer_name == "core.custom":
            if year.check_to_close() > 0:
                raise LucteriosException(
                    IMPORTANT, _("This fiscal year has entries not closed!"))
            result = year.total_revenue - year.total_expense
            if abs(result) > 0.001:
                row = xfer.get_max_row() + 1
                lbl = XferCompLabelForm('title_condo')
                lbl.set_value(
                    _('This fiscal year has a result no null equals to %s.') %
                    format_devise(result, 5))
                lbl.set_location(0, row, 2)
                xfer.add_component(lbl)
                lbl = XferCompLabelForm('question_condo')
                lbl.set_value(_('Where do you want to ventilate this amount?'))
                lbl.set_location(0, row + 1)
                xfer.add_component(lbl)
                sel_cmpt = [('0', _("For each owner"))]
                for account in year.chartsaccount_set.filter(
                        type_of_account=2).order_by('code'):
                    sel_cmpt.append((account.id, six.text_type(account)))
                sel = XferCompSelect("ventilate")
                sel.set_select(sel_cmpt)
                sel.set_value(ventilate)
                sel.set_location(1, row + 1)
                xfer.add_component(sel)
        elif xfer.observer_name == "core.acknowledge":
            for set_cost in year.setcost_set.filter(year=year,
                                                    set__is_active=True,
                                                    set__type_load=0):
                if ventilate == 0:
                    current_system_condo().ventilate_costaccounting(
                        set_cost.set, set_cost.cost_accounting, 1,
                        Params.getvalue("condominium-current-revenue-account"))
                set_cost.cost_accounting.close()
            current_system_condo().ventilate_result(year, ventilate)
Example #10
0
 def total_rest_topay(self):
     return format_devise(self.get_total_rest_topay(), 5)
Example #11
0
def finalizeyear_condo(xfer):
    year = FiscalYear.get_current(xfer.getparam('year'))
    if year is not None:
        ventilate = xfer.getparam("ventilate", 0)
        if xfer.observer_name == "core.custom":
            if year.check_to_close() > 0:
                raise LucteriosException(IMPORTANT, _("This fiscal year has entries not closed!"))
            result = year.total_revenue - year.total_expense
            if abs(result) > 0.001:
                row = xfer.get_max_row() + 1
                lbl = XferCompLabelForm('title_condo')
                lbl.set_value(_('This fiscal year has a result no null equals to %s.') % format_devise(result, 5))
                lbl.set_location(0, row, 2)
                xfer.add_component(lbl)
                lbl = XferCompLabelForm('question_condo')
                lbl.set_value(_('Where do you want to ventilate this amount?'))
                lbl.set_location(0, row + 1)
                xfer.add_component(lbl)
                sel_cmpt = [('0', _("For each owner"))]
                for account in year.chartsaccount_set.filter(type_of_account=2).order_by('code'):
                    sel_cmpt.append((account.id, six.text_type(account)))
                sel = XferCompSelect("ventilate")
                sel.set_select(sel_cmpt)
                sel.set_value(ventilate)
                sel.set_location(1, row + 1)
                xfer.add_component(sel)
        elif xfer.observer_name == "core.acknowledge":
            for set_cost in year.setcost_set.filter(year=year, set__is_active=True, set__type_load=0):
                if ventilate == 0:
                    set_cost.set.ventilate_costaccounting(set_cost.cost_accounting, 1,
                                                          Params.getvalue("condominium-current-revenue-account"))
                set_cost.cost_accounting.close()
            ventilate_result(year, ventilate)
Example #12
0
 def price(self):
     total_price = 0
     for art in self.articles.all():
         total_price += art.price
     return format_devise(total_price, 5)
Example #13
0
 def vta_details(self):
     vtas = []
     for value in self.get_vta_details().values():
         vtas.append(format_devise(value, 5))
     return "{[br/]}".join(vtas)
Example #14
0
 def total(self):
     return format_devise(self.get_total(), 5)
Example #15
0
 def amount(self):
     return format_devise(self.get_amount(), 5)
Example #16
0
 def fill_body(self):
     line_idx = 0
     total1 = 0
     total2 = 0
     totalb = [0, 0, 0]
     revenue_account = Params.getvalue(
         "condominium-current-revenue-account")
     initial_filter = self.filter
     initial_lastfilter = self.lastfilter
     for classloaditem in Set.objects.filter(type_load=0, is_active=True):
         current_costaccounting = classloaditem.setcost_set.filter(
             year=self.item).first().cost_accounting
         current_request = Q(account__code__regex=current_system_account().
                             get_expence_mask())
         current_request |= Q(account__code__regex=current_system_account(
         ).get_revenue_mask()) & ~Q(account__code=revenue_account)
         if initial_filter is not None:
             self.filter = initial_filter & Q(
                 costaccounting_id=current_costaccounting.id)
         if initial_lastfilter is not None:
             self.lastfilter = initial_lastfilter & Q(
                 costaccounting_id=current_costaccounting.
                 last_costaccounting_id)
         query_budget = [
             ~Q(code=revenue_account)
             & Q(cost_accounting=current_costaccounting)
         ]
         if self.next_year is not None:
             set_cost = classloaditem.setcost_set.filter(
                 year=self.next_year).first()
             if set_cost is None:
                 set_cost = classloaditem.create_new_cost(
                     year=self.next_year)
             query_budget.append(~Q(code=revenue_account) & Q(
                 cost_accounting=set_cost.cost_accounting))
         if self.next_year_again is not None:
             set_cost = classloaditem.setcost_set.filter(
                 year=self.next_year_again).first()
             if set_cost is None:
                 set_cost = classloaditem.create_new_cost(
                     year=self.next_year_again)
             query_budget.append(~Q(code=revenue_account) & Q(
                 cost_accounting=set_cost.cost_accounting))
         line__current_dep, subtotal1, subtotal2, subtotalb = self.fill_part_of_grid(
             current_request,
             query_budget,
             line_idx,
             six.text_type(classloaditem),
             sign_value=False)
         line_idx = line__current_dep + 1
         total1 += subtotal1
         total2 += subtotal2
         totalb[0] += subtotalb[0]
         if self.next_year is not None:
             totalb[1] += subtotalb[1]
         if self.next_year_again is not None:
             totalb[2] += subtotalb[2]
     add_cell_in_grid(self.grid, line_idx, 'design',
                      get_spaces(5) + "{[b]}%s{[/b]}" % _('total'))
     add_cell_in_grid(self.grid, line_idx, 'year_n',
                      "{[b]}%s{[/b]}" % format_devise(total1, 5))
     add_cell_in_grid(self.grid, line_idx, 'budget_n',
                      "{[b]}%s{[/b]}" % format_devise(totalb[0], 5))
     if self.item.last_fiscalyear is not None:
         add_cell_in_grid(self.grid, line_idx, 'year_n_1',
                          "{[b]}%s{[/b]}" % format_devise(total2, 5))
     if self.next_year is not None:
         add_cell_in_grid(self.grid, line_idx, 'budget_n1',
                          "{[b]}%s{[/b]}" % format_devise(totalb[1], 5))
     if self.next_year_again is not None:
         add_cell_in_grid(self.grid, line_idx, 'budget_n2',
                          "{[b]}%s{[/b]}" % format_devise(totalb[2], 5))
Example #17
0
 def vta_sum(self):
     return format_devise(self.get_vta_sum(), 5)
Example #18
0
 def total_payed(self):
     return format_devise(self.get_total_payed(), 5)
Example #19
0
 def price_vta(self):
     return format_devise(self.get_vta(), 5)
Example #20
0
 def total_incltax(self):
     return format_devise(self.get_total_incltax(), 5)
Example #21
0
 def price_txt(self):
     return format_devise(self.get_price(), 5)
Example #22
0
 def reduce_txt(self):
     if self.reduce > 0.0001:
         return "%s(%.2f%%)" % (format_devise(self.get_reduce(), 5), 100 * self.get_reduce() / (self.get_price() * float(self.quantity)))
     else:
         return None
Example #23
0
 def value(self):
     return format_devise(self.amount, 5)
Example #24
0
 def price_txt(self):
     return format_devise(self.price, 5)