示例#1
0
文件: views.py 项目: julienM77/syndic
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)
示例#2
0
def paramchange_condominium(params):
    if 'accounting-sizecode' in params:
        for set_item in Set.objects.all():
            if set_item.revenue_account != correct_accounting_code(set_item.revenue_account):
                set_item.revenue_account = correct_accounting_code(set_item.revenue_account)
                set_item.save()
        for exp_item in ExpenseDetail.objects.filter(expense__status=0):
            if exp_item.expense_account != correct_accounting_code(exp_item.expense_account):
                exp_item.expense_account = correct_accounting_code(exp_item.expense_account)
                exp_item.save()
    accounts = ('condominium-default-owner-account', 'condominium-current-revenue-account',
                'condominium-default-owner-account1', 'condominium-default-owner-account2',
                'condominium-default-owner-account3', 'condominium-default-owner-account4',
                'condominium-default-owner-account5',
                'condominium-exceptional-revenue-account', 'condominium-fundforworks-revenue-account',
                'condominium-exceptional-reserve-account', 'condominium-advance-reserve-account',
                'condominium-fundforworks-reserve-account')
    for account_item in accounts:
        has_changed = False
        if (account_item in params) or ('accounting-sizecode' in params):
            Parameter.change_value(account_item, correct_accounting_code(Params.getvalue(account_item)))
            system_condo = current_system_condo()
            system_condo.owner_account_changed(account_item)
            has_changed = True
        if has_changed:
            Params.clear()
    if 'accounting-system' in params:
        clear_system_condo()
        system_condo = current_system_condo()
        system_condo.initialize_system()
示例#3
0
def comptenofound_condo(known_codes, accompt_returned):
    if Params.getvalue("condominium-old-accounting"):
        account_filter = Q(name='condominium-default-owner-account')
        set_unknown = Set.objects.exclude(
            revenue_account__in=known_codes).values_list('revenue_account',
                                                         flat=True)
    else:
        account_filter = Q()
        for param_item in current_system_condo().get_config_params(True):
            account_filter |= Q(name=param_item)
        set_unknown = []
    param_unknown = Parameter.objects.filter(account_filter).exclude(
        value__in=known_codes).values_list('value', flat=True)
    comptenofound = ""
    if (len(set_unknown) > 0):
        comptenofound = _("set") + ":" + ",".join(set(set_unknown)) + " "
    param_unknown = list(param_unknown)
    if '0' in param_unknown:
        param_unknown.remove('0')
    if (len(param_unknown) > 0):
        comptenofound += _("parameters") + ":" + ",".join(set(param_unknown))
    if comptenofound != "":
        accompt_returned.append("- {[i]}{[u]}%s{[/u]}: %s{[/i]}" %
                                (_('Condominium'), comptenofound))
    return True
示例#4
0
def fill_params(self, is_mini=False, new_params=False):
    system_condo = current_system_condo()
    param_lists = system_condo.get_config_params(new_params)
    Params.fill(self, param_lists, 1, self.get_max_row() + 1, nb_col=2)
    btn = XferCompButton('editparam')
    btn.set_location(1, self.get_max_row() + 1, 2, 1)
    btn.set_is_mini(is_mini)
    btn.set_action(self.request, ParamEdit.get_action(TITLE_MODIFY, 'images/edit.png'), close=CLOSE_NO,
                   params={'params': param_lists})
    self.add_component(btn)
示例#5
0
 def edit(self, xfer):
     type_call = xfer.get_components('type_call')
     type_call.set_select(
         current_system_condo().get_callfunds_list(complete=False))
     type_call.set_action(xfer.request,
                          xfer.return_action(),
                          close=CLOSE_NO,
                          modal=FORMTYPE_REFRESH)
     set_comp = xfer.get_components('set')
     if int(self.item.type_call) == CallDetail.TYPECALL_EXCEPTIONAL:
         type_load = 1
     else:
         type_load = 0
     set_list = Set.objects.filter(is_active=True, type_load=type_load)
     if len(set_list) == 0:
         raise LucteriosException(IMPORTANT,
                                  _('No category of charge defined!'))
     set_comp.set_needed(True)
     set_comp.set_select_query(set_list)
     set_comp.set_action(xfer.request,
                         xfer.return_action(),
                         close=CLOSE_NO,
                         modal=FORMTYPE_REFRESH)
     xfer.get_components('price').prec = Params.getvalue(
         "accounting-devise-prec")
     set_comp.get_json()
     current_set = Set.objects.get(id=set_comp.value)
     if current_set.type_load == Set.TYPELOAD_CURRENT:
         if int(self.item.type_call) == CallDetail.TYPECALL_CURRENT:
             xfer.get_components(
                 'price').value = current_set.get_new_current_callfunds()
         elif int(self.item.type_call) == CallDetail.TYPECALL_FUNDFORWORK:
             xfer.get_components(
                 'price').value = current_set.get_current_budget() * 0.05
         else:
             xfer.get_components('price').value = 0.0
     elif current_set.type_load == Set.TYPELOAD_EXCEPTIONAL:
         already_called = 0.0
         call_details = CallDetail.objects.filter(set_id=set_comp.value)
         if self.item.id is not None:
             call_details = call_details.exclude(id=self.item.id)
         for detail in call_details:
             already_called += float(detail.price)
         xfer.get_components('price').value = max(
             0,
             float(current_set.get_current_budget()) -
             float(already_called))
示例#6
0
def paramtitles_condomium(names, titles):
    system_condo = current_system_condo()
    titles.update(system_condo.get_param_titles(names))
示例#7
0
 def fillresponse(self):
     if self.confirme(
             _('Do you want create current call of funds of this year?')):
         current_system_condo().CurrentCallFundsAdding(True)
示例#8
0
def CallFundsAddCurrent_cond(xfer):
    if xfer.getparam('status_filter', 1) == 0:
        return current_system_condo().CurrentCallFundsAdding(False)
    else:
        return False
示例#9
0
def CallFundsAddCurrent_cond(xfer):
    if xfer.getparam('status_filter', CallFunds.STATUS_VALID) == CallFunds.STATUS_BUILDING:
        return current_system_condo().CurrentCallFundsAdding(False)
    else:
        return False