def get_info_state(self): info = [] if self.status == 0: info = Supporting.get_info_state( self, current_system_account().get_customer_mask()) details = self.detail_set.all() if len(details) == 0: info.append(six.text_type(_("no detail"))) else: for detail in details: if detail.article is not None: detail_code = detail.article.sell_account else: detail_code = Params.getvalue( "invoice-default-sell-account") detail_account = None if match(current_system_account().get_revenue_mask(), detail_code) is not None: try: detail_account = ChartsAccount.get_account( detail_code, FiscalYear.get_current()) except LucteriosException: break if detail_account is None: info.append( six.text_type(_("article has code account unknown!"))) break try: info.extend(self.check_date(self.date.isoformat())) except LucteriosException: pass return "{[br/]}".join(info)
def fill_body(self): current_query = Q(costaccounting__setcost__set__type_load=Set.TYPELOAD_CURRENT) & Q(costaccounting__setcost__set__is_active=True) query_budget = Q(code__regex=current_system_account().get_expence_mask()) & Q(cost_accounting__setcost__set__type_load=Set.TYPELOAD_CURRENT) & Q(cost_accounting__setcost__set__is_active=True) budget_query = [Q(year=self.item) & query_budget] if self.next_year is not None: budget_query.append(Q(year=self.next_year) & query_budget) if self.next_year_again is not None: budget_query.append(Q(year=self.next_year_again) & query_budget) line__current_dep, _total1_current_dep, _total2_current_dep, _totalb_current_dep = self.fill_part_of_grid(Q(account__type_of_account=ChartsAccount.TYPE_EXPENSE) & current_query, budget_query, 0, _('Current depency')) query_budget = Q(code__regex=current_system_account().get_revenue_mask()) & Q(cost_accounting__setcost__set__type_load=Set.TYPELOAD_CURRENT) & Q(cost_accounting__setcost__set__is_active=True) budget_query = [Q(year=self.item) & query_budget] if self.next_year is not None: budget_query.append(Q(year=self.next_year) & query_budget) if self.next_year_again is not None: budget_query.append(Q(year=self.next_year_again) & query_budget) line__current_rec, _total1_current_rec, _total2_current_rec, _totalb_current_rec = self.fill_part_of_grid(Q(account__type_of_account=ChartsAccount.TYPE_REVENUE) & current_query, budget_query, line__current_dep + 1, _('Current revenue')) self.next_year = None self.next_year_again = None current_query = Q(costaccounting__setcost__set__type_load=1) & Q(costaccounting__setcost__set__is_active=True) query_budget = Q(year=self.item) & Q(code__regex=current_system_account().get_expence_mask()) & Q(cost_accounting__setcost__set__type_load=Set.TYPELOAD_EXCEPTIONAL) & Q(cost_accounting__setcost__set__is_active=True) budget_query = [query_budget] line__except_dep, _total1_except_dep, _total2_except_dep, _totalb_except_dep = self.fill_part_of_grid(Q(account__type_of_account=ChartsAccount.TYPE_EXPENSE) & current_query, budget_query, line__current_rec + 1, _('Exceptional depency')) query_budget = Q(year=self.item) & Q(code__regex=current_system_account().get_revenue_mask()) & Q(cost_accounting__setcost__set__type_load=Set.TYPELOAD_EXCEPTIONAL) & Q(cost_accounting__setcost__set__is_active=True) budget_query = [query_budget] _line__except_rec, _total1_except_rec, _total2_except_rec, _totalb_except_rec = self.fill_part_of_grid(Q(account__type_of_account=ChartsAccount.TYPE_REVENUE) & current_query, budget_query, line__except_dep + 1, _('Exceptional revenue'))
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 edit(self, xfer): set_comp = xfer.get_components('set') set_comp.set_select_query(Set.objects.filter(is_active=True)) xfer.get_components('price').prec = Params.getvalue( "accounting-devise-prec") old_account = xfer.get_components("expense_account") xfer.remove_component("expense_account") sel_account = XferCompSelect("expense_account") sel_account.description = old_account.description sel_account.set_location(old_account.col, old_account.row, old_account.colspan, old_account.rowspan) for item in FiscalYear.get_current().chartsaccount_set.all().filter( code__regex=current_system_account().get_expence_mask( )).order_by('code'): sel_account.select_list.append((item.code, six.text_type(item))) sel_account.set_value(self.item.expense_account) xfer.add_component(sel_account) self.item.year = FiscalYear.get_current() btn = XferCompButton('add_account') btn.set_location(old_account.col + 1, old_account.row) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.ChartsAccount', 'AddModify', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'year': self.item.year.id}) xfer.add_component(btn) xfer.get_components("set").colspan = old_account.colspan + 1 xfer.get_components("designation").colspan = old_account.colspan + 1 xfer.get_components("price").colspan = old_account.colspan + 1
def before_save(self, xfer): accounts = self.item.third.accountthird_set.filter(code__regex=current_system_account().get_societary_mask()) if len(accounts) == 0: if Params.getvalue("condominium-old-accounting"): AccountThird.objects.create(third=self.item.third, code=correct_accounting_code(Params.getvalue("condominium-default-owner-account"))) else: for num_account in range(1, 5): AccountThird.objects.create(third=self.item.third, code=correct_accounting_code(Params.getvalue("condominium-default-owner-account%d" % num_account))) return SupportingEditor.before_save(self, xfer)
def generate_entry(self): if self.bill_type == 2: is_bill = -1 else: is_bill = 1 third_account = self.get_third_account( current_system_account().get_customer_mask(), self.fiscal_year) self.entry = EntryAccount.objects.create( year=self.fiscal_year, date_value=self.date, designation=self.__str__(), journal=Journal.objects.get(id=3), costaccounting=self.cost_accounting) EntryLineAccount.objects.create( account=third_account, amount=is_bill * self.get_total_incltax(), third=self.third, entry=self.entry) remise_total = 0 detail_list = {} for detail in self.detail_set.all(): if detail.article is not None: detail_code = detail.article.sell_account else: detail_code = Params.getvalue("invoice-default-sell-account") detail_account = ChartsAccount.get_account( detail_code, self.fiscal_year) if detail_account is None: raise LucteriosException( IMPORTANT, _("article has code account unknown!")) if detail_account.id not in detail_list.keys(): detail_list[detail_account.id] = [detail_account, 0] detail_list[detail_account.id][ 1] += detail.get_total_excltax() + detail.get_reduce_excltax() remise_total += detail.get_reduce_excltax() if remise_total > 0.001: remise_code = Params.getvalue("invoice-reduce-account") remise_account = ChartsAccount.get_account( remise_code, self.fiscal_year) if remise_account is None: raise LucteriosException( IMPORTANT, _("reduce-account is not defined!")) EntryLineAccount.objects.create( account=remise_account, amount=-1 * is_bill * remise_total, entry=self.entry) for detail_item in detail_list.values(): EntryLineAccount.objects.create( account=detail_item[0], amount=is_bill * detail_item[1], entry=self.entry) if self.get_vta_sum() > 0.001: vta_code = Params.getvalue("invoice-vatsell-account") vta_account = ChartsAccount.get_account( vta_code, self.fiscal_year) if vta_account is None: raise LucteriosException( IMPORTANT, _("vta-account is not defined!")) EntryLineAccount.objects.create( account=vta_account, amount=is_bill * self.get_vta_sum(), entry=self.entry) no_change, debit_rest, credit_rest = self.entry.serial_control( self.entry.get_serial()) if not no_change or (abs(debit_rest) > 0.001) or (abs(credit_rest) > 0.001): raise LucteriosException( GRAVE, _("Error in accounting generator!") + "{[br/]} no_change=%s debit_rest=%.3f credit_rest=%.3f" % (no_change, debit_rest, credit_rest))
def edit(self, xfer): if xfer.item.id is None: new_account = [] if Params.getvalue("condominium-old-accounting"): new_account.append( Params.getvalue("condominium-default-owner-account")) else: for num_account in LIST_DEFAULT_ACCOUNTS: new_account.append( Params.getvalue("condominium-default-owner-account%d" % num_account)) sel = XferCompSelect('third') sel.needed = True sel.description = _('third') sel.set_location(1, 0) owner_third_ids = [] for owner in Owner.objects.all(): owner_third_ids.append(owner.third_id) items = Third.objects.filter( accountthird__code__regex=current_system_account( ).get_societary_mask()).exclude( id__in=owner_third_ids).distinct() items = sorted(items, key=lambda t: str(t)) sel.set_select_query(items) xfer.add_component(sel) btn = XferCompButton('add_third') btn.set_location(3, 0) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url( 'accounting.Third', 'Add', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'new_account': ';'.join(new_account)}) xfer.add_component(btn) xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"]) else: old_item = xfer.item xfer.item = old_item.third.contact.get_final_child() xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item.third.get_final_child() xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"])
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 check_account_config(self): from diacamma.accounting.tools import current_system_account try: lettering_check = Params.getvalue( "accounting-lettering-check").split('{[br/]}') changed = False new_lettering = [] for letter in lettering_check: if match(current_system_account().get_third_mask(), letter) is not None: new_lettering.append(letter) else: changed = True for account in ChartsAccount.objects.filter( year=FiscalYear.get_current(), code__regex=current_system_account().get_societary_mask()): if account.code not in new_lettering: new_lettering.append(account.code) changed = True if changed: Params.setvalue("accounting-lettering-check", '{[br/]}'.join(new_lettering)) except LucteriosException: pass
def edit(self, xfer): old_account = xfer.get_components("code") xfer.remove_component("code") sel_code = XferCompSelect("code") sel_code.set_location(old_account.col, old_account.row, old_account.colspan + 1, old_account.rowspan) existed_codes = [] for acc_ratio in RecoverableLoadRatio.objects.all(): existed_codes.append(acc_ratio.code) for item in FiscalYear.get_current().chartsaccount_set.all().filter( code__regex=current_system_account().get_expence_mask( )).exclude(code__in=existed_codes).order_by('code'): sel_code.select_list.append((item.code, str(item))) sel_code.set_value(self.item.code) xfer.add_component(sel_code)
def generate_expense_for_expense(self, expense, is_asset, fiscal_year): third_account = expense.get_third_account(current_system_account().get_provider_mask(), fiscal_year) new_entry = EntryAccount.objects.create(year=fiscal_year, date_value=expense.date, designation=expense.__str__(), journal=Journal.objects.get(id=2)) total = 0 for detail in expense.expensedetail_set.all(): detail_account = ChartsAccount.get_account(detail.expense_account, fiscal_year) if detail_account is None: raise LucteriosException(IMPORTANT, _("code account %s unknown!") % detail.expense_account) price = currency_round(detail.price) EntryLineAccount.objects.create(account=detail_account, amount=is_asset * price, entry=new_entry, costaccounting_id=detail.set.current_cost_accounting.id) total += price EntryLineAccount.objects.create(account=third_account, amount=is_asset * total, third=expense.third, entry=new_entry) no_change, debit_rest, credit_rest = new_entry.serial_control(new_entry.get_serial()) if not no_change or (abs(debit_rest) > 0.001) or (abs(credit_rest) > 0.001): raise LucteriosException(GRAVE, _("Error in accounting generator!") + "{[br/]} no_change=%s debit_rest=%.3f credit_rest=%.3f" % (no_change, debit_rest, credit_rest)) expense.entries.set(EntryAccount.objects.filter(id=new_entry.id))
def thirdaddon_expense(item, xfer): if WrapAction.is_permission(xfer.request, 'condominium.change_expense'): try: status_filter = xfer.getparam('status_filter', Expense.STATUS_BUILDING) date_filter = xfer.getparam('date_filter', 0) current_year = FiscalYear.get_current() item.get_account(current_year, current_system_account().get_provider_mask()) xfer.new_tab(_('Expenses')) edt = XferCompSelect("status_filter") edt.set_select(list(Expense.get_field_by_name('status').choices)) edt.set_value(status_filter) edt.description = _('Filter by type') edt.set_location(0, 1) edt.set_action(xfer.request, xfer.return_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) xfer.add_component(edt) edt = XferCompSelect("date_filter") edt.set_select([(0, _('only current fiscal year')), (1, _('all expenses'))]) edt.set_value(date_filter) edt.set_location(0, 2) edt.description = _('Filter by date') edt.set_action(xfer.request, xfer.return_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) xfer.add_component(edt) expense_filter = Q(status=status_filter) & Q(third=item) if date_filter == 0: expense_filter &= Q(date__gte=current_year.begin) & Q( date__lte=current_year.end) expenses = Expense.objects.filter(expense_filter).distinct() expense_grid = XferCompGrid('expense') expense_grid.set_model(expenses, Expense.get_default_fields(status_filter), xfer) expense_grid.add_action_notified(xfer, Expense) expense_grid.set_location(0, 3, 2) xfer.add_component(expense_grid) except LucteriosException: pass
def _generate_revenue_for_expense_oldaccounting(self, expense_detail, is_asset, fiscal_year): revenue_code = expense_detail.set.revenue_account cost_accounting = expense_detail.set.current_cost_accounting revenue_account = ChartsAccount.get_account(revenue_code, fiscal_year) if revenue_account is None: raise LucteriosException(IMPORTANT, _("code account %s unknown!") % revenue_code) price = currency_round(expense_detail.price) new_entry = EntryAccount.objects.create(year=fiscal_year, date_value=expense_detail.expense.date, designation=expense_detail.__str__(), journal=Journal.objects.get(id=3)) EntryLineAccount.objects.create(account=revenue_account, amount=is_asset * price, entry=new_entry, costaccounting=cost_accounting) for ratio in expense_detail.expenseratio_set.all(): third_account = expense_detail.expense.get_third_account(current_system_account().get_societary_mask(), fiscal_year, ratio.owner.third) EntryLineAccount.objects.create(account=third_account, amount=ratio.value, entry=new_entry, third=ratio.owner.third) no_change, debit_rest, credit_rest = new_entry.serial_control(new_entry.get_serial()) if not no_change or (abs(debit_rest) > 0.001) or (abs(credit_rest) > 0.001): raise LucteriosException(GRAVE, _("Error in accounting generator!") + "{[br/]} no_change=%s debit_rest=%.3f credit_rest=%.3f" % (no_change, debit_rest, credit_rest)) expense_detail.entry = new_entry expense_detail.save()
def edit(self, xfer): set_comp = xfer.get_components('set') set_comp.set_select_query(Set.objects.filter(is_active=True)) xfer.get_components('price').prec = Params.getvalue( "accounting-devise-prec") old_account = xfer.get_components("expense_account") xfer.remove_component("expense_account") sel_account = XferCompSelect("expense_account") sel_account.set_location(old_account.col, old_account.row, old_account.colspan, old_account.rowspan) for item in FiscalYear.get_current().chartsaccount_set.all().filter(code__regex=current_system_account().get_expence_mask()).order_by('code'): sel_account.select_list.append((item.code, six.text_type(item))) sel_account.set_value(self.item.expense_account) xfer.add_component(sel_account) self.item.year = FiscalYear.get_current() btn = XferCompButton('add_account') btn.set_location(old_account.col + 1, old_account.row) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.ChartsAccount', 'AddModify', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'year': self.item.year.id}) xfer.add_component(btn) xfer.get_components("set").colspan = old_account.colspan + 1 xfer.get_components("designation").colspan = old_account.colspan + 1 xfer.get_components("price").colspan = old_account.colspan + 1
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]}")
def calcul_table(self): self.budgetfilter_right = Q(cost_accounting=self.item) & Q(code__regex=current_system_account().get_revenue_mask()) self.budgetfilter_left = Q(cost_accounting=self.item) & Q(code__regex=current_system_account().get_expence_mask()) self._add_left_right_accounting(Q(account__type_of_account=4), Q(account__type_of_account=3), True)
def edit(self, xfer): revenue_account = xfer.get_components('revenue_account') if revenue_account is not None: revenue_account.mask = current_system_account().get_revenue_mask()
def get_third_mask(self): return current_system_account().get_customer_mask()
def edit(self, xfer): currency_decimal = Params.getvalue("accounting-devise-prec") xfer.get_components('price').prec = currency_decimal xfer.get_components( 'sell_account').mask = current_system_account().get_revenue_mask()
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)