Exemple #1
0
    def test_sale_editor_confirmed_sale(self):
        sale = self._create_sale()
        sale.order()
        sale.confirm()
        editor = SalePaymentsEditor(self.store, sale)
        payments = editor.slave.payments
        payments.select(payments[0])

        # Before removing the payment, the dialog should be confirmable
        self.assertSensitive(editor.main_dialog, ['ok_button'])
        self.click(editor.slave.remove_button)

        # But we cannot confirm after removing it.
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])

        # Lets add another payment
        self.click(editor.slave.add_button)
        self.assertSensitive(editor.main_dialog, ['ok_button'])

        # There should be one preview payment
        for payment in payments:
            if payment.status == payment.STATUS_PREVIEW:
                break
        assert payment.status == payment.STATUS_PREVIEW

        # Confirming the dialog should change the new payment to pending
        editor.confirm()
        assert payment.status == payment.STATUS_PENDING
Exemple #2
0
    def test_sale_editor_remove_preview_payment(self):
        sale = self._create_sale()
        editor = SalePaymentsEditor(self.store, sale)

        payment = sale.payments[0]
        editor.slave.payments.select(payment)

        # Removing a PREVIEW payment will remove it from the list
        self.assertEquals(payment.status, Payment.STATUS_PREVIEW)
        self.click(editor.slave.remove_button)
        self.assertEquals(len(editor.slave.payments), 0)
Exemple #3
0
    def test_sale_editor_remove_pending_payment(self):
        sale = self._create_sale()
        editor = SalePaymentsEditor(self.store, sale)

        payment = sale.payments[0]
        payment.status = Payment.STATUS_PENDING
        editor.slave.payments.select(payment)

        # Removing an already confirmed payment will just cancel it
        self.assertEquals(payment.status, Payment.STATUS_PENDING)
        self.click(editor.slave.remove_button)
        self.assertEquals(len(editor.slave.payments), 1)
        self.assertEquals(payment.status, Payment.STATUS_CANCELLED)
    def test_pay_with_credit(self):
        client = self.create_client()
        sale = self.create_sale(client=client)
        sale.identifier = 1234
        sellable = self.create_sellable(price=10)
        sale.add_sellable(sellable)

        # Create credit to the client.
        method = PaymentMethod.get_by_name(self.store, u'credit')
        group = self.create_payment_group(payer=client.person)
        payment = self.create_payment(value=20, method=method, group=group)
        payment.set_pending()
        payment.pay()
        self.assertEquals(client.credit_account_balance, 20)

        editor = SalePaymentsEditor(self.store, sale)
        # Select credit method.
        for radio in editor.slave.methods_box.get_children():
            if radio.get_label() == 'Credit ($20.00)':
                radio.set_active(True)
                break
        # Add credit payment.
        editor.slave.value.update(10)
        self.assertSensitive(editor.slave, ['add_button'])
        self.click(editor.slave.add_button)
        editor.confirm()
        self.assertEquals(client.credit_account_balance, 10)
        for payment in sale.payments:
            self.assertEquals(payment.status, Payment.STATUS_PAID)

        # Test remove payment.
        self.assertNotSensitive(editor.slave, ['remove_button'])
        editor = SalePaymentsEditor(self.store, sale)
        payments = editor.slave.payments
        payments.select(payments[0])
        self.assertSensitive(editor.slave, ['remove_button'])
        self.click(editor.slave.remove_button)
        editor.confirm()
        for payment in sale.payments:
            self.assertEquals(payment.status, Payment.STATUS_CANCELLED)
    def test_pay_with_credit(self):
        client = self.create_client()
        sale = self.create_sale(client=client)
        sale.identifier = 1234
        sellable = self.create_sellable(price=10)
        sale.add_sellable(sellable)

        # Create credit to the client.
        method = PaymentMethod.get_by_name(self.store, u"credit")
        group = self.create_payment_group(payer=client.person)
        payment = self.create_payment(value=20, method=method, group=group)
        payment.set_pending()
        payment.pay()
        self.assertEquals(client.credit_account_balance, 20)

        editor = SalePaymentsEditor(self.store, sale)
        # Select credit method.
        for radio in editor.slave.methods_box.get_children():
            if radio.get_label() == "Credit ($20.00)":
                radio.set_active(True)
                break
        # Add credit payment.
        editor.slave.value.update(10)
        self.assertSensitive(editor.slave, ["add_button"])
        self.click(editor.slave.add_button)
        editor.confirm()
        self.assertEquals(client.credit_account_balance, 10)
        for payment in sale.payments:
            self.assertEquals(payment.status, Payment.STATUS_PAID)

        # Test remove payment.
        self.assertNotSensitive(editor.slave, ["remove_button"])
        editor = SalePaymentsEditor(self.store, sale)
        payments = editor.slave.payments
        payments.select(payments[0])
        self.assertSensitive(editor.slave, ["remove_button"])
        self.click(editor.slave.remove_button)
        editor.confirm()
        for payment in sale.payments:
            self.assertEquals(payment.status, Payment.STATUS_CANCELLED)
Exemple #6
0
 def test_sale_editor_show(self):
     sale = self._create_sale()
     editor = SalePaymentsEditor(self.store, sale)
     self.check_editor(editor, 'editor-payment-installments')
 def test_show(self):
     client = self.create_client()
     sale = self.create_sale(client=client)
     editor = SalePaymentsEditor(self.store, sale)
     self.check_editor(editor, 'editor-salepayments-show')