feat: update parent category analytic
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
This commit is contained in:
@@ -183,50 +183,55 @@ class _SummaryCard extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
child: ProfitSharingStatTile(
|
||||
icon: Icons.category_rounded,
|
||||
label: context.lang.sub_category,
|
||||
value: '${summary.categoryCount}',
|
||||
),
|
||||
),
|
||||
const SpaceWidth(10),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
child: ProfitSharingStatTile(
|
||||
icon: Icons.inventory_2_rounded,
|
||||
label: context.lang.products,
|
||||
value: '${summary.productCount}',
|
||||
color: AppColor.info,
|
||||
),
|
||||
),
|
||||
const SpaceWidth(10),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
child: ProfitSharingStatTile(
|
||||
icon: Icons.receipt_long_rounded,
|
||||
label: context.lang.orders,
|
||||
value: summary.orderCount.thousandFormat,
|
||||
color: AppColor.warning,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
child: Divider(height: 1, color: AppColor.borderLight),
|
||||
const SpaceHeight(12),
|
||||
|
||||
ProfitSharingSdlStrip(
|
||||
amount: summary.sdl,
|
||||
feePercent: summary.ownerFeePercent,
|
||||
),
|
||||
|
||||
const SpaceHeight(12),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.std_hpp,
|
||||
value: formatPercent(summary.standardHppPercentage),
|
||||
child: Text(
|
||||
context.lang.gross_profit,
|
||||
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.real_hpp,
|
||||
value: formatPercent(summary.realHppPercentage),
|
||||
valueColor: statusColor(summary.realHppPercentage),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.gross_profit,
|
||||
value: summary.grossProfit.currencyFormatRp,
|
||||
Text(
|
||||
summary.grossProfit.currencyFormatRp,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -21,6 +21,11 @@ class ProfitSharingAllocation extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final total = budget.total;
|
||||
final percentages = budget.percentages;
|
||||
// Fee owner berbeda tiap kategori induk, jadi porsi SDL dihitung dari
|
||||
// nominalnya; persentase bawaan hanya dipakai saat belum ada omzet.
|
||||
final sdlPercentage = total.hasRevenue
|
||||
? total.sdlPercentage
|
||||
: percentages.owner;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
@@ -52,7 +57,7 @@ class ProfitSharingAllocation extends StatelessWidget {
|
||||
|
||||
ProfitSharingBar(
|
||||
purchase: percentages.purchase,
|
||||
owner: percentages.owner,
|
||||
owner: sdlPercentage,
|
||||
team: percentages.team,
|
||||
),
|
||||
|
||||
@@ -69,9 +74,9 @@ class ProfitSharingAllocation extends StatelessWidget {
|
||||
_row(
|
||||
context: context,
|
||||
color: ProfitSharingColor.owner,
|
||||
label: context.lang.share_owner,
|
||||
percentage: percentages.owner,
|
||||
amount: total.limitOwner,
|
||||
label: context.lang.sdl,
|
||||
percentage: sdlPercentage,
|
||||
amount: total.sdl,
|
||||
),
|
||||
const Divider(height: 24, color: AppColor.borderLight),
|
||||
_row(
|
||||
@@ -140,7 +145,7 @@ class ProfitSharingAllocation extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Bar proporsi belanja / owner / tim.
|
||||
/// Bar proporsi belanja / SDL (owner) / tim.
|
||||
class ProfitSharingBar extends StatelessWidget {
|
||||
final double purchase;
|
||||
final double owner;
|
||||
|
||||
@@ -6,7 +6,7 @@ import '../../../../domain/analytic/analytic.dart';
|
||||
import '../../../components/spacer/spacer.dart';
|
||||
import 'profit_sharing_status.dart';
|
||||
|
||||
/// Ringkasan omzet & HPP per kategori induk (parent category).
|
||||
/// Ringkasan omzet & SDL per kategori induk (parent category).
|
||||
/// Tiap kartu bisa diketuk untuk melihat rincian sub kategori & produknya.
|
||||
class ProfitSharingCategories extends StatelessWidget {
|
||||
final List<ProfitSharingCategory> categories;
|
||||
@@ -69,18 +69,18 @@ class ProfitSharingCategories extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
else ...[
|
||||
...sorted.map(
|
||||
(category) => Padding(
|
||||
for (var i = 0; i < sorted.length; i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _CategoryCard(
|
||||
category: category,
|
||||
rank: i + 1,
|
||||
category: sorted[i],
|
||||
share: totalRevenue == 0
|
||||
? 0
|
||||
: category.totalRevenue / totalRevenue,
|
||||
onTap: () => onCategoryTap(category),
|
||||
: sorted[i].totalRevenue / totalRevenue,
|
||||
onTap: () => onCategoryTap(sorted[i]),
|
||||
),
|
||||
),
|
||||
),
|
||||
_TotalCard(categories: sorted),
|
||||
],
|
||||
],
|
||||
@@ -90,11 +90,13 @@ class ProfitSharingCategories extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _CategoryCard extends StatelessWidget {
|
||||
final int rank;
|
||||
final ProfitSharingCategory category;
|
||||
final double share;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _CategoryCard({
|
||||
required this.rank,
|
||||
required this.category,
|
||||
required this.share,
|
||||
required this.onTap,
|
||||
@@ -102,132 +104,216 @@ class _CategoryCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppColor.borderLight),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
category.parentCategoryName,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
final isTop = rank == 1;
|
||||
|
||||
return Material(
|
||||
color: AppColor.background,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColor.borderLight),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: isTop
|
||||
? AppColor.primary
|
||||
: AppColor.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SpaceWidth(8),
|
||||
ProfitSharingStatusBadge(
|
||||
realHppPercentage: category.realHppPercentage,
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
color: AppColor.textSecondary,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SpaceHeight(8),
|
||||
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
category.totalRevenue.currencyFormatRp,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w800,
|
||||
child: Text(
|
||||
'$rank',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: isTop ? AppColor.textWhite : AppColor.primary,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
formatPercent(share * 100),
|
||||
style: AppStyle.xs.copyWith(
|
||||
const SpaceWidth(10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
category.parentCategoryName,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'${category.categoryCount} ${context.lang.sub_category}'
|
||||
' · ${category.productCount} ${context.lang.products}'
|
||||
' · ${context.lang.qty} ${category.totalQuantity.thousandFormat}',
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SpaceWidth(8),
|
||||
ProfitSharingStatusBadge(
|
||||
realHppPercentage: category.realHppPercentage,
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w600,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SpaceHeight(8),
|
||||
const SpaceHeight(14),
|
||||
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: LinearProgressIndicator(
|
||||
value: share.clamp(0.0, 1.0),
|
||||
minHeight: 6,
|
||||
backgroundColor: AppColor.borderLight,
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||
AppColor.primary,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
category.totalRevenue.currencyFormatRp,
|
||||
style: AppStyle.xl.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SpaceWidth(8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
formatPercent(share * 100),
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SpaceHeight(8),
|
||||
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: LinearProgressIndicator(
|
||||
value: share.clamp(0.0, 1.0),
|
||||
minHeight: 6,
|
||||
backgroundColor: AppColor.border.withOpacity(0.6),
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||
AppColor.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SpaceHeight(12),
|
||||
const SpaceHeight(12),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.qty,
|
||||
value: category.totalQuantity.thousandFormat,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.products,
|
||||
value: '${category.productCount}',
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.sub_category,
|
||||
value: '${category.categoryCount}',
|
||||
),
|
||||
),
|
||||
ProfitSharingSdlStrip(
|
||||
amount: category.sdl,
|
||||
feePercent: category.ownerFeePercent,
|
||||
),
|
||||
|
||||
if (category.hasTopProduct) ...[
|
||||
const SpaceHeight(10),
|
||||
_TopProduct(product: category.topProduct),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10),
|
||||
child: Divider(height: 1, color: AppColor.border),
|
||||
),
|
||||
class _TopProduct extends StatelessWidget {
|
||||
final ProfitSharingTopProduct product;
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.std_hpp,
|
||||
value: formatPercent(category.standardHppPercentage),
|
||||
),
|
||||
const _TopProduct({required this.product});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.warning.withOpacity(0.12),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.emoji_events_rounded,
|
||||
color: AppColor.warning,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
const SpaceWidth(10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
context.lang.top_product,
|
||||
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
product.productName,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.real_hpp,
|
||||
value: formatPercent(category.realHppPercentage),
|
||||
valueColor: statusColor(category.realHppPercentage),
|
||||
),
|
||||
),
|
||||
],
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SpaceWidth(8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'${product.quantitySold.thousandFormat}x ${context.lang.sold.toLowerCase()}',
|
||||
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
product.revenue.currencyFormatRp,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -247,74 +333,44 @@ class _TotalCard extends StatelessWidget {
|
||||
0,
|
||||
(sum, e) => sum + e.totalRevenue,
|
||||
);
|
||||
final totalStandardHpp = categories.fold<int>(
|
||||
0,
|
||||
(sum, e) => sum + e.totalStandardHpp,
|
||||
);
|
||||
final totalFifoHpp = categories.fold<int>(
|
||||
0,
|
||||
(sum, e) => sum + e.totalFifoHpp,
|
||||
);
|
||||
|
||||
double percentOf(int hpp) =>
|
||||
totalRevenue == 0 ? 0 : (hpp / totalRevenue) * 100;
|
||||
final totalSdl = categories.fold<int>(0, (sum, e) => sum + e.sdl);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary.withOpacity(0.06),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
gradient: const LinearGradient(
|
||||
colors: AppColor.primaryGradient,
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.lang.grand_total,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
totalRevenue.currencyFormatRp,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
context.lang.grand_total,
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.textWhite.withOpacity(0.8),
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 1,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
totalRevenue.currencyFormatRp,
|
||||
style: AppStyle.xl.copyWith(
|
||||
color: AppColor.textWhite,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
|
||||
const SpaceHeight(12),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.qty,
|
||||
value: totalQuantity.thousandFormat,
|
||||
isBold: true,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.std_hpp,
|
||||
value: formatPercent(percentOf(totalStandardHpp)),
|
||||
isBold: true,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.real_hpp,
|
||||
value: formatPercent(percentOf(totalFifoHpp)),
|
||||
isBold: true,
|
||||
valueColor: statusColor(percentOf(totalFifoHpp)),
|
||||
),
|
||||
),
|
||||
ProfitSharingHeaderStats(
|
||||
stats: [
|
||||
(context.lang.qty, totalQuantity.thousandFormat),
|
||||
(context.lang.sdl, totalSdl.currencyFormatRp),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -130,22 +130,13 @@ class ProfitSharingDetailHeader extends StatelessWidget {
|
||||
const SpaceHeight(16),
|
||||
|
||||
if (state.isFetching)
|
||||
Row(
|
||||
children: [
|
||||
_shimmerBox(width: 120, height: 32, radius: 20),
|
||||
const SpaceWidth(8),
|
||||
_shimmerBox(width: 120, height: 32, radius: 20),
|
||||
],
|
||||
)
|
||||
_shimmerBox(width: double.infinity, height: 62, radius: 14)
|
||||
else
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
_chip(
|
||||
'${context.lang.qty} ${summary.totalQuantity.thousandFormat}',
|
||||
),
|
||||
_chip(context.lang.order_count_label(summary.orderCount)),
|
||||
ProfitSharingHeaderStats(
|
||||
stats: [
|
||||
(context.lang.qty, summary.totalQuantity.thousandFormat),
|
||||
(context.lang.orders, summary.orderCount.thousandFormat),
|
||||
(context.lang.sdl, summary.sdl.currencyFormatRp),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -155,25 +146,6 @@ class ProfitSharingDetailHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _chip(String label) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.textWhite.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: AppColor.textWhite.withOpacity(0.25)),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textWhite,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _shimmerBox({
|
||||
required double width,
|
||||
required double height,
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../../../application/analytic/profit_sharing_loader/profit_sharing_lo
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../components/spacer/spacer.dart';
|
||||
import 'profit_sharing_status.dart';
|
||||
|
||||
class ProfitSharingHeader extends StatelessWidget {
|
||||
final ProfitSharingLoaderState state;
|
||||
@@ -112,9 +113,15 @@ class ProfitSharingHeader extends StatelessWidget {
|
||||
const SpaceHeight(16),
|
||||
|
||||
state.isFetching
|
||||
? _shimmerBox(width: 140, height: 32, radius: 20)
|
||||
: _chip(
|
||||
context.lang.order_count_label(budget.total.orderCount),
|
||||
? _shimmerBox(width: double.infinity, height: 62, radius: 14)
|
||||
: ProfitSharingHeaderStats(
|
||||
stats: [
|
||||
(
|
||||
context.lang.orders,
|
||||
budget.total.orderCount.thousandFormat,
|
||||
),
|
||||
(context.lang.sdl, budget.total.sdl.currencyFormatRp),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -123,25 +130,6 @@ class ProfitSharingHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _chip(String label) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.textWhite.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: AppColor.textWhite.withOpacity(0.25)),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textWhite,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _shimmerBox({
|
||||
required double width,
|
||||
required double height,
|
||||
|
||||
@@ -200,7 +200,7 @@ class _PeriodCard extends StatelessWidget {
|
||||
|
||||
ProfitSharingBar(
|
||||
purchase: percentages.purchase,
|
||||
owner: percentages.owner,
|
||||
owner: period.hasRevenue ? period.sdlPercentage : percentages.owner,
|
||||
team: percentages.team,
|
||||
height: 6,
|
||||
),
|
||||
@@ -214,11 +214,7 @@ class _PeriodCard extends StatelessWidget {
|
||||
period.limitPurchase,
|
||||
ProfitSharingColor.purchase,
|
||||
),
|
||||
_share(
|
||||
context.lang.share_owner,
|
||||
period.limitOwner,
|
||||
ProfitSharingColor.owner,
|
||||
),
|
||||
_share(context.lang.sdl, period.sdl, ProfitSharingColor.owner),
|
||||
_share(
|
||||
context.lang.share_team,
|
||||
period.limitTeam,
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../components/spacer/spacer.dart';
|
||||
import 'profit_sharing_allocation.dart';
|
||||
|
||||
/// Ambang kesehatan berdasarkan % HPP riil terhadap omzet.
|
||||
/// Ubah di sini kalau target margin bisnis berubah.
|
||||
@@ -12,6 +14,10 @@ class HppThreshold {
|
||||
|
||||
String formatPercent(double value) => '${value.toStringAsFixed(1)}%';
|
||||
|
||||
/// Persen fee tanpa desimal kalau nilainya bulat (20% / 22.5%).
|
||||
String formatFeePercent(double value) =>
|
||||
'${value.toStringAsFixed(value % 1 == 0 ? 0 : 1)}%';
|
||||
|
||||
Color statusColor(double realHppPercentage) {
|
||||
if (realHppPercentage <= HppThreshold.healthy) return AppColor.success;
|
||||
if (realHppPercentage <= HppThreshold.watch) return AppColor.warning;
|
||||
@@ -63,6 +69,201 @@ class ProfitSharingStatusBadge extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Strip sorotan SDL: label + persen fee owner di kiri, nominal di kanan.
|
||||
class ProfitSharingSdlStrip extends StatelessWidget {
|
||||
final int amount;
|
||||
final double? feePercent;
|
||||
|
||||
const ProfitSharingSdlStrip({
|
||||
super.key,
|
||||
required this.amount,
|
||||
this.feePercent,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const color = ProfitSharingColor.owner;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: color.withOpacity(0.2)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.account_balance_wallet_rounded,
|
||||
color: color,
|
||||
size: 18,
|
||||
),
|
||||
const SpaceWidth(8),
|
||||
Text(
|
||||
context.lang.sdl,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
if (feePercent != null) ...[
|
||||
const SpaceWidth(6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
formatFeePercent(feePercent!),
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.textWhite,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const SpaceWidth(8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
amount.currencyFormatRp,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.secondaryDark,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Deretan angka ringkas di header (latar gelap), dipisah garis tipis.
|
||||
class ProfitSharingHeaderStats extends StatelessWidget {
|
||||
final List<(String label, String value)> stats;
|
||||
|
||||
const ProfitSharingHeaderStats({super.key, required this.stats});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.textWhite.withOpacity(0.14),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColor.textWhite.withOpacity(0.22)),
|
||||
),
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
children: [
|
||||
for (var i = 0; i < stats.length; i++) ...[
|
||||
if (i > 0)
|
||||
VerticalDivider(
|
||||
width: 1,
|
||||
thickness: 1,
|
||||
color: AppColor.textWhite.withOpacity(0.22),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
stats[i].$1,
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.textWhite.withOpacity(0.75),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
stats[i].$2,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textWhite,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Kotak statistik kecil: ikon, nilai, lalu label.
|
||||
class ProfitSharingStatTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final String value;
|
||||
final Color color;
|
||||
|
||||
const ProfitSharingStatTile({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.value,
|
||||
this.color = AppColor.primary,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppColor.borderLight),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, color: color, size: 16),
|
||||
),
|
||||
const SpaceHeight(10),
|
||||
Text(
|
||||
value,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Label kecil dua baris: judul di atas, nilai di bawah.
|
||||
class ProfitSharingMetric extends StatelessWidget {
|
||||
final String label;
|
||||
|
||||
@@ -178,13 +178,6 @@ class _SubCategoryCard extends StatelessWidget {
|
||||
value: '${category.productCount}',
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProfitSharingMetric(
|
||||
label: context.lang.real_hpp,
|
||||
value: formatPercent(category.realHppPercentage),
|
||||
valueColor: statusColor(category.realHppPercentage),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -237,8 +230,6 @@ class _ProductRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = statusColor(product.realHppPercentage);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Row(
|
||||
@@ -284,25 +275,12 @@ class _ProductRow extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SpaceWidth(8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
product.revenue.currencyFormatRp,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'${context.lang.real_hpp} ${formatPercent(product.realHppPercentage)}',
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
product.revenue.currencyFormatRp,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user