Beispiel #1
0
def delete_mortgages_not_current(institution_code, date, forcedelete, logger):
    logger = logging.getLogger('retrieve')
    logger.info('In delete_mortgages_not_current')
    themortgagemeter_db.cursor.execute(sql_count_jrnl_institution_there,
                                       (institution_code, ))
    row = themortgagemeter_db.cursor.fetchone()
    count = int(row[0])
    deletecount = 0
    logger.info('There are %s mortgages currently', count)
    themortgagemeter_db.cursor.execute(sql_get_mortgages_not_retrieved_on_date,
                                       (institution_code, date))
    for row in themortgagemeter_db.cursor.fetchall():
        mortgage_id = row[0]
        logger.info('Deleting current mortgage: %s %s %s', institution_code,
                    date, mortgage_id)
        themortgagemeter_db.run_sql(sql_update_mortgage_jrnl_delete,
                                    (date, mortgage_id))
        deletecount += 1
        main.update_changes(True, institution_code, logger)
    logger.info('%s mortgages deleted', (int(deletecount)))
    if count > 0 and deletecount == count and forcedelete == False:
        themortgagemeter_utils.record_error(
            'ERROR: Would have deleted all mortgages for ' + institution_code +
            ', check logs', logger, themortgagemeter_db.db_connection,
            themortgagemeter_db.cursor)
        exit()
    return
Beispiel #2
0
def handle_mortgage_insert(institution_code, mortgage_type, rate_percent, svr_percent, apr_percent, ltv_percent, initial_period, booking_fee, term, url, eligibility, logger):
	logger.debug(institution_code)
	logger.debug(mortgage_type)
	logger.debug(rate_percent)
	logger.debug(svr_percent)
	logger.debug(apr_percent)
	logger.debug(ltv_percent)
	logger.debug(initial_period)
	logger.debug(booking_fee)
	logger.debug(term)
	logger.debug(url)
	logger.debug(eligibility)
	check_data(rate_percent,booking_fee,ltv_percent,apr_percent,initial_period,logger)
	rate_percent_int = int(float(rate_percent) * 100)
	apr_percent_int = int(float(apr_percent) * 100)
	ltv_percent_int = int(float(ltv_percent) * 100)
	svr_percent_int = int(float(svr_percent) * 100)
	if mc_db.is_mortgage_there(institution_code, mortgage_type, rate_percent_int, svr_percent_int, apr_percent_int, ltv_percent_int, initial_period, booking_fee, term, eligibility) == 0:
		logger.debug('Mortgage being added')
		mortgage_id = mc_db.insert_mortgage(institution_code, mortgage_type, rate_percent_int, svr_percent_int, apr_percent_int, ltv_percent_int, initial_period, booking_fee, term, eligibility)
		main.update_changes(True,institution_code,logger)
	else:
		logger.debug('Mortgage already there')
		mortgage_id = mc_db.get_mortgage_id(institution_code, mortgage_type, rate_percent_int, svr_percent_int, apr_percent_int, ltv_percent_int, initial_period, booking_fee, term, eligibility)
	# Get the url id:
	url_id = mc_db.get_url_id_insert_if_there(url)
	mc_db.update_jrnl(main.today,mortgage_id,url_id,institution_code)
Beispiel #3
0
def handle_mortgage_insert(institution_code, mortgage_type, rate_percent,
                           svr_percent, apr_percent, ltv_percent,
                           initial_period, booking_fee, term, url, eligibility,
                           logger):
    logger.debug(institution_code)
    logger.debug(mortgage_type)
    logger.debug(rate_percent)
    logger.debug(svr_percent)
    logger.debug(apr_percent)
    logger.debug(ltv_percent)
    logger.debug(initial_period)
    logger.debug(booking_fee)
    logger.debug(term)
    logger.debug(url)
    logger.debug(eligibility)
    check_data(rate_percent, booking_fee, ltv_percent, apr_percent,
               initial_period, logger)
    rate_percent_int = int(float(rate_percent) * 100)
    apr_percent_int = int(float(apr_percent) * 100)
    ltv_percent_int = int(float(ltv_percent) * 100)
    svr_percent_int = int(float(svr_percent) * 100)
    if mc_db.is_mortgage_there(institution_code, mortgage_type,
                               rate_percent_int, svr_percent_int,
                               apr_percent_int, ltv_percent_int,
                               initial_period, booking_fee, term,
                               eligibility) == 0:
        logger.debug('Mortgage being added')
        mortgage_id = mc_db.insert_mortgage(institution_code, mortgage_type,
                                            rate_percent_int, svr_percent_int,
                                            apr_percent_int, ltv_percent_int,
                                            initial_period, booking_fee, term,
                                            eligibility)
        main.update_changes(True, institution_code, logger)
    else:
        logger.debug('Mortgage already there')
        mortgage_id = mc_db.get_mortgage_id(institution_code, mortgage_type,
                                            rate_percent_int, svr_percent_int,
                                            apr_percent_int, ltv_percent_int,
                                            initial_period, booking_fee, term,
                                            eligibility)
    # Get the url id:
    url_id = mc_db.get_url_id_insert_if_there(url)
    mc_db.update_jrnl(main.today, mortgage_id, url_id, institution_code)
