Feat[BE]: refactored Chickin createone and implement approvals and add more needed constant

This commit is contained in:
aguhh18
2025-10-31 15:33:31 +07:00
parent c91d84b652
commit 219a6a39ed
17 changed files with 485 additions and 415 deletions
@@ -670,18 +670,19 @@ func (s *recordingService) getPreviousRecording(tx *gorm.DB, projectFlockKandang
}
func (s *recordingService) getTotalChick(tx *gorm.DB, projectFlockKandangId uint) (int64, error) {
var population entity.ProjectFlockPopulation
err := tx.
Where("project_flock_kandang_id = ?", projectFlockKandangId).
Order("created_at DESC").
First(&population).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return 0, nil
}
if err != nil {
return 0, err
}
return int64(math.Round(population.InitialQuantity)), nil
// var population entity.ProjectFlockPopulation
// err := tx.
// Where("project_flock_kandang_id = ?", projectFlockKandangId).
// Order("created_at DESC").
// First(&population).Error
// if errors.Is(err, gorm.ErrRecordNotFound) {
// return 0, nil
// }
// if err != nil {
// return 0, err
// }
//todo : nanti ganti lagi mas saya hardcode dulu
return int64(math.Round(1000)), nil
}
func (s *recordingService) getAverageBodyWeight(tx *gorm.DB, recordingID uint) (float64, error) {