This commit is contained in:
Aditya Siregar
2025-09-13 15:37:26 +07:00
parent 4f6208e479
commit cfe690a40f
15 changed files with 1199 additions and 2 deletions
+12 -1
View File
@@ -94,6 +94,8 @@ func (a *App) Initialize(cfg *config.Config) error {
validators.accountValidator,
*services.orderIngredientTransactionService,
validators.orderIngredientTransactionValidator,
services.voucherService,
validators.voucherValidator,
)
return nil
@@ -167,6 +169,7 @@ type repositories struct {
chartOfAccountRepo *repository.ChartOfAccountRepositoryImpl
accountRepo *repository.AccountRepositoryImpl
orderIngredientTransactionRepo *repository.OrderIngredientTransactionRepositoryImpl
voucherRepo *repository.VoucherRepository
txManager *repository.TxManager
}
@@ -200,7 +203,8 @@ func (a *App) initRepositories() *repositories {
chartOfAccountRepo: repository.NewChartOfAccountRepositoryImpl(a.db),
accountRepo: repository.NewAccountRepositoryImpl(a.db),
orderIngredientTransactionRepo: repository.NewOrderIngredientTransactionRepositoryImpl(a.db).(*repository.OrderIngredientTransactionRepositoryImpl),
txManager: repository.NewTxManager(a.db),
voucherRepo: repository.NewVoucherRepository(a.db),
txManager: repository.NewTxManager(a.db),
}
}
@@ -229,6 +233,7 @@ type processors struct {
chartOfAccountProcessor *processor.ChartOfAccountProcessorImpl
accountProcessor *processor.AccountProcessorImpl
orderIngredientTransactionProcessor *processor.OrderIngredientTransactionProcessorImpl
voucherProcessor *processor.VoucherProcessor
fileClient processor.FileClient
inventoryMovementService service.InventoryMovementService
}
@@ -262,6 +267,7 @@ func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processor
chartOfAccountProcessor: processor.NewChartOfAccountProcessorImpl(repos.chartOfAccountRepo, repos.chartOfAccountTypeRepo),
accountProcessor: processor.NewAccountProcessorImpl(repos.accountRepo, repos.chartOfAccountRepo),
orderIngredientTransactionProcessor: processor.NewOrderIngredientTransactionProcessorImpl(repos.orderIngredientTransactionRepo, repos.productRecipeRepo, repos.ingredientRepo, repos.unitRepo).(*processor.OrderIngredientTransactionProcessorImpl),
voucherProcessor: processor.NewVoucherProcessor(repos.voucherRepo),
fileClient: fileClient,
inventoryMovementService: inventoryMovementService,
}
@@ -294,6 +300,7 @@ type services struct {
chartOfAccountService service.ChartOfAccountService
accountService service.AccountService
orderIngredientTransactionService *service.OrderIngredientTransactionService
voucherService service.VoucherService
}
func (a *App) initServices(processors *processors, repos *repositories, cfg *config.Config) *services {
@@ -324,6 +331,7 @@ func (a *App) initServices(processors *processors, repos *repositories, cfg *con
chartOfAccountService := service.NewChartOfAccountService(processors.chartOfAccountProcessor)
accountService := service.NewAccountService(processors.accountProcessor)
orderIngredientTransactionService := service.NewOrderIngredientTransactionService(processors.orderIngredientTransactionProcessor, repos.txManager)
voucherService := service.NewVoucherService(processors.voucherProcessor)
// Update order service with order ingredient transaction service
orderService = service.NewOrderServiceImpl(processors.orderProcessor, repos.tableRepo, orderIngredientTransactionService, processors.orderIngredientTransactionProcessor, *repos.productRecipeRepo, repos.txManager)
@@ -355,6 +363,7 @@ func (a *App) initServices(processors *processors, repos *repositories, cfg *con
chartOfAccountService: chartOfAccountService,
accountService: accountService,
orderIngredientTransactionService: orderIngredientTransactionService,
voucherService: voucherService,
}
}
@@ -388,6 +397,7 @@ type validators struct {
chartOfAccountValidator *validator.ChartOfAccountValidatorImpl
accountValidator *validator.AccountValidatorImpl
orderIngredientTransactionValidator *validator.OrderIngredientTransactionValidatorImpl
voucherValidator validator.VoucherValidator
}
func (a *App) initValidators() *validators {
@@ -411,5 +421,6 @@ func (a *App) initValidators() *validators {
chartOfAccountValidator: validator.NewChartOfAccountValidator().(*validator.ChartOfAccountValidatorImpl),
accountValidator: validator.NewAccountValidator().(*validator.AccountValidatorImpl),
orderIngredientTransactionValidator: validator.NewOrderIngredientTransactionValidator().(*validator.OrderIngredientTransactionValidatorImpl),
voucherValidator: validator.NewVoucherValidator(),
}
}