adjust hitung ayam page to match dashboard-cpsp
This commit is contained in:
1 parent
b87f20e3b3
commit
c71dcc188b
1 file changed
+9
-7
@@ -17,6 +17,7 @@ import { PageAiInsight } from '../shared/PageAiInsight.tsx';
|
||||
import PopulationTrendChart from './PopulationTrendChart.tsx';
|
||||
import CountingAccuracyWarningBanner from './CountingAccuracyWarningBanner.tsx';
|
||||
import { getCountingAccuracyWarning } from '../../utils/countingAccuracyWarning.ts';
|
||||
import { stockAkhirFromKpi } from '../../utils/kpiStock.ts';
|
||||
|
||||
type Row = {
|
||||
day: number;
|
||||
@@ -95,12 +96,11 @@ const DataManagementPage: React.FC<{ onSettings: () => void }> = ({ onSettings }
|
||||
const manualByDate = new Map(manualRows.map((m) => [m.date, m]));
|
||||
const kpiByDate = new Map(kpis.map((k) => [k.date, k]));
|
||||
|
||||
const lastCycleDay = Math.max(0, (selectedCycle.total_days || 1) - 1);
|
||||
const endDay = selectedCycle.end_date
|
||||
? cycleDayForDate(selectedCycle.start_date, selectedCycle.end_date)
|
||||
: lastCycleDay;
|
||||
const calendarDay = cycleDayForDate(selectedCycle.start_date, todayIso());
|
||||
const maxDay = Math.min(calendarDay, lastCycleDay, endDay);
|
||||
// Closed cycles stop at end_date; active / open cycles build daily rows through calendar today.
|
||||
const maxDay = selectedCycle.end_date
|
||||
? Math.min(calendarDay, cycleDayForDate(selectedCycle.start_date, selectedCycle.end_date))
|
||||
: calendarDay;
|
||||
const today = todayIso();
|
||||
|
||||
let previousStockAkhir = 0;
|
||||
@@ -122,7 +122,7 @@ const DataManagementPage: React.FC<{ onSettings: () => void }> = ({ onSettings }
|
||||
const panen = manual?.harvest_manual ?? kpi?.harvest ?? 0;
|
||||
// Database menyimpan berat panen dalam gram; tampilkan selalu dalam kg.
|
||||
const beratPanen = (manual?.harvest_weight_manual ?? kpi?.harvest_weight ?? 0) / 1000;
|
||||
const stockAkhir = kpi?.chicken_life ?? Math.max(0, stockAwal - mati - panen);
|
||||
const stockAkhir = stockAkhirFromKpi(kpi) ?? Math.max(0, stockAwal - mati - panen);
|
||||
|
||||
const chickenCount = counting?.total_count;
|
||||
// Akurasi Chicken Counting (IOT) terhadap stock akhir manual:
|
||||
@@ -428,7 +428,9 @@ const DataManagementPage: React.FC<{ onSettings: () => void }> = ({ onSettings }
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-xs text-gray-600 mb-1">Tingkat Mortalitas</p>
|
||||
<p className="text-xl font-bold text-orange-600">{stats.mortalityRate}%</p>
|
||||
<p className="text-xl font-bold text-orange-600">
|
||||
{stats.mortalityRate == null ? 'N/A' : `${stats.mortalityRate.toFixed(2)}%`}
|
||||
</p>
|
||||
</div>
|
||||
<i className="fa-solid fa-chart-line text-orange-500 text-2xl"></i>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user