99 lines
29 KiB
SQL
99 lines
29 KiB
SQL
-- create roles and associate with permissions
|
|
INSERT INTO `m_role` (`id`, `name`, `description`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
|
VALUES
|
|
(3,'Field officer','A field officer role allows the user to add client and loans and view reports but nothing else.',1,'2012-04-12 15:59:48','2012-04-12 15:59:48',1),
|
|
(4,'Data Entry (Portfolio only)','This role allows a user full permissions around client and loan functionality but nothing else.',1,'2012-04-12 16:01:25','2012-04-12 16:01:25',1),
|
|
(5,'Credit Committe Member','This role allows a user to approve reject or withdraw loans (with reporting).',1,'2012-04-12 16:11:25','2012-04-12 16:11:25',1),
|
|
(6,'Manager','This role allows a manager to do anything related to portfolio management and also view all reports.',1,'2012-04-12 17:02:11','2012-04-12 17:02:11',1);
|
|
|
|
INSERT INTO `m_role_permission` (`role_id`, `permission_id`)
|
|
VALUES
|
|
(3,6),(3,7),(3,8),(3,15),(3,22),(4,5),(5,6),(5,9),(5,10),(5,11),(5,12),(5,13),(5,14),(6,5),(6,6);
|
|
|
|
|
|
INSERT INTO `m_code` VALUES (1,'Business'),(2,'Education'),(3,'Ethnic Group'),(4,'Football Team'),(5,'Gender'),(6,'Knowledge of Person'),(7,'Location'),(8,'Religion');
|
|
INSERT INTO `m_code_value` VALUES (1,1,'Existing',8),(2,1,'New',7),(3,2,'None',44),(4,2,'Primary',40),(5,2,'Secondary',41),(6,2,'Tertiary',42),(7,2,'Trade',43),(8,3,'Bedouin',15),(9,3,'Berber',16),(10,3,'Italian',17),(11,3,'Miknasa',18),(12,3,'Mrazig',19),(13,3,'Other',20),(14,3,'Unknown',46),(15,4,'AC Milan',36),(16,4,'Juventus',37),(17,4,'Manchester Utd',39),(18,4,'None, hates soccer',45),(19,4,'Sao Paulo',38),(20,5,'Female',21),(21,5,'Male',22),(22,6,'Friend of staff member',26),(23,6,'Not known by any staff member',27),(24,6,'Other',28),(25,6,'Son/daughter of staff member',25),(26,6,'Spouse of staff member',24),(27,6,'Staff member',23),(28,7,'East Sikkim',1),(29,7,'North Sikkim',2),(30,7,'Other',6),(31,7,'South Sikkim',3),(32,7,'West Sikkim',4),(33,8,'Animist',32),(34,8,'Atheist',33),(35,8,'Catholic',30),(36,8,'Muslim',31),(37,8,'Other',34),(38,8,'Protestant',29),(39,8,'Unknown',35);
|
|
|
|
INSERT INTO `stretchy_report` VALUES (29,'Client Listing','Table',NULL,'Client','select ounder.`name` as \"Office/Branch\", concat(c.lastname, if(c.firstname > \"\", concat(\", \", c.firstname), \"\")) as \"Name\", \r\nc.joining_date as \"Joining Date\"\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\nwhere o.id = ${officeId}\r\nand c.is_deleted=0\r\norder by ounder.hierarchy','Simple sample screen report.\r\nNot really expected to be part of core reports.',0,1),(30,'Client Loans Listing','Table',NULL,'Client','select ounder.`name` as \"Office/Branch\", concat(c.lastname, if(c.firstname > \"\", concat(\", \", c.firstname), \"\")) as \"Name\",c.joining_date as \"Joining Date\",\r\np.name as Loan, st.enum_message_property as \"Status\", l.number_of_repayments as \"Expected No. Repayments\",\r\nl.annual_nominal_interest_rate as \" Annual Nominal Interest Rate\", \r\nifnull(cur.display_symbol, l.currency_code) as Currency, l.principal_amount,date( l.submittedon_date) as Submitted,\r\ndate(l.approvedon_date) Approved, l.expected_disbursedon_date As \"Expected Disbursal\",\r\ndate(l.expected_firstrepaymenton_date) as \"Expected First Repayment\",\r\ndate(l.expected_maturedon_date) \"Expected Maturity\",\r\ndate(l.disbursedon_date) as Disbursed, date(l.closedon_date) as Closed,\r\ndate(l.withdrawnon_date) as Withdrawn, date(l.rejectedon_date) as Rejected,\r\ndate(l.rescheduledon_date) Rescheduled, date(l.writtenoffon_date) \"Written Off\"\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\nleft join m_loan l on l.client_id = c.id\r\nleft join m_product_loan p on p.id = l.product_id\r\nleft join r_enum_value st on st.enum_name = \'loan_status_id\' and st.enum_id = l.loan_status_id\r\nleft join m_currency cur on cur.code = l.currency_code\r\nwhere o.id = ${officeId}\r\norder by ounder.hierarchy, \"Name\" , l.id','Can be a basic core loan report.',1,1),(31,'Loans Awaiting Disbursal','Table',NULL,'Loan Portfolio','SELECT ounder.`name` as \"Office/Branch\", concat(c.lastname, if(c.firstname > \"\", concat(\", \", c.firstname), \"\")) as \"Name\", \r\nl.id as \"Loan ID\", pl.`name` as \"Product\", \r\nifnull(cur.display_symbol, l.currency_code) as Currency, \r\nl.principal_amount as Principal, \r\ndate(l.approvedon_date) \"Approved\", l.expected_disbursedon_date \"Expected Disbursal\"\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\njoin m_product_loan pl on pl.id = l.product_id\r\nleft join m_currency cur on cur.code = l.currency_code\r\nwhere o.id = ${officeId}\r\nand l.loan_status_id = 200\r\norder by ounder.hierarchy, l.expected_disbursedon_date, \"Name\"',NULL,0,1),(32,'Upcoming Repayments','Table',NULL,'Loan Portfolio','SELECT r.duedate \"Due Date\", ounder.`name` as \"Office/Branch\", ifnull(cur.display_symbol, l.currency_code) as Currency, \r\nc.id as \"Client ID\",\r\nconcat(c.lastname, if(c.firstname > \"\", concat(\", \", c.firstname), \"\")) as \"Name\", \r\nl.id as \"Loan ID\", pl.`name` as \"Product\", \r\n\r\n(select\r\n if(if(datediff(curdate(), min(r.duedate)) < 0, 0, datediff(curdate(), min(r.duedate))) > 90, \"High\", \r\n if (if(datediff(curdate(), min(r.duedate)) < 0, 0, datediff(curdate(), min(r.duedate))) > 30, \"Medium\", \r\n if (if(datediff(curdate(), min(r.duedate)) < 0, 0, datediff(curdate(), min(r.duedate))) = 0, \r\n if (min(r.installment) = 1, \"Low\", \"Very Low\"),\r\n if (min(r.installment), \"Medium\", \"Low\")))) \r\nfrom m_loan lr\r\nleft join m_loan_repayment_schedule r on r.loan_id = lr.id\r\n and r.completed_derived is false\r\nwhere lr.id = l.id) as \"Loan Risk\",\r\n\r\n r.installment as Installment, \r\n(r.principal_amount - ifnull(r.principal_completed_derived, 0)) as \"Principal Due\",\r\n(r.interest_amount - ifnull(r.interest_completed_derived, 0)) as \"Interest Due\" ,\r\n((r.principal_amount - ifnull(r.principal_completed_derived, 0)) +\r\n(r.interest_amount - ifnull(r.interest_completed_derived, 0))) as \"Total Due\"\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\njoin m_product_loan pl on pl.id = l.product_id\r\njoin m_loan_repayment_schedule r on r.loan_id = l.id\r\nleft join m_currency cur on cur.code = l.currency_code\r\nwhere o.id = ${officeId}\r\nand (l.currency_code = \"${currencyId}\" or \"-1\" = \"${currencyId}\" )\r\nand l.loan_status_id = 300\r\nand r.duedate >= curdate()\r\norder by r.duedate, \"Name\"','Unlikely to be generally useful. Used as an example for Creocore',0,1),(34,'Loans - Active Loans Portfolio Status','Table',NULL,'Loan','select x.`Office/Branch`, x.Currency, x.`Name`, x.Loan, x.`Loan ID`, x.Disbursed, \r\nx.`Principal Outstanding`, x.`Interest Outstanding`, x.`Days Overdue`,\r\nx.`Principal Overdue`, x.`Interest Overdue`, \r\n\r\nif(x.`Days Overdue` > 90, \"High\", \r\n if (x.`Days Overdue` > 30, \"Medium\", \r\n if (`Days Overdue` = 0, \r\n if (`First Overdue Installment` = 1, \"Low\", \"Very Low\"),\r\n if (`First Overdue Installment` = 1, \"Medium\", \"Low\"))))\r\n\r\nas \"Loan Risk\", \r\nx.`First Overdue Installment`, x.`First Overdue Installment Date`\r\nfrom\r\n(select ounder.hierarchy, ounder.`name` as \"Office/Branch\", concat(c.lastname, if(c.firstname > \"\", concat(\", \", c.firstname), \"\")) as \"Name\", p.`name` as Loan,\r\nl.id as \"Loan ID\", l.disbursedon_date as Disbursed, ifnull(cur.display_symbol, l.currency_code) as Currency,\r\nsum(r.principal_amount - ifnull(r.principal_completed_derived, 0)) as \"Principal Outstanding\",\r\nsum(r.interest_amount - ifnull(r.interest_completed_derived, 0)) as \"Interest Outstanding\",\r\nif(datediff(curdate(), min(duedate)) < 0, 0, datediff(curdate(), min(duedate))) as \"Days Overdue\", \r\nmin(installment) as \"First Overdue Installment\",\r\nmin(duedate) as \"First Overdue Installment Date\",\r\nsum(if(r.duedate <= curdate(), \r\n (r.principal_amount - ifnull(r.principal_completed_derived, 0))\r\n , 0)) as \"Principal Overdue\",\r\nsum(if(r.duedate <= curdate(), \r\n (r.interest_amount - ifnull(r.interest_completed_derived, 0))\r\n , 0)) as \"Interest Overdue\"\r\n\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\nleft join m_currency cur on cur.code = l.currency_code\r\nleft join m_product_loan p on p.id = l.product_id\r\nleft join m_loan_repayment_schedule r on r.loan_id = l.id\r\n and r.completed_derived is false\r\nwhere o.id = ${officeId}\r\nand (l.currency_code = \"${currencyId}\" or \"-1\" = \"${currencyId}\")\r\nand l.loan_status_id = 300\r\ngroup by l.id) x\r\norder by x.hierarchy, x.Currency, x.`Name`, x.Loan, x.`Loan ID`',NULL,0,1),(35,'Portfolio at Risk','Table',NULL,'Loan Portfolio','select \r\nifnull(cur.display_symbol, l.currency_code) as Currency, \r\nsum(r.principal_amount - ifnull(r.principal_completed_derived, 0)) as \"Principal Outstanding\",\r\nsum(if(r.duedate <= curdate(), \r\n (r.principal_amount - ifnull(r.principal_completed_derived, 0))\r\n , 0)) as \"Principal Overdue\",\r\n \r\n cast(round(\r\n (sum(if(r.duedate <= curdate(), \r\n (r.principal_amount - ifnull(r.principal_completed_derived, 0))\r\n , 0)) * 100) / \r\n sum(r.principal_amount - ifnull(r.principal_completed_derived, 0))\r\n , 2) as char)\r\n as \"Portfolio at Risk %\"\r\n \r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\nleft join m_product_loan p on p.id = l.product_id\r\nleft join m_loan_repayment_schedule r on r.loan_id = l.id\r\n and r.completed_derived is false\r\nleft join m_currency cur on cur.code = l.currency_code\r\n\r\nwhere o.id = ${officeId}\r\nand (l.currency_code = \"${currencyId}\" or \"-1\" = \"${currencyId}\")\r\nand l.loan_status_id = 300\r\ngroup by l.currency_code\r\norder by l.currency_code',NULL,0,1),(38,'Upcoming Repayments Summary - Month, Currency, Loan Risk','Table',NULL,'Loan Portfolio','SELECT DATE_FORMAT(r.duedate,\'%Y-%m\') \"Due Month\", ifnull(cur.display_symbol, l.currency_code) as Currency, \r\n\r\n(select\r\n if(if(datediff(curdate(), min(r.duedate)) < 0, 0, datediff(curdate(), min(r.duedate))) > 90, \"4 High\", \r\n if (if(datediff(curdate(), min(r.duedate)) < 0, 0, datediff(curdate(), min(r.duedate))) > 30, \"3 Medium\", \r\n if (if(datediff(curdate(), min(r.duedate)) < 0, 0, datediff(curdate(), min(r.duedate))) = 0, \r\n if (min(r.installment) = 1, \"Low\", \"1 Very Low\"),\r\n if (min(r.installment), \"3 Medium\", \"2 Low\")))) \r\nfrom m_loan lr\r\nleft join m_loan_repayment_schedule r on r.loan_id = lr.id\r\n and r.completed_derived is false\r\nwhere lr.id = l.id) as \"Loan Risk\",\r\n\r\nsum(r.principal_amount - ifnull(r.principal_completed_derived, 0)) as \"Principal Due\",\r\nsum(r.interest_amount - ifnull(r.interest_completed_derived, 0)) as \"Interest Due\",\r\n\r\n(sum(r.principal_amount - ifnull(r.principal_completed_derived, 0)) +\r\nsum(r.interest_amount - ifnull(r.interest_completed_derived, 0))) as \"Total Due\"\r\n\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\njoin m_loan_repayment_schedule r on r.loan_id = l.id\r\nleft join m_currency cur on cur.code = l.currency_code\r\nwhere o.id = ${officeId}\r\nand (l.currency_code = \"${currencyId}\" or \"-1\" = \"${currencyId}\" )\r\nand l.loan_status_id = 300\r\nand r.duedate >= curdate()\r\ngroup by `Due Month`, `Currency`, `Loan Risk`\r\norder by `Due Month`, `Loan Risk`',NULL,0,1),(39,'Loan Disbursals in Previous Year','Chart','Bar','Loan Portfolio','select prevYr.startMonth as \"Disbursed Month\", ifnull(monthlyDisb.disbursed,0) as Disbursed\r\nfrom\r\n(SELECT DATE_FORMAT(@startDate := date_add(@startDate, interval 1 Month),\'%Y-%m\') as startMonth\r\nFROM rpt_sequence s, (SELECT @startDate := date_add(curdate(), interval -13 Month)) d\r\nWHERE s.id <= 13) prevYr\r\nleft join \r\n(select DATE_FORMAT(lt.transaction_date,\'%Y-%m\') as txnMonth, sum(lt.amount) as disbursed\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\njoin m_loan_transaction lt on lt.loan_id = l.id\r\nwhere o.id = ${officeId}\r\nand l.currency_code = \"${currencyId}\"\r\nand lt.transaction_type_enum = 1\r\ngroup by `txnMonth`) monthlyDisb on monthlyDisb.txnMonth = prevYr.startMonth',NULL,0,1),(40,'Loan Repayments in Previous Year','Chart','Bar','Loan Portfolio','select prevYr.startMonth as \"Repayment Month\", ifnull(monthlyR.repaid,0) as Repaid\r\nfrom\r\n(SELECT DATE_FORMAT(@startDate := date_add(@startDate, interval 1 Month),\'%Y-%m\') as startMonth\r\nFROM rpt_sequence s, (SELECT @startDate := date_add(curdate(), interval -13 Month)) d\r\nWHERE s.id <= 13) prevYr\r\nleft join \r\n(select DATE_FORMAT(lt.transaction_date,\'%Y-%m\') as txnMonth, sum(lt.amount) as repaid\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\njoin m_loan_transaction lt on lt.loan_id = l.id\r\nwhere o.id = ${officeId}\r\nand l.currency_code = \"${currencyId}\"\r\nand lt.transaction_type_enum = 2 and lt.contra_id is null\r\ngroup by `txnMonth`) monthlyR on monthlyR.txnMonth = prevYr.startMonth\r\norder by prevYr.startMonth',NULL,0,1),(41,'Clients by Surname (a bit silly)','Chart','Pie','Client','select c.lastname, count(*) as thecount\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\nwhere o.id = ${officeId}\r\nand c.is_deleted=0\r\ngroup by c.lastname',NULL,0,1),(42,'Client Listing - Additional and Unlikely','Table',NULL,'Client','select ounder.`name` as \"Office/Branch\", concat(c.lastname, if(c.firstname > \"\", concat(\", \", c.firstname), \"\")) as \"Name\", \r\na1.`Ethnic Group`, a1.`Ethnic Group Other`, a1.`Household Location`, a1. `Household Location Other`,\r\na1.Religion, a1.`Religion Other`, a1.`Knowledge of Person`, a1.Gender, a1.whois,\r\na2.`Fathers Favourite Team`, a2.`Mothers Favourite Team`, a2.`Fathers DOB`, a2.`Mothers DOB`,\r\na2.`Fathers Education`, a2.`Mothers Education`, a2.`Number of Children`,\r\na2.`Favourite Town`, a2.`Closing Comments`, a2.`Annual Family Income`\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\nleft join `m_client_xAdditional Information` a1 on a1.id = c.id\r\nleft join `m_client_xHighly Improbable Info` a2 on a2.id = c.id\r\nwhere o.id = ${officeId}\r\nand c.is_deleted=0\r\norder by ounder.hierarchy',NULL,0,1),(43,'Client Loans Listing - Additional','Table',NULL,'Client','select ounder.`name` as \"Office/Branch\", concat(c.lastname, if(c.firstname > \"\", concat(\", \", c.firstname), \"\")) as \"Name\",\r\np.name as Loan, st.enum_message_property as \"Status\", \r\nl.annual_nominal_interest_rate as \" Annual Nominal Interest Rate\", \r\nifnull(cur.display_symbol, l.currency_code) as Currency, l.principal_amount,\r\nl1.`Business Location`, l1.`Business Location Other`, l1.`Business` as \"Business Type\", \r\nl1.`Business Description`, l1.`Business Title`\r\nfrom m_office o \r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\nleft join m_loan l on l.client_id = c.id\r\nleft join `m_loan_xAdditional Information` l1 on l1.id = l.id\r\nleft join m_product_loan p on p.id = l.product_id\r\nleft join r_enum_value st on st.enum_name = \'loan_status_id\' and st.enum_id = l.loan_status_id\r\nleft join m_currency cur on cur.code = l.currency_code\r\nwhere o.id = ${officeId}\r\norder by ounder.hierarchy, \"Name\" , l.id',NULL,0,1),(44,'Client Listing (Pentaho)','Pentaho',NULL,'Client',NULL,'Just a sample Pentaho report. \r\nNot production quality',0,1),(45,'Funds Disbursed Summary - Currency','Table',NULL,'Fund','select ifnull(f.`name`, \'-\') as Fund, ifnull(cur.display_symbol, l.currency_code) as Currency, round(sum(l.principal_amount), 4) as disbursed_amount\r\nfrom m_office ounder \r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\njoin m_currency cur on cur.`code` = l.currency_code\r\nleft join m_fund f on f.id = l.fund_id\r\nwhere disbursedon_date between \'${startDate}\' and \'${endDate}\'\r\nand (ifnull(l.fund_id, -10) = ${fundId} or -1 = ${fundId})\r\nand (l.currency_code = \'${currencyId}\' or \'-1\' = \'${currencyId}\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\ngroup by ifnull(f.`name`, \'-\') , ifnull(cur.display_symbol, l.currency_code)\r\norder by ifnull(f.`name`, \'-\') , ifnull(cur.display_symbol, l.currency_code)',NULL,0,1),(46,'Funds Disbursed Summary - Office, Currency','Table',NULL,'Fund','select ounder.`name` as \"Office/Branch\", ifnull(f.`name`, \'-\') as Fund, ifnull(cur.display_symbol, l.currency_code) as Currency, round(sum(l.principal_amount), 4) as disbursed_amount\r\nfrom m_office o\r\njoin m_office ounder on ounder.hierarchy like concat(o.hierarchy, \'%\')\r\nand ounder.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\njoin m_client c on c.office_id = ounder.id\r\njoin m_loan l on l.client_id = c.id\r\njoin m_currency cur on cur.`code` = l.currency_code\r\nleft join m_fund f on f.id = l.fund_id\r\nwhere disbursedon_date between \'${startDate}\' and \'${endDate}\'\r\nand o.id = ${officeId}\r\nand (ifnull(l.fund_id, -10) = ${fundId} or -1 = ${fundId})\r\nand (l.currency_code = \'${currencyId}\' or \'-1\' = \'${currencyId}\')\r\ngroup by ounder.`name`, ifnull(f.`name`, \'-\') , ifnull(cur.display_symbol, l.currency_code)\r\norder by ounder.`name`, ifnull(f.`name`, \'-\') , ifnull(cur.display_symbol, l.currency_code)',NULL,0,1);
|
|
INSERT INTO `stretchy_report_parameter` VALUES (29,5,NULL),(30,5,NULL),(31,5,NULL),(32,5,NULL),(32,6,NULL),(34,5,NULL),(34,6,NULL),(35,5,NULL),(35,6,NULL),(38,5,NULL),(38,6,NULL),(39,5,NULL),(39,7,NULL),(40,5,NULL),(40,7,NULL),(41,5,NULL),(42,5,NULL),(43,5,NULL),(44,5,'officeId'),(45,6,NULL),(45,10,NULL),(45,80,NULL),(45,81,NULL),(46,5,NULL),(46,6,NULL),(46,10,NULL),(46,80,NULL),(46,81,NULL);
|
|
|
|
INSERT INTO `stretchydata_datasettype` VALUES (1,'m_client'),(2,'m_loan');
|
|
INSERT INTO `stretchydata_dataset` VALUES (1,'Additional Information',1),(9,'Highly Improbable Info',1),(8,'Additional Information',2);
|
|
INSERT INTO `stretchydata_dataset_fields` VALUES (2,'Business Location','String',50,'List',8,7),(3,'Business Location Other','String',50,NULL,8,NULL),(4,'Business','String',10,'List',8,1),(5,'Business Description','Text',NULL,NULL,8,NULL),(6,'Ethnic Group','String',50,'List',1,3),(7,'Ethnic Group Other','String',50,NULL,1,NULL),(8,'Household Location','String',50,'List',1,7),(9,'Household Location Other','String',50,NULL,1,NULL),(10,'Religion','String',50,'List',1,8),(11,'Religion Other','String',50,NULL,1,NULL),(12,'Knowledge of Person','String',50,'List',1,6),(13,'Gender','String',10,'List',1,5),(14,'Business Title','String',100,NULL,8,NULL),(15,'Whois','Text',NULL,NULL,1,NULL),(60,'Fathers Favourite Team','String',50,'List',9,4),(61,'Mothers Favourite Team','String',50,'List',9,4),(62,'Fathers DOB','Date',NULL,NULL,9,NULL),(63,'Mothers DOB','Date',NULL,NULL,9,NULL),(64,'Fathers Education','String',50,'List',9,2),(65,'Mothers Education','String',50,'List',9,2),(67,'Number of Children','Integer',NULL,NULL,9,NULL),(68,'Favourite Town','String',30,NULL,9,NULL),(69,'Closing Comments','Text',NULL,NULL,9,NULL),(70,'Annual Family Income','Decimal',NULL,NULL,9,NULL);
|
|
|
|
INSERT INTO `rpt_sequence` (`id`) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20),(21),(22),(23),(24),(25),(26),(27),(28),(29),(30),(31),(32),(33),(34),(35),(36),(37),(38),(39),(40),(41),(42),(43),(44),(45),(46),(47),(48),(49),(50),(51),(52),(53),(54),(55),(56),(57),(58),(59),(60),(61),(62),(63),(64),(65),(66),(67),(68),(69),(70),(71),(72),(73),(74),(75),(76),(77),(78),(79),(80),(81),(82),(83),(84),(85),(86),(87),(88),(89),(90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100),(101),(102),(103),(104),(105),(106),(107),(108),(109),(110),(111),(112),(113),(114),(115),(116),(117),(118),(119),(120),(121),(122),(123),(124),(125),(126),(127),(128),(129),(130),(131),(132),(133),(134),(135),(136),(137),(138),(139),(140),(141),(142),(143),(144),(145),(146),(147),(148),(149),(150),(151),(152),(153),(154),(155),(156),(157),(158),(159),(160),(161),(162),(163),(164),(165),(166),(167),(168),(169),(170),(171),(172),(173),(174),(175),(176),(177),(178),(179),(180),(181),(182),(183),(184),(185),(186),(187),(188),(189),(190),(191),(192),(193),(194),(195),(196),(197),(198),(199),(200),(201),(202),(203),(204),(205),(206),(207),(208),(209),(210),(211),(212),(213),(214),(215),(216),(217),(218),(219),(220),(221),(222),(223),(224),(225),(226),(227),(228),(229),(230),(231),(232),(233),(234),(235),(236),(237),(238),(239),(240),(241),(242),(243),(244),(245),(246),(247),(248),(249),(250),(251),(252),(253),(254),(255),(256),(257),(258),(259),(260),(261),(262),(263),(264),(265),(266),(267),(268),(269),(270),(271),(272),(273),(274),(275),(276),(277),(278),(279),(280),(281),(282),(283),(284),(285),(286),(287),(288),(289),(290),(291),(292),(293),(294),(295),(296),(297),(298),(299),(300),(301),(302),(303),(304),(305),(306),(307),(308),(309),(310),(311),(312),(313),(314),(315),(316),(317),(318),(319),(320),(321),(322),(323),(324),(325),(326),(327),(328),(329),(330),(331),(332),(333),(334),(335),(336),(337),(338),(339),(340),(341),(342),(343),(344),(345),(346),(347),(348),(349),(350),(351),(352),(353),(354),(355),(356),(357),(358),(359),(360),(361),(362),(363),(364),(365),(366),(367),(368),(369),(370),(371),(372),(373),(374),(375),(376),(377),(378),(379),(380),(381),(382),(383),(384),(385),(386),(387),(388),(389),(390),(391),(392),(393),(394),(395),(396),(397),(398),(399),(400),(401),(402),(403),(404),(405),(406),(407),(408),(409),(410),(411),(412),(413),(414),(415),(416),(417),(418),(419),(420),(421),(422),(423),(424),(425),(426),(427),(428),(429),(430),(431),(432),(433),(434),(435),(436),(437),(438),(439),(440),(441),(442),(443),(444),(445),(446),(447),(448),(449),(450),(451),(452),(453),(454),(455),(456),(457),(458),(459),(460),(461),(462),(463),(464),(465),(466),(467),(468),(469),(470),(471),(472),(473),(474),(475),(476),(477),(478),(479),(480),(481),(482);
|
|
|
|
|
|
insert into m_permission (group_enum, code, default_description, default_name)
|
|
select 3, concat("CAN_RUN_", report_name), concat("CAN_RUN_", report_name), concat("CAN_RUN_", report_name)
|
|
from stretchy_report r
|
|
where not exists
|
|
(select 'f' from m_permission x
|
|
where x.code = concat("CAN_RUN_", r.report_name));
|
|
|
|
insert into m_permission (group_enum, code, default_description, default_name)
|
|
select 3, concat("CAN_READ_", t.`name`, "_x", d.`name`), concat("CAN_READ_", t.`name`, "_x", d.`name`), concat("CAN_READ_", t.`name`, "_x", d.`name`)
|
|
from stretchydata_dataset d
|
|
join stretchydata_datasettype t on t.id = d.datasettype_id
|
|
where not exists
|
|
(select 'f' from m_permission x
|
|
where x.code = concat("CAN_READ_", t.`name`, "_x", d.`name`));
|
|
|
|
insert into m_permission (group_enum, code, default_description, default_name)
|
|
select 3, concat("CAN_UPDATE_", t.`name`, "_x", d.`name`), concat("CAN_UPDATE_", t.`name`, "_x", d.`name`), concat("CAN_UPDATE_", t.`name`, "_x", d.`name`)
|
|
from stretchydata_dataset d
|
|
join stretchydata_datasettype t on t.id = d.datasettype_id
|
|
where not exists
|
|
(select 'f' from m_permission x
|
|
where x.code = concat("CAN_UPDATE_", t.`name`, "_x", d.`name`));
|
|
|
|
|
|
|
|
|
|
|
|
-- insert office data required by appuser table/data
|
|
INSERT INTO `m_office` (`id`, `parent_id`, `hierarchy`, `external_id`, `name`, `opening_date`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
|
VALUES
|
|
(2,1,'.2.','2','sub branch 1','2012-01-02',1,'2012-04-14 05:42:40','2012-04-16 11:47:05',1),
|
|
(3,1,'.3.','3','sub branch 2','2012-03-01',1,'2012-04-16 04:12:02','2012-04-16 11:47:14',1),
|
|
(4,1,'.4.',NULL,'sub branch 3','2012-04-17',1,'2012-04-17 06:01:10','2012-04-17 06:01:10',1);
|
|
|
|
|
|
-- insert remaining fund/currencies/product data
|
|
|
|
INSERT INTO `m_organisation_currency` (`id`, `code`, `decimal_places`, `name`, `display_symbol`, `internationalized_name_code`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
|
VALUES
|
|
(17,'KES',2,'Kenyan Shilling','KSh','currency.KES',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
|
(18,'BND',2,'Brunei Dollar','BND','currency.BND',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
|
(19,'LBP',2,'Lebanese Pound','L','currency.LBP',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
|
(20,'GHC',2,'Ghana Cedi','GHC','currency.GHC',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
|
(22,'XOF',0,'CFA Franc BCEAO','CFA','currency.XOF',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1);
|
|
|
|
|
|
INSERT INTO `m_product_loan` (`id`, `currency_code`, `currency_digits`, `principal_amount`, `arrearstolerance_amount`, `name`, `description`, `nominal_interest_rate_per_period`, `interest_period_frequency_enum`, `annual_nominal_interest_rate`, `interest_method_enum`, `repay_every`, `repayment_period_frequency_enum`, `number_of_repayments`, `amortization_method_enum`, `flexible_repayment_schedule`, `interest_rebate`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`, `interest_calculated_in_period_enum`, `fund_id`)
|
|
VALUES
|
|
(1,'XOF',0,'100000.000000','1000.000000','Agricultural Loan','An agricultural loan given to farmers to help buy crop, stock and machinery. With an arrears tolerance setting of 1,000 CFA, loans are not marked as \'in arrears\' or \'in bad standing\' if the amount outstanding is less than this. Interest rate is described using monthly percentage rate (MPR) even though the loan typically lasts a year and requires one repayment (typically at time when farmer sells crop)','1.750000',2,'21.000000',0,12,2,1,1,'\0','\0',1,'2012-04-12 22:14:34','2012-04-12 22:14:34',1,1,NULL);
|
|
|
|
|
|
|
|
-- inserting client
|
|
|
|
INSERT INTO `m_client` (`id`, `office_id`, `external_id`, `firstname`, `lastname`, `joining_date`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
|
VALUES
|
|
(1,1,NULL,'Willie','O\'Meara','2009-01-04',1,'2012-04-12 22:07:44','2012-04-12 22:07:44',1),
|
|
(2,1,NULL,'Declan','Browne','2009-01-04',1,'2012-04-12 22:15:39','2012-04-12 22:15:39',1),
|
|
(3,1,NULL,'Ja','Fallon','2009-01-11',1,'2012-04-12 22:16:30','2012-04-12 22:16:30',1),
|
|
(4,1,NULL,'Peter','Lambert','2009-01-11',1,'2012-04-12 22:17:01','2012-04-12 22:17:01',1),
|
|
(5,1,NULL,NULL,'Sunnyville vegetable growers Ltd','2009-01-24',1,'2012-04-12 22:19:18','2012-04-12 22:19:18',1),
|
|
(6,2,NULL,'Jacques','Lee','2012-04-03',1,'2012-04-14 06:09:22','2012-04-14 06:09:22',1),
|
|
(7,1,NULL,'Kalilou','Traor','2009-02-04',1,'2012-04-14 09:38:11','2012-04-14 09:38:11',1),
|
|
(8,1,NULL,'Sidi','Kon','2009-02-11',1,'2012-04-14 09:45:43','2012-04-14 09:45:43',1),
|
|
(9,1,NULL,'Moustapha','Yattabar','2009-02-18',1,'2012-04-14 10:24:20','2012-04-14 10:24:20',1),
|
|
(10,1,NULL,NULL,'Mali fruit sales ltd.','2009-02-18',1,'2012-04-14 10:25:37','2012-04-14 10:25:37',1),
|
|
(11,1,NULL,NULL,'Djenne co-op group','2009-02-25',1,'2012-04-14 10:31:03','2012-04-14 10:31:03',1);
|
|
|
|
|
|
|
|
update m_client set display_name = concat_ws(' ',firstname,lastname);
|
|
|