diff --git a/src/InvoiceRule/Jumpstart.php b/src/InvoiceRule/Jumpstart.php index d2e89b0a..141e648e 100644 --- a/src/InvoiceRule/Jumpstart.php +++ b/src/InvoiceRule/Jumpstart.php @@ -68,18 +68,8 @@ class Jumpstart implements InvoiceRuleInterface public function getServiceTypeFee($source, CustomerVehicle $cv) { - // check the source of JO - // (1) if from app, service fee is 0 if motolite user. jumpstart fee for app if non-motolite user. - // (2) any other source, jumpstart fees are charged whether motolite user or not - if ($source == TransactionOrigin::MOBILE_APP) - { - if ($cv->hasMotoliteBattery()) - $code = 'motolite_user_service_fee'; - else - $code = 'jumpstart_fee_mobile_app'; - } - else - $code = 'jumpstart_fee'; + // get the service fee code, depending on the JO source and if customer vehicle has a motolite battery + $code = $this->getServiceFeeCode($cv, $source); $fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]); @@ -110,20 +100,10 @@ class Jumpstart implements InvoiceRuleInterface if ($item_type == null) return null; - // find the service offering - // check the source of JO - // (1) if from app, service fee is 0 if motolite user. jumpstart fee for app if non-motolite user. - // (2) any other source, jumpstart fees are charged whether motolite user or not - if ($source == TransactionOrigin::MOBILE_APP) - { - if ($cv->hasMotoliteBattery()) - $code = 'motolite_user_service_fee'; - else - $code = 'jumpstart_fee_mobile_app'; - } - else - $code = 'jumpstart_fee'; + // get the service fee code, depending on the JO source and if customer vehicle has a motolite battery + $code = $this->getServiceFeeCode($cv, $source); + // find the service offering $service = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]); // check if service is null. If null, return null @@ -144,4 +124,33 @@ class Jumpstart implements InvoiceRuleInterface return $title; } + + protected function getServiceFeeCode(CustomerVehicle $cv, $source) + { + // check the source of JO + // (1) if from app, service fee is 0 if motolite user. jumpstart fee for app if non-motolite user. + // (2) any other source, jumpstart fees are charged whether motolite user or not. Service fees for non-motolite + // and motolite users are now different (used to be the same) + if ($source == TransactionOrigin::MOBILE_APP) + { + if ($cv->hasMotoliteBattery()) + $code = 'motolite_user_service_fee'; + else + $code = 'jumpstart_fee_mobile_app'; + } + else + { + error_log('hotline'); + if ($cv->hasMotoliteBattery()) + { + error_log('has motolite battery'); + $code = 'motolite_user_jumpstart_fee'; + } + else + $code = 'jumpstart_fee'; + } + + return $code; + + } }