Beispiel #4
0
def delete_mortgages_not_current(institution_code,date,forcedelete,logger):
	logger = logging.getLogger('retrieve')
	logger.info('In delete_mortgages_not_current')
	themortgagemeter_db.cursor.execute(sql_count_jrnl_institution_there,(institution_code,))
	row = themortgagemeter_db.cursor.fetchone()
	count = int(row[0])
	deletecount = 0
	logger.info('There are %s mortgages currently',count)
	themortgagemeter_db.cursor.execute(sql_get_mortgages_not_retrieved_on_date,(institution_code,date))
	for row in themortgagemeter_db.cursor.fetchall():
		mortgage_id = row[0]
		logger.info('Deleting current mortgage: %s %s %s', institution_code, date, mortgage_id)
		themortgagemeter_db.run_sql(sql_update_mortgage_jrnl_delete,(date, mortgage_id))
		deletecount += 1
		main.update_changes(True,institution_code,logger)
	logger.info('%s mortgages deleted',(int(deletecount)))
	if count > 0 and deletecount == count and forcedelete == False:
		themortgagemeter_utils.record_error('ERROR: Would have deleted all mortgages for ' + institution_code + ', check logs',logger,themortgagemeter_db.db_connection,themortgagemeter_db.cursor)
		exit()
	return
def handle_savings_insert(institution_code, isa, regular_saver, regular_saver_frequency_period, regular_saver_frequency_type, regular_saver_min_amt, regular_saver_max_amt, bonus, bonus_frequency_period, bonus_frequency_type, online, branch, variability, savings_period, min_amt, max_amt, gross_percent, aer_percent, child, interest_paid, url, logger):
	logger.debug(institution_code)
	logger.debug(isa)
	logger.debug(regular_saver)
	logger.debug(regular_saver_frequency_period)
	logger.debug(regular_saver_frequency_type)
	logger.debug(regular_saver_min_amt)
	logger.debug(regular_saver_max_amt)
	logger.debug(bonus)
	logger.debug(bonus_frequency_period)
	logger.debug(bonus_frequency_type)
	logger.debug(online)
	logger.debug(branch)
	logger.debug(variability)
	logger.debug(savings_period)
	logger.debug(min_amt)
	logger.debug(max_amt)
	logger.debug(gross_percent)
	logger.debug(aer_percent)
	logger.debug(child)
	logger.debug(interest_paid)
	check_data(isa, regular_saver, regular_saver_frequency_period, regular_saver_frequency_type, regular_saver_min_amt, regular_saver_max_amt, bonus, bonus_frequency_period, bonus_frequency_type, online, branch, variability, savings_period, min_amt, max_amt, gross_percent, aer_percent, child, interest_paid, logger)
	regular_saver_frequency_period_int      = int(regular_saver_frequency_period)
	savings_period_int          = int(savings_period)
	regular_saver_min_amt_int   = int(float(regular_saver_min_amt) * 100)
	regular_saver_max_amt_int   = int(float(regular_saver_max_amt) * 100)
	bonus_frequency_period_int  = int(float(bonus_frequency_period) * 100)
	min_amt_int                 = int(float(min_amt) * 100)
	max_amt_int                 = int(float(max_amt) * 100)
	gross_percent_int           = int(float(gross_percent) * 100)
	aer_percent_int             = int(float(aer_percent) * 100)
	if savings_db.is_savings_there(institution_code, isa, regular_saver, regular_saver_frequency_period_int, regular_saver_frequency_type, regular_saver_min_amt_int, regular_saver_max_amt_int, bonus, bonus_frequency_period_int, bonus_frequency_type, online, branch, variability, savings_period_int, min_amt_int, max_amt_int, gross_percent_int, aer_percent_int, child, interest_paid) == 0:
		logger.debug('Savings being added')
		savings_id = savings_db.insert_savings(institution_code, isa, regular_saver, regular_saver_frequency_period_int, regular_saver_frequency_type, regular_saver_min_amt_int, regular_saver_max_amt_int, bonus, bonus_frequency_period_int, bonus_frequency_type, online, branch, variability, savings_period_int, min_amt_int, max_amt_int, gross_percent_int, aer_percent_int, child, interest_paid)
		main.update_changes(True,institution_code,logger)
	else:
		logger.debug('Savings already there')
		savings_id = savings_db.get_savings_id(institution_code, isa, regular_saver, regular_saver_frequency_period_int, regular_saver_frequency_type, regular_saver_min_amt_int, regular_saver_max_amt_int, bonus, bonus_frequency_period_int, bonus_frequency_type, online, branch, variability, savings_period_int, min_amt_int, max_amt_int, gross_percent_int, aer_percent_int, child, interest_paid)
	# Get the url id:
	url_id = savings_db.get_url_id_insert_if_there(url)
	savings_db.update_savings_jrnl(main.today,savings_id,url_id,institution_code)
