diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 8ad5366a..e6aca562 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -1028,6 +1028,7 @@ class EmployeeRestController extends AdminController
$self['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
$array->mapped_family_floaters = $self;
+ $array->type = 'GPA';
@@ -1155,7 +1156,7 @@ class EmployeeRestController extends AdminController
}
$array->mapped_family_floaters = $data;
- $array->type = "Group Medical Coverage";
+ $array->type = "GMC";
$checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, policy_type.long_name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
@@ -1344,7 +1345,7 @@ class EmployeeRestController extends AdminController
}
$array->mapped_family_floaters = $data;
- $array->type = "Group Medical Coverage - Parents";
+ $array->type = "GMC - Parents";
return $array;
@@ -1791,7 +1792,7 @@ class EmployeeRestController extends AdminController
$responce['family_floaters_of_only_si_value'] = $only_si_value;
$responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
$responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value;
- $responce['type'] = "Group Medical Coverage - Top Up";
+
if($this->request->getGet('policy') == 'GMC-SI-TOPUP'){
return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200);
@@ -1840,7 +1841,7 @@ class EmployeeRestController extends AdminController
$responce['family_floaters_of_only_si_value'] = $only_si_value;
$responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
$responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value;
- $responce['type'] = "Group Medical Coverage - Parents Top Up";
+
if($this->request->getGet('policy') == 'GMC-SI-PARENT-TOPUP'){
return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_parent_topup'=>$responce]], 200);
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 0d5e76e3..68ce024d 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -56,6 +56,7 @@ class MasterController extends AdminController
protected $clientModel;
protected $clientDepositModel;
protected $insurerTemplateModel;
+ protected $cli_colors;
@@ -84,6 +85,13 @@ class MasterController extends AdminController
$this->clientModel = new ClientModel();
$this->clientDepositModel = new ClientDepositModel();
$this->insurerTemplateModel = new InsurerExcelExportTemplateModel();
+ $this->cli_colors = [
+ 'red' => "\033[31m",
+ 'green' => "\033[32m",
+ 'yellow' => "\033[33m",
+ 'blue' => "\033[34m",
+ 'reset' => "\033[0m"
+ ];
}
@@ -1546,6 +1554,7 @@ class MasterController extends AdminController
$this->checkAndCreateDirectories();
$this->checkGoogleOAuthCredentialsinDB();
$this->getCronJobsList();
+ $this->checkGdriveRootFolderID();
}
@@ -1594,7 +1603,7 @@ class MasterController extends AdminController
$token = $settingsModel->where('id', 1)->first();
echo "################ CHECKING GMAIL OAUTH FOR EMAIL ###################\n";
- if (is_array($token) && !is_null($token['gmail_api_oauth_credentials'])) {
+ if (is_array($token) && is_null($token['gmail_api_oauth_credentials'])) {
echo "Email OAuth credentials not found in database.\n";
echo "Check the following..!\n";
@@ -1632,4 +1641,20 @@ class MasterController extends AdminController
echo "################################################################\n\n";
}
+ //check gdrive root folder id in env file
+ function checkGdriveRootFolderID()
+ {
+ echo "#################### CHECKING GDRIVE FOLDER ID IN ENV FILE ############################\n";
+ $id = getenv('GDRIVE_ROOT_FOLDER_ID');
+ if($id)
+ {
+ echo $this->cli_colors['green'] . "ID is :". $id . $this->cli_colors['reset']. "\n";
+ }
+ else
+ {
+ echo $this->cli_colors['red'] ."Gdrive Folder id not set in env file. set it under 'GDRIVE_ROOT_FOLDER_ID' in env file.". $this->cli_colors['reset'] ."\n";
+ }
+ echo "################################################################\n\n";
+ }
+
}
\ No newline at end of file
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 2607f41c..b73c9daf 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -1268,8 +1268,11 @@ class PolicyTransactionController extends BaseController
//insurer statement list page
public function statementList()
{
- // dd($this->updateInsurerStatement(['file_id' => 13]));
+ // dd($this->validateInsurerStatement(['file_id' => 30]));
// $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)));
+ // echo $fromday;die();
$data['invoice_status_array'] = $this->invoiceStatus;
$data['insurers'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
@@ -1285,7 +1288,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)
+ (SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)
FROM inv_payment_details
WHERE inv_payment_details.is_active = 1
AND inv_payment_details.statement_id = insurer_statements.id
@@ -1295,10 +1298,12 @@ class PolicyTransactionController extends BaseController
->join('insurer_branch', 'insurer_statements.branch_id = insurer_branch.id')
->join('user_profiles', 'insurer_statements.created_by = user_profiles.id')
->where('insurer_statements.is_active', 1)
+ ->where('date(insurer_statements.created_at) >= ', $from_date)
+ ->where('date(insurer_statements.created_at) <= ', $today)
->orderBy('insurer_statements.id', 'DESC')
->findAll();
- // dd( $data['insurer_statement_list']);
+ // dd( $this->insurerStatements->getLastQuery());
$this->loadLayout('insurer_statement_list', $data);
}
@@ -1314,7 +1319,7 @@ class PolicyTransactionController extends BaseController
'max_size[statement,16384]',
],
]);
- $this->createStatementFolder();
+ // $this->createStatementFolder();
if ($validated)
{
$avatar = $this->request->getFile('statement');
@@ -1351,6 +1356,8 @@ class PolicyTransactionController extends BaseController
// print_r($branch_id);
// die();
$month = $this->request->getPost('statement_month');
+ $month = $month.'-01';
+ // print_r($month);die;
$month = change_date_format($month,'Y-M-d','Y-m-d');
// print_r($month);die;
@@ -1439,27 +1446,28 @@ class PolicyTransactionController extends BaseController
// dd($highestRowAndColumn);
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
unset($excel_data[0]);
- // dd($excel_data);
+ // Kint::dump($excel_data);
//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']);
// var_dump($source_data);die();
- // Kint::dump($excel_data);
+ // Kint::dump($source_data);//die();
// check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage
foreach ($excel_data as $excel_key => $excel_row)
{
$is_source_found = 0;
- $excel_row[4] = trim($excel_row[4]);
- $excel_row[5] = trim($excel_row[5]);
- // Kint::dump(change_date_format($excel_row[4],'d-m-Y','Y-m-d'));
- // echo $excel_row[1].'#'.$excel_row[2] .'#'.$excel_row[3].'#'.change_date_format($excel_row[4],'d-m-Y','Y-m-d').'#'.change_date_format($excel_row[5],'d-m-Y','Y-m-d').'
';
+ $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel
+ $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
+ $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
+ $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
+ $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
+
foreach ($source_data as $source_key => $source_row)
{
- // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
- if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date'])
+ if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['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;
unset($source_data[$source_key]);
@@ -1475,7 +1483,6 @@ class PolicyTransactionController extends BaseController
$error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found
}
}
-
if($error_data['error_code'])
{
$status = 'failed';
@@ -1543,13 +1550,16 @@ class PolicyTransactionController extends BaseController
foreach ($excel_data as $excel_key => $excel_row)
{
$is_source_found = 0;
- $excel_row[4] = trim($excel_row[4]);
- $excel_row[5] = trim($excel_row[5]);
+ $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel
+ $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
+ $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
+ $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
+ $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
foreach ($source_data as $source_key => $source_row)
{
// Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
- if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date'])
+ if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['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;
@@ -1646,10 +1656,11 @@ class PolicyTransactionController extends BaseController
->where('is_active',1)
->get()
->getResultArray();
- // print_r($inv_details);
+ // ~dd($inv_details);
$data = [ 'invoice_status' => $inv_details['invoice_status'],
'invoice_no' => $inv_details['invoice_no'],
- 'invoice_date' => $inv_details['invoice_date'] ];
+ '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 ];
$data['payments'] = $inv_payment_details;
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
@@ -1666,13 +1677,15 @@ class PolicyTransactionController extends BaseController
$invoiceStatus = $jsonData['invoice_status'];
$hiddenStatementId = $jsonData['hidden_statement_id'];
$invoiceNo = $jsonData['invoice_no'];
- $invoiceDate = $jsonData['invoice_date'];
+ $invoiceDate = change_date_format($jsonData['invoice_date'],'d-m-Y','Y-m-d');
+ $invoice_amount = $jsonData['invoice_amount'];
//Update statement table
$parentData = [
'invoice_status' => $invoiceStatus,
'invoice_no' => $invoiceNo,
'invoice_date' => $invoiceDate,
+ 'invoice_amount' => $invoice_amount,
'updated_by' => get_session_userid()
];
@@ -1681,21 +1694,24 @@ class PolicyTransactionController extends BaseController
$this->insurerStatements->update($hiddenStatementId, $parentData);
// Process child data
- $invoiceAmounts = $jsonData['invoice_amount'];
+ $receivedAmounts = $jsonData['received_amount'];
$utrNos = $jsonData['utr_no'];
+ $tdsTotal = $jsonData['tds'];
$paymentDates = $jsonData['payment_date'];
$pks = $jsonData['pk'];
- foreach ($invoiceAmounts as $index => $invoiceAmount) {
+ foreach ($receivedAmounts as $index => $receivedAmount) {
$pk = $pks[$index]; // Get the pk for the current record
$utrNo = $utrNos[$index];
+ $tds = $tdsTotal[$index];
$paymentDate = $paymentDates[$index];
// Prepare data for insert/update
$childData = [
- 'inv_amt' => $invoiceAmount,
+ 'inv_amt' => $receivedAmount,
'utr_no' => $utrNo,
- 'received_date' => $paymentDate,
+ 'tds' => $tds,
+ 'received_date' => change_date_format($paymentDate,'d-m-Y','Y-m-d'),
'statement_id' => $hiddenStatementId
];
if($pk){
diff --git a/app/Models/InsurerStatements.php b/app/Models/InsurerStatements.php
index 6b85ed0f..0e2dc2ec 100644
--- a/app/Models/InsurerStatements.php
+++ b/app/Models/InsurerStatements.php
@@ -21,6 +21,7 @@ class InsurerStatements extends Model
"reason",
"invoice_status",
"invoice_no",
+ "invoice_amount",
"invoice_date",
"updated_by"
diff --git a/app/Models/InvPaymentDetailsModel.php b/app/Models/InvPaymentDetailsModel.php
index 6b2d9dac..262f76d6 100644
--- a/app/Models/InvPaymentDetailsModel.php
+++ b/app/Models/InvPaymentDetailsModel.php
@@ -15,6 +15,7 @@ class InvPaymentDetailsModel extends Model
'statement_id',
'inv_amt',
'utr_no',
+ 'tds',
'received_date',
'created_by',
'is_active',
diff --git a/app/Models/PTCOShareDetailsModel.php b/app/Models/PTCOShareDetailsModel.php
index 274b572b..385645ed 100644
--- a/app/Models/PTCOShareDetailsModel.php
+++ b/app/Models/PTCOShareDetailsModel.php
@@ -87,16 +87,18 @@ class PTCOShareDetailsModel extends Model
pt_co.bp_amt,
pt_co.tp_amt,
pt_co.tep_amt,
- pt_co.exp_amt
+ pt_co.exp_amt,
+ pt_co.statement_id
')
->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.created_at)', $month)
- ->where('YEAR(pt.created_at)', $year)
+ ->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.status','completed')
// ->where('pt_co.exp_amt', 0.00)
// ->orWhere('pt_co.exp_amt is null')
->get()
diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php
index cf14f29d..4407c302 100644
--- a/app/Views/insurer_statement_list.php
+++ b/app/Views/insurer_statement_list.php
@@ -113,13 +113,10 @@ table.dataTable tbody td {
| + + | '.$row['first_name'] ?> | - + + | @@ -203,7 +203,7 @@ table.dataTable tbody td {