<?php
/**
 * v5 — برچسب‌گذاری حسابداری فروش فروشگاه در DB
 * php run-arag-upgrade-v5.php
 */
declare(strict_types=1);

define('ACC_BASE_PATH', __DIR__);
require_once __DIR__ . '/standalone/bootstrap.php';

require_once ACC_BASE_PATH . '/includes/helpers/acc-schema.php';
require_once ACC_BASE_PATH . '/includes/helpers/arag-shop-accounting.php';

Acc_Schema::ensure_core_tables();

$migrated = Arag_Shop_Accounting::migrate_legacy_events();
update_option('arag_shop_acct_version', '5.0', false);
update_option('arag_shop_acct_module', Arag_Shop_Accounting::MODULE, false);

header('Content-Type: text/plain; charset=utf-8');
echo "Arag Shop Accounting v5 OK\n";
echo "Legacy events updated: " . (int) ($migrated['updated'] ?? 0) . "\n";
echo "Module tag: " . Arag_Shop_Accounting::MODULE . "\n";
