add common service hpp v2; adjust query marketing without stock allocation

This commit is contained in:
giovanni
2026-04-18 20:08:42 +07:00
parent fcde3b0a36
commit 187e497f97
4 changed files with 602 additions and 2 deletions
+3
View File
@@ -33,6 +33,7 @@ func (RepportModule) RegisterRoutes(router fiber.Router, db *gorm.DB, validate *
recordingRepository := recordingRepo.NewRecordingRepository(db)
approvalRepository := commonRepo.NewApprovalRepository(db)
hppCostRepository := commonRepo.NewHppCostRepository(db)
hppV2CostRepository := commonRepo.NewHppV2CostRepository(db)
purchaseSupplierRepository := repportRepo.NewPurchaseSupplierRepository(db)
debtSupplierRepository := repportRepo.NewDebtSupplierRepository(db)
hppPerKandangRepository := repportRepo.NewHppPerKandangRepository(db)
@@ -46,6 +47,7 @@ func (RepportModule) RegisterRoutes(router fiber.Router, db *gorm.DB, validate *
approvalSvc := approvalService.NewApprovalService(approvalRepository)
hppSvc := approvalService.NewHppService(hppCostRepository)
hppV2Svc := approvalService.NewHppV2Service(hppV2CostRepository)
repportService := sRepport.NewRepportService(
db,
validate,
@@ -57,6 +59,7 @@ func (RepportModule) RegisterRoutes(router fiber.Router, db *gorm.DB, validate *
recordingRepository,
approvalSvc,
hppSvc,
hppV2Svc,
hppCostRepository,
purchaseSupplierRepository,
debtSupplierRepository,
@@ -66,6 +66,7 @@ type repportService struct {
RecordingRepo recordingRepo.RecordingRepository
ApprovalSvc approvalService.ApprovalService
HppSvc approvalService.HppService
HppV2Svc approvalService.HppV2Service
HppCostRepo commonRepo.HppCostRepository
PurchaseSupplierRepo repportRepo.PurchaseSupplierRepository
DebtSupplierRepo repportRepo.DebtSupplierRepository
@@ -97,6 +98,7 @@ func NewRepportService(
recordingRepo recordingRepo.RecordingRepository,
approvalSvc approvalService.ApprovalService,
hppSvc approvalService.HppService,
hppV2Svc approvalService.HppV2Service,
hppCostRepo commonRepo.HppCostRepository,
purchaseSupplierRepo repportRepo.PurchaseSupplierRepository,
debtSupplierRepo repportRepo.DebtSupplierRepository,
@@ -119,6 +121,7 @@ func NewRepportService(
RecordingRepo: recordingRepo,
ApprovalSvc: approvalSvc,
HppSvc: hppSvc,
HppV2Svc: hppV2Svc,
HppCostRepo: hppCostRepo,
PurchaseSupplierRepo: purchaseSupplierRepo,
DebtSupplierRepo: debtSupplierRepo,
@@ -2289,8 +2292,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
var eggWeightFloat float64
var avgWeight float64
eggHpp := 0.0
if s.HppSvc != nil {
hppCost, err := s.HppSvc.CalculateHppCost(row.ProjectFlockKandangID, &periodDate)
if s.HppV2Svc != nil {
hppCost, err := s.HppV2Svc.CalculateHppCost(row.ProjectFlockKandangID, &periodDate)
if err != nil {
return nil, nil, err
}