Add source to invoice criteria. Modify invoice rules to get service fees from database. Modify call to invoice to include source. #758

This commit is contained in:
Korina Cordero 2023-08-23 07:51:43 +00:00
parent e9631b437f
commit cfa77bf2e1
22 changed files with 330 additions and 103 deletions

View file

@ -1035,6 +1035,10 @@ class APIController extends Controller implements LoggedController
// set if taxable // set if taxable
$icrit->setIsTaxable(); $icrit->setIsTaxable();
// set JO source
// old app doesn't have separate jumpstart
$icrit->setSource(TransactionOrigin::CALL);
// send to invoice generator // send to invoice generator
$invoice = $ic->generateInvoice($icrit); $invoice = $ic->generateInvoice($icrit);
$jo->setInvoice($invoice); $jo->setInvoice($invoice);
@ -1317,6 +1321,10 @@ class APIController extends Controller implements LoggedController
// set taxable // set taxable
$icrit->setIsTaxable(true); $icrit->setIsTaxable(true);
// set JO source
// old app doesn't have separate jumpstart
$icrit->setSource(TransactionOrigin::CALL);
// check trade-in // check trade-in
// only allow motolite, other, none // only allow motolite, other, none
$trade_in = $req->request->get('trade_in'); $trade_in = $req->request->get('trade_in');
@ -2882,6 +2890,10 @@ class APIController extends Controller implements LoggedController
// set taxable // set taxable
$icrit->setIsTaxable(true); $icrit->setIsTaxable(true);
// set JO source
// old app doesn't have separate jumpstart
$icrit->setSource(TransactionOrigin::CALL);
// check promo // check promo
$promo_id = $req->request->get('promo_id'); $promo_id = $req->request->get('promo_id');
if (!empty($promo_id)) if (!empty($promo_id))

View file

@ -8,6 +8,7 @@ use Catalyst\ApiBundle\Component\Response as ApiResponse;
use App\Service\InvoiceGeneratorInterface; use App\Service\InvoiceGeneratorInterface;
use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceCriteria;
use App\Ramcar\TradeInType; use App\Ramcar\TradeInType;
use App\Ramcar\TransactionOrigin;
use App\Entity\CustomerVehicle; use App\Entity\CustomerVehicle;
use App\Entity\Promo; use App\Entity\Promo;
use App\Entity\Battery; use App\Entity\Battery;
@ -101,6 +102,9 @@ class InvoiceController extends ApiController
// set if taxable // set if taxable
$icrit->setIsTaxable(); $icrit->setIsTaxable();
// set JO source
$icrit->setSource(TransactionOrigin::MOBILE_APP);
// send to invoice generator // send to invoice generator
$invoice = $ic->generateInvoice($icrit); $invoice = $ic->generateInvoice($icrit);

View file

@ -682,6 +682,9 @@ class JobOrderController extends ApiController
// set taxable // set taxable
$icrit->setIsTaxable(); $icrit->setIsTaxable();
// set JO source
$icrit->setSource(TransactionOrigin::MOBILE_APP);
// send to invoice generator // send to invoice generator
$invoice = $ic->generateInvoice($icrit); $invoice = $ic->generateInvoice($icrit);
$jo->setInvoice($invoice); $jo->setInvoice($invoice);
@ -1087,6 +1090,9 @@ class JobOrderController extends ApiController
// set taxable // set taxable
$icrit->setIsTaxable(); $icrit->setIsTaxable();
// set JO source
$icrit->setSource(TransactionOrigin::MOBILE_APP);
$icrit->addEntry($batt, $trade_in, 1); $icrit->addEntry($batt, $trade_in, 1);
// send to invoice generator // send to invoice generator

View file

