• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python sellable.SellableCategory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stoqlib.domain.sellable.SellableCategory的典型用法代码示例。如果您正苦于以下问题:Python SellableCategory类的具体用法?Python SellableCategory怎么用?Python SellableCategory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SellableCategory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_children_recursively

    def test_get_children_recursively(self):
        base_category = SellableCategory(description=u"Monitor",
                                         store=self.store)
        category = SellableCategory(description=u"LCD Monitor",
                                    category=base_category,
                                    store=self.store)

        self.assertEqual(category.get_children_recursively(), set())
        self.assertEqual(base_category.get_children_recursively(), set([category]))
开发者ID:hackedbellini,项目名称:stoq,代码行数:9,代码来源:test_sellable.py


示例2: test_get_base_categories

 def test_get_base_categories(self):
     categories = SellableCategory.get_base_categories(self.store)
     count = categories.count()
     base_category = SellableCategory(description=u"Monitor",
                                      store=self.store)
     category = SellableCategory(description=u"LCD Monitor",
                                 category=base_category,
                                 store=self.store)
     categories = SellableCategory.get_base_categories(self.store)
     self.failUnless(base_category in categories)
     self.failIf(category in categories)
     self.assertEqual(categories.count(), count + 1)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:12,代码来源:test_sellable.py


示例3: test_get_suggested_markup

    def test_get_suggested_markup(self):
        sellable = self.create_sellable()
        self.assertEqual(sellable.get_suggested_markup(), None)

        category = SellableCategory(description=u"LCD Monitor",
                                    store=self.store)
        sellable.category = category
        self.assertEqual(sellable.get_suggested_markup(), 0)

        category.suggested_markup = 10

        self.assertEqual(sellable.get_suggested_markup(), 10)
开发者ID:hackedbellini,项目名称:stoq,代码行数:12,代码来源:test_sellable.py


示例4: setUp

 def setUp(self):
     DomainTest.setUp(self)
     self._base_category = SellableCategory(description=u"Cigarro",
                                            store=self.store)
     self._category = SellableCategory(description=u"Hollywood",
                                       category=self._base_category,
                                       suggested_markup=10,
                                       store=self.store)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:8,代码来源:test_sellable.py


示例5: test_get_or_create_simple

    def test_get_or_create_simple(self):
        # This test is for a simple get_or_create (only one property)
        cat = self.store.find(SellableCategory, description=u'foo').one()
        self.assertEquals(cat, None)

        cat_a = SellableCategory.get_or_create(self.store, description=u'foo')
        self.assertEquals(cat_a.description, u'foo')

        cat_b = SellableCategory.get_or_create(self.store, description=u'foo')
        self.assertEquals(cat_a, cat_b)

        cat_c = SellableCategory.get_or_create(self.store, description=u'bar')
        self.assertNotEquals(cat_a, cat_c)

        # Giving an invalid property should raise an error
        self.assertRaises(AttributeError, SellableCategory.get_or_create,
                          self.store, foo=123)
开发者ID:rosalin,项目名称:stoq,代码行数:17,代码来源:test_domain.py


示例6: test_get_tax_constant

    def test_get_tax_constant(self):
        base_category = SellableCategory(description=u"Monitor",
                                         store=self.store)
        category = SellableCategory(description=u"LCD Monitor",
                                    category=base_category,
                                    store=self.store)
        sellable = self.create_sellable()
        sellable.tax_constant = None
        sellable.category = category

        self.assertEquals(sellable.get_tax_constant(), None)

        constant = self.create_sellable_tax_constant()
        base_category.tax_constant = constant
        self.assertEquals(sellable.get_tax_constant(), constant)

        constant2 = self.create_sellable_tax_constant()
        category.tax_constant = constant2
        self.assertEquals(sellable.get_tax_constant(), constant2)

        constant3 = self.create_sellable_tax_constant()
        sellable.tax_constant = constant3
        self.assertEquals(sellable.get_tax_constant(), constant3)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:23,代码来源:test_sellable.py


示例7: _setup_widgets

    def _setup_widgets(self):
        # open inventory button
        self.main_dialog.ok_button.set_label(_(u"_Open"))
        # select all the branches that are able to open an inventory
        branches = []
        for branch in self._branches:
            branches.append((branch.person.name, branch))
        self.branch_combo.prefill(branches)
        self.branch_combo.select(branches[0][1])

        self.username.set_text(self.model.user.person.name)
        self.open_time.set_text(self.model.open_date.strftime("%X"))
        # load categories
        self.category_tree.set_columns(self._get_columns())
        for category in SellableCategory.get_base_categories(self.store):
            self._append_category(category)

        self.category_tree.connect(
            'cell-edited', self._on_category_tree__cell_edited)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:19,代码来源:openinventorydialog.py


