diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 09e872c3..dfcf2791 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -46,5 +46,287 @@ class BDSReportController extends BaseController // } - // ----------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + + //Function for get BAP INSURE wise data for premium , policy count , revenue only + public function getBAPInsurerData($category = 0, $start_date = null, $end_date = null) + { + try { + $this->myLogger->logme('error', 'getBAPInsurerData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + select ins.id, ins.name as insurer_name, + + -- Health Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS health_revenue, + + -- Misc Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS misc_revenue, + + + -- Motor Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS motor_revenue, + + -- Engineering Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS engineering_revenue, + + + -- Fire Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS fire_revenue, + + -- Liability Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS liability_revenue, + + + -- Life Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS life_revenue, + + + -- Marine Cargo Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_cargoe_revenue, + + -- Marine Hull Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue + + from insurers ins + left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 + left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 + left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $category + where ins.is_active = 1 + group by ins.id + ORDER BY + health_premium DESC, + misc_premium DESC, + motor_premium DESC, + engineering_premium DESC, + fire_premium DESC, + liability_premium DESC, + life_premium DESC, + marine_cargo_premium DESC, + marine_hull_premium DESC; + + "); + + // Get the query + $result = $builder->getResultArray(); + $this->myLogger->logme('error', 'Query executed successfully.'); + // dd(db_connect()->getLastQuery(),$result); + return $result; + + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getBAPInsurerData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } + + //Function for get BAP CLIENT wise data for premium , policy count , revenue only + public function getBAPClientData($category = 0, $start_date = null, $end_date = null) + { + + try { + $this->myLogger->logme('error', 'getBAPClientData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + SELECT + c.id AS client_id, + c.client_name, + + -- Health Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + + -- Misc Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + + -- Motor Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + + -- Engineering Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + + -- Fire Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + + -- Liability Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + + -- Life Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + + -- Marine Cargo Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + + -- Marine Hull Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium + + FROM clients c + LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + LEFT JOIN policy_type ptp ON pt.policy_type_id = ptp.id + LEFT JOIN pt_co_share_details ptco ON ptco.pt_id = pt.id AND ptco.is_active = 1 + LEFT JOIN co_share_stmt_details stmt ON stmt.co_share_id = ptco.id AND stmt.is_active = 1 + WHERE c.is_active = 1 + AND ptp.policy_category = $category + GROUP BY c.id + ORDER BY + health_premium DESC, + misc_premium DESC, + motor_premium DESC, + engineering_premium DESC, + fire_premium DESC, + liability_premium DESC, + life_premium DESC, + marine_cargo_premium DESC, + marine_hull_premium DESC + + "); + + // Get the query + $result = $builder->getResultArray(); + // dd(db_connect()->getLastQuery(),$result); + return $result; + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getBAPClientData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } + + //Function for get CLIENT wise data for premium and policy count only + public function getClientData($category = 0, $start_date = null, $end_date = null) + { + + try { + + $this->myLogger->logme('error', 'getClientData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + select + c.id as client_id, + c.client_name, + + ( + select + count(policy_transaction.id) + from policy_transaction + left join policy_type on policy_transaction.policy_type_id = policy_type.id + where policy_transaction.client_id = c.id + and policy_transaction.action_type = 'inception' + and policy_transaction.is_active = 1 + + ) as policy_count, + + COALESCE(( + select + sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium + from co_share_stmt_details stmt + left join pt_co_share_details ptco on stmt.co_share_id = ptco.id + left join policy_transaction pt on ptco.pt_id = pt.id + where pt.client_id = c.id + and stmt.is_active = 1 + and ptco.is_active = 1 + and pt.is_active = 1 + + ), 0) as premium + + from clients c + join policy_transaction on c.id = policy_transaction.client_id + join policy_type on policy_transaction.policy_type_id = policy_type.id + where c.is_active = 1 + and policy_type.policy_category = $category + AND policy_transaction.policy_issue_date >= '$fromDate' + AND policy_transaction.policy_issue_date <= '$toDate' + group by client_name + order by premium desc + "); + + // Get the query + $result = $builder->getResultArray(); + // dd(db_connect()->getLastQuery(),$result); + return $result; + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getClientData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } } diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index eab0a10b..d6d1626a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4045,6 +4045,20 @@ class ClientController extends AdminController // $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name); // dd($returndata); + // -----------BDS REPORT CONTROLLER--------------------------------------------------------------------------------- + + $BDSReportController = new BDSReportController(); + + $data['data'] = $BDSReportController->getBAPInsurerData(); + return $this->loadLayout('irda_bap_insurer_report_list', $data); + + // $data['data'] = $BDSReportController->getBAPClientData(); + // return $this->loadLayout('irda_bap_client_report_list', $data); + + // $data['data'] = $BDSReportController->getClientData(); + // return $this->loadLayout('irda_client_report_list', $data); + + // $BDSReportController->getBAPClientData(); } // ------------------------------------------------------------------------------------------------------- diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index ca4a1d66..8a03a1e4 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1103,20 +1103,30 @@ class PolicyTransactionController extends BaseController } - if(!empty($data['data_received_date'])){ + if(empty($data['data_received_date'])){ + $data['data_received_date'] = null; + }else{ $data['data_received_date'] = change_date_format($data['data_received_date'], 'd/m/Y', 'Y-m-d'); } - if(!empty($data['policy_issue_date'])){ + if(empty($data['policy_issue_date'])){ + $data['policy_issue_date'] = null; + }else{ $data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'd/m/Y', 'Y-m-d'); } - if(!empty($data['endorse_eff_date'])){ + if(empty($data['endorse_eff_date'])){ + $data['endorse_eff_date'] = null; + }else{ $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'd/m/Y', 'Y-m-d'); + } - if(!empty($data['install_due_date'])){ + if(empty($data['install_due_date'])){ + $data['install_due_date'] = null; + }else{ $data['install_due_date'] = change_date_format($data['install_due_date'], 'd/m/Y', 'Y-m-d'); + } if(!empty($data['month'])){ @@ -1162,7 +1172,8 @@ class PolicyTransactionController extends BaseController 'policy_type_id' => $issue_type['policy_type_id'] ?? null, 'issue_type' => $issue_type['issue_type'] ?? null, 'source_client_policy_id' => $issue_type['source_client_policy_id'] ?? null, - 'cd_ac_no' => $issue_type['issue_type'] ?? null, + 'cd_ac_no' => $issue_type['cd_ac_no'] ?? null, + 'cd_ac_pk' => $issue_type['cd_ac_pk'] ?? null, // 'policy_issue_date' => $issue_type['policy_issue_date'] ?? null, 'policy_start_date' => $issue_type['policy_start_date'] ?? null, 'policy_end_date' => $issue_type['policy_end_date'] ?? null, diff --git a/app/Models/PolicyTypeModel.php b/app/Models/PolicyTypeModel.php index 29126484..90aa1758 100755 --- a/app/Models/PolicyTypeModel.php +++ b/app/Models/PolicyTypeModel.php @@ -22,6 +22,6 @@ class PolicyTypeModel extends Model "etp", "iep", "itp", - "question_json",'itep','etep' + "question_json",'itep','etep', 'policy_category', ]; } diff --git a/app/Views/irda_bap_client_report_list.php b/app/Views/irda_bap_client_report_list.php new file mode 100644 index 00000000..6ecbf234 --- /dev/null +++ b/app/Views/irda_bap_client_report_list.php @@ -0,0 +1,226 @@ + + +
+
+
+
+
+

