Exemplo n.º 1
0
    def edit(self, xfer):
        if xfer.item.id is None:
            third = xfer.get_components('third')
            xfer.remove_component('third')
            xfer.remove_component('lbl_third')
            lbl = XferCompLabelForm('lbl_third')
            lbl.set_location(third.col - 1, third.row)
            lbl.set_value_as_name(_('third'))
            xfer.add_component(lbl)

            sel = XferCompSelect('third')
            sel.needed = True
            sel.set_location(third.col, third.row)
            owner_third_ids = []
            for owner in Owner.objects.all():
                owner_third_ids.append(owner.third_id)
            items = Third.objects.all().exclude(id__in=owner_third_ids).distinct()
            items = sorted(items, key=lambda t: six.text_type(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': Params.getvalue('condominium-default-owner-account')})
            xfer.add_component(btn)
        else:
            xfer.change_to_readonly('third')
Exemplo n.º 2
0
 def fillresponse(self, costaccounting=0):
     if self.getparam("SAVE") is None:
         dlg = self.create_custom()
         icon = XferCompImage('img')
         icon.set_location(0, 0, 1, 6)
         icon.set_value(self.icon_path())
         dlg.add_component(icon)
         lbl = XferCompLabelForm('lb_costaccounting')
         lbl.set_value_as_name(CostAccounting._meta.verbose_name)
         lbl.set_location(1, 1)
         dlg.add_component(lbl)
         sel = XferCompSelect('costaccounting')
         sel.set_select_query(CostAccounting.objects.filter(status=0))
         if self.item is not None:
             sel.set_value(self.item.costaccounting_id)
         sel.set_location(1, 2)
         dlg.add_component(sel)
         dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"})
         dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
     else:
         if costaccounting == 0:
             new_cost = None
         else:
             new_cost = CostAccounting.objects.get(id=costaccounting)
         for item in self.items:
             if (item.costaccounting is None) or (item.costaccounting.status == 0):
                 item.costaccounting = new_cost
                 item.save()
Exemplo n.º 3
0
    def fillresponse(self, item_name='', subject='', message='', model=0, withpayment=False):
        if item_name != '':
            self.item = Supporting.objects.get(id=self.getparam(item_name, 0))
        self.item = self.item.get_final_child()
        if self.getparam("OK") is None:
            dlg = self.create_custom()
            icon = XferCompImage('img')
            icon.set_location(0, 0, 1, 6)
            icon.set_value(self.icon_path())
            dlg.add_component(icon)
            lbl = XferCompLabelForm('lb_subject')
            lbl.set_value_as_name(_('subject'))
            lbl.set_location(1, 1)
            dlg.add_component(lbl)
            lbl = XferCompEdit('subject')
            lbl.set_value(six.text_type(self.item))
            lbl.set_location(2, 1)
            dlg.add_component(lbl)
            lbl = XferCompLabelForm('lb_message')
            lbl.set_value_as_name(_('message'))
            lbl.set_location(1, 2)
            dlg.add_component(lbl)
            contact = self.item.third.contact.get_final_child()
            lbl = XferCompMemo('message')
            lbl.set_value(Params.getvalue('payoff-email-message') % {
                          'name': contact.get_presentation(), 'doc': self.item.get_docname()})
            lbl.with_hypertext = True
            lbl.set_size(130, 450)
            lbl.set_location(2, 2)
            dlg.add_component(lbl)
            selectors = PrintModel.get_print_selector(
                2, self.item.__class__)[0]
            lbl = XferCompLabelForm('lb_model')
            lbl.set_value_as_name(selectors[1])
            lbl.set_location(1, 3)
            dlg.add_component(lbl)
            sel = XferCompSelect('model')
            sel.set_select(selectors[2])
            sel.set_location(2, 3)
            dlg.add_component(sel)

            if self.item.payoff_have_payment() and (len(PaymentMethod.objects.all()) > 0):
                lbl = XferCompLabelForm('lb_withpayment')
                lbl.set_value_as_name(_('add payment methods in email'))
                lbl.set_location(1, 4)
                dlg.add_component(lbl)
                sel = XferCompCheck('withpayment')
                sel.set_value(True)
                sel.set_location(2, 4)
                dlg.add_component(sel)

            dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"OK": "YES"})
            dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
        else:
            html_message = "<html>"
            html_message += message.replace('{[newline]}', '<br/>\n').replace('{[', '<').replace(']}', '>')
            if self.item.payoff_have_payment() and withpayment:
                html_message += get_html_payment(self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language, self.item)
            html_message += "</html>"
            self.item.send_email(subject, html_message, model)
Exemplo n.º 4
0
    def fill_header(self):
        self.item = FiscalYear.get_current(self.getparam("year"))
        new_begin = convert_date(self.getparam("begin"), self.item.begin)
        new_end = convert_date(self.getparam("end"), self.item.end)
        if (new_begin >= self.item.begin) and (new_end <= self.item.end):
            self.item.begin = new_begin
            self.item.end = new_end
        img = XferCompImage('img')
        img.set_value(self.current_image())
        if not img.value.startswith('/static/'):
            img.type = 'jpg'
        img.set_location(0, 0, 1, 5)
        self.add_component(img)

        if self.item.last_fiscalyear is not None:
            lbl = XferCompLabelForm('year_1')
            lbl.set_location(1, 0, 3)
            lbl.description = _('year N-1')
            lbl.set_value(six.text_type(self.item.last_fiscalyear))
            self.add_component(lbl)
        select_year = XferCompSelect(self.field_id)
        select_year.set_location(1, 1, 3)
        select_year.set_select_query(FiscalYear.objects.all())
        select_year.description = _('year N')
        select_year.set_value(self.item.id)
        select_year.set_needed(True)
        select_year.set_action(self.request,
                               self.__class__.get_action(),
                               close=CLOSE_NO,
                               modal=FORMTYPE_REFRESH)
        self.add_component(select_year)
        self.filter = Q(entry__year=self.item)
        self.lastfilter = Q(entry__year=self.item.last_fiscalyear)
Exemplo n.º 5
0
    def _change_city_select(self, xfer, list_postalcode, obj_city):

        obj_country = xfer.get_components('country')
        city_current = obj_city.value
        city_list = {}
        obj_country.value = ""
        for item_postalcode in list_postalcode:
            city_list[item_postalcode.city] = item_postalcode.city
            if item_postalcode.city == city_current:
                obj_country.value = item_postalcode.country
        if obj_country.value == "":
            obj_country.value = list_postalcode[0].country
            city_current = list_postalcode[0].city
        xfer.remove_component('city')
        xfer.tab = obj_city.tab
        city_select = XferCompSelect('city')
        city_select.set_value(city_current)
        city_select.set_select(city_list)
        city_select.set_location(obj_city.col, obj_city.row, obj_city.colspan,
                                 obj_city.rowspan)
        city_select.description = obj_city.description
        city_select.set_size(obj_city.vmin, obj_city.hmin)
        city_select.set_action(xfer.request,
                               xfer.get_action(),
                               modal=FORMTYPE_REFRESH,
                               close=CLOSE_NO)
        xfer.add_component(city_select)
Exemplo n.º 6
0
 def _select_fields(self):
     select_list = [('', None)]
     for fieldname in self.spamreader.fieldnames:
         if fieldname != '':
             select_list.append((fieldname, fieldname))
     row = 0
     for fieldname in self.model.get_import_fields():
         if isinstance(fieldname, tuple):
             fieldname, title = fieldname
             is_need = False
         else:
             dep_field = self.model.get_field_by_name(fieldname)
             title = dep_field.verbose_name
             is_need = not dep_field.blank and not dep_field.null
             fieldnames = fieldname.split('.')
             if is_need and (len(fieldnames) > 1):
                 init_field = self.model.get_field_by_name(fieldnames[0])
                 if not (init_field.is_relation and init_field.many_to_many):
                     is_need = not init_field.null
         lbl = XferCompSelect('fld_' + fieldname)
         lbl.set_select(deepcopy(select_list))
         lbl.set_value("")
         lbl.set_needed(is_need)
         lbl.set_location(1, row)
         lbl.description = title
         self.add_component(lbl)
         row += 1
