diff --git a/functions/slack_notifier/handler.py b/functions/slack_notifier/handler.py index 2b3dbd5..d9387dd 100644 --- a/functions/slack_notifier/handler.py +++ b/functions/slack_notifier/handler.py @@ -87,7 +87,11 @@ def handle_orders_aggregated(event): totals_text = ( f"*${grand_total:.2f}* order total (bulk rate)\n" f"*${employee_total:.2f}* payroll deductions" - + (f"\n*${grand_total - employee_total:.2f}* company subsidy" if has_subsidy else "") + + ( + f"\n*${grand_total - employee_total:.2f}* company subsidy" + if has_subsidy + else "" + ) ) text = f"Meal orders closed for {week}. {total_employees} employees, {total_meals} meals, ${grand_total:.2f} total." @@ -137,7 +141,9 @@ def handle_order_confirmed(event): for item in items: qty = int(item.get("quantity", 0)) price = float(item.get("price", 0)) - item_lines.append(f"{_escape_mrkdwn(item['name'])} x{qty} — your cost: ${price * qty:.2f}") + item_lines.append( + f"{_escape_mrkdwn(item['name'])} x{qty} — your cost: ${price * qty:.2f}" + ) item_list = "\n".join(item_lines) send_dm( diff --git a/functions/submit_order/handler.py b/functions/submit_order/handler.py index 24abb2c..c2161ab 100644 --- a/functions/submit_order/handler.py +++ b/functions/submit_order/handler.py @@ -161,7 +161,9 @@ def handle_submit(event): return response(403, {"error": "Google authentication is required"}) user_info, verify_status = _verify_google_token(google_token) if verify_status == "unavailable": - return response(503, {"error": "Authentication service temporarily unavailable"}) + return response( + 503, {"error": "Authentication service temporarily unavailable"} + ) if user_info is None: return response(403, {"error": "Invalid or unauthorized Google account"}) name = user_info["name"] @@ -170,7 +172,9 @@ def handle_submit(event): # Google auth not configured but token provided — verify it anyway user_info, verify_status = _verify_google_token(google_token) if verify_status == "unavailable": - return response(503, {"error": "Authentication service temporarily unavailable"}) + return response( + 503, {"error": "Authentication service temporarily unavailable"} + ) if user_info is None: return response(403, {"error": "Invalid or unauthorized Google account"}) name = user_info["name"] @@ -216,7 +220,9 @@ def handle_submit(event): # Step 1: apply bulk discount and round bulk_price = (retail * bulk_mult).quantize(TWO_PLACES, rounding=ROUND_HALF_UP) # Step 2: apply company subsidy and round - emp_price = (bulk_price * subsidy_mult).quantize(TWO_PLACES, rounding=ROUND_HALF_UP) + emp_price = (bulk_price * subsidy_mult).quantize( + TWO_PLACES, rounding=ROUND_HALF_UP + ) subtotal = (emp_price * qty).quantize(TWO_PLACES, rounding=ROUND_HALF_UP) # Convert back to float for JSON serialization item["retail_price"] = float(retail) @@ -224,7 +230,11 @@ def handle_submit(event): item["price"] = float(emp_price) item["subtotal"] = float(subtotal) - total = float(sum(Decimal(str(i["subtotal"])) for i in filtered_items).quantize(TWO_PLACES, rounding=ROUND_HALF_UP)) + total = float( + sum(Decimal(str(i["subtotal"])) for i in filtered_items).quantize( + TWO_PLACES, rounding=ROUND_HALF_UP + ) + ) slug = email.lower() @@ -244,14 +254,17 @@ def handle_submit(event): _lambda.invoke( FunctionName=os.environ["SLACK_NOTIFIER_ARN"], InvocationType="Event", - Payload=json.dumps({ - "event": "order_confirmed", - "employee_name": name, - "employee_email": email, - "items": filtered_items, - "total": order_data["total"], - "week": week, - }, default=float), + Payload=json.dumps( + { + "event": "order_confirmed", + "employee_name": name, + "employee_email": email, + "items": filtered_items, + "total": order_data["total"], + "week": week, + }, + default=float, + ), ) except Exception as exc: logger.error("Slack notifier invocation failed (order already saved): %s", exc) diff --git a/src/aggregator/aggregate.py b/src/aggregator/aggregate.py index 292c066..156919a 100644 --- a/src/aggregator/aggregate.py +++ b/src/aggregator/aggregate.py @@ -161,7 +161,10 @@ def main(): print(f"{meal['meal']:<45} {meal['quantity']:>4} ${meal['line_total']:>7.2f}") print("-" * 60) print(f"{'TOTAL':<45} {summary['total_meals']:>4} ${summary['grand_total']:>7.2f}") - if summary.get("employee_total") is not None and summary["employee_total"] != summary["grand_total"]: + if ( + summary.get("employee_total") is not None + and summary["employee_total"] != summary["grand_total"] + ): print(f"{'PAYROLL DEDUCTIONS':<45} ${summary['employee_total']:>7.2f}") subsidy = round(summary["grand_total"] - summary["employee_total"], 2) print(f"{'COMPANY SUBSIDY':<45} ${subsidy:>7.2f}") diff --git a/src/server/generate_form.py b/src/server/generate_form.py index 989bcb7..2f4f1ac 100644 --- a/src/server/generate_form.py +++ b/src/server/generate_form.py @@ -49,7 +49,9 @@ def generate_form( week = datetime.now().strftime("%Y-W%U") scraped_at = menu.get("scraped_at", "unknown") submit_url = f"{api_url}/api/submit-order" if api_url else "/api/submit-order" - status_url = f"{api_url}/api/form-status/{week}" if api_url else f"/api/form-status/{week}" + status_url = ( + f"{api_url}/api/form-status/{week}" if api_url else f"/api/form-status/{week}" + ) roster_url = f"{api_url}/api/roster" if api_url else "/api/roster" api_key_json = json.dumps(api_key).replace("", "<\\/") has_discount = bulk_discount > 0 or company_subsidy > 0 @@ -299,7 +301,11 @@ body {{ padding-bottom: 80px; }} .countdown {{ font-size: 2rem; font-weight: 700; color: #1a1a2e; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }} .countdown-label {{ font-size: 0.75rem; color: #9ca3af; margin-top: 4px; }} -{'' if use_google_auth else ''} +{ + '' + if use_google_auth + else "" + }
Sign in with your company Google account to place your order.
Sign in with your company Google account to place your order.
Week of {week} · Menu scraped {scraped_at[:10]}
@@ -320,7 +330,15 @@ body {{ padding-bottom: 80px; }}