Add processing of battery entries and invoice item titles. #782

This commit is contained in:
Korina Cordero 2024-01-22 04:24:41 -05:00
parent 70ee7fdd89
commit 29ad8d57a4

View file

@ -38,11 +38,18 @@ class PriceTier implements InvoiceRuleInterface
// price tier is default // price tier is default
if ($pt == null) if ($pt == null)
{ {
// check if service type is battery sales // check if service type is battery sales and battery warranty (sometimes they add a battery
if ($service_type == ServiceType::BATTERY_REPLACEMENT_NEW) // for battery warranty
if (($service_type == ServiceType::BATTERY_REPLACEMENT_NEW) ||
($service_type == ServiceType::BATTERY_REPLACEMENT_WARRANTY))
{ {
$items = $this->processBatteryEntries($criteria, $total); $items = $this->processBatteryEntries($criteria, $total);
} }
else
{
// TODO: process the service fees
$items = $this->processServiceEntries($criteria, $total);
}
} }
else else
{ {
@ -54,6 +61,8 @@ class PriceTier implements InvoiceRuleInterface
// make item price hash // make item price hash
$pt_prices[$pt_item->getItemID()] = $pt_item->getPrice(); $pt_prices[$pt_item->getItemID()] = $pt_item->getPrice();
} }
// TODO: finish this
} }
return $items; return $items;
@ -123,14 +132,17 @@ class PriceTier implements InvoiceRuleInterface
if ($trade_in == null) if ($trade_in == null)
{ {
// battery purchase // check if battery purchase or battery replacement
if ($service_type == ServiceType::BATTERY_REPLACEMENT_NEW)
$price = $batt->getSellingPrice(); $price = $batt->getSellingPrice();
else
$price = 0;
$items[] = [ $items[] = [
'service_type' => $this->getID(), 'service_type' => $this->getID(),
'battery' => $batt, 'battery' => $batt,
'qty' => $qty, 'qty' => $qty,
'title' => $this->getTitle($criteria->getServiceType(), $batt), 'title' => $this->getItemTitle($criteria->getServiceType(), $batt),
'price' => $price, 'price' => $price,
]; ];
@ -144,12 +156,63 @@ class PriceTier implements InvoiceRuleInterface
return $items; return $items;
} }
protected function getTitle($service_type, $battery) protected function processServiceEntries($criteria, &$total)
{
}
protected function getItemTitle($service_type, $battery)
{ {
$title =''; $title ='';
// TODO: check for service type // TODO: check for service type
switch ($service_type) {
case (ServiceType::BATTERY_REPLACEMENT_NEW):
$title = $battery->getModel()->getName() . ' ' . $battery->getSize()->getName(); $title = $battery->getModel()->getName() . ' ' . $battery->getSize()->getName();
break;
case (ServiceType::BATTERY_REPLACEMENT_WARRANTY):
$title = $battery->getModel()->getName() . ' ' . $battery->getSize()->getName() . ' - Service Unit';
break;
default:
$title = '';
break;
}
return $title;
protected function getServiceTitle($service_type, $fuel_type)
{
$title = '';
switch ($service_type) {
case (ServiceType::JUMPSTART_TROUBLESHOOT):
case (ServiceType::JUMPSTART_WARRANTY):
$title = 'Service - Troubleshooting fee';
break;
case (ServiceType::OVERHEAT_ASSISTANCE):
$title = 'Service - ' . ServiceType::getName(ServiceType::OVERHEAT_ASSISTANCE);
break;
case (ServiceType::POST_RECHARGED):
$title = 'Recharge fee';
break;
case (ServiceType::POST_REPLACEMENT):
$title = 'Battery replacement';
break;
case (ServiceType::TIRE_REPAIR):
$title = 'Service - Flat Tire';
break;
case (ServiceType::EMERGENCY_REFUEL):
$title = '4L - ' . ucfirst($fuel_type);
break;
default:
$title = '';
}
return $title;
}
protected function getServiceCoolantTitle()
{
$title = '4L Coolant';
return $title; return $title;
} }