fix(kæde): markvarer som hø og hakkelse kommer fra markerne
ADChainData leverer data.fieldGoods (vindue-varer, spillets konvertere, tørrede varianter og kendte markvarer der findes som fill type). En markvare uden producent/stald får kilden "fra marker" uden afgrødeplan og uden problem, så fermenteringssiloernes hø/lucerne/kløver/hakkelse ikke meldes som køb.
This commit is contained in:
@@ -22,7 +22,7 @@ ADChainView.TIGHT_MONTHS = 3
|
||||
-- nøgler rækkerne bruger (til l10n-testen)
|
||||
ADChainView.TEXT_KEYS = {"spu_chain_empty", "spu_chain_approve", "spu_chain_dismiss", "spu_chain_auto",
|
||||
"spu_chain_flowOk", "spu_chain_flowMissing", "spu_chain_flowPallet", "spu_chain_flowNone", "spu_chain_flowStopped", "spu_chain_bottleneck",
|
||||
"spu_chain_buy", "spu_chain_cycle", "spu_chain_fieldShort", "spu_chain_tight", "spu_chain_noField", "spu_chain_buySource",
|
||||
"spu_chain_buy", "spu_chain_cycle", "spu_chain_fieldShort", "spu_chain_tight", "spu_chain_noField", "spu_chain_buySource", "spu_chain_fromFields",
|
||||
"spu_chain_pause", "spu_chain_resume", "spu_chain_scanning", "spu_chain_rootOk", "spu_chain_rootError", "spu_chain_rootWaiting",
|
||||
"spu_chain_rootPaused", "spu_chain_rootSummary", "spu_chain_free", "spu_chain_switches", "spu_chain_gone", "spu_chain_col_item",
|
||||
"spu_chain_col_source", "spu_chain_col_perMonth", "spu_chain_col_status", "spu_chain_col_stock",
|
||||
@@ -94,7 +94,14 @@ end
|
||||
|
||||
local function stockOf(last, fruit)
|
||||
local stock = last.data ~= nil and last.data.stock or nil
|
||||
return stock ~= nil and stock[fruit] or nil
|
||||
return stock ~= nil and fruit ~= nil and stock[fruit] or nil
|
||||
end
|
||||
|
||||
-- Lager for en mark-node: afgrødens lager, eller varens eget lager for en markvare uden afgrøde (hø, hakkelse …).
|
||||
local function fieldStockOf(last, node)
|
||||
if node.fruit ~= nil then return stockOf(last, node.fruit) end
|
||||
local byFill = last.data ~= nil and last.data.stockByFill or nil
|
||||
return byFill ~= nil and byFill[node.fillType] or nil
|
||||
end
|
||||
|
||||
-- Mark-afgrøde uden mangel men med lager under TIGHT_MONTHS måneders behov.
|
||||
@@ -187,6 +194,8 @@ local function sourceText(node, last, textOf)
|
||||
elseif node.source == "husbandry" then
|
||||
for _, herd in ipairs(node.herds or {}) do table.insert(names, tostring(herd.buildingName)) end
|
||||
elseif node.source == "field" then
|
||||
-- markvare uden egen afgrøde (hø, hakkelse …): ingen afgrødeplan, bare "fra marker"
|
||||
if node.fruit == nil then return textOf("spu_chain_fromFields") end
|
||||
for _, field in ipairs(last.fields or {}) do
|
||||
if plannedFruit(field) == node.fruit then table.insert(names, "F" .. tostring(field.id)) end
|
||||
end
|
||||
@@ -294,7 +303,7 @@ local function rootRows(rows, root, last, ctx, isExpanded)
|
||||
end
|
||||
eachNode(root.children, function(node, depth)
|
||||
local text, nodeLevel = nodeStatus(node, last, ctx.fmt, ctx.textOf, ctx.short)
|
||||
local stock = node.source == "field" and stockOf(last, node.fruit) or nil
|
||||
local stock = node.source == "field" and fieldStockOf(last, node) or nil
|
||||
local row = makeRow("node", depth, nodeLevel, {string.rep(ADChainView.INDENT, depth) .. ctx.titleOf(node.fillType),
|
||||
sourceText(node, last, ctx.textOf), ctx.fmt(node.perMonth or 0), text, stock ~= nil and ctx.fmt(stock) or ""})
|
||||
row.fillType = node.fillType
|
||||
|
||||
Reference in New Issue
Block a user