From 5d0ee48050077b8a3901251907565a63c641d470 Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 22 Mar 2024 16:01:17 +0530 Subject: [PATCH 01/30] 'FIRST_COMMIT_FOR_TEST-BRANCH' --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 00cdf704..8eaa7d72 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,5 @@ Additionally, make sure that the following extensions are enabled in your PHP: - json (enabled by default - don't turn it off) - [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL - [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library + +- first test release From df9c1a98fa56c2529d27b2de000baf1a892ceb6e Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 29 Mar 2024 10:55:15 +0530 Subject: [PATCH 02/30] FILES_CPANEL_YAML_ADDED --- .cpanel.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .cpanel.yml diff --git a/.cpanel.yml b/.cpanel.yml new file mode 100644 index 00000000..944de66e --- /dev/null +++ b/.cpanel.yml @@ -0,0 +1,5 @@ +--- +deployment: + tasks: + - export DEPLOYPATH=/home/example/public_html/ + - /bin/cp . $DEPLOYPATH \ No newline at end of file From 085d4576f583a3a015687b7dfe50965d13193ed9 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 19 Dec 2024 14:31:31 +0530 Subject: [PATCH 03/30] CHANGE_MEMBERS_DEMOGRAPHY_STARTED --- app/Controllers/LeadsController.php | 86 +++++++++++++++++++++++++++- app/Helpers/sendMailNotification.php | 2 +- app/Models/RFQModel.php | 3 +- 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 7c5eef43..856fb649 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -90,6 +90,11 @@ class LeadsController extends BaseController public function viewLeadsList() { + + // $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null); + // $d = $this->calculateMembersDemography(['lead_id' => 34]); + //$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null); + // dd($d); $data['page_name'] = 'Leads'; // Set basic data @@ -431,7 +436,7 @@ class LeadsController extends BaseController //FOR EXCEL public function exportExcelForQCRandRFQ($lead_id, $type) { - $filepath = $this->constructExcelToSaveTemp($lead_id, $type); + //$filepath = $this->constructExcelToSaveTemp($lead_id, $type); $filepath = $filepath['filePath']; if (file_exists($filepath)) { @@ -662,6 +667,85 @@ class LeadsController extends BaseController 'fileName' => $filename, ]; } + + //Merge RFQ/QCR file with lead members file + public function mergeQuoteExcelFileWithMembersListExcelFile($lead_id, $type, $source_file_path) + { + $rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); + + if($source_file_path && $rfq_data['file_name']) + { + + } + + return true; + } + + public function calculateMembersDemography($params) + { + $lead_id = $params['lead_id']; + $lead_data = $this->leadsModel->find($lead_id); + // print_rr($lead_data); + if($lead_data['file_name']) + { + $file_name_with_path = WRITEPATH."/uploads/lead_files/".$lead_data['file_name']; + + //check physical file + if(!file_exists($file_name_with_path)) + { + //file not found update status and reason + $message = "Lead Physcial file not found"; + // echo $message; + $this->myLogger->logme('error',($message . ' for file ' . $file_name_with_path)); + return ['status' => 'failed','message' => 'no physcial file']; + } + + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + + //get members data + $members_sheet = $spreadsheet->getSheet(0); + $highestRowAndColumn = $members_sheet->getHighestRowAndColumn(); + // dd($highestRowAndColumn); + $members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + // dd($members); + + //get age band data + $age_band_sheet = $spreadsheet->getSheet(1); + $highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn(); + $age_band_data = $age_band_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + print_r($age_band_data); + + //check age or dob column + $members_heading = $members[0]; + Kint::dump($members_heading); + $available_col = null; + $col_index = null; + + if (in_array('age', array_map('strtolower',$members_heading))) { + $available_col = 'age'; + $col_index = array_search('age',array_map('strtolower',$members_heading)); + } elseif (in_array('dob', array_map('strtolower', $members_heading))) { + $available_col = 'dob'; + $col_index = array_search('dob', array_map('strtolower', $members_heading)); + } + + if ($available_col == null) { + $message = 'No DOB or Age column '; + $this->myLogger->logme('error',($message . $file_name_with_path)); + return ['status' => 'failed','message' => $message]; + } + + //convert age slab data into array + + } + else + { + $this->myLogger->logme('error',(' no file found ' . $file_name_with_path)); + return ['status' => 'failed','message' => 'no file found']; + } + + } + //this funciton for send mail to insurer and client with either RFQ/QCR public function sendMailWithAttachement() diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 3ac48a4d..2615b1fc 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -327,7 +327,7 @@ class sendMailNotification // dd($payable_employee_array); // dd(count($payable_employee_array['emp_data'])); - if(count($payable_employee_array['emp_data']) > 0){ + if(isset($payable_employee_array['emp_data']) && count($payable_employee_array['emp_data']) > 0){ $table_content .= '

Policy Type :'; $temp_data = ''; diff --git a/app/Models/RFQModel.php b/app/Models/RFQModel.php index d616e517..006ac637 100644 --- a/app/Models/RFQModel.php +++ b/app/Models/RFQModel.php @@ -67,7 +67,8 @@ class RFQModel extends Model tpa.name as tpa_name, tpa_branch.branch_name as tpa_branch_name, policy_type.policy_type, - rfq.json + rfq.json, + file_name ') ->join('leads', 'rfq.lead_id = leads.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id') From a6ff0b0b24c3f79332256ca64c495e6d6e9ad69b Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Thu, 19 Dec 2024 14:45:07 +0530 Subject: [PATCH 04/30] FEAT_EXCEL MERGE HELPER CREATED --- app/Helpers/ExcelMergeHelper.php | 93 +++++++++++++++++++++++++++++ composer.json | 1 + tests/unit/ExcelMergeHelperTest.php | 25 ++++++++ 3 files changed, 119 insertions(+) create mode 100644 app/Helpers/ExcelMergeHelper.php create mode 100755 tests/unit/ExcelMergeHelperTest.php diff --git a/app/Helpers/ExcelMergeHelper.php b/app/Helpers/ExcelMergeHelper.php new file mode 100644 index 00000000..06f68c66 --- /dev/null +++ b/app/Helpers/ExcelMergeHelper.php @@ -0,0 +1,93 @@ + $sheetsToMerge) { + // Load the current file + $currentSpreadsheet = IOFactory::load($filePath); + + // Debugging: Log the number of sheets in the current file + error_log("File: $filePath has " . $currentSpreadsheet->getSheetCount() . " sheets."); + + // If this is the first file, initialize the base spreadsheet + if ($spreadsheet === null) { + $spreadsheet = $currentSpreadsheet; + + // If specific sheets are provided for the first file, remove the others + if (!is_null($sheetsToMerge) && !empty($sheetsToMerge)) { + $sheetCount = $spreadsheet->getSheetCount(); + for ($i = $sheetCount - 1; $i >= 0; $i--) { + if (!in_array($i, $sheetsToMerge)) { + $spreadsheet->removeSheetByIndex($i); + } + } + } + } else { + // If we are not working with the first file, we need to merge specified sheets + if (is_null($sheetsToMerge) || empty($sheetsToMerge)) { + // If no specific sheets, merge all sheets + $sheetsToMerge = range(0, $currentSpreadsheet->getSheetCount() - 1); + } + + // Merge the specified sheets from the current file + foreach ($sheetsToMerge as $sheetIndex) { + // Check if sheet index is within bounds + if ($sheetIndex < 0 || $sheetIndex >= $currentSpreadsheet->getSheetCount()) { + throw new Exception("Invalid sheet index $sheetIndex in file $filePath"); + } + + // Retrieve the sheet to copy + $sheetToCopy = $currentSpreadsheet->getSheet($sheetIndex); + + // Handle sheet name collision by renaming the sheet with a counter + $baseName = $sheetToCopy->getTitle(); + $sheetName = $baseName; + $counter = 1; + while ($spreadsheet->sheetNameExists($sheetName)) { + $sheetName = $baseName . '_merged_' . $counter; + $counter++; + } + $sheetToCopy->setTitle($sheetName); + + // Clone and add the sheet to the base spreadsheet + $spreadsheet->addSheet(clone $sheetToCopy); + } + } + } + + // Save the merged file + $writer = new Xlsx($spreadsheet); + $writer->save($outputPath); + + return true; // Return true if merge was successful + } catch (Exception $e) { + // Log the error (optional) and return false on failure + error_log("Excel Merge Error: " . $e->getMessage()); + return false; + } + } +} diff --git a/composer.json b/composer.json index da1c83ff..73453d9c 100755 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "friendsofphp/php-cs-fixer": "^3.47.1", "kint-php/kint": "^5.0.4", "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.6", "nexusphp/cs-config": "^3.6", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1 || ^2.0" diff --git a/tests/unit/ExcelMergeHelperTest.php b/tests/unit/ExcelMergeHelperTest.php new file mode 100755 index 00000000..e648f0b6 --- /dev/null +++ b/tests/unit/ExcelMergeHelperTest.php @@ -0,0 +1,25 @@ + [1,3,2], + '/home/venba/Downloads/enrollment.xlsx' => [] + ]; + $outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file + + // Call the mergeExcelFiles function + $result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); + var_dump($result); + // Check if the result is true (indicating success) + $this->assertTrue($result, 'Expected true, but got false'); + } + +} \ No newline at end of file From 928bc6117145c6813d92b88089ca4f1d85dee335 Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 21 Dec 2024 18:13:09 +0530 Subject: [PATCH 05/30] CHNAGE_BDS_STMT_UPLOAD&OUTSTANDING --- app/Config/Routes.php | 3 + app/Controllers/EmployeeServiceController.php | 2 +- .../PolicyTransactionController.php | 111 ++++-- app/Models/COShareStmtDetailsModel.php | 38 ++ app/Models/InsurerStatements.php | 6 +- app/Models/InvPaymentDetailsModel.php | 1 + app/Models/PTCOShareDetailsModel.php | 14 +- app/Models/PolicyTransactionModel.php | 50 ++- app/Views/insurer_statement_list.php | 332 ++++++++++++++++-- app/Views/outstanding_report_list.php | 71 ++-- 10 files changed, 544 insertions(+), 84 deletions(-) create mode 100644 app/Models/COShareStmtDetailsModel.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6ad4f058..e02132a3 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -362,6 +362,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1"); $routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement"); $routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1"); + $routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth"); + $routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1"); }); }); @@ -375,6 +377,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) { $routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); $routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1"); $routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1"); + }); $routes->group("rfq", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index d5e6d6f7..f94d4f6e 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1328,7 +1328,7 @@ class EmployeeServiceController extends AdminController // } // dd($row[4]); //for emp table - $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); + // $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); // dd( $this->empEndorsementModel->getLastQuery()); // $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 5e94b340..9d067f9d 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -31,6 +31,7 @@ use App\Models\InsurerStatements; use App\Models\InvPaymentDetailsModel; use App\Models\BatchFileModel; use App\Models\FileModel; +use App\Models\COShareStmtDetailsModel; use Kint; class PolicyTransactionController extends BaseController @@ -62,6 +63,7 @@ class PolicyTransactionController extends BaseController protected $invPaymentDetailsModel; protected $batchFileModel; protected $filesModel; + protected $coShareStmtDetailsModel; public function __construct() { @@ -91,11 +93,12 @@ class PolicyTransactionController extends BaseController $this->invPaymentDetailsModel = new InvPaymentDetailsModel(); $this->batchFileModel = new BatchFileModel(); $this->filesModel = new FileModel(); + $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->invoiceStatus = [ 'pending' => 'Pending', 'generated' => 'Generated', 'sent' => 'Sent', - 'payment_received' => 'Payment Received', + 'payment_received' => 'Payment
Received', ]; } @@ -1531,20 +1534,17 @@ class PolicyTransactionController extends BaseController $end_date = $this->request->getGet('end_date'); $client_id = $this->request->getGet('client_id'); $insurer_id = $this->request->getGet('insurer_id'); - $policy_type_id = $this->request->getGet('policy_type_id'); - $date_type = $this->request->getGet('date_type'); - $issuer = $this->request->getGet('issuer'); + $insurer_branch_id = $this->request->getGet('insurer_branch_id'); - $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date; - $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date; + $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : change_date_format($start_date,'d-m-Y','Y-m-01'); + $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : change_date_format($end_date,'d-m-Y','Y-m-31'); + // dd([$start_date,$end_date]); - $client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id; $insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id; - $policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id; - $date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type; - $issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer; + $insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id; + - $data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer); + $data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date,$insurer_id, $insurer_branch_id); // dd($this->policyTransactionModel->getLastQuery()); // dd($data); $this->loadLayout('outstanding_report_list', $data); @@ -1556,7 +1556,7 @@ class PolicyTransactionController extends BaseController //insurer statement list page public function statementList() { - // dd($this->validateInsurerStatement(['file_id' => 30])); + // dd($this->updateInsurerStatement(['file_id' => 59])); // $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll(); $today = date('Y-m-d'); $fromday = $from_date = date('Y-m-d', strtotime('-60 days', strtotime($today))); @@ -1576,7 +1576,7 @@ class PolicyTransactionController extends BaseController WHERE pt_co_share_details.is_active = 1 AND pt_co_share_details.statement_id = insurer_statements.id ) AS exp_inv_amt, - (SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) + (SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) + SUM(inv_payment_details.gst) FROM inv_payment_details WHERE inv_payment_details.is_active = 1 AND inv_payment_details.statement_id = insurer_statements.id @@ -1649,9 +1649,10 @@ class PolicyTransactionController extends BaseController $month = $month.'-01'; // print_r($month);die; $month = change_date_format($month,'Y-M-d','Y-m-d'); + $stmt_sno = $this->request->getPost('statement_no'); // print_r($month);die; - $file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID]); //here field policy_id have client_policy_id and not policy id from policy master + $file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID,'stmt_sno' => $stmt_sno]); //here field policy_id have client_policy_id and not policy id from policy master $this->myLogger->logme("error", '{file_id} statement uploaded success', ['file_id' => $file_id]); //validate file @@ -1739,11 +1740,11 @@ class PolicyTransactionController extends BaseController unset($excel_data[0]); // Kint::dump($excel_data); //get no of line items and update in DB - $line_items = count($excel_data); + $line_items = 0; // get uploaded month transactions data - $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); + $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); // var_dump($source_data);die(); - // Kint::dump($source_data);//die(); + // print_rr($this->db->getLastQuery()->getQuery);die(); // check policy no,insurer and etc in DB for this month @@ -1765,7 +1766,9 @@ class PolicyTransactionController extends BaseController $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : ""; if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { + $is_source_found = 1; + $line_items = $line_items + 1; unset($source_data[$source_key]); continue 2; } @@ -1842,7 +1845,7 @@ class PolicyTransactionController extends BaseController //get no of line items and update in DB $line_items = count($excel_data); // get uploaded month transactions data - $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); + $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); // Kint::dump($source_data);die; // Kint::dump($excel_data); @@ -1934,7 +1937,7 @@ class PolicyTransactionController extends BaseController //find variance $variance_amt = $source_row['exp_amt'] - $total_amt; - $data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id]; + $data_to_update[] = ['co_share_id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id]; unset($source_data[$source_key]); continue 2; @@ -1944,7 +1947,7 @@ class PolicyTransactionController extends BaseController } } // dd($data_to_update); - $this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id'); + $this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id'); // dd($data_to_update); // if($error_data['error_code']) // { @@ -1966,8 +1969,25 @@ class PolicyTransactionController extends BaseController ->where('is_active',1) ->get() ->getResultArray(); + + if(!$inv_details['invoice_value']) + { + $stmt_level_value = $this->coShareStmtDetailsModel->select('sum(actual_tep_brokerage_amt) + sum(actual_tp_brokerage_amt) + sum(actual_bp_brokerage_amt) + sum(reward) as invoice_value') + ->where('statement_id',$statement_id) + ->groupBy('statement_id') + ->get() + ->getResultArray(); + // print_r($stmt_level_value); + if($stmt_level_value && count($stmt_level_value) && isset($stmt_level_value[0])) + { + $inv_details['invoice_value'] = $stmt_level_value[0]['invoice_value']; + } + } // ~dd($inv_details); $data = [ 'invoice_status' => $inv_details['invoice_status'], + 'gst_per' => $inv_details['gst_per'], + 'invoice_value' => $inv_details['invoice_value'], + 'gst_value' => $inv_details['gst_value'], 'invoice_no' => $inv_details['invoice_no'], 'invoice_amount' => $inv_details['invoice_amount'], 'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ]; @@ -1989,6 +2009,9 @@ class PolicyTransactionController extends BaseController $invoiceNo = $jsonData['invoice_no']; $invoiceDate = change_date_format($jsonData['invoice_date'],'d/m/Y','Y-m-d'); $invoice_amount = $jsonData['invoice_amount']; + $invoice_value = $jsonData['invoice_value']; + $gst_per = $jsonData['invoice_gst_per']; + $gst_value = $jsonData['invoice_gst']; //Update statement table $parentData = [ @@ -1996,6 +2019,9 @@ class PolicyTransactionController extends BaseController 'invoice_no' => $invoiceNo, 'invoice_date' => $invoiceDate, 'invoice_amount' => $invoice_amount, + 'gst_per' => $gst_per, + 'gst_value' => $gst_value, + 'invoice_value' => $invoice_value, 'updated_by' => get_session_userid() ]; @@ -2007,6 +2033,7 @@ class PolicyTransactionController extends BaseController $receivedAmounts = $jsonData['received_amount']; $utrNos = $jsonData['utr_no']; $tdsTotal = $jsonData['tds']; + $gstTotal = $jsonData['gst_amount']; $paymentDates = $jsonData['payment_date']; $pks = $jsonData['pk']; @@ -2014,6 +2041,7 @@ class PolicyTransactionController extends BaseController $pk = $pks[$index]; // Get the pk for the current record $utrNo = $utrNos[$index]; $tds = $tdsTotal[$index]; + $gst = $gstTotal[$index]; $paymentDate = $paymentDates[$index]; // Prepare data for insert/update @@ -2021,6 +2049,7 @@ class PolicyTransactionController extends BaseController 'inv_amt' => $receivedAmount, 'utr_no' => $utrNo, 'tds' => $tds, + 'gst' => $gst, 'received_date' => change_date_format($paymentDate,'d/m/Y','Y-m-d'), 'statement_id' => $hiddenStatementId ]; @@ -2120,5 +2149,45 @@ class PolicyTransactionController extends BaseController } + + public function getInsurerStatementMonth() + { + $insurer_id = $this->request->getGet('insurer_id'); + $month = $this->request->getGet('month'); + // echo $month; + $insurer_branch_id = explode('-',$insurer_id)[1]; + $insurer_id = explode('-',$insurer_id)[0]; + $month = $month.'-01'; + $month = change_date_format($month,'Y-M-d','Y-m-d'); + // echo $month; + + $res_data = $this->insurerStatements + ->where('insurer_id',$insurer_id) + ->where('branch_id',$insurer_branch_id) + ->where('month', $month) + ->where('is_active', 1) + ->where('file_status', 'success') + ->findAll(); + + return $this->respond(['dataStatus' => true, 'code' => 200,'data' => $res_data], 200); + + + } + + public function deleteStatement($id) + { + // echo $id;die(); + $this->coShareStmtDetailsModel->where('statement_id',$id) + ->set(['is_active' => 0]) + ->update(); + $this->invPaymentDetailsModel->where('statement_id',$id) + ->set(['is_active' => 0]) + ->update(); + $this->insurerStatements->where('id',$id) + ->set(['is_active' => 0]) + ->update(); + return $this->respond(['dataStatus' => true, 'code' => 200], 200); + } -} \ No newline at end of file +} + diff --git a/app/Models/COShareStmtDetailsModel.php b/app/Models/COShareStmtDetailsModel.php new file mode 100644 index 00000000..df007cf9 --- /dev/null +++ b/app/Models/COShareStmtDetailsModel.php @@ -0,0 +1,38 @@ +db->table('pt_co_share_details pt_co') ->select(' pt_co.id, @@ -93,12 +96,15 @@ class PTCOShareDetailsModel extends Model ->join('policy_transaction pt', 'pt_co.pt_id = pt.id') ->join('clients c', 'pt.client_id = c.id') ->where('pt_co.is_active', 1) - ->where('MONTH(pt.month)', $month) - ->where('YEAR(pt.month)', $year) + ->where('pt.is_active', 1) + // ->where('MONTH(pt.month)', $month) + // ->where('YEAR(pt.month)', $year) ->where('pt_co.insurer_id', $insurer_id) ->where('pt_co.insurer_branch_id', $insurer_branch_id) - ->where('pt_co.statement_id is null') + // ->where('pt_co.statement_id is null') ->where('pt.status','completed') + ->where('DATE(pt.created_at) >=', $sixMonthsAgo) + ->where('DATE(pt.created_at) <=', $currentDate) // ->where('pt_co.exp_amt', 0.00) // ->orWhere('pt_co.exp_amt is null') ->get() diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index ba54a5ce..e25d7e46 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -694,7 +694,7 @@ class PolicyTransactionModel extends Model return $builder->get()->getResultArray(); } - public function getOutstandingReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0) + public function getOutstandingReportList_OLD($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0) { $builder = $this->db->table('policy_transaction') ->select(" @@ -791,5 +791,53 @@ class PolicyTransactionModel extends Model return $builder->get()->getResultArray(); } + + public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0) + { + $builder = $this->db->table('insurer_statements s') + ->select(' + s.id, + s.insurer_id, + s.branch_id, + ins.short_name, + ib.branch_name, + s.month, + s.line_items, + s.stmt_sno, + s.invoice_status, + s.invoice_date, + s.invoice_no, + s.invoice_amount, + COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0) AS total_paid, + (s.invoice_amount - COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0)) AS outstanding_amount + ') + ->join('inv_payment_details p', 's.id = p.statement_id', 'left') + ->join('insurers ins', 's.insurer_id = ins.id') + ->join('insurer_branch ib', 's.branch_id = ib.id') + ->where('s.is_active', 1) + ->where('p.is_active', 1) + ->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount') + ->having('outstanding_amount >', 0); + // ->get(); + + + // Date range filtering + if ($start_date != 0 && $end_date != 0) { + + $builder->where('s.month >=', $start_date) + ->where('s.month <=', $end_date); + } + + if ($insurer_id != 0) { + $builder->where('s.insurer_id', $insurer_id); + } + if ($insurer_branch_id != 0) { + $builder->where('s.branch_id', $insurer_branch_id); + } + + $builder->orderBy('s.id', 'desc'); + + return $builder->get()->getResultArray(); + } } diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index 1c41c568..a20a4638 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -103,6 +103,10 @@ table.dataTable tbody td { .slider.round:before { border-radius: 50%; } + + .disabled-option { + color: gray; + }
@@ -125,6 +129,7 @@ table.dataTable tbody td {
Insurer
Month
+
Statement
sno
Filename
Line
items
File
status
@@ -140,6 +145,7 @@ table.dataTable tbody td { + " data-exp-amt="" data-received-amt="" onclick="showInvoiceStatusModal(event)"> Invoice status + + Delete +

@@ -218,8 +227,24 @@ table.dataTable tbody td {
- +
+ +
+ + +
+
Download sample file @@ -255,7 +280,7 @@ table.dataTable tbody td {