Exemplo n.º 7
0
 def _add_season_comp(self, xfer, row):
     season = self.item.season
     if self.item.subscriptiontype.duration == 0:  # annually
         lbl = XferCompLabelForm("seasondates")
         lbl.set_location(1, row)
         lbl.set_value(
             "%s => %s" %
             (formats.date_format(season.begin_date, "SHORT_DATE_FORMAT"),
              formats.date_format(season.end_date, "SHORT_DATE_FORMAT")))
         lbl.description = _('annually')
         xfer.add_component(lbl)
     elif self.item.subscriptiontype.duration == 1:  # periodic
         sel = XferCompSelect('period')
         sel.set_needed(True)
         sel.set_select_query(season.period_set.all())
         sel.set_location(1, row)
         sel.description = _('period')
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 2:  # monthly
         sel = XferCompSelect('month')
         sel.set_needed(True)
         sel.set_select(season.get_months())
         sel.set_location(1, row)
         sel.description = _('month')
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 3:  # calendar
         begindate = XferCompDate('begin_date')
         begindate.set_needed(True)
         begindate.set_value(season.date_ref)
         begindate.set_location(1, row)
         begindate.description = _('begin date')
         xfer.add_component(begindate)
Exemplo n.º 8
0
 def fillresponse_header(self):
     modelname = self.getparam('modelname', "")
     lab = XferCompLabelForm('lblmodelname')
     lab.set_location(0, 1)
     lab.set_value_as_name(_('model'))
     self.add_component(lab)
     model_list = {}
     for print_model in PrintModel.objects.all():
         if print_model.modelname not in model_list.keys():
             try:
                 model_list[print_model.modelname] = print_model.model_associated_title()
                 if modelname == '':
                     modelname = print_model.modelname
             except LookupError:
                 pass
     model_list = list(model_list.items())
     model_list.sort(key=lambda item: item[1])
     model_sel = XferCompSelect('modelname')
     model_sel.set_location(1, 1)
     model_sel.set_select(model_list)
     model_sel.set_value(modelname)
     model_sel.set_action(self.request, self.get_action("", ""), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(model_sel)
     self.filter = Q(modelname=modelname)
     self.fieldnames = ['name', 'kind', 'is_default']
     return
Exemplo n.º 9
0
    def fillresponse_header(self):
        status_filter = self.getparam('status_filter', 0)
        self.params['status_filter'] = status_filter
        date_filter = self.getparam('date_filter', 0)
        self.fieldnames = Expense.get_default_fields(status_filter)
        lbl = XferCompLabelForm('lbl_status_filter')
        lbl.set_value_as_name(_('Filter by type'))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        dep_field = self.item.get_field_by_name('status')
        sel_list = list(dep_field.choices)
        edt = XferCompSelect("status_filter")
        edt.set_select(sel_list)
        edt.set_value(status_filter)
        edt.set_location(1, 3)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)

        lbl = XferCompLabelForm('lbl_date_filter')
        lbl.set_value_as_name(_('Filter by date'))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        edt = XferCompSelect("date_filter")
        edt.set_select([(0, _('only current fiscal year')), (1, _('all expenses'))])
        edt.set_value(date_filter)
        edt.set_location(1, 4)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)

        self.filter = Q(status=status_filter)
        if date_filter == 0:
            current_year = FiscalYear.get_current()
            self.filter &= Q(date__gte=current_year.begin) & Q(date__lte=current_year.end)
Exemplo n.º 10
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)
Exemplo n.º 11
0
def thirdaddon_accounting(item, xfer):
    if WrapAction.is_permission(xfer.request, 'accounting.change_entryaccount'):
        try:
            entry_lines_filter = Q(entrylineaccount__third=item)
            lines_filter = xfer.getparam('lines_filter', 0)
            if lines_filter == 0:
                entry_lines_filter &= Q(year=FiscalYear.get_current())
            elif lines_filter == 1:
                entry_lines_filter &= Q(year=FiscalYear.get_current()) & Q(close=False)
            xfer.new_tab(_('entry of account'))
            lbl = XferCompLabelForm('lbl_lines_filter')
            lbl.set_value_as_name(_('Accounts filter'))
            lbl.set_location(0, 1)
            xfer.add_component(lbl)
            edt = XferCompSelect("lines_filter")
            edt.set_select([(0, _('All entries of current fiscal year')), (1, _(
                'Only no-closed entries of current fiscal year')), (2, _('All entries for all fiscal year'))])
            edt.set_value(lines_filter)
            edt.set_location(1, 1)
            edt.set_action(xfer.request, xfer.get_action(),
                           modal=FORMTYPE_REFRESH, close=CLOSE_NO)
            xfer.add_component(edt)
            entries = EntryAccount.objects.filter(entry_lines_filter)
            link_grid_lines = XferCompGrid('entryaccount')
            link_grid_lines.set_model(entries, EntryAccount.get_default_fields(), xfer)
            link_grid_lines.set_location(0, 2, 2)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'OpenFromLine', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Link', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            xfer.add_component(link_grid_lines)
        except LucteriosException:
            pass
Exemplo n.º 12
0
    def fillresponse_header(self):
        contact_filter = self.getparam('filter', '')
        show_filter = self.getparam('show_filter', 0)
        lbl = XferCompLabelForm('lbl_filtre')
        lbl.set_value_as_name(_('Filtrer by contact'))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        comp = XferCompEdit('filter')
        comp.set_value(contact_filter)
        comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        comp.set_location(1, 2)
        self.add_component(comp)

        lbl = XferCompLabelForm('lbl_showing')
        lbl.set_value_as_name(_('Accounts displayed'))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        edt = XferCompSelect("show_filter")
        edt.set_select([(0, _('Hide the account total of thirds')), (1, _('Show the account total of thirds')),
                        (2, _('Filter any thirds unbalanced'))])
        edt.set_value(show_filter)
        edt.set_location(1, 3)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)
        if show_filter != 0:
            self.fieldnames = Third.get_other_fields()

        self.filter = Q(status=0)
        if contact_filter != "":
            q_legalentity = Q(contact__legalentity__name__icontains=contact_filter)
            q_individual = (Q(contact__individual__firstname__icontains=contact_filter) | Q(contact__individual__lastname__icontains=contact_filter))
            self.filter &= (q_legalentity | q_individual)
