From 76644bf9d87f83ea1326654f6018687fe990e117 Mon Sep 17 00:00:00 2001
From: Immanuel Onyeka <immanuel@onyeka.ca>
Date: Sat, 12 Nov 2022 17:02:38 -0500
Subject: [PATCH] Add example fee templates

---
 migrations/0_29092022_create_main_tables.sql |  5 ++-
 migrations/seed.sql                          | 46 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/migrations/0_29092022_create_main_tables.sql b/migrations/0_29092022_create_main_tables.sql
index 900f58f..f79c3a3 100644
--- a/migrations/0_29092022_create_main_tables.sql
+++ b/migrations/0_29092022_create_main_tables.sql
@@ -116,8 +116,9 @@ CREATE TABLE fee_template (
 	id 				INT AUTO_INCREMENT,
 	user_id 		INT,
 	branch_id 		INT,
-	amount 			INT NOT NULL,
-	type 			ENUM('Goverment', 'Title', 'Other'),
+	amount 			INT,
+	perc 			SMALLINT, /* Percentage of sale price instead of amount */
+	type 			ENUM('Goverment', 'Title', 'Required', 'Lender', 'Other'),
 	notes 			VARCHAR(255),
 	name 			VARCHAR(30),
 	/* Group heading shown in report */
diff --git a/migrations/seed.sql b/migrations/seed.sql
index af0e4ea..d6edddf 100644
--- a/migrations/seed.sql
+++ b/migrations/seed.sql
@@ -83,3 +83,49 @@ INSERT IGNORE INTO loan_type (
 	(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
+(
+	NULL,
+	(SELECT id FROM branch LIMIT 1),
+	0,
+	200,
+	'Title',
+	true,
+	"Lender'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),
+	NULL,
+	9900,
+	0,
+	"Government",
+	false,
+	"Recording Charges"
+),
+(
+	(SELECT id FROM user WHERE email="test@example.com" LIMIT 1),
+	NULL,
+	0,
+	400,
+	'Lender',
+	true,
+	"Processing fee"
+);