Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
1ee074dacf
@ -91,7 +91,7 @@ class BDSReportController extends AdminController
|
||||
ins.id,
|
||||
ins.name AS insurers,
|
||||
COALESCE(SUM(CASE WHEN pt.action_type = 'inception' AND pt.insurer_id = ins.id AND ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies,
|
||||
COALESCE(SUM(CASE WHEN ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS Premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS Premium,
|
||||
COALESCE(SUM(CASE WHEN stmt.co_share_id = pt_co.id AND ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN stmt.reward + stmt.actual_bp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.actual_tp_brokerage_amt ELSE 0 END), 0) AS Revenue,
|
||||
COALESCE(SUM(CASE WHEN ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN pt_co.exp_amt ELSE 0 END), 0) AS Expected_amt
|
||||
FROM
|
||||
@ -131,7 +131,7 @@ class BDSReportController extends AdminController
|
||||
SELECT
|
||||
pot.bap AS bap,
|
||||
COALESCE(COUNT(DISTINCT pt.id), 0) AS Policies,
|
||||
COALESCE(SUM((pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt)), 0) AS Premium,
|
||||
COALESCE(SUM((pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt)), 0) AS Premium,
|
||||
COALESCE(SUM(co.reward + co.actual_bp_brokerage_amt + co.actual_tep_brokerage_amt + co.actual_tp_brokerage_amt), 0) AS Revenue,
|
||||
COALESCE(SUM(pt_co.exp_amt), 0) AS Expected_amt
|
||||
FROM policy_type AS pot
|
||||
@ -267,26 +267,26 @@ class BDSReportController extends AdminController
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS health_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN pt_co.exp_amt ELSE 0 END), 0) AS health_exp_amt,
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS misc_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN pt_co.exp_amt ELSE 0 END), 0) AS misc_exp_amt,
|
||||
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS motor_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN pt_co.exp_amt ELSE 0 END), 0) AS motor_exp_amt,
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS engineering_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN pt_co.exp_amt ELSE 0 END), 0) AS engineering_exp_amt,
|
||||
|
||||
@ -294,35 +294,35 @@ class BDSReportController extends AdminController
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS fire_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN pt_co.exp_amt ELSE 0 END), 0) AS fire_exp_amt,
|
||||
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS liability_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN pt_co.exp_amt ELSE 0 END), 0) AS liability_exp_amt,
|
||||
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS life_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN pt_co.exp_amt ELSE 0 END), 0) AS life_exp_amt,
|
||||
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_cargo_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN pt_co.exp_amt ELSE 0 END), 0) AS marine_cargo_exp_amt,
|
||||
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_hull_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN pt_co.exp_amt ELSE 0 END), 0) AS marine_hull_exp_amt,
|
||||
|
||||
@ -341,15 +341,15 @@ class BDSReportController extends AdminController
|
||||
) AS total_policy_count,
|
||||
|
||||
COALESCE(
|
||||
SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+
|
||||
SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+
|
||||
SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END),
|
||||
SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) +
|
||||
SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+
|
||||
SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+
|
||||
SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END),
|
||||
0
|
||||
) AS total_premium,
|
||||
|
||||
@ -429,43 +429,43 @@ class BDSReportController extends AdminController
|
||||
|
||||
-- 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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS health_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS misc_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS motor_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS engineering_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS fire_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS liability_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS life_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_cargo_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_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 (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_hull_premium,
|
||||
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_hull_premium,
|
||||
|
||||
-- Grand Totals
|
||||
COALESCE(SUM(CASE WHEN pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS total_policy_count,
|
||||
COALESCE(SUM(pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt), 0) AS total_premium
|
||||
COALESCE(SUM(pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt), 0) AS total_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'
|
||||
@ -542,7 +542,7 @@ class BDSReportController extends AdminController
|
||||
|
||||
COALESCE((
|
||||
select
|
||||
sum(pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) as premium
|
||||
sum(pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) as premium
|
||||
from co_share_stmt_details stmt
|
||||
left join pt_co_share_details pt_co on stmt.co_share_id = pt_co.id
|
||||
left join policy_transaction pt on pt_co.pt_id = pt.id
|
||||
|
||||
@ -438,6 +438,8 @@ class PolicyTransactionController extends BaseController
|
||||
'bp_cgst' => $data['cgst'][$index] ?? 0,
|
||||
'tp_amt' => $data['tp_premium'][$index] ?? 0,
|
||||
'tep_amt' => $data['ter_premium'][$index] ?? 0,
|
||||
'cotp_amt' => $data['co_tp_premium'][$index] ?? 0,
|
||||
'cotep_amt' => $data['co_ter_premium'][$index] ?? 0,
|
||||
'agreed_amt' => $data['agreed_amount'][$index] ?? 0,
|
||||
'agreed_bp_per' => $data['agreed_bp'][$index] ?? 0,
|
||||
'agreed_tp_per' => $data['agreed_tp'][$index] ?? 0,
|
||||
|
||||
@ -66,6 +66,8 @@ class PTCOShareDetailsModel extends Model
|
||||
'statement_id',
|
||||
'follower_policy_no',
|
||||
'non_comm_per_amt',
|
||||
'cotp_amt',
|
||||
'cotep_amt',
|
||||
];
|
||||
|
||||
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)
|
||||
|
||||
@ -318,6 +318,280 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
// BDS Report NEW Functin for QUERY
|
||||
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer)
|
||||
|
||||
// public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0)
|
||||
// {
|
||||
|
||||
// $date_condition = '';
|
||||
// if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
||||
// $date_condition = "
|
||||
// AND insurer_statements.month >= '".$start_date ."'
|
||||
// AND insurer_statements.month <= '".$end_date ."'
|
||||
// ";
|
||||
// }
|
||||
|
||||
// $builder = $this->db->table('policy_transaction')
|
||||
// ->select("
|
||||
// policy_transaction.*,
|
||||
// DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||
// DATE_FORMAT(
|
||||
// IF(policy_transaction.month IS NULL,
|
||||
// policy_transaction.policy_issue_date,
|
||||
// policy_transaction.month),
|
||||
// '%b %Y') AS policy_issue_month,
|
||||
// CASE
|
||||
// WHEN clients.client_type = 1 THEN 'Group'
|
||||
// WHEN clients.client_type = 2 THEN 'Retail'
|
||||
// ELSE '-'
|
||||
// END AS client_type,
|
||||
// CASE
|
||||
// WHEN policy_transaction.revenue_type = 'NA' THEN 'Fresh'
|
||||
// ELSE 'Renewal'
|
||||
// END AS revenue_type,
|
||||
// CASE
|
||||
// WHEN policy_transaction.action_type = 'inception' THEN 'Policy'
|
||||
// ELSE 'Endorsement'
|
||||
// END AS action_type,
|
||||
// clients.client_name AS client_name,
|
||||
// clients.short_name AS client_short_name,
|
||||
// client_branch.branch_name AS client_branch_name,
|
||||
// client_branch.address1 AS client_address,
|
||||
// policy_type.policy_type,
|
||||
// policy_type.bap,
|
||||
// insurers.name AS insurer_name,
|
||||
// insurers.short_name AS insurer_short_name,
|
||||
// insurer_branch.branch_name AS insurer_branch_name,
|
||||
// insurer_branch.branch_code AS insurer_branch_code,
|
||||
// user_profiles.first_name as user_name,
|
||||
// vehicle.vehicle_no,
|
||||
// tpa.name as tpa_name,
|
||||
// pt_co_share_details.remark as remarks,
|
||||
// pt_co_share_details.bp_amt,
|
||||
// pt_co_share_details.exp_amt,
|
||||
// pt_co_share_details.id as pt_id,
|
||||
// sales_user.first_name as salse_person_name,
|
||||
// service_user.first_name as service_person_name,
|
||||
|
||||
// ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
|
||||
|
||||
// ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
|
||||
|
||||
// ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
|
||||
|
||||
// ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS tp_or_ter,
|
||||
|
||||
// DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
|
||||
|
||||
// (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per,
|
||||
|
||||
// pt_co_share_details.agreed_bp_per,
|
||||
// ROUND(
|
||||
// (
|
||||
// SELECT
|
||||
// (
|
||||
// SUM(co_share_stmt_details.actual_bp_brokerage_amt) +
|
||||
// SUM(co_share_stmt_details.actual_tp_brokerage_amt) +
|
||||
// SUM(co_share_stmt_details.actual_tep_brokerage_amt) +
|
||||
// SUM(co_share_stmt_details.reward)
|
||||
|
||||
// ) AS total_irda_amt
|
||||
// FROM
|
||||
// co_share_stmt_details
|
||||
// JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
||||
// WHERE
|
||||
// co_share_stmt_details.co_share_id = pt_co_share_details.id
|
||||
// AND co_share_stmt_details.is_active = 1
|
||||
// AND insurer_statements.is_active = 1
|
||||
// $date_condition
|
||||
// ),
|
||||
// 2
|
||||
// ) AS total_irda_amt,
|
||||
// ROUND(
|
||||
// (
|
||||
// SELECT
|
||||
// (
|
||||
// SUM(co_share_stmt_details.reward)
|
||||
|
||||
// ) AS reward
|
||||
// FROM
|
||||
// co_share_stmt_details
|
||||
// JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
||||
// WHERE
|
||||
// co_share_stmt_details.co_share_id = pt_co_share_details.id
|
||||
// AND co_share_stmt_details.is_active = 1
|
||||
// AND insurer_statements.is_active = 1
|
||||
// $date_condition
|
||||
// ),
|
||||
// 2
|
||||
// ) AS reward,
|
||||
|
||||
// ROUND(
|
||||
// (
|
||||
// SELECT
|
||||
// SUM(
|
||||
// COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
|
||||
// COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
|
||||
// COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
|
||||
// COALESCE(co_share_stmt_details.reward, 0)
|
||||
// ) AS total_irda_amt
|
||||
// FROM
|
||||
// co_share_stmt_details
|
||||
// JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
|
||||
// JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
||||
// WHERE
|
||||
// co_share_stmt_details.co_share_id = pt_co_share_details.id
|
||||
// AND co_share_stmt_details.is_active = 1
|
||||
// AND pt_table.is_active = 1
|
||||
// AND insurer_statements.is_active = 1
|
||||
// AND insurer_statements.invoice_status IS NOT NULL
|
||||
// $date_condition
|
||||
|
||||
// ),
|
||||
// 2
|
||||
// ) AS billed_amt,
|
||||
|
||||
// ROUND(
|
||||
// (
|
||||
// (
|
||||
// SELECT
|
||||
// SUM(
|
||||
// COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
|
||||
// + COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
|
||||
// + COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
|
||||
// + COALESCE(co_share_stmt_details.reward, 0)
|
||||
// )
|
||||
// FROM
|
||||
// co_share_stmt_details
|
||||
// JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
||||
// WHERE
|
||||
// co_share_stmt_details.co_share_id = pt_co_share_details.id
|
||||
// AND co_share_stmt_details.is_active = 1
|
||||
// $date_condition
|
||||
// )
|
||||
// -
|
||||
// (
|
||||
// SELECT
|
||||
// SUM(
|
||||
// COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
|
||||
// + COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
|
||||
// + COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
|
||||
// + COALESCE(co_share_stmt_details.reward, 0)
|
||||
// )
|
||||
// FROM
|
||||
// co_share_stmt_details
|
||||
// JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
|
||||
// JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
|
||||
// WHERE
|
||||
// co_share_stmt_details.co_share_id = pt_co_share_details.id
|
||||
// AND co_share_stmt_details.is_active = 1
|
||||
// AND pt_table.is_active = 1
|
||||
// AND insurer_statements.is_active = 1
|
||||
// AND insurer_statements.invoice_status IS NULL
|
||||
// $date_condition
|
||||
// )
|
||||
// ),
|
||||
// 2
|
||||
// ) AS unbilled_amt
|
||||
|
||||
// ")
|
||||
// ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
|
||||
// // ->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
|
||||
// ->join('clients', 'clients.id = policy_transaction.client_id')
|
||||
// ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
|
||||
// ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
// ->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
|
||||
// ->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
|
||||
// ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
|
||||
// ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
|
||||
// ->join('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left')
|
||||
// ->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left')
|
||||
// ->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
||||
// ->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
||||
// ->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||
// ->where('policy_transaction.is_active', 1)
|
||||
// ->where('pt_co_share_details.is_active', 1);
|
||||
|
||||
// // Check if the start date and end date are provided
|
||||
// if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
|
||||
|
||||
// $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
// $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
// $builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
// ->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
|
||||
// }
|
||||
|
||||
// // if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
|
||||
|
||||
// // $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
// // $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
// // $builder->where('policy_transaction.month >=', $startDate)
|
||||
// // ->where('policy_transaction.month <=', $endDate);
|
||||
// // }
|
||||
|
||||
// // Conditionally join insurer_statements if $date_type == 'statement_month'
|
||||
// if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
||||
// $startDate = date('Y-m-d', strtotime($start_date));
|
||||
// $endDate = date('Y-m-d', strtotime($end_date));
|
||||
|
||||
// $builder->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id', 'left')
|
||||
// ->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id','left')
|
||||
// ->where('insurer_statements.is_active', 1)
|
||||
// ->where('insurer_statements.month >=', $startDate)
|
||||
// ->where('insurer_statements.month <=', $endDate)
|
||||
// ->groupBy('co_share_stmt_details.co_share_id');
|
||||
// }
|
||||
|
||||
// if ($client_id != 0) {
|
||||
// $builder->where('policy_transaction.client_id', $client_id);
|
||||
// }
|
||||
|
||||
// if ($insurer_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
// }
|
||||
|
||||
// if ($client_branch_id != 0) {
|
||||
// $builder->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||
// }
|
||||
|
||||
// if ($insurer_branch_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||
// }
|
||||
|
||||
// if ($client_policy_id != 0) {
|
||||
// $builder->where('policy_transaction.client_policy_id', $client_policy_id);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// if ($policy_type_id != 0) {
|
||||
// $builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
// }
|
||||
|
||||
// if ($issuer != 0) {
|
||||
// $builder->where('policy_transaction.issuer', $issuer);
|
||||
// }
|
||||
|
||||
// if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
// }
|
||||
|
||||
// $builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
// $result = $builder->get()->getResultArray();
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0)
|
||||
{
|
||||
|
||||
@ -365,19 +639,19 @@ class PolicyTransactionModel extends Model
|
||||
vehicle.vehicle_no,
|
||||
tpa.name as tpa_name,
|
||||
pt_co_share_details.remark as remarks,
|
||||
pt_co_share_details.bp_amt,
|
||||
pt_co_share_details.cop_amt as bp_amt,
|
||||
pt_co_share_details.exp_amt,
|
||||
pt_co_share_details.id as pt_id,
|
||||
sales_user.first_name as salse_person_name,
|
||||
service_user.first_name as service_person_name,
|
||||
|
||||
ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
|
||||
ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) AS premium_wo_gst,
|
||||
|
||||
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
|
||||
ROUND((ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) * 18 / 100), 2) AS gst_amount,
|
||||
|
||||
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
|
||||
ROUND((ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) + ROUND((ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
|
||||
|
||||
ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS tp_or_ter,
|
||||
ROUND((pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) AS tp_or_ter,
|
||||
|
||||
DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
|
||||
|
||||
@ -591,9 +865,89 @@ class PolicyTransactionModel extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
// public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
// {
|
||||
// // dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||
// $builder = $this->db->table('policy_transaction')
|
||||
// ->select('
|
||||
// policy_transaction.*,
|
||||
// clients.short_name AS client_short_name,
|
||||
// clients.client_code,
|
||||
// clients.client_type,
|
||||
// clients.client_name,
|
||||
// client_branch.branch_name AS client_branch_name,
|
||||
// insurers.name AS insurer_name,
|
||||
// insurers.short_name AS insurer_short_name,
|
||||
// policy_type.policy_type,
|
||||
// pt_co_share_details.agreed_amt AS amount,
|
||||
// pt_co_share_details.bp_amt AS bp,
|
||||
// pt_co_share_details.tp_amt AS tp
|
||||
// ')
|
||||
// ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
|
||||
// ->join('clients', 'clients.id = policy_transaction.client_id', 'left')
|
||||
// ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
|
||||
// ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
|
||||
// ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
// ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
|
||||
// ->where('policy_transaction.is_active', 1)
|
||||
// ->where('policy_transaction.action_type', 'inception');
|
||||
|
||||
// if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
// $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
// $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
// $builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
// ->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
// }else{
|
||||
|
||||
// // $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// // $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
// // $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// // ->where('policy_transaction.created_at <=', $toDate);
|
||||
// }
|
||||
|
||||
// if ($client_id != 0) {
|
||||
// $builder->where('policy_transaction.client_id', $client_id);
|
||||
// }
|
||||
|
||||
// if ($insurer_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
// }
|
||||
|
||||
// if ($policy_type_id != 0) {
|
||||
// $builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
// }
|
||||
|
||||
// if ($issuer != 0) {
|
||||
// $builder->where('policy_transaction.issuer', $issuer);
|
||||
// }
|
||||
// if ($status != 0) {
|
||||
// $builder->where('policy_transaction.status', $status);
|
||||
// }
|
||||
|
||||
// if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
// }
|
||||
|
||||
// $builder->orderBy('policy_transaction.id', 'desc')->limit(10);
|
||||
|
||||
// $result = $builder->get()->getResultArray();
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
// dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select('
|
||||
policy_transaction.*,
|
||||
@ -619,59 +973,44 @@ class PolicyTransactionModel extends Model
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.action_type', 'inception');
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
}else{
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
// Optimize Date Filtering
|
||||
if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
|
||||
$builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
|
||||
->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date)));
|
||||
}
|
||||
|
||||
if ($client_id != 0) {
|
||||
// Apply Filters Only When Necessary
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
if (!empty($insurer_id)) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
if (!empty($policy_type_id)) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
if ($issuer != 0) {
|
||||
if (!empty($issuer)) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
if ($status != 0) {
|
||||
if (!empty($status)) {
|
||||
$builder->where('policy_transaction.status', $status);
|
||||
}
|
||||
|
||||
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
|
||||
// Default to Last 30 Days if No Filters Are Applied
|
||||
if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer)) {
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
}
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
$result = $builder->get()->getResultArray();
|
||||
// Optimize Query Execution
|
||||
$builder->orderBy('policy_transaction.id', 'desc')->limit(10);
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
|
||||
return $result;
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
public function getEndorsementTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
@ -762,7 +1101,7 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
pt_co_share_details.exp_amt,
|
||||
pt_co_share_details.variance,
|
||||
ROUND ( (pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt),2) as original_premium,
|
||||
ROUND ( (pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt),2) as original_premium,
|
||||
ROUND(
|
||||
(
|
||||
SELECT
|
||||
@ -780,7 +1119,7 @@ class PolicyTransactionModel extends Model
|
||||
) AS statement_premium,
|
||||
|
||||
COALESCE(
|
||||
(pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 0
|
||||
(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 0
|
||||
) -
|
||||
COALESCE(
|
||||
(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1254,7 +1254,7 @@ $('#issue_type').change(function(){
|
||||
let value = $(this).val()
|
||||
|
||||
if(value == 1){
|
||||
$('#revenue_type').val('NA');
|
||||
$('#revenue_type').val('');
|
||||
$('#revenue_type option[value="NA"]').show();
|
||||
$('#revenue_type option[value="EANR"]').show();
|
||||
$('#revenue_type option[value="EA"]').hide();
|
||||
|
||||
11
writable/cache/.gitkeep
vendored
Executable file
11
writable/cache/.gitkeep
vendored
Executable file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user