Add isCountAboveZero method to xlvask_wash_item and update task logic to skip items with non-positive counts
This commit is contained in:
@@ -233,9 +233,9 @@ class xlvask_tasks
|
||||
/** @var xlvask_wash_item $item */
|
||||
// Skip items that have the id 64, since these are not relevant to anyone.
|
||||
$tmp_item_id = $item->getProduct($log)->id;
|
||||
if ($tmp_item_id === 64) {
|
||||
if ($tmp_item_id === 64 || !$item->isCountAboveZero()) {
|
||||
$tmp_skipped_items[] = $item;
|
||||
continue; // Skip items with id 64
|
||||
continue; // Skip items with id 64 (Or items simply not relevant)
|
||||
}
|
||||
echo '## ' . $item->Count . ' x ' . $item->OriginalProductName . ' @ ' . $item->getPriceExVat() . ' as ' . $tmp_item_id . ' ( ' . $item->getProduct($log)->name->value() . ' )' . PHP_EOL;
|
||||
}
|
||||
|
||||
@@ -301,4 +301,15 @@ class xlvask_wash_item
|
||||
// If either PriceIncVat or Count is not numeric, return 0
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the count of the wash item is above zero.
|
||||
* @note This method was added to accommodate the need to check if the count is above zero. (Since some, but not all wash items can have a count of 0, which is not valid for processing)
|
||||
* @return bool
|
||||
*/
|
||||
public function isCountAboveZero(): bool
|
||||
{
|
||||
// Check if the count is above zero
|
||||
return is_numeric($this->Count) && (float)$this->Count > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user