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

5 lines
2.6 KiB
PHP

<?php
$book=$argv[1]??'regression';require __DIR__.'/sgf-single-bootstrap.php';$checks=[];$ok=function($v,$n)use(&$checks){if(!$v)throw new LogicException($n);$checks[]=$n;};$calc=App\Modules\HumanResources\Remunerations::calculate('10000.00',['worker_rate'=>'3','employer_rate'=>'4','retention_rate'=>'8']);$ok($calc['net_cents']==='890000'&&$calc['employer_cost_cents']==='1040000','autonomous class exact artificial amounts');$tiny=App\Modules\HumanResources\Remunerations::calculate('0.01',['worker_rate'=>'3','employer_rate'=>'4','retention_rate'=>'8']);$ok($tiny['rubrics']['retention_rate']['difference']==='2/25'&&$tiny['net_cents']==='1','exact cent difference preserved');$missing=App\Modules\HumanResources\Remunerations::calculate('10000.00',['worker_rate'=>'3','employer_rate'=>'4','retention_rate'=>null]);$ok($missing['net_cents']===null&&!$missing['complete'],'missing never zero');$ok(!$host->table('permission_grants')->where('permission','like','remunerations.%')->exists(),'former finance grants completely retracted');$ok(!$host->table('permission_grants')->where('permission','like','human_resources.%')->exists(),'no new HR grants before approval');$ok(!$host->getSchemaBuilder()->hasTable('hr_qa_profiles'),'no new HR identities provisioned');$ok($host->table('rm_versions')->count()===0&&$host->table('rm_commands')->count()===0,'no HR processing persisted');$ok(App\Shared\Context\ModuleNavigation::owner('api/remunerations/confirm')==='human_resources','HTTP ownership autonomous');try{App\Shared\Installation\HumanResourcesProfiles::policy();throw new LogicException('Expected no approval');}catch(Symfony\Component\HttpKernel\Exception\HttpExceptionInterface$e){$ok($e->getStatusCode()===403,'unapproved profile installer fail closed');}$ok(config('remunerations.enabled')===false&&config('human_resources.enabled')===false,'both runtime flags off by default');
$context=app(App\Shared\Context\CompanyContext::class);$context->selectFor(13,1,2,2);config(['modules.contracted'=>array_keys(App\Shared\Context\ModuleNavigation::LABELS)]);$modules=app(App\Shared\Context\ModuleNavigation::class)->available($context);$ok(!in_array('human_resources',array_column($modules,'id'),true),'financial preparer cannot discover HR with old finance rights');$context->clear();
file_put_contents($work.'/hr-preauthorization.json',json_encode(['passed'=>true,'checks'=>$checks,'new_grants'=>0,'new_users'=>0,'business_commands'=>0,'positive_hr_workflow_not_yet_tested'=>true],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'checks'=>count($checks),'proof'=>$work.'/hr-preauthorization.json']).PHP_EOL;