Commit 68f69340 authored by Patrick Kimber's avatar Patrick Kimber

Rename 'to_invoice' to 'to_invoice_contact'

parent 054c6d75
......@@ -1094,7 +1094,8 @@ class TimeRecordManager(models.Manager):
tickets.add(x.ticket.pk)
return Ticket.objects.filter(pk__in=tickets)
def to_invoice(self, contact, iteration_end):
# def to_invoice(self, contact, iteration_end):
def to_invoice_contact(self, contact, iteration_end):
"""
Find time records:
- before iteration ended
......
......@@ -139,7 +139,9 @@ class InvoiceCreate:
def create(self, user, contact, currency, iteration_end):
"""Create invoices from time records."""
invoice = None
time_records = TimeRecord.objects.to_invoice(contact, iteration_end)
time_records = TimeRecord.objects.to_invoice_contact(
contact, iteration_end
)
self._is_valid(contact, time_records, raise_exception=True)
with transaction.atomic():
if time_records.count():
......@@ -157,11 +159,13 @@ class InvoiceCreate:
def draft(self, contact, iteration_end):
"""Return a queryset with time records selected to invoice"""
return TimeRecord.objects.to_invoice(contact, iteration_end)
return TimeRecord.objects.to_invoice_contact(contact, iteration_end)
def is_valid(self, contact, raise_exception=None):
iteration_end = date.today()
time_records = TimeRecord.objects.to_invoice(contact, iteration_end)
time_records = TimeRecord.objects.to_invoice_contact(
contact, iteration_end
)
return self._is_valid(contact, time_records, raise_exception)
def refresh(self, user, invoice, iteration_end):
......@@ -170,7 +174,7 @@ class InvoiceCreate:
raise InvoiceError(
"Time records can only be added to a draft invoice."
)
time_records = TimeRecord.objects.to_invoice(
time_records = TimeRecord.objects.to_invoice_contact(
invoice.contact, iteration_end
)
self._is_valid(invoice.contact, time_records, raise_exception=True)
......@@ -179,7 +183,7 @@ class InvoiceCreate:
return invoice
class InvoiceCreateBatch(object):
class InvoiceCreateBatch:
def create(self, user, currency, iteration_end):
""" Create invoices from time records """
invoice_create = InvoiceCreate()
......
......@@ -267,7 +267,7 @@ def test_tickets():
@pytest.mark.django_db
def test_to_invoice():
def test_to_invoice_contact():
contact = ContactFactory()
d = date(2012, 7, 1)
#
......@@ -303,7 +303,7 @@ def test_to_invoice():
TimeRecordFactory(
title="t6", ticket=TicketFactory(contact=contact), date_started=d
)
qs = TimeRecord.objects.to_invoice(contact, date(2012, 7, 31))
qs = TimeRecord.objects.to_invoice_contact(contact, date(2012, 7, 31))
assert ["t1", "t6"] == [x.title for x in qs]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment