From 0c375de6e434713a10dbe40719b7777d9bc890c7 Mon Sep 17 00:00:00 2001 From: efrilm Date: Thu, 14 Aug 2025 17:32:16 +0700 Subject: [PATCH] fix: report profit loss --- lib/core/components/custom_date_picker.dart | 3 ++- lib/core/components/pdf/pdf_header.dart | 0 lib/data/models/response/profit_loss_response_model.dart | 8 ++++---- lib/presentation/report/pages/report_page.dart | 4 ++-- lib/presentation/report/widgets/profit_loss_widget.dart | 2 +- lib/presentation/report/widgets/report_title.dart | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 lib/core/components/pdf/pdf_header.dart diff --git a/lib/core/components/custom_date_picker.dart b/lib/core/components/custom_date_picker.dart index 823d052..a05c9fc 100644 --- a/lib/core/components/custom_date_picker.dart +++ b/lib/core/components/custom_date_picker.dart @@ -70,7 +70,8 @@ class _CustomDatePickerState extends State { ), decoration: InputDecoration( suffixIcon: Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.symmetric( + vertical: 8, horizontal: 16), child: Assets.icons.calendar.svg(), ), prefix: widget.prefix, diff --git a/lib/core/components/pdf/pdf_header.dart b/lib/core/components/pdf/pdf_header.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/data/models/response/profit_loss_response_model.dart b/lib/data/models/response/profit_loss_response_model.dart index a69c7a1..baabbb9 100644 --- a/lib/data/models/response/profit_loss_response_model.dart +++ b/lib/data/models/response/profit_loss_response_model.dart @@ -106,7 +106,7 @@ class ProfitLossSummary { final int netProfit; final double netProfitMargin; final int totalOrders; - final int averageProfit; + final double averageProfit; final double profitabilityRatio; ProfitLossSummary({ @@ -134,7 +134,7 @@ class ProfitLossSummary { netProfit: map['net_profit'], netProfitMargin: (map['net_profit_margin'] as num).toDouble(), totalOrders: map['total_orders'], - averageProfit: map['average_profit'], + averageProfit: (map['average_profit'] as num).toDouble(), profitabilityRatio: (map['profitability_ratio'] as num).toDouble(), ); } @@ -252,8 +252,8 @@ class ProfitLossProduct { cost: map['cost'], grossProfit: map['gross_profit'], grossProfitMargin: (map['gross_profit_margin'] as num).toDouble(), - averagePrice: map['average_price'], - averageCost: map['average_cost'], + averagePrice: (map['average_price'] as num).toInt(), + averageCost: (map['average_cost'] as num).toInt(), profitPerUnit: map['profit_per_unit'], ); } diff --git a/lib/presentation/report/pages/report_page.dart b/lib/presentation/report/pages/report_page.dart index 4f1778c..7b50923 100644 --- a/lib/presentation/report/pages/report_page.dart +++ b/lib/presentation/report/pages/report_page.dart @@ -194,12 +194,12 @@ class _ReportPageState extends State { isActive: selectedMenu == 4, ), ReportMenu( - label: 'Laporan untung rugi', + label: 'Laporan Untung Rugi', subtitle: 'Laporan untung rugi penjualan.', icon: Icons.trending_down, onPressed: () { selectedMenu = 5; - title = 'Laporan untung rugi'; + title = 'Laporan Untung Rugi'; setState(() {}); context.read().add( ProfitLossEvent.getProfitLoss( diff --git a/lib/presentation/report/widgets/profit_loss_widget.dart b/lib/presentation/report/widgets/profit_loss_widget.dart index ac318b9..d536d01 100644 --- a/lib/presentation/report/widgets/profit_loss_widget.dart +++ b/lib/presentation/report/widgets/profit_loss_widget.dart @@ -873,7 +873,7 @@ class ProfitLossWidget extends StatelessWidget { Expanded( child: _buildMetricCard( 'Keuntungan Rata-rata', - _formatCurrency(data.summary.averageProfit), + "${data.summary.averageProfit.round()}%", 'Per pesanan', Icons.trending_up, AppColorProfitLoss.success, diff --git a/lib/presentation/report/widgets/report_title.dart b/lib/presentation/report/widgets/report_title.dart index 30ab197..7268dfe 100644 --- a/lib/presentation/report/widgets/report_title.dart +++ b/lib/presentation/report/widgets/report_title.dart @@ -16,7 +16,7 @@ class ReportTitle extends StatelessWidget { vertical: 10.0, ), width: double.infinity, - height: context.deviceHeight * 0.1, + height: context.deviceHeight * 0.13, decoration: const BoxDecoration( color: AppColors.white, border: Border(