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

Python method.PaymentMethod类代码示例

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

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



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

示例1: test_pay_money_payments

    def test_pay_money_payments(self):
        branch = self.create_branch()
        group = self.create_payment_group()

        method = PaymentMethod.get_by_name(self.store, u'bill')
        payment1 = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(10))
        payment2 = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(10))
        method = PaymentMethod.get_by_name(self.store, u'money')
        method.max_installments = 2
        payment3 = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(10))
        payment4 = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(10))
        group.confirm()

        self.assertEqual(payment1.status, Payment.STATUS_PENDING)
        self.assertEqual(payment2.status, Payment.STATUS_PENDING)
        self.assertEqual(payment3.status, Payment.STATUS_PENDING)
        self.assertEqual(payment4.status, Payment.STATUS_PENDING)
        payment3.pay()
        self.assertEqual(payment3.status, Payment.STATUS_PAID)

        group.pay_method_payments(u'money')
        self.assertEqual(payment1.status, Payment.STATUS_PENDING)
        self.assertEqual(payment2.status, Payment.STATUS_PENDING)
        self.assertEqual(payment3.status, Payment.STATUS_PAID)
        self.assertEqual(payment4.status, Payment.STATUS_PAID)
开发者ID:qman1989,项目名称:stoq,代码行数:25,代码来源:test_payment_group.py


示例2: test_order_receive_sell

    def test_order_receive_sell(self):
        product = self.create_product()
        storable = Storable(product=product, store=self.store)
        self.failIf(self.store.find(ProductStockItem, storable=storable).one())
        purchase_order = self.create_purchase_order()
        purchase_item = purchase_order.add_item(product.sellable, 1)
        purchase_order.status = purchase_order.ORDER_PENDING
        method = PaymentMethod.get_by_name(self.store, u'money')
        method.create_payment(Payment.TYPE_OUT,
                              purchase_order.group, purchase_order.branch,
                              purchase_order.get_purchase_total())
        purchase_order.confirm()

        receiving_order = self.create_receiving_order(purchase_order)
        receiving_order.branch = get_current_branch(self.store)
        self.create_receiving_order_item(
            receiving_order=receiving_order,
            sellable=product.sellable,
            purchase_item=purchase_item,
            quantity=1)
        self.failIf(self.store.find(ProductStockItem, storable=storable).one())
        receiving_order.confirm()
        product_stock_item = self.store.find(ProductStockItem,
                                             storable=storable).one()
        self.failUnless(product_stock_item)
        self.assertEquals(product_stock_item.quantity, 1)

        sale = self.create_sale()
        sale.add_sellable(product.sellable)
        sale.order()
        method = PaymentMethod.get_by_name(self.store, u'check')
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch, Decimal(100))
        sale.confirm()
        self.assertEquals(product_stock_item.quantity, 0)
开发者ID:rosalin,项目名称:stoq,代码行数:34,代码来源:test_receiving.py


示例3: test_create_payment

    def test_create_payment(self):
        acc = self.create_account()
        branch = self.create_branch()
        method = PaymentMethod(method_name=u'Test', destination_account=acc)
        group = self.create_payment_group()
        self.create_payment(payment_type=Payment.TYPE_IN, date=None,
                            value=100, method=method, branch=branch,
                            group=group)
        with self.assertRaisesRegex(
                PaymentMethodError,
                ('You can not create more inpayments for this payment '
                 'group since the maximum allowed for this payment '
                 'method is 1')):
            method.create_payment(payment_type=Payment.TYPE_IN, payment_group=group,
                                  branch=branch, value=100, due_date=None,
                                  description=None, base_value=None,
                                  payment_number=None)

        self.create_payment(payment_type=Payment.TYPE_IN, date=None,
                            value=100, method=method, branch=branch,
                            group=group)
        with self.assertRaises(DatabaseInconsistency):
            method.create_payment(payment_type=Payment.TYPE_IN, payment_group=group,
                                  branch=branch, value=100, due_date=None,
                                  description=None, base_value=None,
                                  payment_number=None)
开发者ID:hackedbellini,项目名称:stoq,代码行数:26,代码来源:test_payment_method.py


