fix: 归一化报工归属工时分配
This commit is contained in:
@@ -238,6 +238,30 @@ def test_blank_overtime_meal_deduction_is_clipped_like_metrics():
|
||||
]
|
||||
|
||||
|
||||
def test_same_device_item_split_inside_meal_is_rescaled_to_metrics_effective_minutes():
|
||||
start_at = datetime(2026, 7, 25, 8, 0)
|
||||
second_started_at = datetime(2026, 7, 25, 12, 0)
|
||||
end_at = datetime(2026, 7, 25, 13, 0)
|
||||
first_item = _item(id=1, good_qty=192, started_at=start_at)
|
||||
second_item = _item(id=2, good_qty=48, started_at=second_started_at)
|
||||
report = _report(start_at, end_at, [first_item, second_item], devices=[_device(start_at)])
|
||||
|
||||
metrics = calculate_report_metrics(start_at, end_at, [first_item, second_item], devices=[_device(start_at)])
|
||||
rows = build_report_allocation_drafts(report)
|
||||
|
||||
assert metrics["effective_minutes"] == 240
|
||||
assert metrics["shift_day_minutes"] == 240
|
||||
assert {first_item.id: first_item.allocated_minutes, second_item.id: second_item.allocated_minutes} == {
|
||||
1: 192,
|
||||
2: 48,
|
||||
}
|
||||
assert [(row.report_item_id, row.effective_minutes, row.day_minutes) for row in rows] == [
|
||||
(1, 192, 192),
|
||||
(2, 48, 48),
|
||||
]
|
||||
assert sum(row.effective_minutes for row in rows) == 240
|
||||
|
||||
|
||||
def test_zero_effective_minutes_falls_back_to_original_report_date():
|
||||
item = _item(good_qty=5, defect_qty=1, scrap_qty=0.5, changeover_count=2, process_unit_price_yuan=3)
|
||||
report = _report(
|
||||
|
||||
Reference in New Issue
Block a user