@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Requisition;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/** Financial-contract fixture, without an issued native order. Not a native approval execution. */
|
||||
function unissuedOrderPartsSource(array $fixture, int $amount): Requisition
|
||||
{
|
||||
$db = DB::connection();
|
||||
$isolated = ($db->getDriverName() === 'sqlite' && $db->getDatabaseName() === ':memory:')
|
||||
|| ($db->getDriverName() === 'pgsql' && preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $db->getDatabaseName()));
|
||||
if (! app()->environment('testing') || ! $isolated || $amount < 0) {
|
||||
throw new LogicException('Unissued order fixtures require isolated synthetic QA.');
|
||||
}
|
||||
$source = $fixture['r']->replicate();
|
||||
$source->number = 'REQ-PARTS-'.Str::random(12);
|
||||
$source->subtotal_minor = $source->total_minor = $amount;
|
||||
$source->tax_minor = 0;
|
||||
$source->save();
|
||||
$line = $fixture['r']->items()->firstOrFail()->replicate();
|
||||
$line->requisition_id = $source->id;
|
||||
$line->quantity = '1.000';
|
||||
$line->unit_price_minor = $line->subtotal_minor = $line->total_minor = $amount;
|
||||
$line->tax_rate = '0.00';
|
||||
$line->tax_minor = 0;
|
||||
$line->save();
|
||||
|
||||
return $source;
|
||||
}
|
||||
Reference in New Issue
Block a user