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:
commit
06dc8eae7b
2 changed files with 21 additions and 6 deletions
|
|
@ -8,6 +8,7 @@ use App\InvoiceRuleInterface;
|
||||||
|
|
||||||
use App\Entity\ServiceOffering;
|
use App\Entity\ServiceOffering;
|
||||||
use App\Entity\ItemType;
|
use App\Entity\ItemType;
|
||||||
|
use App\Entity\CustomerVehicle;
|
||||||
|
|
||||||
use App\Service\PriceTierManager;
|
use App\Service\PriceTierManager;
|
||||||
|
|
||||||
|
|
@ -36,11 +37,13 @@ class JumpstartWarranty implements InvoiceRuleInterface
|
||||||
|
|
||||||
if ($stype == $this->getID())
|
if ($stype == $this->getID())
|
||||||
{
|
{
|
||||||
|
$cv = $criteria->getCustomerVehicle();
|
||||||
|
|
||||||
// check if price tier has item price
|
// check if price tier has item price
|
||||||
$pt_price = $this->getPriceTierItemPrice($pt_id);
|
$pt_price = $this->getPriceTierItemPrice($pt_id, $cv);
|
||||||
|
|
||||||
if ($pt_price == null)
|
if ($pt_price == null)
|
||||||
$price = $this->getServiceTypeFee();
|
$price = $this->getServiceTypeFee($cv);
|
||||||
else
|
else
|
||||||
$price = $pt_price;
|
$price = $pt_price;
|
||||||
|
|
||||||
|
|
@ -60,9 +63,14 @@ class JumpstartWarranty implements InvoiceRuleInterface
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getServiceTypeFee()
|
public function getServiceTypeFee(CustomerVehicle $cv)
|
||||||
{
|
{
|
||||||
$code = 'jumpstart_warranty_fee';
|
// 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
|
// find the service fee using the code
|
||||||
// if we can't find the fee, return 0
|
// if we can't find the fee, return 0
|
||||||
|
|
@ -84,7 +92,7 @@ class JumpstartWarranty implements InvoiceRuleInterface
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPriceTierItemPrice($pt_id)
|
protected function getPriceTierItemPrice($pt_id, CustomerVehicle $cv)
|
||||||
{
|
{
|
||||||
// price_tier is default
|
// price_tier is default
|
||||||
if ($pt_id == 0)
|
if ($pt_id == 0)
|
||||||
|
|
@ -96,7 +104,13 @@ class JumpstartWarranty implements InvoiceRuleInterface
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// find the service offering
|
// find the service offering
|
||||||
$code = 'jumpstart_warranty_fee';
|
// 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]);
|
$service = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
|
||||||
|
|
||||||
// check if service is null. If null, return null
|
// check if service is null. If null, return null
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
INSERT INTO service_offering (name, code, fee) VALUES ('Motolite User Jumpstart Warranty Fee', 'motolite_user_jumpstart_warranty_fee', 200.00);
|
||||||
Loading…
Reference in a new issue