Exemplo n.º 13
0
    def fillresponse_header(self):
        status_filter = self.getparam('status_filter', 0)
        self.params['status_filter'] = status_filter
        date_filter = self.getparam('date_filter', 0)
        self.fieldnames = Expense.get_default_fields(status_filter)
        dep_field = self.item.get_field_by_name('status')
        sel_list = list(dep_field.choices)
        edt = XferCompSelect("status_filter")
        edt.set_select(sel_list)
        edt.set_value(status_filter)
        edt.description = _('Filter by type')
        edt.set_location(0, 3)
        edt.set_action(self.request,
                       self.get_action(),
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        self.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, 4)
        edt.description = _('Filter by date')
        edt.set_action(self.request,
                       self.get_action(),
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        self.add_component(edt)

        self.filter = Q(status=status_filter)
        if date_filter == 0:
            current_year = FiscalYear.get_current()
            self.filter &= Q(date__gte=current_year.begin) & Q(
                date__lte=current_year.end)
Exemplo n.º 14
0
 def fillresponse(self):
     self.action_list = []
     if self.final_class is not None:
         self.add_action(
             self.final_class.get_action(TITLE_OK, "images/ok.png"))
     model_current = self.getparam('modelname')
     if model_current is None:
         self.model = self.inital_model
     else:
         self.model = apps.get_model(model_current)
     self.field_id = self.model.__name__.lower()
     if self.field_id == 'legalentity':
         self.field_id = 'legal_entity'
     self.item = self.model()
     XferSearchEditor.fillresponse(self)
     self.remove_component('title')
     selected_model = XferCompSelect('modelname')
     selected_model.set_value(model_current)
     selected_model.set_select(self.inital_model.get_select_contact_type())
     selected_model.set_location(1, 0, 4)
     selected_model.set_action(self.request,
                               self.get_action(),
                               modal=FORMTYPE_REFRESH,
                               close=CLOSE_NO)
     selected_model.description = _('model')
     self.add_component(selected_model)
     if self.select_class is not None:
         grid = self.get_components(self.field_id)
         grid.add_action(self.request,
                         self.select_class.get_action(
                             _("Select"), "images/ok.png"),
                         close=CLOSE_YES,
                         unique=self.mode_select,
                         params={'pkname': self.field_id},
                         pos_act=0)
Exemplo n.º 15
0
 def fillresponse_add_title(self):
     XferSearchEditor.fillresponse_add_title(self)
     modelname = self.model.get_long_name()
     saved_list = SavedCriteria.objects.filter(modelname=modelname)
     new_row = self.get_max_row()
     sel = XferCompSelect('saved_criteria')
     sel.description = _("saved criteria")
     sel.set_location(1, new_row + 1, 3)
     sel.set_needed(False)
     sel.set_select_query(saved_list)
     sel.set_action(self.request,
                    self.return_action(),
                    close=CLOSE_NO,
                    modal=FORMTYPE_REFRESH)
     self.add_component(sel)
     if len(self.criteria_list) > 0:
         from lucterios.CORE.views import SavedCriteriaAddModify
         btn = XferCompButton('btn_saved_criteria')
         btn.set_location(4, new_row + 1, 2)
         btn.set_is_mini(True)
         btn.set_action(self.request,
                        SavedCriteriaAddModify.get_action("+", ""),
                        close=CLOSE_NO,
                        params={
                            'modelname': modelname,
                            'criteria': self.getparam('CRITERIA', '')
                        })
         self.add_component(btn)
     if self.getparam('saved_criteria', 0) != 0:
         saved_item = SavedCriteria.objects.get(
             id=self.getparam('saved_criteria', 0))
         self.params['CRITERIA'] = saved_item.criteria
         self.read_criteria_from_params()
Exemplo n.º 16
0
 def _add_option_selectors(self, gui):
     row_idx = 3
     for name_selector, title_selector, option_selector in self.selector:
         if isinstance(option_selector, list):
             comp = XferCompSelect(name_selector)
             comp.set_select(option_selector)
             comp.set_value(gui.getparam(name_selector, 0))
         elif isinstance(option_selector, tuple):
             comp = XferCompFloat(name_selector, option_selector[0],
                                  option_selector[1], option_selector[2])
             comp.set_value(option_selector[0])
         elif isinstance(option_selector, six.binary_type):
             comp = XferCompEdit(name_selector)
             comp.set_value(option_selector.decode())
         elif isinstance(option_selector, six.text_type):
             comp = XferCompMemo(name_selector)
             comp.with_hypertext = True
             comp.set_value(option_selector)
         elif isinstance(option_selector, bool):
             comp = XferCompCheck(name_selector)
             comp.set_value(option_selector)
         else:
             comp = None
         if comp is not None:
             comp.set_location(0, row_idx, 2)
             comp.description = title_selector
             gui.add_component(comp)
             row_idx += 1
Exemplo n.º 17
0
 def fillresponse_add_title(self):
     XferSearchEditor.fillresponse_add_title(self)
     modelname = self.model.get_long_name()
     saved_list = SavedCriteria.objects.filter(modelname=modelname)
     new_row = self.get_max_row()
     lbl = XferCompLabelForm('lbl_saved_criteria')
     lbl.set_location(1, new_row + 1)
     lbl.set_value_as_name(_("saved criteria"))
     self.add_component(lbl)
     sel = XferCompSelect('saved_criteria')
     sel.set_location(2, new_row + 1, 2)
     sel.set_needed(False)
     sel.set_select_query(saved_list)
     sel.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     self.add_component(sel)
     if len(self.criteria_list) > 0:
         from lucterios.CORE.views import SavedCriteriaAddModify
         btn = XferCompButton('btn_saved_criteria')
         btn.set_location(4, new_row + 1, 2)
         btn.set_is_mini(True)
         btn.set_action(self.request, SavedCriteriaAddModify.get_action("+", ""), close=CLOSE_NO,
                        params={'modelname': modelname, 'criteria': self.getparam('CRITERIA', '')})
         self.add_component(btn)
     if self.getparam('saved_criteria', 0) != 0:
         saved_item = SavedCriteria.objects.get(
             id=self.getparam('saved_criteria', 0))
         self.params['CRITERIA'] = saved_item.criteria
         self.read_criteria_from_params()
Exemplo n.º 18
0
    def fillresponse(self):
        model_module = ".".join(self.item.model_associated().__module__.split('.')[:-1])
        if self.getparam('SAVE') is None:
            dlg = self.create_custom(self.model)
            dlg.item = self.item
            img = XferCompImage('img')
            img.set_value(self.icon_path())
            img.set_location(0, 0, 1, 3)
            dlg.add_component(img)
            lbl = XferCompLabelForm('title')
            lbl.set_value_as_title(self.caption)
            lbl.set_location(1, 0, 6)
            dlg.add_component(lbl)

            lbl = XferCompLabelForm('lbl_default_model')
            lbl.set_value_as_name(_("Model to reload"))
            lbl.set_location(1, 1)
            dlg.add_component(lbl)
            sel = XferCompSelect('default_model')
            sel.set_select(PrintModel.get_default_model(model_module, self.item.modelname, self.item.kind))
            sel.set_location(2, 1)
            dlg.add_component(sel)

            dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
            dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
        else:
            if self.item.load_model(model_module, self.getparam("default_model", ""), is_default=None):
                self.message(_('Model reloaded'))
Exemplo n.º 19
0
 def _select_csv_parameters(self):
     model_select = XferCompSelect('modelname')
     if self.model is not None:
         model_select.set_value(self.model.get_long_name())
     model_select.set_select(self.get_select_models())
     model_select.set_location(1, 0, 3)
     model_select.description = _('model')
     self.add_component(model_select)
     upld = XferCompUpLoad('csvcontent')
     upld.http_file = True
     upld.add_filter(".csv")
     upld.set_location(1, 1, 2)
     upld.description = _('CSV file')
     self.add_component(upld)
     lbl = XferCompEdit('encoding')
     lbl.set_value(self.encoding)
     lbl.set_location(1, 2)
     lbl.description = _('encoding')
     self.add_component(lbl)
     lbl = XferCompEdit('dateformat')
     lbl.set_value(self.dateformat)
     lbl.set_location(2, 2)
     lbl.description = _('date format')
     self.add_component(lbl)
     lbl = XferCompEdit('delimiter')
     lbl.set_value(self.delimiter)
     lbl.set_location(1, 3)
     lbl.description = _('delimiter')
     self.add_component(lbl)
     lbl = XferCompEdit('quotechar')
     lbl.set_value(self.quotechar)
     lbl.set_location(2, 3)
     lbl.description = _('quotechar')
     self.add_component(lbl)
     return lbl
Exemplo n.º 20
0
 def _create_custom_for_profit(self, year, custom, val_profit):
     from lucterios.framework.xfercomponents import XferCompImage, XferCompLabelForm, XferCompSelect
     from diacamma.accounting.models import format_devise
     if val_profit > 0.0001:
         type_profit = 'bénéfice'
     else:
         type_profit = 'déficite'
     img = XferCompImage("img")
     img.set_location(0, 0)
     img.set_value(get_icon_path("diacamma.accounting/images/account.png"))
     custom.add_component(img)
     lbl = XferCompLabelForm("title")
     lbl.set_value_as_headername("Bénéfices et Pertes")
     lbl.set_location(1, 0)
     custom.add_component(lbl)
     text = "{[i]}Vous avez un %s de %s.{[br/]}Vous devez definir sur quel compte l'affecter.{[br/]}{[/i]}" % (
         type_profit, format_devise(val_profit, 4))
     text += "{[br/]}En validant, vous commencerez '%s'{[br/]}{[br/]}{[i]}{[u]}Attention:{[/u]} Votre report à nouveau doit être totalement fait.{[/i]}" % six.text_type(
         year)
     lbl = XferCompLabelForm("info")
     lbl.set_value(text)
     lbl.set_location(0, 1, 2)
     custom.add_component(lbl)
     sel_cmpt = []
     for account in year.chartsaccount_set.all().filter(code__startswith='10').order_by('code'):
         sel_cmpt.append((account.id, six.text_type(account)))
     sel = XferCompSelect("profit_account")
     sel.set_select(sel_cmpt)
     sel.set_location(1, 2)
     custom.add_component(sel)
     return custom
Exemplo n.º 21
0
    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
Exemplo n.º 22
0
    def edit_account_for_line(self, xfer, column, row, debit_rest, credit_rest):
        num_cpt_txt = xfer.getparam('num_cpt_txt', '')
        num_cpt = xfer.getparam('num_cpt', 0)

        lbl = XferCompLabelForm('numCptlbl')
        lbl.set_location(column, row, 3)
        lbl.set_value_as_headername(_('account'))
        xfer.add_component(lbl)
        edt = XferCompEdit('num_cpt_txt')
        edt.set_location(column, row + 1, 2)
        edt.set_value(num_cpt_txt)
        edt.set_size(20, 25)
        edt.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        xfer.add_component(edt)
        sel_val = []
        current_account = None
        if num_cpt_txt != '':
            year = FiscalYear.get_current(xfer.getparam('year'))
            sel_val, current_account = year.get_account_list(num_cpt_txt, num_cpt)
        sel = XferCompSelect('num_cpt')
        sel.set_location(column + 2, row + 1, 1)
        sel.set_select(sel_val)
        sel.set_size(20, 150)
        sel.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        if current_account is not None:
            sel.set_value(current_account.id)
            self.item.account = current_account
            self.item.set_montant(
                float(xfer.getparam('debit_val', 0.0)), float(xfer.getparam('credit_val', 0.0)))
            if abs(self.item.amount) < 0.0001:
                self.item.set_montant(debit_rest, credit_rest)
        xfer.add_component(sel)
        return lbl, edt
Exemplo n.º 23
0
 def fillresponse(self):
     self.action_list = []
     if self.final_class is not None:
         self.add_action(self.final_class.get_action(TITLE_OK, "images/ok.png"))
     model_current = self.getparam('modelname')
     if model_current is None:
         self.model = self.inital_model
     else:
         self.model = apps.get_model(model_current)
     self.field_id = self.model.__name__.lower()
     if self.field_id == 'legalentity':
         self.field_id = 'legal_entity'
     self.item = self.model()
     XferSearchEditor.fillresponse(self)
     self.remove_component('title')
     lbl = XferCompLabelForm('modelname_lbl')
     lbl.set_value_as_title(_('model'))
     lbl.set_location(1, 0)
     self.add_component(lbl)
     selected_model = XferCompSelect('modelname')
     selected_model.set_value(model_current)
     selected_model.set_select(self.inital_model.get_select_contact_type())
     selected_model.set_location(2, 0, 3)
     selected_model.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(selected_model)
     if self.select_class is not None:
         grid = self.get_components(self.field_id)
         grid.add_action(self.request, self.select_class.get_action(_("Select"), "images/ok.png"),
                         close=CLOSE_YES, unique=self.mode_select, params={'pkname': self.field_id}, pos_act=0)
Exemplo n.º 24
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)
Exemplo n.º 25
0
    def fillresponse_search_select(self):
        selector, script_ref = self.fields_desc.get_select_and_script()
        script_ref += """
var name=current.getValue();
var type=findFields[name];
parent.get('searchValueFloat').setVisible(type=='float');
parent.get('searchValueStr').setVisible(type=='str');
parent.get('searchValueBool').setVisible(type=='bool');
parent.get('searchValueDate').setVisible(type=='date' || type=='datetime');
parent.get('searchValueTime').setVisible(type=='time' || type=='datetime');
parent.get('searchValueList').setVisible(type=='list' || type=='listmult');
"""
        script_ref += get_script_for_operator()
        script_ref += """
if (type=='float') {
    var prec=findLists[name].split(';');
    parent.get('searchValueFloat').setValue('<FLOAT min=\"'+prec[0]+'\" max=\"'+prec[1]+'\" prec=\"'+prec[2]+'\"></FLOAT>');
}
if (type=='str') {
    parent.get('searchValueStr').setValue('<STR></STR>');
}
if (type=='bool') {
    parent.get('searchValueBool').setValue('<BOOL>n</BOOL>');
}
if (type=='date' || type=='datetime') {
    parent.get('searchValueDate').setValue('<DATE>1900/01/01</DATE>');
}
if (type=='time' || type=='datetime') {
    parent.get('searchValueTime').setValue('<DATE>00:00:00</DATE>');
}
if ((type=='list') || (type=='listmult')) {
    var list=findLists[name].split(';');
    var list_txt='';
    for(i=0;i<list.length;i++) {
        var val=list[i].split('||');
        if (val.length>1) {
            list_txt+='<CASE id=\"'+val[0]+'\">'+val[1]+'</CASE>';
        }
    }
    parent.get('searchValueList').setValue('<SELECT>'+list_txt+'</SELECT>');
}
"""
        label = XferCompLabelForm('labelsearchSelector')
        label.set_value("{[bold]Nouveau critere{[/bold]")
        label.set_location(0, 10, 1, 7)
        self.add_component(label)
        comp = XferCompSelect("searchSelector")
        comp.set_select(selector)
        comp.set_value("")
        comp.set_location(1, 10, 1, 7)
        comp.set_size(20, 200)
        comp.java_script = script_ref
        self.add_component(comp)
        comp = XferCompSelect("searchOperator")
        comp.set_select({})
        comp.set_value("")
        comp.set_size(20, 200)
        comp.set_location(2, 10, 1, 7)
        self.add_component(comp)