BAP Client Report

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EngineeringFireHealthLiabilityLifeMarine CargoMiscMotorMarine Hull
S. NoInsuredPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremium
+ +
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/app/Views/irda_bap_insurer_report_list.php b/app/Views/irda_bap_insurer_report_list.php new file mode 100644 index 00000000..6321f7a1 --- /dev/null +++ b/app/Views/irda_bap_insurer_report_list.php @@ -0,0 +1,234 @@ + + +
+
+
+
+
+

BAP Insurer Report

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EngineeringFireHealthLiabilityLifeMarine CargoMiscMotorMarine Hull
S. NoInsurerPoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenue
+ +
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/app/Views/irda_client_report_list.php b/app/Views/irda_client_report_list.php new file mode 100644 index 00000000..70ba446f --- /dev/null +++ b/app/Views/irda_client_report_list.php @@ -0,0 +1,148 @@ + + +
+
+
+
+
+

Client Report

+
+ +
+
+ + + + + + + + + + + + + $row){ ?> + + + + + + + + + + +
S. NoInsuredPoliciesPremium
+ +
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 687891b4..c9d439b9 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -1159,17 +1159,20 @@ function amountCalculation(input) { console.log('gst_per_amt', gst_per_amt); // $('#gst_amount_' + input).val(gst_per_amt.toFixed(2)); - if(gst_amount != 0){ - if (event.target.id.startsWith('non_comm_per_amt')) { + if (event.target.id.startsWith('non_comm_per_amt')) { + $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); + }else if (event.target.id.startsWith('gst_amount')) { + $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + }else{ + if(ncpa != 0 && ncpa != ""){ $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); }else{ - $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + $('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00'); } - }else{ - $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); } + let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt; console.log('Summed Amount:', finalTotal); @@ -1186,11 +1189,15 @@ function amountCalculation(input) { expectedAmount = agreed_amount; // console.log('Formula 1 AGREED AMOUNT'); }else if(sum_of_agreed_premium > 0){ - expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + //expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per; + expectedAmount = (tpTotal * sumOfTheAggreedPer); expectedAmount = expectedAmount / 100; // console.log('Formula 2 AGREED BP TP/TEP %'); }else{ - expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + // expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per; + expectedAmount = (tpTotal * sumOfTheStandardPer); console.log(expectedAmount) expectedAmount = expectedAmount / 100; // console.log('Formula 3 STANDARD BP TP/TEP %'); diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index e08cb097..f1f00d52 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -548,10 +548,10 @@ document.addEventListener("DOMContentLoaded", function () { }); - // var closure_date = flatpickr("#policy_issue_date", { - // dateFormat: "d/m/Y", - // allowInput: false - // }); + var closure_date = flatpickr("#policy_issue_date", { + dateFormat: "d/m/Y", + allowInput: false + }); var install_due_date = flatpickr("#install_due_date", { dateFormat: "d/m/Y", diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 30df9f5a..af9416a2 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1842,17 +1842,20 @@ function amountCalculation(input) { console.log('gst_per_amt', gst_per_amt); // $('#gst_amount_' + input).val(gst_per_amt.toFixed(2)); - if(gst_amount != 0){ - if (event.target.id.startsWith('non_comm_per_amt')) { + if (event.target.id.startsWith('non_comm_per_amt')) { + $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); + }else if (event.target.id.startsWith('gst_amount')) { + $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + }else{ + if(ncpa != 0 && ncpa != ""){ $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); }else{ - $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + $('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00'); } - }else{ - $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); } + let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt; console.log('Summed Amount:', finalTotal); @@ -1869,11 +1872,15 @@ function amountCalculation(input) { expectedAmount = agreed_amount; // console.log('Formula 1 AGREED AMOUNT'); }else if(sum_of_agreed_premium > 0){ - expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + //expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per; + expectedAmount = (tpTotal * sumOfTheAggreedPer); expectedAmount = expectedAmount / 100; // console.log('Formula 2 AGREED BP TP/TEP %'); }else{ - expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + // expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per; + expectedAmount = (tpTotal * sumOfTheStandardPer); console.log(expectedAmount) expectedAmount = expectedAmount / 100; // console.log('Formula 3 STANDARD BP TP/TEP %'); @@ -3890,9 +3897,11 @@ function populateTable(dataArray, cd_ac_pk) { case 2: // CD Account Number cell.find('select').val(cd_ac_pk); var selectElement = cell.find('select'); + console.log('selectElement', selectElement); selectElement.val(cd_ac_pk).prop('selected', true); selectElement.toggleClass('readonly-select', !!disable_td) setTimeout(function(){ + console.log('selectElement', selectElement); selectElement.find('option[value="' + cd_ac_pk + '"]').prop('selected', true); selectElement.toggleClass('readonly-select', !!disable_td) }, 2000) @@ -4240,8 +4249,14 @@ function getCdAmount(cd_ac_pk, increment){ console.log('Data fetched successfully:', response); if (response.status == true) { - $('#cd_current_balance_'+increment).val(response.data.balance); - } + if(!response.data.balance){ + $('#cd_current_balance_'+increment).val(0.00); + }else{ + $('#cd_current_balance_'+increment).val(response.data.balance); + } + } else{ + $('#cd_current_balance_'+increment).val(0.00); + } }, function(xhr, status, error) { console.error('Error fetching data:', error);