示例#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
示例#2
0
def update_jrnl(date,mortgage_id,url_id,institution_code):
	logger = logging.getLogger('retrieve')
	logger.info('%s Updating retrieval mortgage %s', institution_code, mortgage_id)
	# insert if not there.
	if not themortgagemeter_db.is_item_there(sql_is_jrnl_there,(mortgage_id,)):
		themortgagemeter_db.run_sql(sql_insert_mortgage_jrnl,(date,mortgage_id,date,url_id))
	else:
		mortgage_jrnl_id = themortgagemeter_db.get_item_id(sql_get_jrnl_there,(mortgage_id,))
		themortgagemeter_db.run_sql(sql_update_mortgage_jrnl_retrieval,(date,url_id,mortgage_id))
示例#3
0
def update_savings_jrnl(date,savings_id,url_id,institution_code):
	logger = logging.getLogger('retrieve')
	logger.info('%s Updating retrieval savings %s', institution_code, savings_id)
	# insert if not there.
	if not themortgagemeter_db.is_item_there(sql_is_savings_jrnl_there,(savings_id,)):
		themortgagemeter_db.run_sql(sql_insert_savings_jrnl,(date,savings_id,date,url_id))
	else:
		savings_jrnl_id = themortgagemeter_db.get_item_id(sql_get_savings_jrnl_there,(savings_id,))
		themortgagemeter_db.run_sql(sql_update_savings_jrnl_retrieval,(date,url_id,savings_id))
示例#4
0
def insert_mortgage(institution_code, mortgage_type, rate, svr, apr, ltv,
                    initial_period, booking_fee, term, eligibility):
    logger = logging.getLogger('retrieve')
    logger.info('Inserting mortgage: %s %s %s %s %s %s %s %s %s %s',
                institution_code, mortgage_type, rate, svr, apr, ltv,
                initial_period, booking_fee, term, eligibility)
    themortgagemeter_db.run_sql(
        sql_insert_mortgage,
        (institution_code, mortgage_type, rate, svr, apr, ltv, initial_period,
         booking_fee, term, eligibility))
    return get_mortgage_id(institution_code, mortgage_type, rate, svr, apr,
                           ltv, initial_period, booking_fee, term, eligibility)
示例#5
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
示例#6
0
def insert_mortgage(institution_code, mortgage_type, rate, svr, apr, ltv, initial_period, booking_fee, term, eligibility):
	logger = logging.getLogger('retrieve')
	logger.info('Inserting mortgage: %s %s %s %s %s %s %s %s %s %s', institution_code, mortgage_type, rate, svr, apr, ltv, initial_period, booking_fee, term, eligibility)
	themortgagemeter_db.run_sql(sql_insert_mortgage,(institution_code, mortgage_type, rate, svr, apr, ltv, initial_period, booking_fee, term, eligibility))
	return get_mortgage_id(institution_code, mortgage_type, rate, svr, apr, ltv, initial_period, booking_fee, term, eligibility)
示例#7
0
def get_url_id_insert_if_there(url):
	if not themortgagemeter_db.is_item_there(sql_is_url_there,(url,)):
		themortgagemeter_db.run_sql(sql_insert_url,(url,))
	return themortgagemeter_db.get_item_id(sql_get_url_id,(url,))
示例#8
0
def get_url_id_insert_if_there(url):
    if not themortgagemeter_db.is_item_there(sql_is_url_there, (url, )):
        themortgagemeter_db.run_sql(sql_insert_url, (url, ))
    return themortgagemeter_db.get_item_id(sql_get_url_id, (url, ))
示例#9
0
def insert_savings(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):
	logger = logging.getLogger('retrieve')
	logger.info('Inserting savings %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s', 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)
	themortgagemeter_db.run_sql(sql_insert_savings,(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))
	return get_savings_id(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)