mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
feat(FE-356): Include HPP and supplier aggregates in export
This commit is contained in:
@@ -285,14 +285,44 @@ const HppPerKandangTab = () => {
|
|||||||
(item.remaining_chicken_weight_kg || 0),
|
(item.remaining_chicken_weight_kg || 0),
|
||||||
total_remaining_value_rp:
|
total_remaining_value_rp:
|
||||||
acc.total_remaining_value_rp + (item.remaining_value_rp || 0),
|
acc.total_remaining_value_rp + (item.remaining_value_rp || 0),
|
||||||
|
total_hpp_rp: acc.total_hpp_rp + (item.hpp_rp || 0),
|
||||||
|
average_doc_price_rp:
|
||||||
|
acc.average_doc_price_rp + (item.average_doc_price_rp || 0),
|
||||||
|
all_feed_suppliers: new Set([
|
||||||
|
...acc.all_feed_suppliers,
|
||||||
|
...(item.feed_suppliers?.map((s) => s.alias || s.name) || []),
|
||||||
|
]),
|
||||||
|
all_doc_suppliers: new Set([
|
||||||
|
...acc.all_doc_suppliers,
|
||||||
|
...(item.doc_suppliers?.map((s) => s.alias || s.name) || []),
|
||||||
|
]),
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
total_remaining_chicken_birds: 0,
|
total_remaining_chicken_birds: 0,
|
||||||
total_remaining_chicken_weight_kg: 0,
|
total_remaining_chicken_weight_kg: 0,
|
||||||
total_remaining_value_rp: 0,
|
total_remaining_value_rp: 0,
|
||||||
|
total_hpp_rp: 0,
|
||||||
|
average_doc_price_rp: 0,
|
||||||
|
all_feed_suppliers: new Set<string>(),
|
||||||
|
all_doc_suppliers: new Set<string>(),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Calculate averages
|
||||||
|
const avgWeight =
|
||||||
|
totals.total_remaining_chicken_birds > 0
|
||||||
|
? totals.total_remaining_chicken_weight_kg /
|
||||||
|
totals.total_remaining_chicken_birds
|
||||||
|
: 0;
|
||||||
|
const avgDocPrice =
|
||||||
|
allExportData.length > 0
|
||||||
|
? totals.average_doc_price_rp / allExportData.length
|
||||||
|
: 0;
|
||||||
|
const avgHpp =
|
||||||
|
totals.total_remaining_chicken_birds > 0
|
||||||
|
? totals.total_hpp_rp / totals.total_remaining_chicken_birds
|
||||||
|
: 0;
|
||||||
|
|
||||||
const excelData: { [key: string]: string | number }[] = allExportData.map(
|
const excelData: { [key: string]: string | number }[] = allExportData.map(
|
||||||
(item, index) => ({
|
(item, index) => ({
|
||||||
No: index + 1,
|
No: index + 1,
|
||||||
@@ -320,11 +350,11 @@ const HppPerKandangTab = () => {
|
|||||||
'Rentang Bobot': '-',
|
'Rentang Bobot': '-',
|
||||||
'Sisa Ayam (Ekor)': totals.total_remaining_chicken_birds,
|
'Sisa Ayam (Ekor)': totals.total_remaining_chicken_birds,
|
||||||
'Sisa Ayam (KG)': totals.total_remaining_chicken_weight_kg,
|
'Sisa Ayam (KG)': totals.total_remaining_chicken_weight_kg,
|
||||||
'Rata-Rata Bobot (KG)': '',
|
'Rata-Rata Bobot (KG)': avgWeight,
|
||||||
'Feed (Supplier)': '',
|
'Feed (Supplier)': Array.from(totals.all_feed_suppliers).join(' | '),
|
||||||
'DOC (Supplier)': '',
|
'DOC (Supplier)': Array.from(totals.all_doc_suppliers).join(' | '),
|
||||||
'Rata-Rata Harga DOC (RP)': '',
|
'Rata-Rata Harga DOC (RP)': avgDocPrice,
|
||||||
'HPP (RP)': '',
|
'HPP (RP)': avgHpp,
|
||||||
'Nilai Nominal Sisa Ayam (RP)': totals.total_remaining_value_rp,
|
'Nilai Nominal Sisa Ayam (RP)': totals.total_remaining_value_rp,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user