Fix DynamoDB float error — use Decimal for pay records

This commit is contained in:
Adam Moussa 2026-04-07 18:59:52 -04:00
parent f8ceb1dc83
commit 65d35281b2

View file

@ -4,6 +4,7 @@ to Slack every Monday at 7am ET, and emails the pay summary to payroll."""
import logging
import os
from datetime import datetime, timedelta
from decimal import Decimal
from zoneinfo import ZoneInfo
import boto3
@ -40,13 +41,13 @@ def _add_shift_to_pay(schedule, breakdown, totals, date, day_name, shift_type="n
"day": f"{day_name[:3]}{label_suffix}",
"name": name,
"extension": ext,
"rate": rate,
"rate": Decimal(str(rate)),
})
if name not in totals:
totals[name] = {"shifts": 0, "total": 0.0, "extension": ext, "rate": rate}
totals[name] = {"shifts": 0, "total": Decimal("0"), "extension": ext, "rate": Decimal(str(rate))}
totals[name]["shifts"] += 1
totals[name]["total"] += rate
totals[name]["total"] += Decimal(str(rate))
def _calculate_weekly_pay(schedule: ShiftSchedule, week_start: datetime) -> dict: