mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 23:05:44 +00:00
fix filter purchase supplier repport
This commit is contained in:
@@ -60,24 +60,24 @@ func (r *purchaseSupplierRepositoryImpl) baseSupplierQuery(ctx context.Context,
|
||||
Where("(la.action IS NULL OR la.action != ?)", string(entity.ApprovalActionRejected)).
|
||||
Where("purchase_items.received_date IS NOT NULL")
|
||||
|
||||
if filters.SupplierId > 0 {
|
||||
db = db.Where("suppliers.id = ?", filters.SupplierId)
|
||||
if len(filters.SupplierIDs) > 0 {
|
||||
db = db.Where("suppliers.id IN ?", filters.SupplierIDs)
|
||||
}
|
||||
|
||||
if filters.ProductId > 0 {
|
||||
db = db.Where("purchase_items.product_id = ?", filters.ProductId)
|
||||
if len(filters.ProductIDs) > 0 {
|
||||
db = db.Where("purchase_items.product_id IN ?", filters.ProductIDs)
|
||||
}
|
||||
|
||||
if filters.ProductCategoryId > 0 {
|
||||
if len(filters.ProductCategoryIDs) > 0 {
|
||||
db = db.
|
||||
Joins("JOIN products ON products.id = purchase_items.product_id").
|
||||
Where("products.product_category_id = ?", filters.ProductCategoryId)
|
||||
Where("products.product_category_id IN ?", filters.ProductCategoryIDs)
|
||||
}
|
||||
|
||||
if filters.AreaId > 0 || filters.AllowedAreaIDs != nil {
|
||||
if len(filters.AreaIDs) > 0 || filters.AllowedAreaIDs != nil {
|
||||
db = db.Joins("JOIN warehouses ON warehouses.id = purchase_items.warehouse_id")
|
||||
if filters.AreaId > 0 {
|
||||
db = db.Where("warehouses.area_id = ?", filters.AreaId)
|
||||
if len(filters.AreaIDs) > 0 {
|
||||
db = db.Where("warehouses.area_id IN ?", filters.AreaIDs)
|
||||
}
|
||||
if filters.AllowedAreaIDs != nil {
|
||||
if len(filters.AllowedAreaIDs) == 0 {
|
||||
@@ -187,20 +187,20 @@ func (r *purchaseSupplierRepositoryImpl) GetItemsBySuppliers(ctx context.Context
|
||||
Where("(la.action IS NULL OR la.action != ?)", string(entity.ApprovalActionRejected)).
|
||||
Where("purchase_items.received_date IS NOT NULL")
|
||||
|
||||
if filters.ProductId > 0 {
|
||||
db = db.Where("purchase_items.product_id = ?", filters.ProductId)
|
||||
if len(filters.ProductIDs) > 0 {
|
||||
db = db.Where("purchase_items.product_id IN ?", filters.ProductIDs)
|
||||
}
|
||||
|
||||
if filters.ProductCategoryId > 0 {
|
||||
if len(filters.ProductCategoryIDs) > 0 {
|
||||
db = db.
|
||||
Joins("JOIN products ON products.id = purchase_items.product_id").
|
||||
Where("products.product_category_id = ?", filters.ProductCategoryId)
|
||||
Where("products.product_category_id IN ?", filters.ProductCategoryIDs)
|
||||
}
|
||||
|
||||
if filters.AreaId > 0 || filters.AllowedAreaIDs != nil {
|
||||
if len(filters.AreaIDs) > 0 || filters.AllowedAreaIDs != nil {
|
||||
db = db.Joins("JOIN warehouses ON warehouses.id = purchase_items.warehouse_id")
|
||||
if filters.AreaId > 0 {
|
||||
db = db.Where("warehouses.area_id = ?", filters.AreaId)
|
||||
if len(filters.AreaIDs) > 0 {
|
||||
db = db.Where("warehouses.area_id IN ?", filters.AreaIDs)
|
||||
}
|
||||
if filters.AllowedAreaIDs != nil {
|
||||
if len(filters.AllowedAreaIDs) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user