Adds test for manual invoicing
This commit is contained in:
parent
2e5a8e3668
commit
6469bcd8e7
2 changed files with 27 additions and 1 deletions
|
@ -184,7 +184,7 @@ class InvoiceController(ForId, object):
|
|||
invoice = commerce.Invoice.objects.create(
|
||||
user=user,
|
||||
cart=cart,
|
||||
cart_revision=cart.revision,
|
||||
cart_revision=cart.revision if cart else None,
|
||||
status=commerce.Invoice.STATUS_UNPAID,
|
||||
value=invoice_value,
|
||||
issue_time=issued,
|
||||
|
|
|
@ -580,6 +580,32 @@ class InvoiceTestCase(RegistrationCartTestCase):
|
|||
cn2.credit_note.value,
|
||||
)
|
||||
|
||||
def test_can_generate_manual_invoice(self):
|
||||
|
||||
description_price_pairs = [
|
||||
("Item 1", 15),
|
||||
("Item 2", 30),
|
||||
]
|
||||
|
||||
due_delta = datetime.timedelta(hours=24)
|
||||
|
||||
_invoice = TestingInvoiceController.manual_invoice(
|
||||
self.USER_1, due_delta, description_price_pairs
|
||||
)
|
||||
inv = TestingInvoiceController(_invoice)
|
||||
|
||||
self.assertEquals(
|
||||
inv.invoice.value,
|
||||
sum(i[1] for i in description_price_pairs)
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
len(inv.invoice.lineitem_set.all()),
|
||||
len(description_price_pairs)
|
||||
)
|
||||
|
||||
inv.pay("Demo payment", inv.invoice.value)
|
||||
|
||||
def test_sends_email_on_invoice_creation(self):
|
||||
invoice = self._invoice_containing_prod_1(1)
|
||||
self.assertEquals(1, len(self.emails))
|
||||
|
|
Loading…
Reference in a new issue