Files
SGF/scripts/invoice-fixture.php
T

12 lines
1.1 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\ServiceInvoicing::guard();
$file='C:/laragon/data/sgf-tempo/secrets/browser-fixture.json';
$f=json_decode(file_get_contents($file),true,32,JSON_THROW_ON_ERROR);
if(\Illuminate\Support\Facades\DB::table('a_services')->exists() || \Illuminate\Support\Facades\DB::table('si_proposals')->exists()) throw new RuntimeException('Synthetic fixture must be empty; nothing deleted.');
$fixture=\Illuminate\Support\Facades\DB::transaction(fn()=>\Tests\Support\InvoiceFixture::create($f+['manager'=>\App\Models\User::findOrFail($f['manager_id']),'reader'=>\App\Models\User::findOrFail($f['reader_id'])]));
$ids=array_intersect_key($fixture,array_flip(['client','service','source','draft','profile','temporal','calculation','series','rule','today','start','end']));
file_put_contents($file,json_encode($f+['invoice'=>$ids],JSON_THROW_ON_ERROR));
echo "Synthetic invoice fixture ready only in sgf_tempo_test; no invoice or PDF pre-issued.\n";