Files
SGF/scripts/receivables-proof.php
T
nala 21a91f2aff Accept isolated WORKSHOP-RESOURCE-RECORD-v1 delivery
Record explicit workshop acceptance and preserve subsequent synthetic work without accepting receivables. Keep 080000/070000 unapplied, real workshop grants pending and operational issuance blocks intact. Exclude local credentials and real-data preservation reports.
2026-10-27 11:28:34 +02:00

17 lines
2.0 KiB
PHP

<?php
require __DIR__.'/../vendor/autoload.php';
$app=require __DIR__.'/../bootstrap/app.php'; $app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
\App\Modules\Services\ServiceReceivables::guard();
$f=json_decode(file_get_contents('C:/laragon/data/sgf-tempo/secrets/browser-fixture.json'),true,32,JSON_THROW_ON_ERROR);
app(\App\Shared\Context\CompanyContext::class)->selectFor($f['reader_id'],$f['tenant'],$f['company'],$f['unit']);
$s=app(\App\Modules\Services\ServiceReceivables::class); $all=$s->listing($f['reader_id']);
$record=collect($all['records'])->first(fn($r)=>$r->kind==='obligation' && $r->invoice_id===$f['receivables']['invoice']);
$ob=collect($all['obligations'])->firstWhere('id',$record->id);
if($ob['balance']!=='0.00' || $ob['received']!=='1000.00' || $ob['allocated']!=='1000.00' || $ob['available']!=='0.00' || count($ob['receipts'])!==2) throw new RuntimeException('Browser scenario totals not confirmed.');
foreach($ob['receipts'] as $rc) if(!$rc['reconciled']) throw new RuntimeException('Synthetic reconciliation missing.');
$events=\Illuminate\Support\Facades\DB::table('sr_events')->pluck('id'); $delivered=0;
foreach($events as $event) if($s->deliver($event)) $delivered++;
$out=['database'=>'sgf_tempo_test','simulation_only'=>true,'policy'=>$s::POLICY,'notice'=>$s::NOTICE,'document_id'=>$record->invoice_id,'obligation_id'=>$ob['id'],'original'=>$ob['original'],'received'=>$ob['received'],'allocated'=>$ob['allocated'],'unallocated'=>$ob['available'],'balance'=>$ob['balance'],'receipts'=>array_values($ob['receipts']),'revision'=>$ob['revision'],'real_login_browser'=>true,'csrf_enabled'=>true,'actors_distinct'=>$f['manager_id']!==$f['reader_id'],'durable_events_delivered'=>$delivered,'no_fiscal_receipt_or_new_pdf'=>true];
file_put_contents(base_path('docs/proofs/receivables-browser-results.json'),json_encode($out,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));
echo "Browser scenario verified: 1000.00 - 400.00 - 600.00 = 0.00; two simulated reconciliations; durable events delivered internally.\n";