Evo-ERP/app/web/views/inventory.py
2024-11-06 02:39:48 +08:00

29 lines
974 B
Python

from flask import Blueprint, render_template, jsonify
from ...services.inventory_alert_service import InventoryAlertService
bp = Blueprint('inventory', __name__, url_prefix='/inventory')
@bp.route('/alerts')
def alerts():
status = InventoryAlertService.get_stock_status()
summary = InventoryAlertService.get_alert_summary()
return render_template('inventory/alerts.html',
status=status,
summary=summary)
@bp.route('/api/alerts')
def api_alerts():
"""用於AJAX更新的API端點"""
status = InventoryAlertService.get_stock_status()
return jsonify([{
'id': item['product'].id,
'code': item['product'].code,
'name': item['product'].name,
'quantity': item['product'].quantity,
'min_quantity': item['product'].min_quantity,
'status': item['status'],
'margin': item['margin'],
'percentage': item['percentage']
} for item in status])