Files
Investidor-V2/outputs/investmoz-audit-current-20261012/next-lot-final-SQL.php
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

6 lines
3.0 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');$f=json_decode(file_get_contents(__DIR__.'/business-country-fixture.json'),true,512,JSON_THROW_ON_ERROR);putenv('STABILITY_QA_MODE=consumers');$app=require $f['QA_source'].'/tools/portal-stability-runtime.php';$db=Illuminate\Support\Facades\DB::connection();$t=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');if($t!==$f['target'])throw new RuntimeException('QA guard');$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');try{
$v=json_decode(file_get_contents(__DIR__.'/franchise-variants-progress.json'),true,512,JSON_THROW_ON_ERROR);$share=json_decode(file_get_contents(__DIR__.'/partnership-revocation-progress.json'),true,512,JSON_THROW_ON_ERROR);$prior=json_decode(file_get_contents(__DIR__.'/next-lot-inventory-QA.json'),true,512,JSON_THROW_ON_ERROR);$o=App\Models\Opportunity::findOrFail(56);$canonical=app(App\Services\OpportunityManagement::class)->values($o)['canonical'];$room=$db->table('partnership_rooms')->where('id',$share['room_id'])->first();$link=$db->table('partnership_documents')->where('id',$share['attachment_id'])->first();$oldRoom=$db->table('partnership_rooms')->where('id',1)->first();if($oldRoom->status!==$prior['rooms'][0]['status'])throw new RuntimeException('Prior room changed');foreach($prior['room_attachments']as$r){$d=$db->table('partnership_documents as l')->join('documents as d','d.id','=','l.document_id')->where('l.id',$r['id'])->first(['l.shared','d.sha256']);if($d->shared!==$r['shared']||trim($d->sha256)!==trim($r['sha256']))throw new RuntimeException('Prior attachment changed');}
$p=['at'=>gmdate('c'),'target'=>$t,'SQL_read_only'=>true,'opportunity'=>['id'=>56,'status'=>$o->workflow_context['working_state'],'initial_fee'=>$canonical['business_transaction']['franchise_terms']['initial_fee'],'license_resource_id'=>$canonical['business_transaction']['franchise_terms']['brand_license_document_id'],'royalties_preserved'=>str_contains($canonical['business_transaction']['franchise_terms']['royalties'],'seis por cento'),'approval_actor'=>$o->workflow_context['approval']['actor_id'],'publisher_actor'=>$o->workflow_context['publication']['actor_id'],'visibility'=>$o->workflow_context['publication']['visibility']],'room'=>['id'=>$room->id,'status'=>$room->status,'attachment_id'=>$link->id,'shared'=>$link->shared,'original_document_count'=>$db->table('partnership_documents')->where('room_id',$room->id)->count()],'previous_room_1_status_and_3_originals_unchanged'=>true,'new_license_resources'=>$db->table('opportunity_documents')->where('id',$v['license_resource_id'])->count(),'external_notifications_enabled'=>config('portal.notifications_enabled'),'active_writes'=>0,'result'=>'passed'];if($p['opportunity']['license_resource_id']!==$v['license_resource_id']||$room->status!=='cancelled'||$link->shared||$p['new_license_resources']!==1)throw new RuntimeException('Final expected state differs');file_put_contents(__DIR__.'/next-lot-final-SQL.json',json_encode($p,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($p);
}finally{$db->rollBack();}