Exemplo n.º 26
0
def editbudget_condo(xfer):
    if xfer.getparam('set') is not None:
        cost = xfer.getparam('cost_accounting')
        if cost is not None:
            set_item = Set.objects.get(id=xfer.getparam('set', 0))
            title_cost = xfer.get_components('title_cost')
            xfer.remove_component('title_year')
            year = xfer.getparam('year', 0)
            select_year = XferCompSelect('year')
            select_year.set_location(1, title_cost.row - 1)
            select_year.set_select_query(FiscalYear.objects.all())
            select_year.set_value(year)
            select_year.description = _('year')
            select_year.set_needed(set_item.type_load == Set.TYPELOAD_CURRENT)
            select_year.set_action(xfer.request,
                                   xfer.__class__.get_action(),
                                   close=CLOSE_NO,
                                   modal=FORMTYPE_REFRESH)
            xfer.add_component(select_year)
            btn = XferCompButton('confyear')
            btn.set_location(2, title_cost.row - 1)
            btn.set_action(xfer.request,
                           ActionsManage.get_action_url(
                               FiscalYear.get_long_name(), 'configuration',
                               xfer),
                           close=CLOSE_NO)
            btn.set_is_mini(True)
            xfer.add_component(btn)
            if year != 0:
                current_year = FiscalYear.get_current(year)
                xfer.params['readonly'] = str(
                    current_year.status == FiscalYear.STATUS_FINISHED)
                if set_item.type_load == 0:
                    if len(set_item.setcost_set.filter(
                            year=current_year)) == 0:
                        set_item.create_new_cost(year=current_year.id)
                    setcost_item = set_item.setcost_set.filter(
                        year=current_year)[0]
                else:
                    setcost_item = set_item.setcost_set.filter(year=None)[0]
                cost_item = setcost_item.cost_accounting
                xfer.params['cost_accounting'] = cost_item.id
                title_cost.set_value("{[b]}%s{[/b]} : %s" %
                                     (_('cost accounting'), cost_item))
            else:
                year = None
                xfer.params['readonly'] = 'True'
                cost_item = CostAccounting.objects.get(id=cost)
            if (cost_item.status
                    == CostAccounting.STATUS_OPENED) and not xfer.getparam(
                        'readonly', False):
                set_item.change_budget_product(cost_item, year)
    if xfer.getparam('type_of_account') is not None:
        xfer.params['readonly'] = 'True'
    return
Exemplo n.º 27
0
    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"])
Exemplo n.º 28
0
    def fillresponse_search_select(self):
        selector, script_ref = self.fields_desc.get_select_and_script()
        script_ref += """
var name=current.getValue();
var type=findFields[name];
parent.get('searchValueFloat').setVisible(type=='float');
parent.get('searchValueStr').setVisible(type=='str');
parent.get('searchValueBool').setVisible(type=='bool');
parent.get('searchValueDate').setVisible(type=='date' || type=='datetime');
parent.get('searchValueTime').setVisible(type=='time' || type=='datetime');
parent.get('searchValueList').setVisible(type=='list' || type=='listmult');
"""
        script_ref += get_script_for_operator()
        script_ref += """
if (type=='float') {
    var prec=findLists[name];
    parent.get('searchValueFloat').setValue({min:prec[0],max:prec[1],prec:prec[2],value:0});
}
if (type=='str') {
    parent.get('searchValueStr').setValue({value:''});
}
if (type=='bool') {
    parent.get('searchValueBool').setValue({value:false});
}
if (type=='date' || type=='datetime') {
    parent.get('searchValueDate').setValue({value:'2000-01-01'});
}
if (type=='time' || type=='datetime') {
    parent.get('searchValueTime').setValue({value:'00:00'});
}
if ((type=='list') || (type=='listmult')) {
    var select_case=findLists[name];
    parent.get('searchValueList').setValue({case:select_case,value:0});
}
"""
        label = XferCompLabelForm('labelsearchSelector')
        label.set_value("{[bold]Nouveau critere{[/bold]")
        label.set_location(0, 10, 1, 7)
        self.add_component(label)
        comp = XferCompSelect("searchSelector")
        comp.set_select(selector)
        comp.set_value("")
        comp.set_location(1, 10, 1, 7)
        comp.set_size(20, 200)
        comp.java_script = script_ref
        self.add_component(comp)
        comp = XferCompSelect("searchOperator")
        comp.set_select({})
        comp.set_value("")
        comp.set_size(20, 200)
        comp.set_location(2, 10, 1, 7)
        self.add_component(comp)
