diff --git a/src/InvoiceRule/Jumpstart.php b/src/InvoiceRule/Jumpstart.php index 374ac93a..b768840f 100644 --- a/src/InvoiceRule/Jumpstart.php +++ b/src/InvoiceRule/Jumpstart.php @@ -7,6 +7,7 @@ use Doctrine\ORM\EntityManagerInterface; use App\InvoiceRuleInterface; use App\Entity\ServiceOffering; +use App\Entity\CustomerVehicle; use App\Ramcar\TransactionOrigin; @@ -33,7 +34,8 @@ class Jumpstart implements InvoiceRuleInterface if ($stype == $this->getID()) { - $fee = $this->getServiceTypeFee($source); + $cv = $criteria->getCustomerVehicle(); + $fee = $this->getServiceTypeFee($source, $cv); // add the service fee to items $qty = 1; @@ -51,16 +53,24 @@ class Jumpstart implements InvoiceRuleInterface return $items; } - public function getServiceTypeFee($source) - { - // find the service fee for jumpstart using the code - // if we can't find the fee, return 0 - // jumpstart fee depends on the JO source. Jumpstart from app has a different fee - // we set the code to search for the default + public function getServiceTypeFee($source, CustomerVehicle $cv) + { $code = 'jumpstart_fee'; - if ($source == TransactionOrigin::MOBILE_APP) - $code = 'jumpstart_fee_mobile_app'; + // check if customer vehicle has a motolite battery + // if yes, set the code to the motolite user service fee + if ($cv->hasMotoliteBattery()) + $code = 'motolite_user_service_fee'; + else + { + // find the service fee for jumpstart using the code + // if we can't find the fee, return 0 + // jumpstart fee depends on the JO source. Jumpstart from app has a different fee + // we set the code to search for the default + + if ($source == TransactionOrigin::MOBILE_APP) + $code = 'jumpstart_fee_mobile_app'; + } $fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);