Rename root folders

This commit is contained in:
Adi Narayana Raju
2016-02-01 11:00:15 +05:30
parent c5b56dae8f
commit 139e066d3d
2652 changed files with 0 additions and 0 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,21 @@
Bare Bones Demo
======
This demo database contains:
- DDL of latest schema
- Minimum reference data required for deployment of platform which is:
- Its mandatory to have one selected currency so we default to US Dollar
- Its mandatory to have one root or head office, so we have one created by default called a 'Head Office'
- Permissions supported/needed by latest release of software are setup
- Its mandatory to have at least one role when creating new users so we have one role created by default called 'Super user' which has the special permission 'Full Authorisation'. Any user with this role can do anything in the system.
- Its required to have at least one application user setup so remaining setup can be done through ui so we have on application user created by default with username 'mifos' with a password of 'password'. Application users must be associated with an office and a role so this user is associated with 'Head office' and 'Super user' role allowing this user to do any operation in any office(branch).
- Configuration
- No 'additional data' through the 'datatables' approach is setup
- One 'code' is setup called 'Client Identifier' with default values of {'Passport number'} - (required for Client Identity Document functionalty)
- Enable/Disable configuration has one entry named 'maker-checker' to allow people to enable disable this feature at global level. It is off or disabled by default.
- No products (loans, deposit, savings) are setup
- No Charges (fees or penalties) are setup
- No Staff (employees) are setup (loan officers are optional when submiting new loan application)
- No Portfolio data (no clients, groups, loan accounts, deposit accounts, savings accounts)
- No Accounting data (no chart of accounts is setup, by default accounting with respect to portfolio items is off unless enabled when creating a loan product.)
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
CEDA Microfinance (Kampala, Uganda)
======
This demo database contains:
- DDL of latest schema
- Minimum reference data required for deployment of platform
- Customisatons for CEDA on m_code/m_code_value tables, extra datatables for client and loan data capture
- Extra reports over and beyond core reports customisation for CEDA operations
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,344 @@
DELETE FROM `ref_loan_transaction_processing_strategy` WHERE id in (1, 3, 4);
INSERT INTO `m_code` (`code_name`, `is_system_defined`)
VALUES
('FieldOfEmployment', '0'),
('EducationLevel', '0'),
('MaritalStatus', '0'),
('PovertyStatus', '0');
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Banker', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "FieldOfEmployment";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.SoftwareDeveloper', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "FieldOfEmployment";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.University', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "EducationLevel";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Secondary', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "EducationLevel";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Primary', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "EducationLevel";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Married', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "MaritalStatus";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Single', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "MaritalStatus";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Divorced', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "MaritalStatus";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Widow', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "MaritalStatus";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.PovertyStatus.Band1', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "PovertyStatus";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.PovertyStatus.Band2', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "PovertyStatus";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.PovertyStatus.Band3', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "PovertyStatus";
-- ======= ADD in loan purspose and collateral values to enable this functionality
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.House', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "LoanCollateral";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Television', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "LoanCollateral";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Gold', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "LoanCollateral";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Agriculture', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "LoanPurpose";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Manufacturing', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "LoanPurpose";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.HousingImprovement', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "LoanPurpose";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Male', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "Gender";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Female', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "Gender";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Yes', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "YesNo";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.No', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "YesNo";
DROP TABLE IF EXISTS `client additional data`;
CREATE TABLE `client additional data` (
`client_id` bigint(20) NOT NULL,
`Gender_cd` int(11) NOT NULL,
`Date of Birth` date NOT NULL,
`Home address` text NOT NULL,
`Telephone number` varchar(20) NOT NULL,
`Telephone number (2nd)` varchar(20) NOT NULL,
`Email address` varchar(50) NOT NULL,
`EducationLevel_cd` int(11) NOT NULL,
`MaritalStatus_cd` int(11) NOT NULL,
`Number of children` int(11) NOT NULL,
`Citizenship` varchar(50) NOT NULL,
`PovertyStatus_cd` int(11) NOT NULL,
`YesNo_cd_Employed` int(11) NOT NULL,
`FieldOfEmployment_cd_Field of employment` int(11) DEFAULT NULL,
`Employer name` varchar(50) DEFAULT NULL,
`Number of years` int(11) DEFAULT NULL,
`Monthly salary` decimal(19,6) DEFAULT NULL,
`YesNo_cd_Self employed` int(11) NOT NULL,
`FieldOfEmployment_cd_Field of self-employment` int(11) DEFAULT NULL,
`Business address` text,
`Number of employees` int(11) DEFAULT NULL,
`Monthly salaries paid` decimal(19,6) DEFAULT NULL,
`Monthly net income of business activity` decimal(19,6) DEFAULT NULL,
`Monthly rent` decimal(19,6) DEFAULT NULL,
`Other income generating activities` varchar(100) DEFAULT NULL,
`YesNo_cd_Bookkeeping` int(11) DEFAULT NULL,
`YesNo_cd_Loans with other institutions` int(11) NOT NULL,
`From whom` varchar(100) DEFAULT NULL,
`Amount` decimal(19,6) DEFAULT NULL,
`Interest rate pa` decimal(19,6) DEFAULT NULL,
`Number of people depending on overal income` int(11) NOT NULL,
`YesNo_cd_Bank account` int(11) NOT NULL,
`YesNo_cd_Business plan provided` int(11) NOT NULL,
`YesNo_cd_Access to internet` int(11) DEFAULT NULL,
`Introduced by` varchar(100) DEFAULT NULL,
`Known to introducer since` varchar(100) NOT NULL,
`Last visited by` varchar(100) DEFAULT NULL,
`Last visited on` date NOT NULL,
PRIMARY KEY (`client_id`),
CONSTRAINT `FK_client_additional_data` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `impact measurement`;
CREATE TABLE `impact measurement` (
`loan_id` bigint(20) NOT NULL,
`YesNo_cd_RepaidOnSchedule` int(11) NOT NULL,
`ReasonNotRepaidOnSchedule` text DEFAULT NULL,
`How was Loan Amount Invested` text NOT NULL,
`Additional Income Generated` decimal(19,6) NOT NULL,
`Additional Income Used For` text NOT NULL,
`YesNo_cd_NewJobsCreated` int(11) NOT NULL,
`Number of Jobs Created` bigint(20) DEFAULT NULL,
PRIMARY KEY (`loan_id`),
CONSTRAINT `FK_impact measurement` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `loan additional data`;
CREATE TABLE `loan additional data` (
`loan_id` bigint(20) NOT NULL,
`PurposeOfLoan_cd` int(11) NOT NULL,
`CollateralType_cd` int(11) NOT NULL,
`Collateral notes` text NOT NULL,
`YesNo_cd_Guarantor` int(11) NOT NULL,
`Guarantor name` varchar(100) DEFAULT NULL,
`Guarantor relation` varchar(100) DEFAULT NULL,
`Guarantor address` varchar(100) DEFAULT NULL,
`Guarantor telephone number` varchar(20) DEFAULT NULL,
PRIMARY KEY (`loan_id`),
CONSTRAINT `FK_loan_additional_data` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- datatables mapping
INSERT INTO `x_registered_table`
(`registered_table_name`,
`application_table_name`)
VALUES
('client additional data', 'm_client'),
('impact measurement', 'm_loan'),
('loan additional data', 'm_loan');
-- make sure permissions created for registered datatables
/* add a create, read, update and delete permission for each registered datatable */
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('CREATE_', r.registered_table_name), r.registered_table_name, 'CREATE'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('READ_', r.registered_table_name), r.registered_table_name, 'READ'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('UPDATE_', r.registered_table_name), r.registered_table_name, 'UPDATE'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('DELETE_', r.registered_table_name), r.registered_table_name, 'DELETE'
from x_registered_table r;
-- ==== Chart of Accounts =====
truncate `acc_gl_account`;
INSERT INTO `acc_gl_account` VALUES
(1,'Petty Cash Balances',NULL,'11100',0,1,2,1,NULL),
(2,'Cash in Valut 1',NULL,'11101',0,1,1,1,NULL),
(3,'Bank Balances',NULL,'11200',0,1,2,1,NULL),
(4,'Centenary Opening Account',NULL,'11201',0,1,1,1,NULL),
(5,'Centenary Expense Account',NULL,'11202',0,1,1,1,NULL),
(6,'Centenary USD Account',NULL,'11203',0,1,1,1,NULL),
(7,'Loans and Advances',NULL,'13100',0,1,2,1,NULL),
(8,'Loans to Clients',NULL,'13101',0,1,1,1,NULL),
(9,'Outstanding Interest',NULL,'13102',0,1,1,1,NULL),
(10,'Outstanding Late Payment Interest',NULL,'13103',0,1,1,1,NULL),
(11,'Outstanding Bank Fees to be collected',NULL,'13104',0,1,1,1,NULL),
(12,'WriteOff Accounts',NULL,'13200',0,1,2,1,NULL),
(13,'Write-offs (use for funds coming in)',NULL,'13201',0,1,1,1,NULL),
(14,'Write-offs outstanding principal',NULL,'13202',0,1,1,1,NULL),
(15,'Write-offs outstanding interest',NULL,'13203',0,1,1,1,NULL),
(16,'Write-offs collected bank fees',NULL,'13204',0,1,1,1,NULL),
(17,'Write-offs hardware/furniture',NULL,'13205',0,1,1,1,NULL),
(18,'Fixed Assets',NULL,'14100',0,1,2,1,NULL),
(19,'Office Equipment',NULL,'14101',0,1,1,1,NULL),
(20,'Suspense Items (unidentified deposits)',NULL,'15000',0,1,2,1,NULL),
(21,'Assets',NULL,'10000',0,1,2,1,NULL),
(22,'Liabilities',NULL,'20000',0,1,2,2,NULL),
(23,'Shares Account',NULL,'26100',0,1,2,2,NULL),
(24,'Shares Captial',NULL,'26101',0,1,1,2,NULL),
(25,'Donated Equity',NULL,'26300',0,1,2,2,NULL),
(26,'Donated Equity Ameropa Foundation',NULL,'26301',0,1,1,2,NULL),
(27,'Donated Equity e.h',NULL,'26302',0,1,1,2,NULL),
(28,'Overpaid Amounts',NULL,'27000',0,1,2,2,NULL),
(29,'Loss Provision',NULL,'28000',0,1,2,2,NULL),
(30,'Provision Outstanding Principal',NULL,'28001',0,1,1,2,NULL),
(31,'Provision Oustanding Interest',NULL,'28002',0,1,1,2,NULL),(32,'Income',NULL,'30000',0,1,2,4,NULL),
(33,'Interest Income from Loans',NULL,'31100',0,1,2,4,NULL),
(34,'Interest on Loans',NULL,'31101',0,1,1,4,NULL),
(35,'Late Payment Interest',NULL,'31102',0,1,1,4,NULL),
(36,'Income from Micro credit & Lending Activities',NULL,'31300',0,1,2,4,NULL),
(37,'Collected Bank Fees Receivable',NULL,'6201',0,1,1,4,NULL),
(38,'Deposits from Loans Write Off',NULL,'31400',0,1,2,4,NULL),
(39,'Expenditure',NULL,'40000',0,1,2,5,NULL),
(40,'Office Expenditure Account',NULL,'42100',0,1,2,5,NULL),
(41,'Water Charges',NULL,'42102',0,1,1,5,NULL),
(42,'Electricity Charges',NULL,'42103',0,1,1,5,NULL),
(43,'Printing and Stationary',NULL,'42105',0,1,1,5,NULL),
(44,'Office Rent',NULL,'42107',0,1,1,5,NULL),
(45,'Marketing Expense',NULL,'42109',0,1,1,5,NULL),
(46,'Office utilities',NULL,'42112',0,1,1,5,'(supplies, toiletries, kitchen)'),
(47,'Furniture',NULL,'42113',0,1,1,5,NULL),
(48,'CEDA Meeting Expense',NULL,'42114',0,1,1,5,NULL),
(49,'Employee Personal Expsense Account',NULL,'42200',0,1,2,5,NULL),
(50,'Salary Alice',NULL,'42201',0,1,1,5,NULL),
(51,'Salary Irene',NULL,'42202',0,1,1,5,NULL),
(52,'Salary Richard',NULL,'42203',0,1,1,5,NULL),
(53,'Salary Loan Officer TBA',NULL,'42204',0,1,1,5,NULL),
(54,'Medical Insurance Alice & Family',NULL,'42205',0,1,1,5,NULL),
(55,'Medical Insurance Irene',NULL,'42206',0,1,1,5,NULL),
(56,'Medical Insurance Richard',NULL,'42207',0,1,1,5,NULL),
(57,'Medical Insurance Loan Officer TBA',NULL,'42208',0,1,1,5,NULL),
(58,'PAYE all employees',NULL,'42209',0,1,1,5,NULL),
(59,'NSSF all employees',NULL,'42210',0,1,1,5,NULL),
(60,'Lunch Allowances all employees',NULL,'42211',0,1,1,5,NULL),
(61,'IT software and maintenance',NULL,'42300',0,1,2,5,NULL),
(62,'Mifos maintenance contract 12 months',NULL,'42301',0,1,1,5,NULL),
(63,'VPS Contract 12 months',NULL,'42302',0,1,1,5,NULL),
(64,'Bulk SMS Service',NULL,'42303',0,1,1,5,NULL),
(65,'Support Accounting Software',NULL,'42304',0,1,1,5,NULL),
(66,'Mifos Instance Setup',NULL,'42305',0,1,1,5,NULL),
(67,'Misc support expense',NULL,'42306',0,1,1,5,NULL),
(68,'Warid Mobile Line',NULL,'42307',0,1,1,5,NULL),
(69,'Landline',NULL,'42308',0,1,1,5,NULL),
(70,'Modem Alice',NULL,'42309',0,1,1,5,NULL),
(71,'Modem Irene',NULL,'42310',0,1,1,5,NULL),
(72,'Modem Richard',NULL,'42311',0,1,1,5,NULL),
(73,'Repairs',NULL,'42312',0,1,1,5,NULL),
(74,'Airtime Expenses',NULL,'42400',0,1,2,5,NULL),
(75,'Airtime Alice',NULL,'42401',0,1,1,5,NULL),
(76,'Airtime Richard',NULL,'42402',0,1,1,5,NULL),
(77,'Airtime Loan Office TBA',NULL,'42403',0,1,1,5,NULL),
(78,'Special Airtime Alice',NULL,'42404',0,1,1,5,NULL),
(79,'Transportation',NULL,'42500',0,1,2,5,NULL),
(80,'Flat monthly transportation cost',NULL,'42501',0,1,1,5,NULL),
(81,'Faciliation cost for Richard',NULL,'42502',0,1,1,5,NULL),
(82,'Faciliation cost for Loan Officer TBA',NULL,'42503',0,1,1,5,NULL),
(83,'Consultancy Expenses',NULL,'42600',0,1,2,5,NULL),
(84,'Audit Fees',NULL,'42601',0,1,1,5,NULL),
(85,'Legal Fees',NULL,'42602',0,1,1,5,NULL),
(86,'Miscellaneous Expenses Account',NULL,'42700',0,1,2,5,NULL),
(87,'MFI License',NULL,'42703',0,1,1,5,NULL),
(88,'Sundy Expenses',NULL,'42704',0,1,1,5,NULL),
(89,'Bank Fees',NULL,'42800',0,1,2,5,NULL),
(90,'Bank Charges Operating Account',NULL,'42801',0,1,1,5,NULL),
(91,'Bank Charges Expense Account',NULL,'42802',0,1,1,5,NULL),
(92,'E.H Account',NULL,'42900',0,1,2,5,NULL),
(93,'Airtime',NULL,'42901',0,1,1,5,NULL),
(94,'Modem',NULL,'42902',0,1,1,5,NULL),
(95,'Meals',NULL,'42903',0,1,1,5,NULL),
(96,'Transportation',NULL,'42904',0,1,1,5,NULL),
(97,'Miscellaneous',NULL,'42905',0,1,1,5,NULL);
@@ -0,0 +1,104 @@
DELETE FROM `m_organisation_currency` WHERE id>0;
INSERT INTO `m_organisation_currency`
(
`code`,
`decimal_places`,
`name`,
`display_symbol`,
`internationalized_name_code`)
VALUES
('UGX', 2, 'Uganda Shilling', 'USh', 'currency.UGX');
UPDATE `m_appuser` SET `username` = 'admin' WHERE id=1;
INSERT INTO `m_appuser`
(`is_deleted`,
`office_id`,
`username`,
`firstname`,
`lastname`,
`password`,
`email`,
`firsttime_login_remaining`,
`nonexpired`,
`nonlocked`,
`nonexpired_credentials`,
`enabled`)
VALUES
(0, 1, 'keithwoodlock', 'Keith', 'Woodlock',
'4f607e9b6cffbe7d3db92d4bfa3391c7aa751727b4ea29d08fddf9dd72e6e7e3', 'keithwoodlock@gmail.com', 0, 1, 1, 1, 1);
INSERT INTO `m_appuser_role`
(`appuser_id`,`role_id`) VALUES (2,1);
UPDATE `m_office` SET `name` = 'CEDA Microfinance Ltd.' WHERE id=1;
INSERT INTO `m_office`
(
`parent_id`,
`hierarchy`,
`external_id`,
`name`,
`opening_date`)
VALUES
(1, '.2.', 2, 'Uganda (Kampala)', '2009-01-01');
INSERT INTO `m_staff`
(
`is_loan_officer`,
`office_id`,
`firstname`,
`lastname`,
`display_name`)
VALUES
(1, 1, 'CEDA HO', 'LoanOfficer', 'LoanOfficer, CEDA HO'),
(1, 2, 'Kampala', 'LoanOfficer', 'LoanOfficer, Kampala');
INSERT INTO `m_charge`
(
`name`,
`currency_code`,
`charge_applies_to_enum`,
`charge_time_enum`,
`charge_calculation_enum`,
`amount`,
`is_penalty`,
`is_active`,
`is_deleted`)
VALUES ('Bank Fee (per installment)', 'UGX', 1, 2, 1, 1500.000000, 0, 1, 0);
INSERT INTO `m_product_loan`
(
`currency_code`,
`currency_digits`,
`principal_amount`,
`min_principal_amount`,
`max_principal_amount`,
`arrearstolerance_amount`,
`name`,
`description`,
`fund_id`,
`nominal_interest_rate_per_period`,
`interest_period_frequency_enum`,
`annual_nominal_interest_rate`,
`interest_method_enum`,
`interest_calculated_in_period_enum`,
`repay_every`,
`repayment_period_frequency_enum`,
`number_of_repayments`,
`amortization_method_enum`,
`accounting_type`,
`loan_transaction_strategy_id`)
VALUES
('UGX', 2, 1000000.000000, 0, 1000000000000.000000, null , 'Kampala Product (with cash accounting)',
'Typical Kampala loan product with cash accounting enabled for testing.', null ,
24.000000, 3, 24.000000, 1, 1, 1, 2, 12, 1, 2, 2);
-- mapping of that loan product to GL Accounts
INSERT INTO `acc_product_mapping`
VALUES (1,4,1,1,1),(2,8,1,1,2),(3,34,1,1,3),(4,37,1,1,4),(5,35,1,1,5),(6,97,1,1,6);
@@ -0,0 +1,15 @@
default Demo
======
This demo database contains:
- DDL of latest schema
- Minimum reference data required for deployment of platform which is:
- Its mandatory to have one selected currency so we default to several of latin-america currencies
- Its mandatory to have one root or head office, so we have one created by default called a 'Latam HO'
- Permissions supported/needed by latest release of software are setup
- Its mandatory to have at least one role when creating new users so we have one role created by default called 'Super user' which has the special permission 'Full Authorisation'. Any user with this role can do anything in the system.
- Its required to have at least one application user setup so remaining setup can be done through ui so we have on application user created by default with username 'quipo' with a password of 'quipo'. Application users must be associated with an office and a role so this user is associated with 'Latam HO' and 'Super user' role allowing this user to do any operation in any office(branch).
Minimum amount of data to support api-docs interaction.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,221 @@
-- add code and code values for datatables dropdowns
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Male', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "Gender";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Female', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "Gender";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.Yes', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "YesNo";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'option.No', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "YesNo";
INSERT INTO `m_code`
(`code_name`, `is_system_defined`)
VALUES
('Education',1);
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'Primary', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "Education";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'Secondary', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "Education";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'University', ifnull(max(mv.id), 1)
from m_code mc
join m_code_value mv on mv.code_id = mc.id
where mc.`code_name` = "Education";
-- ========= datatables=======
DROP TABLE IF EXISTS `extra_client_details`;
CREATE TABLE `extra_client_details` (
`client_id` bigint(20) NOT NULL,
`Business Description` varchar(100) DEFAULT NULL,
`Years in Business` int(11) DEFAULT NULL,
`Gender_cd` int(11) DEFAULT NULL,
`Education_cv` varchar(60) DEFAULT NULL,
`Next Visit` date DEFAULT NULL,
`Highest Rate Paid` decimal(19,6) DEFAULT NULL,
`Comment` text,
PRIMARY KEY (`client_id`),
CONSTRAINT `FK_extra_client_details` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `extra_family_details`;
CREATE TABLE `extra_family_details` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`client_id` bigint(20) NOT NULL,
`Name` varchar(40) DEFAULT NULL,
`Date of Birth` date DEFAULT NULL,
`Points Score` int(11) DEFAULT NULL,
`Education_cd_Highest` int(11) DEFAULT NULL,
`Other Notes` text,
PRIMARY KEY (`id`),
KEY `FK_Extra Family Details Data_1` (`client_id`),
CONSTRAINT `FK_family_details` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `extra_loan_details`;
CREATE TABLE `extra_loan_details` (
`loan_id` bigint(20) NOT NULL,
`Business Description` varchar(100) DEFAULT NULL,
`Years in Business` int(11) DEFAULT NULL,
`Gender_cd` int(11) DEFAULT NULL,
`Education_cv` varchar(60) DEFAULT NULL,
`Next Visit` date DEFAULT NULL,
`Highest Rate Paid` decimal(19,6) DEFAULT NULL,
`Comment` text,
PRIMARY KEY (`loan_id`),
CONSTRAINT `FK_extra_loan_details` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- datatables mapping
INSERT INTO `x_registered_table`
(`registered_table_name`,`application_table_name`)
VALUES
('extra_client_details', 'm_client'),
('extra_family_details', 'm_client'),
('extra_loan_details', 'm_loan');
-- make sure permissions created for registered datatables
/* add a create, read, update and delete permission for each registered datatable */
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('CREATE_', r.registered_table_name), r.registered_table_name, 'CREATE'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('READ_', r.registered_table_name), r.registered_table_name, 'READ'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('UPDATE_', r.registered_table_name), r.registered_table_name, 'UPDATE'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('DELETE_', r.registered_table_name), r.registered_table_name, 'DELETE'
from x_registered_table r;
-- ==== Chart of Accounts =====
truncate `acc_gl_account`;
INSERT INTO `acc_gl_account` VALUES
(1,'Petty Cash Balances',NULL,'11100',0,1,2,1,NULL),
(2,'Cash in Valut 1',NULL,'11101',0,1,1,1,NULL),
(3,'Bank Balances',NULL,'11200',0,1,2,1,NULL),
(4,'Centenary Opening Account',NULL,'11201',0,1,1,1,NULL),
(5,'Centenary Expense Account',NULL,'11202',0,1,1,1,NULL),
(6,'Centenary USD Account',NULL,'11203',0,1,1,1,NULL),
(7,'Loans and Advances',NULL,'13100',0,1,2,1,NULL),
(8,'Loans to Clients',NULL,'13101',0,1,1,1,NULL),
(9,'Outstanding Interest',NULL,'13102',0,1,1,1,NULL),
(10,'Outstanding Late Payment Interest',NULL,'13103',0,1,1,1,NULL),
(11,'Outstanding Bank Fees to be collected',NULL,'13104',0,1,1,1,NULL),
(12,'WriteOff Accounts',NULL,'13200',0,1,2,1,NULL),
(13,'Write-offs (use for funds coming in)',NULL,'13201',0,1,1,1,NULL),
(14,'Write-offs outstanding principal',NULL,'13202',0,1,1,1,NULL),
(15,'Write-offs outstanding interest',NULL,'13203',0,1,1,1,NULL),
(16,'Write-offs collected bank fees',NULL,'13204',0,1,1,1,NULL),
(17,'Write-offs hardware/furniture',NULL,'13205',0,1,1,1,NULL),
(18,'Fixed Assets',NULL,'14100',0,1,2,1,NULL),
(19,'Office Equipment',NULL,'14101',0,1,1,1,NULL),
(20,'Suspense Items (unidentified deposits)',NULL,'15000',0,1,2,1,NULL),
(21,'Assets',NULL,'10000',0,1,2,1,NULL),
(22,'Liabilities',NULL,'20000',0,1,2,2,NULL),
(23,'Shares Account',NULL,'26100',0,1,2,2,NULL),
(24,'Shares Captial',NULL,'26101',0,1,1,2,NULL),
(25,'Donated Equity',NULL,'26300',0,1,2,2,NULL),
(26,'Donated Equity Ameropa Foundation',NULL,'26301',0,1,1,2,NULL),
(27,'Donated Equity e.h',NULL,'26302',0,1,1,2,NULL),
(28,'Overpaid Amounts',NULL,'27000',0,1,2,2,NULL),
(29,'Loss Provision',NULL,'28000',0,1,2,2,NULL),
(30,'Provision Outstanding Principal',NULL,'28001',0,1,1,2,NULL),
(31,'Provision Oustanding Interest',NULL,'28002',0,1,1,2,NULL),(32,'Income',NULL,'30000',0,1,2,4,NULL),
(33,'Interest Income from Loans',NULL,'31100',0,1,2,4,NULL),
(34,'Interest on Loans',NULL,'31101',0,1,1,4,NULL),
(35,'Late Payment Interest',NULL,'31102',0,1,1,4,NULL),
(36,'Income from Micro credit & Lending Activities',NULL,'31300',0,1,2,4,NULL),
(37,'Collected Bank Fees Receivable',NULL,'6201',0,1,1,4,NULL),
(38,'Deposits from Loans Write Off',NULL,'31400',0,1,2,4,NULL),
(39,'Expenditure',NULL,'40000',0,1,2,5,NULL),
(40,'Office Expenditure Account',NULL,'42100',0,1,2,5,NULL),
(41,'Water Charges',NULL,'42102',0,1,1,5,NULL),
(42,'Electricity Charges',NULL,'42103',0,1,1,5,NULL),
(43,'Printing and Stationary',NULL,'42105',0,1,1,5,NULL),
(44,'Office Rent',NULL,'42107',0,1,1,5,NULL),
(45,'Marketing Expense',NULL,'42109',0,1,1,5,NULL),
(46,'Office utilities',NULL,'42112',0,1,1,5,'(supplies, toiletries, kitchen)'),
(47,'Furniture',NULL,'42113',0,1,1,5,NULL),
(48,'CEDA Meeting Expense',NULL,'42114',0,1,1,5,NULL),
(49,'Employee Personal Expsense Account',NULL,'42200',0,1,2,5,NULL),
(50,'Salary Alice',NULL,'42201',0,1,1,5,NULL),
(51,'Salary Irene',NULL,'42202',0,1,1,5,NULL),
(52,'Salary Richard',NULL,'42203',0,1,1,5,NULL),
(53,'Salary Loan Officer TBA',NULL,'42204',0,1,1,5,NULL),
(54,'Medical Insurance Alice & Family',NULL,'42205',0,1,1,5,NULL),
(55,'Medical Insurance Irene',NULL,'42206',0,1,1,5,NULL),
(56,'Medical Insurance Richard',NULL,'42207',0,1,1,5,NULL),
(57,'Medical Insurance Loan Officer TBA',NULL,'42208',0,1,1,5,NULL),
(58,'PAYE all employees',NULL,'42209',0,1,1,5,NULL),
(59,'NSSF all employees',NULL,'42210',0,1,1,5,NULL),
(60,'Lunch Allowances all employees',NULL,'42211',0,1,1,5,NULL),
(61,'IT software and maintenance',NULL,'42300',0,1,2,5,NULL),
(62,'Mifos maintenance contract 12 months',NULL,'42301',0,1,1,5,NULL),
(63,'VPS Contract 12 months',NULL,'42302',0,1,1,5,NULL),
(64,'Bulk SMS Service',NULL,'42303',0,1,1,5,NULL),
(65,'Support Accounting Software',NULL,'42304',0,1,1,5,NULL),
(66,'Mifos Instance Setup',NULL,'42305',0,1,1,5,NULL),
(67,'Misc support expense',NULL,'42306',0,1,1,5,NULL),
(68,'Warid Mobile Line',NULL,'42307',0,1,1,5,NULL),
(69,'Landline',NULL,'42308',0,1,1,5,NULL),
(70,'Modem Alice',NULL,'42309',0,1,1,5,NULL),
(71,'Modem Irene',NULL,'42310',0,1,1,5,NULL),
(72,'Modem Richard',NULL,'42311',0,1,1,5,NULL),
(73,'Repairs',NULL,'42312',0,1,1,5,NULL),
(74,'Airtime Expenses',NULL,'42400',0,1,2,5,NULL),
(75,'Airtime Alice',NULL,'42401',0,1,1,5,NULL),
(76,'Airtime Richard',NULL,'42402',0,1,1,5,NULL),
(77,'Airtime Loan Office TBA',NULL,'42403',0,1,1,5,NULL),
(78,'Special Airtime Alice',NULL,'42404',0,1,1,5,NULL),
(79,'Transportation',NULL,'42500',0,1,2,5,NULL),
(80,'Flat monthly transportation cost',NULL,'42501',0,1,1,5,NULL),
(81,'Faciliation cost for Richard',NULL,'42502',0,1,1,5,NULL),
(82,'Faciliation cost for Loan Officer TBA',NULL,'42503',0,1,1,5,NULL),
(83,'Consultancy Expenses',NULL,'42600',0,1,2,5,NULL),
(84,'Audit Fees',NULL,'42601',0,1,1,5,NULL),
(85,'Legal Fees',NULL,'42602',0,1,1,5,NULL),
(86,'Miscellaneous Expenses Account',NULL,'42700',0,1,2,5,NULL),
(87,'MFI License',NULL,'42703',0,1,1,5,NULL),
(88,'Sundy Expenses',NULL,'42704',0,1,1,5,NULL),
(89,'Bank Fees',NULL,'42800',0,1,2,5,NULL),
(90,'Bank Charges Operating Account',NULL,'42801',0,1,1,5,NULL),
(91,'Bank Charges Expense Account',NULL,'42802',0,1,1,5,NULL),
(92,'E.H Account',NULL,'42900',0,1,2,5,NULL),
(93,'Airtime',NULL,'42901',0,1,1,5,NULL),
(94,'Modem',NULL,'42902',0,1,1,5,NULL),
(95,'Meals',NULL,'42903',0,1,1,5,NULL),
(96,'Transportation',NULL,'42904',0,1,1,5,NULL),
(97,'Miscellaneous',NULL,'42905',0,1,1,5,NULL);
@@ -0,0 +1,39 @@
DROP TABLE IF EXISTS `risk_analysis`;
CREATE TABLE `risk_analysis` (
`client_id` bigint(20) NOT NULL,
`proposed_loan_amount` decimal(19,6) DEFAULT NULL,
`assets_cash` decimal(19,6) DEFAULT NULL,
`assets_bank_accounts` decimal(19,6) DEFAULT NULL,
`assets_accounts_receivable` decimal(19,6) DEFAULT NULL,
`assets_inventory` decimal(19,6) DEFAULT NULL,
`assets_total_fixed_business` decimal(19,6) DEFAULT NULL,
`assets_total_business` decimal(19,6) DEFAULT NULL,
`assets_total_household` decimal(19,6) DEFAULT NULL,
`liabilities_accounts_payable` decimal(19,6) DEFAULT NULL,
`liabilities_business_debts` decimal(19,6) DEFAULT NULL,
`liabilities_total_business` decimal(19,6) DEFAULT NULL,
`liabilities_equity_working_capital` decimal(19,6) DEFAULT NULL,
`liabilities_total_household` decimal(19,6) DEFAULT NULL,
`liabilities_household_equity` decimal(19,6) DEFAULT NULL,
`cashflow_cash_sales` decimal(19,6) DEFAULT NULL,
`cashflow_cash_sales2` decimal(19,6) DEFAULT NULL,
`cashflow_cost_goods_sold` decimal(19,6) DEFAULT NULL,
`cashflow_cost_goods_sold2` decimal(19,6) DEFAULT NULL,
`cashflow_gross_profit` decimal(19,6) DEFAULT NULL,
`cashflow_other_income1` decimal(19,6) DEFAULT NULL,
`cashflow_total_income2` decimal(19,6) DEFAULT NULL,
`cashflow_household_expense` decimal(19,6) DEFAULT NULL,
`cashflow_payments_to_savings` decimal(19,6) DEFAULT NULL,
`cashflow_operational_expenses` decimal(19,6) DEFAULT NULL,
`cashflow_disposable_income` decimal(19,6) DEFAULT NULL,
`cashflow_amount_loan_installment` decimal(19,6) DEFAULT NULL,
`cashflow_available_surplus` decimal(19,6) DEFAULT NULL,
`fi_inventory_turnover` decimal(19,6) DEFAULT NULL,
`fi_gross_margin` decimal(19,6) DEFAULT NULL,
`fi_indebtedness` decimal(19,6) DEFAULT NULL,
`fi_loan_recommendation` decimal(19,6) DEFAULT NULL,
`fi_roe` decimal(19,6) DEFAULT NULL,
`fi_repayment_capacity` decimal(19,6) DEFAULT NULL,
PRIMARY KEY (`client_id`),
CONSTRAINT `FK_risk_analysis_1` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -0,0 +1,16 @@
latam Demo
======
This demo database contains:
- DDL of latest schema
- Minimum reference data required for deployment of platform which is:
- Its mandatory to have one selected currency so we default to several of latin-america currencies
- Its mandatory to have one root or head office, so we have one created by default called a 'Latam HO'
- Permissions supported/needed by latest release of software are setup
- Its mandatory to have at least one role when creating new users so we have one role created by default called 'Super user' which has the special permission 'Full Authorisation'. Any user with this role can do anything in the system.
- Its required to have at least one application user setup so remaining setup can be done through ui so we have on application user created by default with username 'quipo' with a password of 'quipo'. Application users must be associated with an office and a role so this user is associated with 'Latam HO' and 'Super user' role allowing this user to do any operation in any office(branch).
- Configuration
- No 'additional data' through the 'datatables' approach is setup
- One 'code' is setup called 'Client Identifier' with default values of {'Passport number'} - (required for Client Identity Document functionalty)
- Enable/Disable configuration has one entry named 'maker-checker' to allow people to enable disable this feature at global level. It is off or disabled by default.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,49 @@
DROP TABLE IF EXISTS `latam_extra_client_details`;
CREATE TABLE `latam_extra_client_details` (
`client_id` bigint(20) NOT NULL,
`Business Description` varchar(100) DEFAULT NULL,
`Years in Business` int(11) DEFAULT NULL,
`Gender_cd` int(11) DEFAULT NULL,
`Education_cv` varchar(60) DEFAULT NULL,
`Next Visit` date DEFAULT NULL,
`Highest Rate Paid` decimal(19,6) DEFAULT NULL,
`Comment` text,
PRIMARY KEY (`client_id`),
CONSTRAINT `FK_latam_extra_client_details` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `latam_family_details`;
CREATE TABLE `latam_family_details` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`client_id` bigint(20) NOT NULL,
`Name` varchar(40) DEFAULT NULL,
`Date of Birth` date DEFAULT NULL,
`Points Score` int(11) DEFAULT NULL,
`Education_cd_Highest` int(11) DEFAULT NULL,
`Other Notes` text,
PRIMARY KEY (`id`),
KEY `FK_Extra Family Details Data_1` (`client_id`),
CONSTRAINT `FK_latam_family_details` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `latam_extra_loan_details`;
CREATE TABLE `latam_extra_loan_details` (
`loan_id` bigint(20) NOT NULL,
`Business Description` varchar(100) DEFAULT NULL,
`Years in Business` int(11) DEFAULT NULL,
`Gender_cd` int(11) DEFAULT NULL,
`Education_cv` varchar(60) DEFAULT NULL,
`Next Visit` date DEFAULT NULL,
`Highest Rate Paid` decimal(19,6) DEFAULT NULL,
`Comment` text,
PRIMARY KEY (`loan_id`),
CONSTRAINT `FK_latam_extra_loan_details` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `mifostenant-latam`.`m_code` (`code_name`, `is_system_defined`) VALUES ('Gender', 1);
INSERT INTO `mifostenant-latam`.`m_code_value` (`code_id`, `code_value`, `order_position`) VALUES (2, 'Male', 1); INSERT INTO `mifostenant-latam`.`m_code_value` (`code_id`, `code_value`, `order_position`) VALUES (2, 'Female', 2);
INSERT INTO `mifostenant-latam`.`m_code` (`code_name`, `is_system_defined`) VALUES ('Education', 1);
INSERT INTO `mifostenant-latam`.`m_code_value` (`code_id`, `code_value`, `order_position`) VALUES (3, 'Primary', 1); INSERT INTO `mifostenant-latam`.`m_code_value` (`code_id`, `code_value`, `order_position`) VALUES (3, 'Secondary', 2); INSERT INTO `mifostenant-latam`.`m_code_value` (`code_id`, `code_value`, `order_position`) VALUES (3, 'University', 3);
@@ -0,0 +1,947 @@
-- drop tables in base-schema
SET foreign_key_checks = 0;
-- drop accounting subsystem
DROP TABLE IF EXISTS `acc_gl_account`;
DROP TABLE IF EXISTS `acc_gl_closure`;
DROP TABLE IF EXISTS `acc_gl_journal_entry`;
DROP TABLE IF EXISTS `acc_product_mapping`;
-- drop portfolio subsystem
DROP TABLE IF EXISTS `c_configuration`;
DROP TABLE IF EXISTS `m_appuser`;
DROP TABLE IF EXISTS `m_appuser_role`;
DROP TABLE IF EXISTS `m_calendar`;
DROP TABLE IF EXISTS `m_calendar_instance`;
DROP TABLE IF EXISTS `m_charge`;
DROP TABLE IF EXISTS `m_client`;
DROP TABLE IF EXISTS `m_client_identifier`;
DROP TABLE IF EXISTS `m_code`;
DROP TABLE IF EXISTS `m_code_value`;
DROP TABLE IF EXISTS `m_currency`;
DROP TABLE IF EXISTS `m_deposit_account`;
DROP TABLE IF EXISTS `m_deposit_account_transaction`;
DROP TABLE IF EXISTS `m_document`;
DROP TABLE IF EXISTS `m_fund`;
DROP TABLE IF EXISTS `m_group`;
DROP TABLE IF EXISTS `m_group_level`;
DROP TABLE IF EXISTS `m_group_client`;
DROP TABLE IF EXISTS `m_guarantor`;
DROP TABLE IF EXISTS `m_loan`;
DROP TABLE IF EXISTS `m_loan_charge`;
DROP TABLE IF EXISTS `m_loan_arrears_aging`;
DROP TABLE IF EXISTS `m_loan_collateral`;
DROP TABLE IF EXISTS `m_loan_officer_assignment_history`;
DROP TABLE IF EXISTS `m_loan_repayment_schedule`;
DROP TABLE IF EXISTS `m_loan_transaction`;
DROP TABLE IF EXISTS `m_note`;
DROP TABLE IF EXISTS `m_office`;
DROP TABLE IF EXISTS `m_office_transaction`;
DROP TABLE IF EXISTS `m_organisation_currency`;
DROP TABLE IF EXISTS `m_permission`;
DROP TABLE IF EXISTS `m_portfolio_command_source`;
DROP TABLE IF EXISTS `m_product_deposit`;
DROP TABLE IF EXISTS `m_product_loan`;
DROP TABLE IF EXISTS `m_product_loan_charge`;
DROP TABLE IF EXISTS `m_role`;
DROP TABLE IF EXISTS `m_role_permission`;
DROP TABLE IF EXISTS `m_savings_account`;
DROP TABLE IF EXISTS `m_savings_account_transaction`;
DROP TABLE IF EXISTS `m_savings_product`;
DROP TABLE IF EXISTS `m_staff`;
DROP TABLE IF EXISTS `ref_loan_transaction_processing_strategy`;
DROP TABLE IF EXISTS `x_registered_table`;
-- drop reporting related tables
DROP TABLE IF EXISTS `r_enum_value`;
DROP TABLE IF EXISTS `rpt_sequence`;
DROP TABLE IF EXISTS `stretchy_parameter`;
DROP TABLE IF EXISTS `stretchy_report`;
DROP TABLE IF EXISTS `stretchy_report_parameter`;
SET foreign_key_checks = 1;
-- DDL for reference/lookup tables
CREATE TABLE `m_currency` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`code` varchar(3) NOT NULL,
`decimal_places` smallint(5) NOT NULL,
`display_symbol` varchar(10) DEFAULT NULL,
`name` varchar(50) NOT NULL,
`internationalized_name_code` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_organisation_currency` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`code` varchar(3) NOT NULL,
`decimal_places` smallint(5) NOT NULL,
`name` varchar(50) NOT NULL,
`display_symbol` varchar(10) DEFAULT NULL,
`internationalized_name_code` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `ref_loan_transaction_processing_strategy` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`code` varchar(100) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ltp_strategy_code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `c_configuration` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`enabled` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_code` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code_name` varchar(100) DEFAULT NULL,
`is_system_defined` TINYINT(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `code_name` (`code_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_code_value` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code_id` int(11) NOT NULL,
`code_value` varchar(100) DEFAULT NULL,
`order_position` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `code_value` (`code_id`,`code_value`),
KEY `FKCFCEA42640BE071Z` (`code_id`),
CONSTRAINT `FKCFCEA42640BE071Z` FOREIGN KEY (`code_id`) REFERENCES `m_code` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_document` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`parent_entity_type` varchar(50) NOT NULL,
`parent_entity_id` int(20) NOT NULL DEFAULT '0',
`name` varchar(250) NOT NULL,
`file_name` varchar(250) NOT NULL,
`size` int(20) DEFAULT '0',
`type` varchar(50) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
`location` varchar(500) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*not a major table - just intended for database reporting use for enums and values that would be hidden in java*/
CREATE TABLE `r_enum_value` (
`enum_name` varchar(100) NOT NULL,
`enum_id` int(11) NOT NULL,
`enum_message_property` varchar(100) NOT NULL,
`enum_value` varchar(100) NOT NULL,
PRIMARY KEY (`enum_name`,`enum_id`),
UNIQUE KEY `enum_message_property` (`enum_name`,`enum_message_property`),
UNIQUE KEY `enum_value` (`enum_name`,`enum_value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/* used to link MySql tables to Mifos X application tables for additional data needs */
CREATE TABLE `x_registered_table` (
`registered_table_name` varchar(50) NOT NULL,
`application_table_name` varchar(50) NOT NULL,
PRIMARY KEY (`registered_table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `m_calendar` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`title` varchar(50) NOT NULL,
`description` varchar(100) DEFAULT NULL,
`location` varchar(50) DEFAULT NULL,
`start_date` date NOT NULL,
`end_date` date DEFAULT NULL,
`duration` smallint(6) DEFAULT NULL,
`calendar_type_enum` smallint(5) NOT NULL,
`repeating` tinyint(1) NOT NULL DEFAULT '0',
`recurrence` varchar(100) DEFAULT NULL,
`remind_by_enum` smallint(5) DEFAULT NULL,
`first_reminder` smallint(11) DEFAULT NULL,
`second_reminder` smallint(11) DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `m_calendar_instance` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`calendar_id` bigint(20) NOT NULL,
`entity_id` bigint(20) NOT NULL,
`entity_type_enum` smallint(5) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_m_calendar_m_calendar_instance` (`calendar_id`),
CONSTRAINT `FK_m_calendar_m_calendar_instance` FOREIGN KEY (`calendar_id`) REFERENCES `m_calendar` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ================= end of reference/lookup tables =============
-- DDL for office related tables
CREATE TABLE `m_office` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`parent_id` bigint(20) DEFAULT NULL,
`hierarchy` varchar(100) DEFAULT NULL,
`external_id` varchar(100) DEFAULT NULL,
`name` varchar(50) NOT NULL,
`opening_date` date NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_org` (`name`),
UNIQUE KEY `externalid_org` (`external_id`),
KEY `FK2291C477E2551DCC` (`parent_id`),
CONSTRAINT `FK2291C477E2551DCC` FOREIGN KEY (`parent_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_office_transaction` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`from_office_id` bigint(20) DEFAULT NULL,
`to_office_id` bigint(20) DEFAULT NULL,
`currency_code` varchar(3) NOT NULL,
`currency_digits` int(11) NOT NULL,
`transaction_amount` decimal(19,6) NOT NULL,
`transaction_date` date NOT NULL,
`description` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK1E37728B93C6C1B6` (`to_office_id`),
KEY `FK1E37728B783C5C25` (`from_office_id`),
CONSTRAINT `FK1E37728B783C5C25` FOREIGN KEY (`from_office_id`) REFERENCES `m_office` (`id`),
CONSTRAINT `FK1E37728B93C6C1B6` FOREIGN KEY (`to_office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ============ end of office related tables ==========
-- DDL for admin tables
CREATE TABLE `m_permission` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`grouping` varchar(45) DEFAULT NULL,
`code` varchar(100) NOT NULL,
`entity_name` varchar(100) DEFAULT NULL,
`action_name` varchar(100) DEFAULT NULL,
`can_maker_checker` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_role` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`description` varchar(500) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unq_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_role_permission` (
`role_id` bigint(20) NOT NULL,
`permission_id` bigint(20) NOT NULL,
PRIMARY KEY (`role_id`,`permission_id`),
KEY `FK8DEDB04815CEC7AB` (`role_id`),
KEY `FK8DEDB048103B544B` (`permission_id`),
CONSTRAINT `FK8DEDB048103B544B` FOREIGN KEY (`permission_id`) REFERENCES `m_permission` (`id`),
CONSTRAINT `FK8DEDB04815CEC7AB` FOREIGN KEY (`role_id`) REFERENCES `m_role` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_appuser` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
`office_id` bigint(20) DEFAULT NULL,
`username` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`lastname` varchar(100) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(100) NOT NULL,
`firsttime_login_remaining` bit(1) NOT NULL,
`nonexpired` bit(1) NOT NULL,
`nonlocked` bit(1) NOT NULL,
`nonexpired_credentials` bit(1) NOT NULL,
`enabled` bit(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username_org` (`username`),
KEY `FKB3D587CE0DD567A` (`office_id`),
CONSTRAINT `FKB3D587CE0DD567A` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_appuser_role` (
`appuser_id` bigint(20) NOT NULL,
`role_id` bigint(20) NOT NULL,
PRIMARY KEY (`appuser_id`,`role_id`),
KEY `FK7662CE59B4100309` (`appuser_id`),
KEY `FK7662CE5915CEC7AB` (`role_id`),
CONSTRAINT `FK7662CE5915CEC7AB` FOREIGN KEY (`role_id`) REFERENCES `m_role` (`id`),
CONSTRAINT `FK7662CE59B4100309` FOREIGN KEY (`appuser_id`) REFERENCES `m_appuser` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ================ end of user admin tables ===============
-- DDL for organisation wide related concepts
CREATE TABLE `m_portfolio_command_source` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`action_name` varchar(50) NOT NULL,
`entity_name` varchar(50) NOT NULL,
`office_id` bigint(20) DEFAULT NULL,
`group_id` bigint(20) DEFAULT NULL,
`client_id` bigint(20) DEFAULT NULL,
`loan_id` bigint(20) DEFAULT NULL,
`savings_account_id` bigint(20) DEFAULT NULL,
`api_get_url` varchar(100) NOT NULL,
`resource_id` bigint(20) DEFAULT NULL,
`subresource_id` bigint(20) DEFAULT NULL,
`command_as_json` text NOT NULL,
`maker_id` bigint(20) NOT NULL,
`made_on_date` datetime NOT NULL,
`checker_id` bigint(20) DEFAULT NULL,
`checked_on_date` datetime DEFAULT NULL,
`processing_result_enum` smallint(5) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_m_maker_m_appuser` (`maker_id`),
KEY `FK_m_checker_m_appuser` (`checker_id`),
KEY `action_name` (`action_name`),
KEY `entity_name` (`entity_name`,`resource_id`),
KEY `made_on_date` (`made_on_date`),
KEY `checked_on_date` (`checked_on_date`),
KEY `processing_result_enum` (`processing_result_enum`),
KEY `office_id` (`office_id`),
KEY `group_id` (`office_id`),
KEY `client_id` (`office_id`),
KEY `loan_id` (`office_id`),
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_charge` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`currency_code` varchar(3) NOT NULL,
`charge_applies_to_enum` smallint(5) NOT NULL,
`charge_time_enum` smallint(5) NOT NULL,
`charge_calculation_enum` smallint(5) NOT NULL,
`amount` decimal(19,6) NOT NULL,
`is_penalty` tinyint(1) NOT NULL DEFAULT '0',
`is_active` tinyint(1) NOT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_fund` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`external_id` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `fund_name_org` (`name`),
UNIQUE KEY `fund_externalid_org` (`external_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_staff` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`is_loan_officer` tinyint(1) NOT NULL DEFAULT '0',
`office_id` bigint(20) DEFAULT NULL,
`firstname` varchar(50) DEFAULT NULL,
`lastname` varchar(50) DEFAULT NULL,
`display_name` varchar(100) NOT NULL,
`joining_date` date,
PRIMARY KEY (`id`),
UNIQUE KEY `display_name` (`display_name`),
KEY `FK_m_staff_m_office` (`office_id`),
CONSTRAINT `FK_m_staff_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ============ end of organisation wide related tables ===========
-- DDL client/group related tables
CREATE TABLE `m_group_level` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`parent_id` INT(11) NULL DEFAULT NULL,
`super_parent` TINYINT(1) NOT NULL,
`level_name` VARCHAR(100) NOT NULL,
`recursable` TINYINT(1) NOT NULL,
`can_have_clients` TINYINT(1) NOT NULL,
PRIMARY KEY (`id`),
INDEX `Parent_levelId_reference` (`parent_id`),
CONSTRAINT `Parent_levelId_reference` FOREIGN KEY (`parent_id`) REFERENCES `m_group_level` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_group` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`office_id` bigint(20) NOT NULL,
`staff_id` BIGINT(20) DEFAULT NULL,
`parent_id` BIGINT(20) NULL DEFAULT NULL,
`level_Id` INT(11) NOT NULL,
`hierarchy` VARCHAR(100) NULL DEFAULT NULL,
`name` varchar(100) NOT NULL,
`external_id` varchar(100) DEFAULT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`, `level_id`),
UNIQUE KEY `external_id` (`external_id`, `level_Id`),
KEY `office_id` (`office_id`),
KEY `staff_id` (`staff_id`),
CONSTRAINT `m_group_ibfk_1` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`),
CONSTRAINT `Parent_Id_reference` FOREIGN KEY (`parent_id`) REFERENCES `m_group` (`id`),
CONSTRAINT `FK_m_group_level` FOREIGN KEY (`level_Id`) REFERENCES `m_group_level` (`id`),
CONSTRAINT `FK_m_group_m_staff` FOREIGN KEY (`staff_id`) REFERENCES `m_staff` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_client` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`account_no` varchar(20) NOT NULL,
`office_id` bigint(20) NOT NULL,
`external_id` varchar(100) DEFAULT NULL,
`firstname` varchar(50) DEFAULT NULL,
`middlename` varchar(50) DEFAULT NULL,
`lastname` varchar(50) DEFAULT NULL,
`fullname` varchar(100) DEFAULT NULL,
`display_name` varchar(100) NOT NULL,
`image_key` varchar(500) DEFAULT NULL,
`joined_date` date DEFAULT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `account_no_UNIQUE` (`account_no`),
UNIQUE KEY `external_id` (`external_id`),
KEY `FKCE00CAB3E0DD567A` (`office_id`),
CONSTRAINT `FKCE00CAB3E0DD567A` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_client_identifier` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`client_id` bigint(20) NOT NULL,
`document_type_id` int(11) NOT NULL,
`document_key` varchar(50) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_identifier_key` (`document_type_id`,`document_key`),
UNIQUE KEY `unique_client_identifier` (`client_id`,`document_type_id`),
KEY `FK_m_client_document_m_client` (`client_id`),
KEY `FK_m_client_document_m_code_value` (`document_type_id`),
CONSTRAINT `FK_m_client_document_m_client` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FK_m_client_document_m_code_value` FOREIGN KEY (`document_type_id`) REFERENCES `m_code_value` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_group_client` (
`group_id` bigint(20) NOT NULL,
`client_id` bigint(20) NOT NULL,
PRIMARY KEY (`group_id`,`client_id`),
KEY `client_id` (`client_id`),
CONSTRAINT `m_group_client_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`),
CONSTRAINT `m_group_client_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ==== end of client/group related tables ==========
-- DDL for loan and loan related tables
CREATE TABLE `m_product_loan` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`currency_code` varchar(3) NOT NULL,
`currency_digits` smallint(5) NOT NULL,
`principal_amount` decimal(19,6) NOT NULL,
`arrearstolerance_amount` decimal(19,6) DEFAULT NULL,
`name` varchar(100) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`fund_id` bigint(20) DEFAULT NULL,
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
`interest_period_frequency_enum` smallint(5) NOT NULL,
`annual_nominal_interest_rate` decimal(19,6) NOT NULL,
`interest_method_enum` smallint(5) NOT NULL,
`interest_calculated_in_period_enum` smallint(5) NOT NULL DEFAULT '1',
`repay_every` smallint(5) NOT NULL,
`repayment_period_frequency_enum` smallint(5) NOT NULL,
`number_of_repayments` smallint(5) NOT NULL,
`amortization_method_enum` smallint(5) NOT NULL,
`accounting_type` smallint(5) NOT NULL,
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unq_name` (`name`),
KEY `FKA6A8A7D77240145` (`fund_id`),
KEY `FK_ltp_strategy` (`loan_transaction_strategy_id`),
CONSTRAINT `FKA6A8A7D77240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`),
CONSTRAINT `FK_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_product_loan_charge` (
`product_loan_id` bigint(20) NOT NULL,
`charge_id` bigint(20) NOT NULL,
PRIMARY KEY (`product_loan_id`,`charge_id`),
KEY `charge_id` (`charge_id`),
CONSTRAINT `m_product_loan_charge_ibfk_1` FOREIGN KEY (`charge_id`) REFERENCES `m_charge` (`id`),
CONSTRAINT `m_product_loan_charge_ibfk_2` FOREIGN KEY (`product_loan_id`) REFERENCES `m_product_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_loan` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`account_no` varchar(20) NOT NULL,
`external_id` varchar(100) DEFAULT NULL,
`client_id` bigint(20) DEFAULT NULL,
`group_id` bigint(20) DEFAULT NULL,
`product_id` bigint(20) DEFAULT NULL,
`fund_id` bigint(20) DEFAULT NULL,
`loan_officer_id` bigint(20) DEFAULT NULL,
`loanpurpose_cv_id` int(11) DEFAULT NULL,
`loan_status_id` smallint(5) NOT NULL,
`currency_code` varchar(3) NOT NULL,
`currency_digits` smallint(5) NOT NULL,
`principal_amount` decimal(19,6) NOT NULL,
`arrearstolerance_amount` decimal(19,6) DEFAULT NULL,
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
`interest_period_frequency_enum` smallint(5) NOT NULL,
`annual_nominal_interest_rate` decimal(19,6) NOT NULL,
`interest_method_enum` smallint(5) NOT NULL,
`interest_calculated_in_period_enum` smallint(5) NOT NULL DEFAULT '1',
`term_frequency` smallint(5) NOT NULL DEFAULT '0',
`term_period_frequency_enum` smallint(5) NOT NULL DEFAULT '2',
`repay_every` smallint(5) NOT NULL,
`repayment_period_frequency_enum` smallint(5) NOT NULL,
`number_of_repayments` smallint(5) NOT NULL,
`amortization_method_enum` smallint(5) NOT NULL,
`submittedon_date` date DEFAULT NULL,
`submittedon_userid` bigint(20) DEFAULT NULL,
`approvedon_date` date DEFAULT NULL,
`approvedon_userid` bigint(20) DEFAULT NULL,
`expected_disbursedon_date` date DEFAULT NULL,
`expected_firstrepaymenton_date` date DEFAULT NULL,
`interest_calculated_from_date` date DEFAULT NULL,
`disbursedon_date` date DEFAULT NULL,
`disbursedon_userid` bigint(20) DEFAULT NULL,
`expected_maturedon_date` date DEFAULT NULL,
`maturedon_date` date DEFAULT NULL,
`closedon_date` date DEFAULT NULL,
`closedon_userid` bigint(20) DEFAULT NULL,
`total_charges_due_at_disbursement_derived` decimal(19,6) DEFAULT NULL,
`principal_disbursed_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`principal_repaid_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`principal_writtenoff_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`principal_outstanding_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`interest_charged_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`interest_repaid_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`interest_waived_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`interest_writtenoff_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`interest_outstanding_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`fee_charges_charged_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`fee_charges_repaid_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`fee_charges_waived_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`fee_charges_writtenoff_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`fee_charges_outstanding_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`penalty_charges_charged_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`penalty_charges_repaid_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`penalty_charges_waived_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`penalty_charges_writtenoff_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`penalty_charges_outstanding_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_expected_repayment_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_repayment_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_expected_costofloan_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_costofloan_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_waived_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_writtenoff_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_outstanding_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`rejectedon_date` date DEFAULT NULL,
`rejectedon_userid` bigint(20) DEFAULT NULL,
`rescheduledon_date` date DEFAULT NULL,
`withdrawnon_date` date DEFAULT NULL,
`withdrawnon_userid` bigint(20) DEFAULT NULL,
`writtenoffon_date` date DEFAULT NULL,
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `loan_account_no_UNIQUE` (`account_no`),
UNIQUE KEY `loan_externalid_UNIQUE` (`external_id`),
KEY `FKB6F935D87179A0CB` (`client_id`),
KEY `FKB6F935D8C8D4B434` (`product_id`),
KEY `FK7C885877240145` (`fund_id`),
KEY `FK_loan_ltp_strategy` (`loan_transaction_strategy_id`),
KEY `FK_m_loan_m_staff` (`loan_officer_id`),
KEY `group_id` (`group_id`),
KEY `FK_m_loanpurpose_codevalue` (`loanpurpose_cv_id`),
KEY `FK_submittedon_userid` (`submittedon_userid`),
KEY `FK_approvedon_userid` (`approvedon_userid`),
KEY `FK_rejectedon_userid` (`rejectedon_userid`),
KEY `FK_withdrawnon_userid` (`withdrawnon_userid`),
KEY `FK_disbursedon_userid` (`disbursedon_userid`),
KEY `FK_closedon_userid` (`closedon_userid`),
CONSTRAINT `FK7C885877240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`),
CONSTRAINT `FKB6F935D87179A0CB` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FKB6F935D8C8D4B434` FOREIGN KEY (`product_id`) REFERENCES `m_product_loan` (`id`),
CONSTRAINT `FK_approvedon_userid` FOREIGN KEY (`approvedon_userid`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_closedon_userid` FOREIGN KEY (`closedon_userid`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_disbursedon_userid` FOREIGN KEY (`disbursedon_userid`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_loan_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`),
CONSTRAINT `FK_m_loanpurpose_codevalue` FOREIGN KEY (`loanpurpose_cv_id`) REFERENCES `m_code_value` (`id`),
CONSTRAINT `FK_m_loan_m_staff` FOREIGN KEY (`loan_officer_id`) REFERENCES `m_staff` (`id`),
CONSTRAINT `FK_rejectedon_userid` FOREIGN KEY (`rejectedon_userid`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_submittedon_userid` FOREIGN KEY (`submittedon_userid`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_withdrawnon_userid` FOREIGN KEY (`withdrawnon_userid`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `m_loan_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_loan_arrears_aging` (
`loan_id` bigint(20) NOT NULL AUTO_INCREMENT,
`principal_overdue_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`interest_overdue_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`fee_charges_overdue_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`penalty_charges_overdue_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`total_overdue_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`overdue_since_date_derived` date DEFAULT NULL,
PRIMARY KEY (`loan_id`),
CONSTRAINT `m_loan_arrears_aging_ibfk_1` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_guarantor` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`loan_id` BIGINT(20) NOT NULL,
`client_reln_cv_id` INT(11) DEFAULT NULL,
`type_enum` SMALLINT(5) NOT NULL,
`entity_id` BIGINT(20) NULL DEFAULT NULL,
`firstname` VARCHAR(50) NULL DEFAULT NULL,
`lastname` VARCHAR(50) NULL DEFAULT NULL,
`dob` DATE NULL DEFAULT NULL,
`address_line_1` VARCHAR(500) NULL DEFAULT NULL,
`address_line_2` VARCHAR(500) NULL DEFAULT NULL,
`city` VARCHAR(50) NULL DEFAULT NULL,
`state` VARCHAR(50) NULL DEFAULT NULL,
`country` VARCHAR(50) NULL DEFAULT NULL,
`zip` VARCHAR(20) NULL DEFAULT NULL,
`house_phone_number` VARCHAR(20) NULL DEFAULT NULL,
`mobile_number` VARCHAR(20) NULL DEFAULT NULL,
`comment` VARCHAR(500) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `FK_m_guarantor_m_loan` (`loan_id`),
CONSTRAINT `FK_m_guarantor_m_code_value` FOREIGN KEY (`client_reln_cv_id`) REFERENCES `m_code_value` (`id`)
CONSTRAINT `FK_m_guarantor_m_loan` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_loan_charge` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`loan_id` bigint(20) NOT NULL,
`charge_id` bigint(20) NOT NULL,
`is_penalty` tinyint(1) NOT NULL DEFAULT '0',
`charge_time_enum` smallint(5) NOT NULL,
`due_for_collection_as_of_date` date DEFAULT NULL,
`charge_calculation_enum` smallint(5) NOT NULL,
`calculation_percentage` decimal(19,6) DEFAULT NULL,
`calculation_on_amount` decimal(19,6) DEFAULT NULL,
`amount` decimal(19,6) NOT NULL,
`amount_paid_derived` decimal(19,6) DEFAULT NULL,
`amount_waived_derived` decimal(19,6) DEFAULT NULL,
`amount_writtenoff_derived` decimal(19,6) DEFAULT NULL,
`amount_outstanding_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
`is_paid_derived` tinyint(1) NOT NULL DEFAULT '0',
`waived` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `charge_id` (`charge_id`),
KEY `m_loan_charge_ibfk_2` (`loan_id`),
CONSTRAINT `m_loan_charge_ibfk_1` FOREIGN KEY (`charge_id`) REFERENCES `m_charge` (`id`),
CONSTRAINT `m_loan_charge_ibfk_2` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_loan_collateral` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`loan_id` bigint(20) NOT NULL,
`type_cv_id` int(11) NOT NULL,
`value` DECIMAL(19,6) DEFAULT NULL,
`description` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_collateral_m_loan` (`loan_id`),
KEY `FK_collateral_code_value` (`type_cv_id`),
CONSTRAINT `FK_collateral_m_loan` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`),
CONSTRAINT `FK_collateral_code_value` FOREIGN KEY (`type_cv_id`) REFERENCES `m_code_value` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_loan_officer_assignment_history` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`loan_id` bigint(20) NOT NULL,
`loan_officer_id` bigint(20) DEFAULT NULL,
`start_date` date NOT NULL,
`end_date` date DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_m_loan_officer_assignment_history_0001` (`loan_id`),
KEY `fk_m_loan_officer_assignment_history_0002` (`loan_officer_id`),
CONSTRAINT `fk_m_loan_officer_assignment_history_0001` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`),
CONSTRAINT `fk_m_loan_officer_assignment_history_0002` FOREIGN KEY (`loan_officer_id`) REFERENCES `m_staff` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_loan_repayment_schedule` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`loan_id` bigint(20) NOT NULL,
`fromdate` date DEFAULT NULL,
`duedate` date NOT NULL,
`installment` smallint(5) NOT NULL,
`principal_amount` decimal(19,6) DEFAULT NULL,
`principal_completed_derived` decimal(19,6) DEFAULT NULL,
`principal_writtenoff_derived` decimal(19,6) DEFAULT NULL,
`interest_amount` decimal(19,6) DEFAULT NULL,
`interest_completed_derived` decimal(19,6) DEFAULT NULL,
`interest_writtenoff_derived` decimal(19,6) DEFAULT NULL,
`fee_charges_amount` decimal(19,6) DEFAULT NULL,
`fee_charges_completed_derived` decimal(19,6) DEFAULT NULL,
`fee_charges_writtenoff_derived` decimal(19,6) DEFAULT NULL,
`fee_charges_waived_derived` decimal(19,6) DEFAULT NULL,
`penalty_charges_amount` decimal(19,6) DEFAULT NULL,
`penalty_charges_completed_derived` decimal(19,6) DEFAULT NULL,
`penalty_charges_writtenoff_derived` decimal(19,6) DEFAULT NULL,
`penalty_charges_waived_derived` decimal(19,6) DEFAULT NULL,
`completed_derived` bit(1) NOT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`interest_waived_derived` decimal(19,6) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK488B92AA40BE0710` (`loan_id`),
CONSTRAINT `FK488B92AA40BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_loan_transaction` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`loan_id` bigint(20) NOT NULL,
`is_reversed` TINYINT(1) NOT NULL,
`transaction_type_enum` smallint(5) NOT NULL,
`transaction_date` date NOT NULL,
`amount` decimal(19,6) NOT NULL,
`principal_portion_derived` decimal(19,6) DEFAULT NULL,
`interest_portion_derived` decimal(19,6) DEFAULT NULL,
`fee_charges_portion_derived` decimal(19,6) DEFAULT NULL,
`penalty_charges_portion_derived` decimal(19,6) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FKCFCEA42640BE0710` (`loan_id`),
CONSTRAINT `FKCFCEA42640BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ======== end of loan related tables ==========
CREATE TABLE `m_savings_product` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`description` varchar(500) NOT NULL,
`currency_code` varchar(3) NOT NULL,
`currency_digits` smallint(5) NOT NULL,
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
`nominal_interest_rate_period_frequency_enum` smallint(5) NOT NULL,
`interest_period_enum` SMALLINT(5) NOT NULL,
`interest_calculation_type_enum` SMALLINT(5) NOT NULL,
`interest_calculation_days_in_year_type_enum` SMALLINT(5) NOT NULL,
`min_required_opening_balance` decimal(19,6) DEFAULT NULL,
`lockin_period_frequency` decimal(19,6) DEFAULT NULL,
`lockin_period_frequency_enum` smallint(5) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sp_unq_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_savings_account` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`account_no` varchar(20) NOT NULL,
`external_id` varchar(100) DEFAULT NULL,
`client_id` bigint(20) DEFAULT NULL,
`group_id` bigint(20) DEFAULT NULL,
`product_id` bigint(20) DEFAULT NULL,
`status_enum` SMALLINT(5) NOT NULL DEFAULT 300,
`activation_date` DATE DEFAULT NULL,
`currency_code` varchar(3) NOT NULL,
`currency_digits` smallint(5) NOT NULL,
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
`nominal_interest_rate_period_frequency_enum` smallint(5) NOT NULL,
`annual_nominal_interest_rate` decimal(19,6) NOT NULL,
`interest_period_enum` SMALLINT(5) NOT NULL,
`interest_calculation_type_enum` SMALLINT(5) NOT NULL,
`interest_calculation_days_in_year_type_enum` SMALLINT(5) NOT NULL,
`min_required_opening_balance` decimal(19,6) DEFAULT NULL,
`lockin_period_frequency` decimal(19,6) DEFAULT NULL,
`lockin_period_frequency_enum` smallint(5) DEFAULT NULL,
`lockedin_until_date_derived` DATE DEFAULT NULL,
`total_deposits_derived` decimal(19,6) DEFAULT NULL,
`total_withdrawals_derived` decimal(19,6) DEFAULT NULL,
`total_interest_earned_derived` decimal(19,6) DEFAULT NULL,
`total_interest_posted_derived` decimal(19,6) DEFAULT NULL,
`account_balance_derived` decimal(19,6) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `sa_account_no_UNIQUE` (`account_no`),
UNIQUE KEY `sa_externalid_UNIQUE` (`external_id`),
KEY `FKSA00000000000001` (`client_id`),
KEY `FKSA00000000000002` (`group_id`),
KEY `FKSA00000000000003` (`product_id`),
CONSTRAINT `FKSA00000000000001` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FKSA00000000000002` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`),
CONSTRAINT `FKSA00000000000003` FOREIGN KEY (`product_id`) REFERENCES `m_savings_product` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_savings_account_transaction` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`savings_account_id` bigint(20) NOT NULL,
`transaction_type_enum` smallint(5) NOT NULL,
`transaction_date` date NOT NULL,
`amount` decimal(19,6) NOT NULL,
`is_reversed` tinyint(1) NOT NULL,
`running_balance_derived` DECIMAL(19,6) NULL,
`balance_number_of_days_derived` INT NULL,
`balance_end_date_derived` DATE NULL,
`cumulative_balance_derived` DECIMAL(19,6) NULL,
PRIMARY KEY (`id`),
KEY `FKSAT0000000001` (`savings_account_id`),
CONSTRAINT `FKSAT0000000001` FOREIGN KEY (`savings_account_id`) REFERENCES `m_savings_account` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- end of savings account related tables
-- DDL for notes associated with all client/group and financial accounts
CREATE TABLE `m_note` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`client_id` bigint(20) DEFAULT NULL,
`group_id` bigint(20) DEFAULT NULL,
`loan_id` bigint(20) DEFAULT NULL,
`loan_transaction_id` bigint(20) DEFAULT NULL,
`note_type_enum` smallint(5) NOT NULL,
`note` varchar(1000) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK7C9708924D26803` (`loan_transaction_id`),
KEY `FK7C97089541F0A56` (`createdby_id`),
KEY `FK7C970897179A0CB` (`client_id`),
KEY `FK_m_note_m_group` (`group_id`),
KEY `FK7C970898F889C3F` (`lastmodifiedby_id`),
KEY `FK7C9708940BE0710` (`loan_id`),
CONSTRAINT `FK7C9708924D26803` FOREIGN KEY (`loan_transaction_id`) REFERENCES `m_loan_transaction` (`id`),
CONSTRAINT `FK7C9708940BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`),
CONSTRAINT `FK7C97089541F0A56` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK7C970897179A0CB` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FK_m_note_m_group` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`),
CONSTRAINT `FK7C970898F889C3F` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- DDL for accounting sub system related tables
CREATE TABLE `acc_gl_account` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`parent_id` bigint(20) DEFAULT NULL,
`gl_code` varchar(45) NOT NULL,
`disabled` tinyint(1) NOT NULL DEFAULT '0',
`manual_journal_entries_allowed` tinyint(1) NOT NULL DEFAULT '1',
`account_usage` tinyint(1) NOT NULL DEFAULT '2',
`classification_enum` smallint(5) NOT NULL,
`description` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `acc_gl_code` (`gl_code`),
KEY `FK_ACC_0000000001` (`parent_id`),
CONSTRAINT `FK_ACC_0000000001` FOREIGN KEY (`parent_id`) REFERENCES `acc_gl_account` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `acc_gl_closure` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`office_id` bigint(20) NOT NULL,
`closing_date` date NOT NULL,
`is_deleted` int(20) NOT NULL DEFAULT '0',
`createdby_id` bigint(20) DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`comments` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `office_id_closing_date` (`office_id`,`closing_date`),
KEY `FK_acc_gl_closure_m_office` (`office_id`),
KEY `FK_acc_gl_closure_m_appuser` (`createdby_id`),
KEY `FK_acc_gl_closure_m_appuser_2` (`lastmodifiedby_id`),
CONSTRAINT `FK_acc_gl_closure_m_appuser` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_acc_gl_closure_m_appuser_2` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_acc_gl_closure_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `acc_gl_journal_entry` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`account_id` bigint(20) NOT NULL,
`office_id` bigint(20) NOT NULL,
`reversal_id` bigint(20) DEFAULT NULL,
`transaction_id` varchar(50) NOT NULL,
`reversed` tinyint(1) NOT NULL DEFAULT '0',
`manual_entry` TINYINT(1) NOT NULL DEFAULT '0',
`entry_date` date NOT NULL,
`type_enum` smallint(5) NOT NULL,
`amount` decimal(19,6) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`entity_type_enum` smallint(5) DEFAULT NULL,
`entity_id` bigint(20) DEFAULT NULL,
`createdby_id` bigint(20) NOT NULL,
`lastmodifiedby_id` bigint(20) NOT NULL,
`created_date` datetime NOT NULL,
`lastmodified_date` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_acc_gl_journal_entry_m_office` (`office_id`),
KEY `FK_acc_gl_journal_entry_m_appuser` (`createdby_id`),
KEY `FK_acc_gl_journal_entry_m_appuser_2` (`lastmodifiedby_id`),
KEY `FK_acc_gl_journal_entry_acc_gl_journal_entry` (`reversal_id`),
KEY `FK_acc_gl_journal_entry_acc_gl_account` (`account_id`),
CONSTRAINT `FK_acc_gl_journal_entry_acc_gl_account` FOREIGN KEY (`account_id`) REFERENCES `acc_gl_account` (`id`),
CONSTRAINT `FK_acc_gl_journal_entry_acc_gl_journal_entry` FOREIGN KEY (`reversal_id`) REFERENCES `acc_gl_journal_entry` (`id`),
CONSTRAINT `FK_acc_gl_journal_entry_m_appuser` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_acc_gl_journal_entry_m_appuser_2` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_acc_gl_journal_entry_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `acc_product_mapping` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`gl_account_id` bigint(20) DEFAULT NULL,
`product_id` bigint(20) DEFAULT NULL,
`product_type` smallint(5) DEFAULT NULL,
`financial_account_type` smallint(5) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- =========== end of accounting related tables ==========
-- DDL for reporting related tables
CREATE TABLE `rpt_sequence` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `stretchy_parameter` (
`parameter_id` int(11) NOT NULL AUTO_INCREMENT,
`parameter_name` varchar(45) NOT NULL,
`parameter_variable` varchar(45) DEFAULT NULL,
`parameter_label` varchar(45) NOT NULL,
`parameter_displayType` varchar(45) NOT NULL,
`parameter_FormatType` varchar(10) NOT NULL,
`parameter_default` varchar(45) NOT NULL,
`special` varchar(1) DEFAULT NULL,
`selectOne` varchar(1) DEFAULT NULL,
`selectAll` varchar(1) DEFAULT NULL,
`parameter_sql` text,
`parent_parameter_id` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`parameter_id`),
UNIQUE KEY `name_UNIQUE` (`parameter_name`),
INDEX `fk_stretchy_parameter_0001_idx` (`parent_parameter_id`),
CONSTRAINT `fk_stretchy_parameter_0001` FOREIGN KEY (`parent_parameter_id`) REFERENCES `stretchy_parameter` (`parameter_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `stretchy_report` (
`report_id` int(11) NOT NULL AUTO_INCREMENT,
`report_name` varchar(100) NOT NULL,
`report_type` varchar(20) NOT NULL,
`report_subtype` varchar(20) DEFAULT NULL,
`report_category` varchar(45) DEFAULT NULL,
`report_sql` text,
`description` text,
`core_report` tinyint(1) DEFAULT '0',
`use_report` tinyint(1) DEFAULT '0',
PRIMARY KEY (`report_id`),
UNIQUE KEY `report_name_UNIQUE` (`report_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `stretchy_report_parameter` (
`report_id` int(11) NOT NULL,
`parameter_id` int(11) NOT NULL,
`report_parameter_name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`report_id`,`parameter_id`),
UNIQUE KEY `report_id_name_UNIQUE` (`report_id`,`report_parameter_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- =========== end of reporting related tables ============
@@ -0,0 +1,321 @@
-- currency symbols may not apply through command line on windows so use a different client like mysql workbench
INSERT INTO `ref_loan_transaction_processing_strategy`
(`id`,`code`,`name`)
VALUES
(1, 'mifos-standard-strategy', 'Mifos style'),
(2, 'heavensfamily-strategy', 'Heavensfamily'),
(3, 'creocore-strategy', 'Creocore'),
(4, 'rbi-india-strategy', 'RBI (India)');
INSERT INTO `c_configuration`
(`name`, `enabled`)
VALUES
('maker-checker', 0);
INSERT INTO `r_enum_value`
VALUES
('amortization_method_enum',0,'Equal principle payments','Equal principle payments'),
('amortization_method_enum',1,'Equal installments','Equal installments'),
('interest_calculated_in_period_enum',0,'Daily','Daily'),
('interest_calculated_in_period_enum',1,'Same as repayment period','Same as repayment period'),
('interest_method_enum',0,'Declining Balance','Declining Balance'),
('interest_method_enum',1,'Flat','Flat'),
('interest_period_frequency_enum',2,'Per month','Per month'),
('interest_period_frequency_enum',3,'Per year','Per year'),
('loan_status_id',100,'Submitted and awaiting approval','Submitted and awaiting approval'),
('loan_status_id',200,'Approved','Approved'),
('loan_status_id',300,'Active','Active'),
('loan_status_id',400,'Withdrawn by client','Withdrawn by client'),
('loan_status_id',500,'Rejected','Rejected'),
('loan_status_id',600,'Closed','Closed'),
('loan_status_id',601,'Written-Off','Written-Off'),
('loan_status_id',602,'Rescheduled','Rescheduled'),
('loan_status_id',700,'Overpaid','Overpaid'),
('loan_transaction_strategy_id',1,'mifos-standard-strategy','Mifos style'),
('loan_transaction_strategy_id',2,'heavensfamily-strategy','Heavensfamily'),
('loan_transaction_strategy_id',3,'creocore-strategy','Creocore'),
('loan_transaction_strategy_id',4,'rbi-india-strategy','RBI (India)'),
('processing_result_enum',0,'invalid','Invalid'),
('processing_result_enum',1,'processed','Processed'),
('processing_result_enum',2,'awaiting.approval','Awaiting Approval'),
('processing_result_enum',3,'rejected','Rejected'),
('repayment_period_frequency_enum',0,'Days','Days'),
('repayment_period_frequency_enum',1,'Weeks','Weeks'),
('repayment_period_frequency_enum',2,'Months','Months'),
('term_period_frequency_enum',0,'Days','Days'),
('term_period_frequency_enum',1,'Weeks','Weeks'),
('term_period_frequency_enum',2,'Months','Months'),
('term_period_frequency_enum',3,'Years','Years');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '1', 'Disbursement', 'Disbursement');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '2', 'Repayment', 'Repayment');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '3', 'Contra', 'Contra');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '4', 'Waive Interest', 'Waive Interest');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '5', 'Repayment At Disbursement', 'Repayment At Disbursement');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '6', 'Write-Off', 'Write-Off');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '7', 'Marked for Rescheduling', 'Marked for Rescheduling');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '8', 'Recovery Repayment', 'Recovery Repayment');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '9', 'Waive Charges', 'Waive Charges');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '10', 'Apply Charges', 'Apply Charges');
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('transaction_type_enum', '11', 'Apply Interest', 'Apply Interest');
INSERT INTO `m_currency`
(`id`,`code`,`decimal_places`,`display_symbol`,`name`, `internationalized_name_code`)
VALUES
(1,'AED',2,NULL,'UAE Dirham','currency.AED'),
(2,'AFN',2,NULL,'Afghanistan Afghani','currency.AFN'),
(3,'ALL',2,NULL,'Albanian Lek','currency.ALL'),
(4,'AMD',2,NULL,'Armenian Dram','currency.AMD'),
(5,'ANG',2,NULL,'Netherlands Antillian Guilder','currency.ANG'),
(6,'AOA',2,NULL,'Angolan Kwanza','currency.AOA'),
(7,'ARS',2,'$','Argentine Peso','currency.ARS'),
(8,'AUD',2,'A$','Australian Dollar','currency.AUD'),
(9,'AWG',2,NULL,'Aruban Guilder','currency.AWG'),
(10,'AZM',2,NULL,'Azerbaijanian Manat','currency.AZM'),
(11,'BAM',2,NULL,'Bosnia and Herzegovina Convertible Marks','currency.BAM'),
(12,'BBD',2,NULL,'Barbados Dollar','currency.BBD'),
(13,'BDT',2,NULL,'Bangladesh Taka','currency.BDT'),
(14,'BGN',2,NULL,'Bulgarian Lev','currency.BGN'),
(15,'BHD',3,NULL,'Bahraini Dinar','currency.BHD'),
(16,'BIF',0,NULL,'Burundi Franc','currency.BIF'),
(17,'BMD',2,NULL,'Bermudian Dollar','currency.BMD'),
(18,'BND',2,'B$','Brunei Dollar','currency.BND'),
(19,'BOB',2,'Bs.','Bolivian Boliviano','currency.BOB'),
(20,'BRL',2,'R$','Brazilian Real','currency.BRL'),
(21,'BSD',2,NULL,'Bahamian Dollar','currency.BSD'),
(22,'BTN',2,NULL,'Bhutan Ngultrum','currency.BTN'),
(23,'BWP',2,NULL,'Botswana Pula','currency.BWP'),
(24,'BYR',0,NULL,'Belarussian Ruble','currency.BYR'),
(25,'BZD',2,'BZ$','Belize Dollar','currency.BZD'),
(26,'CAD',2,NULL,'Canadian Dollar','currency.CAD'),
(27,'CDF',2,NULL,'Franc Congolais','currency.CDF'),
(28,'CHF',2,NULL,'Swiss Franc','currency.CHF'),
(29,'CLP',0,'$','Chilean Peso','currency.CLP'),
(30,'CNY',2,NULL,'Chinese Yuan Renminbi','currency.CNY'),
(31,'COP',2,'$','Colombian Peso','currency.COP'),
(32,'CRC',2,'₡','Costa Rican Colon','currency.CRC'),
(33,'CSD',2,NULL,'Serbian Dinar','currency.CSD'),
(34,'CUP',2,'$MN','Cuban Peso','currency.CUP'),
(35,'CVE',2,NULL,'Cape Verde Escudo','currency.CVE'),
(36,'CYP',2,NULL,'Cyprus Pound','currency.CYP'),
(37,'CZK',2,NULL,'Czech Koruna','currency.CZK'),
(38,'DJF',0,NULL,'Djibouti Franc','currency.DJF'),
(39,'DKK',2,NULL,'Danish Krone','currency.DKK'),
(40,'DOP',2,'RD$','Dominican Peso','currency.DOP'),
(41,'DZD',2,NULL,'Algerian Dinar','currency.DZD'),
(42,'EEK',2,NULL,'Estonian Kroon','currency.EEK'),
(43,'EGP',2,NULL,'Egyptian Pound','currency.EGP'),
(44,'ERN',2,NULL,'Eritrea Nafka','currency.ERN'),
(45,'ETB',2,NULL,'Ethiopian Birr','currency.ETB'),
(46,'EUR',2,'€','Euro','currency.EUR'),
(47,'FJD',2,NULL,'Fiji Dollar','currency.FJD'),
(48,'FKP',2,NULL,'Falkland Islands Pound','currency.FKP'),
(49,'GBP',2,NULL,'Pound Sterling','currency.GBP'),
(50,'GEL',2,NULL,'Georgian Lari','currency.GEL'),
(51,'GHC',2,'GHc','Ghana Cedi','currency.GHC'),
(52,'GIP',2,NULL,'Gibraltar Pound','currency.GIP'),
(53,'GMD',2,NULL,'Gambian Dalasi','currency.GMD'),
(54,'GNF',0,NULL,'Guinea Franc','currency.GNF'),
(55,'GTQ',2,'Q','Guatemala Quetzal','currency.GTQ'),
(56,'GYD',2,NULL,'Guyana Dollar','currency.GYD'),
(57,'HKD',2,NULL,'Hong Kong Dollar','currency.HKD'),
(58,'HNL',2,'L','Honduras Lempira','currency.HNL'),
(59,'HRK',2,NULL,'Croatian Kuna','currency.HRK'),
(60,'HTG',2,'G','Haiti Gourde','currency.HTG'),
(61,'HUF',2,NULL,'Hungarian Forint','currency.HUF'),
(62,'IDR',2,NULL,'Indonesian Rupiah','currency.IDR'),
(63,'ILS',2,NULL,'New Israeli Shekel','currency.ILS'),
(64,'INR',2,'₹','Indian Rupee','currency.INR'),
(65,'IQD',3,NULL,'Iraqi Dinar','currency.IQD'),
(66,'IRR',2,NULL,'Iranian Rial','currency.IRR'),
(67,'ISK',0,NULL,'Iceland Krona','currency.ISK'),
(68,'JMD',2,NULL,'Jamaican Dollar','currency.JMD'),
(69,'JOD',3,NULL,'Jordanian Dinar','currency.JOD'),
(70,'JPY',0,NULL,'Japanese Yen','currency.JPY'),
(71,'KES',2,'KSh','Kenyan Shilling','currency.KES'),
(72,'KGS',2,NULL,'Kyrgyzstan Som','currency.KGS'),
(73,'KHR',2,NULL,'Cambodia Riel','currency.KHR'),
(74,'KMF',0,NULL,'Comoro Franc','currency.KMF'),
(75,'KPW',2,NULL,'North Korean Won','currency.KPW'),
(76,'KRW',0,NULL,'Korean Won','currency.KRW'),
(77,'KWD',3,NULL,'Kuwaiti Dinar','currency.KWD'),
(78,'KYD',2,NULL,'Cayman Islands Dollar','currency.KYD'),
(79,'KZT',2,NULL,'Kazakhstan Tenge','currency.KZT'),
(80,'LAK',2,NULL,'Lao Kip','currency.LAK'),
(81,'LBP',2,'L£','Lebanese Pound','currency.LBP'),
(82,'LKR',2,NULL,'Sri Lanka Rupee','currency.LKR'),
(83,'LRD',2,NULL,'Liberian Dollar','currency.LRD'),
(84,'LSL',2,NULL,'Lesotho Loti','currency.LSL'),
(85,'LTL',2,NULL,'Lithuanian Litas','currency.LTL'),
(86,'LVL',2,NULL,'Latvian Lats','currency.LVL'),
(87,'LYD',3,NULL,'Libyan Dinar','currency.LYD'),
(88,'MAD',2,NULL,'Moroccan Dirham','currency.MAD'),
(89,'MDL',2,NULL,'Moldovan Leu','currency.MDL'),
(90,'MGA',2,NULL,'Malagasy Ariary','currency.MGA'),
(91,'MKD',2,NULL,'Macedonian Denar','currency.MKD'),
(92,'MMK',2,'K','Myanmar Kyat','currency.MMK'),
(93,'MNT',2,NULL,'Mongolian Tugrik','currency.MNT'),
(94,'MOP',2,NULL,'Macau Pataca','currency.MOP'),
(95,'MRO',2,NULL,'Mauritania Ouguiya','currency.MRO'),
(96,'MTL',2,NULL,'Maltese Lira','currency.MTL'),
(97,'MUR',2,NULL,'Mauritius Rupee','currency.MUR'),
(98,'MVR',2,NULL,'Maldives Rufiyaa','currency.MVR'),
(99,'MWK',2,NULL,'Malawi Kwacha','currency.MWK'),
(100,'MXN',2,'$','Mexican Peso','currency.MXN'),
(101,'MYR',2,NULL,'Malaysian Ringgit','currency.MYR'),
(102,'MZM',2,NULL,'Mozambique Metical','currency.MZM'),
(103,'NAD',2,NULL,'Namibia Dollar','currency.NAD'),
(104,'NGN',2,NULL,'Nigerian Naira','currency.NGN'),
(105,'NIO',2,'C$','Nicaragua Cordoba Oro','currency.NIO'),
(106,'NOK',2,NULL,'Norwegian Krone','currency.NOK'),
(107,'NPR',2,NULL,'Nepalese Rupee','currency.NPR'),
(108,'NZD',2,NULL,'New Zealand Dollar','currency.NZD'),
(109,'OMR',3,NULL,'Rial Omani','currency.OMR'),
(110,'PAB',2,'B/.','Panama Balboa','currency.PAB'),
(111,'PEN',2,'S/.','Peruvian Nuevo Sol','currency.PEN'),
(112,'PGK',2,NULL,'Papua New Guinea Kina','currency.PGK'),
(113,'PHP',2,NULL,'Philippine Peso','currency.PHP'),
(114,'PKR',2,NULL,'Pakistan Rupee','currency.PKR'),
(115,'PLN',2,NULL,'Polish Zloty','currency.PLN'),
(116,'PYG',0,'₲','Paraguayan Guarani','currency.PYG'),
(117,'QAR',2,NULL,'Qatari Rial','currency.QAR'),
(118,'RON',2,NULL,'Romanian Leu','currency.RON'),
(119,'RUB',2,NULL,'Russian Ruble','currency.RUB'),
(120,'RWF',0,NULL,'Rwanda Franc','currency.RWF'),
(121,'SAR',2,NULL,'Saudi Riyal','currency.SAR'),
(122,'SBD',2,NULL,'Solomon Islands Dollar','currency.SBD'),
(123,'SCR',2,NULL,'Seychelles Rupee','currency.SCR'),
(124,'SDD',2,NULL,'Sudanese Dinar','currency.SDD'),
(125,'SEK',2,NULL,'Swedish Krona','currency.SEK'),
(126,'SGD',2,NULL,'Singapore Dollar','currency.SGD'),
(127,'SHP',2,NULL,'St Helena Pound','currency.SHP'),
(128,'SIT',2,NULL,'Slovenian Tolar','currency.SIT'),
(129,'SKK',2,NULL,'Slovak Koruna','currency.SKK'),
(130,'SLL',2,NULL,'Sierra Leone Leone','currency.SLL'),
(131,'SOS',2,NULL,'Somali Shilling','currency.SOS'),
(132,'SRD',2,NULL,'Surinam Dollar','currency.SRD'),
(133,'STD',2,NULL,'Sao Tome and Principe Dobra','currency.STD'),
(134,'SVC',2,NULL,'El Salvador Colon','currency.SVC'),
(135,'SYP',2,NULL,'Syrian Pound','currency.SYP'),
(136,'SZL',2,NULL,'Swaziland Lilangeni','currency.SZL'),
(137,'THB',2,NULL,'Thai Baht','currency.THB'),
(138,'TJS',2,NULL,'Tajik Somoni','currency.TJS'),
(139,'TMM',2,NULL,'Turkmenistan Manat','currency.TMM'),
(140,'TND',3,'DT','Tunisian Dinar','currency.TND'),
(141,'TOP',2,NULL,'Tonga Pa\'anga','currency.TOP'),
(142,'TRY',2,NULL,'Turkish Lira','currency.TRY'),
(143,'TTD',2,NULL,'Trinidad and Tobago Dollar','currency.TTD'),
(144,'TWD',2,NULL,'New Taiwan Dollar','currency.TWD'),
(145,'TZS',2,NULL,'Tanzanian Shilling','currency.TZS'),
(146,'UAH',2,NULL,'Ukraine Hryvnia','currency.UAH'),
(147,'UGX',2,'USh','Uganda Shilling','currency.UGX'),
(148,'USD',2,'$','US Dollar','currency.USD'),
(149,'UYU',2,'$U','Peso Uruguayo','currency.UYU'),
(150,'UZS',2,NULL,'Uzbekistan Sum','currency.UZS'),
(151,'VEB',2,'Bs.F.','Venezuelan Bolivar','currency.VEB'),
(152,'VND',2,NULL,'Vietnamese Dong','currency.VND'),
(153,'VUV',0,NULL,'Vanuatu Vatu','currency.VUV'),
(154,'WST',2,NULL,'Samoa Tala','currency.WST'),
(155,'XAF',0,NULL,'CFA Franc BEAC','currency.XAF'),
(156,'XCD',2,NULL,'East Caribbean Dollar','currency.XCD'),
(157,'XDR',5,NULL,'SDR (Special Drawing Rights)','currency.XDR'),
(158,'XOF',0, 'CFA','CFA Franc BCEAO','currency.XOF'),
(159,'XPF',0,NULL,'CFP Franc','currency.XPF'),
(160,'YER',2,NULL,'Yemeni Rial','currency.YER'),
(161,'ZAR',2, 'R','South African Rand','currency.ZAR'),
(162,'ZMK',2,NULL,'Zambian Kwacha','currency.ZMK'),
(163,'ZWD',2,NULL,'Zimbabwe Dollar','currency.ZWD');
-- ======== end of currencies ==
INSERT INTO `m_organisation_currency` (`id`, `code`, `decimal_places`, `name`, `display_symbol`, `internationalized_name_code`)
VALUES (21,'USD',2,'US Dollar','$','currency.USD');
INSERT INTO `m_office` (`id`, `parent_id`, `hierarchy`, `external_id`, `name`, `opening_date`)
VALUES
(1,NULL,'.','1','Head Office','2009-01-01');
INSERT INTO `m_group_level` (`id`, `parent_id`, `super_parent`, `level_name`, `recursable`, `can_have_clients`)
VALUES (1, NULL, 1, 'Center', 1, 0);
INSERT INTO `m_group_level` (`id`, `parent_id`, `super_parent`, `level_name`, `recursable`, `can_have_clients`)
VALUES (2, 1, 0, 'Group', 0, 1);
-- create single code and code value for client identifiers
INSERT INTO `m_code`
(`code_name`, `is_system_defined`)
VALUES
('Customer Identifier',1),
('LoanCollateral',1),
('LoanPurpose',1),
('Gender',1),
('YesNo',1),
('GuarantorRelationship',1);
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'Passport', 1
from m_code mc
where mc.`code_name` = "Customer Identifier";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'Id', 2
from m_code mc
where mc.`code_name` = "Customer Identifier";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'Drivers License', 3
from m_code mc
where mc.`code_name` = "Customer Identifier";
INSERT INTO `m_code_value`(`code_id`,`code_value`,`order_position`)
select mc.id, 'Any Other Id Type', 4
from m_code mc
where mc.`code_name` = "Customer Identifier";
-- Adding a few Default Guarantor Relationships
insert into m_code_value (code_id,code_value,order_position)
select id,"Spouse",0
from m_code
where m_code.code_name="GuarantorRelationship";
insert into m_code_value (code_id,code_value,order_position)
select id,"Parent",0
from m_code
where m_code.code_name="GuarantorRelationship";
insert into m_code_value (code_id,code_value,order_position)
select id,"Sibling",0
from m_code
where m_code.code_name="GuarantorRelationship";
insert into m_code_value (code_id,code_value,order_position)
select id,"Business Associate",0
from m_code
where m_code.code_name="GuarantorRelationship";
insert into m_code_value (code_id,code_value,order_position)
select id,"Other",0
from m_code
where m_code.code_name="GuarantorRelationship";
@@ -0,0 +1,334 @@

-- ========= roles and permissions =========
/*
this scripts removes all current m_role_permission and m_permission entries
and then inserts new m_permission entries and just one m_role_permission entry
which gives the role (id 1 - super user) an ALL_FUNCTIONS permission
If you had other roles set up with specific permissions you will have to set up their permissions again.
*/
-- truncate `m_role_permission`;
-- truncate `m_permission`;
-- truncate `x_registered_table`;
INSERT INTO `m_permission`
(`grouping`,`code`,`entity_name`,`action_name`,`can_maker_checker`) VALUES
('special','ALL_FUNCTIONS',NULL,NULL,0),
('special','ALL_FUNCTIONS_READ',NULL,NULL,0),
('special', 'CHECKER_SUPER_USER', NULL, NULL, '0'),
('special','REPORTING_SUPER_USER',NULL,NULL,0),
('authorisation','READ_PERMISSION','PERMISSION','READ',0),
('authorisation','PERMISSIONS_ROLE','ROLE','PERMISSIONS',1),
('authorisation','CREATE_ROLE','ROLE','CREATE',1),
('authorisation','CREATE_ROLE_CHECKER','ROLE','CREATE',0),
('authorisation','READ_ROLE','ROLE','READ',0),
('authorisation','UPDATE_ROLE','ROLE','UPDATE',1),
('authorisation','UPDATE_ROLE_CHECKER','ROLE','UPDATE',0),
('authorisation','DELETE_ROLE','ROLE','DELETE',1),
('authorisation','DELETE_ROLE_CHECKER','ROLE','DELETE',0),
('authorisation','CREATE_USER','USER','CREATE',1),
('authorisation','CREATE_USER_CHECKER','USER','CREATE',0),
('authorisation','READ_USER','USER','READ',0),
('authorisation','UPDATE_USER','USER','UPDATE',1),
('authorisation','UPDATE_USER_CHECKER','USER','UPDATE',0),
('authorisation','DELETE_USER','USER','DELETE',1),
('authorisation','DELETE_USER_CHECKER','USER','DELETE',0),
('configuration','READ_CONFIGURATION','CONFIGURATION','READ',1),
('configuration','UPDATE_CONFIGURATION','CONFIGURATION','UPDATE',1),
('configuration','UPDATE_CONFIGURATION_CHECKER','CONFIGURATION','UPDATE',0),
('configuration','READ_CODE','CODE','READ',0),
('configuration','CREATE_CODE','CODE','CREATE',1),
('configuration','CREATE_CODE_CHECKER','CODE','CREATE',0),
('configuration','UPDATE_CODE','CODE','UPDATE',1),
('configuration','UPDATE_CODE_CHECKER','CODE','UPDATE',0),
('configuration','DELETE_CODE','CODE','DELETE',1),
('configuration','DELETE_CODE_CHECKER','CODE','DELETE',0),
('configuration', 'READ_CODEVALUE', 'CODEVALUE', 'READ', '0'),
('configuration', 'CREATE_CODEVALUE', 'CODEVALUE', 'CREATE', '1'),
('configuration', 'CREATE_CODEVALUE_CHECKER', 'CODEVALUE', 'CREATE', '0'),
('configuration', 'UPDATE_CODEVALUE', 'CODEVALUE', 'UPDATE', '1'),
('configuration', 'UPDATE_CODEVALUE_CHECKER', 'CODEVALUE', 'UPDATE', '0'),
('configuration', 'DELETE_CODEVALUE', 'CODEVALUE', 'DELETE', '1'),
('configuration', 'DELETE_CODEVALUE_CHECKER', 'CODEVALUE', 'DELETE', '0'),
('configuration','READ_CURRENCY','CURRENCY','READ',0),
('configuration','UPDATE_CURRENCY','CURRENCY','UPDATE',1),
('configuration','UPDATE_CURRENCY_CHECKER','CURRENCY','UPDATE',0),
('configuration', 'UPDATE_PERMISSION', 'PERMISSION', 'UPDATE', '1'),
('configuration', 'UPDATE_PERMISSION_CHECKER', 'PERMISSION', 'UPDATE', '0'),
('configuration', 'READ_DATATABLE', 'DATATABLE', 'READ', '0'),
('configuration', 'REGISTER_DATATABLE', 'DATATABLE', 'REGISTER', '1'),
('configuration', 'REGISTER_DATATABLE_CHECKER', 'DATATABLE', 'REGISTER', '0'),
('configuration', 'DEREGISTER_DATATABLE', 'DATATABLE', 'DEREGISTER', '1'),
('configuration', 'DEREGISTER_DATATABLE_CHECKER', 'DATATABLE', 'DEREGISTER', '0'),
('configuration', 'READ_AUDIT', 'AUDIT', 'READ', '0'),
('configuration', 'CREATE_CALENDAR', 'CALENDAR', 'CREATE', '0'),
('configuration', 'READ_CALENDAR', 'CALENDAR', 'READ', '0'),
('configuration', 'UPDATE_CALENDAR', 'CALENDAR', 'UPDATE', '0'),
('configuration', 'DELETE_CALENDAR', 'CALENDAR', 'DELETE', '0'),
('configuration', 'CREATE_CALENDAR_CHECKER', 'CALENDAR', 'CREATE', '0'),
('configuration', 'UPDATE_CALENDAR_CHECKER', 'CALENDAR', 'UPDATE', '0'),
('configuration', 'DELETE_CALENDAR_CHECKER', 'CALENDAR', 'DELETE', '0'),
('organisation', 'READ_MAKERCHECKER', 'MAKERCHECKER', 'READ', '0'),
('organisation', 'READ_CHARGE', 'CHARGE', 'READ', '0'),
('organisation', 'CREATE_CHARGE', 'CHARGE', 'CREATE', '1'),
('organisation', 'CREATE_CHARGE_CHECKER', 'CHARGE', 'CREATE', '0'),
('organisation', 'UPDATE_CHARGE', 'CHARGE', 'UPDATE', '1'),
('organisation', 'UPDATE_CHARGE_CHECKER', 'CHARGE', 'UPDATE', '0'),
('organisation', 'DELETE_CHARGE', 'CHARGE', 'DELETE', '1'),
('organisation', 'DELETE_CHARGE_CHECKER', 'CHARGE', 'DELETE', '0'),
('organisation', 'READ_FUND', 'FUND', 'READ', '0'),
('organisation', 'CREATE_FUND', 'FUND', 'CREATE', '1'),
('organisation', 'CREATE_FUND_CHECKER', 'FUND', 'CREATE', '0'),
('organisation', 'UPDATE_FUND', 'FUND', 'UPDATE', '1'),
('organisation', 'UPDATE_FUND_CHECKER', 'FUND', 'UPDATE', '0'),
('organisation', 'DELETE_FUND', 'FUND', 'DELETE', '1'),
('organisation', 'DELETE_FUND_CHECKER', 'FUND', 'DELETE', '0'),
('organisation', 'READ_LOANPRODUCT', 'LOANPRODUCT', 'READ', '0'),
('organisation', 'CREATE_LOANPRODUCT', 'LOANPRODUCT', 'CREATE', '1'),
('organisation', 'CREATE_LOANPRODUCT_CHECKER', 'LOANPRODUCT', 'CREATE', '0'),
('organisation', 'UPDATE_LOANPRODUCT', 'LOANPRODUCT', 'UPDATE', '1'),
('organisation', 'UPDATE_LOANPRODUCT_CHECKER', 'LOANPRODUCT', 'UPDATE', '0'),
('organisation', 'DELETE_LOANPRODUCT', 'LOANPRODUCT', 'DELETE', '1'),
('organisation', 'DELETE_LOANPRODUCT_CHECKER', 'LOANPRODUCT', 'DELETE', '0'),
('organisation', 'READ_OFFICE', 'OFFICE', 'READ', '0'),
('organisation', 'CREATE_OFFICE', 'OFFICE', 'CREATE', '1'),
('organisation', 'CREATE_OFFICE_CHECKER', 'OFFICE', 'CREATE', '0'),
('organisation', 'UPDATE_OFFICE', 'OFFICE', 'UPDATE', '1'),
('organisation', 'UPDATE_OFFICE_CHECKER', 'OFFICE', 'UPDATE', '0'),
('organisation', 'READ_OFFICETRANSACTION', 'OFFICETRANSACTION', 'READ', '0'),
('organisation', 'DELETE_OFFICE_CHECKER', 'OFFICE', 'DELETE', '0'),
('organisation', 'CREATE_OFFICETRANSACTION', 'OFFICETRANSACTION', 'CREATE', '1'),
('organisation', 'CREATE_OFFICETRANSACTION_CHECKER', 'OFFICETRANSACTION', 'CREATE', '0'),
('organisation', 'DELETE_OFFICETRANSACTION', 'OFFICETRANSACTION', 'DELETE', 1),
('organisation', 'DELETE_OFFICETRANSACTION_CHECKER', 'OFFICETRANSACTION', 'DELETE', 0),
('organisation', 'READ_STAFF', 'STAFF', 'READ', '0'),
('organisation', 'CREATE_STAFF', 'STAFF', 'CREATE', '1'),
('organisation', 'CREATE_STAFF_CHECKER', 'STAFF', 'CREATE', '0'),
('organisation', 'UPDATE_STAFF', 'STAFF', 'UPDATE', '1'),
('organisation', 'UPDATE_STAFF_CHECKER', 'STAFF', 'UPDATE', '0'),
('organisation', 'DELETE_STAFF', 'STAFF', 'DELETE', '1'),
('organisation', 'DELETE_STAFF_CHECKER', 'STAFF', 'DELETE', '0'),
('organisation', 'READ_SAVINGSPRODUCT', 'SAVINGSPRODUCT', 'READ', '0'),
('organisation', 'CREATE_SAVINGSPRODUCT', 'SAVINGSPRODUCT', 'CREATE', '1'),
('organisation', 'CREATE_SAVINGSPRODUCT_CHECKER', 'SAVINGSPRODUCT', 'CREATE', '0'),
('organisation', 'UPDATE_SAVINGSPRODUCT', 'SAVINGSPRODUCT', 'UPDATE', '1'),
('organisation', 'UPDATE_SAVINGSPRODUCT_CHECKER', 'SAVINGSPRODUCT', 'UPDATE', '0'),
('organisation', 'DELETE_SAVINGSPRODUCT', 'SAVINGSPRODUCT', 'DELETE', '1'),
('organisation', 'DELETE_SAVINGSPRODUCT_CHECKER', 'SAVINGSPRODUCT', 'DELETE', '0'),
('portfolio', 'READ_LOAN', 'LOAN', 'READ', '0'),
('portfolio', 'CREATE_LOAN', 'LOAN', 'CREATE', '1'),
('portfolio', 'CREATE_LOAN_CHECKER', 'LOAN', 'CREATE', '0'),
('portfolio', 'UPDATE_LOAN', 'LOAN', 'UPDATE', '1'),
('portfolio', 'UPDATE_LOAN_CHECKER', 'LOAN', 'UPDATE', '0'),
('portfolio', 'DELETE_LOAN', 'LOAN', 'DELETE', '1'),
('portfolio', 'DELETE_LOAN_CHECKER', 'LOAN', 'DELETE', '0'),
-- ('portfolio', 'CREATEHISTORIC_LOAN', 'LOAN', 'CREATEHISTORIC', '1'),
-- ('portfolio', 'CREATEHISTORIC_LOAN_CHECKER', 'LOAN', 'CREATEHISTORIC', '0'),
-- ('portfolio', 'UPDATEHISTORIC_LOAN', 'LOAN', 'UPDATEHISTORIC', '1'),
-- ('portfolio', 'UPDATEHISTORIC_LOAN_CHECKER', 'LOAN', 'UPDATEHISTORIC', '0'),
('portfolio', 'READ_CLIENT', 'CLIENT', 'READ', '0'),
('portfolio', 'CREATE_CLIENT', 'CLIENT', 'CREATE', '1'),
('portfolio', 'CREATE_CLIENT_CHECKER', 'CLIENT', 'CREATE', '0'),
('portfolio', 'UPDATE_CLIENT', 'CLIENT', 'UPDATE', '1'),
('portfolio', 'UPDATE_CLIENT_CHECKER', 'CLIENT', 'UPDATE', '0'),
('portfolio', 'DELETE_CLIENT', 'CLIENT', 'DELETE', '1'),
('portfolio', 'DELETE_CLIENT_CHECKER', 'CLIENT', 'DELETE', '0'),
('portfolio', 'READ_CLIENTIMAGE', 'CLIENTIMAGE', 'READ', '0'),
('portfolio', 'CREATE_CLIENTIMAGE', 'CLIENTIMAGE', 'CREATE', '1'),
('portfolio', 'CREATE_CLIENTIMAGE_CHECKER', 'CLIENTIMAGE', 'CREATE', '0'),
('portfolio', 'DELETE_CLIENTIMAGE', 'CLIENTIMAGE', 'DELETE', '1'),
('portfolio', 'DELETE_CLIENTIMAGE_CHECKER', 'CLIENTIMAGE', 'DELETE', '0'),
('portfolio', 'READ_CLIENTNOTE', 'CLIENTNOTE', 'READ', '0'),
('portfolio', 'CREATE_CLIENTNOTE', 'CLIENTNOTE', 'CREATE', '1'),
('portfolio', 'CREATE_CLIENTNOTE_CHECKER', 'CLIENTNOTE', 'CREATE', '0'),
('portfolio', 'UPDATE_CLIENTNOTE', 'CLIENTNOTE', 'UPDATE', '1'),
('portfolio', 'UPDATE_CLIENTNOTE_CHECKER', 'CLIENTNOTE', 'UPDATE', '0'),
('portfolio', 'DELETE_CLIENTNOTE', 'CLIENTNOTE', 'DELETE', '1'),
('portfolio', 'DELETE_CLIENTNOTE_CHECKER', 'CLIENTNOTE', 'DELETE', '0'),
('portfolio', 'READ_GROUPNOTE', 'GROUPNOTE', 'READ', '0'),
('portfolio', 'CREATE_GROUPNOTE', 'GROUPNOTE', 'CREATE', '1'),
('portfolio', 'UPDATE_GROUPNOTE', 'GROUPNOTE', 'UPDATE', '1'),
('portfolio', 'DELETE_GROUPNOTE', 'GROUPNOTE', 'DELETE', '1'),
('portfolio', 'CREATE_GROUPNOTE_CHECKER', 'GROUPNOTE', 'CREATE', '0'),
('portfolio', 'UPDATE_GROUPNOTE_CHECKER', 'GROUPNOTE', 'UPDATE', '0'),
('portfolio', 'DELETE_GROUPNOTE_CHECKER', 'GROUPNOTE', 'DELETE', '0'),
('portfolio', 'READ_LOANNOTE', 'LOANNOTE', 'READ', '0'),
('portfolio', 'CREATE_LOANNOTE', 'LOANNOTE', 'CREATE', '1'),
('portfolio', 'UPDATE_LOANNOTE', 'LOANNOTE', 'UPDATE', '1'),
('portfolio', 'DELETE_LOANNOTE', 'LOANNOTE', 'DELETE', '1'),
('portfolio', 'CREATE_LOANNOTE_CHECKER', 'LOANNOTE', 'CREATE', '0'),
('portfolio', 'UPDATE_LOANNOTE_CHECKER', 'LOANNOTE', 'UPDATE', '0'),
('portfolio', 'DELETE_LOANNOTE_CHECKER', 'LOANNOTE', 'DELETE', '0'),
('portfolio', 'READ_LOANTRANSACTIONNOTE', 'LOANTRANSACTIONNOTE', 'READ', '0'),
('portfolio', 'CREATE_LOANTRANSACTIONNOTE', 'LOANTRANSACTIONNOTE', 'CREATE', '1'),
('portfolio', 'UPDATE_LOANTRANSACTIONNOTE', 'LOANTRANSACTIONNOTE', 'UPDATE', '1'),
('portfolio', 'DELETE_LOANTRANSACTIONNOTE', 'LOANTRANSACTIONNOTE', 'DELETE', '1'),
('portfolio', 'CREATE_LOANTRANSACTIONNOTE_CHECKER', 'LOANTRANSACTIONNOTE', 'CREATE', '0'),
('portfolio', 'UPDATE_LOANTRANSACTIONNOTE_CHECKER', 'LOANTRANSACTIONNOTE', 'UPDATE', '0'),
('portfolio', 'DELETE_LOANTRANSACTIONNOTE_CHECKER', 'LOANTRANSACTIONNOTE', 'DELETE', '0'),
('portfolio', 'READ_SAVINGNOTE', 'SAVINGNOTE', 'READ', '0'),
('portfolio', 'CREATE_SAVINGNOTE', 'SAVINGNOTE', 'CREATE', '1'),
('portfolio', 'UPDATE_SAVINGNOTE', 'SAVINGNOTE', 'UPDATE', '1'),
('portfolio', 'DELETE_SAVINGNOTE', 'SAVINGNOTE', 'DELETE', '1'),
('portfolio', 'CREATE_SAVINGNOTE_CHECKER', 'SAVINGNOTE', 'CREATE', '0'),
('portfolio', 'UPDATE_SAVINGNOTE_CHECKER', 'SAVINGNOTE', 'UPDATE', '0'),
('portfolio', 'DELETE_SAVINGNOTE_CHECKER', 'SAVINGNOTE', 'DELETE', '0'),
('portfolio', 'READ_CLIENTIDENTIFIER', 'CLIENTIDENTIFIER', 'READ', '0'),
('portfolio', 'CREATE_CLIENTIDENTIFIER', 'CLIENTIDENTIFIER', 'CREATE', '1'),
('portfolio', 'CREATE_CLIENTIDENTIFIER_CHECKER', 'CLIENTIDENTIFIER', 'CREATE', '0'),
('portfolio', 'UPDATE_CLIENTIDENTIFIER', 'CLIENTIDENTIFIER', 'UPDATE', '1'),
('portfolio', 'UPDATE_CLIENTIDENTIFIER_CHECKER', 'CLIENTIDENTIFIER', 'UPDATE', '0'),
('portfolio', 'DELETE_CLIENTIDENTIFIER', 'CLIENTIDENTIFIER', 'DELETE', '1'),
('portfolio', 'DELETE_CLIENTIDENTIFIER_CHECKER', 'CLIENTIDENTIFIER', 'DELETE', '0'),
('portfolio', 'READ_DOCUMENT', 'DOCUMENT', 'READ', '0'),
('portfolio', 'CREATE_DOCUMENT', 'DOCUMENT', 'CREATE', '1'),
('portfolio', 'CREATE_DOCUMENT_CHECKER', 'DOCUMENT', 'CREATE', '0'),
('portfolio', 'UPDATE_DOCUMENT', 'DOCUMENT', 'UPDATE', '1'),
('portfolio', 'UPDATE_DOCUMENT_CHECKER', 'DOCUMENT', 'UPDATE', '0'),
('portfolio', 'DELETE_DOCUMENT', 'DOCUMENT', 'DELETE', '1'),
('portfolio', 'DELETE_DOCUMENT_CHECKER', 'DOCUMENT', 'DELETE', '0'),
('portfolio', 'READ_GROUP', 'GROUP', 'READ', '0'),
('portfolio', 'CREATE_GROUP', 'GROUP', 'CREATE', '1'),
('portfolio', 'CREATE_GROUP_CHECKER', 'GROUP', 'CREATE', '0'),
('portfolio', 'UPDATE_GROUP', 'GROUP', 'UPDATE', '1'),
('portfolio', 'UPDATE_GROUP_CHECKER', 'GROUP', 'UPDATE', '0'),
('portfolio', 'DELETE_GROUP', 'GROUP', 'DELETE', '1'),
('portfolio', 'DELETE_GROUP_CHECKER', 'GROUP', 'DELETE', '0'),
('portfolio', 'UNASSIGNSTAFF_GROUP', 'GROUP', 'UNASSIGNSTAFF', 1),
('portfolio', 'UNASSIGNSTAFF_GROUP_CHECKER', 'GROUP', 'UNASSIGNSTAFF', 0),
('portfolio', 'CREATE_LOANCHARGE', 'LOANCHARGE', 'CREATE', '1'),
('portfolio', 'CREATE_LOANCHARGE_CHECKER', 'LOANCHARGE', 'CREATE', '0'),
('portfolio', 'UPDATE_LOANCHARGE', 'LOANCHARGE', 'UPDATE', '1'),
('portfolio', 'UPDATE_LOANCHARGE_CHECKER', 'LOANCHARGE', 'UPDATE', '0'),
('portfolio', 'DELETE_LOANCHARGE', 'LOANCHARGE', 'DELETE', '1'),
('portfolio', 'DELETE_LOANCHARGE_CHECKER', 'LOANCHARGE', 'DELETE', '0'),
('portfolio', 'WAIVE_LOANCHARGE', 'LOANCHARGE', 'WAIVE', '1'),
('portfolio', 'WAIVE_LOANCHARGE_CHECKER', 'LOANCHARGE', 'WAIVE', '0'),
('portfolio', 'READ_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'READ', '0'),
('portfolio', 'CREATE_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'CREATE', '1'),
('portfolio', 'CREATE_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'CREATE', '0'),
('portfolio', 'UPDATE_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'UPDATE', '1'),
('portfolio', 'UPDATE_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'UPDATE', '0'),
('portfolio', 'DELETE_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'DELETE', '1'),
('portfolio', 'DELETE_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'DELETE', '0'),
('portfolio', 'READ_GUARANTOR', 'GUARANTOR', 'READ', 0),
('portfolio', 'CREATE_GUARANTOR', 'GUARANTOR', 'CREATE', 1),
('portfolio', 'CREATE_GUARANTOR_CHECKER', 'GUARANTOR', 'CREATE', 0),
('portfolio', 'UPDATE_GUARANTOR', 'GUARANTOR', 'UPDATE', 1),
('portfolio', 'UPDATE_GUARANTOR_CHECKER', 'GUARANTOR', 'UPDATE', 0),
('portfolio', 'DELETE_GUARANTOR', 'GUARANTOR', 'DELETE', 1),
('portfolio', 'DELETE_GUARANTOR_CHECKER', 'GUARANTOR', 'DELETE', 0),
('portfolio', 'READ_COLLATERAL', 'COLLATERAL', 'READ', '0'),
('portfolio', 'CREATE_COLLATERAL', 'COLLATERAL', 'CREATE', '1'),
('portfolio', 'UPDATE_COLLATERAL', 'COLLATERAL', 'UPDATE', '1'),
('portfolio', 'DELETE_COLLATERAL', 'COLLATERAL', 'DELETE', '1'),
('portfolio', 'CREATE_COLLATERAL_CHECKER', 'COLLATERAL', 'CREATE', '0'),
('portfolio', 'UPDATE_COLLATERAL_CHECKER', 'COLLATERAL', 'UPDATE', '0'),
('portfolio', 'DELETE_COLLATERAL_CHECKER', 'COLLATERAL', 'DELETE', '0'),
('transaction_loan', 'APPROVE_LOAN', 'LOAN', 'APPROVE', '1'),
('transaction_loan', 'APPROVEINPAST_LOAN', 'LOAN', 'APPROVEINPAST', '1'),
('transaction_loan', 'REJECT_LOAN', 'LOAN', 'REJECT', '1'),
('transaction_loan', 'REJECTINPAST_LOAN', 'LOAN', 'REJECTINPAST', '1'),
('transaction_loan', 'WITHDRAW_LOAN', 'LOAN', 'WITHDRAW', '1'),
('transaction_loan', 'WITHDRAWINPAST_LOAN', 'LOAN', 'WITHDRAWINPAST', '1'),
('transaction_loan', 'APPROVALUNDO_LOAN', 'LOAN', 'APPROVALUNDO', '1'),
('transaction_loan', 'DISBURSE_LOAN', 'LOAN', 'DISBURSE', '1'),
('transaction_loan', 'DISBURSEINPAST_LOAN', 'LOAN', 'DISBURSEINPAST', '1'),
('transaction_loan', 'DISBURSALUNDO_LOAN', 'LOAN', 'DISBURSALUNDO', '1'),
('transaction_loan', 'REPAYMENT_LOAN', 'LOAN', 'REPAYMENT', '1'),
('transaction_loan', 'REPAYMENTINPAST_LOAN', 'LOAN', 'REPAYMENTINPAST', '1'),
('transaction_loan', 'ADJUST_LOAN', 'LOAN', 'ADJUST', '1'),
('transaction_loan', 'WAIVEINTERESTPORTION_LOAN', 'LOAN', 'WAIVEINTERESTPORTION', '1'),
('transaction_loan', 'WRITEOFF_LOAN', 'LOAN', 'WRITEOFF', '1'),
('transaction_loan', 'CLOSE_LOAN', 'LOAN', 'CLOSE', '1'),
('transaction_loan', 'CLOSEASRESCHEDULED_LOAN', 'LOAN', 'CLOSEASRESCHEDULED', '1'),
('transaction_loan', 'UPDATELOANOFFICER_LOAN', 'LOAN', 'UPDATELOANOFFICER', 1),
('transaction_loan', 'UPDATELOANOFFICER_LOAN_CHECKER', 'LOAN', 'UPDATELOANOFFICER', 0),
('transaction_loan', 'REMOVELOANOFFICER_LOAN', 'LOAN', 'REMOVELOANOFFICER', 1),
('transaction_loan', 'REMOVELOANOFFICER_LOAN_CHECKER', 'LOAN', 'REMOVELOANOFFICER', 0),
('transaction_loan', 'BULKREASSIGN_LOAN', 'LOAN', 'BULKREASSIGN', '1'),
('transaction_loan', 'BULKREASSIGN_LOAN_CHECKER', 'LOAN', 'BULKREASSIGN', '0'),
('transaction_loan', 'APPROVE_LOAN_CHECKER', 'LOAN', 'APPROVE', '0'),
('transaction_loan', 'APPROVEINPAST_LOAN_CHECKER', 'LOAN', 'APPROVEINPAST', '0'),
('transaction_loan', 'REJECT_LOAN_CHECKER', 'LOAN', 'REJECT', '0'),
('transaction_loan', 'REJECTINPAST_LOAN_CHECKER', 'LOAN', 'REJECTINPAST', '0'),
('transaction_loan', 'WITHDRAW_LOAN_CHECKER', 'LOAN', 'WITHDRAW', '0'),
('transaction_loan', 'WITHDRAWINPAST_LOAN_CHECKER', 'LOAN', 'WITHDRAWINPAST', '0'),
('transaction_loan', 'APPROVALUNDO_LOAN_CHECKER', 'LOAN', 'APPROVALUNDO', '0'),
('transaction_loan', 'DISBURSE_LOAN_CHECKER', 'LOAN', 'DISBURSE', '0'),
('transaction_loan', 'DISBURSEINPAST_LOAN_CHECKER', 'LOAN', 'DISBURSEINPAST', '0'),
('transaction_loan', 'DISBURSALUNDO_LOAN_CHECKER', 'LOAN', 'DISBURSALUNDO', '0'),
('transaction_loan', 'REPAYMENT_LOAN_CHECKER', 'LOAN', 'REPAYMENT', '0'),
('transaction_loan', 'REPAYMENTINPAST_LOAN_CHECKER', 'LOAN', 'REPAYMENTINPAST', '0'),
('transaction_loan', 'ADJUST_LOAN_CHECKER', 'LOAN', 'ADJUST', '0'),
('transaction_loan', 'WAIVEINTERESTPORTION_LOAN_CHECKER', 'LOAN', 'WAIVEINTERESTPORTION', '0'),
('transaction_loan', 'WRITEOFF_LOAN_CHECKER', 'LOAN', 'WRITEOFF', '0'),
('transaction_loan', 'CLOSE_LOAN_CHECKER', 'LOAN', 'CLOSE', '0'),
('transaction_loan', 'CLOSEASRESCHEDULED_LOAN_CHECKER', 'LOAN', 'CLOSEASRESCHEDULED', '0'),
('transaction_savings', 'DEPOSIT_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'DEPOSIT', '1'),
('transaction_savings', 'DEPOSIT_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'DEPOSIT', '0'),
('transaction_savings', 'WITHDRAWAL_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'WITHDRAWAL', '1'),
('transaction_savings', 'WITHDRAWAL_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'WITHDRAWAL', '0'),
('transaction_savings', 'ACTIVATE_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'ACTIVATE', '1'),
('transaction_savings', 'ACTIVATE_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'ACTIVATE', '0'),
('transaction_savings', 'CALCULATEINTEREST_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'CALCULATEINTEREST', '1'),
('transaction_savings', 'CALCULATEINTEREST_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'CALCULATEINTEREST', '0');
-- == accounting related permissions
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES
('accounting', 'CREATE_GLACCOUNT', 'GLACCOUNT', 'CREATE', 1),
('accounting', 'UPDATE_GLACCOUNT', 'GLACCOUNT', 'UPDATE', 1),
('accounting', 'DELETE_GLACCOUNT', 'GLACCOUNT', 'DELETE', 1),
('accounting', 'CREATE_GLCLOSURE', 'GLCLOSURE', 'CREATE', 1),
('accounting', 'UPDATE_GLCLOSURE', 'GLCLOSURE', 'UPDATE', 1),
('accounting', 'DELETE_GLCLOSURE', 'GLCLOSURE', 'DELETE', 1),
('accounting', 'CREATE_JOURNALENTRY', 'JOURNALENTRY', 'CREATE', 1),
('accounting', 'REVERSE_JOURNALENTRY', 'JOURNALENTRY', 'REVERSE', 1);
INSERT INTO `m_role` (`id`, `name`, `description`)
VALUES
(1,'Super user','This role provides all application permissions.');
/* role 1 is super user, give it ALL_FUNCTIONS */
INSERT INTO m_role_permission(role_id, permission_id)
select 1, id
from m_permission
where code = 'ALL_FUNCTIONS';
INSERT INTO `m_appuser` (`id`, `office_id`, `username`, `firstname`, `lastname`, `password`, `email`,
`firsttime_login_remaining`, `nonexpired`, `nonlocked`, `nonexpired_credentials`, `enabled`)
VALUES
(1,1,'mifos','App','Administrator','5787039480429368bf94732aacc771cd0a3ea02bcf504ffe1185ab94213bc63a','demomfi@mifos.org','\0','','','','');
INSERT INTO `m_appuser_role` (`appuser_id`, `role_id`) VALUES (1,1);
-- Add in permissions for any special datatables added in base reference data
-- This needs to always happen at end of the script
/* add a create, read, update and delete permission for each registered datatable */
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('CREATE_', r.registered_table_name), r.registered_table_name, 'CREATE'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('READ_', r.registered_table_name), r.registered_table_name, 'READ'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('UPDATE_', r.registered_table_name), r.registered_table_name, 'UPDATE'
from x_registered_table r;
insert into m_permission(grouping, `code`, entity_name, action_name)
select 'datatable', concat('DELETE_', r.registered_table_name), r.registered_table_name, 'DELETE'
from x_registered_table r;
/* regardless of inserted permission settings above, no permissions (transactions) are preselected as being part of the maker-checker process
so, just set the flag to false... the end-user can decide which permissions should be maker-checkerable
*/
update m_permission set can_maker_checker = false;
File diff suppressed because one or more lines are too long