Add handling for fixed pricing and tank cleaning transactions with action checks and enhanced customer retrieval
This commit is contained in:
@@ -582,4 +582,75 @@ class orders_o extends db
|
||||
]);
|
||||
return (bool)$count;
|
||||
}
|
||||
|
||||
public function getFixedPricingTransactions(int $customer_number, false $asArray, string|null $dateFrom = null, string|null $dateTo = null): array
|
||||
{
|
||||
// Get the fixed pricing transactions for a customer
|
||||
return self::listObjectsWithPagination(
|
||||
1,
|
||||
100,
|
||||
null,
|
||||
[
|
||||
'customer_id' => $customer_number,
|
||||
'deleted_at' => null,
|
||||
'cashier_id' => (new collected_order_invoices_o())->economic_wash_subscription_user_id,
|
||||
...(!empty($dateFrom) ? ['created_at-date_from' => $dateFrom] : []),
|
||||
...(!empty($dateTo) ? ['created_at-date_to' => $dateTo] : []),
|
||||
],
|
||||
[
|
||||
'id' => 'DESC',
|
||||
],
|
||||
function ($object) use ($asArray) {
|
||||
$res = (new orders_o())->select($object['id']);
|
||||
if ($asArray) {
|
||||
return $res->asArray();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getTankCleaningTransactions(int $customer_number, false $asArray, string $dateFrom, string $dateTo): array
|
||||
{
|
||||
// Get the tank cleaning transactions for a customer
|
||||
return self::listObjectsWithPagination(
|
||||
1,
|
||||
100,
|
||||
null,
|
||||
[
|
||||
'customer_id' => $customer_number,
|
||||
'deleted_at' => null,
|
||||
...(!empty($dateFrom) ? ['created_at-date_from' => $dateFrom] : []),
|
||||
...(!empty($dateTo) ? ['created_at-date_to' => $dateTo] : []),
|
||||
],
|
||||
[
|
||||
'id' => 'DESC',
|
||||
],
|
||||
function ($object) use ($asArray) {
|
||||
$res = (new orders_o())->select($object['id']);
|
||||
if ($asArray) {
|
||||
return $res->asArray();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function isBooked(): bool
|
||||
{
|
||||
// Check the invoice collection has been booked
|
||||
if ((int)$this->invoice_collection_id->value() > 0) {
|
||||
$invoice_collection = (new collected_order_invoices_o())->select((int)$this->invoice_collection_id->value());
|
||||
return $invoice_collection->isBooked();
|
||||
} else {
|
||||
// If there is no invoice collection, the order is not booked
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user