Add Inventory Report
This commit is contained in:
@@ -23,7 +23,7 @@ type InventoryService interface {
|
||||
AdjustInventory(ctx context.Context, req *contract.AdjustInventoryRequest) *contract.Response
|
||||
GetLowStockItems(ctx context.Context, outletID uuid.UUID) *contract.Response
|
||||
GetZeroStockItems(ctx context.Context, outletID uuid.UUID) *contract.Response
|
||||
GetInventoryReportSummary(ctx context.Context, outletID, organizationID uuid.UUID) (*contract.InventoryReportSummaryResponse, error)
|
||||
GetInventoryReportSummary(ctx context.Context, outletID, organizationID uuid.UUID, dateFrom, dateTo *time.Time) (*contract.InventoryReportSummaryResponse, error)
|
||||
GetInventoryReportDetails(ctx context.Context, filter *models.InventoryReportFilter, organizationID uuid.UUID) (*contract.InventoryReportDetailResponse, error)
|
||||
}
|
||||
|
||||
@@ -188,8 +188,8 @@ func (s *InventoryServiceImpl) GetZeroStockItems(ctx context.Context, outletID u
|
||||
}
|
||||
|
||||
// GetInventoryReportSummary returns summary statistics for inventory report
|
||||
func (s *InventoryServiceImpl) GetInventoryReportSummary(ctx context.Context, outletID, organizationID uuid.UUID) (*contract.InventoryReportSummaryResponse, error) {
|
||||
summary, err := s.inventoryProcessor.GetInventoryReportSummary(ctx, outletID, organizationID)
|
||||
func (s *InventoryServiceImpl) GetInventoryReportSummary(ctx context.Context, outletID, organizationID uuid.UUID, dateFrom, dateTo *time.Time) (*contract.InventoryReportSummaryResponse, error) {
|
||||
summary, err := s.inventoryProcessor.GetInventoryReportSummary(ctx, outletID, organizationID, dateFrom, dateTo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -202,6 +202,8 @@ func (s *InventoryServiceImpl) GetInventoryReportSummary(ctx context.Context, ou
|
||||
LowStockIngredients: summary.LowStockIngredients,
|
||||
ZeroStockProducts: summary.ZeroStockProducts,
|
||||
ZeroStockIngredients: summary.ZeroStockIngredients,
|
||||
TotalSoldProducts: summary.TotalSoldProducts,
|
||||
TotalSoldIngredients: summary.TotalSoldIngredients,
|
||||
OutletID: summary.OutletID.String(),
|
||||
OutletName: summary.OutletName,
|
||||
GeneratedAt: summary.GeneratedAt.Format(time.RFC3339),
|
||||
@@ -217,7 +219,6 @@ func (s *InventoryServiceImpl) GetInventoryReportDetails(ctx context.Context, fi
|
||||
|
||||
response := &contract.InventoryReportDetailResponse{}
|
||||
|
||||
// Transform summary
|
||||
if report.Summary != nil {
|
||||
response.Summary = &contract.InventoryReportSummaryResponse{
|
||||
TotalProducts: report.Summary.TotalProducts,
|
||||
@@ -227,13 +228,14 @@ func (s *InventoryServiceImpl) GetInventoryReportDetails(ctx context.Context, fi
|
||||
LowStockIngredients: report.Summary.LowStockIngredients,
|
||||
ZeroStockProducts: report.Summary.ZeroStockProducts,
|
||||
ZeroStockIngredients: report.Summary.ZeroStockIngredients,
|
||||
TotalSoldProducts: report.Summary.TotalSoldProducts,
|
||||
TotalSoldIngredients: report.Summary.TotalSoldIngredients,
|
||||
OutletID: report.Summary.OutletID.String(),
|
||||
OutletName: report.Summary.OutletName,
|
||||
GeneratedAt: report.Summary.GeneratedAt.Format(time.RFC3339),
|
||||
}
|
||||
}
|
||||
|
||||
// Transform products
|
||||
response.Products = make([]*contract.InventoryProductDetailResponse, len(report.Products))
|
||||
for i, product := range report.Products {
|
||||
response.Products[i] = &contract.InventoryProductDetailResponse{
|
||||
@@ -245,6 +247,7 @@ func (s *InventoryServiceImpl) GetInventoryReportDetails(ctx context.Context, fi
|
||||
ReorderLevel: product.ReorderLevel,
|
||||
UnitCost: product.UnitCost,
|
||||
TotalValue: product.TotalValue,
|
||||
TotalSold: product.TotalSold,
|
||||
IsLowStock: product.IsLowStock,
|
||||
IsZeroStock: product.IsZeroStock,
|
||||
UpdatedAt: product.UpdatedAt.Format(time.RFC3339),
|
||||
@@ -263,6 +266,7 @@ func (s *InventoryServiceImpl) GetInventoryReportDetails(ctx context.Context, fi
|
||||
ReorderLevel: ingredient.ReorderLevel,
|
||||
UnitCost: ingredient.UnitCost,
|
||||
TotalValue: ingredient.TotalValue,
|
||||
TotalSold: ingredient.TotalSold,
|
||||
IsLowStock: ingredient.IsLowStock,
|
||||
IsZeroStock: ingredient.IsZeroStock,
|
||||
UpdatedAt: ingredient.UpdatedAt.Format(time.RFC3339),
|
||||
|
||||
Reference in New Issue
Block a user