示例8: _setup_widgets

    def _setup_widgets(self):
        self.product_manufacturer.prefill(
            api.for_combo(self.store.find(ProductManufacturer)))

        self.product_brand.prefill(
            [(m, m) for m in
             sorted(Product.find_distinct_values(self.store, Product.brand))])

        self.product_family.prefill(
            [(m, m) for m in
             sorted(Product.find_distinct_values(self.store, Product.family))])

        self.username.set_text(self.model.user.person.name)
        self.open_time.set_text(self.model.open_date.strftime("%X"))
        # load categories
        self.category_tree.set_columns(self._get_columns())
        for category in SellableCategory.get_base_categories(self.store):
            self._append_category(category)

        self._uncategorized_products = self._append_category(
            _UncategorizedProductsCategory())
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:21,代码来源:inventoryeditor.py


示例9: TestSellable

class TestSellable(DomainTest):
    def setUp(self):
        DomainTest.setUp(self)
        self._base_category = SellableCategory(description=u"Cigarro",
                                               store=self.store)
        self._category = SellableCategory(description=u"Hollywood",
                                          category=self._base_category,
                                          suggested_markup=10,
                                          store=self.store)

    def test_price_based_on_category_markup(self):
        # When the price isn't defined, but the category and the cost. In this
        # case the sellable must have the price calculated applying the category's
        # markup in the sellable's cost.
        self._category.suggested_markup = 0
        sellable = Sellable(description=u"MX123",
                            commission=0,
                            cost=100,
                            category=self._category,
                            store=self.store)
        sellable.max_discount = 0
        self.failUnless(sellable.markup == self._category.get_markup(),
                        (u"Expected markup: %r, got %r"
                         % (self._category.get_markup(),
                            sellable.markup)))
        price = sellable.cost * (sellable.markup / currency(100) + 1)
        self.failUnless(sellable.price == price,
                        (u"Expected price: %r, got %r"
                         % (price, sellable.price)))

    def test_price_based_on_specified_markup(self):
        # When the price isn't defined, but the category, markup and the cost.
        # In this case the category's markup must be ignored and the price
        # calculated applying the markup specified in the sellable's cost.
        sellable = Sellable(description=u"FY123",
                            category=self._category,
                            cost=100,
                            store=self.store)
        sellable.markup = 5
        self.assertEquals(sellable.markup, 5)
        self.assertEquals(sellable.price, 105)

        sellable.cost = Decimal('100.33')
        sellable.markup = 7
        self.assertEquals(sellable.price, currency('107.35'))

        sellable.markup = 8
        self.assertEquals(sellable.price, currency('108.36'))

    def test_commission(self):
        self._category.salesperson_commission = 10
        sellable = Sellable(description=u"TX342",
                            category=self._category,
                            store=self.store)
        self.failUnless(sellable.commission
                        == self._category.salesperson_commission,
                        (u"Expected salesperson commission: %r, got %r"
                         % (self._category.salesperson_commission,
                            sellable.commission)))

    def test_prices_and_markups(self):
        self._category.markup = 0
        sellable = Sellable(category=self._category, cost=50,
                            description=u"Test", price=currency(100),
                            store=self.store)
        self.failUnless(sellable.price == 100,
                        u"Expected price: %r, got %r" % (100, sellable.price))
        self.failUnless(sellable.markup == 100,
                        u"Expected markup: %r, got %r" % (100, sellable.markup))
        sellable.markup = 10
        self.failUnless(sellable.price == 55,
                        u"Expected price: %r, got %r" % (55, sellable.price))
        sellable.price = 50
        self.failUnless(sellable.markup == 0,
                        u"Expected markup %r, got %r" % (0, sellable.markup))

        # When the price specified isn't equivalent to the markup specified.
        # In this case the price don't must be updated based on the markup.
        sellable = Sellable(cost=50,
                            description=u"Test", price=currency(100),
                            store=self.store)
        self.failUnless(sellable.price == 100)

        # A simple test: product without cost and price, markup must be 0
        sellable.cost = currency(0)
        sellable.price = currency(0)
        self.failUnless(sellable.markup == 0,
                        u"Expected markup %r, got %r" % (0, sellable.markup))

    def test_get_available_sellables_query(self):
        # Sellable and query without supplier
        sellable = self.create_sellable()
        self.create_storable(product=sellable.product,
                             branch=self.create_branch())

        self.assertIn(
            sellable,
            self.store.find(Sellable,
                            Sellable.get_available_sellables_query(self.store)))

