commit compras3 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 18:16:04 +02:00
parent 060c119ba1
commit 1ddabbbdcc
41 changed files with 1341 additions and 138 deletions
@@ -1,6 +1,7 @@
<?php
use App\Models\SupplyRecord;
use App\Services\ImportLegalAmounts;
use App\Services\ImportLegalReferenceDrafts;
use App\Services\ImportLegalRules;
use Illuminate\Http\UploadedFile;
@@ -36,7 +37,7 @@ test('a supplied official edition offers exact documentary drafts without publis
new UploadedFile($path, basename($path), 'application/pdf', UPLOAD_ERR_OK, true));
$workspace = $service->workspace($this->f['issuer'], $this->f['r']);
$drafts = $workspace['referenceDrafts'];
expect($drafts)->toHaveCount(11)
expect($drafts)->toHaveCount(48)
->and(array_column($drafts, 'code'))->toContain('3506.91.20', '7604.10.10')
->and($drafts[0]['rate_percent'])->toBe('20')
->and($drafts[2]['rate_percent'])->toBe('7.5')
@@ -44,9 +45,28 @@ test('a supplied official edition offers exact documentary drafts without publis
->and($drafts[0]['citation'])->toContain('2180-(4)')
->and($drafts[0]['source_id'])->toBe($source->id)
->and($drafts[0]['charges'][0]['kind'])->toBe('duty')
->and($drafts[0]['charges'])->toHaveCount(4)
->and($workspace['referenceDraftWarnings'])->toBe([])
->and(SupplyRecord::query()->where('kind', 'import_legal_rule')->count())->toBe(0)
->and(json_encode($workspace['sources'], JSON_THROW_ON_ERROR))->not->toContain('import-legal/');
expect(array_unique(array_column($drafts, 'code')))->toHaveCount(48);
$capital = collect($drafts)->firstWhere('code', '8451.80.10');
$vehicle = collect($drafts)->firstWhere('code', '8704.21.10');
$last = collect($drafts)->firstWhere('code', '9507.90.90');
expect($capital['rate_percent'])->toBe('5')->and($capital['documentary_class'])->toBe('K')
->and($capital['obligations'])->toContain('não comprova elegibilidade')
->and($capital['citation'])->toContain('2180-(5)')
->and($vehicle['documentary_class'])->toBeNull()
->and($vehicle['obligations'])->toContain('bens de capital para investimento')
->and($last['citation'])->toContain('2180-(7)')
->and($last['rate_percent'])->toBe('5');
// A purely illustrative 100 MZN base is not a real import, debt or complete tax assessment.
$estimate = app(ImportLegalAmounts::class)->calculate($drafts[0]['charges'], ['general_duty' => [
'value_minor' => 10000, 'quantity' => null, 'quantity_unit' => null, 'source' => 'Explicit synthetic 100 MZN unit-test base']]);
expect($estimate['known_subtotal_minor'])->toBe(2000)
->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);
}