mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-22 06:15:44 +00:00
[FIX/BE-US] adjustment sso-location
This commit is contained in:
@@ -303,20 +303,12 @@ func (s *adjustmentService) AdjustmentHistory(c *fiber.Ctx, query *validation.Qu
|
||||
return nil, 0, fiber.NewError(fiber.StatusNotFound, "Product not found")
|
||||
}
|
||||
|
||||
var scopeErr error
|
||||
stockLogs, total, err := s.StockLogsRepository.GetAll(c.Context(), offset, query.Limit, func(db *gorm.DB) *gorm.DB {
|
||||
scope, err := m.ResolveLocationScope(c, s.StockLogsRepository.DB())
|
||||
if err != nil {
|
||||
return db.Where("1 = 0")
|
||||
}
|
||||
if scope.Restrict {
|
||||
if len(scope.IDs) == 0 {
|
||||
return db.Where("1 = 0")
|
||||
}
|
||||
db = db.
|
||||
Joins("JOIN product_warehouses pw ON pw.id = stock_logs.product_warehouse_id").
|
||||
Joins("JOIN warehouses w ON w.id = pw.warehouse_id")
|
||||
db = m.ApplyScopeFilter(db, scope, "w.location_id")
|
||||
}
|
||||
db = db.
|
||||
Joins("JOIN product_warehouses pw ON pw.id = stock_logs.product_warehouse_id").
|
||||
Joins("JOIN warehouses w ON w.id = pw.warehouse_id")
|
||||
db, scopeErr = m.ApplyLocationScope(c, db, "w.location_id")
|
||||
db = s.withRelations(db)
|
||||
|
||||
db = db.Where("loggable_type = ?", string(utils.StockLogTypeAdjustment))
|
||||
@@ -329,6 +321,9 @@ func (s *adjustmentService) AdjustmentHistory(c *fiber.Ctx, query *validation.Qu
|
||||
return db.Order("created_at DESC")
|
||||
})
|
||||
|
||||
if scopeErr != nil {
|
||||
return nil, 0, scopeErr
|
||||
}
|
||||
if err != nil {
|
||||
s.Log.Errorf("Failed to get adjustments: %+v", err)
|
||||
return nil, 0, fiber.NewError(fiber.StatusInternalServerError, "Failed to get adjustment history")
|
||||
|
||||
Reference in New Issue
Block a user