Fix issue of jumpstart for motolite user. #758

This commit is contained in:
Korina Cordero 2023-08-25 09:42:42 +08:00
parent cfa77bf2e1
commit fc95f781d8

View file

@ -7,6 +7,7 @@ use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Entity\ServiceOffering; use App\Entity\ServiceOffering;
use App\Entity\CustomerVehicle;
use App\Ramcar\TransactionOrigin; use App\Ramcar\TransactionOrigin;
@ -33,7 +34,8 @@ class Jumpstart implements InvoiceRuleInterface
if ($stype == $this->getID()) if ($stype == $this->getID())
{ {
$fee = $this->getServiceTypeFee($source); $cv = $criteria->getCustomerVehicle();
$fee = $this->getServiceTypeFee($source, $cv);
// add the service fee to items // add the service fee to items
$qty = 1; $qty = 1;
@ -51,16 +53,24 @@ class Jumpstart implements InvoiceRuleInterface
return $items; return $items;
} }
public function getServiceTypeFee($source) public function getServiceTypeFee($source, CustomerVehicle $cv)
{ {
// 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'; $code = 'jumpstart_fee';
if ($source == TransactionOrigin::MOBILE_APP) // check if customer vehicle has a motolite battery
$code = 'jumpstart_fee_mobile_app'; // 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]); $fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);