table('goods_receipts')->value('id');$url='/api/purchasing-receipts/history/'.$id;$docs=$url.'/documents';$bytes=file_get_contents($s['root'].'/receipt-documents/'.$db->table('receipt_documents')->where('goods_receipt_id',$id)->orderBy('id')->value('path')); $send=function($role,$path,$fields)use($clients,$options,$bytes){$parts=[];foreach($fields as$name=>$value)$parts[]=['name'=>$name,'contents'=>$value];$parts[]=['name'=>'file','contents'=>$bytes,'filename'=>'qa-original.png'];$r=$clients[0]->post($path,$options($role)+['multipart'=>$parts]);return ['status'=>$r->getStatusCode(),'data'=>json_decode((string)$r->getBody(),true)];};$r=$call('validator',$url);$fields=['operation_key'=>(string)Str::uuid(),'revision'=>$r['data']['document_revision'],'reason'=>'Conferencia adicional da origem documental sintetica.','document_type'=>'delivery_note'];$p=$send('validator',$docs.'/preview',$fields);if($p['status']!==200)throw new RuntimeException('Additional preview failed');$cut=json_decode(Illuminate\Support\Facades\Crypt::decryptString($p['data']['preview']),true,64,JSON_THROW_ON_ERROR);$encode=fn($v)=>Illuminate\Support\Facades\Crypt::encryptString(json_encode($v,JSON_THROW_ON_ERROR));$bad=$cut;$bad['revision']=str_repeat('0',64);$ok($send('validator',$docs.'/confirm',['preview'=>$encode($bad)])['status']===409,'confirmation compares current immutable receipt revision again');$bad=$cut;$bad['observed']=time()-601;$ok($send('validator',$docs.'/confirm',['preview'=>$encode($bad)])['status']===409,'expired conference requires a new individual preview');$bad=$cut;$bad['binding']=str_repeat('0',64);$ok($send('validator',$docs.'/confirm',['preview'=>$encode($bad)])['status']===409,'changed source binding cannot confirm earlier conference');$bad=$cut;$bad['generation']=str_repeat('0',64);$ok($send('validator',$docs.'/confirm',['preview'=>$encode($bad)])['status']===409,'changed session context generation requires renewed conference'); // Exercise the shared storage helper's original default branch, without committing supplier changes. $supplier=$n['supplier_ids'][0];$u='/api/purchasing-suppliers/'.$supplier;$r=$call('actor',$u);$before=(array)$db->table('suppliers')->where('id',$supplier)->first();$p=$send('actor',$u.'/documents/preview',['operation_key'=>(string)Str::uuid(),'revision'=>$r['data']['revision'],'reason'=>'Prova da preservacao do armazenamento privado existente.','document_type'=>'license']);$ok($p['status']===200&&$p['data']['impact']['supplier_status']==='pending','shared storage helper preserves supplier native preview with default disk');$ok($db->table('supplier_documents')->count()===0&&(array)$db->table('suppliers')->where('id',$supplier)->first()===$before&&$db->table('receipt_documents')->count()===16,'supplier preview keeps both document namespaces and prior receipt evidence intact'); file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'new_right_names'=>[]],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." receipt document additional checks passed.\n";