kpi configuration (still prototype some data still use manual need to update later)
This commit is contained in:
1 parent
e4dbfd0252
commit
ed84d989b7
12 files changed
+547
-89
No files matched your search
@@ -0,0 +1,68 @@
|
||||
"""Pure KPI / FCR / EEF formula helpers (Excel-correct)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def compute_chicken_life(doc_in_count: int, mortality_total: int) -> int:
|
||||
return max(int(doc_in_count) - int(mortality_total), 0)
|
||||
|
||||
|
||||
def compute_chicken_life_percentage(doc_in_count: int, chicken_life: int) -> float:
|
||||
if not doc_in_count:
|
||||
return 0.0
|
||||
return (chicken_life / doc_in_count) * 100.0
|
||||
|
||||
|
||||
def compute_stock_akhir(chicken_life: int, harvest_total: int) -> int:
|
||||
return max(int(chicken_life) - int(harvest_total), 0)
|
||||
|
||||
|
||||
def compute_fcr(
|
||||
feed_total: int | float,
|
||||
stock_akhir: int,
|
||||
iot_weight: float,
|
||||
harvest_weight_total_g: float,
|
||||
) -> float:
|
||||
"""FCR = (feed_total * 50 * 1000) / (stock_akhir * iot_weight + harvest_weight_total_g)."""
|
||||
denom = (stock_akhir * iot_weight) + harvest_weight_total_g
|
||||
if denom <= 0:
|
||||
return 0.0
|
||||
return (feed_total * 50 * 1000) / denom
|
||||
|
||||
|
||||
def compute_average_harvest_weight(
|
||||
harvest_weight_total_g: float,
|
||||
stock_akhir: int,
|
||||
iot_weight: float,
|
||||
harvest_total: int,
|
||||
) -> float:
|
||||
"""Excel live-blend: (hwt_g + stock*iot) / (harvest_total + stock)."""
|
||||
denom = harvest_total + stock_akhir
|
||||
if denom <= 0:
|
||||
return 0.0
|
||||
return (harvest_weight_total_g + stock_akhir * iot_weight) / denom
|
||||
|
||||
|
||||
def compute_average_harvest_day(
|
||||
harvest_age_sum: float,
|
||||
age: int,
|
||||
stock_akhir: int,
|
||||
harvest_total: int,
|
||||
) -> float:
|
||||
"""Excel live-blend: (Σ(age*harvest) + age*stock) / (harvest_total + stock)."""
|
||||
denom = harvest_total + stock_akhir
|
||||
if denom <= 0:
|
||||
return 0.0
|
||||
return (harvest_age_sum + age * stock_akhir) / denom
|
||||
|
||||
|
||||
def compute_eef(
|
||||
life_pct: float,
|
||||
average_harvest_weight_g: float,
|
||||
average_harvest_day: float,
|
||||
fcr: float,
|
||||
) -> float:
|
||||
"""EEF = life_pct * (avg_bw_g/1000) / (avg_day * fcr) * 100."""
|
||||
if average_harvest_day <= 0 or fcr <= 0:
|
||||
return 0.0
|
||||
return life_pct * (average_harvest_weight_g / 1000.0) / (average_harvest_day * fcr) * 100.0
|
||||
Reference in new issue
Block a user