Files
SGF/scripts/sgf-human-resources-preparation-preservation.php
2026-11-11 09:00:17 +02:00

6 lines
2.4 KiB
PHP

<?php
$book='8085';require __DIR__.'/sgf-single-bootstrap.php';$pointer=json_decode(file_get_contents($s['root'].'/remunerations-backup-pointer.json'),true);$before=json_decode(file_get_contents($pointer['root'].'/preservation-private.json'),true);$checks=[];$same=[];$ok=function($v,$n)use(&$checks){if(!$v)throw new LogicException($n);$checks[]=$n;};
foreach(['host','native']as$name){$db=$name==='host'?$host:$native;foreach($before[$name]as$table=>$json){$order=in_array($table,['sr_outbox','sr_deliveries'],true)?'event_id':(in_array($table,['sc_catalogue_meta','pd_due_meta','fo_meta','fs_meta'],true)?'policy':(in_array($table,['fs_results','fs_result_lines'],true)?'snapshot_key':'id'));$rows=$db->table($table)->orderBy($order)->when($table==='fs_result_lines',fn($q)=>$q->orderBy('account_id'))->get();$ok($rows->toJson()===$json,'original identical '.$name.'.'.$table);$same[]=$name.'.'.$table;}}
foreach(['binding'=>'binding.json','single_binding'=>'single-bindings.json','stock_binding'=>'stock-binding.json']as$key=>$file)$ok(hash_file('sha256',$s['root'].'/'.$file)===$before[$key],$file.' unchanged');$ok($host->table('rm_versions')->count()===0&&$host->table('rm_commands')->count()===0,'no employee rules or payroll persisted');$ok(!$host->table('permission_grants')->where('permission','like','remunerations.%')->exists()&&!$host->table('permission_grants')->where('permission','like','human_resources.%')->exists(),'all new finance grants retracted and no HR powers granted');$ok(!$host->getSchemaBuilder()->hasTable('hr_qa_profiles'),'no HR identities created');$ok(!str_contains(file_get_contents($s['app'].'/routes/web.php'),'/api/remunerations'),'new routes not copied to8085');$ok(!str_contains(file_get_contents($s['app'].'/public/build/manifest.json'),'RemunerationsWorkspace'),'prepared bundle not installed');$ok($native->table('gl_journals')->count()===27,'27 journal entries intact');
file_put_contents($work.'/hr-preparation-preservation.json',json_encode(['passed'=>true,'checks'=>$checks,'identical_original_tables'=>$same,'new_schema_tables'=>['rm_meta','rm_versions','rm_commands'],'new_financial_profile_grants_retracted'=>7,'new_hr_profiles'=>0,'new_hr_grants'=>0,'business_commands_8085'=>0,'cache_cleared'=>false,'protected_six_targeted'=>false,'installed'=>false],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'checks'=>count($checks),'identical_original_tables'=>count($same),'proof'=>$work.'/hr-preparation-preservation.json']).PHP_EOL;