Support new services #110
This commit is contained in:
parent
55bc1b8a01
commit
4652a82fff
3 changed files with 42 additions and 13 deletions
|
|
@ -690,7 +690,7 @@ class APIController extends Controller
|
|||
$required_params = [
|
||||
'service_type',
|
||||
'cv_id',
|
||||
'batt_id',
|
||||
// 'batt_id',
|
||||
'trade_in',
|
||||
'long',
|
||||
'lat',
|
||||
|
|
@ -784,13 +784,19 @@ class APIController extends Controller
|
|||
}
|
||||
|
||||
// check battery
|
||||
$batt = $em->getRepository(Battery::class)->find($req->request->get('batt_id'));
|
||||
if ($batt == null)
|
||||
$batt_id = $req->request->get('batt_id');
|
||||
if ($batt_id != null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid battery id');
|
||||
return $res->getReturnResponse();
|
||||
$batt = $em->getRepository(Battery::class)->find($batt_id);
|
||||
if ($batt == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid battery id');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
else
|
||||
$batt = null;
|
||||
|
||||
/*
|
||||
// put battery in criteria
|
||||
|
|
@ -860,7 +866,7 @@ class APIController extends Controller
|
|||
$required_params = [
|
||||
'service_type',
|
||||
'cv_id',
|
||||
'batt_id',
|
||||
// 'batt_id',
|
||||
'trade_in',
|
||||
];
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
|
@ -915,13 +921,19 @@ class APIController extends Controller
|
|||
}
|
||||
|
||||
// check battery
|
||||
$batt = $em->getRepository(Battery::class)->find($req->request->get('batt_id'));
|
||||
if ($batt == null)
|
||||
$batt_id = $req->request->get('batt_id');
|
||||
if ($batt_id != null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid battery id');
|
||||
return $res->getReturnResponse();
|
||||
$batt = $em->getRepository(Battery::class)->find($batt_id);
|
||||
if ($batt == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid battery id');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
else
|
||||
$batt = null;
|
||||
|
||||
/*
|
||||
// put battery in criteria
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ServiceType extends NameValue
|
|||
const POST_RECHARGED = 'post_recharged';
|
||||
const POST_REPLACEMENT = 'post_replacement';
|
||||
const TIRE_REPAIR = 'tire';
|
||||
const OVERHEAT_ASSITANCE = 'overheat';
|
||||
const OVERHEAT_ASSISTANCE = 'overheat';
|
||||
const EMERGENCY_REFUEL = 'fuel';
|
||||
|
||||
const COLLECTION = [
|
||||
|
|
|
|||
|
|
@ -256,6 +256,18 @@ class InvoiceCreator
|
|||
}
|
||||
}
|
||||
|
||||
public function processOtherServices(&$total, $invoice, $stype)
|
||||
{
|
||||
$item = new InvoiceItem();
|
||||
$item->setInvoice($invoice)
|
||||
->setTitle('Service - ' . ServiceType::getName($stype))
|
||||
->setQuantity(1)
|
||||
->setPrice(200.00);
|
||||
$invoice->addItem($item);
|
||||
|
||||
$total['total_price'] = 200.00;
|
||||
}
|
||||
|
||||
public function processCriteria(InvoiceCriteria $criteria)
|
||||
{
|
||||
// initialize
|
||||
|
|
@ -296,6 +308,11 @@ class InvoiceCreator
|
|||
break;
|
||||
case ServiceType::POST_REPLACEMENT:
|
||||
$this->processReplacement($total, $invoice);
|
||||
break;
|
||||
case ServiceType::TIRE_REPAIR:
|
||||
case ServiceType::OVERHEAT_ASSISTANCE:
|
||||
case ServiceType::EMERGENCY_REFUEL:
|
||||
$this->processOtherServices($total, $invoice, $stype);
|
||||
}
|
||||
|
||||
// TODO: check if any promo is applied
|
||||
|
|
|
|||
Loading…
Reference in a new issue