Enhance xlvask_tasks: introduce date range options and additional debug outputs for runSyncUsage. Add new parsers xlvask_parser_ingen_b_rster_foran_no_brush_wash_front and xlvask_parser_ht_dysebom and integrate into xlvask_helpers. Improve rate limiting and reduce FastCGI timeout in nginx configuration. Adjust execution time and memory limits in cli.php.

This commit is contained in:
Jepp9350
2025-07-14 09:22:32 +02:00
parent edcb6e5926
commit ffd0606ece
8 changed files with 311 additions and 43 deletions
@@ -393,41 +393,6 @@ class xlvask_usage_log extends xlvask_helper
return '';
}
/**
* Get the total price of the wash.
* This method calculates the total price of the wash by summing up the prices of all wash items.
* @return float The total price of the wash.
* @throws Exception If any of the wash items do not have a valid price.
*/
public function getTotalPrice(): float
{
// Calculate the total price of the wash by summing up the prices of all wash items
$totalPrice = 0.0;
foreach ( $this->WashItems as $item ) {
/** @var xlvask_wash_item $item */
if (isset($item->PriceIncVat) && is_numeric($item->PriceIncVat)) {
// The reason why we use the PriceIncVat is that it is the final price, and the price without VAT is not always available / correct.
$totalPrice += ((float)$item->PriceIncVat - (float)$item->Vat);
} else {
//print_r($item);
throw new Exception("Invalid price for wash item: " . json_encode($item));
}
}
return $totalPrice;
}
/**
* Check if the wash is completed.
* @note This method checks the FinishStatus property to determine if the wash is completed.
* * A wash is considered completed if the FinishStatus is set to 1.
* @return bool
*/
public function isCompleted(): bool
{
// Check if the wash is completed based on the FinishStatus
return $this->FinishStatus === 1; // Assuming 1 indicates a completed wash
}
/**
* Get the primary wash item from the usage log.
* This method returns the first wash item in the WashItems array as the primary item.
@@ -559,4 +524,84 @@ class xlvask_usage_log extends xlvask_helper
// Return the start time as a timestamp
return date('Y-m-d H:i:s', strtotime($this->StartTime));
}
public function isEligibleForAutomaticContinuance(bool $allowPrepaid = false): bool
{
// Check if the wash is eligible for automatic continuance
// This can be based on various criteria, such as the finish status or other business rules
return
$this->isCompleted() && // Ensure the wash is completed
$this->hasBillableCustomer() && // Ensure the wash has a billable customer
(
$this->getTotalPrice() > 0 || $allowPrepaid
// Allow washes with a total price greater than 0 or allow prepaid washes if $allowPrepaid is true
) &&
(
!$this->isPrepaid() || $allowPrepaid
); // Allow prepaid washes if $allowPrepaid is true)
}
/**
* Check if the wash is completed.
* @note This method checks the FinishStatus property to determine if the wash is completed.
* * A wash is considered completed if the FinishStatus is set to 1.
* @return bool
*/
public function isCompleted(): bool
{
// Check if the wash is completed based on the FinishStatus
return $this->FinishStatus === 1; // Assuming 1 indicates a completed wash
}
public function hasBillableCustomer(): bool
{
// Check if the wash has a non-default customer with a valid external ID
return !$this->hasDefaultCustomer() && $this->hasExternalId();
}
public function hasDefaultCustomer(): bool
{
// Check if the customer is a default customer (e.g., "Unknown" or similar)
$default_customers = [
'CTW',
'Personalebiler Truckwash ', // The space at the end is intentional
'XL Gønge Transport ApS', // This is a test customer
];
return in_array($this->Customer, $default_customers, true);
}
public function hasExternalId(): bool
{
// Check if the wash has an external ID (e.g., CustomerId)
return !empty($this->CustomerId) && $this->CustomerId !== '0';
}
/**
* Get the total price of the wash.
* This method calculates the total price of the wash by summing up the prices of all wash items.
* @return float The total price of the wash.
* @throws Exception If any of the wash items do not have a valid price.
*/
public function getTotalPrice(): float
{
// Calculate the total price of the wash by summing up the prices of all wash items
$totalPrice = 0.0;
foreach ( $this->WashItems as $item ) {
/** @var xlvask_wash_item $item */
if (isset($item->PriceIncVat) && is_numeric($item->PriceIncVat)) {
// The reason why we use the PriceIncVat is that it is the final price, and the price without VAT is not always available / correct.
$totalPrice += ((float)$item->PriceIncVat - (float)$item->Vat);
} else {
//print_r($item);
throw new Exception("Invalid price for wash item: " . json_encode($item));
}
}
return $totalPrice;
}
public function isPrepaid(): bool
{
// Check if the wash is prepaid
return !empty($this->Prepaid) && $this->Prepaid === 1; // Assuming 1 indicates a prepaid wash
}
}