Changeset - fd9980efc578
[Not reviewed]
0 2 0
Christopher Neugebauer - 8 years ago 2016-09-15 01:41:50
chrisjrn@gmail.com
Makes sure we only apply unclaimed credit notes when auto-applying credit notes.
2 files changed with 15 insertions and 1 deletions:
0 comments (0 inline, 0 general)
registrasion/controllers/invoice.py
Show inline comments
...
 
@@ -217,7 +217,9 @@ class InvoiceController(ForId, object):
 
        if invoices.count() > 1:
 
            return
 

	
 
        notes = commerce.CreditNote.objects.filter(invoice__user=invoice.user)
 
        notes = commerce.CreditNote.unclaimed().filter(
 
            invoice__user=invoice.user
 
        )
 
        for note in notes:
 
            try:
 
                CreditNoteController(note).apply_to_invoice(invoice)
registrasion/tests/test_credit_note.py
Show inline comments
...
 
@@ -428,3 +428,15 @@ class CreditNoteTestCase(TestHelperMixin, RegistrationCartTestCase):
 
        # The credit notes are not automatically applied.
 
        self.assertEqual(0, invoice.total_payments())
 
        self.assertTrue(invoice.invoice.is_unpaid)
 

	
 
    def test_credit_notes_are_applied_even_if_some_notes_are_claimed(self):
 

	
 
        for i in xrange(10):
 
            # Generate credit note
 
            invoice1 = self._manual_invoice(1)
 
            invoice1.pay("Pay", invoice1.invoice.value)
 
            invoice1.refund()
 

	
 
            # Generate invoice that should be automatically paid
 
            invoice2 = self._manual_invoice(1)
 
            self.assertTrue(invoice2.invoice.is_paid)
0 comments (0 inline, 0 general)