Files
SGF/scripts/sgf-remunerations-retract-finance.php
2026-11-11 09:00:17 +02:00

6 lines
1.2 KiB
PHP

<?php
$book=$argv[1]??'regression';require __DIR__.'/sgf-single-bootstrap.php';
$p=json_decode(file_get_contents($repo.'/docs/integration/sgf-remunerations-access-proposal.json'),true);if(($p['status']??null)!=='superseded_by_autonomous_hr_directive')throw new LogicException('Express autonomous HR correction required');
$removed=$host->transaction(function()use($host,$p){$count=0;foreach($p['grants_per_book']as$g){$where=$p['scope']+$g;$rows=$host->table('permission_grants')->where($where)->get();foreach($rows as$row){$host->table('permission_grants')->where('id',$row->id)->delete();App\Modules\Identity\Services\Audit::record('access.remuneration_qa_retracted',null,1,2,2,$row->user_id,['permission'=>$row->permission,'reason'=>'Directiva expressa: RH autónomo com perfis distintos; revogar só as concessões novas deste bloco ainda não disponibilizado.']);$count++;}}return$count;});
file_put_contents($work.'/remunerations-finance-retracted.json',json_encode(['passed'=>true,'book'=>$book,'removed_only_new_financial_profile_grants'=>$removed,'business_writes'=>0,'new_hr_grants'=>0],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'book'=>$book,'removed'=>$removed,'proof'=>$work.'/remunerations-finance-retracted.json']).PHP_EOL;