Avoid empty self-serve invoice orders
Only create the invoice order context when elapsed minute billing has a positive quantity. This preserves automatic-mode included-minute reduction without leaving an empty order id on the lane. Tests: - bash scripts/php-ci-test.sh unit
This commit is contained in:
@@ -124,8 +124,8 @@ trait selfserve_lane_invoice_t
|
||||
$included_minutes = $this->resolveIncludedMinutesForBilling();
|
||||
$billable_minutes = $this->calculateBillableMinutes($elapsed_minutes, $included_minutes);
|
||||
|
||||
$order = $this->createInvoiceOrderContext($arguments);
|
||||
if ($billable_minutes > 0) {
|
||||
$order = $this->createInvoiceOrderContext($arguments);
|
||||
$this->billable_minutes_order_item = $this->addMinuteBillingLine((int)$order->id, (int)$product_id, $billable_minutes);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -24,6 +24,7 @@ class SelfserveLaneInvoiceModeBillingHarness
|
||||
public ?int $lastAddedOrderId = null;
|
||||
public ?int $lastAddedProductId = null;
|
||||
public ?int $lastAddedQuantity = null;
|
||||
public int $createdOrderContexts = 0;
|
||||
|
||||
private selfserve_lane_status $laneStatus = selfserve_lane_status::OCCUPIED;
|
||||
private selfserve_lane_mode $laneMode = selfserve_lane_mode::MANUAL;
|
||||
@@ -85,6 +86,7 @@ class SelfserveLaneInvoiceModeBillingHarness
|
||||
|
||||
protected function createInvoiceOrderContext(): orders_o
|
||||
{
|
||||
$this->createdOrderContexts++;
|
||||
$order = new SelfserveLaneInvoiceModeOrderStub();
|
||||
$order->id = 424242;
|
||||
$this->last_invoice_order_id = (int)$order->id;
|
||||
@@ -111,6 +113,7 @@ it('bills manual self-serve stop using full elapsed minutes without included-min
|
||||
expect($harness->lastAddedOrderId)->toBe(424242);
|
||||
expect($harness->lastAddedProductId)->toBe(999);
|
||||
expect($harness->lastAddedQuantity)->toBe(1);
|
||||
expect($harness->createdOrderContexts)->toBe(1);
|
||||
expect($harness->getLastInvoiceOrderId())->toBe(424242);
|
||||
});
|
||||
|
||||
@@ -126,6 +129,6 @@ it('keeps included-minute reduction for automatic mode', function (): void {
|
||||
expect($harness->lastAddedOrderId)->toBeNull();
|
||||
expect($harness->lastAddedProductId)->toBeNull();
|
||||
expect($harness->lastAddedQuantity)->toBeNull();
|
||||
expect($harness->createdOrderContexts)->toBe(0);
|
||||
expect($harness->getLastInvoiceOrderId())->toBeNull();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user