fix(pl): 同市与异地混跑时结转只要求本组来源有实运量。
运输证分组只有部分来源时,忽略实际量里多出来的来源,不再整单报缺实际量。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
643221c61f
commit
3f62af430f
2 files changed
+19
-1
No files matched your search
@@ -339,6 +339,8 @@ def settle_allocations(reserved: Sequence[Allocation], actual_by_source: Mapping
|
||||
超来源量或超任一证件预占量均要求先补充分配。
|
||||
同市等仅购买证场景下,调用方仍可能对本函数传入空的运输证分组与全量实运量;
|
||||
无预占行时直接空结转,不把「缺实际量」套到另一类证件上。
|
||||
同市装货 + 异地卸货混跑时,运输证分组往往只有卸货来源,而 actual 含全部来源;
|
||||
只要求本组预占来源都有实运量,多出来源忽略。
|
||||
"""
|
||||
if not reserved:
|
||||
return ()
|
||||
@@ -357,7 +359,7 @@ def settle_allocations(reserved: Sequence[Allocation], actual_by_source: Mapping
|
||||
keys.add(key)
|
||||
seqs.add(seq)
|
||||
grouped.setdefault(row.source_id, []).append(row)
|
||||
if set(actual_by_source) != set(grouped):
|
||||
if not set(grouped) <= set(actual_by_source):
|
||||
raise AllocationInputError('必须明确提交每个来源的实际量')
|
||||
manual = {}
|
||||
for row in manual_actuals:
|
||||
|
||||
@@ -254,6 +254,22 @@ def test_empty_transport_kind_settle_ignores_source_actuals():
|
||||
assert settle_allocations([], {'city': D(10)}) == ()
|
||||
|
||||
|
||||
def test_partial_transport_settle_ignores_sources_without_reservation():
|
||||
"""同市装货无运输预占、异地卸货有运输预占时,运输结转不得因多出来源实运量报缺实际量。"""
|
||||
from app.services.pl_quota_allocation import Allocation
|
||||
|
||||
transport_rows = [
|
||||
Allocation('transport', 'delivery:sp', 't1', D(33), D(33), 'dun', 'dun', 1),
|
||||
]
|
||||
actuals = {'load:sp': D(33), 'delivery:sp': D(33)}
|
||||
settled = settle_allocations(transport_rows, actuals)
|
||||
assert len(settled) == 1
|
||||
assert settled[0].actual_source_quantity == D(33)
|
||||
|
||||
with pytest.raises(AllocationInputError, match='实际量'):
|
||||
settle_allocations(transport_rows, {'load:sp': D(33)})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('manual_values', [(8,10,0),(18,0,0)])
|
||||
def test_zero_capacity_foreign_row_cannot_unlock_manual_reordering(manual_values):
|
||||
from app.services.pl_quota_allocation import Allocation
|
||||
|
||||
Reference in new issue
Block a user