Exemplo n.º 29
0
def select_account_system(xfer):
    current_account_system = Params.getvalue("accounting-system")
    if current_account_system == '':
        edt = XferCompSelect("account_system")
        account_systems = list(accounting_system_list().items())
        account_systems.insert(0, ('', '---'))
        edt.set_select(account_systems)
        edt.set_action(xfer.request, ConfigurationAccountingSystem.get_action(), modal=FORMTYPE_MODAL, close=CLOSE_NO)
    else:
        edt = XferCompLabelForm("account_system")
    edt.set_value(accounting_system_name(current_account_system))
    edt.set_location(1, xfer.get_max_row() + 1)
    xfer.add_component(edt)
Exemplo n.º 30
0
 def fillresponse_header(self):
     status_filter = self.getparam('status_filter', CallFunds.STATUS_BUILDING)
     self.params['status_filter'] = status_filter
     dep_field = self.item.get_field_by_name('status')
     sel_list = list(dep_field.choices)
     edt = XferCompSelect("status_filter")
     edt.description = _('Filter by type')
     edt.set_select(sel_list)
     edt.set_value(status_filter)
     edt.set_location(0, 3)
     edt.set_action(self.request, self.return_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q(status=status_filter)
Exemplo n.º 31
0
    def _get_from_selector(self):
        if not isinstance(self.selector, list) and (self.selector is not None):
            raise LucteriosException(GRAVE, "Error of print selector!")
        gui = XferContainerCustom()
        gui.model = self.model
        gui._initialize(self.request)
        gui.is_view_right = self.is_view_right
        gui.caption = self.caption
        gui.extension = self.extension
        gui.action = self.action
        gui.params = self.params
        pdfreport = self.get_persistent_pdfreport()
        if (pdfreport is not None) and (not isinstance(pdfreport, list)
                                        or len(pdfreport) == len(self.items)):
            presitent_report = XferCompCheck('PRINT_PERSITENT')
            presitent_report.set_value(True)
            presitent_report.set_location(0, 0, 2)
            presitent_report.description = _('Get saved report')
            presitent_report.java_script = """
var is_persitent=current.getValue();
parent.get('PRINT_MODE').setEnabled(!is_persitent);
parent.get('print_sep').setEnabled(!is_persitent);
"""
            if self.selector is not None:
                for name_selector, _selector, _selector in self.selector:
                    presitent_report.java_script += "parent.get('%s').setEnabled(!is_persitent);\n" % name_selector
            gui.add_component(presitent_report)
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_REGENERATE_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)
        elif (pdfreport is not None):
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_WARNING_SAVING_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)

        print_mode = XferCompSelect('PRINT_MODE')
        print_mode.set_select(self.print_selector)
        print_mode.set_value(PRINT_PDF_FILE)
        print_mode.set_location(0, 2, 2)
        print_mode.description = _('Kind of report')
        gui.add_component(print_mode)
        if self.selector is not None:
            self._add_option_selectors(gui)
        gui.add_action(self.return_action(_("Print"), "images/print.png"),
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_YES)
        gui.add_action(WrapAction(_("Close"), "images/close.png"))
        return gui
Exemplo n.º 32
0
 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)
Exemplo n.º 33
0
 def fillresponse_header(self):
     show_filter = self.getparam('show_filter', 0)
     lbl = XferCompLabelForm('lbl_showing')
     lbl.set_value_as_name(_('Show articles'))
     lbl.set_location(0, 3)
     self.add_component(lbl)
     edt = XferCompSelect("show_filter")
     edt.set_select([(0, _('Only activate')), (1, _('All'))])
     edt.set_value(show_filter)
     edt.set_location(1, 3)
     edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q()
     if show_filter == 0:
         self.filter = Q(isdisabled=False)
Exemplo n.º 34
0
 def fillresponse_header(self):
     status_filter = self.getparam('status_filter', 1)
     self.params['status_filter'] = status_filter
     lbl = XferCompLabelForm('lbl_filter')
     lbl.set_value_as_name(_('Filter by type'))
     lbl.set_location(0, 3)
     self.add_component(lbl)
     dep_field = self.item.get_field_by_name('status')
     sel_list = list(dep_field.choices)
     edt = XferCompSelect("status_filter")
     edt.set_select(sel_list)
     edt.set_value(status_filter)
     edt.set_location(1, 3)
     edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q(status=status_filter)
Exemplo n.º 35
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     dlg.get_components('activity').colspan = 3
     dlg.get_components('date').colspan = 3
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"),
                    close=CLOSE_YES,
                    params={'CONFIRME': 'YES'})
     dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Exemplo n.º 36
0
Arquivo: views.py Projeto: povtux/core
    def fillresponse(self, modelname=''):
        img_title = XferCompImage('img')
        img_title.set_location(0, 0, 1, 2)
        img_title.set_value(self.icon_path())
        self.add_component(img_title)
        lab = XferCompLabelForm('title')
        lab.set_location(1, 0, 3)
        lab.set_value_as_title(_("Print models"))
        self.add_component(lab)

        lab = XferCompLabelForm('lblmodelname')
        lab.set_location(1, 1)
        lab.set_value_as_name(_('model'))
        self.add_component(lab)
        model_list = {}
        for print_model in PrintModel.objects.all():
            if print_model.modelname not in model_list.keys():
                try:
                    model_list[
                        print_model.modelname] = print_model.model_associated_title()
                    if modelname == '':
                        modelname = print_model.modelname
                except LookupError:
                    pass
        model_sel = XferCompSelect('modelname')
        model_sel.set_location(2, 1, 2)
        model_sel.set_select(model_list)
        model_sel.set_value(modelname)
        model_sel.set_action(self.request, self.get_action(
            "", ""), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO})
        self.add_component(model_sel)

        items = PrintModel.objects.filter(
            modelname=modelname)
        grid = XferCompGrid('print_model')
        grid.set_location(1, 2, 3)
        grid.set_model(items, ['name', 'kind'], self)
        grid.add_action(self.request, PrintModelEdit.get_action(
            _('edit'), 'images/edit.png'), {'unique': SELECT_SINGLE})
        grid.add_action(self.request, PrintModelClone.get_action(
            _('clone'), 'images/clone.png'), {'unique': SELECT_SINGLE})
        grid.add_action(self.request, PrintModelDelete.get_action(
            _('delete'), 'images/delete.png'), {'unique': SELECT_SINGLE})
        self.add_component(grid)

        self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Exemplo n.º 37
