From 071f5556f6136afb363fea087cbf4197a2a694c4 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Sat, 26 Jan 2013 20:23:22 +0000 Subject: [PATCH] drop audit fields for office tables, update api-docs, update DDL and schemas. --- api-docs/apiLive.htm | 9 +- .../0001a-mifosplatform-core-ddl-latest.sql | 8 - .../0002-mifosng-base-reference-data.sql | 161 ++- .../bare-bones-demo/bk_bare_bones_demo.sql | 1110 ++++++++++++++++- .../patches/02-drop-office-audit-columns.sql | 11 + .../office/api/OfficesApiResource.java | 20 +- .../office/command/OfficeCommand.java | 73 -- .../organisation/office/data/OfficeData.java | 14 +- .../organisation/office/domain/Office.java | 13 +- .../OfficeCommandFromApiJsonDeserializer.java | 82 +- .../service/OfficeReadPlatformService.java | 9 +- .../OfficeReadPlatformServiceImpl.java | 33 +- ...WritePlatformServiceJpaRepositoryImpl.java | 20 +- 13 files changed, 1390 insertions(+), 173 deletions(-) create mode 100644 mifosng-db/patches/02-drop-office-audit-columns.sql delete mode 100644 mifosng-provider/src/main/java/org/mifosplatform/organisation/office/command/OfficeCommand.java diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index ba8b7dafb..a33a2c666 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -1613,13 +1613,15 @@ Request Body: { "name": "Example New Branch", "dateFormat": "dd MMMM yyyy", + "locale": "en", "openingDate": "01 July 2007", "parentId": 2, "externalId": "SYS54-88" } { - "resourceId": 9 + "officeId": 3, + "resourceId": 3 } @@ -1640,7 +1642,10 @@ Request Body: } { - "resourceId": 1 + "officeId": 3, + "resourceId": 3, + "changes": { + "name": "Name is updated" } diff --git a/mifosng-db/0001a-mifosplatform-core-ddl-latest.sql b/mifosng-db/0001a-mifosplatform-core-ddl-latest.sql index 41c424f40..2693c9e87 100644 --- a/mifosng-db/0001a-mifosplatform-core-ddl-latest.sql +++ b/mifosng-db/0001a-mifosplatform-core-ddl-latest.sql @@ -165,10 +165,6 @@ CREATE TABLE `m_office` ( `external_id` varchar(100) DEFAULT NULL, `name` varchar(50) NOT NULL, `opening_date` date NOT 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`), UNIQUE KEY `name_org` (`name`), UNIQUE KEY `externalid_org` (`external_id`), @@ -185,10 +181,6 @@ CREATE TABLE `m_office_transaction` ( `transaction_amount` decimal(19,6) NOT NULL, `transaction_date` date NOT NULL, `description` varchar(100) 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 `FK1E37728B93C6C1B6` (`to_office_id`), KEY `FK1E37728B783C5C25` (`from_office_id`), diff --git a/mifosng-db/0002-mifosng-base-reference-data.sql b/mifosng-db/0002-mifosng-base-reference-data.sql index 0ab647577..6d3466719 100644 --- a/mifosng-db/0002-mifosng-base-reference-data.sql +++ b/mifosng-db/0002-mifosng-base-reference-data.sql @@ -1,4 +1,4 @@ --- currency symbols may not apply through command line on windows so use a different client like mysql workbench +-- 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`) @@ -66,7 +66,7 @@ VALUES (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'), +(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'), @@ -79,7 +79,7 @@ Islands Pound','currency.FKP'),(49,'GBP',2,NULL,'Pound Sterling','currency.GBP') (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'), +(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'), @@ -92,7 +92,7 @@ Islands Pound','currency.FKP'),(49,'GBP',2,NULL,'Pound Sterling','currency.GBP') (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'), +(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'), @@ -163,9 +163,9 @@ INSERT INTO `m_code_value` (`id`,`code_id`,`code_value`,`order_position`) VALUES (1,1,'Passport number',0); -INSERT INTO `m_office` (`id`, `parent_id`, `hierarchy`, `external_id`, `name`, `opening_date`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`) +INSERT INTO `m_office` (`id`, `parent_id`, `hierarchy`, `external_id`, `name`, `opening_date`) VALUES -(1,NULL,'.','1','Head Office','2009-01-01',NULL,NULL,'2012-07-13 17:04:20',1); +(1,NULL,'.','1','Head Office','2009-01-01'); -- ========= roles and permissions ========= @@ -191,7 +191,105 @@ INSERT INTO `m_permission` VALUES (9,'transaction_loan','REJECT_LOAN','LOAN','REJECT',1), (10,'transaction_loan','REJECTINPAST_LOAN','LOAN','REJECTINPAST',1), (11,'transaction_loan','WITHDRAW_LOAN','LOAN','WITHDRAW',1), -(12,'transaction_loan','WITHDRAWINPAST_LOAN','LOAN','WITHDRAWINPAST',1),(13,'portfolio','DELETE_LOAN','LOAN','DELETE',1),(14,'transaction_loan','APPROVALUNDO_LOAN','LOAN','APPROVALUNDO',1),(15,'transaction_loan','DISBURSE_LOAN','LOAN','DISBURSE',1),(16,'transaction_loan','DISBURSEINPAST_LOAN','LOAN','DISBURSEINPAST',1),(17,'transaction_loan','DISBURSALUNDO_LOAN','LOAN','DISBURSALUNDO',1),(18,'transaction_loan','REPAYMENT_LOAN','LOAN','REPAYMENT',1),(19,'transaction_loan','REPAYMENTINPAST_LOAN','LOAN','REPAYMENTINPAST',1),(20,'portfolio','CREATE_CLIENT','CLIENT','CREATE',1),(42,'special','ALL_FUNCTIONS',NULL,NULL,0),(43,'special','ALL_FUNCTIONS_READ',NULL,NULL,0),(112,'organisation','CREATE_CHARGE','CHARGE','CREATE',1),(113,'organisation','READ_CHARGE','CHARGE','READ',0),(114,'organisation','UPDATE_CHARGE','CHARGE','UPDATE',1),(115,'organisation','DELETE_CHARGE','CHARGE','DELETE',1),(120,'portfolio','READ_CLIENT','CLIENT','READ',0),(121,'portfolio','UPDATE_CLIENT','CLIENT','UPDATE',1),(122,'portfolio','DELETE_CLIENT','CLIENT','DELETE',1),(123,'portfolio','CREATE_CLIENTIMAGE','CLIENTIMAGE','CREATE',1),(124,'portfolio','READ_CLIENTIMAGE','CLIENTIMAGE','READ',0),(126,'portfolio','DELETE_CLIENTIMAGE','CLIENTIMAGE','DELETE',1),(127,'portfolio','CREATE_CLIENTNOTE','CLIENTNOTE','CREATE',1),(128,'portfolio','READ_CLIENTNOTE','CLIENTNOTE','READ',0),(129,'portfolio','UPDATE_CLIENTNOTE','CLIENTNOTE','UPDATE',1),(130,'portfolio','DELETE_CLIENTNOTE','CLIENTNOTE','DELETE',1),(131,'portfolio','CREATE_CLIENTIDENTIFIER','CLIENTIDENTIFIER','CREATE',1),(132,'portfolio','READ_CLIENTIDENTIFIER','CLIENTIDENTIFIER','READ',0),(133,'portfolio','UPDATE_CLIENTIDENTIFIER','CLIENTIDENTIFIER','UPDATE',1),(134,'portfolio','DELETE_CLIENTIDENTIFIER','CLIENTIDENTIFIER','DELETE',1),(135,'configuration','CREATE_CODE','CODE','CREATE',1),(136,'configuration','READ_CODE','CODE','READ',0),(137,'configuration','UPDATE_CODE','CODE','UPDATE',1),(138,'configuration','DELETE_CODE','CODE','DELETE',1),(139,'configuration','READ_CURRENCY','CURRENCY','READ',0),(140,'configuration','UPDATE_CURRENCY','CURRENCY','UPDATE',1),(141,'portfolio','CREATE_DOCUMENT','DOCUMENT','CREATE',1),(142,'portfolio','READ_DOCUMENT','DOCUMENT','READ',0),(143,'portfolio','UPDATE_DOCUMENT','DOCUMENT','UPDATE',1),(144,'portfolio','DELETE_DOCUMENT','DOCUMENT','DELETE',1),(145,'organisation','CREATE_FUND','FUND','CREATE',1),(146,'organisation','READ_FUND','FUND','READ',0),(147,'organisation','UPDATE_FUND','FUND','UPDATE',1),(148,'organisation','DELETE_FUND','FUND','DELETE',1),(149,'portfolio','CREATE_GROUP','GROUP','CREATE',1),(150,'portfolio','READ_GROUP','GROUP','READ',0),(151,'portfolio','UPDATE_GROUP','GROUP','UPDATE',1),(152,'portfolio','DELETE_GROUP','GROUP','DELETE',1),(153,'organisation','CREATE_LOANPRODUCT','LOANPRODUCT','CREATE',1),(154,'organisation','READ_LOANPRODUCT','LOANPRODUCT','READ',0),(155,'organisation','UPDATE_LOANPRODUCT','LOANPRODUCT','UPDATE',1),(156,'organisation','DELETE_LOANPRODUCT','LOANPRODUCT','DELETE',1),(157,'portfolio','READ_LOAN','LOAN','READ',0),(158,'portfolio','UPDATE_LOAN','LOAN','UPDATE',1),(159,'portfolio','UPDATEHISTORIC_LOAN','LOAN','UPDATEHISTORIC',1),(160,'portfolio','CREATE_LOANCHARGE','LOANCHARGE','CREATE',1),(161,'portfolio','UPDATE_LOANCHARGE','LOANCHARGE','UPDATE',1),(162,'portfolio','DELETE_LOANCHARGE','LOANCHARGE','DELETE',1),(163,'portfolio','WAIVE_LOANCHARGE','LOANCHARGE','WAIVE',1),(164,'transaction_loan','BULKREASSIGN_LOAN','LOAN','BULKREASSIGN',1),(165,'transaction_loan','ADJUST_LOAN','LOAN','ADJUST',1),(166,'transaction_loan','WAIVEINTERESTPORTION_LOAN','LOAN','WAIVEINTERESTPORTION',1),(167,'transaction_loan','WRITEOFF_LOAN','LOAN','WRITEOFF',1),(168,'transaction_loan','CLOSE_LOAN','LOAN','CLOSE',1),(169,'transaction_loan','CLOSEASRESCHEDULED_LOAN','LOAN','CLOSEASRESCHEDULED',1),(170,'organisation','READ_MAKERCHECKER','MAKERCHECKER','READ',0),(171,'organisation','CREATE_OFFICE','OFFICE','CREATE',1),(172,'organisation','READ_OFFICE','OFFICE','READ',0),(173,'organisation','UPDATE_OFFICE','OFFICE','UPDATE',1),(174,'organisation','DELETE_OFFICE','OFFICE','DELETE',1),(175,'organisation','READ_OFFICETRANSACTION','OFFICETRANSACTION','READ',0),(176,'organisation','CREATE_OFFICETRANSACTION','OFFICETRANSACTION','CREATE',1),(177,'authorisation','READ_PERMISSION','PERMISSION','READ',0),(178,'authorisation','CREATE_ROLE','ROLE','CREATE',1),(179,'authorisation','READ_ROLE','ROLE','READ',0),(180,'authorisation','UPDATE_ROLE','ROLE','UPDATE',1),(181,'authorisation','DELETE_ROLE','ROLE','DELETE',1),(182,'authorisation','CREATE_USER','USER','CREATE',1),(183,'authorisation','READ_USER','USER','READ',0),(184,'authorisation','UPDATE_USER','USER','UPDATE',1),(185,'authorisation','DELETE_USER','USER','DELETE',1),(186,'organisation','CREATE_STAFF','STAFF','CREATE',1),(187,'organisation','READ_STAFF','STAFF','READ',0),(188,'organisation','UPDATE_STAFF','STAFF','UPDATE',1),(189,'organisation','DELETE_STAFF','STAFF','DELETE',1),(190,'organisation','CREATE_SAVINGSPRODUCT','SAVINGSPRODUCT','CREATE',1),(191,'organisation','READ_SAVINGSPRODUCT','SAVINGSPRODUCT','READ',0),(192,'organisation','UPDATE_SAVINGSPRODUCT','SAVINGSPRODUCT','UPDATE',1),(193,'organisation','DELETE_SAVINGSPRODUCT','SAVINGSPRODUCT','DELETE',1),(194,'organisation','CREATE_DEPOSITPRODUCT','DEPOSITPRODUCT','CREATE',1),(195,'organisation','READ_DEPOSITPRODUCT','DEPOSITPRODUCT','READ',0),(196,'organisation','UPDATE_DEPOSITPRODUCT','DEPOSITPRODUCT','UPDATE',1),(197,'organisation','DELETE_DEPOSITPRODUCT','DEPOSITPRODUCT','DELETE',1),(198,'portfolio','CREATE_DEPOSITACCOUNT','DEPOSITACCOUNT','CREATE',1),(199,'portfolio','READ_DEPOSITACCOUNT','DEPOSITACCOUNT','READ',0),(200,'portfolio','UPDATE_DEPOSITACCOUNT','DEPOSITACCOUNT','UPDATE',1),(201,'portfolio','DELETE_DEPOSITACCOUNT','DEPOSITACCOUNT','DELETE',1),(202,'transaction_deposit','APPROVE_DEPOSITACCOUNT','DEPOSITACCOUNT','APPROVE',1),(203,'transaction_deposit','REJECT_DEPOSITACCOUNT','DEPOSITACCOUNT','REJECT',1),(204,'transaction_deposit','WITHDRAW_DEPOSITACCOUNT','DEPOSITACCOUNT','WITHDRAW',1),(205,'transaction_deposit','APPROVALUNDO_DEPOSITACCOUNT','DEPOSITACCOUNT','APPROVALUNDO',1),(206,'transaction_deposit','WITHDRAWAL_DEPOSITACCOUNT','DEPOSITACCOUNT','WITHDRAWAL',1),(207,'transaction_deposit','INTEREST_DEPOSITACCOUNT','DEPOSITACCOUNT','INTEREST',1),(208,'transaction_deposit','RENEW_DEPOSITACCOUNT','DEPOSITACCOUNT','RENEW',1),(209,'portfolio','CREATE_SAVINGSACCOUNT','SAVINGSACCOUNT','CREATE',1),(210,'portfolio','READ_SAVINGSACCOUNT','SAVINGSACCOUNT','READ',0),(211,'portfolio','UPDATE_SAVINGSACCOUNT','SAVINGSACCOUNT','UPDATE',1),(212,'portfolio','DELETE_SAVINGSACCOUNT','SAVINGSACCOUNT','DELETE',1), +(12,'transaction_loan','WITHDRAWINPAST_LOAN','LOAN','WITHDRAWINPAST',1),(13,'portfolio','DELETE_LOAN','LOAN','DELETE',1), + +(14,'transaction_loan','APPROVALUNDO_LOAN','LOAN','APPROVALUNDO',1),(15,'transaction_loan','DISBURSE_LOAN','LOAN','DISBURSE',1), + +(16,'transaction_loan','DISBURSEINPAST_LOAN','LOAN','DISBURSEINPAST',1),(17,'transaction_loan','DISBURSALUNDO_LOAN','LOAN','DISBURSALUNDO',1), + +(18,'transaction_loan','REPAYMENT_LOAN','LOAN','REPAYMENT',1),(19,'transaction_loan','REPAYMENTINPAST_LOAN','LOAN','REPAYMENTINPAST',1), + +(20,'portfolio','CREATE_CLIENT','CLIENT','CREATE',1),(42,'special','ALL_FUNCTIONS',NULL,NULL,0),(43,'special','ALL_FUNCTIONS_READ',NULL,NULL,0), + +(112,'organisation','CREATE_CHARGE','CHARGE','CREATE',1),(113,'organisation','READ_CHARGE','CHARGE','READ',0), + +(114,'organisation','UPDATE_CHARGE','CHARGE','UPDATE',1),(115,'organisation','DELETE_CHARGE','CHARGE','DELETE',1),(120,'portfolio','READ_CLIENT','CLIENT','READ',0), + +(121,'portfolio','UPDATE_CLIENT','CLIENT','UPDATE',1),(122,'portfolio','DELETE_CLIENT','CLIENT','DELETE',1), + +(123,'portfolio','CREATE_CLIENTIMAGE','CLIENTIMAGE','CREATE',1),(124,'portfolio','READ_CLIENTIMAGE','CLIENTIMAGE','READ',0), + +(126,'portfolio','DELETE_CLIENTIMAGE','CLIENTIMAGE','DELETE',1),(127,'portfolio','CREATE_CLIENTNOTE','CLIENTNOTE','CREATE',1), + +(128,'portfolio','READ_CLIENTNOTE','CLIENTNOTE','READ',0),(129,'portfolio','UPDATE_CLIENTNOTE','CLIENTNOTE','UPDATE',1), + +(130,'portfolio','DELETE_CLIENTNOTE','CLIENTNOTE','DELETE',1),(131,'portfolio','CREATE_CLIENTIDENTIFIER','CLIENTIDENTIFIER','CREATE',1), + +(132,'portfolio','READ_CLIENTIDENTIFIER','CLIENTIDENTIFIER','READ',0),(133,'portfolio','UPDATE_CLIENTIDENTIFIER','CLIENTIDENTIFIER','UPDATE',1), + +(134,'portfolio','DELETE_CLIENTIDENTIFIER','CLIENTIDENTIFIER','DELETE',1),(135,'configuration','CREATE_CODE','CODE','CREATE',1), + +(136,'configuration','READ_CODE','CODE','READ',0),(137,'configuration','UPDATE_CODE','CODE','UPDATE',1),(138,'configuration','DELETE_CODE','CODE','DELETE',1), + +(139,'configuration','READ_CURRENCY','CURRENCY','READ',0),(140,'configuration','UPDATE_CURRENCY','CURRENCY','UPDATE',1), + +(141,'portfolio','CREATE_DOCUMENT','DOCUMENT','CREATE',1),(142,'portfolio','READ_DOCUMENT','DOCUMENT','READ',0), + +(143,'portfolio','UPDATE_DOCUMENT','DOCUMENT','UPDATE',1),(144,'portfolio','DELETE_DOCUMENT','DOCUMENT','DELETE',1), + +(145,'organisation','CREATE_FUND','FUND','CREATE',1),(146,'organisation','READ_FUND','FUND','READ',0),(147,'organisation','UPDATE_FUND','FUND','UPDATE',1), + +(148,'organisation','DELETE_FUND','FUND','DELETE',1),(149,'portfolio','CREATE_GROUP','GROUP','CREATE',1),(150,'portfolio','READ_GROUP','GROUP','READ',0), + +(151,'portfolio','UPDATE_GROUP','GROUP','UPDATE',1),(152,'portfolio','DELETE_GROUP','GROUP','DELETE',1), + +(153,'organisation','CREATE_LOANPRODUCT','LOANPRODUCT','CREATE',1),(154,'organisation','READ_LOANPRODUCT','LOANPRODUCT','READ',0), + +(155,'organisation','UPDATE_LOANPRODUCT','LOANPRODUCT','UPDATE',1),(156,'organisation','DELETE_LOANPRODUCT','LOANPRODUCT','DELETE',1), + +(157,'portfolio','READ_LOAN','LOAN','READ',0),(158,'portfolio','UPDATE_LOAN','LOAN','UPDATE',1),(159,'portfolio','UPDATEHISTORIC_LOAN','LOAN','UPDATEHISTORIC',1), + +(160,'portfolio','CREATE_LOANCHARGE','LOANCHARGE','CREATE',1),(161,'portfolio','UPDATE_LOANCHARGE','LOANCHARGE','UPDATE',1), + +(162,'portfolio','DELETE_LOANCHARGE','LOANCHARGE','DELETE',1),(163,'portfolio','WAIVE_LOANCHARGE','LOANCHARGE','WAIVE',1), + +(164,'transaction_loan','BULKREASSIGN_LOAN','LOAN','BULKREASSIGN',1),(165,'transaction_loan','ADJUST_LOAN','LOAN','ADJUST',1), + +(166,'transaction_loan','WAIVEINTERESTPORTION_LOAN','LOAN','WAIVEINTERESTPORTION',1),(167,'transaction_loan','WRITEOFF_LOAN','LOAN','WRITEOFF',1), + +(168,'transaction_loan','CLOSE_LOAN','LOAN','CLOSE',1),(169,'transaction_loan','CLOSEASRESCHEDULED_LOAN','LOAN','CLOSEASRESCHEDULED',1), + +(170,'organisation','READ_MAKERCHECKER','MAKERCHECKER','READ',0),(171,'organisation','CREATE_OFFICE','OFFICE','CREATE',1), + +(172,'organisation','READ_OFFICE','OFFICE','READ',0),(173,'organisation','UPDATE_OFFICE','OFFICE','UPDATE',1), + +(174,'organisation','DELETE_OFFICE','OFFICE','DELETE',1),(175,'organisation','READ_OFFICETRANSACTION','OFFICETRANSACTION','READ',0), + +(176,'organisation','CREATE_OFFICETRANSACTION','OFFICETRANSACTION','CREATE',1),(177,'authorisation','READ_PERMISSION','PERMISSION','READ',0), + +(178,'authorisation','CREATE_ROLE','ROLE','CREATE',1),(179,'authorisation','READ_ROLE','ROLE','READ',0),(180,'authorisation','UPDATE_ROLE','ROLE','UPDATE',1), + +(181,'authorisation','DELETE_ROLE','ROLE','DELETE',1),(182,'authorisation','CREATE_USER','USER','CREATE',1),(183,'authorisation','READ_USER','USER','READ',0), + +(184,'authorisation','UPDATE_USER','USER','UPDATE',1),(185,'authorisation','DELETE_USER','USER','DELETE',1),(186,'organisation','CREATE_STAFF','STAFF','CREATE',1), + +(187,'organisation','READ_STAFF','STAFF','READ',0),(188,'organisation','UPDATE_STAFF','STAFF','UPDATE',1),(189,'organisation','DELETE_STAFF','STAFF','DELETE',1), + +(190,'organisation','CREATE_SAVINGSPRODUCT','SAVINGSPRODUCT','CREATE',1),(191,'organisation','READ_SAVINGSPRODUCT','SAVINGSPRODUCT','READ',0), + +(192,'organisation','UPDATE_SAVINGSPRODUCT','SAVINGSPRODUCT','UPDATE',1),(193,'organisation','DELETE_SAVINGSPRODUCT','SAVINGSPRODUCT','DELETE',1), + +(194,'organisation','CREATE_DEPOSITPRODUCT','DEPOSITPRODUCT','CREATE',1),(195,'organisation','READ_DEPOSITPRODUCT','DEPOSITPRODUCT','READ',0), + +(196,'organisation','UPDATE_DEPOSITPRODUCT','DEPOSITPRODUCT','UPDATE',1),(197,'organisation','DELETE_DEPOSITPRODUCT','DEPOSITPRODUCT','DELETE',1), + +(198,'portfolio','CREATE_DEPOSITACCOUNT','DEPOSITACCOUNT','CREATE',1),(199,'portfolio','READ_DEPOSITACCOUNT','DEPOSITACCOUNT','READ',0), + +(200,'portfolio','UPDATE_DEPOSITACCOUNT','DEPOSITACCOUNT','UPDATE',1),(201,'portfolio','DELETE_DEPOSITACCOUNT','DEPOSITACCOUNT','DELETE',1), + +(202,'transaction_deposit','APPROVE_DEPOSITACCOUNT','DEPOSITACCOUNT','APPROVE',1),(203,'transaction_deposit','REJECT_DEPOSITACCOUNT','DEPOSITACCOUNT','REJECT',1), + +(204,'transaction_deposit','WITHDRAW_DEPOSITACCOUNT','DEPOSITACCOUNT','WITHDRAW',1), + +(205,'transaction_deposit','APPROVALUNDO_DEPOSITACCOUNT','DEPOSITACCOUNT','APPROVALUNDO',1), + +(206,'transaction_deposit','WITHDRAWAL_DEPOSITACCOUNT','DEPOSITACCOUNT','WITHDRAWAL',1), + +(207,'transaction_deposit','INTEREST_DEPOSITACCOUNT','DEPOSITACCOUNT','INTEREST',1),(208,'transaction_deposit','RENEW_DEPOSITACCOUNT','DEPOSITACCOUNT','RENEW',1), + +(209,'portfolio','CREATE_SAVINGSACCOUNT','SAVINGSACCOUNT','CREATE',1),(210,'portfolio','READ_SAVINGSACCOUNT','SAVINGSACCOUNT','READ',0), + +(211,'portfolio','UPDATE_SAVINGSACCOUNT','SAVINGSACCOUNT','UPDATE',1),(212,'portfolio','DELETE_SAVINGSACCOUNT','SAVINGSACCOUNT','DELETE',1), (213,'authorisation','PERMISSIONS_ROLE','ROLE','PERMISSIONS',1); INSERT INTO `m_permission` @@ -207,9 +305,9 @@ VALUES ('configuration','READ_CONFIGURATION', 'CONFIGURATION','READ',1); -INSERT INTO `m_role` (`id`, `name`, `description`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`) +INSERT INTO `m_role` (`id`, `name`, `description`) VALUES -(1,'Super user','This role provides all application permissions.',NULL,NULL,NULL,NULL); +(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) @@ -223,17 +321,52 @@ where grouping not in ('special', 'report') and action_name != 'READ'; INSERT INTO `m_appuser` (`id`, `office_id`, `username`, `firstname`, `lastname`, `password`, `email`, -`firsttime_login_remaining`, `nonexpired`, `nonlocked`, `nonexpired_credentials`, `enabled`, -`createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`) +`firsttime_login_remaining`, `nonexpired`, `nonlocked`, `nonexpired_credentials`, `enabled`) VALUES -(1,1,'mifos','App','Administrator','5787039480429368bf94732aacc771cd0a3ea02bcf504ffe1185ab94213bc63a','demomfi@mifos.org','\0','','','','',NULL,NULL,NULL,NULL); +(1,1,'mifos','App','Administrator','5787039480429368bf94732aacc771cd0a3ea02bcf504ffe1185ab94213bc63a','demomfi@mifos.org','\0','','','',''); INSERT INTO `m_appuser_role` (`appuser_id`, `role_id`) VALUES (1,1); INSERT INTO `stretchy_parameter` VALUES -(3,'FullReportList',NULL,'n/a','n/a','n/a','n/a','Y',NULL,NULL,'select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category,\r rp.parameter_id, rp.report_parameter_name, p.parameter_name\r from stretchy_report r\r left join stretchy_report_parameter rp on rp.report_id = r.report_id\r left join stretchy_parameter p on p.parameter_id = rp.parameter_id\r where r.use_report is true\r and exists\r (\r select \'f\'\r from m_appuser_role ur \r join m_role r on r.id = ur.role_id\r join m_role_permission rp on rp.role_id = r.id\r join m_permission p on p.id = rp.permission_id\r where ur.appuser_id = ${currentUserId}\r and (p.code in (\'ALL_FUNCTIONS_READ\', \'ALL_FUNCTIONS\') or p.code = concat(\"READ_\", r.report_name))\r )\r order by r.report_name, rp.parameter_id'),(4,'FullParameterList',NULL,'n/a','n/a','n/a','n/a','Y',NULL,NULL,'select parameter_name, parameter_variable, parameter_label, parameter_displayType, parameter_FormatType, parameter_default, selectOne, selectAll\r\nfrom stretchy_parameter p\r\nwhere special is null\r\norder by parameter_id'),(5,'selectOfficeId','officeId','Office','select','number','0',NULL,'Y',NULL,'select id, \r\nconcat(substring(\"........................................\", 1, \r\n ((LENGTH(`hierarchy`) - LENGTH(REPLACE(`hierarchy`, \'.\', \'\')) - 1) * 4)), \r\n `name`) as tc\r\nfrom m_office\r\nwhere hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\r\norder by hierarchy'),(6,'currencyIdSelectAll','currencyId','Currency','select','number','0',NULL,'Y','Y','select `code`, `name`\r\nfrom m_organisation_currency\r\norder by `code`'),(7,'currencyIdSelectOne','currencyId','Currency','select','number','0',NULL,'Y',NULL,'select `code`, `name`\r\nfrom m_organisation_currency\r\norder by `code`'),(10,'fundIdSelectAll','fundId','Fund','select','number','0',NULL,'Y','Y','(select id, `name`\r\nfrom m_fund\r\norder by `name`)\r\nunion all\r\n(select -10, \'-\')'),(80,'selectStartDate','startDate','startDate','date','date','today',NULL,NULL,NULL,NULL),(81,'selectEndDate','endDate','endDate','date','date','today',NULL,NULL,NULL,NULL), -(82,'reportCategoryList',NULL,'n/a','n/a','n/a','n/a','Y',NULL,NULL,'select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category,\r rp.parameter_id, rp.report_parameter_name, p.parameter_name\r from stretchy_report r\r left join stretchy_report_parameter rp on rp.report_id = r.report_id\r left join stretchy_parameter p on p.parameter_id = rp.parameter_id\r where r.report_category = \'${reportCategory}\'\r and r.use_report is true\r and exists\r (\r select \'f\'\r from m_appuser_role ur \r join m_role r on r.id = ur.role_id\r join m_role_permission rp on rp.role_id = r.id\r join m_permission p on p.id = rp.permission_id\r where ur.appuser_id = ${currentUserId}\r and (p.code in (\'ALL_FUNCTIONS_READ\', \'ALL_FUNCTIONS\') or p.code = concat(\"READ_\", r.report_name))\r )\r order by r.report_name, rp.parameter_id'); +(3,'FullReportList',NULL,'n/a','n/a','n/a','n/a','Y',NULL,NULL,'select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category,\r + +rp.parameter_id, rp.report_parameter_name, p.parameter_name\r from stretchy_report r\r left join stretchy_report_parameter rp on rp.report_id = r.report_id\r left + +join stretchy_parameter p on p.parameter_id = rp.parameter_id\r where r.use_report is true\r and exists\r (\r select \'f\'\r from m_appuser_role ur \r join m_role + +r on r.id = ur.role_id\r join m_role_permission rp on rp.role_id = r.id\r join m_permission p on p.id = rp.permission_id\r where ur.appuser_id = ${currentUserId}\r + +and (p.code in (\'ALL_FUNCTIONS_READ\', \'ALL_FUNCTIONS\') or p.code = concat(\"READ_\", r.report_name))\r )\r order by r.report_name, rp.parameter_id'), + +(4,'FullParameterList',NULL,'n/a','n/a','n/a','n/a','Y',NULL,NULL,'select parameter_name, parameter_variable, parameter_label, parameter_displayType, + +parameter_FormatType, parameter_default, selectOne, selectAll\r\nfrom stretchy_parameter p\r\nwhere special is null\r\norder by parameter_id'), + +(5,'selectOfficeId','officeId','Office','select','number','0',NULL,'Y',NULL,'select id, \r\nconcat(substring(\"........................................\", 1, \r\n + +((LENGTH(`hierarchy`) - LENGTH(REPLACE(`hierarchy`, \'.\', \'\')) - 1) * 4)), \r\n `name`) as tc\r\nfrom m_office\r\nwhere hierarchy like concat + +(\'${currentUserHierarchy}\', \'%\')\r\norder by hierarchy'),(6,'currencyIdSelectAll','currencyId','Currency','select','number','0',NULL,'Y','Y','select `code`, + +`name`\r\nfrom m_organisation_currency\r\norder by `code`'),(7,'currencyIdSelectOne','currencyId','Currency','select','number','0',NULL,'Y',NULL,'select `code`, + +`name`\r\nfrom m_organisation_currency\r\norder by `code`'),(10,'fundIdSelectAll','fundId','Fund','select','number','0',NULL,'Y','Y','(select id, `name`\r\nfrom + +m_fund\r\norder by `name`)\r\nunion all\r\n(select -10, \'-\')'),(80,'selectStartDate','startDate','startDate','date','date','today',NULL,NULL,NULL,NULL), + +(81,'selectEndDate','endDate','endDate','date','date','today',NULL,NULL,NULL,NULL), +(82,'reportCategoryList',NULL,'n/a','n/a','n/a','n/a','Y',NULL,NULL,'select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category,\r + +rp.parameter_id, rp.report_parameter_name, p.parameter_name\r from stretchy_report r\r left join stretchy_report_parameter rp on rp.report_id = r.report_id\r left + +join stretchy_parameter p on p.parameter_id = rp.parameter_id\r where r.report_category = \'${reportCategory}\'\r and r.use_report is true\r and exists\r (\r + +select \'f\'\r from m_appuser_role ur \r join m_role r on r.id = ur.role_id\r join m_role_permission rp on rp.role_id = r.id\r join m_permission p on p.id = + +rp.permission_id\r where ur.appuser_id = ${currentUserId}\r and (p.code in (\'ALL_FUNCTIONS_READ\', \'ALL_FUNCTIONS\') or p.code = concat(\"READ_\", + +r.report_name))\r )\r order by r.report_name, rp.parameter_id'); -- Add datatables for guarantor stuff in here for now rather than DDL as we expect it may change DROP TABLE IF EXISTS `m_guarantor_external`; diff --git a/mifosng-db/multi-tenant-demo-backups/bare-bones-demo/bk_bare_bones_demo.sql b/mifosng-db/multi-tenant-demo-backups/bare-bones-demo/bk_bare_bones_demo.sql index 865ad5509..aa6f97eb4 100644 --- a/mifosng-db/multi-tenant-demo-backups/bare-bones-demo/bk_bare_bones_demo.sql +++ b/mifosng-db/multi-tenant-demo-backups/bare-bones-demo/bk_bare_bones_demo.sql @@ -48,6 +48,91 @@ LOCK TABLES `acc_gl_account` WRITE; /*!40000 ALTER TABLE `acc_gl_account` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `acc_gl_closure` +-- + +DROP TABLE IF EXISTS `acc_gl_closure`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `acc_gl_closure` +-- + +LOCK TABLES `acc_gl_closure` WRITE; +/*!40000 ALTER TABLE `acc_gl_closure` DISABLE KEYS */; +/*!40000 ALTER TABLE `acc_gl_closure` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `acc_gl_journal_entry` +-- + +DROP TABLE IF EXISTS `acc_gl_journal_entry`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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', + `portfolio_generated` tinyint(1) NOT NULL DEFAULT '0', + `entry_date` date NOT NULL, + `type_enum` smallint(50) NOT NULL, + `amount` decimal(19,6) NOT NULL, + `description` varchar(500) DEFAULT NULL, + `entity_type` varchar(50) 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `acc_gl_journal_entry` +-- + +LOCK TABLES `acc_gl_journal_entry` WRITE; +/*!40000 ALTER TABLE `acc_gl_journal_entry` DISABLE KEYS */; +/*!40000 ALTER TABLE `acc_gl_journal_entry` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `acc_product_mapping` -- @@ -99,6 +184,72 @@ INSERT INTO `c_configuration` VALUES (1,'maker-checker',0); /*!40000 ALTER TABLE `c_configuration` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `m_appuser` +-- + +DROP TABLE IF EXISTS `m_appuser`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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 AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_appuser` +-- + +LOCK TABLES `m_appuser` WRITE; +/*!40000 ALTER TABLE `m_appuser` DISABLE KEYS */; +INSERT INTO `m_appuser` VALUES (1,0,1,'mifos','App','Administrator','5787039480429368bf94732aacc771cd0a3ea02bcf504ffe1185ab94213bc63a','demomfi@mifos.org','\0','','','',''); +/*!40000 ALTER TABLE `m_appuser` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_appuser_role` +-- + +DROP TABLE IF EXISTS `m_appuser_role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_appuser_role` +-- + +LOCK TABLES `m_appuser_role` WRITE; +/*!40000 ALTER TABLE `m_appuser_role` DISABLE KEYS */; +INSERT INTO `m_appuser_role` VALUES (1,1); +/*!40000 ALTER TABLE `m_appuser_role` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `m_charge` -- @@ -135,6 +286,87 @@ LOCK TABLES `m_charge` WRITE; /*!40000 ALTER TABLE `m_charge` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `m_client` +-- + +DROP TABLE IF EXISTS `m_client`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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, + `createdby_id` bigint(20) DEFAULT NULL, + `created_date` datetime DEFAULT NULL, + `lastmodified_date` datetime DEFAULT NULL, + `lastmodifiedby_id` bigint(20) 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`), + KEY `FKAUD0000000000001` (`createdby_id`), + KEY `FKAUD0000000000002` (`lastmodifiedby_id`), + CONSTRAINT `FKAUD0000000000001` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FKAUD0000000000002` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FKCE00CAB3E0DD567A` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=347 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_client` +-- + +LOCK TABLES `m_client` WRITE; +/*!40000 ALTER TABLE `m_client` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_client` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_client_identifier` +-- + +DROP TABLE IF EXISTS `m_client_identifier`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_client_identifier` +-- + +LOCK TABLES `m_client_identifier` WRITE; +/*!40000 ALTER TABLE `m_client_identifier` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_client_identifier` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `m_code` -- @@ -219,6 +451,108 @@ INSERT INTO `m_currency` VALUES (1,'AED',2,NULL,'UAE Dirham','currency.AED'),(2, /*!40000 ALTER TABLE `m_currency` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `m_deposit_account` +-- + +DROP TABLE IF EXISTS `m_deposit_account`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_deposit_account` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `is_deleted` tinyint(1) NOT NULL DEFAULT '0', + `status_enum` smallint(5) NOT NULL DEFAULT '0', + `external_id` varchar(100) DEFAULT NULL, + `client_id` bigint(20) NOT NULL, + `product_id` bigint(20) NOT NULL, + `currency_code` varchar(3) NOT NULL, + `currency_digits` smallint(5) NOT NULL, + `deposit_amount` decimal(19,6) DEFAULT NULL, + `maturity_nominal_interest_rate` decimal(19,6) NOT NULL, + `tenure_months` int(11) NOT NULL, + `interest_compounded_every` smallint(5) NOT NULL DEFAULT '1', + `interest_compounded_every_period_enum` smallint(5) NOT NULL DEFAULT '2', + `projected_commencement_date` date NOT NULL, + `actual_commencement_date` date DEFAULT NULL, + `matures_on_date` datetime DEFAULT NULL, + `projected_interest_accrued_on_maturity` decimal(19,6) NOT NULL, + `actual_interest_accrued` decimal(19,6) DEFAULT NULL, + `projected_total_maturity_amount` decimal(19,6) NOT NULL, + `actual_total_amount` decimal(19,6) DEFAULT NULL, + `is_compounding_interest_allowed` tinyint(1) NOT NULL DEFAULT '0', + `interest_paid` decimal(19,6) NOT NULL DEFAULT '0.000000', + `is_interest_withdrawable` tinyint(1) NOT NULL DEFAULT '0', + `available_interest` decimal(19,6) DEFAULT '0.000000', + `interest_posted_amount` decimal(19,6) DEFAULT '0.000000', + `last_interest_posted_date` date DEFAULT NULL, + `next_interest_posting_date` date DEFAULT NULL, + `is_renewal_allowed` tinyint(1) NOT NULL DEFAULT '0', + `renewed_account_id` bigint(20) DEFAULT NULL, + `is_preclosure_allowed` tinyint(1) NOT NULL DEFAULT '0', + `pre_closure_interest_rate` decimal(19,6) NOT NULL, + `is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0', + `lock_in_period` bigint(20) DEFAULT NULL, + `lock_in_period_type` smallint(5) NOT NULL DEFAULT '2', + `withdrawnon_date` datetime DEFAULT NULL, + `rejectedon_date` datetime DEFAULT NULL, + `closedon_date` datetime 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`), + UNIQUE KEY `deposit_acc_external_id` (`external_id`), + KEY `FKKW0000000000001` (`client_id`), + KEY `FKKW0000000000002` (`product_id`), + KEY `FKKW0000000000003` (`renewed_account_id`), + CONSTRAINT `FKKW0000000000001` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`), + CONSTRAINT `FKKW0000000000002` FOREIGN KEY (`product_id`) REFERENCES `m_product_deposit` (`id`), + CONSTRAINT `FKKW0000000000003` FOREIGN KEY (`renewed_account_id`) REFERENCES `m_deposit_account` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_deposit_account` +-- + +LOCK TABLES `m_deposit_account` WRITE; +/*!40000 ALTER TABLE `m_deposit_account` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_deposit_account` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_deposit_account_transaction` +-- + +DROP TABLE IF EXISTS `m_deposit_account_transaction`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_deposit_account_transaction` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `deposit_account_id` bigint(20) NOT NULL, + `transaction_type_enum` smallint(5) NOT NULL, + `contra_id` bigint(20) DEFAULT NULL, + `transaction_date` date NOT NULL, + `amount` decimal(19,6) NOT NULL, + `interest` decimal(19,6) NOT NULL, + `total` decimal(19,6) NOT NULL, + PRIMARY KEY (`id`), + KEY `FKKW00000000000005` (`deposit_account_id`), + KEY `FKKW00000000000006` (`contra_id`), + CONSTRAINT `FKKW00000000000005` FOREIGN KEY (`deposit_account_id`) REFERENCES `m_deposit_account` (`id`), + CONSTRAINT `FKKW00000000000006` FOREIGN KEY (`contra_id`) REFERENCES `m_deposit_account_transaction` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_deposit_account_transaction` +-- + +LOCK TABLES `m_deposit_account_transaction` WRITE; +/*!40000 ALTER TABLE `m_deposit_account_transaction` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_deposit_account_transaction` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `m_document` -- @@ -283,6 +617,394 @@ LOCK TABLES `m_fund` WRITE; /*!40000 ALTER TABLE `m_fund` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `m_group` +-- + +DROP TABLE IF EXISTS `m_group`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_group` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `office_id` bigint(20) NOT NULL, + `name` varchar(100) DEFAULT NULL, + `external_id` varchar(100) DEFAULT NULL, + `is_deleted` tinyint(1) NOT NULL DEFAULT '0', + `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`), + UNIQUE KEY `name` (`name`), + UNIQUE KEY `external_id` (`external_id`), + KEY `FKJPWG000000000003` (`createdby_id`), + KEY `FKJPWG000000000004` (`lastmodifiedby_id`), + KEY `office_id` (`office_id`), + CONSTRAINT `FKJPWG000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FKJPWG000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `m_group_ibfk_1` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_group` +-- + +LOCK TABLES `m_group` WRITE; +/*!40000 ALTER TABLE `m_group` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_group` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_group_client` +-- + +DROP TABLE IF EXISTS `m_group_client`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_group_client` +-- + +LOCK TABLES `m_group_client` WRITE; +/*!40000 ALTER TABLE `m_group_client` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_group_client` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_guarantor_external` +-- + +DROP TABLE IF EXISTS `m_guarantor_external`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_guarantor_external` ( + `loan_id` bigint(20) NOT NULL, + `firstname` varchar(50) NOT NULL, + `lastname` varchar(50) NOT NULL, + `dob` date DEFAULT NULL, + `address_line_1` varchar(500) DEFAULT NULL, + `address_line_2` varchar(500) DEFAULT NULL, + `city` varchar(50) DEFAULT NULL, + `state` varchar(50) DEFAULT NULL, + `country` varchar(50) DEFAULT NULL, + `zip` varchar(20) DEFAULT NULL, + `house_phone_number` varchar(20) DEFAULT NULL, + `mobile_number` varchar(20) DEFAULT NULL, + `comment` varchar(20) DEFAULT NULL, + PRIMARY KEY (`loan_id`), + CONSTRAINT `FK_m_guarantor_m_loan` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_guarantor_external` +-- + +LOCK TABLES `m_guarantor_external` WRITE; +/*!40000 ALTER TABLE `m_guarantor_external` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_guarantor_external` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_loan` +-- + +DROP TABLE IF EXISTS `m_loan`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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, + `guarantor_id` bigint(20) 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, + `total_charges_due_at_disbursement_derived` decimal(19,6) DEFAULT NULL, + `submittedon_date` datetime DEFAULT NULL, + `approvedon_date` datetime 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, + `expected_maturedon_date` date DEFAULT NULL, + `maturedon_date` date DEFAULT NULL, + `closedon_date` datetime DEFAULT NULL, + `rejectedon_date` datetime DEFAULT NULL, + `rescheduledon_date` datetime DEFAULT NULL, + `withdrawnon_date` datetime DEFAULT NULL, + `writtenoffon_date` datetime DEFAULT NULL, + `createdby_id` bigint(20) DEFAULT NULL, + `created_date` datetime DEFAULT NULL, + `lastmodified_date` datetime DEFAULT NULL, + `lastmodifiedby_id` bigint(20) 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_loan_guarantor` (`guarantor_id`), + 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_loan_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`), + CONSTRAINT `FK_m_loan_guarantor` FOREIGN KEY (`guarantor_id`) REFERENCES `m_client` (`id`), + CONSTRAINT `FK_m_loan_m_staff` FOREIGN KEY (`loan_officer_id`) REFERENCES `m_staff` (`id`), + CONSTRAINT `m_loan_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_loan` +-- + +LOCK TABLES `m_loan` WRITE; +/*!40000 ALTER TABLE `m_loan` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_loan` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_loan_charge` +-- + +DROP TABLE IF EXISTS `m_loan_charge`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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', + 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_loan_charge` +-- + +LOCK TABLES `m_loan_charge` WRITE; +/*!40000 ALTER TABLE `m_loan_charge` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_loan_charge` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_loan_officer_assignment_history` +-- + +DROP TABLE IF EXISTS `m_loan_officer_assignment_history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_loan_officer_assignment_history` +-- + +LOCK TABLES `m_loan_officer_assignment_history` WRITE; +/*!40000 ALTER TABLE `m_loan_officer_assignment_history` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_loan_officer_assignment_history` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_loan_repayment_schedule` +-- + +DROP TABLE IF EXISTS `m_loan_repayment_schedule`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_loan_repayment_schedule` +-- + +LOCK TABLES `m_loan_repayment_schedule` WRITE; +/*!40000 ALTER TABLE `m_loan_repayment_schedule` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_loan_repayment_schedule` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_loan_transaction` +-- + +DROP TABLE IF EXISTS `m_loan_transaction`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_loan_transaction` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `loan_id` bigint(20) NOT NULL, + `transaction_type_enum` smallint(5) NOT NULL, + `contra_id` bigint(20) DEFAULT NULL, + `transaction_date` date NOT NULL, + `amount` decimal(19,6) NOT NULL, + `createdby_id` bigint(20) DEFAULT NULL, + `created_date` datetime DEFAULT NULL, + `lastmodified_date` datetime DEFAULT NULL, + `lastmodifiedby_id` bigint(20) DEFAULT 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`), + KEY `FKCFCEA426FC69F3F1` (`contra_id`), + CONSTRAINT `FKCFCEA42640BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`), + CONSTRAINT `FKCFCEA426FC69F3F1` FOREIGN KEY (`contra_id`) REFERENCES `m_loan_transaction` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_loan_transaction` +-- + +LOCK TABLES `m_loan_transaction` WRITE; +/*!40000 ALTER TABLE `m_loan_transaction` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_loan_transaction` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_note` +-- + +DROP TABLE IF EXISTS `m_note`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_note` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `client_id` bigint(20) NOT NULL, + `loan_id` bigint(20) DEFAULT NULL, + `loan_transaction_id` bigint(20) DEFAULT NULL, + `deposit_account_id` bigint(20) DEFAULT NULL, + `saving_account_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 `FK7C970898F889C3F` (`lastmodifiedby_id`), + KEY `FK7C9708940BE0710` (`loan_id`), + KEY `FK_m_note_m_deposit_account` (`deposit_account_id`), + KEY `FK_m_note_m_saving_account` (`saving_account_id`), + CONSTRAINT `FK_m_note_m_saving_account` FOREIGN KEY (`saving_account_id`) REFERENCES `m_saving_account` (`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 `FK7C970898F889C3F` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FK_m_note_m_deposit_account` FOREIGN KEY (`deposit_account_id`) REFERENCES `m_deposit_account` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_note` +-- + +LOCK TABLES `m_note` WRITE; +/*!40000 ALTER TABLE `m_note` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_note` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `m_office` -- @@ -297,10 +1019,6 @@ CREATE TABLE `m_office` ( `external_id` varchar(100) DEFAULT NULL, `name` varchar(50) NOT NULL, `opening_date` date NOT 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`), UNIQUE KEY `name_org` (`name`), UNIQUE KEY `externalid_org` (`external_id`), @@ -315,7 +1033,7 @@ CREATE TABLE `m_office` ( LOCK TABLES `m_office` WRITE; /*!40000 ALTER TABLE `m_office` DISABLE KEYS */; -INSERT INTO `m_office` VALUES (1,NULL,'.','1','Head Office','2009-01-01',NULL,NULL,'2012-07-13 17:04:20',1); +INSERT INTO `m_office` VALUES (1,NULL,'.','1','Head Office','2009-01-01'); /*!40000 ALTER TABLE `m_office` ENABLE KEYS */; UNLOCK TABLES; @@ -335,10 +1053,6 @@ CREATE TABLE `m_office_transaction` ( `transaction_amount` decimal(19,6) NOT NULL, `transaction_date` date NOT NULL, `description` varchar(100) 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 `FK1E37728B93C6C1B6` (`to_office_id`), KEY `FK1E37728B783C5C25` (`from_office_id`), @@ -417,6 +1131,237 @@ INSERT INTO `m_permission` VALUES (4,'special','REPORTING_SUPER_USER',NULL,NULL, /*!40000 ALTER TABLE `m_permission` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `m_portfolio_command_source` +-- + +DROP TABLE IF EXISTS `m_portfolio_command_source`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +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, + `api_get_url` varchar(100) NOT NULL, + `resource_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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_portfolio_command_source` +-- + +LOCK TABLES `m_portfolio_command_source` WRITE; +/*!40000 ALTER TABLE `m_portfolio_command_source` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_portfolio_command_source` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_product_deposit` +-- + +DROP TABLE IF EXISTS `m_product_deposit`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_product_deposit` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `is_deleted` tinyint(1) NOT NULL DEFAULT '0', + `external_id` varchar(100) DEFAULT NULL, + `description` varchar(500) DEFAULT NULL, + `currency_code` varchar(3) NOT NULL, + `currency_digits` smallint(5) NOT NULL, + `minimum_balance` decimal(19,6) DEFAULT NULL, + `maximum_balance` decimal(19,6) DEFAULT NULL, + `tenure_months` int(11) NOT NULL, + `interest_compounded_every` smallint(5) NOT NULL DEFAULT '1', + `interest_compounded_every_period_enum` smallint(5) NOT NULL DEFAULT '2', + `maturity_default_interest_rate` decimal(19,6) NOT NULL, + `maturity_min_interest_rate` decimal(19,6) NOT NULL, + `maturity_max_interest_rate` decimal(19,6) NOT NULL, + `is_compounding_interest_allowed` tinyint(1) NOT NULL DEFAULT '0', + `is_renewal_allowed` tinyint(1) NOT NULL DEFAULT '0', + `is_preclosure_allowed` tinyint(1) NOT NULL DEFAULT '0', + `pre_closure_interest_rate` decimal(19,6) NOT NULL, + `is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0', + `lock_in_period` bigint(20) DEFAULT NULL, + `lock_in_period_type` smallint(5) NOT NULL DEFAULT '2', + `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`), + UNIQUE KEY `name_deposit_product` (`name`), + UNIQUE KEY `externalid_deposit_product` (`external_id`), + KEY `FKJPW0000000000003` (`createdby_id`), + KEY `FKJPW0000000000004` (`lastmodifiedby_id`), + CONSTRAINT `FKJPX0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FKJPX0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_product_deposit` +-- + +LOCK TABLES `m_product_deposit` WRITE; +/*!40000 ALTER TABLE `m_product_deposit` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_product_deposit` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_product_loan` +-- + +DROP TABLE IF EXISTS `m_product_loan`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +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, + `createdby_id` bigint(20) DEFAULT NULL, + `created_date` datetime DEFAULT NULL, + `lastmodified_date` datetime DEFAULT NULL, + `lastmodifiedby_id` bigint(20) DEFAULT NULL, + `loan_transaction_strategy_id` bigint(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FKAUD0000000000003` (`createdby_id`), + KEY `FKAUD0000000000004` (`lastmodifiedby_id`), + KEY `FKA6A8A7D77240145` (`fund_id`), + KEY `FK_ltp_strategy` (`loan_transaction_strategy_id`), + CONSTRAINT `FKA6A8A7D77240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`), + CONSTRAINT `FKAUD0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FKAUD0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FK_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_product_loan` +-- + +LOCK TABLES `m_product_loan` WRITE; +/*!40000 ALTER TABLE `m_product_loan` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_product_loan` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_product_loan_charge` +-- + +DROP TABLE IF EXISTS `m_product_loan_charge`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = 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; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_product_loan_charge` +-- + +LOCK TABLES `m_product_loan_charge` WRITE; +/*!40000 ALTER TABLE `m_product_loan_charge` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_product_loan_charge` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_product_savings` +-- + +DROP TABLE IF EXISTS `m_product_savings`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_product_savings` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `description` varchar(500) DEFAULT NULL, + `currency_code` varchar(3) DEFAULT NULL, + `currency_digits` smallint(5) DEFAULT NULL, + `interest_rate` decimal(19,6) DEFAULT NULL, + `min_interest_rate` decimal(19,6) DEFAULT NULL, + `max_interest_rate` decimal(19,6) DEFAULT NULL, + `savings_deposit_amount` decimal(19,6) NOT NULL, + `savings_product_type` smallint(5) DEFAULT NULL, + `tenure_type` smallint(5) DEFAULT NULL, + `deposit_every` bigint(20) DEFAULT NULL, + `tenure` int(11) DEFAULT NULL, + `frequency` int(11) DEFAULT NULL, + `interest_type` smallint(5) DEFAULT NULL, + `interest_calculation_method` smallint(5) DEFAULT NULL, + `min_bal_for_withdrawal` decimal(19,6) NOT NULL, + `is_partial_deposit_allowed` tinyint(1) NOT NULL DEFAULT '0', + `is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0', + `lock_in_period` bigint(20) DEFAULT NULL, + `lock_in_period_type` smallint(5) NOT NULL DEFAULT '1', + `is_deleted` tinyint(1) NOT NULL DEFAULT '0', + `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 `FKJPW0000000000003` (`createdby_id`), + KEY `FKJPW0000000000004` (`lastmodifiedby_id`), + CONSTRAINT `FKJPW0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`), + CONSTRAINT `FKJPW0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_product_savings` +-- + +LOCK TABLES `m_product_savings` WRITE; +/*!40000 ALTER TABLE `m_product_savings` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_product_savings` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `m_role` -- @@ -429,7 +1374,7 @@ CREATE TABLE `m_role` ( `name` varchar(100) NOT NULL, `description` varchar(500) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -438,6 +1383,7 @@ CREATE TABLE `m_role` ( LOCK TABLES `m_role` WRITE; /*!40000 ALTER TABLE `m_role` DISABLE KEYS */; +INSERT INTO `m_role` VALUES (1,'Super user','This role provides all application permissions.'); /*!40000 ALTER TABLE `m_role` ENABLE KEYS */; UNLOCK TABLES; @@ -465,9 +1411,151 @@ CREATE TABLE `m_role_permission` ( LOCK TABLES `m_role_permission` WRITE; /*!40000 ALTER TABLE `m_role_permission` DISABLE KEYS */; +INSERT INTO `m_role_permission` VALUES (1,42); /*!40000 ALTER TABLE `m_role_permission` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `m_saving_account` +-- + +DROP TABLE IF EXISTS `m_saving_account`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_saving_account` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `is_deleted` tinyint(1) NOT NULL DEFAULT '0', + `status_enum` smallint(5) NOT NULL DEFAULT '0', + `external_id` varchar(100) DEFAULT NULL, + `client_id` bigint(20) NOT NULL, + `product_id` bigint(20) NOT NULL, + `deposit_amount_per_period` decimal(19,6) NOT NULL, + `savings_product_type` smallint(5) DEFAULT NULL, + `currency_code` varchar(3) NOT NULL, + `currency_digits` smallint(5) NOT NULL, + `total_deposit_amount` decimal(19,6) NOT NULL, + `reccuring_nominal_interest_rate` decimal(19,6) NOT NULL, + `regular_saving_nominal_interest_rate` decimal(19,6) NOT NULL, + `tenure` int(11) NOT NULL, + `tenure_type` smallint(5) DEFAULT NULL, + `deposit_every` bigint(20) DEFAULT NULL, + `frequency` int(11) DEFAULT NULL, + `interest_posting_every` int(11) DEFAULT NULL, + `interest_posting_frequency` int(11) DEFAULT NULL, + `interest_type` smallint(5) DEFAULT NULL, + `interest_calculation_method` smallint(5) DEFAULT NULL, + `projected_commencement_date` date NOT NULL, + `actual_commencement_date` date DEFAULT NULL, + `matures_on_date` datetime DEFAULT NULL, + `projected_interest_accrued_on_maturity` decimal(19,6) NOT NULL, + `actual_interest_accrued` decimal(19,6) DEFAULT NULL, + `projected_total_maturity_amount` decimal(19,6) NOT NULL, + `actual_total_amount` decimal(19,6) DEFAULT NULL, + `is_preclosure_allowed` tinyint(1) NOT NULL DEFAULT '0', + `pre_closure_interest_rate` decimal(19,6) NOT NULL, + `outstanding_amount` decimal(19,6) NOT NULL, + `interest_posted_amount` decimal(19,6) DEFAULT '0.000000', + `last_interest_posted_date` date DEFAULT NULL, + `next_interest_posting_date` date DEFAULT NULL, + `is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0', + `lock_in_period` bigint(20) DEFAULT NULL, + `lock_in_period_type` smallint(5) NOT NULL DEFAULT '1', + `withdrawnon_date` datetime DEFAULT NULL, + `rejectedon_date` datetime DEFAULT NULL, + `closedon_date` datetime 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`), + UNIQUE KEY `deposit_acc_external_id` (`external_id`), + KEY `FKSA0000000000001` (`client_id`), + KEY `FKSA0000000000002` (`product_id`), + CONSTRAINT `FKSA0000000000001` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`), + CONSTRAINT `FKSA0000000000002` FOREIGN KEY (`product_id`) REFERENCES `m_product_savings` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_saving_account` +-- + +LOCK TABLES `m_saving_account` WRITE; +/*!40000 ALTER TABLE `m_saving_account` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_saving_account` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_saving_account_transaction` +-- + +DROP TABLE IF EXISTS `m_saving_account_transaction`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_saving_account_transaction` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `saving_account_id` bigint(20) NOT NULL, + `transaction_type_enum` smallint(5) NOT NULL, + `contra_id` bigint(20) DEFAULT NULL, + `transaction_date` date NOT NULL, + `amount` decimal(19,6) NOT 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 `FKSAT0000000001` (`saving_account_id`), + KEY `FKSAT0000000002` (`contra_id`), + CONSTRAINT `FKSAT0000000001` FOREIGN KEY (`saving_account_id`) REFERENCES `m_saving_account` (`id`), + CONSTRAINT `FKSAT0000000002` FOREIGN KEY (`contra_id`) REFERENCES `m_saving_account_transaction` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_saving_account_transaction` +-- + +LOCK TABLES `m_saving_account_transaction` WRITE; +/*!40000 ALTER TABLE `m_saving_account_transaction` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_saving_account_transaction` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `m_saving_schedule` +-- + +DROP TABLE IF EXISTS `m_saving_schedule`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m_saving_schedule` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `saving_account_id` bigint(20) NOT NULL, + `duedate` date NOT NULL, + `installment` smallint(5) NOT NULL, + `deposit` decimal(21,4) NOT NULL, + `payment_date` date DEFAULT NULL, + `deposit_paid` decimal(21,4) DEFAULT NULL, + `interest_accured` decimal(21,4) DEFAULT '0.0000', + `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, + PRIMARY KEY (`id`), + KEY `FKSS00000000001` (`saving_account_id`), + CONSTRAINT `FKSS00000000001` FOREIGN KEY (`saving_account_id`) REFERENCES `m_saving_account` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `m_saving_schedule` +-- + +LOCK TABLES `m_saving_schedule` WRITE; +/*!40000 ALTER TABLE `m_saving_schedule` DISABLE KEYS */; +/*!40000 ALTER TABLE `m_saving_schedule` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `m_staff` -- @@ -705,4 +1793,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2013-01-26 3:06:52 +-- Dump completed on 2013-01-26 20:21:03 diff --git a/mifosng-db/patches/02-drop-office-audit-columns.sql b/mifosng-db/patches/02-drop-office-audit-columns.sql new file mode 100644 index 000000000..e1927b9c2 --- /dev/null +++ b/mifosng-db/patches/02-drop-office-audit-columns.sql @@ -0,0 +1,11 @@ +ALTER TABLE `m_office` +DROP COLUMN `lastmodifiedby_id` , +DROP COLUMN `lastmodified_date` , +DROP COLUMN `created_date`, +DROP COLUMN `createdby_id`; + +ALTER TABLE `m_office_transaction` +DROP COLUMN `lastmodifiedby_id` , +DROP COLUMN `lastmodified_date` , +DROP COLUMN `created_date`, +DROP COLUMN `createdby_id`; \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java index 30dc6d949..4b6cc1ff7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java @@ -1,10 +1,8 @@ package org.mifosplatform.organisation.office.api; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import java.util.List; import java.util.Set; import javax.ws.rs.Consumes; @@ -21,14 +19,12 @@ import javax.ws.rs.core.UriInfo; import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeData; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.organisation.office.data.OfficeData; -import org.mifosplatform.organisation.office.data.OfficeLookup; import org.mifosplatform.organisation.office.service.OfficeReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @@ -40,7 +36,8 @@ import org.springframework.stereotype.Component; public class OfficesApiResource { /** - * The set of parameters that are supported in response for {@link CodeData} + * The set of parameters that are supported in response for + * {@link OfficeData}. */ private final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate", "hierarchy", "parentId", "parentName", "allowedParents")); @@ -87,7 +84,7 @@ public class OfficesApiResource { OfficeData office = this.readPlatformService.retrieveNewOfficeTemplate(); - final List allowedParents = new ArrayList(this.readPlatformService.retrieveAllOfficesForLookup()); + final Collection allowedParents = this.readPlatformService.retrieveAllOfficesForDropdown(); office = OfficeData.appendedTemplate(office, allowedParents); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); @@ -99,7 +96,9 @@ public class OfficesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String createOffice(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createOffice().withJson(apiRequestBodyAsJson) + final CommandWrapper commandRequest = new CommandWrapperBuilder() // + .createOffice() // + .withJson(apiRequestBodyAsJson) // .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -119,7 +118,7 @@ public class OfficesApiResource { OfficeData office = this.readPlatformService.retrieveOffice(officeId); if (settings.isTemplate()) { - List allowedParents = this.readPlatformService.retrieveAllowedParents(officeId); + Collection allowedParents = this.readPlatformService.retrieveAllowedParents(officeId); office = OfficeData.appendedTemplate(office, allowedParents); } @@ -132,7 +131,10 @@ public class OfficesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateOffice(@PathParam("officeId") final Long officeId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateOffice(officeId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder() // + .updateOffice(officeId) // + .withJson(apiRequestBodyAsJson) // + .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/command/OfficeCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/command/OfficeCommand.java deleted file mode 100644 index becd5ec70..000000000 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/command/OfficeCommand.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.mifosplatform.organisation.office.command; - -import java.util.ArrayList; -import java.util.List; - -import org.joda.time.LocalDate; -import org.mifosplatform.infrastructure.core.data.ApiParameterError; -import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; -import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; - -/** - * Immutable command for creating or updating details of a office. - */ -public class OfficeCommand { - - private final String name; - private final String externalId; - private final LocalDate openingDate; - private final Long parentId; - - public OfficeCommand(final String officeName, final String externalId, final Long parentId, final LocalDate openingDate) { - this.name = officeName; - this.externalId = externalId; - this.parentId = parentId; - this.openingDate = openingDate; - } - - public String getName() { - return name; - } - - public String getExternalId() { - return externalId; - } - - public LocalDate getOpeningDate() { - return openingDate; - } - - public Long getParentId() { - return parentId; - } - - public void validateForCreate() { - List dataValidationErrors = new ArrayList(); - - DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("office"); - - baseDataValidator.reset().parameter("name").value(this.name).notBlank(); - baseDataValidator.reset().parameter("openingDate").value(this.openingDate).notBlank(); - baseDataValidator.reset().parameter("externalId").value(this.externalId).notExceedingLengthOf(100); - baseDataValidator.reset().parameter("parentId").value(this.parentId).notNull().integerGreaterThanZero(); - - if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", - "Validation errors exist.", dataValidationErrors); } - } - - public void validateForUpdate() { - List dataValidationErrors = new ArrayList(); - - DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("office"); - - baseDataValidator.reset().parameter("name").value(this.name).ignoreIfNull().notBlank(); - baseDataValidator.reset().parameter("openingDate").value(this.openingDate).ignoreIfNull().notBlank(); - baseDataValidator.reset().parameter("externalId").value(this.externalId).ignoreIfNull().notExceedingLengthOf(100); - baseDataValidator.reset().parameter("parentId").value(this.parentId).ignoreIfNull().notNull().integerGreaterThanZero(); - - baseDataValidator.reset().anyOfNotNull(this.name, this.openingDate, this.externalId, this.parentId); - - if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", - "Validation errors exist.", dataValidationErrors); } - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java index 1f811932c..2275443fc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeData.java @@ -1,5 +1,6 @@ package org.mifosplatform.organisation.office.data; +import java.util.Collection; import java.util.List; import org.joda.time.LocalDate; @@ -17,25 +18,24 @@ public class OfficeData { private final String hierarchy; private final Long parentId; private final String parentName; - @SuppressWarnings("unused") - private final List allowedParents; + private final Collection allowedParents; public static OfficeData dropdown(final Long id, final String name, final String nameDecorated) { return new OfficeData(id, name, nameDecorated, null, null, null, null, null, null); } - public static OfficeData template(final List parentLookups, final LocalDate defaultOpeningDate) { + public static OfficeData template(final List parentLookups, final LocalDate defaultOpeningDate) { return new OfficeData(null, null, null, null, defaultOpeningDate, null, null, null, parentLookups); } - public static OfficeData appendedTemplate(final OfficeData office, final List allowedParents) { + public static OfficeData appendedTemplate(final OfficeData office, final Collection allowedParents) { return new OfficeData(office.id, office.name, office.nameDecorated, office.externalId, office.openingDate, office.hierarchy, office.parentId, office.parentName, allowedParents); } public OfficeData(final Long id, final String name, final String nameDecorated, final String externalId, final LocalDate openingDate, - String hierarchy, final Long parentId, final String parentName, final List allowedParents) { + final String hierarchy, final Long parentId, final String parentName, final Collection allowedParents) { this.id = id; this.name = name; this.nameDecorated = nameDecorated; @@ -46,4 +46,8 @@ public class OfficeData { this.parentId = parentId; this.allowedParents = allowedParents; } + + public boolean hasIdentifyOf(final Long officeId) { + return this.id.equals(officeId); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/domain/Office.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/domain/Office.java index df1c67648..10184b1ec 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/domain/Office.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/domain/Office.java @@ -20,15 +20,14 @@ import javax.persistence.UniqueConstraint; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; import org.mifosplatform.infrastructure.core.api.JsonCommand; -import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.organisation.office.exception.CannotUpdateOfficeWithParentOfficeSameAsSelf; import org.mifosplatform.organisation.office.exception.RootOfficeParentCannotBeUpdated; -import org.mifosplatform.useradministration.domain.AppUser; +import org.springframework.data.jpa.domain.AbstractPersistable; @Entity @Table(name = "m_office", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "name_org"), @UniqueConstraint(columnNames = { "external_id" }, name = "externalid_org") }) -public class Office extends AbstractAuditableCustom { +public class Office extends AbstractPersistable { @OneToMany(fetch = FetchType.EAGER) @JoinColumn(name = "parent_id") @@ -101,11 +100,9 @@ public class Office extends AbstractAuditableCustom { final String localeAsInput = command.locale(); final String parentIdParamName = "parentId"; - - if (command.parameterExists(parentIdParamName) && this.parent == null) { - throw new RootOfficeParentCannotBeUpdated(); - } - + + if (command.parameterExists(parentIdParamName) && this.parent == null) { throw new RootOfficeParentCannotBeUpdated(); } + if (this.parent != null && command.isChangeInLongParameterNamed(parentIdParamName, this.parent.getId())) { final Long newValue = command.longValueOfParameterNamed(parentIdParamName); actualChanges.put(parentIdParamName, newValue); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/serialization/OfficeCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/serialization/OfficeCommandFromApiJsonDeserializer.java index 5e618a312..2f769fb82 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/serialization/OfficeCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/serialization/OfficeCommandFromApiJsonDeserializer.java @@ -1,18 +1,20 @@ package org.mifosplatform.organisation.office.serialization; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; import org.mifosplatform.infrastructure.core.exception.InvalidJsonException; -import org.mifosplatform.infrastructure.core.serialization.AbstractFromApiJsonDeserializer; -import org.mifosplatform.infrastructure.core.serialization.FromApiJsonDeserializer; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; -import org.mifosplatform.organisation.office.command.OfficeCommand; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,11 +22,10 @@ import com.google.gson.JsonElement; import com.google.gson.reflect.TypeToken; /** - * Implementation of {@link FromApiJsonDeserializer} for {@link OfficeCommand} - * 's. + * Deserializer of JSON for office API. */ @Component -public final class OfficeCommandFromApiJsonDeserializer extends AbstractFromApiJsonDeserializer { +public final class OfficeCommandFromApiJsonDeserializer { /** * The parameters supported for this command. @@ -39,19 +40,72 @@ public final class OfficeCommandFromApiJsonDeserializer extends AbstractFromApiJ this.fromApiJsonHelper = fromApiJsonHelper; } - @Override - public OfficeCommand commandFromApiJson(final String json) { + public void validateForCreate(final String json) { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } final Type typeOfMap = new TypeToken>() {}.getType(); fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters); - final JsonElement element = fromApiJsonHelper.parse(json); - final String name = fromApiJsonHelper.extractStringNamed("name", element); - final String externalId = fromApiJsonHelper.extractStringNamed("externalId", element); - final Long parentId = fromApiJsonHelper.extractLongNamed("parentId", element); - final LocalDate openingLocalDate = fromApiJsonHelper.extractLocalDateNamed("openingDate", element); + final List dataValidationErrors = new ArrayList(); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("office"); - return new OfficeCommand(name, externalId, parentId, openingLocalDate); + final JsonElement element = fromApiJsonHelper.parse(json); + + final String name = fromApiJsonHelper.extractStringNamed("name", element); + baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100); + + final LocalDate openingDate = fromApiJsonHelper.extractLocalDateNamed("openingDate", element); + baseDataValidator.reset().parameter("openingDate").value(openingDate).notNull(); + + if (fromApiJsonHelper.parameterExists("externalId", element)) { + final String externalId = fromApiJsonHelper.extractStringNamed("externalId", element); + baseDataValidator.reset().parameter("externalId").value(externalId).notExceedingLengthOf(100); + } + + if (fromApiJsonHelper.parameterExists("parentId", element)) { + final Long parentId = fromApiJsonHelper.extractLongNamed("parentId", element); + baseDataValidator.reset().parameter("parentId").value(parentId).notNull().integerGreaterThanZero(); + } + + throwExceptionIfValidationWarningsExist(dataValidationErrors); + } + + private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { + if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); } + } + + public void validateForUpdate(final String json) { + if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } + + final Type typeOfMap = new TypeToken>() {}.getType(); + fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters); + + final List dataValidationErrors = new ArrayList(); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("office"); + + final JsonElement element = fromApiJsonHelper.parse(json); + + if (fromApiJsonHelper.parameterExists("name", element)) { + final String name = fromApiJsonHelper.extractStringNamed("name", element); + baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100); + } + + if (fromApiJsonHelper.parameterExists("openingDate", element)) { + final LocalDate openingDate = fromApiJsonHelper.extractLocalDateNamed("openingDate", element); + baseDataValidator.reset().parameter("openingDate").value(openingDate).notNull(); + } + + if (fromApiJsonHelper.parameterExists("externalId", element)) { + final String externalId = fromApiJsonHelper.extractStringNamed("externalId", element); + baseDataValidator.reset().parameter("externalId").value(externalId).notExceedingLengthOf(100); + } + + if (fromApiJsonHelper.parameterExists("parentId", element)) { + final Long parentId = fromApiJsonHelper.extractLongNamed("parentId", element); + baseDataValidator.reset().parameter("parentId").value(parentId).notNull().integerGreaterThanZero(); + } + + throwExceptionIfValidationWarningsExist(dataValidationErrors); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java index cceb785c5..97848eacc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java @@ -1,7 +1,6 @@ package org.mifosplatform.organisation.office.service; import java.util.Collection; -import java.util.List; import org.mifosplatform.organisation.office.data.OfficeData; import org.mifosplatform.organisation.office.data.OfficeLookup; @@ -12,14 +11,18 @@ public interface OfficeReadPlatformService { Collection retrieveAllOffices(); Collection retrieveAllOfficesForDropdown(); - + + /* + * Deprecated so cane eventually remove need for OfficeLookup type - so use + * retrieveAllOfficesForDropdown instead. + */ Collection retrieveAllOfficesForLookup(); OfficeData retrieveOffice(Long officeId); OfficeData retrieveNewOfficeTemplate(); - List retrieveAllowedParents(Long officeId); + Collection retrieveAllowedParents(Long officeId); Collection retrieveAllOfficeTransactions(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java index 022346949..ccabec63d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java @@ -52,17 +52,16 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService @Override public OfficeData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { - Long id = rs.getLong("id"); - String name = rs.getString("name"); - String nameDecorated = rs.getString("nameDecorated"); - String externalId = rs.getString("externalId"); - LocalDate openingDate = JdbcSupport.getLocalDate(rs, "openingDate"); - String hierarchy = rs.getString("hierarchy"); - Long parentId = JdbcSupport.getLong(rs, "parentId"); - String parentName = rs.getString("parentName"); + final Long id = rs.getLong("id"); + final String name = rs.getString("name"); + final String nameDecorated = rs.getString("nameDecorated"); + final String externalId = rs.getString("externalId"); + final LocalDate openingDate = JdbcSupport.getLocalDate(rs, "openingDate"); + final String hierarchy = rs.getString("hierarchy"); + final Long parentId = JdbcSupport.getLong(rs, "parentId"); + final String parentName = rs.getString("parentName"); - List allowedParents = new ArrayList(); - return new OfficeData(id, name, nameDecorated, externalId, openingDate, hierarchy, parentId, parentName, allowedParents); + return new OfficeData(id, name, nameDecorated, externalId, openingDate, hierarchy, parentId, parentName, null); } } @@ -202,22 +201,19 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService context.authenticatedUser(); - List parentLookups = new ArrayList(); - - return OfficeData.template(parentLookups, new LocalDate()); + return OfficeData.template(null, new LocalDate()); } @Override - public List retrieveAllowedParents(final Long officeId) { + public Collection retrieveAllowedParents(final Long officeId) { context.authenticatedUser(); - List filterParentLookups = new ArrayList(); + Collection filterParentLookups = new ArrayList(); if (isNotHeadOffice(officeId)) { - List parentLookups = new ArrayList(retrieveAllOfficesForLookup()); - - for (OfficeLookup office : parentLookups) { + Collection parentLookups = retrieveAllOfficesForDropdown(); + for (OfficeData office : parentLookups) { if (!office.hasIdentifyOf(officeId)) { filterParentLookups.add(office); } @@ -225,7 +221,6 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } return filterParentLookups; - } private boolean isNotHeadOffice(final Long officeId) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java index 6501336e1..560709783 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java @@ -14,7 +14,6 @@ import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency; import org.mifosplatform.organisation.monetary.domain.Money; import org.mifosplatform.organisation.monetary.exception.CurrencyNotFoundException; import org.mifosplatform.organisation.office.command.BranchMoneyTransferCommand; -import org.mifosplatform.organisation.office.command.OfficeCommand; import org.mifosplatform.organisation.office.domain.Office; import org.mifosplatform.organisation.office.domain.OfficeRepository; import org.mifosplatform.organisation.office.domain.OfficeTransaction; @@ -63,11 +62,14 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP try { final AppUser currentUser = context.authenticatedUser(); - final OfficeCommand officeCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json()); - officeCommand.validateForCreate(); + this.fromApiJsonDeserializer.validateForCreate(command.json()); - final Office parent = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, officeCommand.getParentId()); + Long parentId = null; + if (command.parameterExists("parentId")) { + parentId = command.longValueOfParameterNamed("parentId"); + } + final Office parent = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, parentId); final Office office = Office.fromJson(parent, command); // pre save to generate id for use in office hierarchy @@ -92,15 +94,19 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP try { final AppUser currentUser = context.authenticatedUser(); - final OfficeCommand officeCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json()); - officeCommand.validateForUpdate(); + this.fromApiJsonDeserializer.validateForUpdate(command.json()); + + Long parentId = null; + if (command.parameterExists("parentId")) { + parentId = command.longValueOfParameterNamed("parentId"); + } final Office office = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, officeId); final Map changes = office.update(command); if (changes.containsKey("parentId")) { - final Office parent = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, officeCommand.getParentId()); + final Office parent = validateUserPriviledgeOnOfficeAndRetrieve(currentUser, parentId); office.update(parent); }