@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use App\Models\PurchaseAward;
|
||||
use App\Models\Quotation;
|
||||
|
||||
require_once __DIR__.'/../Support/ReceiptFixture.php';
|
||||
|
||||
test('synthetic receipt sources preserve explicit unit prices and calculate coherent line and header amounts', function (string $quantity, array $categories, int $unit, int $lineTotal, int $documentTotal) {
|
||||
$f = receiptFixture($quantity, 'consumable', $categories);
|
||||
expect($f['r']->total_minor)->toBe($documentTotal)->and($f['order']->total_minor)->toBe($documentTotal)
|
||||
->and($f['order']->items()->count())->toBe(count($categories))
|
||||
->and((int) $f['r']->items()->sum('total_minor'))->toBe($documentTotal)
|
||||
->and((int) $f['order']->items()->sum('total_minor'))->toBe($documentTotal)
|
||||
->and(Quotation::query()->where('requisition_id', $f['r']->id)->sole()->total_minor)->toBe($documentTotal)
|
||||
->and(PurchaseAward::query()->where('requisition_id', $f['r']->id)->sole()->total_minor)->toBe($documentTotal);
|
||||
foreach ($f['lines'] as $line) {
|
||||
expect($line->unit_price_minor)->toBe($unit)->and($line->total_minor)->toBe($lineTotal);
|
||||
}
|
||||
})->with([
|
||||
['1.000', ['Material'], 10000, 10000, 10000],
|
||||
['100.000', ['Material'], 10000, 1000000, 1000000],
|
||||
['0.333', ['Material'], 10000, 3330, 3330],
|
||||
['1.000', ['Material', 'Serviços'], 5000, 5000, 10000],
|
||||
]);
|
||||
Reference in New Issue
Block a user