mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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),
|
||||
total_remaining_value_rp:
|
||||
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_weight_kg: 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(
|
||||
(item, index) => ({
|
||||
No: index + 1,
|
||||
@@ -320,11 +350,11 @@ const HppPerKandangTab = () => {
|
||||
'Rentang Bobot': '-',
|
||||
'Sisa Ayam (Ekor)': totals.total_remaining_chicken_birds,
|
||||
'Sisa Ayam (KG)': totals.total_remaining_chicken_weight_kg,
|
||||
'Rata-Rata Bobot (KG)': '',
|
||||
'Feed (Supplier)': '',
|
||||
'DOC (Supplier)': '',
|
||||
'Rata-Rata Harga DOC (RP)': '',
|
||||
'HPP (RP)': '',
|
||||
'Rata-Rata Bobot (KG)': avgWeight,
|
||||
'Feed (Supplier)': Array.from(totals.all_feed_suppliers).join(' | '),
|
||||
'DOC (Supplier)': Array.from(totals.all_doc_suppliers).join(' | '),
|
||||
'Rata-Rata Harga DOC (RP)': avgDocPrice,
|
||||
'HPP (RP)': avgHpp,
|
||||
'Nilai Nominal Sisa Ayam (RP)': totals.total_remaining_value_rp,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user