@@ -531,12 +531,58 @@ class InvoiceTestCase(RegistrationCartTestCase):
invoice.refund()
# Now that we don't have CAT_1, we can't checkout this cart
with self.assertRaises(ValidationError):
invoice = TestingInvoiceController.for_cart(cart.cart)
def test_invoice_with_credit_note_applied_is_refunded(self):
''' Invoices with partial payments should void when cart is updated.
Test for issue #64 -- applying a credit note to an invoice
means that invoice cannot be voided, and new invoices cannot be
created. '''
cart = TestingCartController.for_user(self.USER_1)
cart.add_to_cart(self.PROD_1, 1)
# Now get a credit note
invoice.pay("Lol", invoice.invoice.value)
cn = self._credit_note_for_invoice(invoice.invoice)
# Create a cart of higher value than the credit note
cart.add_to_cart(self.PROD_1, 2)
# Create a current invoice, and apply partial payments
cn.apply_to_invoice(invoice.invoice)
# Adding to cart will mean that the old invoice for this cart
# will be invalidated. A new invoice should be generated.
invoice = TestingInvoiceController.for_id(invoice.invoice.id)
invoice2 = TestingInvoiceController.for_cart(cart.cart)
cn2 = self._credit_note_for_invoice(invoice.invoice)
invoice._refresh()
# The first invoice should be refunded
self.assertEquals(
commerce.Invoice.STATUS_VOID,
invoice.invoice.status,
)
# Both credit notes should be for the same amount
cn.credit_note.value,
cn2.credit_note.value,
def test_sends_email_on_invoice_creation(self):
invoice = self._invoice_containing_prod_1(1)
self.assertEquals(1, len(self.emails))
email = self.emails[0]
self.assertEquals([self.USER_1.email], email["to"])
self.assertEquals("invoice_created", email["kind"])