feat: regel 'Hent først når kilden er over X %' for salgsflows (v1.62.68)
This commit is contained in:
@@ -71,6 +71,8 @@ function ADOutboundPlanner.evaluate(product, input)
|
||||
priceOk = input.sellAtPercent == 0 or (percent ~= nil and percent >= (input.sellAtPercent or 90)),
|
||||
-- "sælg altid over X %": kilden er så fuld, at der sælges uanset pris
|
||||
overflow = (input.sellAbovePercent or 0) > 0 and storagePercent >= input.sellAbovePercent,
|
||||
-- "hent først ved X %": salg venter til kilden er så fuld, eller et fuldt læs ligger klar (0 = fra)
|
||||
minSourceOk = (input.minSourcePercent or 0) <= 0 or fullLoad or storagePercent >= input.minSourcePercent,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -101,6 +103,10 @@ local function reasonFor(product, e, input)
|
||||
local names = table.concat(product.reservedFor or {}, ", ")
|
||||
return string.format("%s: %s reserveret til %s", product.name, formatLiters(e.reserve), names ~= "" and names or "gårdens eget forbrug")
|
||||
end
|
||||
if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and not e.minSourceOk then
|
||||
return string.format("%s: lager %d %% (henter fra %d %% eller fuldt læs)", product.name,
|
||||
math.floor(e.storagePercent + 0.5), input.minSourcePercent)
|
||||
end
|
||||
local canStore = wantsStore(product.policy) and product.store ~= nil
|
||||
if wantsSell(product.policy) and product.quote == nil and not canStore then
|
||||
return product.name .. ": intet nåeligt salgssted"
|
||||
@@ -126,7 +132,7 @@ local function collectCandidates(input)
|
||||
local e = ADOutboundPlanner.evaluate(product, input)
|
||||
local added = false
|
||||
if e.available >= ADOutboundPlanner.MIN_AVAILABLE_LITERS then
|
||||
if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and canSellWithoutReserve(e, input) then
|
||||
if wantsSell(product.policy) and (e.priceOk or e.overflow) and e.minSourceOk and product.quote ~= nil and canSellWithoutReserve(e, input) then
|
||||
table.insert(sell, {product = product, e = e, kind = "sell", targetWayPointId = product.quote.wayPointId, targetName = product.quote.stationName, percent = e.percent})
|
||||
added = true
|
||||
elseif wantsStore(product.policy) and (e.fullLoad or e.storageHigh or (input.feedMode and e.available >= ADOutboundPlanner.FEED_MIN_LITERS)) and product.store ~= nil then
|
||||
|
||||
Reference in New Issue
Block a user