示例4: test_can_purchase_disallow_store_credit

    def test_can_purchase_disallow_store_credit(self):
        #: This parameter disallows the client to purchase with store credit
        #: when he has late payments
        sysparam(self.store).update_parameter(u'LATE_PAYMENTS_POLICY',
                                              unicode(int(LatePaymentPolicy.DISALLOW_STORE_CREDIT)))

        client = self.create_client()
        bill_method = PaymentMethod.get_by_name(self.store, u'bill')
        check_method = PaymentMethod.get_by_name(self.store, u'check')
        money_method = PaymentMethod.get_by_name(self.store, u'money')
        store_credit_method = PaymentMethod.get_by_name(self.store,
                                                        u'store_credit')
        today = localtoday()

        # client can pay if he doesn't have any payments
        self.assertTrue(client.can_purchase(money_method, currency("0")))

        # client can pay if he has payments that are not overdue
        payment = self.create_payment(Payment.TYPE_IN, today, method=bill_method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(client.can_purchase(money_method, currency("0")))

        # for a client with overdue payments
        payment = self.create_payment(Payment.TYPE_IN,
                                      today - relativedelta(days=1),
                                      method=money_method)
        payment.status = Payment.STATUS_PENDING
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        # client can pay if payment method is not store credit
        self.assertTrue(client.can_purchase(check_method, currency("0")))
        self.assertTrue(client.can_purchase(money_method, currency("0")))
        # client can not pay if payment method is store credit
        self.assertRaises(SellError, client.can_purchase, store_credit_method, currency("0"))
开发者ID:rosalin,项目名称:stoq,代码行数:35,代码来源:test_person.py


示例5: test_can_purchase_allow_all

    def test_can_purchase_allow_all(self):
        #: This parameter always allows the client to purchase, no matter if he
        #: has late payments
        sysparam(self.store).update_parameter(u'LATE_PAYMENTS_POLICY',
                                              unicode(int(LatePaymentPolicy.ALLOW_SALES)))

        client = self.create_client()
        bill_method = PaymentMethod.get_by_name(self.store, u'bill')
        check_method = PaymentMethod.get_by_name(self.store, u'check')
        money_method = PaymentMethod.get_by_name(self.store, u'money')
        store_credit_method = PaymentMethod.get_by_name(self.store,
                                                        u'store_credit')
        today = localtoday()

        # client can pay if he doesn't have any payments
        client.credit_limit = Decimal("1000")
        self.assertTrue(client.can_purchase(money_method, currency("200")))

        # client can pay if he has payments that are not overdue
        payment = self.create_payment(Payment.TYPE_IN, today, method=bill_method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(client.can_purchase(check_method, currency("200")))

        # client can pay even if he does have overdue payments
        payment = self.create_payment(Payment.TYPE_IN,
                                      today - relativedelta(days=1), method=check_method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(client.can_purchase(store_credit_method, currency("200")))

        # But he cannot pay if its above the credit limit
        self.assertRaises(SellError, client.can_purchase, store_credit_method, currency("1001"))
开发者ID:rosalin,项目名称:stoq,代码行数:33,代码来源:test_person.py


示例6: test_get_payment_by_method_name

    def test_get_payment_by_method_name(self):
        group = self.create_payment_group()

        method = PaymentMethod.get_by_name(self.store, u'money')
        money_payment1 = self.create_payment(method=method)
        group.add_item(money_payment1)
        money_payment2 = self.create_payment(method=method)
        group.add_item(money_payment2)

        method = PaymentMethod.get_by_name(self.store, u'check')
        check_payment1 = self.create_payment(method=method)
        group.add_item(check_payment1)
        check_payment2 = self.create_payment(method=method)
        group.add_item(check_payment2)

        money_payments = group.get_payments_by_method_name(u'money')
        for payment in [money_payment1, money_payment2]:
            self.assertTrue(payment in money_payments)
        for payment in [check_payment1, check_payment2]:
            self.assertFalse(payment in money_payments)

        check_payments = group.get_payments_by_method_name(u'check')
        for payment in [check_payment1, check_payment2]:
            self.assertTrue(payment in check_payments)
        for payment in [money_payment1, money_payment2]:
            self.assertFalse(payment in check_payments)
开发者ID:qman1989,项目名称:stoq,代码行数:26,代码来源:test_payment_group.py


示例7: _setup_widgets

    def _setup_widgets(self):
        self.remove_button.hide()
        if isinstance(self.model, (PaymentRenegotiation, Sale, ReturnedSale,
                                   StockDecrease)):
            payment_type = Payment.TYPE_IN
        elif isinstance(self.model, PurchaseOrder):
            payment_type = Payment.TYPE_OUT
        else:
            raise AssertionError

        money_method = PaymentMethod.get_by_name(self.store, u'money')
        self._add_method(money_method)
        for method in PaymentMethod.get_creatable_methods(
            self.store, payment_type, separate=False):
            if method.method_name in [u'multiple', u'money']:
                continue
            self._add_method(method)

        self.payments.set_columns(self._get_columns())
        self.payments.add_list(self.model.group.payments)

        self.total_value.set_bold(True)
        self.received_value.set_bold(True)
        self.missing_value.set_bold(True)
        self.total_value.update(self._total_value)
        self.remove_button.set_sensitive(False)
        self._update_values()
开发者ID:romaia,项目名称:stoq,代码行数:27,代码来源:paymentslave.py


示例8: test_inactivate

 def test_inactivate(self):
     acc = self.create_account()
     method = PaymentMethod(method_name=u'Test', destination_account=acc)
     self.assertIsNone(method.inactivate())
     method.is_active = False
     with self.assertRaises(AssertionError) as error:
         method.inactivate()
     self.assertEqual(str(error.exception), 'This provider is already inactive')
开发者ID:hackedbellini,项目名称:stoq,代码行数:8,代码来源:test_payment_method.py


示例9: test_till_daily_movement

    def test_till_daily_movement(self):
        date = datetime.date(2013, 1, 1)
        # create sale payment
        sale = self.create_sale()
        sellable = self.create_sellable()
        sale.add_sellable(sellable, price=100)
        sale.identifier = 1000
        sale.order()

        method = PaymentMethod.get_by_name(self.store, u'money')
        till = Till.get_last_opened(self.store)
        payment = method.create_payment(Payment.TYPE_IN, sale.group, sale.branch,
                                        sale.get_sale_subtotal(),
                                        till=till)
        sale.confirm()
        sale.group.pay()

        sale.confirm_date = date

        payment.identifier = 1010
        payment.paid_date = date

        # create lonely input payment
        payer = self.create_client()
        address = self.create_address()
        address.person = payer.person

        method = PaymentMethod.get_by_name(self.store, u'money')
        group = self.create_payment_group()
        branch = self.create_branch()
        payment_lonely_input = method.create_payment(Payment.TYPE_IN, group, branch, Decimal(100))
        payment_lonely_input.description = u"Test receivable account"
        payment_lonely_input.group.payer = payer.person
        payment_lonely_input.set_pending()
        payment_lonely_input.pay()
        payment_lonely_input.identifier = 1001
        payment_lonely_input.paid_date = date

        # create purchase payment
        drawee = self.create_supplier()
        address = self.create_address()
        address.person = drawee.person

        method = PaymentMethod.get_by_name(self.store, u'money')
        group = self.create_payment_group()
        branch = self.create_branch()
        payment = method.create_payment(Payment.TYPE_OUT, group, branch, Decimal(100))
        payment.description = u"Test payable account"
        payment.group.recipient = drawee.person
        payment.set_pending()
        payment.pay()
        payment.identifier = 1002
        payment.paid_date = date

        # create lonely output payment
        self._diff_expected(TillDailyMovementReport,
                            'till-daily-movement-report', self.store, date)
开发者ID:rosalin,项目名称:stoq,代码行数:57,代码来源:test_reporting.py


示例10: testGetByAccount

 def testGetByAccount(self):
     account = self.create_account()
     methods = PaymentMethod.get_by_account(self.store, account)
     self.assertTrue(methods.is_empty())
     PaymentMethod(store=self.store,
                   method_name=u'test',
                   destination_account=account)
     methods = PaymentMethod.get_by_account(self.store, account)
     self.assertFalse(methods.is_empty())
开发者ID:romaia,项目名称:stoq,代码行数:9,代码来源:test_payment_method.py


示例11: test_create_payments_without_installments

 def test_create_payments_without_installments(self):
     acc = self.create_account()
     branch = self.create_branch()
     method = PaymentMethod(method_name=u'Test', destination_account=acc)
     group = self.create_payment_group()
     with self.assertRaises(ValueError) as error:
         method.create_payments(payment_type=Payment.TYPE_IN, group=group,
                                branch=branch, value=Decimal(100),
                                due_dates=[])
     self.assertEqual(str(error.exception), _('Need at least one installment'))
开发者ID:hackedbellini,项目名称:stoq,代码行数:10,代码来源:test_payment_method.py


示例12: testSalesPersonReport

    def testSalesPersonReport(self):
        sysparam(self.store).SALE_PAY_COMMISSION_WHEN_CONFIRMED = 1
        salesperson = self.create_sales_person()
        product = self.create_product(price=100)
        sellable = product.sellable

        sale = self.create_sale()
        sale.salesperson = salesperson
        sale.add_sellable(sellable, quantity=1)

        self.create_storable(product, get_current_branch(self.store), stock=100)

        CommissionSource(sellable=sellable,
                         direct_value=Decimal(10),
                         installments_value=1,
                         store=self.store)

        sale.order()

        method = PaymentMethod.get_by_name(self.store, u'money')
        till = Till.get_last_opened(self.store)
        method.create_inpayment(sale.group, sale.branch,
                                sale.get_sale_subtotal(),
                                till=till)
        sale.confirm()
        sale.set_paid()

        salesperson_name = salesperson.person.name
        commissions = list(self.store.find(CommissionView))
        commissions[0].identifier = 1
        commissions[1].identifier = 139

        self._diff_expected(SalesPersonReport, 'sales-person-report', commissions,
                            salesperson_name)
开发者ID:romaia,项目名称:stoq,代码行数:34,代码来源:test_reporting.py


示例13: trade

    def trade(self):
        """Do a trade for this return

        Almost the same as :meth:`.return_`, but unlike it, this won't
        generate reversed payments to the client. Instead, it'll
        generate an inpayment using :obj:`.returned_total` value,
        so it can be used as an "already paid quantity" on :obj:`.new_sale`.
        """
        assert self.new_sale
        if self.sale:
            assert self.sale.can_return()
        self._clean_not_used_items()

        store = self.store
        group = self.group
        method = PaymentMethod.get_by_name(store, u'trade')
        description = _(u'Traded items for sale %s') % (
            self.new_sale.identifier, )
        value = self.returned_total
        payment = method.create_payment(Payment.TYPE_IN, group, self.branch, value,
                                        description=description)
        payment.set_pending()
        payment.pay()

        self._return_sale(payment)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:25,代码来源:returnedsale.py


示例14: _create_inpayment

 def _create_inpayment(self):
     sale = self.create_sale()
     sellable = self.create_sellable()
     sale.add_sellable(sellable, price=10)
     method = PaymentMethod.get_by_name(self.store, u'bill')
     payment = method.create_payment(Payment.TYPE_IN, sale.group, sale.branch, Decimal(10))
     return payment
开发者ID:leandrorchaves,项目名称:stoq,代码行数:7,代码来源:test_till.py


示例15: test_get_total_value

    def test_get_total_value(self):
        method = PaymentMethod.get_by_name(self.store, u'check')

        # Test for a group in a sale
        # On sale's group, total value should return
        # sum(inpayments.value) - sum(outpayments.value)
        sale = self.create_sale()
        group = sale.group
        self.assertEqual(group.get_total_value(), 0)

        method.create_payment(Payment.TYPE_IN, group, sale.branch, Decimal(100))
        self.assertEqual(group.get_total_value(), Decimal(100))

        method.create_payment(Payment.TYPE_IN, group, sale.branch, Decimal(200))
        self.assertEqual(group.get_total_value(), Decimal(300))

        method.create_payment(Payment.TYPE_OUT, group, sale.branch, Decimal(50))
        self.assertEqual(group.get_total_value(), Decimal(250))

        # Test for a group in a purchase
        # On purchase's group, total value should return
        # sum(inpayments.value) - sum(outpayments.value)
        purchase = self.create_purchase_order()
        group = purchase.group
        self.assertEqual(group.get_total_value(), 0)

        method.create_payment(Payment.TYPE_OUT, group, purchase.branch, Decimal(100))
        self.assertEqual(group.get_total_value(), Decimal(100))

        method.create_payment(Payment.TYPE_OUT, group, purchase.branch, Decimal(200))
        self.assertEqual(group.get_total_value(), Decimal(300))

        method.create_payment(Payment.TYPE_IN, group, purchase.branch, Decimal(50))
        self.assertEqual(group.get_total_value(), Decimal(250))
开发者ID:qman1989,项目名称:stoq,代码行数:34,代码来源:test_payment_group.py


示例16: _create_payment

    def _create_payment(self):
        group = PaymentGroup()
        group.payer = self.client.person

        method = PaymentMethod.get_by_name(self.store, u'credit')
        branch = api.get_current_branch(self.store)

        if self.model.value < 0:
            payment_type = Payment.TYPE_IN
        else:
            payment_type = Payment.TYPE_OUT

        # Set status to PENDING now, to avoid calling set_pending on
        # on_confirm for payments that shoud not have its status changed.
        payment = Payment(open_date=localtoday(),
                          branch=branch,
                          status=Payment.STATUS_PENDING,
                          description=self.model.description,
                          value=abs(self.model.value),
                          base_value=abs(self.model.value),
                          due_date=localtoday(),
                          method=method,
                          group=group,
                          till=None,
                          category=None,
                          payment_type=payment_type,
                          bill_received=False)
        payment.pay()

        return payment
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:30,代码来源:crediteditor.py


示例17: test_installments_commission_amount_with_multiple_items

    def test_installments_commission_amount_with_multiple_items(self):
        self._payComissionWhenConfirmed()

        sale = self.create_sale()
        sellable = self.add_product(sale, price=300, quantity=3)
        sale.order()

        CommissionSource(sellable=sellable,
                         direct_value=12,
                         installments_value=5,
                         store=self.store)

        method = PaymentMethod.get_by_name(self.store, u'check')
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch, Decimal(300))
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch, Decimal(450))
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch, Decimal(150))
        self.assertTrue(self.store.find(Commission, sale=sale).is_empty())

        sale.confirm()

        commissions = self.store.find(Commission,
                                      sale=sale).order_by(Commission.value)
        self.assertEquals(commissions.count(), 3)
        for c in commissions:
            self.failUnless(c.commission_type == Commission.INSTALLMENTS)

        # the first payment represent 1/3 of the total amount
        # 45 / 6 => 7.50
        self.assertEquals(commissions[0].value, Decimal("7.50"))
        # the second payment represent 1/3 of the total amount
        # 5% of 900: 45,00 * 1/3 => 15,00
        self.assertEquals(commissions[1].value, Decimal("15.00"))
        # the third payment represent 1/2 of the total amount
        # 45 / 2 => 22,50
        self.assertEquals(commissions[2].value, Decimal("22.50"))
