update DDL and reference data files and also demo dumps with latest schema and core reports work.

This commit is contained in:
Keith Woodlock
2013-02-21 01:59:27 +00:00
parent fd2515c1ff
commit a94dcb6f50
20 changed files with 318 additions and 225 deletions
@@ -22,6 +22,7 @@ DROP TABLE IF EXISTS `m_deposit_account_transaction`;
DROP TABLE IF EXISTS `m_document`; DROP TABLE IF EXISTS `m_document`;
DROP TABLE IF EXISTS `m_fund`; DROP TABLE IF EXISTS `m_fund`;
DROP TABLE IF EXISTS `m_group`; DROP TABLE IF EXISTS `m_group`;
DROP TABLE IF EXISTS `m_group_level`;
DROP TABLE IF EXISTS `m_group_client`; DROP TABLE IF EXISTS `m_group_client`;
DROP TABLE IF EXISTS `m_guarantor`; DROP TABLE IF EXISTS `m_guarantor`;
DROP TABLE IF EXISTS `m_loan`; DROP TABLE IF EXISTS `m_loan`;
@@ -319,10 +320,25 @@ CREATE TABLE `m_staff` (
-- ============ end of organisation wide related tables =========== -- ============ end of organisation wide related tables ===========
-- DDL client/group related tables -- DDL client/group related tables
CREATE TABLE `m_group_level` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`parent_id` INT(11) NULL DEFAULT NULL,
`super_parent` TINYINT(1) NOT NULL,
`level_name` VARCHAR(100) NOT NULL,
`recursable` TINYINT(1) NOT NULL,
`can_have_clients` TINYINT(1) NOT NULL,
PRIMARY KEY (`id`),
INDEX `Parent_levelId_reference` (`parent_id`),
CONSTRAINT `Parent_levelId_reference` FOREIGN KEY (`parent_id`) REFERENCES `m_group_level` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_group` ( CREATE TABLE `m_group` (
`id` bigint(20) NOT NULL AUTO_INCREMENT, `id` bigint(20) NOT NULL AUTO_INCREMENT,
`office_id` bigint(20) NOT NULL, `office_id` bigint(20) NOT NULL,
`loan_officer_id` BIGINT(20) DEFAULT NULL, `staff_id` BIGINT(20) DEFAULT NULL,
`parent_id` BIGINT(20) NULL DEFAULT NULL,
`level_Id` INT(11) NOT NULL,
`hierarchy` VARCHAR(100) NULL DEFAULT NULL,
`name` varchar(100) DEFAULT NULL, `name` varchar(100) DEFAULT NULL,
`external_id` varchar(100) DEFAULT NULL, `external_id` varchar(100) DEFAULT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0', `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
@@ -330,9 +346,11 @@ CREATE TABLE `m_group` (
UNIQUE KEY `name` (`name`), UNIQUE KEY `name` (`name`),
UNIQUE KEY `external_id` (`external_id`), UNIQUE KEY `external_id` (`external_id`),
KEY `office_id` (`office_id`), KEY `office_id` (`office_id`),
KEY `loan_officer_id` (`loan_officer_id`), KEY `staff_id` (`staff_id`),
CONSTRAINT `m_group_ibfk_1` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`), CONSTRAINT `m_group_ibfk_1` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`),
CONSTRAINT `FK_m_group_m_staff` FOREIGN KEY (`loan_officer_id`) REFERENCES `m_staff` (`id`) CONSTRAINT `Parent_Id_reference` FOREIGN KEY (`parent_id`) REFERENCES `m_group` (`id`),
CONSTRAINT `FK_m_group_level` FOREIGN KEY (`level_Id`) REFERENCES `m_group_level` (`id`),
CONSTRAINT `FK_m_group_m_staff` FOREIGN KEY (`staff_id`) REFERENCES `m_staff` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_client` ( CREATE TABLE `m_client` (
@@ -685,23 +703,17 @@ CREATE TABLE `m_loan_repayment_schedule` (
CREATE TABLE `m_loan_transaction` ( CREATE TABLE `m_loan_transaction` (
`id` bigint(20) NOT NULL AUTO_INCREMENT, `id` bigint(20) NOT NULL AUTO_INCREMENT,
`loan_id` bigint(20) NOT NULL, `loan_id` bigint(20) NOT NULL,
`is_reversed` TINYINT(1) NOT NULL,
`transaction_type_enum` smallint(5) NOT NULL, `transaction_type_enum` smallint(5) NOT NULL,
`contra_id` bigint(20) DEFAULT NULL,
`transaction_date` date NOT NULL, `transaction_date` date NOT NULL,
`amount` decimal(19,6) 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, `principal_portion_derived` decimal(19,6) DEFAULT NULL,
`interest_portion_derived` decimal(19,6) DEFAULT NULL, `interest_portion_derived` decimal(19,6) DEFAULT NULL,
`fee_charges_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, `penalty_charges_portion_derived` decimal(19,6) DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `FKCFCEA42640BE0710` (`loan_id`), KEY `FKCFCEA42640BE0710` (`loan_id`),
KEY `FKCFCEA426FC69F3F1` (`contra_id`), CONSTRAINT `FKCFCEA42640BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`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; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ======== end of loan related tables ========== -- ======== end of loan related tables ==========
@@ -942,7 +954,7 @@ CREATE TABLE `acc_gl_journal_entry` (
`reversal_id` bigint(20) DEFAULT NULL, `reversal_id` bigint(20) DEFAULT NULL,
`transaction_id` varchar(50) NOT NULL, `transaction_id` varchar(50) NOT NULL,
`reversed` tinyint(1) NOT NULL DEFAULT '0', `reversed` tinyint(1) NOT NULL DEFAULT '0',
`portfolio_generated` tinyint(1) NOT NULL DEFAULT '0', `manual_entry` TINYINT(1) NOT NULL DEFAULT '0',
`entry_date` date NOT NULL, `entry_date` date NOT NULL,
`type_enum` smallint(50) NOT NULL, `type_enum` smallint(50) NOT NULL,
`amount` decimal(19,6) NOT NULL, `amount` decimal(19,6) NOT NULL,
@@ -206,6 +206,9 @@ INSERT INTO `m_office` (`id`, `parent_id`, `hierarchy`, `external_id`, `name`, `
VALUES VALUES
(1,NULL,'.','1','Head Office','2009-01-01'); (1,NULL,'.','1','Head Office','2009-01-01');
INSERT INTO `m_group_level` (`id`, `parent_id`, `is_super_parent`, `level_name`, `recursable`, `can_have_clients`) VALUES (1, NULL, 1, 'Center', 1, 0);
INSERT INTO `m_group_level` (`id`, `parent_id`, `is_super_parent`, `level_name`, `recursable`, `can_have_clients`) VALUES (2, 1, 0, 'Group', 0, 1);
-- ========= roles and permissions ========= -- ========= roles and permissions =========
/* /*
this scripts removes all current m_role_permission and m_permission entries this scripts removes all current m_role_permission and m_permission entries
@@ -457,6 +460,18 @@ INSERT INTO `m_permission`
('transaction_deposit', 'INTEREST_DEPOSITACCOUNT_CHECKER', 'DEPOSITACCOUNT', 'INTEREST', '0'), ('transaction_deposit', 'INTEREST_DEPOSITACCOUNT_CHECKER', 'DEPOSITACCOUNT', 'INTEREST', '0'),
('transaction_deposit', 'RENEW_DEPOSITACCOUNT_CHECKER', 'DEPOSITACCOUNT', 'RENEW', '0'); ('transaction_deposit', 'RENEW_DEPOSITACCOUNT_CHECKER', 'DEPOSITACCOUNT', 'RENEW', '0');
-- == accounting related permissions
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES
('accounting', 'CREATE_GLACCOUNT', 'GLACCOUNT', 'CREATE', 1),
('accounting', 'UPDATE_GLACCOUNT', 'GLACCOUNT', 'UPDATE', 1),
('accounting', 'DELETE_GLACCOUNT', 'GLACCOUNT', 'DELETE', 1),
('accounting', 'CREATE_GLCLOSURE', 'GLCLOSURE', 'CREATE', 1),
('accounting', 'UPDATE_GLCLOSURE', 'GLCLOSURE', 'UPDATE', 1),
('accounting', 'DELETE_GLCLOSURE', 'GLCLOSURE', 'DELETE', 1),
('accounting', 'CREATE_JOURNALENTRY', 'JOURNALENTRY', 'CREATE', 1),
('accounting', 'REVERSE_JOURNALENTRY', 'JOURNALENTRY', 'REVERSE', 1);
INSERT INTO `m_role` (`id`, `name`, `description`) INSERT INTO `m_role` (`id`, `name`, `description`)
VALUES VALUES
(1,'Super user','This role provides all application permissions.'); (1,'Super user','This role provides all application permissions.');
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
DELETE FROM `mifostenant-ceda`.`ref_loan_transaction_processing_strategy` WHERE id in (1, 3, 4); DELETE FROM `ref_loan_transaction_processing_strategy` WHERE id in (1, 3, 4);
INSERT INTO `mifostenant-ceda`.`m_code` (`code_name`, `is_system_defined`) INSERT INTO `m_code` (`code_name`, `is_system_defined`)
VALUES VALUES
('FieldOfEmployment', '0'), ('FieldOfEmployment', '0'),
('EducationLevel', '0'), ('EducationLevel', '0'),
@@ -142,8 +142,8 @@ where mc.`code_name` = "YesNo";
DROP TABLE IF EXISTS `mifostenant-ceda`.`client additional data`; DROP TABLE IF EXISTS `client additional data`;
CREATE TABLE `mifostenant-ceda`.`client additional data` ( CREATE TABLE `client additional data` (
`client_id` bigint(20) NOT NULL, `client_id` bigint(20) NOT NULL,
`Gender_cd` int(11) NOT NULL, `Gender_cd` int(11) NOT NULL,
`Date of Birth` date NOT NULL, `Date of Birth` date NOT NULL,
@@ -186,8 +186,8 @@ CREATE TABLE `mifostenant-ceda`.`client additional data` (
CONSTRAINT `FK_client_additional_data` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`) CONSTRAINT `FK_client_additional_data` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `mifostenant-ceda`.`impact measurement`; DROP TABLE IF EXISTS `impact measurement`;
CREATE TABLE `mifostenant-ceda`.`impact measurement` ( CREATE TABLE `impact measurement` (
`loan_id` bigint(20) NOT NULL, `loan_id` bigint(20) NOT NULL,
`YesNo_cd_RepaidOnSchedule` int(11) NOT NULL, `YesNo_cd_RepaidOnSchedule` int(11) NOT NULL,
`ReasonNotRepaidOnSchedule` text DEFAULT NULL, `ReasonNotRepaidOnSchedule` text DEFAULT NULL,
@@ -200,8 +200,8 @@ CREATE TABLE `mifostenant-ceda`.`impact measurement` (
CONSTRAINT `FK_impact measurement` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`) CONSTRAINT `FK_impact measurement` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `mifostenant-ceda`.`loan additional data`; DROP TABLE IF EXISTS `loan additional data`;
CREATE TABLE `mifostenant-ceda`.`loan additional data` ( CREATE TABLE `loan additional data` (
`loan_id` bigint(20) NOT NULL, `loan_id` bigint(20) NOT NULL,
`PurposeOfLoan_cd` int(11) NOT NULL, `PurposeOfLoan_cd` int(11) NOT NULL,
`CollateralType_cd` int(11) NOT NULL, `CollateralType_cd` int(11) NOT NULL,
@@ -216,7 +216,7 @@ CREATE TABLE `mifostenant-ceda`.`loan additional data` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- datatables mapping -- datatables mapping
INSERT INTO `mifostenant-ceda`.`x_registered_table` INSERT INTO `x_registered_table`
(`registered_table_name`, (`registered_table_name`,
`application_table_name`) `application_table_name`)
VALUES VALUES
@@ -244,9 +244,8 @@ from x_registered_table r;
-- ==== Chart of Accounts ===== -- ==== Chart of Accounts =====
DELETE FROM `mifostenant-ceda`.`acc_gl_account` WHERE id>0; truncate `acc_gl_account`;
INSERT INTO `acc_gl_account` VALUES
INSERT INTO `mifostenant-ceda`.`acc_gl_account` VALUES
(1,'Petty Cash Balances',NULL,'11100',0,1,2,1,NULL), (1,'Petty Cash Balances',NULL,'11100',0,1,2,1,NULL),
(2,'Cash in Valut 1',NULL,'11101',0,1,1,1,NULL), (2,'Cash in Valut 1',NULL,'11101',0,1,1,1,NULL),
(3,'Bank Balances',NULL,'11200',0,1,2,1,NULL), (3,'Bank Balances',NULL,'11200',0,1,2,1,NULL),
@@ -1,6 +1,6 @@
DELETE FROM `mifostenant-ceda`.`m_organisation_currency` WHERE id>0; DELETE FROM `m_organisation_currency` WHERE id>0;
INSERT INTO `mifostenant-ceda`.`m_organisation_currency` INSERT INTO `m_organisation_currency`
( (
`code`, `code`,
`decimal_places`, `decimal_places`,
@@ -11,9 +11,9 @@ VALUES
('UGX', 2, 'Uganda Shilling', 'USh', 'currency.UGX'); ('UGX', 2, 'Uganda Shilling', 'USh', 'currency.UGX');
UPDATE `mifostenant-ceda`.`m_appuser` SET `username` = 'admin' WHERE id=1; UPDATE `m_appuser` SET `username` = 'admin' WHERE id=1;
INSERT INTO `mifostenant-ceda`.`m_appuser` INSERT INTO `m_appuser`
(`is_deleted`, (`is_deleted`,
`office_id`, `office_id`,
`username`, `username`,
@@ -30,12 +30,12 @@ VALUES
(0, 1, 'keithwoodlock', 'Keith', 'Woodlock', (0, 1, 'keithwoodlock', 'Keith', 'Woodlock',
'4f607e9b6cffbe7d3db92d4bfa3391c7aa751727b4ea29d08fddf9dd72e6e7e3', 'keithwoodlock@gmail.com', 0, 1, 1, 1, 1); '4f607e9b6cffbe7d3db92d4bfa3391c7aa751727b4ea29d08fddf9dd72e6e7e3', 'keithwoodlock@gmail.com', 0, 1, 1, 1, 1);
INSERT INTO `mifostenant-ceda`.`m_appuser_role` INSERT INTO `m_appuser_role`
(`appuser_id`,`role_id`) VALUES (2,1); (`appuser_id`,`role_id`) VALUES (2,1);
UPDATE `mifostenant-ceda`.`m_office` SET `name` = 'CEDA Microfinance Ltd.' WHERE id=1; UPDATE `m_office` SET `name` = 'CEDA Microfinance Ltd.' WHERE id=1;
INSERT INTO `mifostenant-ceda`.`m_office` INSERT INTO `m_office`
( (
`parent_id`, `parent_id`,
`hierarchy`, `hierarchy`,
@@ -46,7 +46,7 @@ VALUES
(1, '.2.', 2, 'Uganda (Kampala)', '2009-01-01'); (1, '.2.', 2, 'Uganda (Kampala)', '2009-01-01');
INSERT INTO `mifostenant-ceda`.`m_staff` INSERT INTO `m_staff`
( (
`is_loan_officer`, `is_loan_officer`,
`office_id`, `office_id`,
@@ -58,7 +58,7 @@ VALUES
(1, 2, 'Kampala', 'LoanOfficer', 'LoanOfficer, Kampala'); (1, 2, 'Kampala', 'LoanOfficer', 'LoanOfficer, Kampala');
INSERT INTO `mifostenant-ceda`.`m_charge` INSERT INTO `m_charge`
( (
`name`, `name`,
`currency_code`, `currency_code`,
@@ -72,7 +72,7 @@ INSERT INTO `mifostenant-ceda`.`m_charge`
VALUES ('Bank Fee (per installment)', 'UGX', 1, 2, 1, 1500.000000, 0, 1, 0); VALUES ('Bank Fee (per installment)', 'UGX', 1, 2, 1, 1500.000000, 0, 1, 0);
INSERT INTO `mifostenant-ceda`.`m_product_loan` INSERT INTO `m_product_loan`
( (
`currency_code`, `currency_code`,
`currency_digits`, `currency_digits`,
@@ -98,5 +98,5 @@ VALUES
24.000000, 3, 24.000000, 1, 1, 1, 2, 12, 1, 2, 2); 24.000000, 3, 24.000000, 1, 1, 1, 2, 12, 1, 2, 2);
-- mapping of that loan product to GL Accounts -- mapping of that loan product to GL Accounts
INSERT INTO `mifostenant-ceda`.`acc_product_mapping` INSERT INTO `acc_product_mapping`
VALUES (1,4,1,1,1),(2,8,1,1,2),(3,34,1,1,3),(4,37,1,1,4),(5,35,1,1,5),(6,97,1,1,6); VALUES (1,4,1,1,1),(2,8,1,1,2),(3,34,1,1,3),(4,37,1,1,4),(5,35,1,1,5),(6,97,1,1,6);
File diff suppressed because one or more lines are too long
@@ -46,6 +46,3 @@ ALTER TABLE `m_loan`
ADD COLUMN `closedon_userid` BIGINT(20) DEFAULT NULL AFTER `closedon_date`, ADD COLUMN `closedon_userid` BIGINT(20) DEFAULT NULL AFTER `closedon_date`,
ADD KEY `FK_closedon_userid` (`closedon_userid`), ADD KEY `FK_closedon_userid` (`closedon_userid`),
ADD CONSTRAINT `FK_closedon_userid` FOREIGN KEY (`closedon_userid`) REFERENCES `m_appuser` (`id`); ADD CONSTRAINT `FK_closedon_userid` FOREIGN KEY (`closedon_userid`) REFERENCES `m_appuser` (`id`);
@@ -27,13 +27,13 @@ public class LoanChargeCommand implements Comparable<LoanChargeCommand> {
private final LocalDate dueDate; private final LocalDate dueDate;
public LoanChargeCommand(final Long id, final Long chargeId, final BigDecimal amount, final Integer chargeTimeType, public LoanChargeCommand(final Long id, final Long chargeId, final BigDecimal amount, final Integer chargeTimeType,
final Integer chargeCalculationType, final LocalDate specifiedDueDate) { final Integer chargeCalculationType, final LocalDate dueDate) {
this.id = id; this.id = id;
this.chargeId = chargeId; this.chargeId = chargeId;
this.amount = amount; this.amount = amount;
this.chargeTimeType = chargeTimeType; this.chargeTimeType = chargeTimeType;
this.chargeCalculationType = chargeCalculationType; this.chargeCalculationType = chargeCalculationType;
this.dueDate = specifiedDueDate; this.dueDate = dueDate;
} }
@Override @Override
@@ -241,9 +241,9 @@ public class LoanCharge extends AbstractPersistable<Long> {
this.loan = loan; this.loan = loan;
} }
public void update(final BigDecimal amount, final LocalDate specifiedDueDate, final BigDecimal loanPrincipal) { public void update(final BigDecimal amount, final LocalDate dueDate, final BigDecimal loanPrincipal) {
if (specifiedDueDate != null) { if (dueDate != null) {
this.dueDate = specifiedDueDate.toDate(); this.dueDate = dueDate.toDate();
} }
if (amount != null) { if (amount != null) {
@@ -304,14 +304,14 @@ public class LoanCharge extends AbstractPersistable<Long> {
// ChargeCalculationType.fromInt(newValue).getValue(); // ChargeCalculationType.fromInt(newValue).getValue();
// } // }
final String specifiedDueDateParamName = "dueDate"; final String dueDateParamName = "dueDate";
if (command.isChangeInLocalDateParameterNamed(specifiedDueDateParamName, getDueLocalDate())) { if (command.isChangeInLocalDateParameterNamed(dueDateParamName, getDueLocalDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(specifiedDueDateParamName); final String valueAsInput = command.stringValueOfParameterNamed(dueDateParamName);
actualChanges.put(specifiedDueDateParamName, valueAsInput); actualChanges.put(dueDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(specifiedDueDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(dueDateParamName);
this.dueDate = newValue.toDate(); this.dueDate = newValue.toDate();
} }
@@ -368,11 +368,11 @@ public class LoanCharge extends AbstractPersistable<Long> {
} }
public LocalDate getDueLocalDate() { public LocalDate getDueLocalDate() {
LocalDate specifiedDueDate = null; LocalDate dueDate = null;
if (this.dueDate != null) { if (this.dueDate != null) {
specifiedDueDate = new LocalDate(this.dueDate); dueDate = new LocalDate(this.dueDate);
} }
return specifiedDueDate; return dueDate;
} }
private boolean determineIfFullyPaid() { private boolean determineIfFullyPaid() {
@@ -427,8 +427,8 @@ public class LoanCharge extends AbstractPersistable<Long> {
} }
public boolean isDueForCollectionFromAndUpToAndIncluding(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive) { public boolean isDueForCollectionFromAndUpToAndIncluding(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive) {
final LocalDate specifiedDueDate = getDueLocalDate(); final LocalDate dueDate = getDueLocalDate();
return occursOnDayFromAndUpToAndIncluding(fromNotInclusive, upToAndInclusive, specifiedDueDate); return occursOnDayFromAndUpToAndIncluding(fromNotInclusive, upToAndInclusive, dueDate);
} }
private boolean occursOnDayFromAndUpToAndIncluding(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive, private boolean occursOnDayFromAndUpToAndIncluding(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive,
@@ -156,7 +156,7 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
if (topLevelJsonElement.get(chargesParameterName).isJsonArray()) { if (topLevelJsonElement.get(chargesParameterName).isJsonArray()) {
final Type arrayObjectParameterTypeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type arrayObjectParameterTypeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "chargeId", "amount", "chargeTimeType", final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "chargeId", "amount", "chargeTimeType",
"chargeCalculationType", "specifiedDueDate")); "chargeCalculationType", "dueDate"));
final JsonArray array = topLevelJsonElement.get("charges").getAsJsonArray(); final JsonArray array = topLevelJsonElement.get("charges").getAsJsonArray();
for (int i = 1; i <= array.size(); i++) { for (int i = 1; i <= array.size(); i++) {
@@ -173,7 +173,7 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
baseDataValidator.reset().parameter("charges").parameterAtIndexArray("amount", i).value(amount).notNull() baseDataValidator.reset().parameter("charges").parameterAtIndexArray("amount", i).value(amount).notNull()
.positiveAmount(); .positiveAmount();
fromApiJsonHelper.extractLocalDateNamed("specifiedDueDate", loanChargeElement, dateFormat, locale); fromApiJsonHelper.extractLocalDateNamed("dueDate", loanChargeElement, dateFormat, locale);
} }
} }
} }
@@ -239,48 +239,4 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
} }
} }
} }
// private LoanChargeCommand[] extractInToLoanChargeCommands(final
// JsonElement element) {
// LoanChargeCommand[] charges = null;
// if (element.isJsonObject()) {
// final JsonObject topLevelJsonElement = element.getAsJsonObject();
// final String dateFormat =
// fromApiJsonHelper.extractDateFormatParameter(topLevelJsonElement);
// final Locale locale =
// fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
// if (topLevelJsonElement.has("charges") &&
// topLevelJsonElement.get("charges").isJsonArray()) {
//
// final JsonArray array =
// topLevelJsonElement.get("charges").getAsJsonArray();
// charges = new LoanChargeCommand[array.size()];
// for (int i = 0; i < array.size(); i++) {
//
// final JsonObject loanChargeElement = array.get(i).getAsJsonObject();
//
// final Long id = fromApiJsonHelper.extractLongNamed("id",
// loanChargeElement);
// final Long chargeId = fromApiJsonHelper.extractLongNamed("chargeId",
// loanChargeElement);
// final BigDecimal amount =
// fromApiJsonHelper.extractBigDecimalNamed("amount", loanChargeElement,
// locale);
// final Integer chargeTimeType =
// fromApiJsonHelper.extractIntegerNamed("chargeTimeType",
// loanChargeElement, locale);
// final Integer chargeCalculationType =
// fromApiJsonHelper.extractIntegerNamed("chargeCalculationType",
// loanChargeElement,
// locale);
// fromApiJsonHelper.extractLocalDateNamed("specifiedDueDate",
// loanChargeElement, dateFormat, locale);
//
// charges[i] = new LoanChargeCommand(id, chargeId, amount, chargeTimeType,
// chargeCalculationType);
// }
// }
// }
// return charges;
// }
} }
@@ -217,7 +217,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
if (topLevelJsonElement.get(chargesParameterName).isJsonArray()) { if (topLevelJsonElement.get(chargesParameterName).isJsonArray()) {
final Type arrayObjectParameterTypeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type arrayObjectParameterTypeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "chargeId", "amount", "chargeTimeType", final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "chargeId", "amount", "chargeTimeType",
"chargeCalculationType", "specifiedDueDate")); "chargeCalculationType", "dueDate"));
final JsonArray array = topLevelJsonElement.get("charges").getAsJsonArray(); final JsonArray array = topLevelJsonElement.get("charges").getAsJsonArray();
for (int i = 1; i <= array.size(); i++) { for (int i = 1; i <= array.size(); i++) {
@@ -234,7 +234,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
baseDataValidator.reset().parameter("charges").parameterAtIndexArray("amount", i).value(amount).notNull() baseDataValidator.reset().parameter("charges").parameterAtIndexArray("amount", i).value(amount).notNull()
.positiveAmount(); .positiveAmount();
fromApiJsonHelper.extractLocalDateNamed("specifiedDueDate", loanChargeElement, dateFormat, locale); fromApiJsonHelper.extractLocalDateNamed("dueDate", loanChargeElement, dateFormat, locale);
} }
} }
} }
@@ -488,7 +488,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
if (topLevelJsonElement.get(chargesParameterName).isJsonArray()) { if (topLevelJsonElement.get(chargesParameterName).isJsonArray()) {
final Type arrayObjectParameterTypeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type arrayObjectParameterTypeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "chargeId", "amount", "chargeTimeType", final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "chargeId", "amount", "chargeTimeType",
"chargeCalculationType", "specifiedDueDate")); "chargeCalculationType", "dueDate"));
final JsonArray array = topLevelJsonElement.get("charges").getAsJsonArray(); final JsonArray array = topLevelJsonElement.get("charges").getAsJsonArray();
for (int i = 1; i <= array.size(); i++) { for (int i = 1; i <= array.size(); i++) {
@@ -505,7 +505,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
baseDataValidator.reset().parameter("charges").parameterAtIndexArray("amount", i).value(amount).notNull() baseDataValidator.reset().parameter("charges").parameterAtIndexArray("amount", i).value(amount).notNull()
.positiveAmount(); .positiveAmount();
fromApiJsonHelper.extractLocalDateNamed("specifiedDueDate", loanChargeElement, dateFormat, locale); fromApiJsonHelper.extractLocalDateNamed("dueDate", loanChargeElement, dateFormat, locale);
} }
} }
} }
@@ -63,7 +63,7 @@ public class LoanChargeAssembler {
final Integer chargeTimeType = fromApiJsonHelper.extractIntegerNamed("chargeTimeType", loanChargeElement, locale); final Integer chargeTimeType = fromApiJsonHelper.extractIntegerNamed("chargeTimeType", loanChargeElement, locale);
final Integer chargeCalculationType = fromApiJsonHelper.extractIntegerNamed("chargeCalculationType", loanChargeElement, final Integer chargeCalculationType = fromApiJsonHelper.extractIntegerNamed("chargeCalculationType", loanChargeElement,
locale); locale);
final LocalDate specifiedDueDate = fromApiJsonHelper.extractLocalDateNamed("specifiedDueDate", loanChargeElement, final LocalDate dueDate = fromApiJsonHelper.extractLocalDateNamed("dueDate", loanChargeElement,
dateFormat, locale); dateFormat, locale);
if (id == null) { if (id == null) {
@@ -77,14 +77,14 @@ public class LoanChargeAssembler {
ChargeCalculationType.fromInt(chargeCalculationType); ChargeCalculationType.fromInt(chargeCalculationType);
} }
final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition, principal, amount, chargeTime, final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition, principal, amount, chargeTime,
chargeCalculation, specifiedDueDate); chargeCalculation, dueDate);
loanCharges.add(loanCharge); loanCharges.add(loanCharge);
} else { } else {
final Long loanChargeId = id; final Long loanChargeId = id;
final LoanCharge loanCharge = this.loanChargeRepository.findOne(loanChargeId); final LoanCharge loanCharge = this.loanChargeRepository.findOne(loanChargeId);
if (loanCharge == null) { throw new LoanChargeNotFoundException(loanChargeId); } if (loanCharge == null) { throw new LoanChargeNotFoundException(loanChargeId); }
loanCharge.update(amount, specifiedDueDate, principal); loanCharge.update(amount, dueDate, principal);
loanCharges.add(loanCharge); loanCharges.add(loanCharge);
} }