feat[BE]: create GetOverhead API, and fixing chickin use newest productwarehouse schema

This commit is contained in:
aguhh18
2025-12-09 15:32:11 +07:00
parent 89b23b0653
commit 511e5501bb
12 changed files with 309 additions and 21 deletions
@@ -1,6 +1,8 @@
package repository
import (
"context"
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
"gorm.io/gorm"
@@ -8,6 +10,7 @@ import (
type ProjectBudgetRepository interface {
repository.BaseRepository[entity.ProjectBudget]
GetByProjectFlockID(ctx context.Context, projectFlockID uint) ([]entity.ProjectBudget, error)
}
type ProjectBudgetRepositoryImpl struct {
@@ -21,3 +24,13 @@ func NewProjectBudgetRepository(db *gorm.DB) ProjectBudgetRepository {
db: db,
}
}
func (r *ProjectBudgetRepositoryImpl) GetByProjectFlockID(ctx context.Context, projectFlockID uint) ([]entity.ProjectBudget, error) {
var budgets []entity.ProjectBudget
err := r.db.WithContext(ctx).
Where("project_flock_id = ?", projectFlockID).
Preload("Nonstock").
Preload("Nonstock.Uom").
Find(&budgets).Error
return budgets, err
}