From 9e2eab6953efe2c4c51d966324afe497dc0ddb94 Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Tue, 7 Apr 2026 19:07:44 -0400 Subject: [PATCH] DM pay reports to admin, rename email to Bonus Pay Summary - Pay summary sent as DM to designated user instead of channel - Email shows only per-person totals, no shift breakdown - Renamed email subject/header to "Bonus Pay Summary" --- src/weekly_post.py | 37 +++++++++++++++---------------------- template.yaml | 1 + 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/weekly_post.py b/src/weekly_post.py index 27b6a2b..ef2464c 100644 --- a/src/weekly_post.py +++ b/src/weekly_post.py @@ -77,14 +77,6 @@ def _calculate_weekly_pay(schedule: ShiftSchedule, week_start: datetime) -> dict def _build_pay_email_html(week_label: str, pay_record: dict) -> str: """Build an HTML email body for the weekly pay summary.""" - rows = "" - for entry in pay_record["breakdown"]: - rows += ( - f"{entry['day']}{entry['date_label']}" - f"{entry['name']}Ext {entry['extension']}" - f"${entry['rate']:.2f}\n" - ) - totals_rows = "" for name, info in sorted(pay_record["totals"].items()): totals_rows += ( @@ -94,14 +86,8 @@ def _build_pay_email_html(week_label: str, pay_record: dict) -> str: return f""" -

After-Hours Pay Summary — {week_label}

+

Bonus Pay Summary — {week_label}

-

Shift Breakdown

- - -{rows}
DayDateNameExtensionRate
- -

Totals by Person

{totals_rows}
NameShiftsRateTotal
@@ -128,7 +114,7 @@ def _send_pay_email(week_label: str, pay_record: dict) -> None: Source=sender, Destination={"ToAddresses": recipients}, Message={ - "Subject": {"Data": f"After-Hours Pay Summary — {week_label}"}, + "Subject": {"Data": f"Bonus Pay Summary — {week_label}"}, "Body": {"Html": {"Data": html_body}}, }, ) @@ -160,6 +146,8 @@ def handler(event, context): prev_monday = prev_monday.replace(hour=0, minute=0, second=0, microsecond=0) pay_record = _calculate_weekly_pay(schedule, prev_monday) + pay_dm_user = os.environ.get("PAY_REPORT_USER") + if pay_record["breakdown"]: week_key = prev_monday.strftime("%Y-%m-%d") schedule.save_pay_record(week_key, pay_record) @@ -169,12 +157,17 @@ def handler(event, context): pay_blocks = build_pay_summary_blocks( week_label, pay_record["breakdown"], pay_record["totals"] ) - slack.chat_postMessage( - channel=channel_id, - blocks=pay_blocks, - text=f"After-Hours Pay — {week_label}", - ) - logger.info("Posted pay summary for week of %s", week_key) + + # DM pay report to designated user instead of channel + if pay_dm_user: + slack.chat_postMessage( + channel=pay_dm_user, + blocks=pay_blocks, + text=f"After-Hours Pay — {week_label}", + ) + logger.info("Sent pay summary DM to %s for week of %s", pay_dm_user, week_key) + else: + logger.warning("PAY_REPORT_USER not set — skipping Slack pay summary") # Email pay summary to payroll _send_pay_email(week_label, pay_record) diff --git a/template.yaml b/template.yaml index 263c261..8191630 100644 --- a/template.yaml +++ b/template.yaml @@ -91,6 +91,7 @@ Resources: SHIFT_CHANNEL_PARAM: /afterhours-shift-manager/channel-id SES_SENDER: noreply@seahaven.com PAYROLL_RECIPIENTS: adam@seahaven.com + PAY_REPORT_USER: U0A3SC48T47 TZ: !Ref Timezone Policies: - DynamoDBCrudPolicy: