diff --git a/core/migrations/0072_rename_first_payment_deadline_semester_half_payment_deadline_and_more.py b/core/migrations/0072_rename_first_payment_deadline_semester_half_payment_deadline_and_more.py new file mode 100644 index 00000000..3165a50b --- /dev/null +++ b/core/migrations/0072_rename_first_payment_deadline_semester_half_payment_deadline_and_more.py @@ -0,0 +1,20 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("core", "0071_alter_semester_first_payment_deadline_and_more"), + ] + + operations = [ + migrations.RenameField( + model_name="semester", + old_name="first_payment_deadline", + new_name="half_payment_deadline", + ), + migrations.RenameField( + model_name="semester", + old_name="most_payment_deadline", + new_name="full_payment_deadline", + ), + ] diff --git a/core/models.py b/core/models.py index 194b3241..6a17aadb 100644 --- a/core/models.py +++ b/core/models.py @@ -56,10 +56,10 @@ class Semester(models.Model): hour_rate = models.PositiveSmallIntegerField( default=80, help_text="The hourly rate for the semester." ) - first_payment_deadline = models.DateTimeField( + half_payment_deadline = models.DateTimeField( null=True, blank=True, help_text="Deadline for half payment." ) - most_payment_deadline = models.DateTimeField( + full_payment_deadline = models.DateTimeField( null=True, blank=True, help_text="Deadline for full payment." ) one_semester_date = models.DateTimeField( diff --git a/dashboard/templates/dashboard/portal.html b/dashboard/templates/dashboard/portal.html index 30b34494..42c921cb 100644 --- a/dashboard/templates/dashboard/portal.html +++ b/dashboard/templates/dashboard/portal.html @@ -57,26 +57,26 @@

{% if student.payment_status == 1 %} As a quick reminder, the deadline for initial payment is - {{ semester.first_payment_deadline|date }}. + {{ semester.half_payment_deadline|date }}. You have not sent any payment at all yet. {% elif student.payment_status == 2 %} - The payment deadline {{ semester.first_payment_deadline|date }} + The payment deadline {{ semester.half_payment_deadline|date }} has passed, but no payment was received. {% elif student.payment_status == 3 %} More than a week since the deadline - {{ semester.first_payment_deadline|date }} + {{ semester.half_payment_deadline|date }} has passed, but no payment is recorded. {% elif student.payment_status == 5 %} As a quick reminder, the deadline for full payment for all semesters is - {{ semester.most_payment_deadline|date }}. + {{ semester.full_payment_deadline|date }}. Your payment is still incomplete. {% elif student.payment_status == 6 %} The payment deadline - {{ semester.most_payment_deadline|date }} + {{ semester.full_payment_deadline|date }} has passed, but your payment is incomplete! {% elif student.payment_status == 7 %} More than a week since the deadline - {{ semester.most_payment_deadline|date }} + {{ semester.full_payment_deadline|date }} has passed, but your payment is incomplete. {% endif %} Link to invoice. diff --git a/dashboard/tests.py b/dashboard/tests.py index 7a1deac3..65d3f8f1 100644 --- a/dashboard/tests.py +++ b/dashboard/tests.py @@ -49,7 +49,7 @@ def test_portal_invoice_redirect(otis): semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), ) alice = StudentFactory.create(semester=semester) otis.login(alice) @@ -297,7 +297,7 @@ def test_submit_permissions(otis): semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), ) alice = StudentFactory.create(semester=semester) otis.login(alice) @@ -548,7 +548,7 @@ def test_pset_list(otis): def test_pset_list_permission(otis): semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), ) alice = StudentFactory.create(semester=semester) otis.login(alice) diff --git a/fixtures/all.json b/fixtures/all.json index e7f191e0..b7c50180 100644 --- a/fixtures/all.json +++ b/fixtures/all.json @@ -74,8 +74,8 @@ "show_invoices": false, "prep_rate": 240, "hour_rate": 80, - "first_payment_deadline": null, - "most_payment_deadline": null, + "half_payment_deadline": null, + "full_payment_deadline": null, "one_semester_date": null, "end_year": 2022, "social_url": "https://instagram.com/evanchen.cc/", @@ -93,8 +93,8 @@ "show_invoices": true, "prep_rate": 240, "hour_rate": 80, - "first_payment_deadline": null, - "most_payment_deadline": null, + "half_payment_deadline": null, + "full_payment_deadline": null, "one_semester_date": null, "end_year": 2023, "social_url": "https://instagram.com/evanchen.cc/", diff --git a/roster/models.py b/roster/models.py index 633c29ad..aad4b576 100644 --- a/roster/models.py +++ b/roster/models.py @@ -276,9 +276,9 @@ def generate_curriculum_rows(self) -> list[CurriculumRowTypeDict]: def payment_status(self): """Returns one of several codes: 0: student is clear (no invoice exists or total owed is nonpositive) - 1: remind of upcoming payment for first deadline - 2: warn of late payment for first deadline - 3: lock late payment for first deadline (more than 2 days past) + 1: remind of upcoming payment for half deadline + 2: warn of late payment for half deadline + 3: lock late payment for half deadline (more than 2 days past) 4: student has something owed for full deadline, but no warning yet 5: remind of upcoming payment for full deadline (up to 28d in advance) 6: warn of late payment for full deadline @@ -302,12 +302,12 @@ def payment_status(self): if ( self.semester.one_semester_date is not None - and self.semester.most_payment_deadline + and self.semester.full_payment_deadline and invoice.created_at > self.semester.one_semester_date ): - initial_payment_deadline = self.semester.most_payment_deadline + initial_payment_deadline = self.semester.full_payment_deadline else: - initial_payment_deadline = self.semester.first_payment_deadline + initial_payment_deadline = self.semester.half_payment_deadline if ( initial_payment_deadline is not None @@ -320,10 +320,10 @@ def payment_status(self): return 2 return 1 - most_payment_deadline = self.semester.most_payment_deadline - if most_payment_deadline is not None: + full_payment_deadline = self.semester.full_payment_deadline + if full_payment_deadline is not None: # anything reaching here has total_owed > 0, i.e. is not paid in full - d = max(invoice.created_at, most_payment_deadline) - now + d = max(invoice.created_at, full_payment_deadline) - now if d < timedelta(days=-2): return 7 elif d < timedelta(days=0): diff --git a/roster/templates/roster/invoice.html b/roster/templates/roster/invoice.html index 15e4ac28..7a630c69 100644 --- a/roster/templates/roster/invoice.html +++ b/roster/templates/roster/invoice.html @@ -76,11 +76,11 @@

Invoice ready for use!

Please contact me if you think there are any errors (I make mistakes every year!).

- {% if student.semester.first_payment_deadline or student.semester.most_payment_deadline %} + {% if student.semester.half_payment_deadline or student.semester.full_payment_deadline %}

As a reminder, the payment deadlines are:

{% endif %} {% if request.user.is_superuser %} diff --git a/roster/tests.py b/roster/tests.py index b6845f62..23927c92 100644 --- a/roster/tests.py +++ b/roster/tests.py @@ -987,7 +987,7 @@ def test_inquiry(otis) -> None: invoice_semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2021, 7, 1, tzinfo=UTC), ) eve = StudentFactory.create(semester=invoice_semester) otis.login(eve) @@ -1261,8 +1261,8 @@ def test_invoice(otis) -> None: def test_delinquency(otis) -> None: semester: Semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), - most_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), + full_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), ) alice: Student = StudentFactory.create(semester=semester) @@ -1348,7 +1348,7 @@ def test_delinquency(otis) -> None: assert not bob.is_delinquent # Now he is affected - semester.first_payment_deadline = datetime.datetime(2023, 1, 28, tzinfo=UTC) + semester.half_payment_deadline = datetime.datetime(2023, 1, 28, tzinfo=UTC) semester.save() with freeze_time("2023-2-08", tz_offset=0): @@ -1362,7 +1362,7 @@ def test_delinquency(otis) -> None: assert bob.payment_status == 7 assert bob.is_delinquent - semester.most_payment_deadline = datetime.datetime(2023, 2, 21, tzinfo=UTC) + semester.full_payment_deadline = datetime.datetime(2023, 2, 21, tzinfo=UTC) semester.save() with freeze_time("2023-3-01", tz_offset=0): @@ -1374,8 +1374,8 @@ def test_delinquency(otis) -> None: def test_delinquency_payment_fractions(otis) -> None: semester: Semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), - most_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), + full_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), ) alice: Student = StudentFactory.create(semester=semester) with freeze_time("2022-08-05", tz_offset=0): @@ -1426,8 +1426,8 @@ def test_delinquency_payment_fractions(otis) -> None: def test_delinquency_counts_credits(otis) -> None: semester: Semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), - most_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), + full_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), ) alice: Student = StudentFactory.create(semester=semester) with freeze_time("2022-08-05", tz_offset=0): @@ -1465,8 +1465,8 @@ def test_delinquency_counts_credits(otis) -> None: def test_delinquency_for_joining_second_semester(otis) -> None: semester: Semester = SemesterFactory.create( show_invoices=True, - first_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), - most_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), + half_payment_deadline=datetime.datetime(2022, 9, 21, tzinfo=UTC), + full_payment_deadline=datetime.datetime(2023, 1, 21, tzinfo=UTC), one_semester_date=datetime.datetime(2022, 12, 30, tzinfo=UTC), )