def handle_savings_insert(institution_code, isa, regular_saver,
                          regular_saver_frequency_period,
                          regular_saver_frequency_type, regular_saver_min_amt,
                          regular_saver_max_amt, bonus, bonus_frequency_period,
                          bonus_frequency_type, online, branch, variability,
                          savings_period, min_amt, max_amt, gross_percent,
                          aer_percent, child, interest_paid, url, logger):
    logger.debug(institution_code)
    logger.debug(isa)
    logger.debug(regular_saver)
    logger.debug(regular_saver_frequency_period)
    logger.debug(regular_saver_frequency_type)
    logger.debug(regular_saver_min_amt)
    logger.debug(regular_saver_max_amt)
    logger.debug(bonus)
    logger.debug(bonus_frequency_period)
    logger.debug(bonus_frequency_type)
    logger.debug(online)
    logger.debug(branch)
    logger.debug(variability)
    logger.debug(savings_period)
    logger.debug(min_amt)
    logger.debug(max_amt)
    logger.debug(gross_percent)
    logger.debug(aer_percent)
    logger.debug(child)
    logger.debug(interest_paid)
    check_data(isa, regular_saver, regular_saver_frequency_period,
               regular_saver_frequency_type, regular_saver_min_amt,
               regular_saver_max_amt, bonus, bonus_frequency_period,
               bonus_frequency_type, online, branch, variability,
               savings_period, min_amt, max_amt, gross_percent, aer_percent,
               child, interest_paid, logger)
    regular_saver_frequency_period_int = int(regular_saver_frequency_period)
    savings_period_int = int(savings_period)
    regular_saver_min_amt_int = int(float(regular_saver_min_amt) * 100)
    regular_saver_max_amt_int = int(float(regular_saver_max_amt) * 100)
    bonus_frequency_period_int = int(float(bonus_frequency_period) * 100)
    min_amt_int = int(float(min_amt) * 100)
    max_amt_int = int(float(max_amt) * 100)
    gross_percent_int = int(float(gross_percent) * 100)
    aer_percent_int = int(float(aer_percent) * 100)
    if savings_db.is_savings_there(
            institution_code, isa, regular_saver,
            regular_saver_frequency_period_int, regular_saver_frequency_type,
            regular_saver_min_amt_int, regular_saver_max_amt_int, bonus,
            bonus_frequency_period_int, bonus_frequency_type, online, branch,
            variability, savings_period_int, min_amt_int, max_amt_int,
            gross_percent_int, aer_percent_int, child, interest_paid) == 0:
        logger.debug('Savings being added')
        savings_id = savings_db.insert_savings(
            institution_code, isa, regular_saver,
            regular_saver_frequency_period_int, regular_saver_frequency_type,
            regular_saver_min_amt_int, regular_saver_max_amt_int, bonus,
            bonus_frequency_period_int, bonus_frequency_type, online, branch,
            variability, savings_period_int, min_amt_int, max_amt_int,
            gross_percent_int, aer_percent_int, child, interest_paid)
        main.update_changes(True, institution_code, logger)
    else:
        logger.debug('Savings already there')
        savings_id = savings_db.get_savings_id(
            institution_code, isa, regular_saver,
            regular_saver_frequency_period_int, regular_saver_frequency_type,
            regular_saver_min_amt_int, regular_saver_max_amt_int, bonus,
            bonus_frequency_period_int, bonus_frequency_type, online, branch,
            variability, savings_period_int, min_amt_int, max_amt_int,
            gross_percent_int, aer_percent_int, child, interest_paid)
    # Get the url id:
    url_id = savings_db.get_url_id_insert_if_there(url)
    savings_db.update_savings_jrnl(main.today, savings_id, url_id,
                                   institution_code)