make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); \App\Shared\Testing\TestingDatabaseGuard::assertSafe(); $in=json_decode(stream_get_contents(STDIN),true,32,JSON_THROW_ON_ERROR); app(\App\Shared\Context\CompanyContext::class)->selectFor($in['actor'],$in['tenant'],$in['company'],$in['unit']); if($in['pause'] ?? false) { $paused=false; \Illuminate\Support\Facades\DB::listen(function($q) use(&$paused) { if(!$paused && str_contains($q->sql,'"companies"') && str_contains($q->sql,'for update')) { $paused=true; echo "LOCK_HELD\n"; flush(); usleep(1500000); } }); } echo json_encode(app(\App\Modules\Services\ServiceFiscal::class)->calculate($in['draft'],$in['actor'],$in['command']),JSON_THROW_ON_ERROR).PHP_EOL;