Exemple #1
0
 def populate(self, value):
     from stoqlib.domain.payment.category import PaymentCategory
     store = get_store_for_field(self)
     categories = PaymentCategory.get_by_type(store, self.category_type)
     values = api.for_combo(
         categories, empty=_('No category'), attr='name')
     self.prefill(values, value)
     # FIXME: Move to noun
     self.add_button.set_tooltip_text(_("Add a new payment category"))
     self.edit_button.set_tooltip_text(_("Edit the selected payment category"))
Exemple #2
0
 def populate(self, value):
     from stoqlib.domain.payment.category import PaymentCategory
     store = get_store_for_field(self)
     categories = PaymentCategory.get_by_type(store, self.category_type)
     values = api.for_combo(
         categories, empty=_('No category'), attr='name')
     self.prefill(values, value)
     # FIXME: Move to noun
     self.add_button.set_tooltip_text(_("Add a new payment category"))
     self.edit_button.set_tooltip_text(_("Edit the selected payment category"))
    def testGetByType(self):
        pcs = PaymentCategory.get_by_type(self.store,
                                          PaymentCategory.TYPE_RECEIVABLE)
        self.assertTrue(pcs.is_empty())
        pcs = PaymentCategory.get_by_type(self.store,
                                          PaymentCategory.TYPE_PAYABLE)
        self.assertTrue(pcs.is_empty())

        category = self.create_payment_category()
        category.name = u'receiviable'
        category.category_type = PaymentCategory.TYPE_RECEIVABLE

        pcs = PaymentCategory.get_by_type(self.store,
                                          PaymentCategory.TYPE_RECEIVABLE)
        self.assertFalse(pcs.is_empty())
        pcs = PaymentCategory.get_by_type(self.store,
                                          PaymentCategory.TYPE_PAYABLE)
        self.assertTrue(pcs.is_empty())

        category = self.create_payment_category()
        category.name = u'payable'
        category.category_type = PaymentCategory.TYPE_PAYABLE

        pcs = PaymentCategory.get_by_type(self.store,
                                          PaymentCategory.TYPE_RECEIVABLE)
        self.assertFalse(pcs.is_empty())
        pcs = PaymentCategory.get_by_type(self.store,
                                          PaymentCategory.TYPE_PAYABLE)
        self.assertFalse(pcs.is_empty())
Exemple #4
0
    def add_filter_items(self, category_type, options):
        categories = PaymentCategory.get_by_type(self.store, category_type)
        items = [(_('All payments'), None)]

        if categories.count() > 0:
            options.append(FilterItem('sep', 'sep'))

        items.extend([(item.name, item) for item in options])
        for c in categories:
            item = FilterItem(c.name, 'category:%s' % (c.name, ),
                              color=c.color,
                              item_id=c.id)
            items.append((item.name, item))

        self.main_filter.update_values(items)
Exemple #5
0
    def add_filter_items(self, category_type, options):
        categories = PaymentCategory.get_by_type(self.store, category_type)
        items = [(_('All payments'), None)]

        if categories.count() > 0:
            options.append(FilterItem('sep', 'sep'))

        items.extend([(item.name, item) for item in options])
        for c in categories:
            item = FilterItem(c.name, 'category:%s' % (c.name, ),
                              color=c.color,
                              item_id=c.id)
            items.append((item.name, item))

        self.main_filter.update_values(items)
    def testGetByType(self):
        pcs = PaymentCategory.get_by_type(self.store, PaymentCategory.TYPE_RECEIVABLE)
        self.assertTrue(pcs.is_empty())
        pcs = PaymentCategory.get_by_type(self.store, PaymentCategory.TYPE_PAYABLE)
        self.assertTrue(pcs.is_empty())

        category = self.create_payment_category()
        category.name = u'receiviable'
        category.category_type = PaymentCategory.TYPE_RECEIVABLE

        pcs = PaymentCategory.get_by_type(self.store, PaymentCategory.TYPE_RECEIVABLE)
        self.assertFalse(pcs.is_empty())
        pcs = PaymentCategory.get_by_type(self.store, PaymentCategory.TYPE_PAYABLE)
        self.assertTrue(pcs.is_empty())

        category = self.create_payment_category()
        category.name = u'payable'
        category.category_type = PaymentCategory.TYPE_PAYABLE

        pcs = PaymentCategory.get_by_type(self.store, PaymentCategory.TYPE_RECEIVABLE)
        self.assertFalse(pcs.is_empty())
        pcs = PaymentCategory.get_by_type(self.store, PaymentCategory.TYPE_PAYABLE)
        self.assertFalse(pcs.is_empty())