diff --git a/src/InvoiceRule/JumpstartWarranty.php b/src/InvoiceRule/JumpstartWarranty.php index 4c6ac387..c627a574 100644 --- a/src/InvoiceRule/JumpstartWarranty.php +++ b/src/InvoiceRule/JumpstartWarranty.php @@ -8,6 +8,7 @@ use App\InvoiceRuleInterface; use App\Entity\ServiceOffering; use App\Entity\ItemType; +use App\Entity\CustomerVehicle; use App\Service\PriceTierManager; @@ -36,11 +37,13 @@ class JumpstartWarranty implements InvoiceRuleInterface if ($stype == $this->getID()) { + $cv = $criteria->getCustomerVehicle(); + // check if price tier has item price - $pt_price = $this->getPriceTierItemPrice($pt_id); + $pt_price = $this->getPriceTierItemPrice($pt_id, $cv); if ($pt_price == null) - $price = $this->getServiceTypeFee(); + $price = $this->getServiceTypeFee($cv); else $price = $pt_price; @@ -60,9 +63,14 @@ class JumpstartWarranty implements InvoiceRuleInterface return $items; } - public function getServiceTypeFee() + public function getServiceTypeFee(CustomerVehicle $cv) { - $code = 'jumpstart_warranty_fee'; + // check if user has motolite battery. + // Motolite users now have a service fee for jumpstart warranty + if ($cv->hasMotoliteBattery()) + $code = 'motolite_user_jumpstart_warranty_fee'; + else + $code = 'jumpstart_warranty_fee'; // find the service fee using the code // if we can't find the fee, return 0 @@ -84,7 +92,7 @@ class JumpstartWarranty implements InvoiceRuleInterface return null; } - protected function getPriceTierItemPrice($pt_id) + protected function getPriceTierItemPrice($pt_id, CustomerVehicle $cv) { // price_tier is default if ($pt_id == 0) @@ -96,7 +104,13 @@ class JumpstartWarranty implements InvoiceRuleInterface return null; // find the service offering - $code = 'jumpstart_warranty_fee'; + // check if user has motolite battery. + // Motolite users now have a service fee for jumpstart warranty + if ($cv->hasMotoliteBattery()) + $code = 'motolite_user_jumpstart_warranty_fee'; + else + $code = 'jumpstart_warranty_fee'; + $service = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]); // check if service is null. If null, return null diff --git a/utils/service_offering/insert_motolite_user_jumpstart_warranty_fee.sql b/utils/service_offering/insert_motolite_user_jumpstart_warranty_fee.sql new file mode 100644 index 00000000..afe55b2f --- /dev/null +++ b/utils/service_offering/insert_motolite_user_jumpstart_warranty_fee.sql @@ -0,0 +1 @@ + INSERT INTO service_offering (name, code, fee) VALUES ('Motolite User Jumpstart Warranty Fee', 'motolite_user_jumpstart_warranty_fee', 200.00);