0
    def edit(self, xfer):
        if xfer.item.id is None:
            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.all().exclude(
                id__in=owner_third_ids).distinct()
            items = sorted(items, key=lambda t: six.text_type(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':
                    Params.getvalue('condominium-default-owner-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"])
Exemplo n.º 38
0
 def fillresponse_header(self):
     self.new_tab(_("Log entries"))
     row = self.get_max_row() + 1
     type_selected = self.getparam('type_selected', '')
     sel = XferCompSelect('type_selected')
     sel.set_select(LucteriosLogEntry.get_typeselection())
     sel.set_needed(True)
     sel.set_value(type_selected)
     sel.set_location(1, row)
     sel.description = _("content type")
     sel._check_case()
     sel.set_action(self.request,
                    self.get_action(),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(sel)
     self.filter = Q(modelname=sel.value)
Exemplo n.º 39
0
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
Exemplo n.º 40
0
 def fill_third_convert(self, dlg):
     lbl = XferCompLabelForm('tle_third')
     lbl.set_value(_('How do want to convert owner third account?'))
     lbl.set_location(0, 0, 2)
     dlg.add_component(lbl)
     select_account = [('', None)]
     for num_account in range(1, 6):
         owner_account = correct_accounting_code(Params.getvalue('condominium-default-owner-account%d' % num_account))
         select_account.append((owner_account, owner_account))
     row = 1
     for code_item in AccountThird.objects.filter(code__regex=r"^45[0-9a-zA-Z]*$", third__status=0).values_list('code').distinct():
         sel = XferCompSelect('code_' + code_item[0])
         sel.set_location(0, row)
         sel.description = code_item[0]
         sel.set_value(dlg.getparam('code_' + code_item[0], ""))
         sel.set_select(select_account)
         dlg.add_component(sel)
         row += 1
Exemplo n.º 41
0
 def _get_from_selector(self):
     if not isinstance(self.selector, list) and (self.selector is not None):
         raise LucteriosException(GRAVE, "Error of print selector!")
     gui = XferContainerCustom()
     gui.model = self.model
     gui._initialize(self.request)
     gui.is_view_right = self.is_view_right
     gui.caption = self.caption
     gui.extension = self.extension
     gui.action = self.action
     gui.params = self.params
     lbl = XferCompLabelForm('lblPrintMode')
     lbl.set_value_as_name(_('Kind of report'))
     lbl.set_location(0, 0)
     gui.add_component(lbl)
     print_mode = XferCompSelect('PRINT_MODE')
     print_mode.set_select(self.print_selector)
     print_mode.set_value(PRINT_PDF_FILE)
     print_mode.set_location(1, 0)
     gui.add_component(print_mode)
     if self.selector is not None:
         row_idx = 1
         for name_selector, title_selector, option_selector in self.selector:
             lbl = XferCompLabelForm('lbl' + name_selector)
             lbl.set_value_as_name(title_selector)
             lbl.set_location(0, row_idx)
             gui.add_component(lbl)
             if isinstance(option_selector, list):
                 comp = XferCompSelect(name_selector)
                 comp.set_select(option_selector)
                 comp.set_value(gui.getparam(name_selector, 0))
             elif isinstance(option_selector, tuple):
                 comp = XferCompFloat(name_selector, option_selector[0],
                                      option_selector[1],
                                      option_selector[2])
                 comp.set_value(option_selector[0])
             comp.set_location(1, row_idx)
             gui.add_component(comp)
             row_idx += 1
     gui.add_action(self.get_action(_("Print"), "images/print.png"),
                    modal=FORMTYPE_MODAL,
                    close=CLOSE_YES)
     gui.add_action(WrapAction(_("Close"), "images/close.png"))
     return gui
Exemplo n.º 42
0
 def fillresponse(self, journal=0):
     if self.getparam('SAVE') is None:
         dlg = self.create_custom()
         image = XferCompImage('image')
         image.set_value(self.icon_path())
         image.set_location(0, 0, 1, 6)
         dlg.add_component(image)
         lbl = XferCompLabelForm('lblmodel')
         lbl.set_value(_('model name'))
         lbl.set_location(1, 0)
         dlg.add_component(lbl)
         if journal > 0:
             mod_query = ModelEntry.objects.filter(journal=journal)
         else:
             mod_query = ModelEntry.objects.all()
         sel = XferCompSelect('model')
         sel.set_location(2, 0)
         sel.set_needed(True)
         sel.set_select_query(mod_query)
         dlg.add_component(sel)
         lbl = XferCompLabelForm('lblfactor')
         lbl.set_value(_('factor'))
         lbl.set_location(1, 1)
         dlg.add_component(lbl)
         fact = XferCompFloat('factor', 0.00, 1000000.0, 2)
         fact.set_value(1.0)
         fact.set_location(2, 1)
         dlg.add_component(fact)
         dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         factor = self.getparam('factor', 1.0)
         model = ModelEntry.objects.get(id=self.getparam('model', 0))
         for old_key in ['SAVE', 'model', 'factor']:
             if old_key in self.params.keys():
                 del self.params[old_key]
         year = FiscalYear.get_current(self.getparam('year'))
         serial_entry = model.get_serial_entry(factor, year)
         date_value = date.today().isoformat()
         entry = EntryAccount.objects.create(year=year, date_value=date_value, designation=model.designation,
                                             journal=model.journal, costaccounting=model.costaccounting)
         entry.editor.before_save(self)
         self.params["entryaccount"] = entry.id
         self.redirect_action(EntryAccountEdit.get_action(), params={"serial_entry": serial_entry})
Exemplo n.º 43
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'})
     dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Exemplo n.º 44
0
    def fillresponse(self, current_folder=0, docext=""):
        if current_folder == 0:
            self.item.parent_id = None
        else:
            self.item.parent_id = current_folder
        if self.getparam('CONFIRME', '') == 'YES':
            self.params = {}
            filename_spited = self.item.name.split('.')
            if len(filename_spited) > 1:
                filename_spited = filename_spited[:-1]
            self.item.name = "%s.%s" % (".".join(filename_spited), docext)
            self.item.editor.before_save(self)
            self.item.save()
            self.item.content = ""
            self.redirect_action(DocumentEditor.get_action(),
                                 modal=FORMTYPE_NOMODAL,
                                 close=CLOSE_YES,
                                 params={'document': self.item.id})
        else:
            dlg = self.create_custom(self.model)
            max_row = dlg.get_max_row() + 1
            img = XferCompImage('img')
            img.set_value(self.icon_path())
            img.set_location(0, 0, 1, 6)
            dlg.add_component(img)
            dlg.fill_from_model(1, max_row, True, ['parent'])
            dlg.fill_from_model(1, max_row + 1, False, ['name', 'description'])

            max_row = dlg.get_max_row() + 1
            select = XferCompSelect('docext')
            select.set_select([
                (item, item)
                for item in DocEditor.get_all_extension_supported()
            ])
            select.set_value(select.select_list[0][1])
            select.set_location(1, max_row)
            select.description = _('document type')
            dlg.add_component(select)
            dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'),
                           close=CLOSE_YES,
                           params={'CONFIRME': 'YES'})
            dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 45
0
 def edit(self, xfer):
     obj_model = xfer.get_components('modelname')
     obj_kind = xfer.get_components('kind')
     xfer.tab = obj_model.tab
     sel_models = self._get_basic_model(xfer).get_select_contact_type()
     model_current = obj_model.value
     xfer.remove_component('modelname')
     model_select = XferCompSelect('modelname')
     model_select.description = obj_model.description
     model_select.set_value(model_current)
     model_select.set_select(sel_models)
     model_select.set_location(obj_model.col, obj_model.row, obj_model.colspan, obj_model.rowspan)
     model_select.set_size(obj_model.vmin, obj_model.hmin)
     xfer.add_component(model_select)
     if len(sel_models) == 1:
         xfer.params['modelname'] = sel_models[0][0]
         model_select.set_value(xfer.params['modelname'])
         xfer.change_to_readonly('modelname')
     self._edit_add_args(xfer, obj_kind)
     obj_kind.java_script = """
Exemplo n.º 46
0
 def edit(self, xfer):
     obj_model = xfer.get_components('modelname')
     obj_kind = xfer.get_components('kind')
     xfer.tab = obj_model.tab
     sel_models = self._get_basic_model(xfer).get_select_contact_type()
     model_current = obj_model.value
     xfer.remove_component('modelname')
     model_select = XferCompSelect('modelname')
     model_select.description = obj_model.description
     model_select.set_value(model_current)
     model_select.set_select(sel_models)
     model_select.set_location(obj_model.col, obj_model.row, obj_model.colspan, obj_model.rowspan)
     model_select.set_size(obj_model.vmin, obj_model.hmin)
     xfer.add_component(model_select)
     if len(sel_models) == 1:
         xfer.params['modelname'] = sel_models[0][0]
         model_select.set_value(xfer.params['modelname'])
         xfer.change_to_readonly('modelname')
     self._edit_add_args(xfer, obj_kind)
     obj_kind.java_script = """
Exemplo n.º 47
0
 def fill_third_convert(self, dlg):
     lbl = XferCompLabelForm('tle_third')
     lbl.set_value(_('How do want to convert owner third account?'))
     lbl.set_location(0, 0, 2)
     dlg.add_component(lbl)
     select_account = [('', None)]
     for num_account in range(1, 5):
         owner_account = correct_accounting_code(Params.getvalue('condominium-default-owner-account%d' % num_account))
         select_account.append((owner_account, owner_account))
     row = 1
     for code_item in AccountThird.objects.filter(code__regex=r"^45[0-9a-zA-Z]*$", third__status=0).values_list('code').distinct():
         lbl = XferCompLabelForm('lbl_code_' + code_item[0])
         lbl.set_value_as_name(code_item[0])
         lbl.set_location(0, row)
         dlg.add_component(lbl)
         sel = XferCompSelect('code_' + code_item[0])
         sel.set_location(1, row)
         sel.set_value(dlg.getparam('code_' + code_item[0], ""))
         sel.set_select(select_account)
         dlg.add_component(sel)
         row += 1
Exemplo n.º 48
0
 def _filter_by_nature(self):
     select_filter = self.getparam('filter', 1)
     lbl = XferCompLabelForm("filterLbl")
     lbl.set_location(0, 3)
     lbl.set_value_as_name(_("Filter"))
     self.add_component(lbl)
     sel = XferCompSelect("filter")
     sel.set_select({0: _('All'), 1: _('In progress'), 2: _('Valid'), 3: _('Lettered'), 4: _('Not lettered')})
     sel.set_value(select_filter)
     sel.set_location(1, 3)
     sel.set_size(20, 200)
     sel.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     self.add_component(sel)
     if select_filter == 1:
         self.filter &= Q(close=False)
     elif select_filter == 2:
         self.filter &= Q(close=True)
     elif select_filter == 3:
         self.filter &= Q(link__id__gt=0)
     elif select_filter == 4:
         self.filter &= Q(link=None)
Exemplo n.º 49
0
def _add_bill_filter(xfer, row):
    status_filter = xfer.getparam('status_filter', -1)
    lbl = XferCompLabelForm('lbl_filter')
    lbl.set_value_as_name(_('Filter by type'))
    lbl.set_location(0, row)
    xfer.add_component(lbl)
    dep_field = Bill.get_field_by_name('status')
    sel_list = list(dep_field.choices)
    sel_list.insert(0, (-1, _('building+valid')))
    edt = XferCompSelect("status_filter")
    edt.set_select(sel_list)
    edt.set_value(status_filter)
    edt.set_location(1, row)
    edt.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
    xfer.add_component(edt)
    current_filter = Q()
    if status_filter >= 0:
        current_filter &= Q(status=status_filter)
    elif status_filter == -1:
        current_filter &= Q(status=0) | Q(status=1)
    return current_filter, status_filter
Exemplo n.º 50
0
 def _get_from_selector(self):
     if not isinstance(self.selector, list) and (self.selector is not None):
         raise LucteriosException(GRAVE, "Error of print selector!")
     gui = XferContainerCustom()
     gui.request = self.request
     gui.is_view_right = self.is_view_right
     gui.caption = self.caption
     gui.extension = self.extension
     gui.action = self.action
     lbl = XferCompLabelForm('lblPrintMode')
     lbl.set_value_as_name(_('Kind of report'))
     lbl.set_location(0, 0)
     gui.add_component(lbl)
     print_mode = XferCompSelect('PRINT_MODE')
     print_mode.set_select(self.print_selector)
     print_mode.set_value(PRINT_PDF_FILE)
     print_mode.set_location(1, 0)
     gui.add_component(print_mode)
     if self.selector is not None:
         row_idx = 1
         for name_selector, title_selector, option_selector in self.selector:
             lbl = XferCompLabelForm('lbl' + name_selector)
             lbl.set_value_as_name(title_selector)
             lbl.set_location(0, row_idx)
             gui.add_component(lbl)
             if isinstance(option_selector, list):
                 comp = XferCompSelect(name_selector)
                 comp.set_select(option_selector)
                 comp.set_value(None)
             elif isinstance(option_selector, tuple):
                 comp = XferCompFloat(
                     name_selector, option_selector[0], option_selector[1], option_selector[2])
                 comp.set_value(option_selector[0])
             comp.set_location(1, row_idx)
             gui.add_component(comp)
             row_idx += 1
     gui.add_action(self.get_action(
         _("Print"), "images/print.png"), {'modal': FORMTYPE_MODAL, 'close': CLOSE_YES})
     gui.add_action(WrapAction(_("Close"), "images/close.png"), {})
     return gui
Exemplo n.º 51
0
    def fillresponse_header(self):
        status_filter = self.getparam('status_filter',
                                      Expense.STATUS_BUILDING_WAITING)
        self.params['status_filter'] = status_filter
        date_filter = self.getparam('date_filter', 0)
        self.fieldnames = Expense.get_default_fields(status_filter)
        edt = XferCompSelect("status_filter")
        edt.set_select(Expense.SELECTION_STATUS)
        edt.set_value(status_filter)
        edt.description = _('Filter by type')
        edt.set_location(0, 3)
        edt.set_action(self.request,
                       self.return_action(),
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        self.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, 4)
        edt.description = _('Filter by date')
        edt.set_action(self.request,
                       self.return_action(),
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        self.add_component(edt)

        if status_filter == Expense.STATUS_BUILDING_WAITING:
            self.filter = Q(status=Expense.STATUS_BUILDING) | Q(
                status=Expense.STATUS_WAITING)
        elif status_filter != Expense.STATUS_ALL:
            self.filter = Q(status=status_filter)
        else:
            self.filter = Q()
        if date_filter == 0:
            current_year = FiscalYear.get_current()
            self.filter &= Q(date__gte=current_year.begin) & Q(
                date__lte=current_year.end)
Exemplo n.º 52
0
 def fillresponse_header(self):
     self.new_tab(_("Season"))
     show_filter = self.getparam("show_filter", 0)
     lbl = XferCompLabelForm("lbl_showing")
     lbl.set_value_as_name(_("Show season"))
     lbl.set_location(0, 3)
     self.add_component(lbl)
     edt = XferCompSelect("show_filter")
     edt.set_select([(0, _("Near active")), (1, _("All"))])
     edt.set_value(show_filter)
     edt.set_location(1, 3)
     edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q()
     if show_filter == 0:
         try:
             year_ref = Season.current_season().reference_year
             designation_begin = "%d/%d" % (year_ref - 2, year_ref - 1)
             designation_end = "%d/%d" % (year_ref + 2, year_ref + 3)
             self.filter = Q(designation__gte=designation_begin) & Q(designation__lte=designation_end)
         except:
             pass
Exemplo n.º 53
0
 def fillresponse_header(self):
     self.new_tab(_('Season'))
     show_filter = self.getparam('show_filter', 0)
     edt = XferCompSelect("show_filter")
     edt.set_select([(0, _('Near active')), (1, _('All'))])
     edt.set_value(show_filter)
     edt.set_location(0, 3)
     edt.description = _('Show season')
     edt.set_action(self.request,
                    self.get_action(),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q()
     if show_filter == 0:
         try:
             year_ref = Season.current_season().reference_year
             designation_begin = "%d/%d" % (year_ref - 2, year_ref - 1)
             designation_end = "%d/%d" % (year_ref + 2, year_ref + 3)
             self.filter = Q(designation__gte=designation_begin) & Q(
                 designation__lte=designation_end)
         except Exception:
             pass
Exemplo n.º 54
0
def edit_third_for_line(xfer, column, row, account_code, current_third, vertical=True):
    lbl = XferCompLabelForm('thirdlbl')
    lbl.set_value_as_name(_('third'))
    sel_thirds = []
    for third in Third.objects.filter(accountthird__code=account_code):
        sel_thirds.append((third.id, six.text_type(third)))
    sel_thirds = sorted(sel_thirds, key=lambda third_item: third_item[1])
    sel_thirds.insert(0, (0, '---'))
    cb_third = XferCompSelect('third')
    cb_third.set_select(sel_thirds)
    if current_third is None:
        cb_third.set_value(xfer.getparam('third', 0))
    else:
        cb_third.set_value(xfer.getparam('third', current_third.id))
    if vertical:
        cb_third.set_location(column, row + 1)
        lbl.set_location(column, row)
    else:
        cb_third.set_location(column + 2, row)
        lbl.set_location(column, row, 2)
    xfer.add_component(lbl)
    xfer.add_component(cb_third)
    return lbl
Exemplo n.º 55
0
    def _change_city_select(self, xfer, list_postalcode, obj_city):

        obj_country = xfer.get_components('country')
        city_current = obj_city.value
        city_list = {}
        obj_country.value = ""
        for item_postalcode in list_postalcode:
            city_list[item_postalcode.city] = item_postalcode.city
            if item_postalcode.city == city_current:
                obj_country.value = item_postalcode.country
        if obj_country.value == "":
            obj_country.value = list_postalcode[0].country
            city_current = list_postalcode[0].city
        xfer.remove_component('city')
        xfer.tab = obj_city.tab
        city_select = XferCompSelect('city')
        city_select.set_value(city_current)
        city_select.set_select(city_list)
        city_select.set_location(obj_city.col, obj_city.row, obj_city.colspan, obj_city.rowspan)
        city_select.description = obj_city.description
        city_select.set_size(obj_city.vmin, obj_city.hmin)
        city_select.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        xfer.add_component(city_select)
Exemplo n.º 56
0
    def fillresponse_header(self):
        status_filter = self.getparam('status_filter', -1)
        year_filter = self.getparam('year_filter', FiscalYear.get_current().id)
        lbl = XferCompLabelForm('lbl_statusfilter')
        lbl.set_value_as_name(_('Filter by status'))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        dep_field = DepositSlip.get_field_by_name('status')
        sel_list = list(dep_field.choices)
        sel_list.insert(0, (-1, '---'))
        edt = XferCompSelect("status_filter")
        edt.set_select(sel_list)
        edt.set_value(status_filter)
        edt.set_needed(False)
        edt.set_location(1, 1)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)

        lbl = XferCompLabelForm('lbl_yearfilter')
        lbl.set_value_as_name(_('Filter by year'))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        edt = XferCompSelect("year_filter")
        edt.set_needed(False)
        edt.set_select_query(FiscalYear.objects.all())
        edt.set_value(year_filter)
        edt.set_location(1, 2)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)

        self.filter = Q()
        if status_filter >= 0:
            self.filter &= Q(status=status_filter)
        if year_filter > 0:
            year = FiscalYear.objects.get(id=year_filter)
            self.filter &= Q(date__gte=year.begin)
            self.filter &= Q(date__lte=year.end)
Exemplo n.º 57
0
    def fill_header(self):
        self.item = FiscalYear.get_current(self.getparam("year"))
        new_begin = convert_date(self.getparam("begin"), self.item.begin)
        new_end = convert_date(self.getparam("end"), self.item.end)
        if (new_begin >= self.item.begin) and (new_end <= self.item.end):
            self.item.begin = new_begin
            self.item.end = new_end
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 3)
        self.add_component(img)

        select_year = XferCompSelect(self.field_id)
        select_year.set_location(1, 0, 4)
        select_year.set_select_query(FiscalYear.objects.all())
        select_year.set_value(self.item.id)
        select_year.set_needed(True)
        select_year.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(select_year)
        self.filter = Q(entry__year=self.item)
        if self.item.status != 2:
            self.fill_from_model(1, 1, False, ['begin'])
            self.fill_from_model(3, 1, False, ['end'])
            begin_filter = self.get_components('begin')
            begin_filter.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
            end_filter = self.get_components('end')
            end_filter.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
            self.filter &= Q(entry__date_value__gte=self.item.begin)
            self.filter &= Q(entry__date_value__lte=self.item.end)
        self.fill_filterCode()
        lbl = XferCompLabelForm("result")
        lbl.set_value_center(self.item.total_result_text)
        lbl.set_location(0, 6, 6)
        self.add_component(lbl)
        self.fill_filterheader()
        self.define_gridheader()
Exemplo n.º 58
0
    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
Exemplo n.º 59
0
    def fillresponse(self, season):
        if season is None:
            working_season = Season.current_season()
        else:
            working_season = Season.objects.get(id=season)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0)
        self.add_component(img)
        lab = XferCompLabelForm('lbl_season')
        lab.set_value_as_name(_('season'))
        lab.set_location(1, 0)
        self.add_component(lab)
        sel = XferCompSelect('season')
        sel.set_needed(True)
        sel.set_select_query(Season.objects.all())
        sel.set_value(working_season.id)
        sel.set_location(2, 0)
        sel.set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(sel)
        stat_result = working_season.get_statistic()
        if len(stat_result) == 0:
            lab = XferCompLabelForm('lbl_season')
            lab.set_color('red')
            lab.set_value_as_infocenter(_('no subscription!'))
            lab.set_location(1, 1, 2)
            self.add_component(lab)
        else:
            tab_iden = 0
            for stat_title, stat_city, stat_type in stat_result:
                tab_iden += 1
                if (len(stat_city) > 0) and (len(stat_type) > 0):
                    self.new_tab(stat_title)
                    lab = XferCompLabelForm("lbltown_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by city"))
                    lab.set_location(0, 1)
                    self.add_component(lab)
                    grid = XferCompGrid("town_%d" % tab_iden)
                    grid.add_header("city", _("city"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_city:
                        for stat_key in stat_val.keys():
                            grid.set_value(cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 2)
                    self.add_component(grid)

                    lab = XferCompLabelForm("lbltype_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by type"))
                    lab.set_location(0, 3)
                    self.add_component(lab)
                    grid = XferCompGrid("type_%d" % tab_iden)
                    grid.add_header("type", _("type"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_type:
                        for stat_key in stat_val.keys():
                            if (stat_key == 'type') and not isinstance(stat_val['type'], six.text_type):
                                grid.set_value(cmp, stat_key, six.text_type(
                                    SubscriptionType.objects.get(id=stat_val['type'])))
                            else:
                                grid.set_value(
                                    cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 4)
                    self.add_component(grid)
        self.add_action(AdherentStatisticPrint.get_action(TITLE_PRINT, "images/print.png"),
                        close=CLOSE_NO, params={'classname': self.__class__.__name__})
        self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 60
0
    def fillresponse(self,
                     edt1='aaa',
                     flt1=3.1399999,
                     mm1='xyz',
                     dt1='2007-04-23',
                     tm1='12:34:00',
                     ck1=False,
                     slct1='1',
                     flt2=5,
                     cl1=['1', '2'],
                     cl2=['b', 'd', 'f'],
                     stm1='2008-07-12 23:47:31'):
        act_modif = self.return_action('Modify', '')

        lbl = XferCompLabelForm('Lbl2')
        lbl.set_value('editor=' + six.text_type(edt1))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        edt = XferCompEdit('edt1')
        edt.set_value(edt1)

        edt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        edt.set_location(1, 1)

        self.add_component(edt)

        lbl = XferCompLabelForm('Lbl3')
        lbl.set_value('Real=' + six.text_type(flt1))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 2)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl4')
        lbl.set_value('Memo=' + six.text_type(mm1))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        cmm = XferCompMemo('mm1')
        cmm.set_value(mm1)
        cmm.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        cmm.add_sub_menu('Première valeur', 'VALUE_1')
        cmm.add_sub_menu('Deuxième valeur', 'VALUE_2')
        cmm.add_sub_menu('Troisième valeur', 'VALUE_3')
        cmm.set_location(1, 3)
        self.add_component(cmm)

        lbl = XferCompLabelForm('Lbl5')
        lbl.set_value('Date=' + six.text_type(dt1))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        date.set_location(1, 4)
        self.add_component(date)

        lbl = XferCompLabelForm('Lbl6')
        lbl.set_value('Hour=' + six.text_type(tm1))
        lbl.set_location(0, 5)
        self.add_component(lbl)
        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        time.set_location(1, 5)
        self.add_component(time)

        lbl = XferCompLabelForm('Lbl7')
        lbl.set_value('Date Hour=' + six.text_type(stm1))
        lbl.set_location(0, 6)
        self.add_component(lbl)
        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request,
                            act_modif,
                            modal=FORMTYPE_REFRESH,
                            close=CLOSE_NO)
        datetime.set_location(1, 6)
        self.add_component(datetime)

        lbl = XferCompLabelForm('Lbl8')
        lbl.set_value('Coche=' + six.text_type(ck1))
        lbl.set_location(0, 7)
        self.add_component(lbl)
        check = XferCompCheck('ck1')
        check.set_value(ck1)
        check.set_action(self.request,
                         act_modif,
                         modal=FORMTYPE_REFRESH,
                         close=CLOSE_NO)
        check.set_location(1, 7)
        self.add_component(check)

        lbl = XferCompLabelForm('Lbl9')
        lbl.set_value('Select=' + six.text_type(slct1))
        lbl.set_location(0, 8)
        self.add_component(lbl)
        slct = XferCompSelect('slct1')
        if (flt2 is not None) and (flt2 < 2):
            slct.set_select({'1': 'abc', '2': 'def'})
        elif (flt2 is not None) and (flt2 < 10):
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij'})
        else:
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        slct.set_value(slct1)
        slct.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        slct.set_location(1, 8)
        self.add_component(slct)

        lbl = XferCompLabelForm('Lbl10')
        lbl.set_value('Integer=' + six.text_type(flt2))
        lbl.set_location(0, 9)
        self.add_component(lbl)
        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 9)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl11')
        lbl.set_value('CheckList=' + six.text_type(cl1))
        lbl.set_location(0, 10)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl1')
        checklist.set_select({
            '1': 'abc',
            '2': 'def',
            '3': 'ghij',
            '4': 'klmn'
        })
        checklist.set_value(cl1)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 10)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl12')
        lbl.set_value('CheckList 2=' + six.text_type(cl2))
        lbl.set_location(0, 11)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl2')
        checklist.simple = 2
        checklist.set_select({
            'a': '123',
            'b': '456',
            'c': '789',
            'd': '147',
            'e': '258',
            'f': '369'
        })
        checklist.set_value(cl2)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 11)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl13')
        lbl.set_value('Bouton')
        lbl.set_location(0, 20)
        self.add_component(lbl)
        btn = XferCompButton('btn1')
        btn.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        btn.set_location(1, 20)
        self.add_component(btn)

        self.add_action(WrapAction('Fin', 'images/close.png'),
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_YES)