make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); \App\Modules\Services\ServiceInvoicing::guard(); $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\ServiceInvoicing::class)->issue($in['draft'],$in['actor'],$in['input'],$in['key']),JSON_THROW_ON_ERROR).PHP_EOL;