From b58e9a10b1c9372e2f49f9cff82b16e2b0c58c17 Mon Sep 17 00:00:00 2001 From: ragilap Date: Wed, 1 Apr 2026 16:25:04 +0700 Subject: [PATCH] fix filter purchase supplier repport --- internal/modules/repports/controllers/repport.controller.go | 1 + .../repports/repositories/purchase_supplier.repository.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/modules/repports/controllers/repport.controller.go b/internal/modules/repports/controllers/repport.controller.go index 5e33d2a0..5d85a53e 100644 --- a/internal/modules/repports/controllers/repport.controller.go +++ b/internal/modules/repports/controllers/repport.controller.go @@ -432,6 +432,7 @@ func (c *RepportController) GetProductionResult(ctx *fiber.Ctx) error { func parseCommaSeparatedInt64s(raw string) ([]int64, error) { return parseCommaSeparatedInt64sWithField(raw, "supplier_ids") } + func parseCommaSeparatedInt64sWithField(raw, field string) ([]int64, error) { raw = strings.TrimSpace(raw) if raw == "" { diff --git a/internal/modules/repports/repositories/purchase_supplier.repository.go b/internal/modules/repports/repositories/purchase_supplier.repository.go index d4860d3d..f484a6f1 100644 --- a/internal/modules/repports/repositories/purchase_supplier.repository.go +++ b/internal/modules/repports/repositories/purchase_supplier.repository.go @@ -71,7 +71,7 @@ func (r *purchaseSupplierRepositoryImpl) baseSupplierQuery(ctx context.Context, if len(filters.ProductCategoryIDs) > 0 { db = db. Joins("JOIN products ON products.id = purchase_items.product_id"). - Where("products.product_category_id IN ?", filters.ProductCategoryIDs) + Where("products.product_category_id IN ?", filters.ProductCategoryIDs) } if len(filters.AreaIDs) > 0 || filters.AllowedAreaIDs != nil { @@ -194,7 +194,7 @@ func (r *purchaseSupplierRepositoryImpl) GetItemsBySuppliers(ctx context.Context if len(filters.ProductCategoryIDs) > 0 { db = db. Joins("JOIN products ON products.id = purchase_items.product_id"). - Where("products.product_category_id IN ?", filters.ProductCategoryIDs) + Where("products.product_category_id IN ?", filters.ProductCategoryIDs) } if len(filters.AreaIDs) > 0 || filters.AllowedAreaIDs != nil { db = db.Joins("JOIN warehouses ON warehouses.id = purchase_items.warehouse_id")