#.........这里部分代码省略.........
开发者ID:LeonamSilva,项目名称:stoq,代码行数:101,代码来源:test_sellable.py


示例10: TestSellable

class TestSellable(DomainTest):
    def setUp(self):
        DomainTest.setUp(self)
        self._base_category = SellableCategory(description=u"Cigarro",
                                               store=self.store)
        self._category = SellableCategory(description=u"Hollywood",
                                          category=self._base_category,
                                          suggested_markup=10,
                                          store=self.store)

    def test_get_description(self):
        sellable = self.create_sellable()
        sellable.category = self._category
        self.assertEqual(sellable.get_description(), 'Description')
        self.assertEqual(sellable.get_description(full_description=True),
                         '[Hollywood] Description')

    def test_get_category_description(self):
        sellable = self.create_sellable()
        sellable.category = self._category
        self.assertEqual(sellable.get_category_description(), 'Hollywood')

    def test_price_based_on_category_markup(self):
        # When the price isn't defined, but the category and the cost. In this
        # case the sellable must have the price calculated applying the category's
        # markup in the sellable's cost.
        self._category.suggested_markup = 0
        sellable = Sellable(description=u"MX123",
                            commission=0,
                            cost=100,
                            category=self._category,
                            store=self.store)
        sellable.max_discount = 0
        self.assertTrue(sellable.markup == self._category.get_markup(),
                        (u"Expected markup: %r, got %r"
                         % (self._category.get_markup(),
                            sellable.markup)))
        price = sellable.cost * (sellable.markup / currency(100) + 1)
        self.assertTrue(sellable.price == price,
                        (u"Expected price: %r, got %r"
                         % (price, sellable.price)))

    def test_price_based_on_specified_markup(self):
        # When the price isn't defined, but the category, markup and the cost.
        # In this case the category's markup must be ignored and the price
        # calculated applying the markup specified in the sellable's cost.
        sellable = Sellable(description=u"FY123",
                            category=self._category,
                            cost=100,
                            store=self.store)
        sellable.markup = 5
        self.assertEqual(sellable.markup, 5)
        self.assertEqual(sellable.price, 105)

        sellable.cost = Decimal('100.33')
        sellable.markup = 7
        self.assertEqual(sellable.price, currency('107.35'))

        sellable.markup = 8
        self.assertEqual(sellable.price, currency('108.36'))

    def test_commission(self):
        self._category.salesperson_commission = 10
        sellable = Sellable(description=u"TX342",
                            category=self._category,
                            store=self.store)
        self.assertTrue(sellable.commission
                        == self._category.salesperson_commission,
                        (u"Expected salesperson commission: %r, got %r"
                         % (self._category.salesperson_commission,
                            sellable.commission)))

    def test_prices_and_markups(self):
        self._category.markup = 0
        sellable = Sellable(category=self._category, cost=50,
                            description=u"Test", price=currency(100),
                            store=self.store)
        self.assertTrue(sellable.price == 100,
                        u"Expected price: %r, got %r" % (100, sellable.price))
        self.assertTrue(sellable.markup == 100,
                        u"Expected markup: %r, got %r" % (100, sellable.markup))
        sellable.markup = 10
        self.assertTrue(sellable.price == 55,
                        u"Expected price: %r, got %r" % (55, sellable.price))
        sellable.price = 50
        self.assertTrue(sellable.markup == 0,
                        u"Expected markup %r, got %r" % (0, sellable.markup))

        # When the price specified isn't equivalent to the markup specified.
        # In this case the price don't must be updated based on the markup.
        sellable = Sellable(cost=50,
                            description=u"Test", price=currency(100),
                            store=self.store)
        self.assertTrue(sellable.price == 100)

        # A simple test: product without cost and price, markup must be 0
        sellable.cost = currency(0)
        sellable.price = currency(0)
        self.assertTrue(sellable.markup == 0,
                        u"Expected markup %r, got %r" % (0, sellable.markup))
#.........这里部分代码省略.........
开发者ID:hackedbellini,项目名称:stoq,代码行数:101,代码来源:test_sellable.py



注:本文中的stoqlib.domain.sellable.SellableCategory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sellable.SellableTaxConstant类代码示例发布时间:2022-05-27
下一篇:
Python sellable.Sellable类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap