Пример #1
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)
Пример #2
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)
Пример #3
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
Пример #4
0
def add_test_expenses(simple=True, with_payoff=False):
    expense1 = Expense(date=convert_date('2015-05-07'), comment='opq 666', expensetype=0, third_id=2)
    expense1.editor.before_save(None)
    expense1.save()
    ExpenseDetail.objects.create(expense=expense1, set_id=2, designation='set 2', expense_account='604', price='100')
    expense1.valid()
    if not simple:
        expense2 = Expense(date=convert_date('2015-08-28'), comment='creation', expensetype=0, third_id=2)
        expense2.editor.before_save(None)
        expense2.save()
        ExpenseDetail.objects.create(expense=expense2, set_id=3, designation='set 1', expense_account='602', price='75')
        expense2.valid()
    if with_payoff:
        pay = Payoff(supporting_id=expense1.id, date='2015-05-11', mode=0, amount=35.0)
        pay.editor.before_save(None)
        pay.save()
        pay = Payoff(supporting_id=expense2.id, date='2015-08-30', mode=0, amount=75.0)
        pay.editor.before_save(None)
        pay.save()
Пример #5
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)
Пример #6
0
def _add_test_expenses(expense_account1, expense_account2, simple,
                       with_payoff):
    expense1 = Expense(date=convert_date('2015-05-07'),
                       comment='opq 666',
                       expensetype=0,
                       third_id=2)
    expense1.editor.before_save(None)
    expense1.save()
    ExpenseDetail.objects.create(expense=expense1,
                                 set_id=2,
                                 designation='set 2',
                                 expense_account=expense_account1,
                                 price='100')
    expense1.valid()
    if not simple:
        expense2 = Expense(date=convert_date('2015-08-28'),
                           comment='creation',
                           expensetype=0,
                           third_id=2)
        expense2.editor.before_save(None)
        expense2.save()
        ExpenseDetail.objects.create(expense=expense2,
                                     set_id=3,
                                     designation='set 1',
                                     expense_account=expense_account2,
                                     price='75')
        expense2.valid()
    if with_payoff:
        pay = Payoff(supporting_id=expense1.id,
                     date='2015-05-11',
                     mode=0,
                     amount=35.0)
        pay.editor.before_save(None)
        pay.save()
        pay = Payoff(supporting_id=expense2.id,
                     date='2015-08-30',
                     mode=0,
                     amount=75.0)
        pay.editor.before_save(None)
        pay.save()