Files
compras/scripts/purchasing-client-check.php
2026-11-02 08:08:05 +02:00

26 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
use Tempo\Distribution\Release;
use Tempo\Purchasing\Supply\ReplenishmentProjection;
// Run this installed copy in the client host; no source checkout or application boot.
$host = dirname(__DIR__);
require $host.'/vendor/autoload.php';
require $host.'/packages/purchasing/bootstrap.php';
$current = Release::current($host);
$policy = ['daily_milli' => 10000, 'safety_milli' => 20000, 'target_milli' => 100000, 'maximum_milli' => 120000, 'lead_days' => 4, 'approval_days' => 1, 'minimum_milli' => 24000, 'pack_milli' => 12000, 'horizon_days' => 30];
$result = (new ReplenishmentProjection)->calculate($policy, 120000, '2026-11-01');
if ($result['quantity_milli'] !== 84000) {
throw new RuntimeException('O pacote instalado não preserva o resultado de referência.');
}
$base = strtolower(str_replace('\\', '/', realpath($host))).'/';
foreach (get_included_files() as $file) {
if (! str_starts_with(strtolower(str_replace('\\', '/', realpath($file))), $base)) {
throw new RuntimeException('Foi carregado código fora da instalação cliente.');
}
}
echo json_encode(['version' => $current['version'], 'runtime' => PHP_VERSION, 'all_loaded_code_in_client_host' => true,
'source_checkout_required' => false, 'database_connected' => false, 'quantity_milli' => $result['quantity_milli']], JSON_THROW_ON_ERROR)."\n";