From 9bcfd21af5452c6f8ded83687b14742d30dbdfa1 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 20 Nov 2025 10:32:19 +0530 Subject: [PATCH] Invoice --- app/Config/Routes.php | 9 ++++++ app/Controllers/InvoiceController.php | 43 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a286d10..2f0a48d 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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'); + + + }); diff --git a/app/Controllers/InvoiceController.php b/app/Controllers/InvoiceController.php index 75fedb3..bd00ea1 100644 --- a/app/Controllers/InvoiceController.php +++ b/app/Controllers/InvoiceController.php @@ -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); + } + } + +