fix: kæden skifter aldrig til eng (kan ikke sås); eng tæller som udbud; ugyldige kædemål ryddes (v1.62.31)

This commit is contained in:
2026-10-05 16:00:13 +02:00
parent 5d7b3bebca
commit defbf136f4
7 changed files with 79 additions and 16 deletions
+4 -1
View File
@@ -33,7 +33,10 @@ function ADCropPlan.shortages(demand, stock, fields, yields, products)
local need = perMonth * ADCropPlan.HORIZON_MONTHS
local supply = (stock or {})[key] or 0
for _, field in ipairs(fields or {}) do
if ADCropPlan.plannedFruit(field) == fruit and (product == nil or ADCropPlan.fieldProduct(field) == product) then
local planned = ADCropPlan.plannedFruit(field)
-- andre afgrøder med samme vindue (eng) tæller også som udbud
local sameCrop = planned == fruit or (spec ~= nil and spec.fruits ~= nil and planned ~= nil and spec.fruits[planned] == true)
if sameCrop and (product == nil or ADCropPlan.fieldProduct(field) == product) then
supply = supply + (field.areaHa or 0) * perHa
end
end