Add processing of sealant fee for tire repair service. #811
This commit is contained in:
parent
dc4d5f90a7
commit
1b24e68f6b
5 changed files with 101 additions and 3 deletions
|
|
@ -386,6 +386,7 @@ class RiderAppController extends ApiController
|
|||
'flag_coolant' => $jo->hasCoolant(),
|
||||
'has_motolite' => $cv->hasMotoliteBattery(),
|
||||
'delivery_status' => $jo->getDeliveryStatus(),
|
||||
'flag_sealant' => $jo->hasSealant(),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
@ -1324,7 +1325,7 @@ class RiderAppController extends ApiController
|
|||
return new APIResponse(false, 'Invalid promo id - ' . $promo_id);
|
||||
}
|
||||
|
||||
// get other parameters, if any: has motolite battery, has warranty doc, with coolant, payment method
|
||||
// get other parameters, if any: has motolite battery, has warranty doc, with coolant, payment method, with sealant
|
||||
if (isset($items['flag_motolite_battery']))
|
||||
{
|
||||
// get customer vehicle from jo
|
||||
|
|
@ -1359,6 +1360,15 @@ class RiderAppController extends ApiController
|
|||
$jo->setModeOfPayment($payment_method);
|
||||
}
|
||||
|
||||
if (isset($items['flag_sealant']))
|
||||
{
|
||||
$has_sealant = $items['flag_sealant'];
|
||||
if ($has_sealant == 'true')
|
||||
$jo->setHasSealant(true);
|
||||
else
|
||||
$jo->setHasSealant(false);
|
||||
}
|
||||
|
||||
// get capi user
|
||||
$capi_user = $this->getUser();
|
||||
if ($capi_user == null)
|
||||
|
|
@ -1443,6 +1453,13 @@ class RiderAppController extends ApiController
|
|||
else
|
||||
$jo->setHasCoolant(false);
|
||||
|
||||
// sealant
|
||||
$flag_sealant = $req->request->get('flag_sealant', 'false');
|
||||
if ($flag_sealant == 'true')
|
||||
$jo->setHasSealant(true);
|
||||
else
|
||||
$jo->setHasSealant(false);
|
||||
|
||||
// has motolite battery
|
||||
$cv = $jo->getCustomerVehicle();
|
||||
$has_motolite = $req->request->get('has_motolite', 'false');
|
||||
|
|
@ -1543,6 +1560,9 @@ class RiderAppController extends ApiController
|
|||
// get coolant if any
|
||||
$flag_coolant = $jo->hasCoolant();
|
||||
|
||||
// get sealant if any
|
||||
$flag_sealant = $jo->hasSealant();
|
||||
|
||||
// check if new promo is null
|
||||
if ($promo == null)
|
||||
{
|
||||
|
|
@ -1561,6 +1581,7 @@ class RiderAppController extends ApiController
|
|||
->setCustomerVehicle($cv)
|
||||
->setSource($source)
|
||||
->setHasCoolant($flag_coolant)
|
||||
->setHasSealant($flag_sealant)
|
||||
->setIsTaxable();
|
||||
|
||||
// set price tier
|
||||
|
|
|
|||
|
|
@ -441,6 +441,12 @@ class JobOrder
|
|||
*/
|
||||
protected $flag_cust_new;
|
||||
|
||||
// only for tire service, if it requires sealant or not
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $flag_sealant;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date_create = new DateTime();
|
||||
|
|
@ -458,6 +464,7 @@ class JobOrder
|
|||
$this->trade_in_type = null;
|
||||
$this->flag_rider_rating = false;
|
||||
$this->flag_coolant = false;
|
||||
$this->flag_sealant = false;
|
||||
|
||||
$this->priority = 0;
|
||||
$this->meta = [];
|
||||
|
|
@ -1256,4 +1263,15 @@ class JobOrder
|
|||
return $this->flag_cust_new;
|
||||
}
|
||||
|
||||
public function setHasSealant($flag = true)
|
||||
{
|
||||
$this->flag_sealant = $flag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasSealant()
|
||||
{
|
||||
return $this->flag_sealant;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class TireRepair implements InvoiceRuleInterface
|
|||
public function compute($criteria, &$total)
|
||||
{
|
||||
$stype = $criteria->getServiceType();
|
||||
$has_sealant = $criteria->hasSealant();
|
||||
$pt_id = $criteria->getPriceTier();
|
||||
|
||||
$items = [];
|
||||
|
|
@ -56,8 +57,28 @@ class TireRepair implements InvoiceRuleInterface
|
|||
'price' => $price,
|
||||
];
|
||||
|
||||
$qty_price = bcmul($price, $qty, 2);
|
||||
$total['total_price'] = bcadd($total['total_price'], $qty_price, 2);
|
||||
$qty_fee = bcmul($qty, $price, 2);
|
||||
$total_price = $qty_fee;
|
||||
|
||||
if ($has_sealant)
|
||||
{
|
||||
$sealant_fee_data = $this->getSealantFeeData();
|
||||
|
||||
$sealant_fee = $sealant_fee_data['fee'];
|
||||
$sealant_title = $sealant_fee_data['title'];
|
||||
|
||||
$items[] = [
|
||||
'service_type' => $this->getID(),
|
||||
'qty' => $qty,
|
||||
'title' => $sealant_title,
|
||||
'price' => $sealant_fee,
|
||||
];
|
||||
|
||||
$qty_price = bcmul($sealant_fee, $qty, 2);
|
||||
$total_price = bcadd($total_price, $qty_price, 2);
|
||||
}
|
||||
|
||||
$total['total_price'] = bcadd($total['total_price'], $total_price, 2);
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
|
@ -131,4 +152,28 @@ class TireRepair implements InvoiceRuleInterface
|
|||
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getSealantFeeData()
|
||||
{
|
||||
$data = [
|
||||
'fee' => 0.00,
|
||||
'title' => '',
|
||||
];
|
||||
|
||||
$code = 'tire_sealant_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)
|
||||
{
|
||||
$data = [
|
||||
'fee' => $fee->getFee(),
|
||||
'title' => $fee->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class InvoiceCriteria
|
|||
protected $flag_taxable;
|
||||
protected $source; // use Ramcar's TransactionOrigin
|
||||
protected $price_tier;
|
||||
protected $flag_sealant;
|
||||
|
||||
// entries are battery and trade-in combos
|
||||
protected $entries;
|
||||
|
|
@ -34,6 +35,7 @@ class InvoiceCriteria
|
|||
$this->flag_taxable = false;
|
||||
$this->source = '';
|
||||
$this->price_tier = 0; // set to default
|
||||
$this->flag_sealant = false;
|
||||
}
|
||||
|
||||
public function setServiceType($stype)
|
||||
|
|
@ -202,4 +204,15 @@ class InvoiceCriteria
|
|||
{
|
||||
return $this->price_tier;
|
||||
}
|
||||
|
||||
public function setHasSealant($flag = true)
|
||||
{
|
||||
$this->flag_sealant = $flag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasSealant()
|
||||
{
|
||||
return $this->flag_sealant;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
utils/service_offering/insert_sealant_fee.sql
Normal file
1
utils/service_offering/insert_sealant_fee.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
INSERT INTO service_offering (name, code, fee) VALUES ('Tire Sealant Fee', 'tire_sealant_fee', '200.00');
|
||||
Loading…
Reference in a new issue