diff --git a/src/app/(dashboard)/absensi/page.tsx b/src/app/(dashboard)/absensi/page.tsx
index 0a35986..5c7c452 100644
--- a/src/app/(dashboard)/absensi/page.tsx
+++ b/src/app/(dashboard)/absensi/page.tsx
@@ -311,9 +311,9 @@ export default function AbsensiPage() {
}}
formatter={(value, name) => {
if (name === t('attendance.persentase')) {
- return [`${value}%`, name];
+ return [`${Number(value).toLocaleString('id-ID', {maximumFractionDigits: 2})}%`, name];
}
- return [value, name];
+ return [`${Number(value).toLocaleString('id-ID')} ${t('common.hariKerja')}`, name];
}}
/>
diff --git a/src/app/(dashboard)/hrcost/page.tsx b/src/app/(dashboard)/hrcost/page.tsx
index a5400e7..2051bcd 100644
--- a/src/app/(dashboard)/hrcost/page.tsx
+++ b/src/app/(dashboard)/hrcost/page.tsx
@@ -110,6 +110,12 @@ export default function HrcostPage() {
value: hrCost.total_bpjs_ks,
valueInMillions: hrCost.total_bpjs_ks / 1000000000,
color: COLORS[2]
+ },
+ {
+ name: t('hrcost.thr'),
+ value: hrCost.total_thr,
+ valueInMillions: hrCost.total_thr / 1000000000,
+ color: COLORS[3]
}
] : [];
diff --git a/src/app/(dashboard)/productivity/page.tsx b/src/app/(dashboard)/productivity/page.tsx
index 252f1b2..af9b913 100644
--- a/src/app/(dashboard)/productivity/page.tsx
+++ b/src/app/(dashboard)/productivity/page.tsx
@@ -41,6 +41,18 @@ export default function ProductivityPage() {
const totalTonnageAge = productivityByAge?.reduce((sum, item) => sum + (item.tonnage / 1000), 0) || 0;
const totalTonnageTenure = productivityByTenure?.reduce((sum, item) => sum + (item.tonnage / 1000), 0) || 0;
+ // Calculate number of days between start_date and end_date
+ const calculateDays = (startDate: string, endDate: string) => {
+ const start = new Date(startDate);
+ const end = new Date(endDate);
+ const timeDiff = end.getTime() - start.getTime();
+ const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24)) + 1; // +1 to include both start and end dates
+ return daysDiff;
+ };
+
+ const filterDays = filter.start_date && filter.end_date ?
+ calculateDays(filter.start_date, filter.end_date) : 1;
+
// Prepare data for pie charts (convert kg to tons)
const ageData = productivityByAge?.map(item => ({
name: item.age_range,
@@ -54,29 +66,36 @@ export default function ProductivityPage() {
percentage: totalTonnageTenure > 0 ? (((item.tonnage / 1000) / totalTonnageTenure) * 100).toFixed(1) : 0
})) || [];
- // Prepare data for charts (convert kg to tons and calculate ratio)
+ // Prepare data for charts (convert kg to tons and calculate ratio per employee per day)
const regionData = productivityByRegion?.map(item => ({
...item,
tonnage: item.tonnage / 1000, // Convert kg to tons
- ratioPerEmployee: item.count > 0 ? (item.tonnage / 1000) / item.count : 0
+ ratioPerEmployee: item.count > 0 && filterDays > 0 ?
+ ((item.tonnage / 1000) / item.count) / filterDays : 0
})).sort((a, b) => b.ratioPerEmployee - a.ratioPerEmployee) || []; // Sort by ratio descending
const ageBarData = productivityByAge?.map(item => ({
...item,
tonnage: item.tonnage / 1000, // Convert kg to tons
- ratioPerEmployee: item.count > 0 ? (item.tonnage / 1000) / item.count : 0
+ ratioPerEmployee: item.count > 0 && filterDays > 0 ?
+ ((item.tonnage / 1000) / item.count) / filterDays : 0
})).sort((a, b) => b.ratioPerEmployee - a.ratioPerEmployee) || []; // Sort by ratio descending
const tenureBarData = productivityByTenure?.map(item => ({
...item,
tonnage: item.tonnage / 1000, // Convert kg to tons
- ratioPerEmployee: item.count > 0 ? (item.tonnage / 1000) / item.count : 0
+ ratioPerEmployee: item.count > 0 && filterDays > 0 ?
+ ((item.tonnage / 1000) / item.count) / filterDays : 0
})).sort((a, b) => b.ratioPerEmployee - a.ratioPerEmployee) || []; // Sort by ratio descending
// Prepare data for tonnage harvest group employee pie chart
const tonnageGroupData = tonnageHarvestGroupEmployee?.map(item => {
// Parse tonnage range from kg format (e.g., "0.0 - 20499.9") and convert to tons
const parseRange = (range: string) => {
+ if (!range || range.endsWith("+")){
+ return (Number(range.replace("+", "")) / 1000).toFixed(1) + "+ ton"
+ }
+
const parts = range.split(' - ');
if (parts.length === 2) {
const min = parseFloat(parts[0]) / 1000; // Convert kg to tons
@@ -243,13 +262,28 @@ export default function ProductivityPage() {
{tonnageGroupData && tonnageGroupData.length > 0 ? (
{`${t('productivity.gaji')}: ${payload[0].name}`}
{`${t('productivity.output')}: ${data.value.toLocaleString('id-ID')} ${t('common.ton')}`}
{`${t('common.karyawan')}: ${data.count.toLocaleString('id-ID')} ${t('common.orang')}`}
-{`${t('productivity.persentase')}: ${data.percentage}%`}
+{`${t('productivity.persentase')}: ${calculatedPercentage}%`}