31 lines
852 B
Go
31 lines
852 B
Go
package query
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type InventoryMovementFilter struct {
|
|
ClientID string `form:"client_id"`
|
|
SourceLocation string `form:"source_location"`
|
|
DestinationLocation string `form:"destination_location"`
|
|
PerPage int `form:"per_page"`
|
|
Page int `form:"page"`
|
|
Status string `form:"status"`
|
|
}
|
|
|
|
func ApplyInventoryMovementFilters(db *gorm.DB, filter InventoryMovementFilter) *gorm.DB {
|
|
if filter.ClientID != "" {
|
|
db = db.Where("client_id = ?", filter.ClientID)
|
|
}
|
|
if filter.SourceLocation != "" {
|
|
db = db.Where("source_location_id = ?", filter.SourceLocation)
|
|
}
|
|
if filter.DestinationLocation != "" {
|
|
db = db.Where("destination_location_id = ?", filter.DestinationLocation)
|
|
}
|
|
if filter.Status != "" {
|
|
db = db.Where("status = ?", filter.Status)
|
|
}
|
|
return db
|
|
}
|