当前位置: 首页>>代码示例>>Python>>正文


Python PaymentMethod.get_by_name方法代码示例

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


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

示例1: test_can_purchase_disallow_store_credit

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:37,代码来源:test_person.py

示例2: test_pay_money_payments

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:27,代码来源:test_payment_group.py

示例3: test_can_purchase_allow_all

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:35,代码来源:test_person.py

示例4: test_get_payment_by_method_name

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:28,代码来源:test_payment_group.py

示例5: test_order_receive_sell

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:36,代码来源:test_receiving.py

示例6: test_till_daily_movement

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:59,代码来源:test_reporting.py

示例7: createOutPayments

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
 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,代码行数:9,代码来源:test_payment_method.py

示例8: testBank

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
 def testBank(self):
     sale = self.create_sale()
     method = PaymentMethod.get_by_name(self.store, self.method_type)
     payment = method.create_outpayment(sale.group, sale.branch, Decimal(10))
     check_data = method.operation.get_check_data_by_payment(payment)
     check_data.bank_account.bank_number = 123
     self.assertEquals(payment.bank_account_number, 123)
开发者ID:romaia,项目名称:stoq,代码行数:9,代码来源:test_payment_method.py

示例9: createInPayments

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
 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,代码行数:9,代码来源:test_payment_method.py

示例10: test_create

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    def test_create(self):
        wizard = PurchaseWizard(self.store)

        method = PaymentMethod.get_by_name(self.store, u"card")
        order = self.create_purchase_order()
        slave = CardMethodSlave(wizard, None, self.store, order, method, Decimal(200))
        self.check_slave(slave, "slave-card-method")
开发者ID:rosalin,项目名称:stoq,代码行数:9,代码来源:test_payment_slave.py

示例11: trade

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:27,代码来源:returnedsale.py

示例12: test_negative_credit

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    def test_negative_credit(self):
        method = PaymentMethod.get_by_name(self.store, u'credit')
        client = self.create_client()
        group = self.create_payment_group(payer=client.person)

        payment = self.create_payment(method=method,
                                      payment_type=Payment.TYPE_OUT, value=6,
                                      group=group)
        payment.set_pending()
        payment.pay()

        editor = CreditEditor(self.store, client)
        editor.description.set_text('Desc')

        editor.value.set_text('-5')
        self.assertValid(editor, ['value'])
        self.assertSensitive(editor.main_dialog, ['ok_button'])

        editor.value.set_text('-6')
        self.assertValid(editor, ['value'])
        self.assertSensitive(editor.main_dialog, ['ok_button'])

        editor.value.set_text('-7')
        self.assertInvalid(editor, ['value'])
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:27,代码来源:test_crediteditor.py

示例13: test_installments_commission_amount_with_multiple_items

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    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,代码行数:37,代码来源:test_payment_group.py

示例14: test_has_late_payments

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    def test_has_late_payments(self):
        client = self.create_client()
        today = localtoday().date()
        method = PaymentMethod.get_by_name(self.store, u'bill')

        # client does not have any payments
        self.assertFalse(InPaymentView.has_late_payments(self.store,
                                                         client.person))

        # client has payments that are not overdue
        payment = self.create_payment(Payment.TYPE_IN,
                                      today + relativedelta(days=1),
                                      method=method)
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertFalse(InPaymentView.has_late_payments(self.store,
                                                         client.person))

        # client has overdue payments
        payment = self.create_payment(Payment.TYPE_IN,
                                      today - relativedelta(days=2),
                                      method=method)
        payment.status = Payment.STATUS_PENDING
        payment.group = self.create_payment_group()
        payment.group.payer = client.person
        self.assertTrue(InPaymentView.has_late_payments(self.store,
                                                        client.person))
开发者ID:leandrorchaves,项目名称:stoq,代码行数:29,代码来源:test_payment_views.py

示例15: testPartialReturnNotPaid

# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_by_name [as 别名]
    def testPartialReturnNotPaid(self):
        sale = self.create_sale()
        self.failIf(sale.can_return())

        self.add_product(sale, quantity=2, price=300)
        sale.order()
        self.failIf(sale.can_return())

        method = PaymentMethod.get_by_name(self.store, u'check')
        payment = method.create_inpayment(sale.group, sale.branch, Decimal(600))
        sale.confirm()
        self.failUnless(sale.can_return())

        returned_sale = sale.create_sale_return_adapter()
        list(returned_sale.returned_items)[0].quantity = 1

        # Mimic what is done on sale return wizard that is to cancel
        # the existing payment and create another one with the new
        # total (in this case, 300)
        method.create_inpayment(sale.group, sale.branch, Decimal(300))
        payment.cancel()

        returned_sale.return_()
        self.failUnless(sale.can_return())
        self.assertEqual(sale.status, Sale.STATUS_CONFIRMED)

        returned_amount = 0
        for payment in sale.payments:
            if payment.is_outpayment():
                returned_amount += payment.value
        self.assertEqual(returned_amount, currency(0))
开发者ID:romaia,项目名称:stoq,代码行数:33,代码来源:test_sale.py


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