@@ -29,6 +29,7 @@ use App\Models\User;
|
||||
use App\Models\Warehouse;
|
||||
use App\Services\AgreementOrderLimits;
|
||||
use App\Services\BudgetWorkflow;
|
||||
use App\Services\CommonBudget;
|
||||
use App\Services\ComparisonPolicy;
|
||||
use App\Services\ConflictGuard;
|
||||
use App\Services\DocumentaryQualificationWorkflow;
|
||||
@@ -43,6 +44,7 @@ use App\Services\ProposalOpeningWorkflow;
|
||||
use App\Services\PurchaseControlPolicyWorkflow;
|
||||
use App\Services\PurchaseRevisionWorkflow;
|
||||
use App\Services\QuotationExchange;
|
||||
use App\Services\RequisitionBudgetDistributions;
|
||||
use App\Services\RequisitionCatalogue;
|
||||
use App\Services\RequisitionWorkflow;
|
||||
use App\Services\SupplyPlanning;
|
||||
@@ -53,9 +55,48 @@ use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Tempo\Finance\Budget\BudgetControl;
|
||||
|
||||
require_once __DIR__.'/../Support/SupplyFixture.php';
|
||||
require_once __DIR__.'/../Support/ReceiptFixture.php';
|
||||
require_once __DIR__.'/../Support/BudgetDistributionSchema.php';
|
||||
|
||||
test('distributed approved synthetic requisition follows native adjudication approval and issuance without parallel entries', function () {
|
||||
if (! method_exists(BudgetControl::class, 'recordDistribution')) {
|
||||
$this->markTestSkipped('Unpublished common source requires explicit QA selection.');
|
||||
}
|
||||
budgetDistributionFixtureSchema();
|
||||
config(['budget-distributions.qa_enabled' => true]);
|
||||
$this->withoutVite();
|
||||
$second = CostCenter::query()->create(['tenant_id' => $this->tenant->id, 'department_id' => $this->department->id, 'code' => 'QA-SPLIT', 'name' => 'Segundo centro sintético']);
|
||||
$adapter = app(CommonBudget::class);
|
||||
foreach ([$this->r->cost_center_id, $second->id] as $centre) {
|
||||
$this->actingAs($this->finance);
|
||||
$id = $adapter->for($this->finance)->create(['cost_center_id' => $centre, 'year' => (int) now()->year, 'kind' => 'operating', 'includes_tax' => true,
|
||||
'amount_minor' => 20000, 'reason' => 'Dotação sintética do percurso distribuído.']);
|
||||
$this->actingAs($this->admin);
|
||||
$adapter->for($this->admin)->approve($id);
|
||||
}
|
||||
$host = app(RequisitionBudgetDistributions::class);
|
||||
$allocations = array_map(fn ($centre) => ['allocation_key' => (string) Str::uuid(), 'line_id' => $this->item->id, 'centre_id' => $centre,
|
||||
'subtotal_minor' => 5000, 'total_minor' => 5000], [$this->r->cost_center_id, $second->id]);
|
||||
// The approved source is the existing fixture; preparation/submission have their separate native tests.
|
||||
$this->r->forceFill(['budget_distribution_preparation' => ['allocations' => $allocations,
|
||||
'source_revision' => $host->revision($this->r, $host->requestLines($this->r)), 'prepared_by' => $this->owner->id, 'reason' => 'Distribuição da fonte sintética aprovada.']])->save();
|
||||
$this->actingAs($this->finance);
|
||||
DB::transaction(fn () => app(BudgetWorkflow::class)->record($this->finance, $this->r, 'reserve', 10000, 10000));
|
||||
$this->selection['reason'] = 'Confirmação explícita das parcelas da proposta seleccionada.';
|
||||
$this->selection['budget_distribution_preparation'] = array_map(fn ($row) => ['allocation_key' => $row['allocation_key'], 'line_id' => $row['line_id'], 'centre_id' => $row['centre_id'], 'subtotal' => '50.00', 'total' => '50.00'], $allocations);
|
||||
$this->actingAs($this->buyer)->get($this->awardUrl)->assertOk()->assertViewHas('page', fn (array $page) => $page['encryptHistory'] === true);
|
||||
$award = selectPurchaseAward($this);
|
||||
$order = issuePurchaseOrder($this, $award);
|
||||
expect($order->snapshot['budget_control']['phase'])->toBe('commit')
|
||||
->and(DB::table('budget_distribution_entries')->where('kind', 'commit')->count())->toBe(2)
|
||||
->and(DB::table('budget_entries')->where('requisition_id', $this->r->id)->count())->toBe(0);
|
||||
$before = DB::table('budget_distribution_entries')->count();
|
||||
$this->actingAs($this->buyer)->post('/adjudicacoes/'.$award->id.'/emitir')->assertRedirect();
|
||||
expect(DB::table('budget_distribution_entries')->count())->toBe($before)->and(PurchaseOrder::query()->count())->toBe(1);
|
||||
});
|
||||
|
||||
function perOrderAgreement(object $test, ?string $amount = '100.00', ?string $quantity = '1.000', ?string $stockUnit = null): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user