开发者ID:qman1989,项目名称:stoq,代码行数:35,代码来源:test_payment_group.py


示例18: createOutPayments

 def createOutPayments(self, no=3):
     purchase = self.create_purchase_order()
     d = datetime.datetime.today()
     method = PaymentMethod.get_by_name(self.store, self.method_type)
     payments = method.create_outpayments(purchase.group, purchase.branch, Decimal(100),
                                          [d] * no)
     return payments
开发者ID:romaia,项目名称:stoq,代码行数:7,代码来源:test_payment_method.py


示例19: _setup_payment_methods

    def _setup_payment_methods(self, payment_type):
        methods = PaymentMethod.get_creatable_methods(self.store, payment_type, separate=False)
        group = None
        for method in methods:
            method_name = method.method_name
            widget = gtk.RadioButton(group, N_(method.description))
            widget.connect("toggled", self._on_method__toggled)
            widget.set_data("method", method)
            if group is None:
                group = widget
            self.methods_box.pack_start(widget, False, False, 6)
            widget.show()

            self._methods[method_name] = method
            self._widgets[method_name] = widget
            self.method_set_sensitive(method_name, True)

        # Don't allow the user to change the kind of payment method if
        # there's only one
        if len(methods) == 1:
            self._widgets[methods[0].method_name].set_sensitive(False)
        else:
            # Money should be the first
            widget = self._widgets.get(u"money")
            if widget is not None:
                self.methods_box.reorder_child(widget, 0)

            # Multiple should be the last
            widget = self._widgets.get(u"multiple")
            if widget is not None:
                self.methods_box.reorder_child(widget, len(self.methods_box) - 1)
开发者ID:romaia,项目名称:stoq,代码行数:31,代码来源:paymentmethodslave.py


示例20: createInPayments

 def createInPayments(self, no=3):
     sale = self.create_sale()
     d = datetime.datetime.today()
     method = PaymentMethod.get_by_name(self.store, self.method_type)
     payments = method.create_inpayments(sale.group, sale.branch, Decimal(100),
                                         [d] * no)
     return payments
开发者ID:romaia,项目名称:stoq,代码行数:7,代码来源:test_payment_method.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python payment.Payment类代码示例发布时间:2022-05-27
下一篇:
Python card.CreditProvider类代码示例发布时间: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