Example #1
0
 def create_model(self, store):
     used_colors = set([pc.color for pc in store.find(PaymentCategory)])
     color = get_random_color(ignore=used_colors)
     return PaymentCategory(name=u'',
                            color=color,
                            category_type=int(self._category_type),
                            store=store)
Example #2
0
    def test_create_category(self):
        category = PaymentCategory(store=self.store,
                                   name=u'TestCategory',
                                   category_type=PaymentCategory.TYPE_RECEIVABLE)
        editor = InPaymentEditor(self.store, category=category.name)

        self.check_editor(editor, 'editor-in-payment-create-with-category')
Example #3
0
 def create_payment_category(self, name=u'category', category_type=None):
     from stoqlib.domain.payment.category import PaymentCategory
     return PaymentCategory(name=name,
                            color=u'#ff0000',
                            store=self.store,
                            category_type=category_type
                            or PaymentCategory.TYPE_PAYABLE)
Example #4
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"))
Example #5
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"))
Example #6
0
    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())
Example #7
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)
Example #8
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())