Resolve "Add inventory column to Job Order Details Report" #1684

Merged
korina.cordero merged 4 commits from 759-add-inventory-column-to-job-order-details-report into 746-resq-2-0-final 2023-09-05 20:00:37 +00:00
Showing only changes of commit d00b211363 - Show all commits

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]);