Files
dashboard-cpsp/utils/kpiStock.ts
T

11 lines
408 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* KPI.chicken_life = DOC − cumulative mortality (excludes harvest).
* Stock akhir (in-house remaining) = chicken_life − harvest_total.
*/
export function stockAkhirFromKpi(
kpi: { chicken_life?: number | null; harvest_total?: number | null } | null | undefined
): number | null {
if (kpi?.chicken_life == null) return null;
return Math.max(0, kpi.chicken_life - (kpi.harvest_total ?? 0));
}