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', data_item[1]) add_cell_in_grid(self.grid, line_idx, 'budget_n', data_item[3]) if self.next_year is not None: add_cell_in_grid(self.grid, line_idx, 'budget_n1', data_item[4]) if self.next_year_again is not None: add_cell_in_grid(self.grid, line_idx, 'budget_n2', data_item[5]) if self.item.last_fiscalyear is not None: add_cell_in_grid(self.grid, line_idx, 'year_n_1', data_item[2]) 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', total1, "{[u]}%s{[/u]}") add_cell_in_grid(self.grid, line_idx, 'budget_n', totalb[0], "{[u]}%s{[/u]}") if self.next_year is not None: add_cell_in_grid(self.grid, line_idx, 'budget_n1', totalb[1], "{[u]}%s{[/u]}") if self.next_year_again is not None: add_cell_in_grid(self.grid, line_idx, 'budget_n2', totalb[2], "{[u]}%s{[/u]}") if self.item.last_fiscalyear is not None: add_cell_in_grid(self.grid, line_idx, 'year_n_1', total2, "{[u]}%s{[/u]}") line_idx += 1 add_cell_in_grid(self.grid, line_idx, 'design', '') return line_idx, total1, total2, totalb
def fill_part_of_grid(self, side, current_filter, index_begin, title, sign_value=None, with_third=False): data_line, total1, total2, _totalb = convert_query_to_account(self.filter & current_filter, self.lastfilter & current_filter, sign_value=sign_value, with_third=with_third) add_cell_in_grid(self.grid, index_begin, side, get_spaces(5) + '{[u]}%s{[/u]}' % title) line_idx = index_begin + 1 line_idx = fill_grid(self.grid, line_idx, side, data_line) add_cell_in_grid(self.grid, line_idx, side, '') line_idx += 1 return line_idx, total1, total2
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): first_setcost = classloaditem.setcost_set.filter(year=self.item).first() if first_setcost is None: continue current_costaccounting = first_setcost.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, str(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', total1, "{[b]}%s{[/b]}") add_cell_in_grid(self.grid, line_idx, 'budget_n', totalb[0], "{[b]}%s{[/b]}") if self.item.last_fiscalyear is not None: add_cell_in_grid(self.grid, line_idx, 'year_n_1', total2, "{[b]}%s{[/b]}") if self.next_year is not None: add_cell_in_grid(self.grid, line_idx, 'budget_n1', totalb[1], "{[b]}%s{[/b]}") if self.next_year_again is not None: add_cell_in_grid(self.grid, line_idx, 'budget_n2', totalb[2], "{[b]}%s{[/b]}")
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))
def fill_body(self): line__tresor, total1_tresor, total2_tresor = self.fill_part_of_grid( 'left', Q(account__code__regex=current_system_account().get_cash_mask()), 0, _('Tresory')) line__capital, total1_capital, total2_capital = self.fill_part_of_grid( 'right', Q(account__type_of_account=2), 0, _('Provision and advance')) line_idx = max(line__tresor, line__capital) add_item_in_grid(self.grid, line_idx, 'left', (_('total'), total1_tresor, total2_tresor, None), get_spaces(5) + "{[u]}%s{[/u]}") add_item_in_grid(self.grid, line_idx, 'right', (_('total'), total1_capital, total2_capital, None), get_spaces(5) + "{[u]}%s{[/u]}") add_cell_in_grid(self.grid, line_idx + 1, 'left', '') add_cell_in_grid(self.grid, line_idx + 1, 'right', '') last_ids = [] try: last_ids.append( EntryAccount.objects.filter( year=self.item).order_by('-id')[0].id) except IndexError: last_ids.append(0) if self.item.last_fiscalyear is not None: try: last_ids.append( EntryAccount.objects.filter( year=self.item.last_fiscalyear).order_by('-id')[0].id) except IndexError: last_ids.append(0) current_filter = Q(account__type_of_account__in=(0, 1)) & ~Q( account__code__regex=current_system_account().get_cash_mask()) current_filter &= ( ~Q(entry__year__status=2) | ~(Q(entry__journal=5) & Q(entry__id__in=tuple(last_ids)))) line__creance, total1_creance, total2_creance = self.fill_part_of_grid( 'left', current_filter, line_idx + 2, _('Créance'), sign_value=-1, with_third=True) line__dette, total1_dette, total2_dette = self.fill_part_of_grid( 'right', current_filter, line_idx + 2, _('Dettes'), sign_value=1, with_third=True) line_idx = max(line__creance, line__dette) add_item_in_grid(self.grid, line_idx, 'left', (_('total'), total1_creance, total2_creance, None), get_spaces(5) + "{[u]}%s{[/u]}") add_item_in_grid(self.grid, line_idx, 'right', (_('total'), total1_dette, total2_dette, None), get_spaces(5) + "{[u]}%s{[/u]}") add_cell_in_grid(self.grid, line_idx + 1, 'left', '') add_cell_in_grid(self.grid, line_idx + 1, 'right', '') add_item_in_grid(self.grid, line_idx + 2, 'left', (_('total'), total1_tresor + total1_creance, total2_tresor + total2_creance, None), get_spaces(5) + "{[b]}%s{[/b]}") add_item_in_grid(self.grid, line_idx + 2, 'right', (_('total'), total1_capital + total1_dette, total2_capital + total2_dette, None), get_spaces(5) + "{[b]}%s{[/b]}")