mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Feat[BE-261] : inisiate expense module
This commit is contained in:
@@ -48,14 +48,18 @@ func ToMarketingProductDTO(e entity.MarketingProduct) MarketingProductDTO {
|
||||
}
|
||||
}
|
||||
|
||||
func ToSalesOrdersListDTO(e entity.SalesOrders) SalesOrdersListDTO {
|
||||
func ToSalesOrdersListDTO(e entity.Marketing) SalesOrdersListDTO {
|
||||
products := make([]MarketingProductDTO, len(e.Products))
|
||||
for i, p := range e.Products {
|
||||
products[i] = ToMarketingProductDTO(p)
|
||||
}
|
||||
|
||||
return SalesOrdersListDTO{
|
||||
Id: e.Id,
|
||||
SoNumber: e.Name,
|
||||
SoDate: time.Time{},
|
||||
Notes: "",
|
||||
SalesOrder: []MarketingProductDTO{},
|
||||
SoNumber: e.SoNumber,
|
||||
SoDate: e.SoDate,
|
||||
Notes: e.Notes,
|
||||
SalesOrder: products,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,10 @@ import (
|
||||
type SalesOrdersModule struct{}
|
||||
|
||||
func (SalesOrdersModule) RegisterRoutes(router fiber.Router, db *gorm.DB, validate *validator.Validate) {
|
||||
salesOrdersRepo := rSalesOrders.NewSalesOrdersRepository(db)
|
||||
marketingRepo := rSalesOrders.NewMarketingRepository(db)
|
||||
userRepo := rUser.NewUserRepository(db)
|
||||
customerRepo := rCustomer.NewCustomerRepository(db)
|
||||
productWarehouseRepo := rProductWarehouse.NewProductWarehouseRepository(db)
|
||||
marketingRepo := rSalesOrders.NewMarketingRepository(db)
|
||||
|
||||
approvalSvc := commonSvc.NewApprovalService(commonRepo.NewApprovalRepository(db))
|
||||
|
||||
@@ -33,7 +32,7 @@ func (SalesOrdersModule) RegisterRoutes(router fiber.Router, db *gorm.DB, valida
|
||||
panic(fmt.Sprintf("failed to register marketing approval workflow: %v", err))
|
||||
}
|
||||
|
||||
salesOrdersService := sSalesOrders.NewSalesOrdersService(salesOrdersRepo, customerRepo, productWarehouseRepo, marketingRepo, userRepo, approvalSvc, validate)
|
||||
salesOrdersService := sSalesOrders.NewSalesOrdersService(marketingRepo, customerRepo, productWarehouseRepo, userRepo, approvalSvc, validate)
|
||||
userService := sUser.NewUserService(userRepo, validate)
|
||||
|
||||
SalesOrdersRoutes(router, userService, salesOrdersService)
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type SalesOrdersRepository interface {
|
||||
repository.BaseRepository[entity.SalesOrders]
|
||||
}
|
||||
|
||||
type SalesOrdersRepositoryImpl struct {
|
||||
*repository.BaseRepositoryImpl[entity.SalesOrders]
|
||||
}
|
||||
|
||||
func NewSalesOrdersRepository(db *gorm.DB) SalesOrdersRepository {
|
||||
return &SalesOrdersRepositoryImpl{
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.SalesOrders](db),
|
||||
}
|
||||
}
|
||||
@@ -34,22 +34,20 @@ type SalesOrdersService interface {
|
||||
type salesOrdersService struct {
|
||||
Log *logrus.Logger
|
||||
Validate *validator.Validate
|
||||
Repository repository.SalesOrdersRepository
|
||||
MarketingRepo repository.MarketingRepository
|
||||
CustomerRepo customerRepo.CustomerRepository
|
||||
ProductWarehouseRepo productWarehouseRepo.ProductWarehouseRepository
|
||||
MarketingRepo repository.MarketingRepository
|
||||
UserRepo userRepo.UserRepository
|
||||
ApprovalSvc commonSvc.ApprovalService
|
||||
}
|
||||
|
||||
func NewSalesOrdersService(repo repository.SalesOrdersRepository, customerRepo customerRepo.CustomerRepository, productWarehouseRepo productWarehouseRepo.ProductWarehouseRepository, marketingRepo repository.MarketingRepository, userRepo userRepo.UserRepository, approvalSvc commonSvc.ApprovalService, validate *validator.Validate) SalesOrdersService {
|
||||
func NewSalesOrdersService(marketingRepo repository.MarketingRepository, customerRepo customerRepo.CustomerRepository, productWarehouseRepo productWarehouseRepo.ProductWarehouseRepository, userRepo userRepo.UserRepository, approvalSvc commonSvc.ApprovalService, validate *validator.Validate) SalesOrdersService {
|
||||
return &salesOrdersService{
|
||||
Log: utils.Log,
|
||||
Validate: validate,
|
||||
Repository: repo,
|
||||
MarketingRepo: marketingRepo,
|
||||
CustomerRepo: customerRepo,
|
||||
ProductWarehouseRepo: productWarehouseRepo,
|
||||
MarketingRepo: marketingRepo,
|
||||
UserRepo: userRepo,
|
||||
ApprovalSvc: approvalSvc,
|
||||
}
|
||||
@@ -118,7 +116,7 @@ func (s *salesOrdersService) CreateOne(c *fiber.Ctx, req *validation.Create) (*e
|
||||
soNumber := fmt.Sprintf("SO-%05d", nextSeq)
|
||||
|
||||
var marketing *entity.Marketing
|
||||
err = s.Repository.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
||||
err = s.MarketingRepo.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
||||
|
||||
marketingRepoTx := repository.NewMarketingRepository(dbTransaction)
|
||||
marketingProductRepoTx := repository.NewMarketingProductRepository(dbTransaction)
|
||||
@@ -208,7 +206,7 @@ func (s salesOrdersService) UpdateOne(c *fiber.Ctx, req *validation.Update, id u
|
||||
}
|
||||
}
|
||||
|
||||
err = s.Repository.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
||||
err = s.MarketingRepo.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
||||
|
||||
marketingRepoTx := repository.NewMarketingRepository(dbTransaction)
|
||||
marketingProductRepoTx := repository.NewMarketingProductRepository(dbTransaction)
|
||||
@@ -366,7 +364,7 @@ func (s salesOrdersService) DeleteOne(c *fiber.Ctx, id uint) error {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, "Failed to fetch sales order")
|
||||
}
|
||||
|
||||
err = s.Repository.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
||||
err = s.MarketingRepo.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
||||
|
||||
marketingProductRepoTx := repository.NewMarketingProductRepository(dbTransaction)
|
||||
marketingDeliveryProductRepoTx := repository.NewMarketingDeliveryProductRepository(dbTransaction)
|
||||
|
||||
Reference in New Issue
Block a user