package repports

import (
	"github.com/go-playground/validator/v10"
	"github.com/gofiber/fiber/v2"
	"gorm.io/gorm"

	commonRepo "gitlab.com/mbugroup/lti-api.git/internal/common/repository"
	approvalService "gitlab.com/mbugroup/lti-api.git/internal/common/service"
	repportRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/repports/repositories"
	sRepport "gitlab.com/mbugroup/lti-api.git/internal/modules/repports/services"

	expenseRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/expenses/repositories"
	marketingRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/marketing/repositories"
	customerRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/master/customers/repositories"
	productionStandardRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/master/production-standards/repositories"
	chickinRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/production/chickins/repositories"
	recordingRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/production/recordings/repositories"
	purchaseRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/purchases/repositories"

	rUser "gitlab.com/mbugroup/lti-api.git/internal/modules/users/repositories"
	sUser "gitlab.com/mbugroup/lti-api.git/internal/modules/users/services"
)

type RepportModule struct{}

func (RepportModule) RegisterRoutes(router fiber.Router, db *gorm.DB, validate *validator.Validate) {

	expenseRealizationRepository := expenseRepo.NewExpenseRealizationRepository(db)
	marketingDeliveryProductRepository := marketingRepo.NewMarketingDeliveryProductRepository(db)
	purchaseRepository := purchaseRepo.NewPurchaseRepository(db)
	chickinRepository := chickinRepo.NewChickinRepository(db)
	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)
	expenseDepreciationRepository := repportRepo.NewExpenseDepreciationRepository(db)
	productionResultRepository := repportRepo.NewProductionResultRepository(db)
	customerPaymentRepository := repportRepo.NewCustomerPaymentRepository(db)
	customerRepository := customerRepo.NewCustomerRepository(db)
	standardGrowthDetailRepository := productionStandardRepo.NewStandardGrowthDetailRepository(db)
	productionStandardDetailRepository := productionStandardRepo.NewProductionStandardDetailRepository(db)
	userRepository := rUser.NewUserRepository(db)

	approvalSvc := approvalService.NewApprovalService(approvalRepository)
	hppSvc := approvalService.NewHppService(hppCostRepository)
	hppV2Svc := approvalService.NewHppV2Service(hppV2CostRepository)
	repportService := sRepport.NewRepportService(
		db,
		validate,
		expenseRealizationRepository,
		expenseDepreciationRepository,
		marketingDeliveryProductRepository,
		purchaseRepository,
		chickinRepository,
		recordingRepository,
		approvalSvc,
		hppSvc,
		hppV2Svc,
		hppCostRepository,
		purchaseSupplierRepository,
		debtSupplierRepository,
		hppPerKandangRepository,
		productionResultRepository,
		customerPaymentRepository,
		customerRepository,
		standardGrowthDetailRepository,
		productionStandardDetailRepository,
	)
	userService := sUser.NewUserService(userRepository, validate)

	RepportRoutes(router, userService, repportService)
}
