INSERT IGNORE INTO branch
  (type, num )
VALUES
  ('NMLS', 'abc123idk'),
  ('FSRA', 'another branch');

INSERT IGNORE INTO user (
	first_name,
	last_name,
	password,
	branch_id,
	country,
	title,
	email,
	verified,
	role,
	status
) VALUES

(
	'Blue',
	'Coltrane',
	sha2('test123', 256),
	(SELECT id FROM branch LIMIT 1),
	'Canada',
	'Loan Officer',
	'test@example.com',
	true,
	'User',
	'Free'
),

(
	'Giant',
	'Coltrane',
	sha2('test123', 256),
	0,
	'USA',
	'Mortgage Broker',
	'unverified@example.com',
	false,
	'User',
	'Free'
),

(
	'Jeru',
	'Mulligan',
	sha2('test123', 256),
	(SELECT id FROM branch LIMIT 1),
	'USA',
	'Branch Manager',
	'manager@example.com',
	true,
	'Manager',
	'Free'
);

INSERT IGNORE INTO license (
	user_id,
	type,
	num
) VALUES
(
	(SELECT id FROM user WHERE email = 'test@example.com' LIMIT 1),
	'NMLS',
	'randomnml523s'
),
(
	(SELECT id FROM user WHERE email = 'manager@example.com' LIMIT 1),
	'FSRA',
	'5234gsdf'
);

INSERT IGNORE INTO loan_type (
	branch_id,
	user_id,
	name
) VALUES
(
	(SELECT id FROM branch LIMIT 1),
	0,
	'testType'
),
(
	0,
	(SELECT id FROM user WHERE email="manager@example.com" LIMIT 1),
	'manager idea'
);

INSERT IGNORE INTO fee_template (
	user_id,
	branch_id,
	amount,
	perc,
	type,
	auto,
	name
) VALUES
(
	0,
	(SELECT id FROM branch LIMIT 1),
	0,
	200,
	'Title',
	true,
	"LenderS's Title Insurance"
),
(
	(SELECT id FROM user WHERE email="manager@example.com" LIMIT 1),
	(SELECT id FROM branch LIMIT 1),
	5250,
	0,
	'Required',
	true,
	"Appraisal"
),
(
	(SELECT id FROM user WHERE email="test@example.com" LIMIT 1),
	0,
	9900,
	0,
	"Government",
	false,
	"Recording Charges"
),
(
	(SELECT id FROM user WHERE email="test@example.com" LIMIT 1),
	0,
	0,
	400,
	'Lender',
	true,
	"Processing fee"
);

INSERT IGNORE INTO loan_type (
	user_id,
	branch_id,
	name
) VALUES
(
	0,
	0,
	"Conventional"
),
(
	0,
	0,
	"FHA"
),
(
	0,
	0,
	"VA"
),
(
	0,
	0,
	"USDA"
),
(
	0,
	(SELECT id FROM branch LIMIT 1),
	"Test"
);

INSERT IGNORE INTO borrower (
	credit_score,
	monthly_income,
	num
) VALUES
(
	740,
	500000,
	1
);

INSERT INTO estimate (
	user_id,
	borrower_id,
	transaction,
	price,
	property,
	occupancy,
	zip,
	pud
) VALUES
(
	(SELECT id FROM user WHERE email="test@example.com" LIMIT 1),
	(SELECT id FROM borrower ORDER BY id DESC LIMIT 1),
	'Purchase',
	100000000,
	1,
	1,
	'95051',
	false
),
(
	(SELECT id FROM user WHERE email="manager@example.com" LIMIT 1),
	(SELECT id FROM borrower ORDER BY id DESC LIMIT 1),
	'Purchase',
	25000000,
	2,
	1,
	'95051',
	false
),
(
	(SELECT id FROM user WHERE email="test@example.com" LIMIT 1),
	(SELECT id FROM borrower ORDER BY id DESC LIMIT 1),
	'Refinance',
	50000000,
	3,
	2,
	'95051',
	false
);

INSERT INTO loan (
	estimate_id,
	type_id,
	amount,
	term,
	interest,
	ltv,
	dti,
	hoi,
	name
) VALUES
(
	1,
	(SELECT id FROM loan_type WHERE name="Conventional"),
	3300000,
	30,
	375,
	88.00,
	5.00,
	0,
	"For client 1"
),
(
	1,
	(SELECT id FROM loan_type WHERE name="FHA"),
	2510000,
	30,
	300,
	90.00,
	6.70,
	0,
	"For client 2"
),
(
	3,
	(SELECT id FROM loan_type WHERE name="FHA"),
	2510000,
	30,
	300,
	90.00,
	6.70,
	0,
	"For client 2"
),
(
	2,
	(SELECT id FROM loan_type WHERE name="USDA"),
	8000000,
	10,
	125,
	95.00,
	4.90,
	0,
	"Random name"
);

INSERT INTO mi (
	loan_id,
	type,
	label,
	lender,
	rate,
	premium,
	upfront,
	five_year_total,
	initial_premium,
	initial_rate
) VALUES
(
	1,
	"BPM",
	"National MI test loan",
	"National MI",
	28,
	77000,
	0,
	4620000,
	77000,
	28
);


INSERT INTO estimate_result (
	loan_id,
	loan_payment,
	total_monthly,
	total_fees,
	total_credits,
	cash_to_close
) VALUES
(
	1,
	258060,
	311500,
	87211,
	-15089,
	411822
),
(
	2,
	198060,
	241500,
	54400,
	-10089,
	310022
),
(
	3,
	118000,
	350000,
	54400,
	-70089,
	411699
);
