feat: add getmovementstock on backend
This commit is contained in:
@@ -114,3 +114,21 @@ func StockOut(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Уход оформлен"})
|
||||
}
|
||||
|
||||
func GetStockMovements(c *gin.Context) {
|
||||
itemID := c.Query("item_id")
|
||||
|
||||
var movements []models.StockMovement
|
||||
query := database.DB.Preload("Item").Order("created_at desc")
|
||||
|
||||
if itemID != "" {
|
||||
query = query.Where("item_id = ?", itemID)
|
||||
}
|
||||
|
||||
if err := query.Find(&movements).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Не удалось получить историю"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, movements)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user