feat: inventory

This commit is contained in:
efrilm
2025-08-17 23:54:28 +07:00
parent 577adb7964
commit d22ffdd6d0
20 changed files with 5118 additions and 506 deletions
+1
View File
@@ -7,4 +7,5 @@ part 'analytic.freezed.dart';
part 'entities/sales_analytic_entity.dart';
part 'entities/profit_loss_analytic_entity.dart';
part 'entities/category_analytic_entity.dart';
part 'entities/inventory_analytic_entity.dart';
part 'failures/analytic_failure.dart';
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,119 @@
part of '../analytic.dart';
@freezed
class InventoryAnalytic with _$InventoryAnalytic {
const factory InventoryAnalytic({
required InventorySummary summary,
required List<InventoryProduct> products,
required List<InventoryIngredient> ingredients,
}) = _InventoryAnalytic;
factory InventoryAnalytic.empty() => InventoryAnalytic(
summary: InventorySummary.empty(),
products: [],
ingredients: [],
);
}
@freezed
class InventorySummary with _$InventorySummary {
const factory InventorySummary({
required int totalProducts,
required int totalIngredients,
required int totalValue,
required int lowStockProducts,
required int lowStockIngredients,
required int zeroStockProducts,
required int zeroStockIngredients,
required int totalSoldProducts,
required int totalSoldIngredients,
required String outletId,
required String outletName,
required String generatedAt,
}) = _InventorySummary;
factory InventorySummary.empty() => const InventorySummary(
totalProducts: 0,
totalIngredients: 0,
totalValue: 0,
lowStockProducts: 0,
lowStockIngredients: 0,
zeroStockProducts: 0,
zeroStockIngredients: 0,
totalSoldProducts: 0,
totalSoldIngredients: 0,
outletId: "",
outletName: "",
generatedAt: "",
);
}
@freezed
class InventoryProduct with _$InventoryProduct {
const factory InventoryProduct({
required String id,
required String productId,
required String productName,
required String categoryName,
required int quantity,
required int reorderLevel,
required int unitCost,
required int totalValue,
required int totalIn,
required int totalOut,
required bool isLowStock,
required bool isZeroStock,
required String updatedAt,
}) = _InventoryProduct;
factory InventoryProduct.empty() => const InventoryProduct(
id: "",
productId: "",
productName: "",
categoryName: "",
quantity: 0,
reorderLevel: 0,
unitCost: 0,
totalValue: 0,
totalIn: 0,
totalOut: 0,
isLowStock: false,
isZeroStock: false,
updatedAt: "",
);
}
@freezed
class InventoryIngredient with _$InventoryIngredient {
const factory InventoryIngredient({
required String id,
required String ingredientId,
required String ingredientName,
required String unitName,
required int quantity,
required int reorderLevel,
required int unitCost,
required int totalValue,
required int totalIn,
required int totalOut,
required bool isLowStock,
required bool isZeroStock,
required String updatedAt,
}) = _InventoryIngredient;
factory InventoryIngredient.empty() => const InventoryIngredient(
id: "",
ingredientId: "",
ingredientName: "",
unitName: "",
quantity: 0,
reorderLevel: 0,
unitCost: 0,
totalValue: 0,
totalIn: 0,
totalOut: 0,
isLowStock: false,
isZeroStock: false,
updatedAt: "",
);
}
@@ -17,4 +17,9 @@ abstract class IAnalyticRepository {
required DateTime dateFrom,
required DateTime dateTo,
});
Future<Either<AnalyticFailure, InventoryAnalytic>> getInventory({
required DateTime dateFrom,
required DateTime dateTo,
});
}