Merge branch 'FEAT/BE/Production_standard' into 'development'

FEAT[BE] :add production standard detail creation for growing only FCR

See merge request mbugroup/lti-api!302
This commit is contained in:
Hafizh A. Y.
2026-02-03 05:58:15 +00:00
@@ -152,6 +152,23 @@ func (s *productionStandardService) CreateOne(c *fiber.Ctx, req *validation.Crea
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil { if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err) return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
} }
} else if req.ProjectCategory == string(utils.ProjectFlockCategoryGrowing) {
if detailReq.ProductionStandardDetails != nil && detailReq.ProductionStandardDetails.StandardFCR != nil {
var zero float64 = 0
productionStandardDetail := &entity.ProductionStandardDetail{
ProductionStandardId: newStandard.Id,
Week: detailReq.Week,
TargetHenDayProduction: &zero,
TargetHenHouseProduction: &zero,
TargetEggWeight: &zero,
TargetEggMass: &zero,
StandardFCR: detailReq.ProductionStandardDetails.StandardFCR,
}
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
}
}
} }
standardGrowthDetail := &entity.StandardGrowthDetail{ standardGrowthDetail := &entity.StandardGrowthDetail{
@@ -265,6 +282,23 @@ func (s productionStandardService) UpdateOne(c *fiber.Ctx, req *validation.Updat
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil { if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err) return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
} }
} else if projectCategory == "GROWING" {
if detailReq.ProductionStandardDetails != nil && detailReq.ProductionStandardDetails.StandardFCR != nil {
var zero float64 = 0
productionStandardDetail := &entity.ProductionStandardDetail{
ProductionStandardId: id,
Week: detailReq.Week,
TargetHenDayProduction: &zero,
TargetHenHouseProduction: &zero,
TargetEggWeight: &zero,
TargetEggMass: &zero,
StandardFCR: detailReq.ProductionStandardDetails.StandardFCR,
}
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
}
}
} }
standardGrowthDetail := &entity.StandardGrowthDetail{ standardGrowthDetail := &entity.StandardGrowthDetail{