@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Models\CriticalityLevel;
|
||||
use App\Models\Department;
|
||||
use App\Models\Equipment;
|
||||
use App\Models\SupplyRecord;
|
||||
use App\Models\User;
|
||||
use App\Services\CapitalAssignments;
|
||||
use App\Services\CapitalRegister;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
@@ -27,6 +29,72 @@ beforeEach(function () {
|
||||
'reason' => 'Preparação de referência sintética para testes de compras'];
|
||||
});
|
||||
|
||||
test('capital search returns current metadata literal matches pagination and native history links without business writes', function () {
|
||||
$service = app(CapitalRegister::class);
|
||||
$before = [];
|
||||
foreach (['budget_entries', 'stock_movements', 'invoices', 'purchase_orders'] as $table) {
|
||||
$before[$table] = DB::table($table)->orderBy('id')->get()->toJson();
|
||||
}
|
||||
$old = $service->save($this->f['issuer'], [...$this->input, 'name' => 'OLD-CAPITAL-SEARCH']);
|
||||
$current = $service->save($this->f['issuer'], [...$this->input, 'operation_key' => (string) Str::uuid(),
|
||||
'record_key' => $old->record_key, 'version' => 1, 'name' => 'NEW-CAPITAL%_SEARCH', 'state' => 'archived']);
|
||||
$read = function (string $query) {
|
||||
$response = $this->get('/compras/pesquisa?'.$query)->assertOk()
|
||||
->assertHeader('Cache-Control', 'max-age=0, no-store, private');
|
||||
$props = $response->viewData('page')['props'];
|
||||
expect($props['capitalSearchAvailable'])->toBeTrue();
|
||||
expect($props['capitalRegisterAvailable'])->toBeTrue();
|
||||
|
||||
return collect($props['groups'])->firstWhere('key', 'capital')['records'];
|
||||
};
|
||||
expect($read('q=OLD-CAPITAL-SEARCH')['total'])->toBe(0);
|
||||
$literal = $read('q='.urlencode('%_'));
|
||||
expect($literal['total'])->toBe(1)->and($literal['data'][0]['id'])->toBe($current->id)
|
||||
->and($literal['data'][0]['detail'])->toBe('archived')
|
||||
->and($literal['data'][0]['title'])->toContain('NEW-CAPITAL%_SEARCH', 'v2')
|
||||
->and(array_keys($literal['data'][0]))->toBe(['id', 'title', 'detail', 'href'])
|
||||
->and($literal['data'][0]['href'])->toBe('/projectos-imobilizado?history='.$old->record_key);
|
||||
$this->get($literal['data'][0]['href'])->assertOk()->assertInertia(fn (Assert $page) => $page->has('history.data', 2));
|
||||
foreach (range(1, 17) as $index) {
|
||||
$service->save($this->f['issuer'], [...$this->input, 'operation_key' => (string) Str::uuid(), 'code' => 'CAP-PAGE-'.$index]);
|
||||
}
|
||||
$firstPage = $read('q=CAP-PAGE-');
|
||||
expect($firstPage['total'])->toBe(17)->and($firstPage['data'])->toHaveCount(15)
|
||||
->and($firstPage['next_page_url'])->toContain('q=CAP-PAGE-', 'capital_page=2');
|
||||
expect($read('q=CAP-PAGE-&capital_page=2')['data'])->toHaveCount(2);
|
||||
$asset = $service->save($this->f['issuer'], [...$this->input, 'operation_key' => (string) Str::uuid(), 'code' => 'CAP-ASSET', 'type' => 'asset']);
|
||||
expect($read('q=CAP-ASSET')['data'][0]['title'])->toContain('Imobilizado CAP-ASSET');
|
||||
foreach ($before as $table => $rows) {
|
||||
expect(DB::table($table)->orderBy('id')->get()->toJson())->toBe($rows);
|
||||
}
|
||||
$this->getJson('/compras/pesquisa?q=CAP&capital_page=0')->assertUnprocessable();
|
||||
});
|
||||
|
||||
test('capital search retains tenant departmental permission and QA boundaries', function () {
|
||||
$service = app(CapitalRegister::class);
|
||||
$own = $this->f;
|
||||
$service->save($own['issuer'], $this->input);
|
||||
$foreign = receiptFixture();
|
||||
$this->actingAs($foreign['issuer']);
|
||||
expect($service->searchQuery($foreign['issuer'])?->count())->toBe(0)
|
||||
->and($service->searchQuery($own['issuer']))->toBeNull();
|
||||
$this->actingAs($own['issuer']);
|
||||
$department = Department::query()->create(['tenant_id' => $own['tenant']->id, 'code' => 'OTHER-CAP', 'name' => 'Outro departamento QA']);
|
||||
$service->save($own['issuer'], [...$this->input, 'operation_key' => (string) Str::uuid(), 'code' => 'CAP-OTHER', 'department_id' => $department->id]);
|
||||
$head = User::factory()->create(['tenant_id' => $own['tenant']->id, 'department_id' => $own['department']->id]);
|
||||
supplyGrant($head, ['department_head']);
|
||||
$this->actingAs($head);
|
||||
expect($service->searchQuery($head)?->count())->toBe(1);
|
||||
$this->get('/compras/pesquisa?q=CAP-OTHER')->assertOk()->assertViewHas('page', fn (array $page) => collect($page['props']['groups'])->firstWhere('key', 'capital')['records']['total'] === 0);
|
||||
DB::table('organization_profiles')->whereIn('id', DB::table('organization_memberships')->where('user_id', $head->id)->pluck('profile_id'))
|
||||
->update(['permissions' => json_encode(['requester'])]);
|
||||
$this->get('/compras/pesquisa?q=PRJ')->assertInertia(fn (Assert $page) => $page->where('capitalSearchAvailable', false)->where('capitalRegisterAvailable', false)
|
||||
->where('groups', fn ($groups) => ! collect($groups)->contains('key', 'capital')));
|
||||
config(['capital-register.qa_enabled' => false]);
|
||||
supplyGrant($own['issuer'], ['procurement']);
|
||||
$this->actingAs($own['issuer'])->get('/compras/pesquisa?q=PRJ')->assertInertia(fn (Assert $page) => $page->where('capitalSearchAvailable', false));
|
||||
});
|
||||
|
||||
test('own project register versions preserves identity and replay without financial or stock effects', function () {
|
||||
$service = app(CapitalRegister::class);
|
||||
$before = [];
|
||||
|
||||
@@ -53,11 +53,41 @@ test('direction release preserves declarations applies to the complete correctio
|
||||
->and(ConflictRelease::query()->count())->toBe(1)
|
||||
->and(AuditLog::query()->where('action', 'conflict.release_authorised')->count())->toBe(1);
|
||||
$this->get('/conflitos/'.$root->id)->assertInertia(fn (Assert $page) => $page->where('canAuthoriseRelease', false)->where('release.declaration_id', $latest->id));
|
||||
$this->get('/conflitos')->assertInertia(fn (Assert $page) => $page->where('releasedRoots', [$root->id])->where('declarations.data.0.has_conflict', true));
|
||||
$this->actingAs($this->owner)->get('/conflitos')->assertForbidden();
|
||||
$this->actingAs($this->admin);
|
||||
$this->post('/conflitos/'.$latest->id.'/levantamento', [...$input, 'reason' => 'Alteração indevida do fundamento após decisão.'])->assertConflict();
|
||||
ConflictDeclaration::query()->create([...$root->only(['tenant_id', 'user_id', 'supplier_id', 'requisition_id', 'has_conflict', 'known_since', 'reason']), 'declared_at' => now()]);
|
||||
expect($guard->hasConflict($this->buyer->id, $this->supplier->id, $this->r->id))->toBeTrue();
|
||||
});
|
||||
|
||||
test('release consultation is limited to the roots on the visible declaration page', function () {
|
||||
config(['conflict-releases.qa_enabled' => true]);
|
||||
for ($index = 0; $index < 16; $index++) {
|
||||
$this->post('/conflitos', personalConflict($this->supplier->id))->assertSessionHasNoErrors();
|
||||
}
|
||||
$first = ConflictDeclaration::query()->oldest('id')->firstOrFail();
|
||||
$last = ConflictDeclaration::query()->latest('id')->firstOrFail();
|
||||
$this->actingAs($this->owner)->post('/conflitos', personalConflict($this->supplier->id))->assertSessionHasNoErrors();
|
||||
$other = ConflictDeclaration::query()->latest('id')->firstOrFail();
|
||||
$profile = DB::table('organization_profiles')->insertGetId(['tenant_id' => $this->tenant->id, 'name' => 'Compras exclusivamente sintéticas',
|
||||
'permissions' => json_encode(['procurement']), 'version' => 1, 'created_at' => now(), 'updated_at' => now()]);
|
||||
DB::table('organization_memberships')->insert(['tenant_id' => $this->tenant->id, 'user_id' => $this->buyer->id,
|
||||
'profile_id' => $profile, 'maintenance' => false, 'created_at' => now(), 'updated_at' => now()]);
|
||||
configureConflictDirection($this->admin);
|
||||
$this->actingAs($this->admin);
|
||||
foreach ([$first, $last, $other] as $row) {
|
||||
$this->post('/conflitos/'.$row->id.'/levantamento', ['operation_key' => (string) Str::uuid(),
|
||||
'reason' => 'Decisão exclusivamente sintética para conferir a consulta paginada.'])->assertSessionHasNoErrors();
|
||||
}
|
||||
$originals = ConflictDeclaration::query()->orderBy('id')->get()->toJson();
|
||||
$auditCount = AuditLog::query()->count();
|
||||
$this->actingAs($this->buyer)->get('/conflitos')->assertOk()->assertInertia(fn (Assert $page) => $page->has('declarations.data', 15)->where('releasedRoots', [$last->id]));
|
||||
$this->get('/conflitos?page=2')->assertOk()->assertInertia(fn (Assert $page) => $page->has('declarations.data', 1)->where('releasedRoots', [$first->id]));
|
||||
expect(ConflictDeclaration::query()->orderBy('id')->get()->toJson())->toBe($originals)
|
||||
->and(AuditLog::query()->count())->toBe($auditCount);
|
||||
});
|
||||
|
||||
test('direction authority is current scoped and never inherited from admin or finance', function () {
|
||||
config(['conflict-releases.qa_enabled' => true]);
|
||||
$this->post('/conflitos', personalConflict($this->supplier->id))->assertSessionHasNoErrors();
|
||||
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
require_once __DIR__.'/../Support/ReceiptFixture.php';
|
||||
require_once __DIR__.'/../Support/SupplyFixture.php';
|
||||
@@ -83,3 +84,97 @@ test('an unknown edition never inherits parameters from its title or citation',
|
||||
'snapshot' => ['evidence' => ['sha256' => hash('sha256', 'different edition')]]]);
|
||||
expect(app(ImportLegalReferenceDrafts::class)->forSource($source))->toBe([]);
|
||||
});
|
||||
|
||||
test('the documentary VAT rate requires explicit classification and valuation before a draft can be saved', function () {
|
||||
$path = 'C:/Mac/Home/Documents/TEMPO/Portal Tempo/Legislacao/alteracao CIVA 2023.pdf';
|
||||
if (! is_file($path)) {
|
||||
test()->markTestSkipped('The supplied BR250 edition is required for this real-source integration.');
|
||||
}
|
||||
expect(hash_file('sha256', $path))->toBe(ImportLegalReferenceDrafts::VAT_EDITION_SHA256);
|
||||
$before = [];
|
||||
foreach (['budget_entries', 'stock_movements', 'purchase_orders', 'invoices'] as $table) {
|
||||
$before[$table] = DB::table($table)->orderBy('id')->get()->toJson();
|
||||
}
|
||||
$service = app(ImportLegalRules::class);
|
||||
$source = $service->save($this->f['issuer'], ['operation_key' => (string) Str::uuid(), 'action' => 'source', 'version' => 0,
|
||||
'official_reference' => 'Lei 22/2022; BR I Série250, 28/12/2022, exemplar partilhado',
|
||||
'reason' => 'Exemplar partilhado copiado apenas para QA sintético, sem publicação de taxa.'],
|
||||
new UploadedFile($path, basename($path), 'application/pdf', UPLOAD_ERR_OK, true));
|
||||
$drafts = $service->workspace($this->f['issuer'], $this->f['r'])['referenceDrafts'];
|
||||
expect($drafts)->toHaveCount(1);
|
||||
$draft = $drafts[0];
|
||||
expect($draft['match_code'])->toBe('')->and($draft['suggested_code'])->toBe('')
|
||||
->and($draft['valid_from'])->toBe('2023-01-01')->and($draft['valid_until'])->toBeNull()
|
||||
->and($draft['citation'])->toContain('2238', '2239')->and($draft['charges'][0]['kind'])->toBe('vat')
|
||||
->and($draft['charges'][0]['rate_percent'])->toBe('16')->and($draft['charges'][0]['basis_reference'])->toBe('')
|
||||
->and(array_column(array_slice($draft['charges'], 1), 'method'))->toBe(['unknown', 'unknown', 'unknown']);
|
||||
$input = [...array_intersect_key($draft, array_flip(['source_id', 'title', 'official_reference', 'official_url', 'citation', 'valid_from', 'valid_until', 'obligations', 'charges', 'match_code', 'suggested_code'])),
|
||||
'operation_key' => (string) Str::uuid(), 'record_key' => null, 'version' => 0, 'action' => 'save',
|
||||
'document_types' => [], 'reason' => 'Preparação exclusivamente sintética para conferir os parâmetros explícitos.'];
|
||||
expect(fn () => $service->save($this->f['issuer'], $input))->toThrow(ValidationException::class);
|
||||
$input['match_code'] = $input['suggested_code'] = 'SYNTHETIC-VAT-QA';
|
||||
expect(fn () => $service->save($this->f['issuer'], $input))->toThrow(ValidationException::class);
|
||||
expect(SupplyRecord::query()->where('kind', 'import_legal_rule')->count())->toBe(0);
|
||||
$input['charges'][0]['basis_reference'] = 'Base declarada exclusivamente sintética de100MZN; não representa valoração de uma importação real.';
|
||||
$saved = $service->save($this->f['issuer'], $input);
|
||||
expect($saved->state)->toBe('draft')->and($saved->data['charges'][0]['rate_percent'])->toBe('16.000000')
|
||||
->and($saved->data['match_code'])->toBe('SYNTHETIC-VAT-QA');
|
||||
$estimate = app(ImportLegalAmounts::class)->calculate($saved->data['charges'], ['vat_normal_documentary' => [
|
||||
'value_minor' => 10000, 'quantity' => null, 'quantity_unit' => null, 'source' => 'Synthetic illustrative base, not a real assessment']]);
|
||||
expect($estimate['known_subtotal_minor'])->toBe(1600)->and($estimate['complete'])->toBeFalse()
|
||||
->and($estimate['total_minor'])->toBeNull()->and($estimate['financial_effects'])->toBeFalse();
|
||||
foreach ($before as $table => $rows) {
|
||||
expect(DB::table($table)->orderBy('id')->get()->toJson())->toBe($rows);
|
||||
}
|
||||
Storage::disk('local')->put($source->snapshot['evidence']['path'], 'ALTERED-QA-VAT-COPY');
|
||||
$workspace = $service->workspace($this->f['issuer'], $this->f['r']);
|
||||
expect($workspace['referenceDrafts'])->toBe([])->and($workspace['referenceDraftWarnings'])->toHaveCount(1)
|
||||
->and(hash_file('sha256', $path))->toBe(ImportLegalReferenceDrafts::VAT_EDITION_SHA256);
|
||||
});
|
||||
|
||||
test('the official second supplement supplies only its eleven ICE positions and explicit two-year period', function () {
|
||||
$path = base_path('tmp/pdfs/import-legal-source-review-20261128/law7-2025-official-second-supplement.pdf');
|
||||
if (! is_file($path)) {
|
||||
test()->markTestSkipped('The separately retained official second supplement is required.');
|
||||
}
|
||||
expect(hash_file('sha256', $path))->toBe(ImportLegalReferenceDrafts::ICE_EDITION_SHA256);
|
||||
$service = app(ImportLegalRules::class);
|
||||
$source = $service->save($this->f['issuer'], ['operation_key' => (string) Str::uuid(), 'action' => 'source', 'version' => 0,
|
||||
'official_reference' => 'Lei 7/2025, BR I Série 248, 2.º suplemento, 2180-(21 a 22)',
|
||||
'reason' => 'Official original used only in disposable synthetic QA; no rule activation.'],
|
||||
new UploadedFile($path, basename($path), 'application/pdf', UPLOAD_ERR_OK, true));
|
||||
$before = [];
|
||||
foreach (['budget_entries', 'stock_movements', 'purchase_orders', 'invoices'] as $table) {
|
||||
$before[$table] = DB::table($table)->orderBy('id')->get()->toJson();
|
||||
}
|
||||
$drafts = $service->workspace($this->f['issuer'], $this->f['r'])['referenceDrafts'];
|
||||
$expected = ['8702.10.10' => '20', '8702.10.20' => '25', '8702.20.00' => '20', '8702.30.00' => '20',
|
||||
'8702.40.10' => '0', '8702.40.20' => '0', '8702.90.10' => '20', '8702.90.20' => '25', '8702.90.90' => '0',
|
||||
'8703.80.10' => '5', '8703.80.20' => '15'];
|
||||
expect(array_column($drafts, 'rate_percent', 'code'))->toBe($expected);
|
||||
foreach ($drafts as $draft) {
|
||||
expect($draft['valid_from'])->toBe('2026-01-01')->and($draft['valid_until'])->toBe('2027-12-31')
|
||||
->and($draft['source_id'])->toBe($source->id)->and($draft['source_sha256'])->toBe(ImportLegalReferenceDrafts::ICE_EDITION_SHA256)
|
||||
->and($draft['citation'])->toContain('2.º suplemento', '2180-(22)', $draft['code'])
|
||||
->and($draft['charges'][0]['kind'])->toBe('ice')->and($draft['charges'][0]['rate_percent'])->toBe($expected[$draft['code']])
|
||||
->and(array_column(array_slice($draft['charges'], 1), 'method'))->toBe(['unknown', 'unknown', 'unknown']);
|
||||
$estimate = app(ImportLegalAmounts::class)->calculate($draft['charges'], ['ice_documentary' => [
|
||||
'value_minor' => 10000, 'quantity' => null, 'quantity_unit' => null, 'source' => 'Synthetic 100 MZN illustrative base only']]);
|
||||
expect($estimate['known_subtotal_minor'])->toBe(((int) $expected[$draft['code']]) * 100)
|
||||
->and($estimate['complete'])->toBeFalse()->and($estimate['total_minor'])->toBeNull()->and($estimate['financial_effects'])->toBeFalse();
|
||||
}
|
||||
expect(SupplyRecord::query()->where('kind', 'import_legal_rule')->count())->toBe(0);
|
||||
$draft = collect($drafts)->firstWhere('code', '8703.80.10');
|
||||
$saved = $service->save($this->f['issuer'], [...array_intersect_key($draft, array_flip(['source_id', 'title', 'official_reference', 'official_url', 'citation', 'valid_from', 'valid_until', 'obligations', 'charges'])),
|
||||
'operation_key' => (string) Str::uuid(), 'record_key' => null, 'version' => 0, 'action' => 'save',
|
||||
'match_code' => $draft['code'], 'suggested_code' => $draft['code'], 'document_types' => [],
|
||||
'reason' => 'Explicit synthetic QA preparation of documentary ICE; not publication.']);
|
||||
expect($saved->state)->toBe('draft')->and($saved->data['valid_until'])->toBe('2027-12-31')
|
||||
->and($saved->data['charges'][0]['rate_percent'])->toBe('5.000000');
|
||||
foreach ($before as $table => $rows) {
|
||||
expect(DB::table($table)->orderBy('id')->get()->toJson())->toBe($rows);
|
||||
}
|
||||
Storage::disk('local')->put($source->snapshot['evidence']['path'], 'ALTERED-QA-SECOND-SUPPLEMENT');
|
||||
$workspace = $service->workspace($this->f['issuer'], $this->f['r']);
|
||||
expect($workspace['referenceDrafts'])->toBe([])->and($workspace['referenceDraftWarnings'])->toHaveCount(1);
|
||||
});
|
||||
|
||||
@@ -26,6 +26,80 @@ beforeEach(function () {
|
||||
$this->actingAs($this->admin);
|
||||
});
|
||||
|
||||
test('operational order search retains literal matching pagination and opens the selected native source beyond the first page', function () {
|
||||
config(['operational-orders.qa_enabled' => true]);
|
||||
$service = app(OperationalOrders::class);
|
||||
$service->configure($this->admin, $this->policy);
|
||||
$this->actingAs($this->f['issuer']);
|
||||
$before = [];
|
||||
foreach (['budget_entries', 'stock_movements', 'invoices', 'purchase_orders'] as $table) {
|
||||
$before[$table] = DB::table($table)->orderBy('id')->get()->toJson();
|
||||
}
|
||||
$old = $service->save($this->f['issuer'], [...$this->input, 'reference' => 'OP-FOUND-OLD']);
|
||||
foreach (range(1, 17) as $index) {
|
||||
$service->save($this->f['issuer'], [...$this->input, 'operation_key' => (string) Str::uuid(), 'reference' => 'OP-PAGE-'.$index]);
|
||||
}
|
||||
$literal = $service->save($this->f['issuer'], [...$this->input, 'operation_key' => (string) Str::uuid(), 'reference' => 'OP%_LITERAL']);
|
||||
$sourceRows = SupplyRecord::query()->where('kind', 'op_order')->orderBy('id')->get()->toJson();
|
||||
$read = function (string $query) {
|
||||
$response = $this->get('/compras/pesquisa?'.$query)->assertOk()->assertHeader('Cache-Control', 'max-age=0, no-store, private');
|
||||
$props = $response->viewData('page')['props'];
|
||||
expect($props['operationalOrderSearchAvailable'])->toBeTrue();
|
||||
|
||||
return collect($props['groups'])->firstWhere('key', 'operational_orders')['records'];
|
||||
};
|
||||
$page = $read('q=OP-PAGE-');
|
||||
expect($page['total'])->toBe(17)->and($page['data'])->toHaveCount(15)
|
||||
->and($page['next_page_url'])->toContain('q=OP-PAGE-', 'operational_orders_page=2');
|
||||
expect($read('q=OP-PAGE-&operational_orders_page=2')['data'])->toHaveCount(2);
|
||||
$match = $read('q='.urlencode('%_'));
|
||||
expect($match['total'])->toBe(1)->and($match['data'][0]['id'])->toBe($literal->id)
|
||||
->and($match['data'][0]['detail'])->toBe('recorded')->and($match['data'][0]['title'])->toContain('Produção OP%_LITERAL', 'v1')
|
||||
->and(array_keys($match['data'][0]))->toBe(['id', 'title', 'detail', 'href']);
|
||||
$oldMatch = $read('q=OP-FOUND-OLD')['data'][0];
|
||||
expect($oldMatch['href'])->toBe('/ordens-operacionais?order_id='.$old->id.'#op-order-'.$old->id);
|
||||
$this->get($oldMatch['href'])->assertOk()->assertInertia(fn (Assert $page) => $page->has('orders.data', 1)
|
||||
->where('orders.data.0.id', $old->id)->where('selectedOrderId', $old->id));
|
||||
$this->get('/ordens-operacionais?order_id='.$old->id.'&page=999')->assertOk()->assertInertia(fn (Assert $page) => $page
|
||||
->where('orders.current_page', 1)->has('orders.data', 1)->where('orders.data.0.id', $old->id));
|
||||
$this->get('/ordens-operacionais')->assertOk()->assertInertia(fn (Assert $page) => $page->has('orders.data', 15)->where('selectedOrderId', null));
|
||||
$this->getJson('/compras/pesquisa?q=OP&operational_orders_page=0')->assertUnprocessable();
|
||||
$this->getJson('/ordens-operacionais?order_id=0')->assertUnprocessable();
|
||||
expect(SupplyRecord::query()->where('kind', 'op_order')->orderBy('id')->get()->toJson())->toBe($sourceRows);
|
||||
foreach ($before as $table => $rows) {
|
||||
expect(DB::table($table)->orderBy('id')->get()->toJson())->toBe($rows);
|
||||
}
|
||||
});
|
||||
|
||||
test('operational order search and direct source selection retain native departmental tenant and current capability boundaries', function () {
|
||||
config(['operational-orders.qa_enabled' => true]);
|
||||
$service = app(OperationalOrders::class);
|
||||
$service->configure($this->admin, $this->policy);
|
||||
supplyGrant($this->f['issuer'], ['procurement']);
|
||||
$this->actingAs($this->f['issuer']);
|
||||
$own = $service->save($this->f['issuer'], $this->input);
|
||||
$department = Department::query()->create(['tenant_id' => $this->f['tenant']->id, 'code' => 'OP-OTHER', 'name' => 'Outro departamento sintético']);
|
||||
$other = $service->save($this->f['issuer'], [...$this->input, 'operation_key' => (string) Str::uuid(), 'department_id' => $department->id, 'reference' => 'OP-OTHER-SECRET']);
|
||||
$viewer = User::factory()->create(['tenant_id' => $this->f['tenant']->id, 'department_id' => $this->f['department']->id]);
|
||||
supplyGrant($viewer, ['production_order_prepare']);
|
||||
$this->actingAs($viewer);
|
||||
expect($service->searchQuery($viewer)?->pluck('id')->all())->toBe([$own->id]);
|
||||
$this->get('/compras/pesquisa?q=OP-OTHER-SECRET')->assertOk()->assertViewHas('page', fn (array $page) => collect($page['props']['groups'])->firstWhere('key', 'operational_orders')['records']['total'] === 0);
|
||||
$this->get('/ordens-operacionais?order_id='.$other->id)->assertNotFound();
|
||||
$this->get('/ordens-operacionais?order_id='.$own->id)->assertOk();
|
||||
DB::table('organization_profiles')->whereIn('id', DB::table('organization_memberships')->where('user_id', $viewer->id)->pluck('profile_id'))
|
||||
->update(['permissions' => json_encode(['finance'])]);
|
||||
$this->get('/compras/pesquisa?q=OP')->assertInertia(fn (Assert $page) => $page->where('operationalOrderSearchAvailable', false)
|
||||
->where('groups', fn ($groups) => ! collect($groups)->contains('key', 'operational_orders')));
|
||||
$this->get('/ordens-operacionais?order_id='.$own->id)->assertForbidden();
|
||||
$foreign = receiptFixture();
|
||||
$this->actingAs($foreign['issuer']);
|
||||
expect($service->searchQuery($foreign['issuer'])?->count())->toBe(0)->and($service->searchQuery($this->f['issuer']))->toBeNull();
|
||||
$this->get('/ordens-operacionais?order_id='.$own->id)->assertNotFound();
|
||||
config(['operational-orders.qa_enabled' => false]);
|
||||
expect($service->searchQuery($foreign['issuer']))->toBeNull();
|
||||
});
|
||||
|
||||
test('operational register requires explicit origin mode preserves sources and has no financial or stock effects', function () {
|
||||
$this->get('/ordens-operacionais')->assertStatus(503);
|
||||
config(['operational-orders.qa_enabled' => true]);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\PurchasingRole;
|
||||
use App\Models\User;
|
||||
use App\Services\ReceiptWorkflow;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
|
||||
require_once __DIR__.'/../Support/ReceiptFixture.php';
|
||||
|
||||
test('order and receipt consultations link the exact authorised financial context without business effects', function () {
|
||||
$f = receiptFixture('1.000');
|
||||
$finance = User::factory()->create(['tenant_id' => $f['tenant']->id, 'department_id' => $f['department']->id, 'purchasing_role' => PurchasingRole::Finance]);
|
||||
$receipt = app(ReceiptWorkflow::class)->confirm($f['receiver'], $f['order'], receiptPayload($f));
|
||||
$before = [];
|
||||
foreach (['purchase_orders', 'purchase_order_items', 'invoices', 'external_payments', 'stock_movements', 'budget_entries', 'audit_logs'] as $table) {
|
||||
$before[$table] = DB::table($table)->orderBy('id')->get()->toJson();
|
||||
}
|
||||
$href = '/facturas?purchase_order_id='.$f['order']->id.'#invoice-documents';
|
||||
$this->actingAs($finance)->get('/ordens/'.$f['order']->id)->assertOk()
|
||||
->assertViewHas('page', fn ($page) => $page['encryptHistory'] === true)->assertInertia(fn (Assert $p) => $p
|
||||
->component('purchases/show')->where('financialDocumentsHref', $href)
|
||||
->has('relatedProcesses', 1)->where('relatedProcesses.0.id', $f['r']->id)
|
||||
->where('relatedProcesses.0.href', '/requisicoes/'.$f['r']->id.'/processo'));
|
||||
$this->get('/ordens/'.$f['order']->id.'/recepcoes')->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->component('receipts/order')->where('financialDocumentsHref', $href));
|
||||
$this->get('/recepcoes/'.$receipt->id)->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->component('receipts/show')->where('financialDocumentsHref', $href));
|
||||
$this->get($href)->assertOk()->assertInertia(fn (Assert $p) => $p->where('focusOrderId', $f['order']->id));
|
||||
foreach ($before as $table => $rows) {
|
||||
expect(DB::table($table)->orderBy('id')->get()->toJson())->toBe($rows);
|
||||
}
|
||||
});
|
||||
|
||||
test('context links do not grant procurement warehouse or foreign identities access to financial documents', function () {
|
||||
$f = receiptFixture();
|
||||
$receipt = app(ReceiptWorkflow::class)->confirm($f['receiver'], $f['order'], receiptPayload($f));
|
||||
$this->actingAs($f['issuer'])->get('/ordens/'.$f['order']->id)->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->where('financialDocumentsHref', null)->has('relatedProcesses', 1));
|
||||
$this->get('/facturas?purchase_order_id='.$f['order']->id)->assertForbidden();
|
||||
$this->actingAs($f['receiver'])->get('/ordens/'.$f['order']->id.'/recepcoes')->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->where('financialDocumentsHref', null));
|
||||
$this->get('/recepcoes/'.$receipt->id)->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->where('financialDocumentsHref', null));
|
||||
$this->get('/facturas?purchase_order_id='.$f['order']->id)->assertForbidden();
|
||||
$foreign = receiptFixture();
|
||||
$other = User::factory()->create(['tenant_id' => $foreign['tenant']->id, 'purchasing_role' => PurchasingRole::Finance]);
|
||||
$this->actingAs($other)->get('/ordens/'.$f['order']->id)->assertNotFound();
|
||||
$this->get('/recepcoes/'.$receipt->id)->assertNotFound();
|
||||
$this->getJson('/facturas?purchase_order_id='.$f['order']->id)->assertUnprocessable();
|
||||
});
|
||||
|
||||
test('print navigation leaves Inertia only after checking the current order access', function () {
|
||||
$f = receiptFixture();
|
||||
$page = $this->actingAs($f['issuer'])->get('/ordens/'.$f['order']->id)->assertOk()->viewData('page');
|
||||
$headers = ['X-Inertia' => 'true'];
|
||||
if ($page['version'] !== null) {
|
||||
$headers['X-Inertia-Version'] = $page['version'];
|
||||
}
|
||||
$route = '/ordens/'.$f['order']->id.'/imprimir';
|
||||
$this->get($route, $headers)->assertStatus(409)->assertHeader('X-Inertia-Location', $route);
|
||||
$this->get($route)->assertOk()->assertSee($f['order']->number);
|
||||
$this->actingAs($f['receiver'])->get($route, $headers)->assertForbidden()->assertHeaderMissing('X-Inertia-Location');
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\PurchasingRole;
|
||||
use App\Models\AuditLog;
|
||||
use App\Models\PrivateAuditExport;
|
||||
use App\Models\SupplierDocument;
|
||||
use App\Models\User;
|
||||
@@ -46,6 +47,11 @@ afterEach(function () {
|
||||
|
||||
test('private audit creates a verified immutable package and replays without duplicating or changing business facts', function () {
|
||||
$before = DB::table('purchase_orders')->orderBy('id')->get()->toJson();
|
||||
foreach (['supplier_evaluation.approved', 'supplier_improvement.closed', 'supplier_response.decided', 'supplier.bank_viewed',
|
||||
'planning.created', 'order_cancellation.approved', 'warehouse_return.confirmed'] as $action) {
|
||||
AuditLog::query()->create(['tenant_id' => $this->actor->tenant_id, 'user_id' => $this->actor->id, 'action' => $action,
|
||||
'after' => ['evidence' => 'SYNTHETIC-EVENT-PAYLOAD-NOT-EXPORTED'], 'created_at' => now()]);
|
||||
}
|
||||
$input = ['operation_key' => (string) Str::uuid(), 'families' => ['configuration', 'purchasing', 'stock', 'finance'], 'purpose' => 'Synthetic QA audit'];
|
||||
$service = app(PrivateAuditExporter::class);
|
||||
$export = $service->generate($this->actor, $input);
|
||||
@@ -55,6 +61,12 @@ test('private audit creates a verified immutable package and replays without dup
|
||||
try {
|
||||
$manifest = json_decode($zip->getFromName('manifesto.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
expect($manifest['families'])->toHaveCount(4);
|
||||
$events = $zip->getFromName('dados/purchasing/eventos.ndjson');
|
||||
expect($events)->toBeString()->toContain('supplier_evaluation.approved')->toContain('supplier_improvement.closed')->toContain('supplier_response.decided')
|
||||
->toContain('planning.created')->toContain('order_cancellation.approved')
|
||||
->not->toContain('warehouse_return.confirmed')->not->toContain('supplier.bank_viewed')->not->toContain('SYNTHETIC-EVENT-PAYLOAD-NOT-EXPORTED');
|
||||
expect($zip->getFromName('dados/stock/eventos.ndjson'))->toContain('warehouse_return.confirmed')
|
||||
->not->toContain('planning.created')->not->toContain('order_cancellation.approved');
|
||||
foreach ($manifest['datasets'] as $dataset) {
|
||||
if ($dataset['state'] === 'not_installed') {
|
||||
expect($dataset['records'])->toBeNull();
|
||||
|
||||
@@ -101,6 +101,57 @@ test('private audit preserves ordinary data while excluding bank coordinates cre
|
||||
expect($event)->toHaveKey('after_projected')->not->toHaveKey('after');
|
||||
});
|
||||
|
||||
test('purchasing audit includes supplier follow up events without bank events or foreign company history', function () {
|
||||
$included = ['supplier.created', 'supplier.updated', 'supplier.reviewed', 'supplier.document_uploaded', 'supplier.document_downloaded',
|
||||
'supplier_evaluation.approved', 'supplier_improvement.closed', 'supplier_response.decided'];
|
||||
$excluded = ['supplier.bank_viewed', 'supplier.bank_proposed', 'supplier.bank_approved', 'supplier.bank_rejected', 'supplier.future_private_action'];
|
||||
$foreign = Tenant::query()->create(['name' => 'FOREIGN-SUPPLIER-AUDIT']);
|
||||
$foreignActor = User::factory()->create(['tenant_id' => $foreign->id]);
|
||||
foreach ([...$included, ...$excluded] as $action) {
|
||||
AuditLog::query()->create(['tenant_id' => $this->actor->tenant_id, 'user_id' => $this->actor->id,
|
||||
'action' => $action, 'after' => ['evidence' => 'SYNTHETIC-PRIVATE-PAYLOAD'], 'created_at' => now()]);
|
||||
AuditLog::query()->create(['tenant_id' => $foreign->id, 'user_id' => $foreignActor->id, 'action' => $action,
|
||||
'after' => ['evidence' => 'FOREIGN-SYNTHETIC-PRIVATE-PAYLOAD'], 'created_at' => now()]);
|
||||
}
|
||||
$before = DB::table('audit_logs')->orderBy('id')->get()->toJson();
|
||||
$sources = collectedPrivateAuditSources($this->actor, ['purchasing']);
|
||||
$events = $sources['purchasing:audit_logs']['rows'];
|
||||
foreach ($included as $action) {
|
||||
$matches = array_values(array_filter($events, fn ($row) => $row['action'] === $action));
|
||||
expect($matches)->toHaveCount(1)
|
||||
->and((int) $matches[0]['tenant_id'])->toBe($this->actor->tenant_id)
|
||||
->and($matches[0])->not->toHaveKey('after')->not->toHaveKey('before');
|
||||
}
|
||||
expect(array_column($events, 'action'))->not->toContain(...$excluded)
|
||||
->and(json_encode($events, JSON_THROW_ON_ERROR))->not->toContain('SYNTHETIC-PRIVATE-PAYLOAD')
|
||||
->and(DB::table('audit_logs')->orderBy('id')->get()->toJson())->toBe($before);
|
||||
foreach (['stock', 'finance', 'configuration'] as $family) {
|
||||
$other = collectedPrivateAuditSources($this->actor, [$family]);
|
||||
expect(array_column($other[$family.':audit_logs']['rows'], 'action'))->not->toContain(...$included);
|
||||
}
|
||||
});
|
||||
|
||||
test('audit links planning cancellation and warehouse return events to their own source family', function () {
|
||||
$families = ['purchasing' => ['planning.created', 'planning.linked', 'purchase_control.approved', 'cancellation.approved',
|
||||
'order_cancellation.approved', 'order_cancellation_policy.approved'],
|
||||
'stock' => ['warehouse_return.prepared', 'warehouse_return.confirmed', 'warehouse_return.cancelled']];
|
||||
foreach ($families as $actions) {
|
||||
foreach ($actions as $action) {
|
||||
AuditLog::query()->create(['tenant_id' => $this->actor->tenant_id, 'user_id' => $this->actor->id,
|
||||
'action' => $action, 'after' => ['synthetic' => true], 'created_at' => now()]);
|
||||
}
|
||||
}
|
||||
$before = DB::table('audit_logs')->orderBy('id')->get()->toJson();
|
||||
$sources = collectedPrivateAuditSources($this->actor, ['purchasing', 'stock', 'finance', 'configuration']);
|
||||
foreach ($families as $family => $actions) {
|
||||
expect(array_column($sources[$family.':audit_logs']['rows'], 'action'))->toContain(...$actions);
|
||||
foreach (array_diff(['purchasing', 'stock', 'finance', 'configuration'], [$family]) as $other) {
|
||||
expect(array_column($sources[$other.':audit_logs']['rows'], 'action'))->not->toContain(...$actions);
|
||||
}
|
||||
}
|
||||
expect(DB::table('audit_logs')->orderBy('id')->get()->toJson())->toBe($before);
|
||||
});
|
||||
|
||||
test('private audit exposes installed empty data separately from uninstalled optional common sources without calculations or writes', function () {
|
||||
$before = [];
|
||||
foreach (['budget_entries', 'stock_movements', 'external_payments', 'invoices', 'purchase_orders', 'audit_logs'] as $table) {
|
||||
|
||||
@@ -340,11 +340,33 @@ test('a partial native order retains its confirmed imported item classification
|
||||
->and(StockMovement::query()->count())->toBe(1)->and((int) StockMovement::query()->sum('quantity_milli'))->toBe(400);
|
||||
});
|
||||
|
||||
test('ordinary controlled order preserves the common budget confirmation and its original on replay', function () {
|
||||
$adapter = app(CommonBudget::class);
|
||||
$this->actingAs($this->finance);
|
||||
$id = $adapter->for($this->finance)->create(['cost_center_id' => $this->r->cost_center_id, 'year' => (int) now()->year,
|
||||
'kind' => 'operating', 'includes_tax' => true, 'amount_minor' => 20000, 'reason' => 'Dotação exclusivamente sintética para conferir o documento de emissão.']);
|
||||
$this->actingAs($this->admin);
|
||||
$adapter->for($this->admin)->approve($id);
|
||||
$this->actingAs($this->finance);
|
||||
DB::transaction(fn () => app(BudgetWorkflow::class)->record($this->finance, $this->r, 'reserve', 10000, 10000));
|
||||
$this->actingAs($this->buyer);
|
||||
$award = selectPurchaseAward($this);
|
||||
$order = issuePurchaseOrder($this, $award);
|
||||
expect($order->snapshot['budget_checked'])->toBeTrue()->and($order->snapshot['budget_control']['budget_id'])->toBe($id);
|
||||
$original = $order->snapshot;
|
||||
$entries = DB::table('budget_entries')->count();
|
||||
$this->post('/adjudicacoes/'.$award->id.'/emitir')->assertRedirect();
|
||||
expect($order->fresh()->snapshot)->toBe($original)->and(DB::table('budget_entries')->count())->toBe($entries);
|
||||
$this->get('/ordens/'.$order->id.'/imprimir')->assertOk()->assertSee('Controlo orçamental registado na emissão.');
|
||||
});
|
||||
|
||||
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();
|
||||
if (! DB::getSchemaBuilder()->hasTable('budget_distributions')) {
|
||||
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']);
|
||||
@@ -370,6 +392,7 @@ test('distributed approved synthetic requisition follows native adjudication app
|
||||
$award = selectPurchaseAward($this);
|
||||
$order = issuePurchaseOrder($this, $award);
|
||||
expect($order->snapshot['budget_control']['phase'])->toBe('commit')
|
||||
->and($order->snapshot['budget_checked'])->toBeTrue()
|
||||
->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();
|
||||
|
||||
@@ -350,7 +350,8 @@ test('native office purchase reconciles declared accounts through receipt invoic
|
||||
$this->actingAs($buyer)->postJson('/adjudicacoes/'.$award->id.'/emitir')->assertRedirect();
|
||||
$this->postJson('/adjudicacoes/'.$award->id.'/emitir')->assertRedirect();
|
||||
$order = PurchaseOrder::query()->where('purchase_award_id', $award->id)->sole();
|
||||
expect($order->total_minor)->toBe(10000)->and($order->snapshot['account_assignments'][$line->id]['data']['allocations'][0]['account']['id'])->toBe($account['id']);
|
||||
expect($order->total_minor)->toBe(10000)->and($order->snapshot['budget_checked'])->toBeTrue()
|
||||
->and($order->snapshot['account_assignments'][$line->id]['data']['allocations'][0]['account']['id'])->toBe($account['id']);
|
||||
$receiver = $this->f['receiver'];
|
||||
$this->actingAs($receiver);
|
||||
$stock = StockItem::query()->create(['tenant_id' => $tenant, 'created_by' => $receiver->id, 'code' => 'OFFICE-FLOW-QA',
|
||||
|
||||
@@ -102,14 +102,28 @@ test('insufficient evidence remains explicit and needs correction before indepen
|
||||
expect(AuditLog::query()->where('action', 'supplier_evaluation.return')->sole()->after['review_reason'])->toContain('Completar');
|
||||
});
|
||||
|
||||
test('approved report keeps its reviewer identity when the selected history page is empty', function () {
|
||||
$evaluation = submittedEvaluation($this);
|
||||
$this->actingAs($this->reviewer)->post('/fornecedores/avaliacoes/'.$evaluation->id.'/approve', [
|
||||
'version' => 2, 'reason' => 'Revisão independente com identidade preservada no relatório.',
|
||||
])->assertRedirect();
|
||||
$before = DB::table('audit_logs')->orderBy('id')->get()->toJson();
|
||||
$this->actingAs($this->f['issuer'])->get('/fornecedores/avaliacoes/'.$evaluation->id.'/relatorio?history_page=99')
|
||||
->assertOk()->assertInertia(fn (Assert $p) => $p->where('reportOnly', true)
|
||||
->where('evaluation.reviewed_by', $this->reviewer->id)
|
||||
->where('people.'.$this->reviewer->id, $this->reviewer->name)->has('history.data', 0));
|
||||
expect(DB::table('audit_logs')->orderBy('id')->get()->toJson())->toBe($before);
|
||||
});
|
||||
|
||||
test('approved evaluation is immutable and a new revision preserves the prior approved report', function () {
|
||||
$e = submittedEvaluation($this);
|
||||
$url = '/fornecedores/avaliacoes/'.$e->id;
|
||||
$this->actingAs($this->reviewer)->post($url.'/approve', ['version' => 2, 'reason' => 'Evidências e âmbito conferidos independentemente.'])->assertRedirect();
|
||||
$e->refresh();
|
||||
$this->actingAs($this->f['issuer'])->put($url, ['version' => 3, 'payload' => $this->data['payload']])->assertConflict();
|
||||
expect(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->update(['status' => 'draft']))->toThrow(QueryException::class);
|
||||
expect(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->delete())->toThrow(QueryException::class);
|
||||
expect(fn () => DB::transaction(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->update(['status' => 'draft'])))->toThrow(QueryException::class);
|
||||
expect(fn () => DB::transaction(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->delete()))->toThrow(QueryException::class);
|
||||
expect($e->fresh()->status)->toBe('approved')->and(SupplierEvaluation::query()->whereKey($e->id)->count())->toBe(1);
|
||||
$this->post($url.'/rever', ['version' => 3])->assertRedirect();
|
||||
$child = SupplierEvaluation::query()->where('previous_id', $e->id)->sole();
|
||||
$this->post($url.'/rever', ['version' => 3])->assertRedirect('/fornecedores/avaliacoes/'.$child->id);
|
||||
|
||||
@@ -5,6 +5,7 @@ use App\Models\User;
|
||||
use App\Services\ReceiptWorkflow;
|
||||
use App\Services\SupplyCoordination;
|
||||
use App\Services\SupplyPlanning;
|
||||
use App\Services\WarehouseReservations;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
|
||||
@@ -25,11 +26,27 @@ test('availability reuses physical balance without treating planning needs as ph
|
||||
app(SupplyPlanning::class)->save($f['receiver'], 'policy', supplyInput([], 'approve', $draft));
|
||||
$movements = DB::table('stock_movements')->count();
|
||||
$this->get('/stock/disponibilidade?warehouse_id='.$f['warehouse']->id)->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->component('stock/availability')->where('rows.data.0.physical_milli', 10000)->where('rows.data.0.usable_milli', 10000)
|
||||
->component('stock/availability')->where('reservationsAvailable', true)->where('rows.data.0.physical_milli', 10000)->where('rows.data.0.usable_milli', 10000)
|
||||
->where('rows.data.0.planned_milli', 20000)->where('rows.data.0.physical_commitment_milli', 0)->where('rows.data.0.free_milli', 10000)->where('rows.data.0.at_minimum', true));
|
||||
expect(DB::table('stock_movements')->count())->toBe($movements);
|
||||
});
|
||||
|
||||
test('availability does not infer a free balance when physical reservations are unavailable', function () {
|
||||
$f = receiptFixture('100.000');
|
||||
$this->actingAs($f['receiver']);
|
||||
app(ReceiptWorkflow::class)->confirm($f['receiver'], $f['order'], receiptPayload($f, '10.000'));
|
||||
$reservations = Mockery::mock(WarehouseReservations::class);
|
||||
$reservations->shouldReceive('ready')->andReturn(false);
|
||||
$reservations->shouldNotReceive('committed');
|
||||
$this->app->instance(WarehouseReservations::class, $reservations);
|
||||
$movements = DB::table('stock_movements')->count();
|
||||
$this->get('/stock/disponibilidade?warehouse_id='.$f['warehouse']->id)->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->where('reservationsAvailable', false)->where('rows.data.0.physical_milli', 10000)
|
||||
->where('rows.data.0.usable_milli', 10000)->where('rows.data.0.physical_commitment_milli', null)
|
||||
->where('rows.data.0.free_milli', null)->where('rows.data.0.at_minimum', false));
|
||||
expect(DB::table('stock_movements')->count())->toBe($movements);
|
||||
});
|
||||
|
||||
test('availability is tenant scoped and does not disclose planning without permission', function () {
|
||||
$f = receiptFixture();
|
||||
$this->actingAs($f['receiver'])->get('/stock/disponibilidade?warehouse_id='.$f['warehouse']->id)->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
|
||||
Reference in New Issue
Block a user