Files
SGF/scripts/sgf-install-fiscal-coverage.php
2026-11-11 09:00:17 +02:00

8 lines
2.2 KiB
PHP

<?php
$book='8085';require __DIR__.'/sgf-single-bootstrap.php';
$proof=$run['root'].'/private/receipt-composition-b4093c6f6707/single-integration/20261110-182835-4be44cc1/fiscal-coverage-result.json';$p=json_decode(file_get_contents($proof),true);if(($p['passed']??false)!==true||count($p['checks']??[])!==17)throw new LogicException('Require valid affected regression');
$build=$run['root'].'/private/single-fiscal-coverage-build-20261110';if(!is_file($build.'/manifest.json'))throw new LogicException('Private build required');$files=['app/Modules/Services/FiscalCoverage.php','app/Modules/Services/ServiceFiscal.php','app/Shared/Installation/PresentationEntry.php'];foreach($files as$file)(new Symfony\Component\Process\Process([PHP_BINARY,'-l',$repo.'/'.$file]))->mustRun();
$before=[];foreach(['sf_proposals','sf_decisions','sf_activation_events','service_calculation_results','si_invoices','sr_records','sr_effects','cash_events','permission_grants']as$table)$before['host'][$table]=hash('sha256',$host->table($table)->orderBy('id')->get()->toJson());foreach(['stock_movements','gl_journals']as$table)$before['native'][$table]=hash('sha256',$native->table($table)->orderBy('id')->get()->toJson());
$hashes=[];$copy=function($src,$file)use($s,$work,&$hashes){$dest=$s['app'].'/'.$file;$backup=$work.'/before/'.$file;if(is_file($dest)){if(!is_dir(dirname($backup)))mkdir(dirname($backup),0700,true);copy($dest,$backup);}if(!is_dir(dirname($dest)))mkdir(dirname($dest),0700,true);copy($src,$dest);$hashes[$file]=hash_file('sha256',$dest);};foreach($files as$file)$copy($repo.'/'.$file,$file);foreach(glob($build.'/assets/*')as$file)$copy($file,'public/build/assets/'.basename($file));$copy($build.'/manifest.json','public/build/manifest.json');
file_put_contents($work.'/fiscal-coverage-installation.json',json_encode(['passed'=>true,'hashes'=>$hashes,'before'=>$before,'new_rights'=>0,'business_commands'=>0,'cache_cleared'=>false,'new_demo'=>false],JSON_PRETTY_PRINT));file_put_contents($s['root'].'/fiscal-coverage-installation-pointer.json',json_encode(['proof'=>$work.'/fiscal-coverage-installation.json']));echo json_encode(['passed'=>true,'proof'=>$work.'/fiscal-coverage-installation.json']).PHP_EOL;