Fix issue of jumpstart for motolite user. #758
This commit is contained in:
parent
cfa77bf2e1
commit
fc95f781d8
1 changed files with 19 additions and 9 deletions
|
|
@ -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)
|
||||
public function getServiceTypeFee($source, CustomerVehicle $cv)
|
||||
{
|
||||
$code = 'jumpstart_fee';
|
||||
|
||||
// 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
|
||||
$code = 'jumpstart_fee';
|
||||
|
||||
if ($source == TransactionOrigin::MOBILE_APP)
|
||||
$code = 'jumpstart_fee_mobile_app';
|
||||
}
|
||||
|
||||
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue