From d2450749047255202d191544913bca09cd523f17 Mon Sep 17 00:00:00 2001 From: efrilm Date: Tue, 23 Sep 2025 20:54:43 +0700 Subject: [PATCH 1/2] no translate for payment method --- .../payment-methods/PaymentMethodReport.tsx | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/views/dashboards/payment-methods/PaymentMethodReport.tsx b/src/views/dashboards/payment-methods/PaymentMethodReport.tsx index d0a9ed1..b0194f3 100644 --- a/src/views/dashboards/payment-methods/PaymentMethodReport.tsx +++ b/src/views/dashboards/payment-methods/PaymentMethodReport.tsx @@ -19,22 +19,25 @@ const PaymentMethodReport = ({ payments }: { payments: PaymentDataItem[] }) => {

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 -
-
- ))} + ))}
-- 2.47.2 From 1b9908e882748d0fb82abf7a287fc32757fc7102 Mon Sep 17 00:00:00 2001 From: efrilm Date: Tue, 23 Sep 2025 22:27:58 +0700 Subject: [PATCH 2/2] update report --- .gitignore | 2 + .../dashboards/daily-report/page.tsx | 344 ++++++++++-------- .../dashboards/daily-report/report-header.tsx | 84 +---- 3 files changed, 211 insertions(+), 219 deletions(-) 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

-
- - - - - - - - - - - - - {profitLoss?.product_data?.map((item, index) => ( - - - - - - - - - )) || []} - - - - - - - - - - - -
ProdukQtyPendapatanHPPLaba KotorMargin (%)
{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

- + @@ -493,7 +421,7 @@ const DailyPOSReport = () => { )) || []} - + @@ -510,18 +438,17 @@ const DailyPOSReport = () => { {/* Category Summary */}

- 2. Ringkasan Kategori + Ringkasan Kategori

Metode Pembayaran Tipe Jumlah Order
TOTAL {paymentAnalytics?.summary.total_orders ?? 0}
- + - - + @@ -530,7 +457,6 @@ const DailyPOSReport = () => { - @@ -538,11 +464,10 @@ const DailyPOSReport = () => { )) || []} - + - @@ -553,49 +478,164 @@ const DailyPOSReport = () => { {/* Transaction Summary */}

- 4. Ringkasan Item + Ringkasan Item

-
-
Nama Total Produk QtyJumlah OrderPendapatanPendapatan
{c.category_name} {c.product_count} {c.total_quantity}{c.order_count} {formatCurrency(c.total_revenue)}
TOTAL {categorySummary?.productCount ?? 0} {categorySummary?.totalQuantity ?? 0}{categorySummary?.orderCount ?? 0} {formatCurrency(categorySummary?.totalRevenue ?? 0)}
- - - - - - - - - - - - {products?.data?.map((item, index) => ( - - - - - - - +
+
+
ProdukKategoriQtyOrderPendapatanRata Rata
{item.product_name}{item.category_name}{item.quantity_sold}{item.order_count ?? 0}{formatCurrency(item.revenue)}{formatCurrency(item.average_price)}
+ + + + + + + + + + + + + + - )) || []} - - - - - - - - - - - -
ProdukQtyOrderPendapatanRata 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} - - - )} - + )}