Merge branch '795-jumpstart-service-fee-for-motolite-users' into '783-rider-app-trade-in-support'

Resolve "Jumpstart service fee for motolite users"

See merge request jankstudio/resq!907
This commit is contained in:
Ramon Gutierrez 2024-04-01 13:19:07 +00:00
commit 06dc8eae7b
2 changed files with 21 additions and 6 deletions

View file

@ -8,6 +8,7 @@ use App\InvoiceRuleInterface;
use App\Entity\ServiceOffering;
use App\Entity\ItemType;
use App\Entity\CustomerVehicle;
use App\Service\PriceTierManager;
@ -36,11 +37,13 @@ class JumpstartWarranty implements InvoiceRuleInterface
if ($stype == $this->getID())
{
$cv = $criteria->getCustomerVehicle();
// check if price tier has item price
$pt_price = $this->getPriceTierItemPrice($pt_id);
$pt_price = $this->getPriceTierItemPrice($pt_id, $cv);
if ($pt_price == null)
$price = $this->getServiceTypeFee();
$price = $this->getServiceTypeFee($cv);
else
$price = $pt_price;
@ -60,8 +63,13 @@ class JumpstartWarranty implements InvoiceRuleInterface
return $items;
}
public function getServiceTypeFee()
public function getServiceTypeFee(CustomerVehicle $cv)
{
// check if user has motolite battery.
// Motolite users now have a service fee for jumpstart warranty
if ($cv->hasMotoliteBattery())
$code = 'motolite_user_jumpstart_warranty_fee';
else
$code = 'jumpstart_warranty_fee';
// find the service fee using the code
@ -84,7 +92,7 @@ class JumpstartWarranty implements InvoiceRuleInterface
return null;
}
protected function getPriceTierItemPrice($pt_id)
protected function getPriceTierItemPrice($pt_id, CustomerVehicle $cv)
{
// price_tier is default
if ($pt_id == 0)
@ -96,7 +104,13 @@ class JumpstartWarranty implements InvoiceRuleInterface
return null;
// find the service offering
// check if user has motolite battery.
// Motolite users now have a service fee for jumpstart warranty
if ($cv->hasMotoliteBattery())
$code = 'motolite_user_jumpstart_warranty_fee';
else
$code = 'jumpstart_warranty_fee';
$service = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
// check if service is null. If null, return null

View file

@ -0,0 +1 @@
INSERT INTO service_offering (name, code, fee) VALUES ('Motolite User Jumpstart Warranty Fee', 'motolite_user_jumpstart_warranty_fee', 200.00);