diff --git a/.gitignore b/.gitignore
index c5a2dee..01fb283 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,5 @@ next-env.d.ts
# icon generated file
src/assets/iconify-icons/generated-icons.js
src/assets/iconify-icons/generated-icons.css
+
+*.backup
diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/daily-report/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/daily-report/page.tsx
index 0d46ceb..d5ba06b 100644
--- a/src/app/[lang]/(dashboard)/(private)/dashboards/daily-report/page.tsx
+++ b/src/app/[lang]/(dashboard)/(private)/dashboards/daily-report/page.tsx
@@ -55,14 +55,6 @@ const DailyPOSReport = () => {
totalOrders: products?.data?.reduce((sum, item) => sum + (item?.order_count || 0), 0) || 0
}
- // Calculate profit loss product summary
- const profitLossProductSummary = {
- totalRevenue: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.revenue || 0), 0) || 0,
- totalCost: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.cost || 0), 0) || 0,
- totalGrossProfit: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.gross_profit || 0), 0) || 0,
- totalQuantity: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.quantity_sold || 0), 0) || 0
- }
-
const categorySummary = {
totalRevenue: category?.data?.reduce((sum, item) => sum + (item?.total_revenue || 0), 0) || 0,
orderCount: category?.data?.reduce((sum, item) => sum + (item?.order_count || 0), 0) || 0,
@@ -340,126 +332,62 @@ const DailyPOSReport = () => {
{/* Performance Summary */}
- 1. Ringkasan
+ Ringkasan
-
-
-
- Total Penjualan (termasuk rasik)
-
- {formatCurrency(profitLoss?.summary.total_revenue ?? 0)}
-
-
-
- Total Terjual
- {productSummary.totalQuantitySold}
-
-
- HPP
-
- {formatCurrency(profitLoss?.summary.total_cost ?? 0)} |{' '}
- {(((profitLoss?.summary.total_cost ?? 0) / (profitLoss?.summary.total_revenue || 1)) * 100).toFixed(
- 0
- )}
- %
-
-
-
- Laba Kotor
-
- {formatCurrency(profitLoss?.summary.gross_profit ?? 0)} |{' '}
- {(profitLoss?.summary.gross_profit_margin ?? 0).toFixed(0)}%
-
-
+
+
+ Total Penjualan
+
+ {formatCurrency(profitLoss?.summary.total_revenue ?? 0)}
+
-
-
-
- Biaya lain²
-
- {formatCurrency(profitLoss?.summary.total_tax ?? 0)} |{' '}
- {(((profitLoss?.summary.total_tax ?? 0) / (profitLoss?.summary.total_revenue || 1)) * 100).toFixed(0)}
- %
-
-
-
- Laba/Rugi
-
- {formatCurrency(profitLoss?.summary.net_profit ?? 0)} |{' '}
- {(profitLoss?.summary.net_profit_margin ?? 0).toFixed(0)}%
-
-
+
+ Total Diskon
+
+ {formatCurrency(profitLoss?.summary.total_discount ?? 0)}
+
+
+
+ Total Pajak
+ {formatCurrency(profitLoss?.summary.total_tax ?? 0)}
+
+
+ Total
+ {formatCurrency(profitLoss?.summary.total_revenue ?? 0)}
- {/* Profit Loss Product Table */}
-
- Laba Rugi Per Produk
+
+ Invoice
-
-
-
-
- | Produk |
- Qty |
- Pendapatan |
- HPP |
- Laba Kotor |
- Margin (%) |
-
-
-
- {profitLoss?.product_data?.map((item, index) => (
-
- | {item.product_name} |
- {item.quantity_sold} |
- {formatCurrency(item.revenue)} |
- {formatCurrency(item.cost)} |
- {formatCurrency(item.gross_profit)} |
-
- {(item.gross_profit_margin ?? 0).toFixed(1)}%
- |
-
- )) || []}
-
-
-
- | TOTAL |
- {profitLossProductSummary.totalQuantity} |
- {formatCurrency(profitLossProductSummary.totalRevenue)} |
- {formatCurrency(profitLossProductSummary.totalCost)} |
-
- {formatCurrency(profitLossProductSummary.totalGrossProfit)}
- |
-
- {profitLossProductSummary.totalRevenue > 0
- ? (
- (profitLossProductSummary.totalGrossProfit / profitLossProductSummary.totalRevenue) *
- 100
- ).toFixed(1)
- : 0}
- %
- |
-
-
-
+
+
+ Total Invoice
+ {profitLoss?.summary.total_orders ?? 0}
+
+
+ Rata-rata Tagihan Per Invoice
+
+ {formatCurrency(profitLoss?.summary.average_profit ?? 0)}
+
+
{/* Payment Method Summary */}
- 2. Ringkasan Metode Pembayaran
+ Ringkasan Metode Pembayaran
-
+
| Metode Pembayaran |
Tipe |
Jumlah Order |
@@ -493,7 +421,7 @@ const DailyPOSReport = () => {
)) || []}
-
+
| TOTAL |
|
{paymentAnalytics?.summary.total_orders ?? 0} |
@@ -510,18 +438,17 @@ const DailyPOSReport = () => {
{/* Category Summary */}
- 2. Ringkasan Kategori
+ Ringkasan Kategori
-
+
| Nama |
Total Produk |
Qty |
- Jumlah Order |
- Pendapatan |
+ Pendapatan |
@@ -530,7 +457,6 @@ const DailyPOSReport = () => {
{c.category_name} |
{c.product_count} |
{c.total_quantity} |
- {c.order_count} |
{formatCurrency(c.total_revenue)}
|
@@ -538,11 +464,10 @@ const DailyPOSReport = () => {
)) || []}
-
+
| TOTAL |
{categorySummary?.productCount ?? 0} |
{categorySummary?.totalQuantity ?? 0} |
- {categorySummary?.orderCount ?? 0} |
{formatCurrency(categorySummary?.totalRevenue ?? 0)} |
@@ -553,49 +478,164 @@ const DailyPOSReport = () => {
{/* Transaction Summary */}
- 4. Ringkasan Item
+ Ringkasan Item
-
-
-
-
- | Produk |
- Kategori |
- Qty |
- Order |
- Pendapatan |
- Rata Rata |
-
-
-
- {products?.data?.map((item, index) => (
-
- | {item.product_name} |
- {item.category_name} |
- {item.quantity_sold} |
- {item.order_count ?? 0} |
- {formatCurrency(item.revenue)} |
- {formatCurrency(item.average_price)} |
+
+
+
+
+
+
+
+
+
+
+
+
+ | Produk |
+ Qty |
+ Order |
+ Pendapatan |
+ Rata Rata |
- )) || []}
-
-
-
- | TOTAL |
- |
- {productSummary.totalQuantitySold ?? 0} |
- {productSummary.totalOrders ?? 0} |
- {formatCurrency(productSummary.totalRevenue ?? 0)} |
- |
-
-
-
+
+
+ {(() => {
+ // Group products by category
+ const groupedProducts =
+ products?.data?.reduce(
+ (acc, item) => {
+ const categoryName = item.category_name || 'Tidak Berkategori'
+ if (!acc[categoryName]) {
+ acc[categoryName] = []
+ }
+ acc[categoryName].push(item)
+ return acc
+ },
+ {} as Record
+ ) || {}
+
+ const rows: JSX.Element[] = []
+ let globalIndex = 0
+
+ // Sort categories alphabetically
+ Object.keys(groupedProducts)
+ .sort()
+ .forEach(categoryName => {
+ const categoryProducts = groupedProducts[categoryName]
+
+ // Category header row
+ rows.push(
+
+ |
+ {categoryName.toUpperCase()}
+ |
+ |
+ |
+ |
+ |
+
+ )
+
+ // Product rows for this category
+ categoryProducts.forEach((item, index) => {
+ globalIndex++
+ rows.push(
+
+ |
+ {item.product_name}
+ |
+
+ {item.quantity_sold}
+ |
+
+ {item.order_count ?? 0}
+ |
+
+ {formatCurrency(item.revenue)}
+ |
+
+ {formatCurrency(item.average_price)}
+ |
+
+ )
+ })
+
+ // Category subtotal row
+ const categoryTotalQty = categoryProducts.reduce(
+ (sum, item) => sum + (item.quantity_sold || 0),
+ 0
+ )
+ const categoryTotalOrders = categoryProducts.reduce(
+ (sum, item) => sum + (item.order_count || 0),
+ 0
+ )
+ const categoryTotalRevenue = categoryProducts.reduce(
+ (sum, item) => sum + (item.revenue || 0),
+ 0
+ )
+
+ rows.push(
+
+ |
+ Subtotal {categoryName}
+ |
+
+ {categoryTotalQty}
+ |
+
+ {categoryTotalOrders}
+ |
+
+ {formatCurrency(categoryTotalRevenue)}
+ |
+ |
+
+ )
+ })
+
+ return rows
+ })()}
+
+
+
+ | TOTAL KESELURUHAN |
+
+ {productSummary.totalQuantitySold ?? 0}
+ |
+
+ {productSummary.totalOrders ?? 0}
+ |
+
+ {formatCurrency(productSummary.totalRevenue ?? 0)}
+ |
+ |
+
+
+
+
- {/* Profit Loss Product Table */}
-
{/* Footer */}
diff --git a/src/views/dashboards/daily-report/report-header.tsx b/src/views/dashboards/daily-report/report-header.tsx
index 2cece41..bbed8d0 100644
--- a/src/views/dashboards/daily-report/report-header.tsx
+++ b/src/views/dashboards/daily-report/report-header.tsx
@@ -7,9 +7,6 @@ import type { FC } from 'react'
import { Box, Typography, Divider } from '@mui/material'
import { useTheme } from '@mui/material/styles'
-// Component Imports
-import Logo from '@core/svg/Logo'
-
// Type Imports
import type { Outlet } from '@/types/services/outlet'
@@ -39,75 +36,28 @@ const ReportHeader: FC
= ({
return (
-
- {/* Left Section - Brand & Outlet Info */}
-
-
-
-
- {brandName}
-
- {outlet?.name && (
-
- {outlet.name}
-
- )}
- {outlet?.address && (
-
- {outlet.address}
-
- )}
-
-
-
- {/* Right Section - Report Info */}
-
+
+
+ {reportTitle}
+
+ {periode && (
- {reportTitle}
+ {periode}
- {periode && (
-
-
- {periode}
-
-
- )}
- {reportSubtitle && (
-
-
- {reportSubtitle}
-
-
- )}
-
+ )}
{
Payment Methods
- {payments && payments.map(method => (
-
-
-
{method.payment_method_name}
-
{method.percentage.toFixed(1)}%
+ {payments &&
+ payments.map(method => (
+
+
+
+ {method.payment_method_name}
+
+ {method.percentage.toFixed(1)}%
+
+
+
+ {formatCurrency(method.total_amount)}
+ {method.order_count} orders
+
-
-
- {formatCurrency(method.total_amount)}
- {method.order_count} orders
-
-
- ))}
+ ))}