<?php
require_once __DIR__ . '/../app/bootstrap.php';
use App\Core\Auth; use App\Core\PosService; use App\Core\Response;
PosService::requireAccess('public/login.php');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') Response::json(['ok'=>false,'message'=>'POST required.'], 405);
if (!verify_csrf()) Response::json(['ok'=>false,'message'=>'Invalid security token.'], 419);
$payload = json_decode(file_get_contents('php://input'), true) ?: [];
if (!PosService::can('pos.sell')) Response::json(['ok'=>false,'message'=>'You do not have POS sale permission.'], 403);
$res = PosService::createSale($payload);
Response::json($res, $res['ok'] ? 200 : 422);
