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
@@ -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;
}