commit de compras
This commit is contained in:
@@ -3,11 +3,31 @@
|
||||
$file=realpath($argv[1]??'');$state=json_decode(file_get_contents('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'),true,512,JSON_THROW_ON_ERROR);
|
||||
$private=realpath($state['root'].'/private');
|
||||
if(!$file||!$private||!str_starts_with($file,$private.DIRECTORY_SEPARATOR)||$state['port']!==55439)throw new LogicException('QA settings refused');
|
||||
$s=json_decode(file_get_contents($file),true,512,JSON_THROW_ON_ERROR);$phase=$argv[2]??'';$native=in_array($phase,['native','native-post'],true);$mode=$native?'native':'sgf';$c=$s[$mode];
|
||||
$s=json_decode(file_get_contents($file),true,512,JSON_THROW_ON_ERROR);$phase=$argv[2]??'';$native=in_array($phase,['native','native-post'],true)||str_starts_with($phase,'native-page-')||str_starts_with($phase,'native-cycle-');$mode=$native?'native':'sgf';$c=$s[$mode];
|
||||
if(!preg_match('/^[a-f0-9]{12}$/D',$s['tag'])||$c['database']!==($native?'compras_receipts_test_':'payable_sgf_').$s['tag']||$c['role']!=='payable_history_'.$mode.'_'.$s['tag'])throw new LogicException('QA identity refused');
|
||||
$env=['APP_ENV'=>$native?'testing':'payable-testing','APP_DEBUG'=>'false','APP_KEY'=>'base64:'.base64_encode(str_repeat('s',32)),'DB_CONNECTION'=>'pgsql','DB_URL'=>'','DB_HOST'=>'127.0.0.1','DB_PORT'=>'55439','DB_DATABASE'=>$c['database'],'DB_USERNAME'=>$c['role'],'DB_PASSWORD'=>$c['password'],'SESSION_DRIVER'=>'array','CACHE_STORE'=>'array','QUEUE_CONNECTION'=>'sync','MAIL_MAILER'=>'array','BCRYPT_ROUNDS'=>'4','LARAVEL_STORAGE_PATH'=>$c['storage'],'APP_CONFIG_CACHE'=>$c['storage'].'/cache/config.php','APP_ROUTES_CACHE'=>$c['storage'].'/cache/routes.php','APP_SERVICES_CACHE'=>$c['storage'].'/cache/services.php','APP_PACKAGES_CACHE'=>$c['storage'].'/cache/packages.php','VIEW_COMPILED_PATH'=>$c['storage'].'/framework/views','COMMON_PAYABLES_PATH'=>dirname(__DIR__).'/packages/payables','COMMON_PAYABLES_ENABLED'=>'true','COMMON_PAYABLES_HISTORY_ENABLED'=>'true','PAYABLE_SOURCE_INSTANCE'=>$s['source_instance']];
|
||||
if(isset($s['common_bundle'])){
|
||||
$bundleRoot=realpath($s['common_bundle']);if(!$native||!$bundleRoot||!str_starts_with($bundleRoot,$private.DIRECTORY_SEPARATOR))throw new LogicException('Owned standalone artifact required');
|
||||
$bundle=['payables'=>$bundleRoot.'/payables','ledger'=>$bundleRoot.'/general-ledger'];$env['COMMON_FINANCE_BUNDLE_ROOT']=$bundleRoot;$env['COMMON_FINANCE_BUNDLE_SHA256']=$s['common_bundle_sha256']??'';
|
||||
}
|
||||
foreach($env as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}
|
||||
if($phase==='http'){putenv('SESSION_DRIVER=file');$_ENV['SESSION_DRIVER']=$_SERVER['SESSION_DRIVER']='file';}
|
||||
if(str_starts_with($phase,'ledger-sales-')){foreach(['APP_ENV'=>'testing','SGF_SALES_LEDGER_QA'=>'true'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}}
|
||||
if(str_starts_with($phase,'ledger-cost-')){foreach(['APP_ENV'=>'testing','SGF_COST_LEDGER_QA'=>'true'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}}
|
||||
if(str_starts_with($phase,'ledger-cost-correction-')||($s['cost_correction']??false)===true){putenv('SGF_COST_CORRECTION_QA=true');$_ENV['SGF_COST_CORRECTION_QA']=$_SERVER['SGF_COST_CORRECTION_QA']='true';}
|
||||
if(str_starts_with($phase,'ledger-cost-composition-')||($s['ledger_composition']??false)===true){foreach(['SGF_COST_CORRECTION_QA'=>'true','SGF_SALES_LEDGER_QA'=>'true','SGF_LEDGER_COMPOSITION_QA'=>'true'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}}
|
||||
if(str_starts_with($phase,'ledger-cost-industrial-')||($s['industrial_ledger']??false)===true){putenv('SGF_INDUSTRIAL_LEDGER_QA=true');$_ENV['SGF_INDUSTRIAL_LEDGER_QA']=$_SERVER['SGF_INDUSTRIAL_LEDGER_QA']='true';}
|
||||
if(str_starts_with($phase,'ledger-cost-industrial-correction-')||($s['industrial_correction']??false)===true){putenv('SGF_INDUSTRIAL_CORRECTION_QA=true');$_ENV['SGF_INDUSTRIAL_CORRECTION_QA']=$_SERVER['SGF_INDUSTRIAL_CORRECTION_QA']='true';}
|
||||
if($phase==='ledger-cost-http'){foreach(['APP_ENV'=>'browser-testing','SESSION_DRIVER'=>'file','SESSION_COOKIE'=>'sgf_cost_'.$s['tag'],'SESSION_SECURE_COOKIE'=>'false'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}}
|
||||
if($phase==='ledger-sales-http'){foreach(['APP_ENV'=>'browser-testing','SESSION_DRIVER'=>'file','SESSION_COOKIE'=>'sgf_sales_'.$s['tag'],'SESSION_SECURE_COOKIE'=>'false'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}}
|
||||
if(isset($s['app_key'])){putenv('APP_KEY='.$s['app_key']);$_ENV['APP_KEY']=$_SERVER['APP_KEY']=$s['app_key'];}
|
||||
if(in_array($phase,['http','settlement-page-http','settlement-read-http','payable-report-http','ledger-http'],true)){putenv('SESSION_DRIVER=file');$_ENV['SESSION_DRIVER']=$_SERVER['SESSION_DRIVER']='file';}
|
||||
if($phase==='ledger-http'){foreach(['SESSION_COOKIE'=>'sgf_ledger_'.$s['tag'],'SESSION_SECURE_COOKIE'=>'false'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}}
|
||||
if($phase==='native-page-http'){
|
||||
foreach(['APP_ENV'=>'payable-testing','SESSION_DRIVER'=>'file','SESSION_COOKIE'=>'qa_native_page_'.$s['tag'],'SESSION_SECURE_COOKIE'=>'false','COMMON_PAYABLES_HISTORY_DECISIONS_ENABLED'=>'false'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}
|
||||
}
|
||||
if($phase==='native-cycle-http'){
|
||||
foreach(['APP_ENV'=>'payable-testing','SESSION_DRIVER'=>'file','SESSION_COOKIE'=>'sgc_ledger_'.$s['tag'],'SESSION_SECURE_COOKIE'=>'false'] as $k=>$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;}
|
||||
}
|
||||
require $c['root'].'/vendor/autoload.php';$app=require $c['root'].'/bootstrap/app.php';$app->useStoragePath($c['storage']);$app->addAbsoluteCachePathPrefix('C:');$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -16,6 +36,9 @@ $i=DB::selectOne("SELECT current_database() AS db,current_user AS role,inet_serv
|
||||
if($i->db!==$c['database']||$i->role!==$c['role']||(int)$i->port!==55439||$i->cluster!==$s['cluster'])throw new LogicException('Effective QA host refused');
|
||||
$role=DB::selectOne('SELECT rolsuper OR rolcreatedb OR rolcreaterole OR rolreplication OR rolbypassrls AS elevated FROM pg_roles WHERE rolname=current_user');if($role->elevated)throw new LogicException('Elevated role refused');
|
||||
function fingerprint():string {$rows=[];foreach(['invoices','invoice_items','external_payments','budget_entries','budget_consumptions','stock_movements'] as $t)$rows[$t]=DB::table($t)->orderBy('id')->get()->map(fn($r)=>(array)$r)->all();return hash('sha256',Payables::canonical($rows));}
|
||||
if(str_starts_with($phase,'ledger-sales-')){require __DIR__.'/ledger-sales-proof.php';exit;}
|
||||
if(str_starts_with($phase,'ledger-cost-')){require __DIR__.'/ledger-cost-proof.php';exit;}
|
||||
if(str_starts_with($phase,'native-cycle-')){require __DIR__.'/ledger-cycle-native-proof.php';exit;}
|
||||
if($phase==='native'){
|
||||
if(DB::getSchemaBuilder()->hasTable('users'))throw new LogicException('Fresh native database required');
|
||||
Illuminate\Support\Facades\Artisan::call('migrate',['--force'=>true]);require $c['root'].'/tests/Support/PaymentFixture.php';$f=paymentFixture();
|
||||
@@ -56,6 +79,9 @@ if($phase==='worker'){
|
||||
try{$r=app(App\Modules\Purchasing\SupplierPayables::class)->engine($u)->command('validate_history',$w['proposal'],'Synthetic exact history conference.',$w['key']);$out=['status'=>200,'result'=>$r];}catch(DomainException $e){$out=['status'=>409];}
|
||||
file_put_contents($input.'.result',json_encode($out,JSON_THROW_ON_ERROR));exit;
|
||||
}
|
||||
if($phase==='page-read-worker'){
|
||||
$input=realpath($argv[3]??'');if(!$input||!str_starts_with($input,realpath($s['root']).DIRECTORY_SEPARATOR))throw new LogicException('Read worker input refused');$w=json_decode(file_get_contents($input),true,64,JSON_THROW_ON_ERROR);$f=json_decode(file_get_contents($s['root'].'/fixture.json'),true,64,JSON_THROW_ON_ERROR);config(['supplier_payable_history.synthetic_enabled'=>true]);$u=App\Models\User::findOrFail($f['actors']['read']);auth()->setUser($u);app(App\Shared\Context\CompanyContext::class)->selectFor($u->id,$f['scope']['tenant_id'],$f['scope']['company_id'],$f['scope']['unit_id']);$start=hrtime(true);$d=app(App\Modules\Purchasing\SupplierPayables::class)->listing($u);file_put_contents($input.'.result',json_encode(['documents'=>count($d['documents']),'balances'=>array_column($d['obligations'],'balance_minor'),'time_ms'=>(hrtime(true)-$start)/1e6],JSON_THROW_ON_ERROR));exit;
|
||||
}
|
||||
if($phase==='http'){
|
||||
config(['supplier_payable_history.synthetic_enabled'=>true]);$f=json_decode(file_get_contents($s['root'].'/fixture.json'),true,64,JSON_THROW_ON_ERROR);
|
||||
Illuminate\Support\Facades\Route::middleware('web')->get('/qa/enter/{role}',function(Illuminate\Http\Request $r,string $role)use($f){abort_unless(in_array($role,['prepare','validate','read'],true),404);$u=App\Models\User::findOrFail($f['actors'][$role]);auth()->login($u);$r->session()->regenerate();$token=bin2hex(random_bytes(24));$r->session()->put('auth_version',$u->auth_version);$r->session()->put('company_context',$f['scope']+['token'=>$token,'module_id'=>'purchasing']);return response()->json(['csrf'=>csrf_token(),'context'=>$token,'source_id'=>$f['source_id']])->header('Cache-Control','no-store');});
|
||||
@@ -66,8 +92,17 @@ if($phase==='post'){
|
||||
if(!$row||!$ob||!$import||Payables::canonical($source)!==Payables::canonical(json_decode($row->payload,true))||DB::table('pa_obligations')->count()!==1||DB::table('pa_history_imports')->count()!==1||DB::table('pa_imported_payments')->count()!==3||(int)$ob->principal_minor!==6000||(int)$import->confirmed_minor!==3000||(int)$import->pending_minor!==1000||(int)$import->rejected_minor!==500||DB::table('pa_source_histories')->count()!==1||config('supplier_payable_history.synthetic_enabled')!==false)throw new LogicException('SGF final preservation check failed');
|
||||
file_put_contents($s['root'].'/sgf-post.json',json_encode(['read_only'=>true,'one_obligation'=>true,'one_history_import'=>true,'original_source_unchanged'=>true,'source_receipt_sha256'=>$row->receipt_hash,'imported_payments'=>3,'states'=>DB::table('pa_imported_payments')->orderBy('legacy_payment_id')->pluck('status')->all(),'recognition_events'=>DB::table('pa_events')->where('kind','payable.recognised')->count(),'history_events'=>DB::table('pa_events')->where('kind','payable.legacy_history_imported')->count(),'principal_minor'=>6000,'confirmed_minor'=>3000,'pending_minor'=>1000,'rejected_minor'=>500,'pending_decision_schema_installed'=>DB::getSchemaBuilder()->hasTable('pa_payment_decisions'),'default_feature_enabled'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));DB::rollBack();echo "SGF final source, single import and default-disabled configuration verified read-only.\n";exit;
|
||||
}
|
||||
if(str_starts_with($phase,'native-page-')){require __DIR__.'/native-payable-page-proof.php';exit;}
|
||||
if($phase==='page-evidence'){require __DIR__.'/payable-evidence-cases.php';exit;}
|
||||
if($phase==='page-evidence-settlements'){require __DIR__.'/payable-evidence-settlements.php';exit;}
|
||||
if($phase==='page-evidence-post'){require __DIR__.'/payable-evidence-post.php';exit;}
|
||||
if(str_starts_with($phase,'settlement-page-')||str_starts_with($phase,'settlement-read-')){require __DIR__.'/settlement-page-proof.php';exit;}
|
||||
if(str_starts_with($phase,'payable-report-profile-')){require __DIR__.'/payable-report-profile.php';exit;}
|
||||
if(str_starts_with($phase,'payable-report-')){require __DIR__.'/payable-report-proof.php';exit;}
|
||||
if(str_starts_with($phase,'ledger-')){require __DIR__.'/ledger-proof.php';exit;}
|
||||
if($phase==='page-seed'){require __DIR__.'/payable-page-fixture.php';exit;}
|
||||
if($phase==='page-cases'){require __DIR__.'/payable-page-cases.php';exit;}
|
||||
if($phase==='page-bench'){require __DIR__.'/payable-page-bench.php';exit;}
|
||||
if(in_array($phase,['page-fresh-command','page-post','page-concurrent-read','page-filter-positive'],true)){require __DIR__.'/payable-page-final.php';exit;}
|
||||
if($phase!=='regression')throw new LogicException('Unknown phase');
|
||||
require __DIR__.'/payable-history-sgf-cases.php';
|
||||
|
||||
Reference in New Issue
Block a user