Files
compras/tests/Support/ExpenseAllocationQaFixture.php
T
nala d58b75c87a
tests / ci (push) Waiting to run
commit compras5 2711
2026-11-27 20:19:21 +02:00

30 lines
1.6 KiB
PHP

<?php
use App\Services\ExpenseAllocations;
use App\Services\ExternalPaymentWorkflow;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
require_once __DIR__.'/PaymentFixture.php';
/** Native payment originals and exact, labelled synthetic categories; guarded by receiptFixture. */
function expenseAllocationQaFixture(): array
{
$f = paymentFixture(['Material', 'Serviços']);
config(['common-payables.enabled' => true, 'common-payables.source_instance' => 'explicit-expense-qa', 'expense-allocations.qa_enabled' => true]);
foreach ([$f['author'], $f['validator']] as $actor) {
DB::table('pa_access')->insert(['tenant_id' => $actor->tenant_id, 'company_id' => 0, 'unit_id' => 0, 'user_id' => $actor->id,
'person' => 'expense-qa-'.$actor->id, 'action' => 'view']);
}
auth()->guard()->setUser($f['author']);
$payment = app(ExternalPaymentWorkflow::class)->register($f['author'], $f['invoice'], $f['payment_data']);
auth()->guard()->setUser($f['validator']);
app(ExternalPaymentWorkflow::class)->review($f['validator'], $payment, 'confirmed', 'Conferência de evidência estritamente sintética');
$source = app(ExpenseAllocations::class)->source($f['validator'], $payment->id);
$input = ['operation_key' => (string) Str::uuid(), 'version' => 0, 'fingerprint' => $source['fingerprint'],
'reason' => 'Imputação explícita de Finanças no ensaio sintético',
'allocations' => [['category' => 'Material', 'amount' => '15.00'], ['category' => 'Serviços', 'amount' => '25.00']]];
return compact('f', 'payment', 'source', 'input');
}