Commit ·
6fecf06
1
Parent(s): 67de3eb
feat: 賃金体系を基本給・早朝手当・個人昇給額の3層構造に変更
Browse files- app_settings に base_hourly_wage・early_morning_allowance を追加
- employees.hourly_wage を「昇給額(個人差分)」として再定義
- 人件費計算:(基本給+昇給額+早朝手当)×朝食h + (基本給+昇給額)×ディナーh
- 設定画面の「人件費設定」カードに基本給・早朝手当・個人昇給額をまとめて表示
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- db/database.py +2 -0
- db/repositories.py +14 -2
- routes/settings_routes.py +8 -4
- templates/schedule/stats_multi.html +3 -2
- templates/settings/index.html +53 -20
db/database.py
CHANGED
|
@@ -335,6 +335,8 @@ def initialize_db():
|
|
| 335 |
("reserv_extra_breakfast", "1"),
|
| 336 |
("reserv_threshold_dinner", "25"),
|
| 337 |
("reserv_extra_dinner", "1"),
|
|
|
|
|
|
|
| 338 |
]:
|
| 339 |
conn.execute(
|
| 340 |
"INSERT INTO app_settings (key, value) VALUES (?,?) ON CONFLICT DO NOTHING",
|
|
|
|
| 335 |
("reserv_extra_breakfast", "1"),
|
| 336 |
("reserv_threshold_dinner", "25"),
|
| 337 |
("reserv_extra_dinner", "1"),
|
| 338 |
+
("base_hourly_wage", "1000"),
|
| 339 |
+
("early_morning_allowance", "0"),
|
| 340 |
]:
|
| 341 |
conn.execute(
|
| 342 |
"INSERT INTO app_settings (key, value) VALUES (?,?) ON CONFLICT DO NOTHING",
|
db/repositories.py
CHANGED
|
@@ -813,9 +813,14 @@ def get_multi_period_stats(period_ids: list[int]) -> dict:
|
|
| 813 |
else:
|
| 814 |
hour_map[(pid_r, eid_r, date_r, "dinner")] = hrs
|
| 815 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 816 |
# 従業員マップ(PT のみ。社員は時給計算対象外)
|
| 817 |
all_emps = get_all_employees(active_only=False)
|
| 818 |
pt_ids = {e.id for e in all_emps if e.employment_type != EmploymentType.FULL_TIME}
|
|
|
|
| 819 |
wage_map = {e.id: e.hourly_wage for e in all_emps if e.id in pt_ids}
|
| 820 |
|
| 821 |
result: dict = {}
|
|
@@ -832,8 +837,15 @@ def get_multi_period_stats(period_ids: list[int]) -> dict:
|
|
| 832 |
hrs = _ft_hours(slot, pos)
|
| 833 |
|
| 834 |
# 社員は時給計算対象外(コストは 0 のまま)
|
| 835 |
-
|
| 836 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 837 |
|
| 838 |
if eid not in result:
|
| 839 |
result[eid] = {"shifts": 0, "hours": 0.0, "cost": 0.0, "by_period": {}}
|
|
|
|
| 813 |
else:
|
| 814 |
hour_map[(pid_r, eid_r, date_r, "dinner")] = hrs
|
| 815 |
|
| 816 |
+
# グローバル賃金設定
|
| 817 |
+
base_wage = int(settings.get("base_hourly_wage", "0") or 0)
|
| 818 |
+
early_allow = int(settings.get("early_morning_allowance", "0") or 0)
|
| 819 |
+
|
| 820 |
# 従業員マップ(PT のみ。社員は時給計算対象外)
|
| 821 |
all_emps = get_all_employees(active_only=False)
|
| 822 |
pt_ids = {e.id for e in all_emps if e.employment_type != EmploymentType.FULL_TIME}
|
| 823 |
+
# hourly_wage 列は昇給額(base_wage に上乗せする個人差分)
|
| 824 |
wage_map = {e.id: e.hourly_wage for e in all_emps if e.id in pt_ids}
|
| 825 |
|
| 826 |
result: dict = {}
|
|
|
|
| 837 |
hrs = _ft_hours(slot, pos)
|
| 838 |
|
| 839 |
# 社員は時給計算対象外(コストは 0 のまま)
|
| 840 |
+
if eid not in pt_ids:
|
| 841 |
+
cost = 0.0
|
| 842 |
+
else:
|
| 843 |
+
raise_amt = wage_map.get(eid, 0)
|
| 844 |
+
hourly = base_wage + raise_amt
|
| 845 |
+
# 朝食シフトは早朝手当を加算
|
| 846 |
+
if slot == "breakfast":
|
| 847 |
+
hourly += early_allow
|
| 848 |
+
cost = hrs * hourly
|
| 849 |
|
| 850 |
if eid not in result:
|
| 851 |
result[eid] = {"shifts": 0, "hours": 0.0, "cost": 0.0, "by_period": {}}
|
routes/settings_routes.py
CHANGED
|
@@ -67,17 +67,21 @@ def save():
|
|
| 67 |
|
| 68 |
@bp.post("/save-wages")
|
| 69 |
def save_wages():
|
| 70 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
wages = {}
|
| 72 |
for key, val in request.form.items():
|
| 73 |
if key.startswith("wage_"):
|
| 74 |
try:
|
| 75 |
-
|
| 76 |
-
wages[emp_id] = int(val or 0)
|
| 77 |
except ValueError:
|
| 78 |
pass
|
| 79 |
repo.save_employee_wages(wages)
|
| 80 |
-
flash("
|
| 81 |
return redirect(url_for("settings.index"))
|
| 82 |
|
| 83 |
|
|
|
|
| 67 |
|
| 68 |
@bp.post("/save-wages")
|
| 69 |
def save_wages():
|
| 70 |
+
"""基本給・早朝手当・昇給額を一括保存"""
|
| 71 |
+
# グローバル賃金設定
|
| 72 |
+
global_keys = ["base_hourly_wage", "early_morning_allowance"]
|
| 73 |
+
global_vals = {k: request.form.get(k, "0") for k in global_keys}
|
| 74 |
+
repo.save_all_app_settings(global_vals)
|
| 75 |
+
# 個人別昇給額
|
| 76 |
wages = {}
|
| 77 |
for key, val in request.form.items():
|
| 78 |
if key.startswith("wage_"):
|
| 79 |
try:
|
| 80 |
+
wages[int(key[5:])] = int(val or 0)
|
|
|
|
| 81 |
except ValueError:
|
| 82 |
pass
|
| 83 |
repo.save_employee_wages(wages)
|
| 84 |
+
flash("賃金設定を保存しました", "success")
|
| 85 |
return redirect(url_for("settings.index"))
|
| 86 |
|
| 87 |
|
templates/schedule/stats_multi.html
CHANGED
|
@@ -174,8 +174,9 @@
|
|
| 174 |
</div>
|
| 175 |
|
| 176 |
<p class="text-muted small px-1">
|
| 177 |
-
※ 推計時間はシフト希望のパターン時刻
|
| 178 |
-
※ 人件費は
|
|
|
|
| 179 |
</p>
|
| 180 |
{% endif %}
|
| 181 |
|
|
|
|
| 174 |
</div>
|
| 175 |
|
| 176 |
<p class="text-muted small px-1">
|
| 177 |
+
※ 推計時間はシフト希望のパターン時刻をもとに算出します。<br>
|
| 178 |
+
※ 人件費は(基本給+個人昇給額)×時間(朝食は早朝手当加算)の概算です。休憩・交通費等は含みません。<br>
|
| 179 |
+
※ 基本給・早朝手当・昇給額は設定画面の「人件費設定」で変更できます。
|
| 180 |
</p>
|
| 181 |
{% endif %}
|
| 182 |
|
templates/settings/index.html
CHANGED
|
@@ -121,38 +121,71 @@
|
|
| 121 |
|
| 122 |
</form>
|
| 123 |
|
| 124 |
-
<!--
|
| 125 |
<form method="post" action="{{ url_for('settings.save_wages') }}">
|
| 126 |
<div class="card mb-3">
|
| 127 |
<div class="card-body">
|
| 128 |
-
<div class="d-flex align-items-center justify-content-between mb-
|
| 129 |
-
<h6 class="card-title text-muted mb-0">
|
| 130 |
-
{% if pt_employees %}
|
| 131 |
<button type="submit" class="btn btn-primary btn-sm">
|
| 132 |
<i class="bi bi-floppy me-1"></i>保存
|
| 133 |
</button>
|
| 134 |
-
{% endif %}
|
| 135 |
</div>
|
| 136 |
-
|
| 137 |
-
<
|
| 138 |
-
<div
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
<
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
min="0" max="9999" step="1"
|
| 146 |
-
class="form-control form-control-sm text-end"
|
| 147 |
-
|
| 148 |
-
<span class="input-group-text px-1" style="font-size:.75rem">円</span>
|
| 149 |
</div>
|
| 150 |
</div>
|
| 151 |
-
{% endfor %}
|
| 152 |
</div>
|
| 153 |
-
|
| 154 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
</div>
|
| 157 |
</div>
|
| 158 |
</form>
|
|
|
|
| 121 |
|
| 122 |
</form>
|
| 123 |
|
| 124 |
+
<!-- 人件費設定 -->
|
| 125 |
<form method="post" action="{{ url_for('settings.save_wages') }}">
|
| 126 |
<div class="card mb-3">
|
| 127 |
<div class="card-body">
|
| 128 |
+
<div class="d-flex align-items-center justify-content-between mb-3">
|
| 129 |
+
<h6 class="card-title text-muted mb-0">人件費設定</h6>
|
|
|
|
| 130 |
<button type="submit" class="btn btn-primary btn-sm">
|
| 131 |
<i class="bi bi-floppy me-1"></i>保存
|
| 132 |
</button>
|
|
|
|
| 133 |
</div>
|
| 134 |
+
|
| 135 |
+
<!-- 基本給・早朝手当 -->
|
| 136 |
+
<div class="d-flex gap-3 mb-3 flex-wrap">
|
| 137 |
+
<div>
|
| 138 |
+
<label class="form-label small fw-semibold mb-1">基本給</label>
|
| 139 |
+
<div class="input-group input-group-sm" style="width:130px">
|
| 140 |
+
<input type="number" name="base_hourly_wage"
|
| 141 |
+
value="{{ settings.get('base_hourly_wage', '1000') }}"
|
| 142 |
+
min="0" max="99999" step="1"
|
| 143 |
+
class="form-control form-control-sm text-end">
|
| 144 |
+
<span class="input-group-text px-1" style="font-size:.75rem">円/時</span>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
<div>
|
| 148 |
+
<label class="form-label small fw-semibold mb-1">早朝手当
|
| 149 |
+
<span class="text-muted fw-normal">(朝食シフト加算)</span>
|
| 150 |
+
</label>
|
| 151 |
+
<div class="input-group input-group-sm" style="width:130px">
|
| 152 |
+
<input type="number" name="early_morning_allowance"
|
| 153 |
+
value="{{ settings.get('early_morning_allowance', '0') }}"
|
| 154 |
min="0" max="9999" step="1"
|
| 155 |
+
class="form-control form-control-sm text-end">
|
| 156 |
+
<span class="input-group-text px-1" style="font-size:.75rem">円/時</span>
|
|
|
|
| 157 |
</div>
|
| 158 |
</div>
|
|
|
|
| 159 |
</div>
|
| 160 |
+
|
| 161 |
+
<!-- 個人別昇給額 -->
|
| 162 |
+
{% if pt_employees %}
|
| 163 |
+
<div class="border-top pt-3" style="border-color:#334155 !important">
|
| 164 |
+
<div class="small fw-semibold text-muted mb-2">個人昇給額
|
| 165 |
+
<span class="fw-normal text-muted">(基本給に上乗せ)</span>
|
| 166 |
+
</div>
|
| 167 |
+
<div style="display:grid;grid-template-columns:repeat(2,1fr);gap:.4rem .75rem">
|
| 168 |
+
{% for emp in pt_employees %}
|
| 169 |
+
<div class="d-flex align-items-center gap-2">
|
| 170 |
+
<span class="small fw-semibold text-truncate" style="min-width:0;flex:1">{{ emp.name }}</span>
|
| 171 |
+
<div class="input-group input-group-sm flex-shrink-0" style="width:110px">
|
| 172 |
+
<span class="input-group-text px-1" style="font-size:.75rem">+</span>
|
| 173 |
+
<input type="number" name="wage_{{ emp.id }}"
|
| 174 |
+
value="{{ emp.hourly_wage }}"
|
| 175 |
+
min="0" max="9999" step="1"
|
| 176 |
+
class="form-control form-control-sm text-end"
|
| 177 |
+
placeholder="0">
|
| 178 |
+
<span class="input-group-text px-1" style="font-size:.75rem">円</span>
|
| 179 |
+
</div>
|
| 180 |
+
</div>
|
| 181 |
+
{% endfor %}
|
| 182 |
+
</div>
|
| 183 |
+
</div>
|
| 184 |
{% endif %}
|
| 185 |
+
|
| 186 |
+
<div class="text-muted small mt-3">
|
| 187 |
+
実効時給 = 基本給 + 個人昇給額(+早朝手当 for 朝食)。社員は対象外。
|
| 188 |
+
</div>
|
| 189 |
</div>
|
| 190 |
</div>
|
| 191 |
</form>
|