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:
parent
e9631b437f
commit
cfa77bf2e1
22 changed files with 330 additions and 103 deletions
|
|
@ -1035,6 +1035,10 @@ class APIController extends Controller implements LoggedController
|
|||
// set if taxable
|
||||
$icrit->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
// old app doesn't have separate jumpstart
|
||||
$icrit->setSource(TransactionOrigin::CALL);
|
||||
|
||||
// send to invoice generator
|
||||
$invoice = $ic->generateInvoice($icrit);
|
||||
$jo->setInvoice($invoice);
|
||||
|
|
@ -1317,6 +1321,10 @@ class APIController extends Controller implements LoggedController
|
|||
// set taxable
|
||||
$icrit->setIsTaxable(true);
|
||||
|
||||
// set JO source
|
||||
// old app doesn't have separate jumpstart
|
||||
$icrit->setSource(TransactionOrigin::CALL);
|
||||
|
||||
// check trade-in
|
||||
// only allow motolite, other, none
|
||||
$trade_in = $req->request->get('trade_in');
|
||||
|
|
@ -2882,6 +2890,10 @@ class APIController extends Controller implements LoggedController
|
|||
// set taxable
|
||||
$icrit->setIsTaxable(true);
|
||||
|
||||
// set JO source
|
||||
// old app doesn't have separate jumpstart
|
||||
$icrit->setSource(TransactionOrigin::CALL);
|
||||
|
||||
// check promo
|
||||
$promo_id = $req->request->get('promo_id');
|
||||
if (!empty($promo_id))
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
|||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\TradeInType;
|
||||
use App\Ramcar\TransactionOrigin;
|
||||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\Promo;
|
||||
use App\Entity\Battery;
|
||||
|
|
@ -101,6 +102,9 @@ class InvoiceController extends ApiController
|
|||
// set if taxable
|
||||
$icrit->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
$icrit->setSource(TransactionOrigin::MOBILE_APP);
|
||||
|
||||
// send to invoice generator
|
||||
$invoice = $ic->generateInvoice($icrit);
|
||||
|
||||
|
|
|
|||
|
|
@ -682,6 +682,9 @@ class JobOrderController extends ApiController
|
|||
// set taxable
|
||||
$icrit->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
$icrit->setSource(TransactionOrigin::MOBILE_APP);
|
||||
|
||||
// send to invoice generator
|
||||
$invoice = $ic->generateInvoice($icrit);
|
||||
$jo->setInvoice($invoice);
|
||||
|
|
@ -1087,6 +1090,9 @@ class JobOrderController extends ApiController
|
|||
// set taxable
|
||||
$icrit->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
$icrit->setSource(TransactionOrigin::MOBILE_APP);
|
||||
|
||||
$icrit->addEntry($batt, $trade_in, 1);
|
||||
|
||||
// send to invoice generator
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Ramcar\InvoiceCriteria;
|
|||
use App\Ramcar\CMBServiceType;
|
||||
use App\Ramcar\ServiceType;
|
||||
use App\Ramcar\JOCancelReasons;
|
||||
use App\Ramcar\TransactionOrigin;
|
||||
|
||||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\Promo;
|
||||
|
|
@ -738,7 +739,8 @@ class JobOrderController extends Controller
|
|||
$criteria = new InvoiceCriteria();
|
||||
$criteria->setServiceType($stype)
|
||||
->setCustomerVehicle($cv)
|
||||
->setIsTaxable();
|
||||
->setIsTaxable()
|
||||
->setSource(TransactionOrigin::CALL);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -160,6 +160,9 @@ class JobOrderController extends ApiController
|
|||
// set taxable
|
||||
$icrit->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
$icrit->setSource(TransactionOrigin::THIRD_PARTY);
|
||||
|
||||
$icrit->addEntry($data['batt'], $data['trade_in_type'], 1);
|
||||
|
||||
// send to invoice generator
|
||||
|
|
@ -449,6 +452,12 @@ class JobOrderController extends ApiController
|
|||
|
||||
$icrit->addEntry($data['battery'], $data['trade_in_type'], 1);
|
||||
|
||||
// set taxable
|
||||
$icrit->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
$icrit->setSource('third_party');
|
||||
|
||||
// send to invoice generator
|
||||
$invoice = $ic->generateInvoice($icrit);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use App\Ramcar\ServiceType;
|
|||
use App\Ramcar\TradeInType;
|
||||
|
||||
use App\Entity\Battery;
|
||||
use App\Entity\ServiceOffering;
|
||||
|
||||
class BatteryReplacementWarranty implements InvoiceRuleInterface
|
||||
{
|
||||
|
|
@ -59,10 +60,16 @@ class BatteryReplacementWarranty implements InvoiceRuleInterface
|
|||
|
||||
public function getServiceTypeFee()
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 0;
|
||||
$code = 'battery_replacement_warranty_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)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,25 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Ramcar\FuelType;
|
||||
use App\Ramcar\ServiceType;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
use App\Entity\CustomerVehicle;
|
||||
|
||||
class Fuel implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'fuel';
|
||||
|
|
@ -22,12 +34,9 @@ class Fuel implements InvoiceRuleInterface
|
|||
|
||||
if ($stype == $this->getID())
|
||||
{
|
||||
// check if customer vehicle has a motolite battery
|
||||
$cv = $criteria->getCustomerVehicle();
|
||||
if ($cv->hasMotoliteBattery())
|
||||
$fee = 0;
|
||||
else
|
||||
$fee = $this->getServiceTypeFee();
|
||||
|
||||
$fee = $this->getServiceTypeFee($cv);
|
||||
|
||||
$ftype = $cv->getFuelType();
|
||||
|
||||
|
|
@ -82,29 +91,41 @@ class Fuel implements InvoiceRuleInterface
|
|||
return $items;
|
||||
}
|
||||
|
||||
public function getServiceTypeFee()
|
||||
public function getServiceTypeFee(CustomerVehicle $cv)
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any changes are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 300;
|
||||
// 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
|
||||
$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)
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any changes are to be made, we just edit the file
|
||||
// instead of the code
|
||||
$code = '';
|
||||
if ($fuel_type == FuelType::GAS)
|
||||
{
|
||||
// gas fuel fee
|
||||
return 340;
|
||||
}
|
||||
else
|
||||
{
|
||||
// diesel fuel fee
|
||||
return 300;
|
||||
}
|
||||
$code = 'fuel_gas_fee';
|
||||
if ($fuel_type == FuelType::DIESEL)
|
||||
$code = 'fuel_diesel_fee';
|
||||
|
||||
// find the fuel fee for the specific fuel type 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)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,23 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
|
||||
use App\Ramcar\TransactionOrigin;
|
||||
|
||||
class Jumpstart implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'jumpstart_troubleshoot';
|
||||
|
|
@ -14,12 +27,13 @@ class Jumpstart implements InvoiceRuleInterface
|
|||
public function compute($criteria, &$total)
|
||||
{
|
||||
$stype = $criteria->getServiceType();
|
||||
$source = $criteria->getSource();
|
||||
|
||||
$items = [];
|
||||
|
||||
if ($stype == $this->getID())
|
||||
{
|
||||
$fee = $this->getServiceTypeFee();
|
||||
$fee = $this->getServiceTypeFee($source);
|
||||
|
||||
// add the service fee to items
|
||||
$qty = 1;
|
||||
|
|
@ -37,12 +51,23 @@ class Jumpstart implements InvoiceRuleInterface
|
|||
return $items;
|
||||
}
|
||||
|
||||
public function getServiceTypeFee()
|
||||
public function getServiceTypeFee($source)
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 300;
|
||||
// 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';
|
||||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,21 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
|
||||
class JumpstartWarranty implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'jumpstart_warranty';
|
||||
|
|
@ -39,10 +50,16 @@ class JumpstartWarranty implements InvoiceRuleInterface
|
|||
|
||||
public function getServiceTypeFee()
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 0;
|
||||
$code = 'jumpstart_warranty_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)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,24 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Ramcar\ServiceType;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
use App\Entity\CustomerVehicle;
|
||||
|
||||
class Overheat implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'overheat';
|
||||
|
|
@ -22,12 +34,8 @@ class Overheat implements InvoiceRuleInterface
|
|||
|
||||
if ($stype == $this->getID())
|
||||
{
|
||||
// check if customer vehicle has a motolite battery
|
||||
$cv = $criteria->getCustomerVehicle();
|
||||
if ($cv->hasMotoliteBattery())
|
||||
$fee = 0;
|
||||
else
|
||||
$fee = $this->getServiceTypeFee();
|
||||
$fee = $this->getServiceTypeFee($cv);
|
||||
|
||||
// add the service fee to items
|
||||
$qty = 1;
|
||||
|
|
@ -61,20 +69,37 @@ class Overheat implements InvoiceRuleInterface
|
|||
return $items;
|
||||
}
|
||||
|
||||
public function getServiceTypeFee()
|
||||
public function getServiceTypeFee(CustomerVehicle $cv)
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 300;
|
||||
$code = 'overheat_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';
|
||||
|
||||
// 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()
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 1600;
|
||||
$code = 'coolant_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);
|
||||
|
||||
if ($fee == null)
|
||||
return 0;
|
||||
|
||||
return $fee->getFee();
|
||||
}
|
||||
|
||||
public function validatePromo($criteria, $promo_id)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,21 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
|
||||
class PostRecharged implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'post_recharged';
|
||||
|
|
@ -39,10 +50,16 @@ class PostRecharged implements InvoiceRuleInterface
|
|||
|
||||
public function getServiceTypeFee()
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 300;
|
||||
$code = 'post_recharged_fee';
|
||||
|
||||
// find the service fee for post recharged 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)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,21 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
|
||||
class PostReplacement implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'post_replacement';
|
||||
|
|
@ -38,10 +49,16 @@ class PostReplacement implements InvoiceRuleInterface
|
|||
|
||||
public function getServiceTypeFee()
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 0;
|
||||
$code = 'post_replacement_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)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,23 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Ramcar\ServiceType;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
|
||||
class Tax implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'tax';
|
||||
|
|
@ -101,10 +112,16 @@ class Tax implements InvoiceRuleInterface
|
|||
|
||||
protected function getTaxRate()
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 0.12;
|
||||
$code = 'tax';
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,22 @@
|
|||
|
||||
namespace App\InvoiceRule;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\InvoiceRuleInterface;
|
||||
|
||||
use App\Entity\ServiceOffering;
|
||||
use App\Entity\CustomerVehicle;
|
||||
|
||||
class TireRepair implements InvoiceRuleInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return 'tire';
|
||||
|
|
@ -19,12 +31,8 @@ class TireRepair implements InvoiceRuleInterface
|
|||
|
||||
if ($stype == $this->getID())
|
||||
{
|
||||
// check if customer vehicle has a motolite battery
|
||||
$cv = $criteria->getCustomerVehicle();
|
||||
if ($cv->hasMotoliteBattery())
|
||||
$fee = 0;
|
||||
else
|
||||
$fee = $this->getServiceTypeFee();
|
||||
$fee = $this->getServiceTypeFee($cv);
|
||||
|
||||
// add the service fee to items
|
||||
$qty = 1;
|
||||
|
|
@ -42,12 +50,23 @@ class TireRepair implements InvoiceRuleInterface
|
|||
return $items;
|
||||
}
|
||||
|
||||
protected function getServiceTypeFee()
|
||||
protected function getServiceTypeFee(CustomerVehicle $cv)
|
||||
{
|
||||
// TODO: we need to to put this somewhere like in .env
|
||||
// so that if any chanages are to be made, we just edit the file
|
||||
// instead of the code
|
||||
return 300;
|
||||
$code = 'tire_repair_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';
|
||||
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class InvoiceCriteria
|
|||
protected $discount;
|
||||
protected $service_charges;
|
||||
protected $flag_taxable;
|
||||
protected $source; // use Ramcar's TransactionOrigin
|
||||
|
||||
// entries are battery and trade-in combos
|
||||
protected $entries;
|
||||
|
|
@ -30,6 +31,7 @@ class InvoiceCriteria
|
|||
$this->discount = 0;
|
||||
$this->service_charges = [];
|
||||
$this->flag_taxable = false;
|
||||
$this->source = '';
|
||||
}
|
||||
|
||||
public function setServiceType($stype)
|
||||
|
|
@ -166,4 +168,15 @@ class InvoiceCriteria
|
|||
return $this->flag_taxable;
|
||||
}
|
||||
|
||||
public function setSource($source)
|
||||
{
|
||||
$this->source = $source;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSource()
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ interface InvoiceGeneratorInterface
|
|||
public function generateInvoice(InvoiceCriteria $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
|
||||
public function generateDraftInvoice(InvoiceCriteria $criteria, int $promo_id, array $service_charges, array $items);
|
||||
|
|
|
|||
|
|
@ -44,21 +44,21 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
|||
return [
|
||||
new InvoiceRule\BatterySales($this->em),
|
||||
new InvoiceRule\BatteryReplacementWarranty($this->em),
|
||||
new InvoiceRule\Jumpstart(),
|
||||
new InvoiceRule\JumpstartWarranty(),
|
||||
new InvoiceRule\PostRecharged(),
|
||||
new InvoiceRule\PostReplacement(),
|
||||
new InvoiceRule\Overheat(),
|
||||
new InvoiceRule\Fuel(),
|
||||
new InvoiceRule\TireRepair(),
|
||||
new InvoiceRule\Jumpstart($this->em),
|
||||
new InvoiceRule\JumpstartWarranty($this->em),
|
||||
new InvoiceRule\PostRecharged($this->em),
|
||||
new InvoiceRule\PostReplacement($this->em),
|
||||
new InvoiceRule\Overheat($this->em),
|
||||
new InvoiceRule\Fuel($this->em),
|
||||
new InvoiceRule\TireRepair($this->em),
|
||||
new InvoiceRule\DiscountType($this->em),
|
||||
new InvoiceRule\TradeIn(),
|
||||
new InvoiceRule\Tax(),
|
||||
new InvoiceRule\Tax($this->em),
|
||||
];
|
||||
}
|
||||
|
||||
// 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
|
||||
$criteria = new InvoiceCriteria();
|
||||
|
|
@ -70,6 +70,9 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
|||
// would mean adding it as a parameter to the call, impacting all calls
|
||||
$criteria->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
$criteria->setSource($source);
|
||||
|
||||
foreach ($this->available_rules as $avail_rule)
|
||||
{
|
||||
$ierror = $avail_rule->validatePromo($criteria, $promo_id);
|
||||
|
|
@ -185,6 +188,7 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
|||
];
|
||||
|
||||
// get what is in criteria
|
||||
// NOTE: is this snippet still needed? if not, remove
|
||||
$stype = $criteria->getServiceType();
|
||||
$entries = $criteria->getEntries();
|
||||
$promos = $criteria->getPromos();
|
||||
|
|
|
|||
|
|
@ -562,7 +562,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
// check if invoice changed
|
||||
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
|
||||
|
|
@ -792,7 +794,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$invoice_change = $req->request->get('invoice_change', 0);
|
||||
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
|
||||
|
|
@ -2135,7 +2139,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
// check if invoice changed
|
||||
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
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use App\Ramcar\InvoiceStatus;
|
|||
use App\Ramcar\ModeOfPayment;
|
||||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\WarrantySource;
|
||||
use App\Ramcar\TransactionOrigin;
|
||||
|
||||
use App\Service\RiderAPIHandlerInterface;
|
||||
use App\Service\RedisClientProvider;
|
||||
|
|
@ -869,6 +870,10 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
// set istaxable
|
||||
$crit->setIsTaxable();
|
||||
|
||||
// set JO source
|
||||
// set to anything other than mobile app
|
||||
$icrit->setSource(TransactionOrigin::WALK_IN);
|
||||
|
||||
if ($promo != null)
|
||||
$crit->addPromo($promo);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ CREATE TABLE `service_offering` (
|
|||
|
||||
LOCK TABLES `service_offering` WRITE;
|
||||
/*!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 */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
|
@ -51,4 +51,4 @@ UNLOCK TABLES;
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!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
|
||||
|
|
|
|||
Loading…
Reference in a new issue