Skip to content

Commit

Permalink
Fix cabin/food report counts
Browse files Browse the repository at this point in the history
The cabin and food report wouldn't include attendees who didn't have a badge, like deferred attendees. Also these reports will now tell you if an attendee owes money.
  • Loading branch information
kitsuta committed May 29, 2024
1 parent a7fc7a0 commit a421e1f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions magstock/site_sections/magstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@


def camp_food_report(session):
attendees_with_meal_plan = sorted(session.attendees_with_badges().filter(
attendees_with_meal_plan = sorted(session.valid_attendees().filter(
Attendee.meal_plan != c.NO_FOOD), key=lambda a: a.full_name)
total_data = defaultdict(int)

total_data['attendees'] = []
total_data['owe_money'] = {}

for attendee in attendees_with_meal_plan:
total_data['attendees'].append(attendee)
total_data['attendee_count'] += 1

if attendee.amount_unpaid:
total_data['owe_money'][attendee.id] = attendee.amount_unpaid

if attendee.meal_plan == c.BEVERAGE:
total_data['beverage'] += 1
elif attendee.meal_plan == c.FULL_FOOD:
Expand All @@ -28,11 +32,15 @@ def camp_food_report(session):
return total_data

def camp_cabin_report(session):
attendees_with_cabins = session.attendees_with_badges().filter(Attendee.camping_type == c.CABIN)
attendees_with_cabins = session.valid_attendees().filter(Attendee.camping_type == c.CABIN)
total_data = defaultdict(int)

total_data['attendees'] = sorted(attendees_with_cabins.all(), key=lambda a: a.full_name)
total_data['attendee_count'] = attendees_with_cabins.count()
total_data['owe_money'] = {}

for attendee in [a for a in attendees_with_cabins if a.amount_unpaid]:
total_data['owe_money'][attendee.id] = attendee.amount_unpaid

for cabin_type in c.CABIN_TYPES.keys():
total_data[cabin_type] = attendees_with_cabins.filter(Attendee.cabin_type == cabin_type).count()
Expand Down
5 changes: 5 additions & 0 deletions magstock/templates/magstock/cabin_purchasers.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h2 class="center">MAGStock Cabin Report</h2>
<th>Cabin Type</th>
<th>Group Name</th>
<th>Badge Type</th>
<th>Paid?</th>
</thead>
<tbody>
{% for attendee in total_data['attendees'] %}
Expand All @@ -43,6 +44,10 @@ <h2 class="center">MAGStock Cabin Report</h2>
<td>{{ attendee.cabin_type_label }}</td>
<td>{{ attendee.group.name }}</td>
<td>{{ attendee.badge_type_label }}</td>
<td data-sort="{{ total_data['owe_money'][attendee.id] }}">
{% if total_data['owe_money'][attendee.id] %}No (owes {{ total_data['owe_money'][attendee.id]|format_currency }})
{% else %}Yes{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
5 changes: 5 additions & 0 deletions magstock/templates/magstock/food_consumers.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h2 class="center">MAGStock Food Report</h2>
<th>Meal Restrictions</th>
<th>Group Name</th>
<th>Badge Type</th>
<th>Paid?</th>
</thead>
<tbody>
{% for attendee in total_data['attendees'] %}
Expand All @@ -49,6 +50,10 @@ <h2 class="center">MAGStock Food Report</h2>
</td>
<td>{{ attendee.group.name }}</td>
<td>{{ attendee.badge_type_label }}</td>
<td data-sort="{{ total_data['owe_money'][attendee.id] }}">
{% if total_data['owe_money'][attendee.id] %}No (owes {{ total_data['owe_money'][attendee.id]|format_currency }})
{% else %}Yes{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit a421e1f

Please sign in to comment.