fix: first push implementation fifo v2 to all stockable and useable

This commit is contained in:
Hafizh A. Y
2026-02-27 15:21:55 +07:00
parent a2de21e351
commit e7e065c320
28 changed files with 1469 additions and 164 deletions
@@ -856,7 +856,7 @@ func (s closingService) GetClosingDataProduksi(c *fiber.Ctx, projectFlockID uint
// FeedUsedPerHead: feedUsedPerHead,
}
chickenFlagNames := []string{string(utils.FlagPullet), string(utils.FlagAyamAfkir), string(utils.FlagAyamCulling), string(utils.FlagLayer)}
chickenFlagNames := []string{string(utils.FlagAyam), string(utils.FlagPullet), string(utils.FlagAyamAfkir), string(utils.FlagAyamCulling), string(utils.FlagLayer)}
chickenSalesWeight, chickenSalesQty, chickenSalesPrice, err := s.Repository.SumMarketingWeightAndQtyByProjectFlockKandangIDsAndFlagNames(c.Context(), projectFlockKandangIDs, chickenFlagNames)
if err != nil {
s.Log.Errorf("Failed to fetch chicken sales data for project flock %d: %+v", projectFlockID, err)
@@ -885,7 +885,7 @@ func (s closingService) GetClosingDataProduksi(c *fiber.Ctx, projectFlockID uint
chickenDepletion = 0
}
chickenPerformance := calculatePerformanceMetrics(chickenAverageWeight, chickenSalesWeight, feedUsed, population, chickenDepletion, age)
chickenPerformance := calculatePerformanceMetrics(chickenAverageWeight, chickenSalesWeight, feedUsed, population, chickenDepletion, age)
if fcrActFromRecording != nil {
chickenPerformance.FcrAct = *fcrActFromRecording
}
@@ -432,8 +432,8 @@ func (s sapronakService) buildSapronakItems(ctx context.Context, pfk entity.Proj
return true
}
candidate := strings.ToUpper(f)
if filterFlag == "DOC" || filterFlag == "PULLET" {
return candidate == "DOC" || candidate == "PULLET"
if filterFlag == "AYAM" || filterFlag == "DOC" || filterFlag == "PULLET" {
return candidate == "AYAM" || candidate == "DOC" || candidate == "PULLET"
}
return candidate == filterFlag
}
@@ -474,7 +474,8 @@ func (s sapronakService) buildSapronakItems(ctx context.Context, pfk entity.Proj
if !isLaying {
filteredUsage := make([]repository.SapronakUsageRow, 0, len(chickinUsageRows))
for _, row := range chickinUsageRows {
if strings.ToUpper(row.Flag) == "DOC" {
flag := strings.ToUpper(row.Flag)
if flag == "AYAM" || flag == "DOC" {
filteredUsage = append(filteredUsage, row)
}
}
@@ -483,7 +484,8 @@ func (s sapronakService) buildSapronakItems(ctx context.Context, pfk entity.Proj
filteredDetail := make(map[uint][]repository.SapronakDetailRow, len(chickinUsageDetailsRows))
for pid, rows := range chickinUsageDetailsRows {
for _, d := range rows {
if strings.ToUpper(d.Flag) == "DOC" {
flag := strings.ToUpper(d.Flag)
if flag == "AYAM" || flag == "DOC" {
filteredDetail[pid] = append(filteredDetail[pid], d)
}
}