Project

General

Profile

Actions

Support #806

open

Report for Accounting

Added by Greg Krabbenhoft 2 months ago. Updated 2 months ago.

Status:
Merge with Production
Priority:
Immediate
Start date:
02/18/2025
Due date:
02/19/2025 (about 2 months late)
% Done:

0%

Estimated time:

Description

Tina requires a 1 time report for all of 2024. Please see the attached spreadsheet and create a custom DB query for this to be completed. When complete, please paste the query into the ticket so either George or myself can run it against the live database.

We do not have the ability to determine if the policy is a renewal, so please disregard that field, and for the client identifier please use the ID field of the user table (user_id field in the policies table)


Files

Database report.xlsx (9.5 KB) Database report.xlsx Greg Krabbenhoft, 02/18/2025 06:41 PM
report.csv.zip (3.78 MB) report.csv.zip George Howington, 02/21/2025 12:12 AM
Actions #1

Updated by Leo Esaki 2 months ago

  • Status changed from New to QA
  • Assignee changed from Leo Esaki to George Howington

Hi George.

I completed a raw sql query for this task. Please take a look!

SELECT pd.policy_num,
p.user_id,
CONCAT AS client_name,
un.company_name AS carrier_name,
pc.underwriter_premium AS carrier_premium,
pc.opt_travel_premium AS mexvisit_premium,
pc.evac_premium AS tme_premium,
DATE_FORMAT(FROM_UNIXTIME(pd.sales_time), '%Y-%m') AS sales_date,
af.business_name AS affiliate_name,
p.aff_id AS affiliate_id,
NULL AS producer_commission_amount,
ac.agent_premium AS affiliate_commission_rate,
pdvr.city AS billing_city,
s.name AS billing_state,
pdvr.zip AS billing_postalcode,
NULL AS classification,
CASE
WHEN p.leave_date < UNIX_TIMESTAMP() THEN 'Expired'
ELSE 'Active'
END AS policy_status
FROM policydetails pd
JOIN policies p ON pd.policy_id = p.id
JOIN users u ON p.user_id = u.id
JOIN underwriters un ON pd.underwriter_id = un.id
JOIN policyCosts pc ON pd.policy_id = pc.policy_id
JOIN affDetails af ON p.aff_id = af.aff_id
JOIN affComm ac ON p.aff_id = ac.aff_id
AND pd.underwriter_id = ac.underwriter_id
AND pd.sales_type = ac.sales_type
JOIN policydrivers pdvr ON pd.policy_id = pdvr.policy_id
JOIN states s ON pdvr.state = s.id
WHERE pd.sales_time >= 1704067200
AND pd.sales_time < 1735680000;

Thanks,
Leo

Actions #2

Updated by Leo Esaki 2 months ago

SELECT pd.policy_num,
p.user_id,
CONCAT AS client_name,
un.company_name AS carrier_name,
pc.underwriter_premium AS carrier_premium,
pc.opt_travel_premium AS mexvisit_premium,
pc.evac_premium AS tme_premium,
DATE_FORMAT(FROM_UNIXTIME(pd.sales_time), '%Y-%m') AS sales_date,
af.business_name AS affiliate_name,
p.aff_id AS affiliate_id,
NULL AS producer_commission_amount,
ac.agent_premium AS affiliate_commission_rate,
pdvr.city AS billing_city,
s.name AS billing_state,
pdvr.zip AS billing_postalcode,
NULL AS classification,
CASE
WHEN p.leave_date < UNIX_TIMESTAMP() THEN 'Expired'
ELSE 'Active'
END AS policy_status
FROM policydetails pd
JOIN policies p ON pd.policy_id = p.id
JOIN users u ON p.user_id = u.id
JOIN underwriters un ON pd.underwriter_id = un.id
LEFT JOIN (
SELECT policy_id,
MAX AS underwriter_premium,
MAX AS opt_travel_premium,
MAX AS evac_premium
FROM policyCosts
GROUP BY policy_id
) pc ON pd.policy_id = pc.policy_id
LEFT JOIN (
SELECT aff_id, underwriter_id, sales_type, MAX AS agent_premium
FROM affComm
GROUP BY aff_id, underwriter_id, sales_type
) ac ON p.aff_id = ac.aff_id AND pd.underwriter_id = ac.underwriter_id AND pd.sales_type = ac.sales_type
JOIN affDetails af ON p.aff_id = af.aff_id
JOIN policydrivers pdvr ON pd.policy_id = pdvr.policy_id
JOIN states s ON pdvr.state = s.id
WHERE pd.sales_time >= 1704067200
AND pd.sales_time < 1735680000;

Please use this.

Thanks,
Leo

Actions #3

Updated by George Howington 2 months ago

  • File report.csv.zip report.csv.zip added
  • Status changed from QA to Merge with Production
  • Assignee changed from George Howington to Greg Krabbenhoft

Hi Greg,

I've verified the accuracy of the produced data. Attached is a copy of 2024's data for Tina to verify.

Please let me know if you have any questions and thank you,
--George

Actions

Also available in: Atom PDF