make(Kernel::class)->bootstrap(); $p = json_decode(file_get_contents($file), true, 64, JSON_THROW_ON_ERROR); $db = DB::connection(); $i = $db->selectOne("SELECT current_database() AS db,current_user AS role,inet_server_port() AS port,current_setting('cluster_name') AS cluster"); if (! preg_match('/^compras_receipts_test_([a-f0-9]{12})$/D', $i->db, $m) || $i->role !== 'stock_receipt_qa_'.$m[1] || (int) $i->port !== 55439 || $i->cluster !== 'sgf_modular_regression_'.getenv('SGF_ISOLATED_REGRESSION_RUN')) { throw new LogicException('QA worker database refused'); } config(['common-payables.enabled' => true, 'common-payables.history_enabled' => true, 'common-payables.paged_read_enabled' => true, 'common-payables.source_instance' => $p['instance']]); $u = User::query()->findOrFail($p['actor']); auth()->setUser($u); $time = hrtime(true); try { $d = app(SupplierPayables::class)->listing($u); $out = ['status' => 200, 'documents' => count($d['documents']), 'balances' => array_column($d['obligations'], 'balance_minor'), 'time_ms' => (hrtime(true) - $time) / 1e6]; } catch (HttpExceptionInterface $e) { $out = ['status' => $e->getStatusCode()]; } file_put_contents($file.'.result', json_encode($out, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));