@@ -161,8 +161,10 @@ test('cancellation releases only its unconsumed issued part and never replenishe
|
||||
$control->commitOrderParts($order, [orderPartsAmount($source, 4000, 0)], (string) Str::uuid());
|
||||
$key = (string) Str::uuid();
|
||||
$input = [orderPartsAmount($source, 4000, 1)];
|
||||
expect($control->cancelOrderParts($order, $input, $key)['replayed'])->toBeFalse()
|
||||
->and($control->cancelOrderParts($order, $input, $key)['replayed'])->toBeTrue();
|
||||
$this->actingAs($this->finance);
|
||||
$cancel = app(CommonBudget::class)->for($this->finance);
|
||||
expect($cancel->cancelOrderParts($order, $input, $key)['replayed'])->toBeFalse()
|
||||
->and($cancel->cancelOrderParts($order, $input, $key)['replayed'])->toBeTrue();
|
||||
expect(orderPartsBalance($this))->toMatchArray(['reserved_minor' => 6000, 'committed_minor' => 0, 'available_minor' => 94000]);
|
||||
expect(fn () => $control->commitOrderParts((string) Str::uuid(), [orderPartsAmount($source, 6001, 2)], (string) Str::uuid()))->toThrow(BudgetFailure::class);
|
||||
$control->commitOrderParts((string) Str::uuid(), [orderPartsAmount($source, 6000, 2)], (string) Str::uuid());
|
||||
@@ -181,8 +183,8 @@ test('consumed orders reject cancellation and over-consumption without changing
|
||||
$next = orderPartsAmount($source, 5001, 2);
|
||||
$next['allocations'][0]['order_key'] = $order;
|
||||
expect(fn () => app(CommonBudget::class)->for($this->finance)->consumeOrderParts(orderPartsInvoice($this, 5001)->id, [$next], (string) Str::uuid()))->toThrow(BudgetFailure::class);
|
||||
$this->actingAs($this->f['issuer']);
|
||||
expect(fn () => app(CommonBudget::class)->for($this->f['issuer'])->cancelOrderParts($order, [orderPartsAmount($source, 10000, 2)], (string) Str::uuid()))->toThrow(BudgetFailure::class);
|
||||
$this->actingAs($this->finance);
|
||||
expect(fn () => app(CommonBudget::class)->for($this->finance)->cancelOrderParts($order, [orderPartsAmount($source, 10000, 2)], (string) Str::uuid()))->toThrow(BudgetFailure::class);
|
||||
expect(orderPartsBalance($this))->toMatchArray(['committed_minor' => 5000, 'consumed_minor' => 5000]);
|
||||
});
|
||||
|
||||
@@ -238,8 +240,8 @@ test('bad invoice allocation rolls back every origin and an unconsumed cancelled
|
||||
$invoice = orderPartsInvoice($this, 25001);
|
||||
expect(fn () => app(CommonBudget::class)->for($this->finance)->consumeOrderParts($invoice->id, $input, (string) Str::uuid()))->toThrow(BudgetFailure::class);
|
||||
expect(DB::table('budget_order_consumptions')->count())->toBe(0)->and(DB::table('budget_order_commands')->count())->toBe(1);
|
||||
$this->actingAs($this->f['issuer']);
|
||||
$control->cancelOrderParts($order, [orderPartsAmount($a, 10000, 1), orderPartsAmount($b, 20000, 1)], (string) Str::uuid());
|
||||
$this->actingAs($this->finance);
|
||||
app(CommonBudget::class)->for($this->finance)->cancelOrderParts($order, [orderPartsAmount($a, 10000, 1), orderPartsAmount($b, 20000, 1)], (string) Str::uuid());
|
||||
$this->actingAs($this->finance);
|
||||
$cancelled = orderPartsAmount($a, 100, 2);
|
||||
$cancelled['allocations'][0]['order_key'] = $order;
|
||||
|
||||
Reference in New Issue
Block a user