from flask import Blueprint, jsonify, request, session
from core.db import get_db
from services.stock_service import add_stock_movement

stock_bp = Blueprint('stock', __name__)


@stock_bp.route('/api/stok/hareket', methods=['POST'])
def stok_hareket():
    if not session.get('giris'):
        return jsonify({'ok': False}), 401
    d = request.json
    db = get_db()
    add_stock_movement(db, d)
    return jsonify({'ok': True})
