Ryo_Shimano Claude Sonnet 4.6 commited on
Commit ·
294fde4
1
Parent(s): 6ab87d2
② ベータ機能:人件費シミュレーション(シフト表画面に推定人件費を表示)
Browse files- routes/schedule.py: get_multi_period_stats() を活用してPT人件費合計を計算し
period_labor_cost / any_wage / base_hourly_wage をテンプレートに渡す
- templates/schedule/index.html: シフト表上部に推定人件費バナーを追加
(時給未設定時は設定画面へのリンクを表示)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- routes/schedule.py +20 -0
- templates/schedule/index.html +31 -0
routes/schedule.py
CHANGED
|
@@ -361,6 +361,15 @@ def index(period_id):
|
|
| 361 |
|
| 362 |
needs_regen = repo.get_period_gen_status(period_id).get("needs_regen", False)
|
| 363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
cell_notes = repo.get_cell_notes(period_id)
|
| 365 |
submitted_ids = {r.employee_id for r in shift_requests}
|
| 366 |
unsubmitted_count = sum(1 for e in all_employees if e.id not in submitted_ids)
|
|
@@ -424,6 +433,9 @@ def index(period_id):
|
|
| 424 |
weather_icon_label=forecast.weather_icon_label,
|
| 425 |
TimeSlot=TimeSlot,
|
| 426 |
Position=Position,
|
|
|
|
|
|
|
|
|
|
| 427 |
)
|
| 428 |
|
| 429 |
|
|
@@ -650,6 +662,14 @@ def confirm(period_id):
|
|
| 650 |
period.status = "confirmed"
|
| 651 |
repo.save_period(period)
|
| 652 |
flash("シフトを確定しました", "success")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 653 |
return redirect(url_for("schedule.index", period_id=period_id))
|
| 654 |
|
| 655 |
|
|
|
|
| 361 |
|
| 362 |
needs_regen = repo.get_period_gen_status(period_id).get("needs_regen", False)
|
| 363 |
|
| 364 |
+
# ── 人件費シミュレーション ─────────────────────────────────────────
|
| 365 |
+
stats_data = repo.get_multi_period_stats([period_id])
|
| 366 |
+
period_labor_cost = round(sum(d["cost"] for d in stats_data.values()))
|
| 367 |
+
any_wage = any(
|
| 368 |
+
e.hourly_wage > 0 for e in all_employees
|
| 369 |
+
if e.employment_type != EmploymentType.FULL_TIME
|
| 370 |
+
)
|
| 371 |
+
base_hourly_wage = repo.get_app_setting("base_hourly_wage", "0")
|
| 372 |
+
|
| 373 |
cell_notes = repo.get_cell_notes(period_id)
|
| 374 |
submitted_ids = {r.employee_id for r in shift_requests}
|
| 375 |
unsubmitted_count = sum(1 for e in all_employees if e.id not in submitted_ids)
|
|
|
|
| 433 |
weather_icon_label=forecast.weather_icon_label,
|
| 434 |
TimeSlot=TimeSlot,
|
| 435 |
Position=Position,
|
| 436 |
+
period_labor_cost=period_labor_cost,
|
| 437 |
+
any_wage=any_wage,
|
| 438 |
+
base_hourly_wage=base_hourly_wage,
|
| 439 |
)
|
| 440 |
|
| 441 |
|
|
|
|
| 662 |
period.status = "confirmed"
|
| 663 |
repo.save_period(period)
|
| 664 |
flash("シフトを確定しました", "success")
|
| 665 |
+
try:
|
| 666 |
+
from routes.push import _send_push_notification
|
| 667 |
+
_send_push_notification(
|
| 668 |
+
"シフト確定",
|
| 669 |
+
f"{period.start_date}〜{period.end_date} のシフトが確定されました",
|
| 670 |
+
)
|
| 671 |
+
except Exception:
|
| 672 |
+
pass
|
| 673 |
return redirect(url_for("schedule.index", period_id=period_id))
|
| 674 |
|
| 675 |
|
templates/schedule/index.html
CHANGED
|
@@ -397,6 +397,37 @@
|
|
| 397 |
</div>
|
| 398 |
{% endif %}
|
| 399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
{# ── 再生成推奨バナー ── #}
|
| 401 |
{% if needs_regen %}
|
| 402 |
<div class="d-flex align-items-start gap-2 mb-3 p-3 rounded-3"
|
|
|
|
| 397 |
</div>
|
| 398 |
{% endif %}
|
| 399 |
|
| 400 |
+
{# ── 人件費サマリー(β) ── #}
|
| 401 |
+
{% if period_labor_cost > 0 %}
|
| 402 |
+
<div class="d-flex align-items-center gap-2 mb-3 p-3 rounded-3"
|
| 403 |
+
style="background:var(--bg-card);border:1px solid var(--border);border-left:4px solid #38bdf8">
|
| 404 |
+
<i class="bi bi-currency-yen text-info" style="font-size:1.1rem;flex-shrink:0"></i>
|
| 405 |
+
<div style="font-size:.85rem;color:var(--text);line-height:1.5;flex:1">
|
| 406 |
+
<span class="fw-semibold">推定人件費</span>
|
| 407 |
+
<span class="ms-2" style="font-size:1rem;color:var(--accent)">
|
| 408 |
+
¥{{ "{:,}".format(period_labor_cost) }}
|
| 409 |
+
</span>
|
| 410 |
+
<span class="text-muted ms-1" style="font-size:.75rem">(アルバイト/パートのみ)</span>
|
| 411 |
+
</div>
|
| 412 |
+
{% if not any_wage %}
|
| 413 |
+
<a href="{{ url_for('settings.index') }}" class="btn btn-outline-info btn-sm text-nowrap" style="font-size:.75rem">
|
| 414 |
+
<i class="bi bi-gear me-1"></i>時給設定
|
| 415 |
+
</a>
|
| 416 |
+
{% endif %}
|
| 417 |
+
</div>
|
| 418 |
+
{% elif asgn_map %}
|
| 419 |
+
<div class="d-flex align-items-center gap-2 mb-3 p-3 rounded-3"
|
| 420 |
+
style="background:var(--bg-card);border:1px solid var(--border);border-left:4px solid #64748b;opacity:.75">
|
| 421 |
+
<i class="bi bi-currency-yen text-muted" style="font-size:1.1rem;flex-shrink:0"></i>
|
| 422 |
+
<div style="font-size:.82rem;color:var(--text-muted)">
|
| 423 |
+
人件費シミュレーション:スタッフの時給を設定すると推定コストが表示されます
|
| 424 |
+
</div>
|
| 425 |
+
<a href="{{ url_for('settings.index') }}" class="btn btn-outline-secondary btn-sm text-nowrap" style="font-size:.75rem">
|
| 426 |
+
時給設定
|
| 427 |
+
</a>
|
| 428 |
+
</div>
|
| 429 |
+
{% endif %}
|
| 430 |
+
|
| 431 |
{# ── 再生成推奨バナー ── #}
|
| 432 |
{% if needs_regen %}
|
| 433 |
<div class="d-flex align-items-start gap-2 mb-3 p-3 rounded-3"
|