Merge branch '746-resq-2-0-final' of gitlab.com:jankstudio/resq into 759-add-inventory-column-to-job-order-details-report

This commit is contained in:
Korina Cordero 2023-08-29 10:15:09 +08:00
commit d00b211363

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)
{
$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 // find the service fee for jumpstart using the code
// if we can't find the fee, return 0 // if we can't find the fee, return 0
// jumpstart fee depends on the JO source. Jumpstart from app has a different fee // jumpstart fee depends on the JO source. Jumpstart from app has a different fee
// we set the code to search for the default // we set the code to search for the default
$code = 'jumpstart_fee';
if ($source == TransactionOrigin::MOBILE_APP) if ($source == TransactionOrigin::MOBILE_APP)
$code = 'jumpstart_fee_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]);