fix: 保留未填报设备段归属工时

This commit is contained in:
souplearn
2026-07-25 04:05:05 +08:00
parent 2084f834e3
commit 5918b5ddde
2 changed files with 52 additions and 0 deletions
+31
View File
@@ -214,6 +214,37 @@ def test_device_matched_and_unmatched_items_match_metrics_remaining_minutes():
}
def test_unassigned_device_segment_is_allocated_when_all_items_already_matched():
start_at = datetime(2026, 7, 25, 0, 0)
switch_at = datetime(2026, 7, 25, 8, 0)
end_at = datetime(2026, 7, 25, 10, 0)
devices = [
_device(start_at, device_no="23#", sort_order=0),
_device(switch_at, device_no="99#", sort_order=1),
]
item = _item(id=1, good_qty=600, device_no="23#", started_at=start_at)
report = _report(start_at, end_at, item, devices=devices)
metrics = calculate_report_metrics(start_at, end_at, [item], devices=devices)
rows = build_report_allocation_drafts(report)
assert metrics["effective_minutes"] == 600
assert metrics["shift_day_minutes"] == 120
assert metrics["shift_overtime_minutes"] == 120
assert metrics["shift_night_minutes"] == 360
assert round(sum(row.effective_minutes for row in rows), 2) == metrics["effective_minutes"]
assert {
"day": round(sum(row.day_minutes for row in rows), 2),
"overtime": round(sum(row.overtime_minutes for row in rows), 2),
"night": round(sum(row.night_minutes for row in rows), 2),
} == {
"day": metrics["shift_day_minutes"],
"overtime": metrics["shift_overtime_minutes"],
"night": metrics["shift_night_minutes"],
}
assert all(row.effective_minutes == round(row.day_minutes + row.overtime_minutes + row.night_minutes, 2) for row in rows)
def test_night_allocation_uses_meal_deducted_minutes_with_previous_date_rules():
schedule = WorkScheduleConfig(
day_start="08:00",