43 lines
2.4 KiB
PHP
43 lines
2.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Str;
|
|
|
|
/** Synthetic rules only. Never seed official rates or a customer's configuration. */
|
|
function importLegalQaInput(array $overrides = []): array
|
|
{
|
|
$db = DB::connection();
|
|
if (! app()->environment('testing') || ! (($db->getDriverName() === 'sqlite' && $db->getDatabaseName() === ':memory:')
|
|
|| ($db->getDriverName() === 'pgsql' && $db->getConfig('host') === '127.0.0.1' && preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $db->getDatabaseName())))) {
|
|
throw new LogicException('Legal fixtures require isolated QA.');
|
|
}
|
|
|
|
return [...['operation_key' => (string) Str::uuid(), 'record_key' => null, 'version' => 0, 'action' => 'save',
|
|
'title' => 'Synthetic tariff rule', 'official_reference' => 'Synthetic official edition QA only',
|
|
'official_url' => 'https://example.test/official-qa.pdf', 'citation' => 'Synthetic article 1, page 2',
|
|
'valid_from' => '2026-01-01', 'valid_until' => '2026-12-31', 'match_code' => '1234', 'suggested_code' => '1234.56',
|
|
'origin_country' => 'Synthetic A', 'sector' => 'Synthetic sector', 'obligations' => 'Synthetic conditions only; no real tax activated',
|
|
'document_types' => ['licence'], 'reason' => 'Synthetic legal configuration; not an approved real legal rule'], ...$overrides];
|
|
}
|
|
|
|
function importLegalQaFile(): UploadedFile
|
|
{
|
|
return UploadedFile::fake()->createWithContent('source.pdf', "%PDF-1.4\nSynthetic official source for QA only\n%%EOF");
|
|
}
|
|
|
|
function importLegalQaCharge(): array
|
|
{
|
|
return ['key' => 'synthetic-duty', 'kind' => 'duty', 'label' => 'Synthetic duty', 'method' => 'ad_valorem',
|
|
'rate_percent' => '7.5', 'specific_minor' => null, 'quantity_unit' => null,
|
|
'basis_reference' => 'Synthetic explicit customs valuation; no real rate configured'];
|
|
}
|
|
|
|
function importLegalQaAmountInput(int $itemId, int $ruleId): array
|
|
{
|
|
return ['operation_key' => (string) Str::uuid(), 'version' => 0, 'requisition_item_id' => $itemId, 'rule_id' => $ruleId,
|
|
'match_code' => '1234', 'origin' => 'Synthetic A', 'sector' => 'Synthetic sector', 'date' => '2026-11-27',
|
|
'bases' => ['synthetic-duty' => ['value_minor' => 10001, 'quantity' => null, 'quantity_unit' => null, 'source' => 'Synthetic exact declared valuation']],
|
|
'reason' => 'Synthetic legal charge estimate without financial or stock effects'];
|
|
}
|