feat: update parent category analytic
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s

This commit is contained in:
efrilm
2026-10-03 00:38:32 +07:00
parent 36bc9e0f9e
commit 288d0d75a0
21 changed files with 1366 additions and 344 deletions
+325 -21
View File
@@ -12394,6 +12394,9 @@ mixin _$ProfitSharingCategory {
int get totalStandardHpp => throw _privateConstructorUsedError;
int get totalFifoHpp => throw _privateConstructorUsedError;
int get totalMovingAverageHpp => throw _privateConstructorUsedError;
double get ownerFeePercent => throw _privateConstructorUsedError;
int get sdl => throw _privateConstructorUsedError;
ProfitSharingTopProduct get topProduct => throw _privateConstructorUsedError;
/// Create a copy of ProfitSharingCategory
/// with the given fields replaced by the non-null parameter values.
@@ -12420,7 +12423,12 @@ abstract class $ProfitSharingCategoryCopyWith<$Res> {
int totalStandardHpp,
int totalFifoHpp,
int totalMovingAverageHpp,
double ownerFeePercent,
int sdl,
ProfitSharingTopProduct topProduct,
});
$ProfitSharingTopProductCopyWith<$Res> get topProduct;
}
/// @nodoc
@@ -12451,6 +12459,9 @@ class _$ProfitSharingCategoryCopyWithImpl<
Object? totalStandardHpp = null,
Object? totalFifoHpp = null,
Object? totalMovingAverageHpp = null,
Object? ownerFeePercent = null,
Object? sdl = null,
Object? topProduct = null,
}) {
return _then(
_value.copyWith(
@@ -12494,10 +12505,32 @@ class _$ProfitSharingCategoryCopyWithImpl<
? _value.totalMovingAverageHpp
: totalMovingAverageHpp // ignore: cast_nullable_to_non_nullable
as int,
ownerFeePercent: null == ownerFeePercent
? _value.ownerFeePercent
: ownerFeePercent // ignore: cast_nullable_to_non_nullable
as double,
sdl: null == sdl
? _value.sdl
: sdl // ignore: cast_nullable_to_non_nullable
as int,
topProduct: null == topProduct
? _value.topProduct
: topProduct // ignore: cast_nullable_to_non_nullable
as ProfitSharingTopProduct,
)
as $Val,
);
}
/// Create a copy of ProfitSharingCategory
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProfitSharingTopProductCopyWith<$Res> get topProduct {
return $ProfitSharingTopProductCopyWith<$Res>(_value.topProduct, (value) {
return _then(_value.copyWith(topProduct: value) as $Val);
});
}
}
/// @nodoc
@@ -12520,7 +12553,13 @@ abstract class _$$ProfitSharingCategoryImplCopyWith<$Res>
int totalStandardHpp,
int totalFifoHpp,
int totalMovingAverageHpp,
double ownerFeePercent,
int sdl,
ProfitSharingTopProduct topProduct,
});
@override
$ProfitSharingTopProductCopyWith<$Res> get topProduct;
}
/// @nodoc
@@ -12548,6 +12587,9 @@ class __$$ProfitSharingCategoryImplCopyWithImpl<$Res>
Object? totalStandardHpp = null,
Object? totalFifoHpp = null,
Object? totalMovingAverageHpp = null,
Object? ownerFeePercent = null,
Object? sdl = null,
Object? topProduct = null,
}) {
return _then(
_$ProfitSharingCategoryImpl(
@@ -12591,6 +12633,18 @@ class __$$ProfitSharingCategoryImplCopyWithImpl<$Res>
? _value.totalMovingAverageHpp
: totalMovingAverageHpp // ignore: cast_nullable_to_non_nullable
as int,
ownerFeePercent: null == ownerFeePercent
? _value.ownerFeePercent
: ownerFeePercent // ignore: cast_nullable_to_non_nullable
as double,
sdl: null == sdl
? _value.sdl
: sdl // ignore: cast_nullable_to_non_nullable
as int,
topProduct: null == topProduct
? _value.topProduct
: topProduct // ignore: cast_nullable_to_non_nullable
as ProfitSharingTopProduct,
),
);
}
@@ -12610,6 +12664,9 @@ class _$ProfitSharingCategoryImpl extends _ProfitSharingCategory {
required this.totalStandardHpp,
required this.totalFifoHpp,
required this.totalMovingAverageHpp,
this.ownerFeePercent = 0,
this.sdl = 0,
this.topProduct = const ProfitSharingTopProduct(),
}) : super._();
@override
@@ -12632,10 +12689,19 @@ class _$ProfitSharingCategoryImpl extends _ProfitSharingCategory {
final int totalFifoHpp;
@override
final int totalMovingAverageHpp;
@override
@JsonKey()
final double ownerFeePercent;
@override
@JsonKey()
final int sdl;
@override
@JsonKey()
final ProfitSharingTopProduct topProduct;
@override
String toString() {
return 'ProfitSharingCategory(parentCategoryId: $parentCategoryId, parentCategoryName: $parentCategoryName, totalRevenue: $totalRevenue, totalQuantity: $totalQuantity, categoryCount: $categoryCount, productCount: $productCount, orderCount: $orderCount, totalStandardHpp: $totalStandardHpp, totalFifoHpp: $totalFifoHpp, totalMovingAverageHpp: $totalMovingAverageHpp)';
return 'ProfitSharingCategory(parentCategoryId: $parentCategoryId, parentCategoryName: $parentCategoryName, totalRevenue: $totalRevenue, totalQuantity: $totalQuantity, categoryCount: $categoryCount, productCount: $productCount, orderCount: $orderCount, totalStandardHpp: $totalStandardHpp, totalFifoHpp: $totalFifoHpp, totalMovingAverageHpp: $totalMovingAverageHpp, ownerFeePercent: $ownerFeePercent, sdl: $sdl, topProduct: $topProduct)';
}
@override
@@ -12662,7 +12728,12 @@ class _$ProfitSharingCategoryImpl extends _ProfitSharingCategory {
(identical(other.totalFifoHpp, totalFifoHpp) ||
other.totalFifoHpp == totalFifoHpp) &&
(identical(other.totalMovingAverageHpp, totalMovingAverageHpp) ||
other.totalMovingAverageHpp == totalMovingAverageHpp));
other.totalMovingAverageHpp == totalMovingAverageHpp) &&
(identical(other.ownerFeePercent, ownerFeePercent) ||
other.ownerFeePercent == ownerFeePercent) &&
(identical(other.sdl, sdl) || other.sdl == sdl) &&
(identical(other.topProduct, topProduct) ||
other.topProduct == topProduct));
}
@override
@@ -12678,6 +12749,9 @@ class _$ProfitSharingCategoryImpl extends _ProfitSharingCategory {
totalStandardHpp,
totalFifoHpp,
totalMovingAverageHpp,
ownerFeePercent,
sdl,
topProduct,
);
/// Create a copy of ProfitSharingCategory
@@ -12705,6 +12779,9 @@ abstract class _ProfitSharingCategory extends ProfitSharingCategory {
required final int totalStandardHpp,
required final int totalFifoHpp,
required final int totalMovingAverageHpp,
final double ownerFeePercent,
final int sdl,
final ProfitSharingTopProduct topProduct,
}) = _$ProfitSharingCategoryImpl;
const _ProfitSharingCategory._() : super._();
@@ -12728,6 +12805,12 @@ abstract class _ProfitSharingCategory extends ProfitSharingCategory {
int get totalFifoHpp;
@override
int get totalMovingAverageHpp;
@override
double get ownerFeePercent;
@override
int get sdl;
@override
ProfitSharingTopProduct get topProduct;
/// Create a copy of ProfitSharingCategory
/// with the given fields replaced by the non-null parameter values.
@@ -12737,6 +12820,228 @@ abstract class _ProfitSharingCategory extends ProfitSharingCategory {
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$ProfitSharingTopProduct {
String get productId => throw _privateConstructorUsedError;
String get productName => throw _privateConstructorUsedError;
int get quantitySold => throw _privateConstructorUsedError;
int get revenue => throw _privateConstructorUsedError;
/// Create a copy of ProfitSharingTopProduct
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ProfitSharingTopProductCopyWith<ProfitSharingTopProduct> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProfitSharingTopProductCopyWith<$Res> {
factory $ProfitSharingTopProductCopyWith(
ProfitSharingTopProduct value,
$Res Function(ProfitSharingTopProduct) then,
) = _$ProfitSharingTopProductCopyWithImpl<$Res, ProfitSharingTopProduct>;
@useResult
$Res call({
String productId,
String productName,
int quantitySold,
int revenue,
});
}
/// @nodoc
class _$ProfitSharingTopProductCopyWithImpl<
$Res,
$Val extends ProfitSharingTopProduct
>
implements $ProfitSharingTopProductCopyWith<$Res> {
_$ProfitSharingTopProductCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProfitSharingTopProduct
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? productId = null,
Object? productName = null,
Object? quantitySold = null,
Object? revenue = null,
}) {
return _then(
_value.copyWith(
productId: null == productId
? _value.productId
: productId // ignore: cast_nullable_to_non_nullable
as String,
productName: null == productName
? _value.productName
: productName // ignore: cast_nullable_to_non_nullable
as String,
quantitySold: null == quantitySold
? _value.quantitySold
: quantitySold // ignore: cast_nullable_to_non_nullable
as int,
revenue: null == revenue
? _value.revenue
: revenue // ignore: cast_nullable_to_non_nullable
as int,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$ProfitSharingTopProductImplCopyWith<$Res>
implements $ProfitSharingTopProductCopyWith<$Res> {
factory _$$ProfitSharingTopProductImplCopyWith(
_$ProfitSharingTopProductImpl value,
$Res Function(_$ProfitSharingTopProductImpl) then,
) = __$$ProfitSharingTopProductImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String productId,
String productName,
int quantitySold,
int revenue,
});
}
/// @nodoc
class __$$ProfitSharingTopProductImplCopyWithImpl<$Res>
extends
_$ProfitSharingTopProductCopyWithImpl<
$Res,
_$ProfitSharingTopProductImpl
>
implements _$$ProfitSharingTopProductImplCopyWith<$Res> {
__$$ProfitSharingTopProductImplCopyWithImpl(
_$ProfitSharingTopProductImpl _value,
$Res Function(_$ProfitSharingTopProductImpl) _then,
) : super(_value, _then);
/// Create a copy of ProfitSharingTopProduct
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? productId = null,
Object? productName = null,
Object? quantitySold = null,
Object? revenue = null,
}) {
return _then(
_$ProfitSharingTopProductImpl(
productId: null == productId
? _value.productId
: productId // ignore: cast_nullable_to_non_nullable
as String,
productName: null == productName
? _value.productName
: productName // ignore: cast_nullable_to_non_nullable
as String,
quantitySold: null == quantitySold
? _value.quantitySold
: quantitySold // ignore: cast_nullable_to_non_nullable
as int,
revenue: null == revenue
? _value.revenue
: revenue // ignore: cast_nullable_to_non_nullable
as int,
),
);
}
}
/// @nodoc
class _$ProfitSharingTopProductImpl implements _ProfitSharingTopProduct {
const _$ProfitSharingTopProductImpl({
this.productId = '',
this.productName = '',
this.quantitySold = 0,
this.revenue = 0,
});
@override
@JsonKey()
final String productId;
@override
@JsonKey()
final String productName;
@override
@JsonKey()
final int quantitySold;
@override
@JsonKey()
final int revenue;
@override
String toString() {
return 'ProfitSharingTopProduct(productId: $productId, productName: $productName, quantitySold: $quantitySold, revenue: $revenue)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProfitSharingTopProductImpl &&
(identical(other.productId, productId) ||
other.productId == productId) &&
(identical(other.productName, productName) ||
other.productName == productName) &&
(identical(other.quantitySold, quantitySold) ||
other.quantitySold == quantitySold) &&
(identical(other.revenue, revenue) || other.revenue == revenue));
}
@override
int get hashCode =>
Object.hash(runtimeType, productId, productName, quantitySold, revenue);
/// Create a copy of ProfitSharingTopProduct
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProfitSharingTopProductImplCopyWith<_$ProfitSharingTopProductImpl>
get copyWith =>
__$$ProfitSharingTopProductImplCopyWithImpl<
_$ProfitSharingTopProductImpl
>(this, _$identity);
}
abstract class _ProfitSharingTopProduct implements ProfitSharingTopProduct {
const factory _ProfitSharingTopProduct({
final String productId,
final String productName,
final int quantitySold,
final int revenue,
}) = _$ProfitSharingTopProductImpl;
@override
String get productId;
@override
String get productName;
@override
int get quantitySold;
@override
int get revenue;
/// Create a copy of ProfitSharingTopProduct
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProfitSharingTopProductImplCopyWith<_$ProfitSharingTopProductImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$ProfitSharingBudget {
ProfitSharingPercentage get percentages => throw _privateConstructorUsedError;
@@ -13229,7 +13534,7 @@ mixin _$ProfitSharingPeriod {
int get revenue => throw _privateConstructorUsedError;
int get orderCount => throw _privateConstructorUsedError;
int get limitPurchase => throw _privateConstructorUsedError;
int get limitOwner => throw _privateConstructorUsedError;
int get sdl => throw _privateConstructorUsedError;
int get limitTeam => throw _privateConstructorUsedError;
String get month => throw _privateConstructorUsedError;
int get weekCount => throw _privateConstructorUsedError;
@@ -13254,7 +13559,7 @@ abstract class $ProfitSharingPeriodCopyWith<$Res> {
int revenue,
int orderCount,
int limitPurchase,
int limitOwner,
int sdl,
int limitTeam,
String month,
int weekCount,
@@ -13281,7 +13586,7 @@ class _$ProfitSharingPeriodCopyWithImpl<$Res, $Val extends ProfitSharingPeriod>
Object? revenue = null,
Object? orderCount = null,
Object? limitPurchase = null,
Object? limitOwner = null,
Object? sdl = null,
Object? limitTeam = null,
Object? month = null,
Object? weekCount = null,
@@ -13308,9 +13613,9 @@ class _$ProfitSharingPeriodCopyWithImpl<$Res, $Val extends ProfitSharingPeriod>
? _value.limitPurchase
: limitPurchase // ignore: cast_nullable_to_non_nullable
as int,
limitOwner: null == limitOwner
? _value.limitOwner
: limitOwner // ignore: cast_nullable_to_non_nullable
sdl: null == sdl
? _value.sdl
: sdl // ignore: cast_nullable_to_non_nullable
as int,
limitTeam: null == limitTeam
? _value.limitTeam
@@ -13345,7 +13650,7 @@ abstract class _$$ProfitSharingPeriodImplCopyWith<$Res>
int revenue,
int orderCount,
int limitPurchase,
int limitOwner,
int sdl,
int limitTeam,
String month,
int weekCount,
@@ -13371,7 +13676,7 @@ class __$$ProfitSharingPeriodImplCopyWithImpl<$Res>
Object? revenue = null,
Object? orderCount = null,
Object? limitPurchase = null,
Object? limitOwner = null,
Object? sdl = null,
Object? limitTeam = null,
Object? month = null,
Object? weekCount = null,
@@ -13398,9 +13703,9 @@ class __$$ProfitSharingPeriodImplCopyWithImpl<$Res>
? _value.limitPurchase
: limitPurchase // ignore: cast_nullable_to_non_nullable
as int,
limitOwner: null == limitOwner
? _value.limitOwner
: limitOwner // ignore: cast_nullable_to_non_nullable
sdl: null == sdl
? _value.sdl
: sdl // ignore: cast_nullable_to_non_nullable
as int,
limitTeam: null == limitTeam
? _value.limitTeam
@@ -13428,7 +13733,7 @@ class _$ProfitSharingPeriodImpl extends _ProfitSharingPeriod {
required this.revenue,
required this.orderCount,
required this.limitPurchase,
required this.limitOwner,
required this.sdl,
required this.limitTeam,
this.month = '',
this.weekCount = 0,
@@ -13445,7 +13750,7 @@ class _$ProfitSharingPeriodImpl extends _ProfitSharingPeriod {
@override
final int limitPurchase;
@override
final int limitOwner;
final int sdl;
@override
final int limitTeam;
@override
@@ -13457,7 +13762,7 @@ class _$ProfitSharingPeriodImpl extends _ProfitSharingPeriod {
@override
String toString() {
return 'ProfitSharingPeriod(periodStart: $periodStart, periodEnd: $periodEnd, revenue: $revenue, orderCount: $orderCount, limitPurchase: $limitPurchase, limitOwner: $limitOwner, limitTeam: $limitTeam, month: $month, weekCount: $weekCount)';
return 'ProfitSharingPeriod(periodStart: $periodStart, periodEnd: $periodEnd, revenue: $revenue, orderCount: $orderCount, limitPurchase: $limitPurchase, sdl: $sdl, limitTeam: $limitTeam, month: $month, weekCount: $weekCount)';
}
@override
@@ -13474,8 +13779,7 @@ class _$ProfitSharingPeriodImpl extends _ProfitSharingPeriod {
other.orderCount == orderCount) &&
(identical(other.limitPurchase, limitPurchase) ||
other.limitPurchase == limitPurchase) &&
(identical(other.limitOwner, limitOwner) ||
other.limitOwner == limitOwner) &&
(identical(other.sdl, sdl) || other.sdl == sdl) &&
(identical(other.limitTeam, limitTeam) ||
other.limitTeam == limitTeam) &&
(identical(other.month, month) || other.month == month) &&
@@ -13491,7 +13795,7 @@ class _$ProfitSharingPeriodImpl extends _ProfitSharingPeriod {
revenue,
orderCount,
limitPurchase,
limitOwner,
sdl,
limitTeam,
month,
weekCount,
@@ -13516,7 +13820,7 @@ abstract class _ProfitSharingPeriod extends ProfitSharingPeriod {
required final int revenue,
required final int orderCount,
required final int limitPurchase,
required final int limitOwner,
required final int sdl,
required final int limitTeam,
final String month,
final int weekCount,
@@ -13534,7 +13838,7 @@ abstract class _ProfitSharingPeriod extends ProfitSharingPeriod {
@override
int get limitPurchase;
@override
int get limitOwner;
int get sdl;
@override
int get limitTeam;
@override
@@ -39,6 +39,9 @@ class ProfitSharingCategory with _$ProfitSharingCategory {
required int totalStandardHpp,
required int totalFifoHpp,
required int totalMovingAverageHpp,
@Default(0) double ownerFeePercent,
@Default(0) int sdl,
@Default(ProfitSharingTopProduct()) ProfitSharingTopProduct topProduct,
}) = _ProfitSharingCategory;
factory ProfitSharingCategory.empty() => const ProfitSharingCategory(
@@ -54,6 +57,8 @@ class ProfitSharingCategory with _$ProfitSharingCategory {
totalMovingAverageHpp: 0,
);
bool get hasTopProduct => topProduct.productId.isNotEmpty;
/// Laba kotor memakai HPP standar (acuan yang dipakai di laporan laba rugi).
int get grossProfit => totalRevenue - totalStandardHpp;
@@ -69,6 +74,17 @@ class ProfitSharingCategory with _$ProfitSharingCategory {
totalRevenue == 0 ? 0 : (totalFifoHpp / totalRevenue) * 100;
}
/// Produk dengan omzet tertinggi di satu kategori induk.
@freezed
class ProfitSharingTopProduct with _$ProfitSharingTopProduct {
const factory ProfitSharingTopProduct({
@Default('') String productId,
@Default('') String productName,
@Default(0) int quantitySold,
@Default(0) int revenue,
}) = _ProfitSharingTopProduct;
}
@freezed
class ProfitSharingBudget with _$ProfitSharingBudget {
const factory ProfitSharingBudget({
@@ -114,7 +130,7 @@ class ProfitSharingPeriod with _$ProfitSharingPeriod {
required int revenue,
required int orderCount,
required int limitPurchase,
required int limitOwner,
required int sdl,
required int limitTeam,
@Default('') String month,
@Default(0) int weekCount,
@@ -126,12 +142,16 @@ class ProfitSharingPeriod with _$ProfitSharingPeriod {
revenue: 0,
orderCount: 0,
limitPurchase: 0,
limitOwner: 0,
sdl: 0,
limitTeam: 0,
);
bool get hasRevenue => revenue > 0;
/// % SDL (bagian owner) terhadap omzet. Fee owner berbeda tiap kategori
/// induk, jadi porsinya dihitung dari nominal, bukan dari persentase tetap.
double get sdlPercentage => revenue == 0 ? 0 : (sdl / revenue) * 100;
int get averageOrderValue => orderCount == 0 ? 0 : revenue ~/ orderCount;
}