########################################################
####### THIS FUNCTION DETERMINES WHICH RATIO TO BE USED
#######################################################
def premium_logic(row, scc="gbp"):
# ALL YEARS
if round(row.gl_future_premium,0) == 0:
return 0
# PREVIOUS YEARS, I.E ALL YEARS BEFORE THE CURRENT YEAR
elif row.yoa_code < current_year:
if row.total_value_signed_prems == 0 and row.gl_ultimate_premium >= 0:
return row[scc + "_default_bucket"]
else:
return row[scc + "_signed_prems"]
# CURRENT YEAR, I.E ALL YEARS AFTER CURRENT YEAR - 1
elif row.yoa_code > current_year - 1:
if row.total_value_signed_prems == 0 and row.total_value_prev_signed_prems !=0:
return row[scc + "_prev_signed_prems"]
elif row.total_value_signed_prems > row.total_value_prev_signed_prems:
elif row.total_value_signed_prems < row.total_value_prev_signed_prems:
if USE_SIGNED:
elif row.total_value_signed_prems == row.total_value_prev_signed_prems == 0:
def claims_logic(row, scc="gbp"):
## FOR ALL YEARS OF ACCOUNT
if round(row.gl_general_ibnr,0) == 0:
# FOR YEARS LESS THAN 2 YEARS AGO
elif row.yoa_code < current_year - 2:
if row.total_value_incurred_claims == 0 or round(row.claims_developed,2) < 0.85:
if row.total_premium_allocations == 0:
return row[scc+"_signed_prems"]
return row[scc+"_premium_ratio"]
return row[scc+"_incurred_claims"]
# FOR YEARS BETWEEN TWO YEARS AGO AND LAST YEAR
elif row.yoa_code >= current_year - 2 and row.yoa_code < current_year:
# FOR CURRENT YEAR