table('wo_entries')->where('id',$direct['material'])->first();$data=json_decode($entry->data,true);$input=$host->table('ic_inputs')->where('id',$industrial['refs']['material']['id'])->first(); if($entry->order_id!==$direct['order']||$input->lot_id!==$industrial['lot']||$data['resource']!=='QA-MATERIAL-DIRECTO-'.$tag||!str_starts_with($input->source_ref,'IND-TEST-MATERIAL-'))throw new LogicException('Only explicitly prepared artificial materials may enter this perimeter'); $policy=['contract'=>'SGF-QA-DISJOINT-MATERIALS-v1','composition'=>$tag,'host_database'=>$host->getDatabaseName(),'scope'=>['tenant_id'=>1,'company_id'=>2,'unit_id'=>2],'valued_stock'=>[['stock_item_id'=>$stock['stock_item_id'],'warehouse_id'=>$stock['warehouse_id']]],'direct_costs'=>[(string)$direct['order']=>['material_origin'=>$entry->origin,'resource'=>$data['resource'],'treatment'=>'synthetic material outside selected valued article']],'industrial_costs'=>[(string)$industrial['lot']=>['material_origin'=>$input->source_ref,'treatment'=>'synthetic material outside selected valued article']],'reason'=>'Recorte QA autorizado: três materiais artificiais distintos, sem correspondência implícita ou dupla valorização. Não é valorização geral de produção.','prepared_by'=>$profiles['finance_prepare']['user_id'],'reviewed_by'=>$profiles['finance_review']['user_id']]; $file=$s['root'].'/single-material-perimeter.json';$raw=json_encode($policy,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR);if(is_file($file)&&file_get_contents($file)!==$raw)throw new LogicException('Preserve differing individual material perimeter');file_put_contents($file,$raw);config(['sgf_single_installation.material_perimeter_sha256'=>hash_file('sha256',$file)]); app(App\Modules\Accounting\ComposedMaterialIsolation::class)->check($host,$native,$policy['scope']); file_put_contents($work.'/material-perimeter-result.json',json_encode(['passed'=>true,'book'=>$book,'sha256'=>hash_file('sha256',$file),'synthetic_only'=>true,'physical_stock_changed'=>false,'protected_associations_changed'=>false],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'proof'=>$work.'/material-perimeter-result.json']).PHP_EOL;