Add a separate service fee for motolite users for jumpstart. #798

This commit is contained in:
Korina Cordero 2024-04-02 01:11:32 -04:00
parent 06dc8eae7b
commit c8e2c02be1

View file

@ -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;
}
}