@@ -4,13 +4,14 @@ use App\Enums\PurchasingRole;
|
||||
use App\Models\Budget;
|
||||
use App\Models\User;
|
||||
use App\Services\BudgetWorkflow;
|
||||
use App\Services\CommonBudget;
|
||||
use App\Services\OrderCancellationPolicyWorkflow;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
require_once __DIR__.'/../Support/ReceiptFixture.php';
|
||||
|
||||
function issuedOrderCancellationFixture(object $test): void
|
||||
function issuedOrderCancellationFixture(object $test, int $cycle = 1): void
|
||||
{
|
||||
config(['order_cancellation.enabled' => true]);
|
||||
$test->f = receiptFixture();
|
||||
@@ -33,7 +34,19 @@ function issuedOrderCancellationFixture(object $test): void
|
||||
$test->budget = Budget::query()->create(['tenant_id' => $test->f['tenant']->id, 'cost_center_id' => $test->f['r']->cost_center_id, 'year' => now()->year,
|
||||
'amount_minor' => 20000, 'includes_tax' => true, 'reason' => 'Dotação fictícia para ensaio da reversão.', 'created_by' => $test->finance->id,
|
||||
'approved_by' => $test->admins[0]->id, 'approved_at' => now()]);
|
||||
DB::transaction(function () use ($test) {
|
||||
DB::transaction(function () use ($test, $cycle) {
|
||||
if ($cycle === 2) {
|
||||
$origin = $test->f['r']->id;
|
||||
$adapter = app(CommonBudget::class);
|
||||
$first = $adapter->for($test->finance, [$origin => 1]);
|
||||
$first->beginRequisitionCycle($origin, 1, (string) Str::uuid());
|
||||
$first->record($origin, $test->f['r']->cost_center_id, 'operating', 'reserve', 10000, 10000);
|
||||
$first->record($origin, $test->f['r']->cost_center_id, 'operating', 'release');
|
||||
$first->closeRequisitionCycle($origin, 1, (string) Str::uuid());
|
||||
$second = $adapter->for($test->finance, [$origin => 2]);
|
||||
$second->beginRequisitionCycle($origin, 2, (string) Str::uuid());
|
||||
$test->f['r']->forceFill(['approval_cycle' => 2])->save();
|
||||
}
|
||||
foreach (['reserve', 'award', 'commit'] as $kind) {
|
||||
app(BudgetWorkflow::class)->record($test->finance, $test->f['r'], $kind, 10000, 10000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user