Skip to content

Commit

Permalink
Exclude FKed items from receipt discrepancies
Browse files Browse the repository at this point in the history
This will let us add items to attendee receipts for purchases that don't affect their default cost without tripping the receipt discrepancies page.

The FK stands for Foreign Key.
  • Loading branch information
kitsuta committed Nov 22, 2024
1 parent f56bf04 commit a39da0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Binary file modified celerybeat-schedule
Binary file not shown.
6 changes: 6 additions & 0 deletions uber/models/commerce.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ def item_total(self):
def item_total_sql(cls):
return coalesce(func.sum(ReceiptItem.amount * ReceiptItem.count), 0)

@classproperty
def fkless_item_total_sql(cls):
return coalesce(func.sum(ReceiptItem.amount * ReceiptItem.count).filter(
ReceiptItem.fk_id == None
), 0)

@property
def txn_total(self):
return self.payment_total - self.refund_total
Expand Down
7 changes: 4 additions & 3 deletions uber/site_sections/reg_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ def attendee_receipt_discrepancies(self, session, include_pending=False):
else:
filter = Attendee.is_valid == True # noqa: E712

attendees = session.query(Attendee).filter(filter).join( # noqa: E712
Attendee.active_receipt).outerjoin(ModelReceipt.receipt_items).group_by(
ModelReceipt.id).group_by(Attendee.id).having(Attendee.default_cost_cents != ModelReceipt.item_total_sql)
attendees = session.query(Attendee).filter(
filter).join(Attendee.active_receipt).outerjoin(ModelReceipt.receipt_items).group_by(
ModelReceipt.id).group_by(Attendee.id).having(
Attendee.default_cost_cents != ModelReceipt.fkless_item_total_sql)

return {
'attendees': attendees,
Expand Down

0 comments on commit a39da0d

Please sign in to comment.