Regista aceitacao funcional do primeiro incremento PGC-NIRF e preserva as dependencias documentais e tecnicas existentes. A validacao do calculo fiscal continua separada e pendente. Sem credenciais, bases operacionais ou publicacao.
33 lines
4.0 KiB
PHP
33 lines
4.0 KiB
PHP
<?php
|
|
use App\Modules\Services\CatalogueAccounting;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Str;
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
$app=require __DIR__.'/../bootstrap/app.php';$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
\App\Shared\Testing\TestingDatabaseGuard::assertSafe();
|
|
$file='C:/laragon/data/sgf-tempo/secrets/browser-fixture.json';$f=json_decode(file_get_contents($file),true,32,JSON_THROW_ON_ERROR);
|
|
if(DB::table('ca_proposals')->exists())throw new RuntimeException('Accounting fixture already present; no data deleted.');
|
|
foreach(['manager_id','reader_id'] as $field)if(!str_ends_with(DB::table('users')->where('id',$f[$field])->value('email'),'@example.test'))throw new RuntimeException('Synthetic identities required.');
|
|
$result=DB::transaction(function()use($f){
|
|
foreach(['manager_id'=>'propose','reader_id'=>'approve'] as $field=>$action)foreach(['view',$action] as $right)\Tests\Support\IdentityFixture::grant($f[$field],$f['tenant'],$f['company'],"catalogue_accounting.$right");
|
|
$select=function(int $actor)use($f){app(\App\Shared\Context\CompanyContext::class)->selectFor($actor,$f['tenant'],$f['company'],$f['unit']);};
|
|
$select($f['manager_id']);$workflow=app(\App\Modules\Services\ServiceWorkflow::class);
|
|
$client=$workflow->save('clients',null,$f['manager_id'],['name'=>'Cliente de classificação sintética'],(string)Str::uuid())['id'];
|
|
$service=$workflow->save('services',null,$f['manager_id'],['name'=>'Apoio administrativo pontual — Ensaio'],(string)Str::uuid())['id'];
|
|
$draft=$workflow->save('service_drafts',null,$f['manager_id'],['client_id'=>$client,'lines'=>[['service_id'=>$service,'quantity'=>'1','unit_price'=>'100']]],(string)Str::uuid())['id'];
|
|
$create=function(string $kind,array $data,bool $approve=true)use($f,$select){
|
|
$select($f['manager_id']);$c=app(CatalogueAccounting::class);$id=$c->propose($f['manager_id'],['kind'=>$kind,'data'=>$data,'valid_from'=>'2026-01-01','reason'=>'Proposta exclusivamente sintética para demonstração.'],(string)Str::uuid())['id'];
|
|
if($approve){$c->submit($id,$f['manager_id'],(string)Str::uuid());$select($f['reader_id']);$c->decide($id,$f['reader_id'],['decision'=>'approved','reason'=>'Validação sintética; não é enquadramento da Tempo Lda.'],(string)Str::uuid());}
|
|
return $id;
|
|
};
|
|
$plan=$create('plan',['plan'=>'PGC-NIRF','source_version'=>CatalogueAccounting::SOURCE_VERSION]);
|
|
$account=$create('account',['plan_id'=>$plan,'code'=>'7.2.900','name'=>'Serviços normais — conta empresarial sintética','origin'=>'enterprise','movable'=>true,'evidence'=>'Desdobramento empresarial de teste, não código oficial proposto à Tempo Lda.']);
|
|
$category=$create('category',['name'=>'Serviços normais — Categoria sintética','account_id'=>$account,'conditions'=>'Apenas apoio administrativo da actividade normal sintética.']);
|
|
$link=$create('service_link',['service_id'=>$service,'category_id'=>$category]);
|
|
$select($f['manager_id']);$c=app(CatalogueAccounting::class);$consulted=$c->resolve($service,'2026-10-26',$f['manager_id']);$resolution=$c->capture($f['manager_id'],['area'=>'service_drafts','record_id'=>$draft,'record_version'=>1,'service_id'=>$service,'reference_date'=>'2026-10-26','resolution_revision'=>$consulted['revision']],(string)Str::uuid())['id'];
|
|
$refuse=$create('category',['name'=>'Proposta sintética a recusar','account_id'=>$account,'conditions'=>'Evidência incompleta; não activar.'],false);$select($f['manager_id']);$c->submit($refuse,$f['manager_id'],(string)Str::uuid());
|
|
return ['accounting_service'=>$service,'accounting_draft'=>$draft,'accounting_plan'=>$plan,'accounting_account'=>$account,'accounting_category'=>$category,'accounting_link'=>$link,'accounting_resolution'=>$resolution,'accounting_refuse'=>$refuse];
|
|
});
|
|
file_put_contents($file,json_encode($f+$result,JSON_THROW_ON_ERROR));
|
|
echo "Synthetic classification graph, captured baseline and pending refusal prepared only in sgf_tempo_test. Credentials omitted.\n";
|