Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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",
),
]
4 changes: 2 additions & 2 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions dashboard/templates/dashboard/portal.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,26 @@ <h1 class="alert-heading">
</h1>
{% 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 %}
<a href="{% url 'invoice' student.pk %}" class="alert-link">Link to invoice.</a>
Expand Down
6 changes: 3 additions & 3 deletions dashboard/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions fixtures/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand All @@ -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/",
Expand Down
18 changes: 9 additions & 9 deletions roster/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions roster/templates/roster/invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ <h2 class="alert-heading">Invoice ready for use!</h2>
Please contact me if you think there are any errors
(I make mistakes every year!).
</p>
{% if student.semester.first_payment_deadline or student.semester.most_payment_deadline %}
{% if student.semester.half_payment_deadline or student.semester.full_payment_deadline %}
<p>As a reminder, the payment deadlines are:</p>
<ul>
{% if student.semester.first_payment_deadline %}<li>{{ student.semester.first_payment_deadline|date }}</li>{% endif %}
{% if student.semester.most_payment_deadline %}<li>{{ student.semester.most_payment_deadline|date }}</li>{% endif %}
{% if student.semester.half_payment_deadline %}<li>{{ student.semester.half_payment_deadline|date }}</li>{% endif %}
{% if student.semester.full_payment_deadline %}<li>{{ student.semester.full_payment_deadline|date }}</li>{% endif %}
</ul>
{% endif %}
{% if request.user.is_superuser %}
Expand Down
22 changes: 11 additions & 11 deletions roster/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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),
)

Expand Down
Loading