@ -7,6 +7,7 @@ use App\Ramcar\InvoiceCriteria;
use App\Ramcar\CMBServiceType; use App\Ramcar\CMBServiceType;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
use App\Ramcar\JOCancelReasons; use App\Ramcar\JOCancelReasons;
use App\Ramcar\TransactionOrigin;
use App\Entity\CustomerVehicle; use App\Entity\CustomerVehicle;
use App\Entity\Promo; use App\Entity\Promo;
@ -738,7 +739,8 @@ class JobOrderController extends Controller
$criteria = new InvoiceCriteria(); $criteria = new InvoiceCriteria();
$criteria->setServiceType($stype) $criteria->setServiceType($stype)
->setCustomerVehicle($cv) ->setCustomerVehicle($cv)
->setIsTaxable(); ->setIsTaxable()
->setSource(TransactionOrigin::CALL);
/* /*

View file

@ -160,6 +160,9 @@ class JobOrderController extends ApiController
// set taxable // set taxable
$icrit->setIsTaxable(); $icrit->setIsTaxable();
// set JO source
$icrit->setSource(TransactionOrigin::THIRD_PARTY);
$icrit->addEntry($data['batt'], $data['trade_in_type'], 1); $icrit->addEntry($data['batt'], $data['trade_in_type'], 1);
// send to invoice generator // send to invoice generator
@ -449,6 +452,12 @@ class JobOrderController extends ApiController
$icrit->addEntry($data['battery'], $data['trade_in_type'], 1); $icrit->addEntry($data['battery'], $data['trade_in_type'], 1);
// set taxable
$icrit->setIsTaxable();
// set JO source
$icrit->setSource('third_party');
// send to invoice generator // send to invoice generator
$invoice = $ic->generateInvoice($icrit); $invoice = $ic->generateInvoice($icrit);

View file

@ -10,6 +10,7 @@ use App\Ramcar\ServiceType;
use App\Ramcar\TradeInType; use App\Ramcar\TradeInType;
use App\Entity\Battery; use App\Entity\Battery;
use App\Entity\ServiceOffering;
class BatteryReplacementWarranty implements InvoiceRuleInterface class BatteryReplacementWarranty implements InvoiceRuleInterface
{ {
@ -59,10 +60,16 @@ class BatteryReplacementWarranty implements InvoiceRuleInterface
public function getServiceTypeFee() public function getServiceTypeFee()
{ {
// TODO: we need to to put this somewhere like in .env $code = 'battery_replacement_warranty_fee';
// so that if any chanages are to be made, we just edit the file
// instead of the code // find the service fee using the code
return 0; // if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -2,13 +2,25 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Ramcar\FuelType; use App\Ramcar\FuelType;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
use App\Entity\ServiceOffering;
use App\Entity\CustomerVehicle;
class Fuel implements InvoiceRuleInterface class Fuel implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'fuel'; return 'fuel';
@ -22,12 +34,9 @@ class Fuel implements InvoiceRuleInterface
if ($stype == $this->getID()) if ($stype == $this->getID())
{ {
// check if customer vehicle has a motolite battery
$cv = $criteria->getCustomerVehicle(); $cv = $criteria->getCustomerVehicle();
if ($cv->hasMotoliteBattery())
$fee = 0; $fee = $this->getServiceTypeFee($cv);
else
$fee = $this->getServiceTypeFee();
$ftype = $cv->getFuelType(); $ftype = $cv->getFuelType();
@ -82,29 +91,41 @@ class Fuel implements InvoiceRuleInterface
return $items; return $items;
} }
public function getServiceTypeFee() public function getServiceTypeFee(CustomerVehicle $cv)
{ {
// TODO: we need to to put this somewhere like in .env // check if customer vehicle has a motolite battery
// so that if any changes are to be made, we just edit the file // if yes, set the code to the motolite user service fee
// instead of the code if ($cv->hasMotoliteBattery())
return 300; $code = 'motolite_user_service_fee';
else
$code = 'fuel_service_fee';
// find the service fee using the code
// if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function getFuelFee($fuel_type) public function getFuelFee($fuel_type)
{ {
// TODO: we need to to put this somewhere like in .env $code = '';
// so that if any changes are to be made, we just edit the file
// instead of the code
if ($fuel_type == FuelType::GAS) if ($fuel_type == FuelType::GAS)
{ $code = 'fuel_gas_fee';
// gas fuel fee if ($fuel_type == FuelType::DIESEL)
return 340; $code = 'fuel_diesel_fee';
}
else // find the fuel fee for the specific fuel type using the code
{ // if we can't find the fee, return 0
// diesel fuel fee $fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
return 300;
} if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -2,10 +2,23 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Entity\ServiceOffering;
use App\Ramcar\TransactionOrigin;
class Jumpstart implements InvoiceRuleInterface class Jumpstart implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'jumpstart_troubleshoot'; return 'jumpstart_troubleshoot';
@ -14,12 +27,13 @@ class Jumpstart implements InvoiceRuleInterface
public function compute($criteria, &$total) public function compute($criteria, &$total)
{ {
$stype = $criteria->getServiceType(); $stype = $criteria->getServiceType();
$source = $criteria->getSource();
$items = []; $items = [];
if ($stype == $this->getID()) if ($stype == $this->getID())
{ {
$fee = $this->getServiceTypeFee(); $fee = $this->getServiceTypeFee($source);
// add the service fee to items // add the service fee to items
$qty = 1; $qty = 1;
@ -37,12 +51,23 @@ class Jumpstart implements InvoiceRuleInterface
return $items; return $items;
} }
public function getServiceTypeFee() public function getServiceTypeFee($source)
{ {
// TODO: we need to to put this somewhere like in .env // find the service fee for jumpstart using the code
// so that if any chanages are to be made, we just edit the file // if we can't find the fee, return 0
// instead of the code // jumpstart fee depends on the JO source. Jumpstart from app has a different fee
return 300; // we set the code to search for the default
$code = 'jumpstart_fee';
if ($source == TransactionOrigin::MOBILE_APP)
$code = 'jumpstart_fee_mobile_app';
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -2,10 +2,21 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Entity\ServiceOffering;
class JumpstartWarranty implements InvoiceRuleInterface class JumpstartWarranty implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'jumpstart_warranty'; return 'jumpstart_warranty';
@ -38,11 +49,17 @@ class JumpstartWarranty implements InvoiceRuleInterface
} }
public function getServiceTypeFee() public function getServiceTypeFee()
{ {
// TODO: we need to to put this somewhere like in .env $code = 'jumpstart_warranty_fee';
// so that if any chanages are to be made, we just edit the file
// instead of the code // find the service fee using the code
return 0; // if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -2,12 +2,24 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
use App\Entity\ServiceOffering;
use App\Entity\CustomerVehicle;
class Overheat implements InvoiceRuleInterface class Overheat implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'overheat'; return 'overheat';
@ -22,12 +34,8 @@ class Overheat implements InvoiceRuleInterface
if ($stype == $this->getID()) if ($stype == $this->getID())
{ {
// check if customer vehicle has a motolite battery
$cv = $criteria->getCustomerVehicle(); $cv = $criteria->getCustomerVehicle();
if ($cv->hasMotoliteBattery()) $fee = $this->getServiceTypeFee($cv);
$fee = 0;
else
$fee = $this->getServiceTypeFee();
// add the service fee to items // add the service fee to items
$qty = 1; $qty = 1;
@ -61,20 +69,37 @@ class Overheat implements InvoiceRuleInterface
return $items; return $items;
} }
public function getServiceTypeFee() public function getServiceTypeFee(CustomerVehicle $cv)
{ {
// TODO: we need to to put this somewhere like in .env $code = 'overheat_fee';
// so that if any chanages are to be made, we just edit the file
// instead of the code // check if customer vehicle has a motolite battery
return 300; // if yes, set the code to the motolite user service fee
if ($cv->hasMotoliteBattery())
$code = 'motolite_user_service_fee';
// find the service fee for overheat using the code
// if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function getCoolantFee() public function getCoolantFee()
{ {
// TODO: we need to to put this somewhere like in .env $code = 'coolant_fee';
// so that if any chanages are to be made, we just edit the file
// instead of the code // find the service fee using the code
return 1600; // if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy($code);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -2,10 +2,21 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Entity\ServiceOffering;
class PostRecharged implements InvoiceRuleInterface class PostRecharged implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'post_recharged'; return 'post_recharged';
@ -38,11 +49,17 @@ class PostRecharged implements InvoiceRuleInterface
} }
public function getServiceTypeFee() public function getServiceTypeFee()
{ {
// TODO: we need to to put this somewhere like in .env $code = 'post_recharged_fee';
// so that if any chanages are to be made, we just edit the file
// instead of the code // find the service fee for post recharged using the code
return 300; // if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -2,10 +2,21 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Entity\ServiceOffering;
class PostReplacement implements InvoiceRuleInterface class PostReplacement implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'post_replacement'; return 'post_replacement';
@ -37,11 +48,17 @@ class PostReplacement implements InvoiceRuleInterface
} }
public function getServiceTypeFee() public function getServiceTypeFee()
{ {
// TODO: we need to to put this somewhere like in .env $code = 'post_replacement_fee';
// so that if any chanages are to be made, we just edit the file
// instead of the code // find the service fee using the code
return 0; // if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -2,12 +2,23 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
use App\Entity\ServiceOffering;
class Tax implements InvoiceRuleInterface class Tax implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'tax'; return 'tax';
@ -101,10 +112,16 @@ class Tax implements InvoiceRuleInterface
protected function getTaxRate() protected function getTaxRate()
{ {
// TODO: we need to to put this somewhere like in .env $code = 'tax';
// so that if any chanages are to be made, we just edit the file
// instead of the code // find the service fee using the code
return 0.12; // if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
} }

View file

@ -2,10 +2,22 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Entity\ServiceOffering;
use App\Entity\CustomerVehicle;
class TireRepair implements InvoiceRuleInterface class TireRepair implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'tire'; return 'tire';
@ -19,12 +31,8 @@ class TireRepair implements InvoiceRuleInterface
if ($stype == $this->getID()) if ($stype == $this->getID())
{ {
// check if customer vehicle has a motolite battery
$cv = $criteria->getCustomerVehicle(); $cv = $criteria->getCustomerVehicle();
if ($cv->hasMotoliteBattery()) $fee = $this->getServiceTypeFee($cv);
$fee = 0;
else
$fee = $this->getServiceTypeFee();
// add the service fee to items // add the service fee to items
$qty = 1; $qty = 1;
@ -42,12 +50,23 @@ class TireRepair implements InvoiceRuleInterface
return $items; return $items;
} }
protected function getServiceTypeFee() protected function getServiceTypeFee(CustomerVehicle $cv)
{ {
// TODO: we need to to put this somewhere like in .env $code = 'tire_repair_fee';
// so that if any chanages are to be made, we just edit the file
// instead of the code // check if customer vehicle has a motolite battery
return 300; // if yes, set the code to the motolite user service fee
if ($cv->hasMotoliteBattery())
$code = 'motolite_user_service_fee';
// find the service fee using the code
// if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee == null)
return 0;
return $fee->getFee();
} }
public function validatePromo($criteria, $promo_id) public function validatePromo($criteria, $promo_id)

View file

@ -16,6 +16,7 @@ class InvoiceCriteria
protected $discount; protected $discount;
protected $service_charges; protected $service_charges;
protected $flag_taxable; protected $flag_taxable;
protected $source; // use Ramcar's TransactionOrigin
// entries are battery and trade-in combos // entries are battery and trade-in combos
protected $entries; protected $entries;
@ -30,6 +31,7 @@ class InvoiceCriteria
$this->discount = 0; $this->discount = 0;
$this->service_charges = []; $this->service_charges = [];
$this->flag_taxable = false; $this->flag_taxable = false;
$this->source = '';
} }
public function setServiceType($stype) public function setServiceType($stype)
@ -166,4 +168,15 @@ class InvoiceCriteria
return $this->flag_taxable; return $this->flag_taxable;
} }
public function setSource($source)
{
$this->source = $source;
return $this;
}
public function getSource()
{
return $this->source;
}
} }

View file

@ -134,7 +134,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
} }
// generate invoice criteria // generate invoice criteria
public function generateInvoiceCriteria($jo, $discount, $invoice_items, &$error_array) public function generateInvoiceCriteria($jo, $discount, $invoice_items, $source = null, &$error_array)
{ {
$em = $this->em; $em = $this->em;

View file

@ -144,7 +144,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
} }
// generate invoice criteria // generate invoice criteria
public function generateInvoiceCriteria($jo, $promo_id, $invoice_items, &$error_array) public function generateInvoiceCriteria($jo, $promo_id, $invoice_items, $source = null, &$error_array)
{ {
$em = $this->em; $em = $this->em;

View file

@ -13,7 +13,7 @@ interface InvoiceGeneratorInterface
public function generateInvoice(InvoiceCriteria $criteria); public function generateInvoice(InvoiceCriteria $criteria);
// generate invoice criteria // generate invoice criteria
public function generateInvoiceCriteria(JobOrder $jo, int $promo_id, array $invoice_items, array &$error_array); public function generateInvoiceCriteria(JobOrder $jo, int $promo_id, array $invoice_items, $source, array &$error_array);
// prepare draft for invoice // prepare draft for invoice
public function generateDraftInvoice(InvoiceCriteria $criteria, int $promo_id, array $service_charges, array $items); public function generateDraftInvoice(InvoiceCriteria $criteria, int $promo_id, array $service_charges, array $items);

View file

@ -44,21 +44,21 @@ class InvoiceManager implements InvoiceGeneratorInterface
return [ return [
new InvoiceRule\BatterySales($this->em), new InvoiceRule\BatterySales($this->em),
new InvoiceRule\BatteryReplacementWarranty($this->em), new InvoiceRule\BatteryReplacementWarranty($this->em),
new InvoiceRule\Jumpstart(), new InvoiceRule\Jumpstart($this->em),
new InvoiceRule\JumpstartWarranty(), new InvoiceRule\JumpstartWarranty($this->em),
new InvoiceRule\PostRecharged(), new InvoiceRule\PostRecharged($this->em),
new InvoiceRule\PostReplacement(), new InvoiceRule\PostReplacement($this->em),
new InvoiceRule\Overheat(), new InvoiceRule\Overheat($this->em),
new InvoiceRule\Fuel(), new InvoiceRule\Fuel($this->em),
new InvoiceRule\TireRepair(), new InvoiceRule\TireRepair($this->em),
new InvoiceRule\DiscountType($this->em), new InvoiceRule\DiscountType($this->em),
new InvoiceRule\TradeIn(), new InvoiceRule\TradeIn(),
new InvoiceRule\Tax(), new InvoiceRule\Tax($this->em),
]; ];
} }
// this is called when JO is submitted // this is called when JO is submitted
public function generateInvoiceCriteria($jo, $promo_id, $invoice_items, &$error_array) public function generateInvoiceCriteria($jo, $promo_id, $invoice_items, $source, &$error_array)
{ {
// instantiate the invoice criteria // instantiate the invoice criteria
$criteria = new InvoiceCriteria(); $criteria = new InvoiceCriteria();
@ -70,6 +70,9 @@ class InvoiceManager implements InvoiceGeneratorInterface
// would mean adding it as a parameter to the call, impacting all calls // would mean adding it as a parameter to the call, impacting all calls
$criteria->setIsTaxable(); $criteria->setIsTaxable();
// set JO source
$criteria->setSource($source);
foreach ($this->available_rules as $avail_rule) foreach ($this->available_rules as $avail_rule)
{ {
$ierror = $avail_rule->validatePromo($criteria, $promo_id); $ierror = $avail_rule->validatePromo($criteria, $promo_id);
@ -185,6 +188,7 @@ class InvoiceManager implements InvoiceGeneratorInterface
]; ];
// get what is in criteria // get what is in criteria
// NOTE: is this snippet still needed? if not, remove
$stype = $criteria->getServiceType(); $stype = $criteria->getServiceType();
$entries = $criteria->getEntries(); $entries = $criteria->getEntries();
$promos = $criteria->getPromos(); $promos = $criteria->getPromos();

View file

@ -562,7 +562,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// check if invoice changed // check if invoice changed
if ($invoice_change) if ($invoice_change)
{ {
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); $source = $jo->getSource();
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $source, $error_array);
} }
// validate // validate
@ -792,7 +794,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$invoice_change = $req->request->get('invoice_change', 0); $invoice_change = $req->request->get('invoice_change', 0);
if ($invoice_change) if ($invoice_change)
{ {
$this->ic->generateInvoiceCriteria($obj, $promo_id, $invoice_items, $error_array); $source = $obj->getSource();
$this->ic->generateInvoiceCriteria($obj, $promo_id, $invoice_items, $source, $error_array);
} }
// validate // validate
@ -2135,7 +2139,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// check if invoice changed // check if invoice changed
if ($invoice_change) if ($invoice_change)
{ {
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); // NOTE: this is CMB code but for compilation purposes we need to add this
$source = $jo->getSource();
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $source, $error_array);
} }
// validate // validate

View file

@ -16,6 +16,7 @@ use App\Ramcar\InvoiceStatus;
use App\Ramcar\ModeOfPayment; use App\Ramcar\ModeOfPayment;
use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceCriteria;
use App\Ramcar\WarrantySource; use App\Ramcar\WarrantySource;
use App\Ramcar\TransactionOrigin;
use App\Service\RiderAPIHandlerInterface; use App\Service\RiderAPIHandlerInterface;
use App\Service\RedisClientProvider; use App\Service\RedisClientProvider;
@ -869,6 +870,10 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
// set istaxable // set istaxable
$crit->setIsTaxable(); $crit->setIsTaxable();
// set JO source
// set to anything other than mobile app
$icrit->setSource(TransactionOrigin::WALK_IN);
if ($promo != null) if ($promo != null)
$crit->addPromo($promo); $crit->addPromo($promo);

View file

@ -38,7 +38,7 @@ CREATE TABLE `service_offering` (
LOCK TABLES `service_offering` WRITE; LOCK TABLES `service_offering` WRITE;
/*!40000 ALTER TABLE `service_offering` DISABLE KEYS */; /*!40000 ALTER TABLE `service_offering` DISABLE KEYS */;
INSERT INTO `service_offering` VALUES (1,'Tax','tax',0.12),(2,'Motolite User Service Fee','motolite_service_fee',0.00),(3,'Battery Replacement Warranty Fee','battery_replacement_warranty_fee',0.00),(4,'Fuel Service Fee','fuel_service_fee',300.00),(5,'Fuel Gas Fee','fuel_gas_fee',340.00),(6,'Fuel Diesel Fee','fuel_diesel_fee',300.00),(7,'Jumpstart Fee','jumpstart_fee',150.00),(8,'Jumpstart Fee Mobile App','jumpstart_fee_mobile_app',300.00),(9,'Jumpstart Warranty Fee','jumpstart_warranty_fee',0.00),(10,'Overheat Fee','overheat_fee',300.00),(11,'Coolant Fee','coolant_fee',1600.00),(12,'Post Recharged Fee','post_recharged_fee',300.00),(13,'Post Replacement Fee','post_replacement_fee',0.00),(14,'Tire Repair Fee','tire_repair_fee',300.00); INSERT INTO `service_offering` VALUES (1,'Tax','tax',0.12),(2,'Motolite User Service Fee','motolite_user_service_fee',0.00),(3,'Battery Replacement Warranty Fee','battery_replacement_warranty_fee',0.00),(4,'Fuel Service Fee','fuel_service_fee',300.00),(5,'Fuel Gas Fee','fuel_gas_fee',340.00),(6,'Fuel Diesel Fee','fuel_diesel_fee',300.00),(7,'Jumpstart Fee','jumpstart_fee',150.00),(8,'Jumpstart Fee Mobile App','jumpstart_fee_mobile_app',300.00),(9,'Jumpstart Warranty Fee','jumpstart_warranty_fee',0.00),(10,'Overheat Fee','overheat_fee',300.00),(11,'Coolant Fee','coolant_fee',1600.00),(12,'Post Recharged Fee','post_recharged_fee',300.00),(13,'Post Replacement Fee','post_replacement_fee',0.00),(14,'Tire Repair Fee','tire_repair_fee',300.00);
/*!40000 ALTER TABLE `service_offering` ENABLE KEYS */; /*!40000 ALTER TABLE `service_offering` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@ -51,4 +51,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-08-22 10:50:35 -- Dump completed on 2023-08-23 2:02:51