Invoice
This commit is contained in:
parent
462e16e293
commit
9bcfd21af5
@ -117,6 +117,15 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
||||
$routes->get('dashboard/staffDashboard', 'DashboardController::staffDashboard');
|
||||
$routes->get('dashboard/agentDashboard', 'DashboardController::agentDashboard');
|
||||
|
||||
//invoice
|
||||
$routes->get('invoice/list', 'InvoiceController::invoiceList');
|
||||
$routes->get('invoice/details', 'InvoiceController::findInvoiceWithItems');
|
||||
$routes->post('invoice/create-or-update', 'InvoiceController::createOrUpdateInvoice');
|
||||
$routes->get('invoice/delete', 'InvoiceController::deleteInvoice');
|
||||
$routes->post('invoice/commission-rate-list', 'InvoiceController::getCommissionRateList');
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -177,6 +177,49 @@ class InvoiceController extends ResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getCommissionRateList()
|
||||
{
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
|
||||
if (empty($input['agent_id']) || empty($input['issued_date'])) {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 400,
|
||||
'message'=> 'agent_id and issued_date are required'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$broker_id = $input['broker_id'];
|
||||
$agent_id = $input['agent_id'];
|
||||
$issued_date = format_date_for_database($input['issued_date']);
|
||||
|
||||
$data = $this->PolicyModel
|
||||
->select('partner_policy.*')
|
||||
->join('partner_enquiry pe', 'pe.id = partner_policy.enquiry_id', 'left')
|
||||
->where('pe.broker_id', $broker_id)
|
||||
->where('partner_policy.agent_id', $agent_id)
|
||||
->where('partner_policy.issued_date <=', $issued_date)
|
||||
->where('partner_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'data' => $data
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
'message'=> $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user