feat[BE-127]: Createing transfer laying create one, approvals, get one, get all, update, delete, but Still unfinished

This commit is contained in:
aguhh18
2025-11-05 08:56:18 +07:00
parent 3a5c49c511
commit 1ee97b91a5
13 changed files with 928 additions and 74 deletions
@@ -13,6 +13,7 @@ type ProjectChickinRepository interface {
GetFirstByProjectFlockID(ctx context.Context, projectFlockID uint) (*entity.ProjectChickin, error)
GetByProjectFlockKandangID(ctx context.Context, projectFlockKandangID uint) ([]entity.ProjectChickin, error)
GetPendingByProjectFlockKandangID(ctx context.Context, projectFlockKandangID uint) ([]entity.ProjectChickin, error)
GetTotalPendingUsageQtyByProjectFlockKandangID(ctx context.Context, projectFlockKandangID uint) (float64, error)
}
type ChickinRepositoryImpl struct {
@@ -64,3 +65,17 @@ func (r *ChickinRepositoryImpl) GetPendingByProjectFlockKandangID(ctx context.Co
}
return chickins, nil
}
func (r *ChickinRepositoryImpl) GetTotalPendingUsageQtyByProjectFlockKandangID(ctx context.Context, projectFlockKandangID uint) (float64, error) {
var total float64
err := r.db.WithContext(ctx).
Model(&entity.ProjectChickin{}).
Where("project_flock_kandang_id = ?", projectFlockKandangID).
Where("pending_usage_qty > 0").
Select("COALESCE(SUM(pending_usage_qty), 0)").
Row().Scan(&total)
if err != nil {
return 0, err
}
return total, nil
}