fix layout + collect/writeoff debts
This commit is contained in:
1 parent
7ec95ee24a
commit
7e7b3a7011
8 files changed
+263
-35
No files matched your search
@@ -31,6 +31,7 @@ class SessionEntry:
|
||||
player_name: str
|
||||
buy_in_cents: int = 0
|
||||
front_cents: int = 0
|
||||
front_collected_cents: int = 0
|
||||
front_writeoff_cents: int = 0
|
||||
cash_out_cents: int = 0
|
||||
paid_cents: int = 0
|
||||
@@ -68,7 +69,7 @@ class SessionEntry:
|
||||
|
||||
@property
|
||||
def player_owes_cents(self) -> int:
|
||||
return max(self.raw_player_owes_cents - self.front_writeoff_applied_cents, 0)
|
||||
return max(self.raw_player_owes_cents - self.front_resolved_cents, 0)
|
||||
|
||||
@property
|
||||
def raw_player_owes_cents(self) -> int:
|
||||
@@ -84,7 +85,18 @@ class SessionEntry:
|
||||
|
||||
@property
|
||||
def front_writeoff_applied_cents(self) -> int:
|
||||
return min(self.front_writeoff_cents, self.raw_player_owes_cents)
|
||||
return min(
|
||||
self.front_writeoff_cents,
|
||||
max(self.raw_player_owes_cents - self.front_collected_applied_cents, 0),
|
||||
)
|
||||
|
||||
@property
|
||||
def front_collected_applied_cents(self) -> int:
|
||||
return min(self.front_collected_cents, self.raw_player_owes_cents)
|
||||
|
||||
@property
|
||||
def front_resolved_cents(self) -> int:
|
||||
return self.front_collected_applied_cents + self.front_writeoff_applied_cents
|
||||
|
||||
@property
|
||||
def payout_status(self) -> str:
|
||||
@@ -92,6 +104,8 @@ class SessionEntry:
|
||||
return "owes"
|
||||
if self.front_writeoff_applied_cents > 0:
|
||||
return "written_off"
|
||||
if self.front_collected_applied_cents > 0:
|
||||
return "collected"
|
||||
if self.gross_payout_cents <= 0:
|
||||
return "none"
|
||||
if self.current_due_cents <= 0:
|
||||
@@ -169,6 +183,10 @@ class SessionSummary:
|
||||
def total_front_writeoff_cents(self) -> int:
|
||||
return sum(entry.front_writeoff_applied_cents for entry in self.entries)
|
||||
|
||||
@property
|
||||
def total_front_collected_cents(self) -> int:
|
||||
return sum(entry.front_collected_applied_cents for entry in self.entries)
|
||||
|
||||
@property
|
||||
def total_cash_in_cents(self) -> int:
|
||||
return sum(entry.buy_in_cents for entry in self.entries)
|
||||
@@ -196,6 +214,7 @@ class PlayerStats:
|
||||
biggest_loss_cents: int
|
||||
total_buy_in_cents: int
|
||||
total_front_cents: int
|
||||
total_front_collected_cents: int
|
||||
total_front_writeoff_cents: int
|
||||
current_player_owes_cents: int
|
||||
total_rollover_in_cents: int
|
||||
@@ -347,6 +366,8 @@ def build_session_summaries(events: list[EventRow]) -> list[SessionSummary]:
|
||||
entry.buy_in_cents += event["amount_cents"]
|
||||
elif event_type == "front":
|
||||
entry.front_cents += event["amount_cents"]
|
||||
elif event_type == "front_collected":
|
||||
entry.front_collected_cents += event["amount_cents"]
|
||||
elif event_type == "front_writeoff":
|
||||
entry.front_writeoff_cents += event["amount_cents"]
|
||||
elif event_type == "rollover_in":
|
||||
@@ -481,6 +502,9 @@ def build_leaderboard(sessions: list[SessionSummary]) -> list[PlayerStats]:
|
||||
|
||||
total_buy_in = sum(entry.buy_in_cents for entry in entries)
|
||||
total_front = sum(entry.front_cents for entry in entries)
|
||||
total_front_collected = sum(
|
||||
entry.front_collected_applied_cents for entry in entries
|
||||
)
|
||||
total_front_writeoff = sum(
|
||||
entry.front_writeoff_applied_cents for entry in entries
|
||||
)
|
||||
@@ -507,6 +531,7 @@ def build_leaderboard(sessions: list[SessionSummary]) -> list[PlayerStats]:
|
||||
biggest_loss_cents=biggest_loss,
|
||||
total_buy_in_cents=total_buy_in,
|
||||
total_front_cents=total_front,
|
||||
total_front_collected_cents=total_front_collected,
|
||||
total_front_writeoff_cents=total_front_writeoff,
|
||||
current_player_owes_cents=current_player_owes,
|
||||
total_rollover_in_cents=total_rollover_in,
|
||||
|
||||
Reference in new issue
Block a user