Add route for getJOInvoice. Modify getJOInvoice responses. #686
This commit is contained in:
parent
f486a1b5a0
commit
3e73bc0513
2 changed files with 14 additions and 35 deletions
|
|
@ -11,6 +11,11 @@ tapi_estimate:
|
||||||
controller: App\Controller\TAPI\JobOrderController::getEstimate
|
controller: App\Controller\TAPI\JobOrderController::getEstimate
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
tapi_jo_invoice:
|
||||||
|
path: /tapi/job_order/invoice/{jo_id}
|
||||||
|
controller: App\Controller\TAPI\JobOrderController:getJOInvoice
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
# vehicle manufacturer and vehicle
|
# vehicle manufacturer and vehicle
|
||||||
tapi_vehicle_mfg_list:
|
tapi_vehicle_mfg_list:
|
||||||
path: /tapi/vehicle/mfgs
|
path: /tapi/vehicle/mfgs
|
||||||
|
|
|
||||||
|
|
@ -469,44 +469,20 @@ class JobOrderController extends APIController
|
||||||
return new APIResponse(true, $message, $data);
|
return new APIResponse(true, $message, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJOInvoice(Request $req, EntityManagerInterface $em)
|
public function getJOInvoice(Request $req, $jo_id, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('tapi_jo.get.invoice', null, 'No access.');
|
$this->denyAccessUnlessGranted('tapi_jo.get.invoice', null, 'No access.');
|
||||||
|
|
||||||
$required_params = [
|
$required_params = [];
|
||||||
'jo_id',
|
$msg = $this->checkRequiredParameters($req, $required_params);
|
||||||
];
|
if ($msg)
|
||||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
return new APIResponse(false, $msg);
|
||||||
if ($res->isError())
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
|
|
||||||
// get job order
|
|
||||||
$jo_id = $req->query->get('jo_id');
|
|
||||||
$jo = $em->getRepository(JobOrder::class)->find($jo_id);
|
$jo = $em->getRepository(JobOrder::class)->find($jo_id);
|
||||||
if ($jo == null)
|
if ($jo == null)
|
||||||
{
|
{
|
||||||
$res->setError(true)
|
$message = 'No job order found';
|
||||||
->setErrorMessage('No job order found');
|
return new APIResponse(false, $message);
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get customer
|
|
||||||
// TODO: modify to get customer
|
|
||||||
$cust = $this->session->getCustomer();
|
|
||||||
if ($cust == null)
|
|
||||||
{
|
|
||||||
$res->setError(true)
|
|
||||||
->setErrorMessage('No customer information found');
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
// check that the customer owns the job order
|
|
||||||
$jo_cust = $jo->getCustomer();
|
|
||||||
if ($jo_cust->getID() != $cust->getID())
|
|
||||||
{
|
|
||||||
$res->setError(true)
|
|
||||||
->setErrorMessage('Job order was not initiated by customer');
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = $jo->getInvoice();
|
$invoice = $jo->getInvoice();
|
||||||
|
|
@ -540,10 +516,8 @@ class JobOrderController extends APIController
|
||||||
|
|
||||||
$data['items'] = $items_data;
|
$data['items'] = $items_data;
|
||||||
|
|
||||||
// set data
|
$message = 'JO invoice found.';
|
||||||
$res->setData($data);
|
return new APIResponse(true, $message, $data);
|
||||||
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancelJobOrder(Request $req, MQTTClient $mclient, EntityManagerInterface $em)
|
public function cancelJobOrder(Request $req, MQTTClient $mclient, EntityManagerInterface $em)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue