diff --git a/internal/modules/repports/controllers/repport.controller.go b/internal/modules/repports/controllers/repport.controller.go index 3e6c39d0..039854c8 100644 --- a/internal/modules/repports/controllers/repport.controller.go +++ b/internal/modules/repports/controllers/repport.controller.go @@ -106,8 +106,8 @@ func (c *RepportController) GetPurchaseSupplier(ctx *fiber.Ctx) error { SupplierId: int64(ctx.QueryInt("supplier_id", 0)), ProductId: int64(ctx.QueryInt("product_id", 0)), ProductCategoryId: int64(ctx.QueryInt("product_category_id", 0)), - DateFrom: ctx.Query("date_from", ""), - DateTo: ctx.Query("date_to", ""), + StartDate: ctx.Query("start_date", ""), + EndDate: ctx.Query("end_date", ""), SortBy: ctx.Query("sort_by", ""), FilterBy: ctx.Query("filter_by", ""), } @@ -126,8 +126,8 @@ func (c *RepportController) GetPurchaseSupplier(ctx *fiber.Ctx) error { "supplier_id": query.SupplierId, "product_id": query.ProductId, "product_category_id": query.ProductCategoryId, - "date_from": query.DateFrom, - "date_to": query.DateTo, + "start_date": query.StartDate, + "end_date": query.EndDate, "sort_by": query.SortBy, "filter_by": query.FilterBy, } diff --git a/internal/modules/repports/repositories/purchase_supplier.repository.go b/internal/modules/repports/repositories/purchase_supplier.repository.go index cd282e8e..979623fc 100644 --- a/internal/modules/repports/repositories/purchase_supplier.repository.go +++ b/internal/modules/repports/repositories/purchase_supplier.repository.go @@ -26,7 +26,6 @@ func NewPurchaseSupplierRepository(db *gorm.DB) PurchaseSupplierRepository { } func (r *purchaseSupplierRepositoryImpl) baseSupplierQuery(ctx context.Context, filters *validation.PurchaseSupplierQuery) *gorm.DB { - // Tentukan kolom tanggal yang akan dipakai untuk filter dateColumn := "purchase_items.received_date" switch strings.ToLower(strings.TrimSpace(filters.FilterBy)) { case "po_date": @@ -60,14 +59,14 @@ func (r *purchaseSupplierRepositoryImpl) baseSupplierQuery(ctx context.Context, Where("warehouses.area_id = ?", filters.AreaId) } - if filters.DateFrom != "" { - if dateFrom, err := utils.ParseDateString(filters.DateFrom); err == nil { + if filters.StartDate != "" { + if dateFrom, err := utils.ParseDateString(filters.StartDate); err == nil { db = db.Where(fmt.Sprintf("DATE(%s) >= ?", dateColumn), dateFrom) } } - if filters.DateTo != "" { - if dateTo, err := utils.ParseDateString(filters.DateTo); err == nil { + if filters.EndDate != "" { + if dateTo, err := utils.ParseDateString(filters.EndDate); err == nil { db = db.Where(fmt.Sprintf("DATE(%s) <= ?", dateColumn), dateTo) } } @@ -171,14 +170,14 @@ func (r *purchaseSupplierRepositoryImpl) GetItemsBySuppliers(ctx context.Context Where("warehouses.area_id = ?", filters.AreaId) } - if filters.DateFrom != "" { - if dateFrom, err := utils.ParseDateString(filters.DateFrom); err == nil { + if filters.StartDate != "" { + if dateFrom, err := utils.ParseDateString(filters.StartDate); err == nil { db = db.Where(fmt.Sprintf("DATE(%s) >= ?", dateColumn), dateFrom) } } - if filters.DateTo != "" { - if dateTo, err := utils.ParseDateString(filters.DateTo); err == nil { + if filters.EndDate != "" { + if dateTo, err := utils.ParseDateString(filters.EndDate); err == nil { db = db.Where(fmt.Sprintf("DATE(%s) <= ?", dateColumn), dateTo) } } diff --git a/internal/modules/repports/validations/repport.validation.go b/internal/modules/repports/validations/repport.validation.go index 942eeaa8..53ba22d7 100644 --- a/internal/modules/repports/validations/repport.validation.go +++ b/internal/modules/repports/validations/repport.validation.go @@ -35,8 +35,8 @@ type PurchaseSupplierQuery struct { SupplierId int64 `query:"supplier_id" validate:"omitempty"` ProductId int64 `query:"product_id" validate:"omitempty"` ProductCategoryId int64 `query:"product_category_id" validate:"omitempty"` - DateFrom string `query:"date_from" validate:"omitempty"` - DateTo string `query:"date_to" validate:"omitempty"` + StartDate string `query:"start_date" validate:"omitempty"` + EndDate string `query:"end_date" validate:"omitempty"` SortBy string `query:"sort_by" validate:"omitempty"` FilterBy string `query:"filter_by" validate:"omitempty"` }