feat: add getmovementstock on backend

This commit is contained in:
2026-06-26 17:11:03 +03:00
parent 7b662bb618
commit 8000d241b4
2 changed files with 19 additions and 0 deletions
+18
View File
@@ -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)
}