feat: udkørsel kan sælge alt gården ikke bruger + politikken Behold (1.62.378)
This commit is contained in:
@@ -90,12 +90,14 @@ end
|
||||
-- ---- store-wrappers (erstatter altid hele store'en; modellen muterer aldrig) ----
|
||||
|
||||
function ADRunsController.createRun(name, kind)
|
||||
if ADSources ~= nil and ADSources.invalidateUsed ~= nil then ADSources.invalidateUsed() end -- "Sælg alt ubrugt" ser nye flows straks
|
||||
local store, run = ADRuns.createRun(ADRunsController.store, name, kind)
|
||||
ADRunsController.store = store
|
||||
return run
|
||||
end
|
||||
|
||||
function ADRunsController.deleteRun(runId, adEnv)
|
||||
if ADSources ~= nil and ADSources.invalidateUsed ~= nil then ADSources.invalidateUsed() end
|
||||
local run = ADRuns.getRun(ADRunsController.store, runId)
|
||||
if run ~= nil and adEnv ~= nil and not run.stopped then
|
||||
for _, vehicleId in ipairs(run.vehicleIds) do
|
||||
@@ -108,6 +110,7 @@ end
|
||||
|
||||
-- Hver ændring logges, så et klik der ikke når modellen kan ses i log.txt.
|
||||
function ADRunsController.updateRun(runId, changes)
|
||||
if ADSources ~= nil and ADSources.invalidateUsed ~= nil then ADSources.invalidateUsed() end
|
||||
ADRunsController.store = ADRuns.updateRun(ADRunsController.store, runId, changes)
|
||||
local run = ADRuns.getRun(ADRunsController.store, runId)
|
||||
local parts = {}
|
||||
@@ -740,6 +743,7 @@ function ADRunsController.getFlowRow(adEnv, run)
|
||||
table.insert(row.productNames, product.fillType)
|
||||
table.insert(row.policies, product.policy)
|
||||
end
|
||||
if run.sellUnused then table.insert(row.policies, "sell") end
|
||||
local status = ADRunsController.getOutboundStatus(adEnv, run)
|
||||
row.reason, row.warning = status.reasons[1], status.warning
|
||||
else
|
||||
@@ -849,7 +853,12 @@ function ADRunsController.getRunProducts(adEnv, run, includeEmpty)
|
||||
for _, item in ipairs(ADSources.getProducts(adEnv, source, farmId, includeEmpty)) do
|
||||
local product = byName[item.name]
|
||||
if product == nil then
|
||||
product = {fillType = item.fillType, name = item.name, title = item.title or item.name, policy = ADRuns.getProductPolicy(run, item.name), isPallet = item.isPallet, canPallet = item.canPallet, available = 0, level = 0, capacity = 0}
|
||||
-- "Sælg alt, gården ikke bruger": en ikke-valgt vare uden brug på gården tæller som Sell (validering, liste)
|
||||
local used, usedBy = nil, nil
|
||||
if ADSources.farmUses ~= nil then used, usedBy = ADSources.farmUses(item.fillType, farmId) end
|
||||
local policy = ADRuns.effectivePolicy(run, item.name, function() return used ~= false end)
|
||||
product = {fillType = item.fillType, name = item.name, title = item.title or item.name, policy = policy, isPallet = item.isPallet, canPallet = item.canPallet, available = 0, level = 0, capacity = 0,
|
||||
used = used, usedBy = usedBy}
|
||||
byName[item.name] = product
|
||||
table.insert(result, product)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user