Makes sure we only apply unclaimed credit notes when auto-applying credit notes.
This commit is contained in:
		
							parent
							
								
									77a7689de5
								
							
						
					
					
						commit
						fd9980efc5
					
				
					 2 changed files with 15 additions and 1 deletions
				
			
		|  | @ -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) | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer