From 1c1e83eb5e5a77372bba79217dbdae34fcb14aa2 Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Sat, 1 Mar 2014 04:40:57 -0800 Subject: [PATCH] applying format across the project and fixing all warnings Conflicts: mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsApplicationProcessWritePlatformService.java mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl.java --- .../common/AccountingConstants.java | 27 +- .../glaccount/api/GLAccountsApiResource.java | 2 +- .../glaccount/data/GLAccountData.java | 8 +- .../service/GLAccountReadPlatformService.java | 2 +- .../GLAccountReadPlatformServiceImpl.java | 46 +-- .../api/JournalEntriesApiResource.java | 19 +- ...JournalEntryAssociationParametersData.java | 10 +- .../journalentry/data/JournalEntryData.java | 4 +- .../data/SavingsTransactionDTO.java | 9 +- .../journalentry/domain/JournalEntry.java | 44 +-- .../service/AccountingProcessorHelper.java | 2 +- ...ashBasedAccountingProcessorForSavings.java | 29 +- .../JournalEntryReadPlatformService.java | 4 +- ...lEntryRunningBalanceUpdateServiceImpl.java | 4 +- .../commands/api/AuditsApiResource.java | 9 +- .../commands/domain/CommandWrapper.java | 9 +- .../service/AuditReadPlatformService.java | 2 +- .../service/AuditReadPlatformServiceImpl.java | 23 +- .../service/CommandWrapperBuilder.java | 19 +- ...CommandSourceWritePlatformServiceImpl.java | 1 - .../SynchronousCommandProcessingService.java | 19 +- .../ConfigurationReadPlatformServiceImpl.java | 5 +- .../infrastructure/core/api/JsonCommand.java | 8 +- .../core/data/DataValidatorBuilder.java | 15 +- .../core/data/PaginationParameters.java | 40 +-- .../PaginationParametersDataValidator.java | 30 +- .../core/serialization/FromJsonHelper.java | 4 +- .../core/serialization/JsonParserHelper.java | 12 +- .../core/service/DateUtils.java | 2 +- .../data/ResultsetColumnHeaderData.java | 2 +- .../ReadWriteNonCoreDataServiceImpl.java | 2 +- .../service/ImageReadPlatformServiceImpl.java | 4 +- .../jobs/service/JobRegisterServiceImpl.java | 2 +- .../infrastructure/sms/domain/SmsMessage.java | 2 +- .../sms/domain/SmsMessageAssembler.java | 6 +- .../sms/domain/SmsMessageEnumerations.java | 25 +- ...WritePlatformServiceJpaRepositoryImpl.java | 12 +- .../holiday/api/HolidayApiConstants.java | 8 +- .../holiday/api/HolidaysApiResource.java | 18 +- .../holiday/data/HolidayDataValidator.java | 18 +- .../organisation/holiday/domain/Holiday.java | 23 +- .../holiday/domain/HolidayRepository.java | 3 +- .../domain/HolidayRepositoryWrapper.java | 4 +- .../holiday/domain/HolidayStatusType.java | 3 +- .../holiday/service/HolidayEnumerations.java | 6 +- .../service/HolidayReadPlatformService.java | 2 +- .../HolidayReadPlatformServiceImpl.java | 2 +- .../service/HolidayWritePlatformService.java | 10 +- ...WritePlatformServiceJpaRepositoryImpl.java | 30 +- .../staff/api/StaffApiResource.java | 4 +- .../organisation/staff/data/StaffData.java | 6 +- .../organisation/staff/domain/Staff.java | 12 +- .../StaffCommandFromApiJsonDeserializer.java | 6 +- .../service/StaffReadPlatformServiceImpl.java | 21 +- ...WritePlatformServiceJpaRepositoryImpl.java | 1 + .../WorkingDaysWritePlatformService.java | 4 +- .../api/AccountTransfersApiResource.java | 3 +- .../account/data/AccountTransferDTO.java | 4 +- .../account/domain/AccountTransfer.java | 1 - .../domain/AccountTransferRepository.java | 2 +- ...ountTransfersWritePlatformServiceImpl.java | 9 +- ...sReadPlatformServiceJpaRepositoryImpl.java | 2 +- .../portfolio/calendar/CalendarConstants.java | 3 +- .../calendar/api/CalendarsApiResource.java | 12 +- .../portfolio/calendar/data/CalendarData.java | 103 +++--- .../portfolio/calendar/domain/Calendar.java | 40 ++- .../calendar/domain/CalendarEntityType.java | 12 +- .../domain/CalendarFrequencyType.java | 12 +- .../calendar/domain/CalendarHistory.java | 21 +- .../calendar/domain/CalendarType.java | 4 +- .../calendar/domain/CalendarWeekDaysType.java | 9 +- ...alendarCommandFromApiJsonDeserializer.java | 8 +- .../CalendarDropdownReadPlatformService.java | 4 +- ...lendarDropdownReadPlatformServiceImpl.java | 2 +- .../service/CalendarEnumerations.java | 14 +- .../service/CalendarReadPlatformService.java | 2 +- .../CalendarReadPlatformServiceImpl.java | 9 +- .../calendar/service/CalendarUtils.java | 12 +- ...WritePlatformServiceJpaRepositoryImpl.java | 18 +- .../portfolio/charge/data/ChargeData.java | 36 ++- .../portfolio/charge/domain/Charge.java | 5 +- .../charge/domain/ChargeAppliesTo.java | 3 +- .../charge/domain/ChargeCalculationType.java | 8 +- .../charge/domain/ChargeTimeType.java | 18 +- .../LoanChargeCannotBePayedException.java | 14 +- .../LoanChargeCannotBeUpdatedException.java | 8 +- .../LoanChargeCannotBeWaivedException.java | 18 +- ...initionCommandFromApiJsonDeserializer.java | 22 +- .../ChargeDropdownReadPlatformService.java | 6 +- ...ChargeDropdownReadPlatformServiceImpl.java | 20 +- .../charge/service/ChargeEnumerations.java | 26 +- .../ChargeReadPlatformServiceImpl.java | 13 +- ...WritePlatformServiceJpaRepositoryImpl.java | 36 +-- .../client/api/ClientApiConstants.java | 8 +- .../client/api/ClientsApiResource.java | 1 - .../portfolio/client/data/ClientData.java | 24 +- .../client/data/ClientDataValidator.java | 16 +- .../client/data/ClientTimelineData.java | 11 +- .../portfolio/client/domain/Client.java | 10 +- .../ClientActiveForUpdateException.java | 5 +- .../ClientReadPlatformServiceImpl.java | 44 ++- .../group/api/CentersApiResource.java | 29 +- .../group/api/GroupingTypesApiConstants.java | 18 +- .../group/api/GroupsApiResource.java | 15 +- .../portfolio/group/data/CenterData.java | 12 +- .../group/data/GroupGeneralData.java | 20 +- .../group/data/GroupTimelineData.java | 14 +- .../portfolio/group/data/StaffCenterData.java | 44 +-- .../GroupingTypesDataValidator.java | 20 +- .../service/AllGroupTypesDataMapper.java | 16 +- .../service/CenterReadPlatformService.java | 4 +- .../CenterReadPlatformServiceImpl.java | 181 +++++------ .../service/GroupReadPlatformService.java | 2 +- .../service/GroupReadPlatformServiceImpl.java | 14 +- ...WritePlatformServiceJpaRepositoryImpl.java | 12 +- .../group/service/SearchParameters.java | 53 +-- .../loanaccount/api/LoanApiConstants.java | 8 +- .../api/LoanChargesApiResource.java | 12 +- .../LoanDisbursementDetailApiResource.java | 22 +- .../api/LoanTransactionsApiResource.java | 4 +- .../loanaccount/api/LoansApiResource.java | 44 +-- .../loanaccount/data/DisbursementData.java | 16 +- .../loanaccount/data/LoanAccountData.java | 302 +++++++++--------- .../data/LoanApplicationTimelineData.java | 8 +- .../data/LoanBorrowerCycleData.java | 17 +- .../loanaccount/data/LoanChargeData.java | 32 +- .../data/LoanInstallmentChargeData.java | 4 +- .../loanaccount/data/LoanStatusEnumData.java | 4 +- .../data/LoanTermVariationsData.java | 7 +- .../loanaccount/data/LoanTransactionData.java | 4 +- .../RepaymentScheduleRelatedLoanData.java | 7 +- .../domain/ChangedTransactionDetail.java | 2 +- .../DefaultLoanLifecycleStateMachine.java | 6 +- .../domain/LoanAccountDomainServiceJpa.java | 10 +- .../loanaccount/domain/LoanCharge.java | 183 ++++++----- .../domain/LoanDisbursementDetails.java | 18 +- .../loanaccount/domain/LoanEvent.java | 4 +- .../domain/LoanInstallmentCharge.java | 22 +- ...oanRepaymentScheduleProcessingWrapper.java | 54 ++-- ...ntScheduleTransactionProcessorFactory.java | 2 +- .../loanaccount/domain/LoanSummary.java | 2 - .../domain/LoanTermVariations.java | 24 +- .../loanaccount/domain/LoanTransaction.java | 31 +- ...RepaymentScheduleTransactionProcessor.java | 13 +- .../exception/LoanDisbursalException.java | 4 +- ...ultiDisbursementDataRequiredException.java | 3 +- .../domain/AbstractLoanScheduleGenerator.java | 105 +++--- ...gBalanceInterestLoanScheduleGenerator.java | 4 +- .../domain/DefaultScheduledDateGenerator.java | 21 +- .../domain/FinanicalFunctions.java | 13 +- .../domain/LoanApplicationTerms.java | 85 +++-- .../LoanScheduleModelDisbursementPeriod.java | 14 +- .../domain/LoanScheduleModelPeriod.java | 4 +- .../LoanScheduleModelRepaymentPeriod.java | 2 +- .../service/LoanScheduleAssembler.java | 34 +- ...cheduleCalculationPlatformServiceImpl.java | 11 +- ...ateLoanScheduleQueryFromApiJsonHelper.java | 5 +- ...anApplicationCommandFromApiJsonHelper.java | 110 ++++--- .../LoanEventApiJsonValidator.java | 58 ++-- .../loanaccount/service/LoanAssembler.java | 34 +- .../service/LoanChargeAssembler.java | 2 +- .../LoanChargeReadPlatformService.java | 4 +- .../LoanChargeReadPlatformServiceImpl.java | 28 +- .../service/LoanReadPlatformService.java | 20 +- .../service/LoanReadPlatformServiceImpl.java | 95 +++--- ...WritePlatformServiceJpaRepositoryImpl.java | 139 ++++---- .../loanproduct/LoanProductConstants.java | 24 +- .../api/LoanProductsApiResource.java | 11 +- ...LoanProductBorrowerCycleVariationData.java | 11 +- .../loanproduct/data/LoanProductData.java | 96 +++--- .../loanproduct/domain/LoanProduct.java | 75 +++-- .../domain/LoanProductParamType.java | 8 +- .../domain/LoanProductRelatedDetail.java | 5 +- .../domain/LoanProductTrancheDetails.java | 3 - .../domain/LoanProductValueConditionType.java | 10 +- .../LoanTransactionProcessingStrategy.java | 2 +- .../LoanProductDataValidator.java | 166 +++++----- .../LoanDropdownReadPlatformServiceImpl.java | 6 +- .../loanproduct/service/LoanEnumerations.java | 42 +-- .../LoanProductReadPlatformServiceImpl.java | 1 - ...WritePlatformServiceJpaRepositoryImpl.java | 4 +- .../meeting/api/MeetingsApiResource.java | 6 +- .../portfolio/meeting/data/MeetingData.java | 2 +- .../service/MeetingReadPlatformService.java | 2 +- .../MeetingReadPlatformServiceImpl.java | 4 +- .../SavingsAccountTransactionType.java | 15 +- .../savings/SavingsApiConstants.java | 35 +- .../api/SavingsAccountsApiResource.java | 2 +- .../data/SavingsAccountAnnualFeeData.java | 5 +- .../data/SavingsAccountChargeData.java | 34 +- .../SavingsAccountChargeDataValidator.java | 21 +- .../savings/data/SavingsAccountData.java | 64 ++-- .../data/SavingsAccountDataValidator.java | 33 +- .../SavingsAccountTransactionEnumData.java | 10 +- .../savings/data/SavingsProductData.java | 65 ++-- .../data/SavingsProductDataValidator.java | 113 +++---- .../domain/SavingsAccountAssembler.java | 47 ++- .../savings/domain/SavingsAccountCharge.java | 49 +-- .../domain/SavingsAccountChargeAssembler.java | 27 +- .../SavingsAccountChargeRepository.java | 2 +- ...SavingsAccountChargeRepositoryWrapper.java | 8 +- .../SavingsAccountDomainServiceJpa.java | 4 +- .../savings/domain/SavingsAccountSummary.java | 6 +- .../domain/SavingsAccountTransaction.java | 84 +++-- .../SavingsAccountTransactionComparator.java | 14 +- ...vingsAccountTransactionSummaryWrapper.java | 4 +- .../savings/domain/SavingsProduct.java | 269 ++++++++-------- .../domain/SavingsProductAssembler.java | 8 +- .../domain/SavingsProductChargeAssembler.java | 8 +- ...AnnualFeeSavingsAccountCommandHandler.java | 4 +- ...vingsAccountChargeReadPlatformService.java | 4 +- ...sAccountChargeReadPlatformServiceImpl.java | 4 +- .../SavingsAccountReadPlatformService.java | 3 +- ...SavingsAccountReadPlatformServiceImpl.java | 187 ++++++----- .../SavingsAccountWritePlatformService.java | 2 +- ...WritePlatformServiceJpaRepositoryImpl.java | 15 +- ...pplicationProcessWritePlatformService.java | 2 +- .../SavingsProductReadPlatformService.java | 2 +- ...SavingsProductReadPlatformServiceImpl.java | 61 ++-- ...WritePlatformServiceJpaRepositoryImpl.java | 6 +- .../portfolio/search/SearchConstants.java | 2 +- .../search/api/SearchApiResource.java | 15 +- .../data/AdHocQuerySearchConditions.java | 21 +- .../data/AdHocQuerySearchConstants.java | 8 +- .../portfolio/search/data/SearchData.java | 2 +- .../SearchReadPlatformServiceImpl.java | 103 +++--- .../src/main/resources/META-INF/orm.xml | 10 +- .../main/resources/META-INF/persistence.xml | 10 +- .../resources/META-INF/spring/appContext.xml | 65 ++-- .../main/resources/META-INF/spring/cache.xml | 16 +- .../resources/META-INF/spring/ehcache.xml | 10 +- .../META-INF/spring/infrastructure.xml | 53 ++- .../META-INF/spring/securityContext.xml | 63 ++-- .../src/main/resources/logback.xml | 65 ++-- .../src/main/webapp/META-INF/context.xml | 11 +- .../src/main/webapp/WEB-INF/web.xml | 43 ++- .../mix/report/service/XBRLBuilderTest.java | 1 + .../src/test/resources/META-INF/context.xml | 14 +- .../test/resources/META-INF/testContext.xml | 112 +++---- 239 files changed, 2881 insertions(+), 2851 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/common/AccountingConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/common/AccountingConstants.java index d2753cec2..dd61d5cd6 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/common/AccountingConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/common/AccountingConstants.java @@ -109,9 +109,8 @@ public class AccountingConstants { public static enum LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS { FUND_SOURCE("fundSourceAccount"), LOAN_PORTFOLIO("loanPortfolioAccount"), INTEREST_ON_LOANS("interestOnLoanAccount"), INCOME_FROM_FEES( "incomeFromFeeAccount"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccount"), LOSSES_WRITTEN_OFF("writeOffAccount"), OVERPAYMENT( - "overpaymentLiabilityAccount"), INTEREST_RECEIVABLE("receivableInterestAccount"), FEES_RECEIVABLE( - "receivableFeeAccount"), PENALTIES_RECEIVABLE("receivablePenaltyAccount"), TRANSFERS_SUSPENSE( - "transfersInSuspenseAccount"), INCOME_ACCOUNT_ID("incomeAccount"); + "overpaymentLiabilityAccount"), INTEREST_RECEIVABLE("receivableInterestAccount"), FEES_RECEIVABLE("receivableFeeAccount"), PENALTIES_RECEIVABLE( + "receivablePenaltyAccount"), TRANSFERS_SUSPENSE("transfersInSuspenseAccount"), INCOME_ACCOUNT_ID("incomeAccount"); private final String value; @@ -129,12 +128,10 @@ public class AccountingConstants { } } - /*** Accounting placeholders for cash based accounting for savings products ***/ public static enum CASH_ACCOUNTS_FOR_SAVINGS { SAVINGS_REFERENCE(1), SAVINGS_CONTROL(2), INTEREST_ON_SAVINGS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), TRANSFERS_SUSPENSE( - 10),OVERDRAFT_PORTFOLIO_CONTROL(11),INCOME_FROM_INTEREST(12), - LOSSES_WRITTEN_OFF(13); + 10), OVERDRAFT_PORTFOLIO_CONTROL(11), INCOME_FROM_INTEREST(12), LOSSES_WRITTEN_OFF(13); private final Integer value; @@ -174,8 +171,8 @@ public class AccountingConstants { "interestOnSavingsAccountId"), PAYMENT_CHANNEL_FUND_SOURCE_MAPPING("paymentChannelToFundSourceMappings"), PAYMENT_TYPE( "paymentTypeId"), FUND_SOURCE("fundSourceAccountId"), TRANSFERS_SUSPENSE("transfersInSuspenseAccountId"), FEE_INCOME_ACCOUNT_MAPPING( "feeToIncomeAccountMappings"), PENALTY_INCOME_ACCOUNT_MAPPING("penaltyToIncomeAccountMappings"), CHARGE_ID("chargeId"), INCOME_ACCOUNT_ID( - "incomeAccountId"),OVERDRAFT_PORTFOLIO_CONTROL("overdraftPortfolioControlId"),INCOME_FROM_INTEREST("incomeFromInterestId"), - LOSSES_WRITTEN_OFF("writeOffAccountId"); + "incomeAccountId"), OVERDRAFT_PORTFOLIO_CONTROL("overdraftPortfolioControlId"), INCOME_FROM_INTEREST("incomeFromInterestId"), LOSSES_WRITTEN_OFF( + "writeOffAccountId"); private final String value; @@ -192,14 +189,13 @@ public class AccountingConstants { return this.value; } } - + public static enum SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS { - SAVINGS_REFERENCE("savingsReferenceAccount"), SAVINGS_CONTROL("savingsControlAccount"), INCOME_FROM_FEES( - "incomeFromFeeAccount"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccount"), INTEREST_ON_SAVINGS( - "interestOnSavingsAccount"), PAYMENT_TYPE("paymentType"), FUND_SOURCE("fundSourceAccount"), - TRANSFERS_SUSPENSE("transfersInSuspenseAccount"), PENALTY_INCOME_ACCOUNT_MAPPING("penaltyToIncomeAccountMappings"), CHARGE_ID("charge"), INCOME_ACCOUNT_ID( - "incomeAccount"),OVERDRAFT_PORTFOLIO_CONTROL("overdraftPortfolioControl"),INCOME_FROM_INTEREST("incomeFromInterest"), - LOSSES_WRITTEN_OFF("writeOffAccount"); + SAVINGS_REFERENCE("savingsReferenceAccount"), SAVINGS_CONTROL("savingsControlAccount"), INCOME_FROM_FEES("incomeFromFeeAccount"), INCOME_FROM_PENALTIES( + "incomeFromPenaltyAccount"), INTEREST_ON_SAVINGS("interestOnSavingsAccount"), PAYMENT_TYPE("paymentType"), FUND_SOURCE( + "fundSourceAccount"), TRANSFERS_SUSPENSE("transfersInSuspenseAccount"), PENALTY_INCOME_ACCOUNT_MAPPING( + "penaltyToIncomeAccountMappings"), CHARGE_ID("charge"), INCOME_ACCOUNT_ID("incomeAccount"), OVERDRAFT_PORTFOLIO_CONTROL( + "overdraftPortfolioControl"), INCOME_FROM_INTEREST("incomeFromInterest"), LOSSES_WRITTEN_OFF("writeOffAccount"); private final String value; @@ -217,7 +213,6 @@ public class AccountingConstants { } } - public static final String ASSESTS_TAG_OPTION_CODE_NAME = "AssetAccountTags"; public static final String LIABILITIES_TAG_OPTION_CODE_NAME = "LiabilityAccountTags"; public static final String EQUITY_TAG_OPTION_CODE_NAME = "EquityAccountTags"; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java index 07233f6f8..b97cdd5c8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java @@ -124,7 +124,7 @@ public class GLAccountsApiResource { final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(false, runningBalance); - GLAccountData glAccountData = this.glAccountReadPlatformService.retrieveGLAccountById(glAccountId,associationParametersData); + GLAccountData glAccountData = this.glAccountReadPlatformService.retrieveGLAccountById(glAccountId, associationParametersData); if (settings.isTemplate()) { glAccountData = handleTemplate(glAccountData); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java index 100d6fe84..017c23064 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java @@ -35,7 +35,6 @@ public class GLAccountData { private final CodeValueData tagId; private final Long organizationRunningBalance; - // templates final List accountTypeOptions; final List usageOptions; @@ -52,7 +51,7 @@ public class GLAccountData { public GLAccountData(final Long id, final String name, final Long parentId, final String glCode, final boolean disabled, final boolean manualEntriesAllowed, final EnumOptionData type, final EnumOptionData usage, final String description, - final String nameDecorated, final CodeValueData tagId,final Long organizationRunningBalance) { + final String nameDecorated, final CodeValueData tagId, final Long organizationRunningBalance) { this.id = id; this.name = name; this.parentId = parentId; @@ -97,7 +96,7 @@ public class GLAccountData { this.description = accountData.description; this.nameDecorated = accountData.nameDecorated; this.tagId = accountData.tagId; - this.organizationRunningBalance = accountData.organizationRunningBalance; + this.organizationRunningBalance = accountData.organizationRunningBalance; this.accountTypeOptions = accountTypeOptions; this.usageOptions = usageOptions; this.assetHeaderAccountOptions = assetHeaderAccountOptions; @@ -131,7 +130,8 @@ public class GLAccountData { final CodeValueData tagId = null; final Long organizationRunningBalance = null; - return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, nameDecorated, tagId,organizationRunningBalance); + return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, nameDecorated, + tagId, organizationRunningBalance); } public GLAccountData(final Long id, final String name, final String glCode) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java index 95f891c1d..02e72a008 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java @@ -17,7 +17,7 @@ public interface GLAccountReadPlatformService { List retrieveAllGLAccounts(Integer accountClassification, String searchParam, Integer usage, Boolean manualTransactionsAllowed, Boolean disabled, JournalEntryAssociationParametersData associationParametersData); - GLAccountData retrieveGLAccountById(long glAccountId,JournalEntryAssociationParametersData associationParametersData); + GLAccountData retrieveGLAccountById(long glAccountId, JournalEntryAssociationParametersData associationParametersData); List retrieveAllEnabledDetailGLAccounts(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java index 1c654d439..60c58ef6d 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java @@ -43,27 +43,27 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe private static final class GLAccountMapper implements RowMapper { private final JournalEntryAssociationParametersData associationParametersData; - - + public GLAccountMapper(final JournalEntryAssociationParametersData associationParametersData) { - if(associationParametersData == null){ - this.associationParametersData = new JournalEntryAssociationParametersData(); - }else{ + if (associationParametersData == null) { + this.associationParametersData = new JournalEntryAssociationParametersData(); + } else { this.associationParametersData = associationParametersData; } } - + public String schema() { StringBuilder sb = new StringBuilder(); - sb.append(" gl.id as id, name as name, parent_id as parentId, gl_code as glCode, disabled as disabled, manual_journal_entries_allowed as manualEntriesAllowed, ") - .append("classification_enum as classification, account_usage as accountUsage, gl.description as description, ") - .append(nameDecoratedBaseOnHierarchy).append(" as nameDecorated, ") - .append("cv.id as codeId, cv.code_value as codeValue "); - if(this.associationParametersData.isRunningBalanceRequired()){ + sb.append( + " gl.id as id, name as name, parent_id as parentId, gl_code as glCode, disabled as disabled, manual_journal_entries_allowed as manualEntriesAllowed, ") + .append("classification_enum as classification, account_usage as accountUsage, gl.description as description, ") + .append(nameDecoratedBaseOnHierarchy).append(" as nameDecorated, ") + .append("cv.id as codeId, cv.code_value as codeValue "); + if (this.associationParametersData.isRunningBalanceRequired()) { sb.append(",gl_j.organization_running_balance as organizationRunningBalance "); } sb.append("from acc_gl_account gl left join m_code_value cv on tag_id=cv.id "); - if(this.associationParametersData.isRunningBalanceRequired()){ + if (this.associationParametersData.isRunningBalanceRequired()) { sb.append("left outer Join acc_gl_journal_entry gl_j on gl_j.account_id = gl.id"); } return sb.toString(); @@ -88,7 +88,7 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe final String codeValue = rs.getString("codeValue"); final CodeValueData tagId = CodeValueData.instance(codeId, codeValue); Long organizationRunningBalance = null; - if(associationParametersData.isRunningBalanceRequired()){ + if (associationParametersData.isRunningBalanceRequired()) { organizationRunningBalance = rs.getLong("organizationRunningBalance"); } return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, accountType, usage, description, @@ -110,9 +110,9 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe final GLAccountMapper rm = new GLAccountMapper(associationParametersData); String sql = "select " + rm.schema(); // append SQL statement for fetching account totals - if(associationParametersData.isRunningBalanceRequired()){ - sql = sql + " and gl_j.id in (select t1.id from (SELECT t2.id , max(concat(t2.entry_date,t2.id)) " - + "FROM acc_gl_journal_entry t2 WHERE is_running_balance_calculated = 1 GROUP BY t2.account_id DESC) t1)"; + if (associationParametersData.isRunningBalanceRequired()) { + sql = sql + " and gl_j.id in (select t1.id from (SELECT t2.id , max(concat(t2.entry_date,t2.id)) " + + "FROM acc_gl_journal_entry t2 WHERE is_running_balance_calculated = 1 GROUP BY t2.account_id DESC) t1)"; } final Object[] paramaterArray = new Object[3]; int arrayPos = 0; @@ -184,17 +184,17 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe } @Override - public GLAccountData retrieveGLAccountById(final long glAccountId,JournalEntryAssociationParametersData associationParametersData) { + public GLAccountData retrieveGLAccountById(final long glAccountId, JournalEntryAssociationParametersData associationParametersData) { try { final GLAccountMapper rm = new GLAccountMapper(associationParametersData); - final StringBuilder sql = new StringBuilder(); + final StringBuilder sql = new StringBuilder(); sql.append("select ").append(rm.schema()); - if(associationParametersData.isRunningBalanceRequired()){ + if (associationParametersData.isRunningBalanceRequired()) { sql.append(" and gl_j.is_running_balance_calculated = 1 "); } sql.append("where gl.id = ?"); - if(associationParametersData.isRunningBalanceRequired()){ + if (associationParametersData.isRunningBalanceRequired()) { sql.append(" ORDER BY gl_j.entry_date DESC,gl_j.id DESC LIMIT 1"); } final GLAccountData glAccountData = this.jdbcTemplate.queryForObject(sql.toString(), rm, new Object[] { glAccountId }); @@ -207,7 +207,8 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe @Override public List retrieveAllEnabledDetailGLAccounts(final GLAccountType accountType) { - return retrieveAllGLAccounts(accountType.getValue(), null, GLAccountUsage.DETAIL.getValue(), null, false, new JournalEntryAssociationParametersData()); + return retrieveAllGLAccounts(accountType.getValue(), null, GLAccountUsage.DETAIL.getValue(), null, false, + new JournalEntryAssociationParametersData()); } @Override @@ -236,7 +237,8 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe @Override public List retrieveAllEnabledHeaderGLAccounts(final GLAccountType accountType) { - return retrieveAllGLAccounts(accountType.getValue(), null, GLAccountUsage.HEADER.getValue(), null, false, new JournalEntryAssociationParametersData()); + return retrieveAllGLAccounts(accountType.getValue(), null, GLAccountUsage.HEADER.getValue(), null, false, + new JournalEntryAssociationParametersData()); } @Override diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java index 8edcd640a..e98f513e4 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java @@ -77,11 +77,11 @@ public class JournalEntriesApiResource { public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("officeId") final Long officeId, @QueryParam("glAccountId") final Long glAccountId, @QueryParam("manualEntriesOnly") final Boolean onlyManualEntries, @QueryParam("fromDate") final DateParam fromDateParam, @QueryParam("toDate") final DateParam toDateParam, - @QueryParam("transactionId") final String transactionId, @QueryParam("entityType") final Integer entityType, @QueryParam("offset") final Integer offset, - @QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy, - @QueryParam("sortOrder") final String sortOrder, @QueryParam("locale") final String locale, - @QueryParam("dateFormat") final String dateFormat,@QueryParam("runningBalance") final boolean runningBalance, - @QueryParam("transactionDetails") final boolean transactionDetails) { + @QueryParam("transactionId") final String transactionId, @QueryParam("entityType") final Integer entityType, + @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, + @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, + @QueryParam("locale") final String locale, @QueryParam("dateFormat") final String dateFormat, + @QueryParam("runningBalance") final boolean runningBalance, @QueryParam("transactionDetails") final boolean transactionDetails) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); @@ -95,7 +95,8 @@ public class JournalEntriesApiResource { } final SearchParameters searchParameters = SearchParameters.forJournalEntries(officeId, offset, limit, orderBy, sortOrder); - JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(transactionDetails, runningBalance); + JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(transactionDetails, + runningBalance); final Page glJournalEntries = this.journalEntryReadPlatformService.retrieveAll(searchParameters, glAccountId, onlyManualEntries, fromDate, toDate, transactionId, entityType, associationParametersData); @@ -111,8 +112,10 @@ public class JournalEntriesApiResource { @QueryParam("runningBalance") final boolean runningBalance, @QueryParam("transactionDetails") final boolean transactionDetails) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); - JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(transactionDetails, runningBalance); - final JournalEntryData glJournalEntryData = this.journalEntryReadPlatformService.retrieveGLJournalEntryById(journalEntryId, associationParametersData); + JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(transactionDetails, + runningBalance); + final JournalEntryData glJournalEntryData = this.journalEntryReadPlatformService.retrieveGLJournalEntryById(journalEntryId, + associationParametersData); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.apiJsonSerializerService.serialize(settings, glJournalEntryData, RESPONSE_DATA_PARAMETERS); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryAssociationParametersData.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryAssociationParametersData.java index a3cb601f5..ff721df1b 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryAssociationParametersData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryAssociationParametersData.java @@ -1,28 +1,24 @@ package org.mifosplatform.accounting.journalentry.data; - public class JournalEntryAssociationParametersData { private final boolean transactionDetailsRequired; private final boolean runningBalanceRequired; - - + public JournalEntryAssociationParametersData() { this.transactionDetailsRequired = false; this.runningBalanceRequired = false; } - - public JournalEntryAssociationParametersData(final boolean transactionDetailsRequired , final boolean runningBalanceRequired) { + + public JournalEntryAssociationParametersData(final boolean transactionDetailsRequired, final boolean runningBalanceRequired) { this.transactionDetailsRequired = transactionDetailsRequired; this.runningBalanceRequired = runningBalanceRequired; } - public boolean isTransactionDetailsRequired() { return this.transactionDetailsRequired; } - public boolean isRunningBalanceRequired() { return this.runningBalanceRequired; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java index 0e9327cdd..5a26ed0d6 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java @@ -13,7 +13,7 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData; /** * Immutable object representing a General Ledger Account - * + * * Note: no getter/setters required as google will produce json from fields of * object. */ @@ -71,7 +71,7 @@ public class JournalEntryData { final Boolean manualEntry, final EnumOptionData entityType, final Long entityId, final Long createdByUserId, final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber, final BigDecimal officeRunningBalance, final BigDecimal organizationRunningBalance, - final Boolean runningBalanceComputed,final TransactionDetailData transactionDetailData, final CurrencyData currency) { + final Boolean runningBalanceComputed, final TransactionDetailData transactionDetailData, final CurrencyData currency) { this.id = id; this.officeId = officeId; this.officeName = officeName; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/SavingsTransactionDTO.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/SavingsTransactionDTO.java index ad0797010..d687245df 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/SavingsTransactionDTO.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/SavingsTransactionDTO.java @@ -31,7 +31,7 @@ public class SavingsTransactionDTO { public SavingsTransactionDTO(final Long officeId, final Long paymentTypeId, final String transactionId, final Date transactionDate, final SavingsAccountTransactionEnumData transactionType, final BigDecimal amount, final boolean reversed, - final List feePayments, final List penaltyPayments,final BigDecimal overdraftAmount) { + final List feePayments, final List penaltyPayments, final BigDecimal overdraftAmount) { this.paymentTypeId = paymentTypeId; this.transactionId = transactionId; this.transactionDate = transactionDate; @@ -80,13 +80,12 @@ public class SavingsTransactionDTO { return this.feePayments; } - public BigDecimal getOverdraftAmount() { return this.overdraftAmount; } - - public boolean isOverdraftTransaction(){ - return this.overdraftAmount!=null && this.overdraftAmount.doubleValue() > 0; + + public boolean isOverdraftTransaction() { + return this.overdraftAmount != null && this.overdraftAmount.doubleValue() > 0; } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java index 31c69f75b..0643b1fd3 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java @@ -33,15 +33,15 @@ public class JournalEntry extends AbstractAuditableCustom { @ManyToOne @JoinColumn(name = "office_id", nullable = false) private Office office; - + @ManyToOne(optional = true) @JoinColumn(name = "payment_details_id", nullable = true) private PaymentDetail paymentDetail; - + @ManyToOne @JoinColumn(name = "account_id", nullable = false) private GLAccount glAccount; - + @Column(name = "currency_code", length = 3, nullable = false) private String currencyCode; @@ -59,7 +59,7 @@ public class JournalEntry extends AbstractAuditableCustom { @ManyToOne @JoinColumn(name = "savings_transaction_id", nullable = false) private SavingsAccountTransaction savingsTransaction; - + @Column(name = "reversed", nullable = false) private boolean reversed = false; @@ -87,23 +87,25 @@ public class JournalEntry extends AbstractAuditableCustom { @Column(name = "ref_num") private String referenceNumber; - - public static JournalEntry createNew(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, final String currencyCode, - final String transactionId, final boolean manualEntry, final Date transactionDate, final JournalEntryType journalEntryType, - final BigDecimal amount, final String description, final Integer entityType, final Long entityId, final String referenceNumber, - final LoanTransaction loanTransaction, final SavingsAccountTransaction savingsTransaction) { - return new JournalEntry(office, paymentDetail, glAccount, currencyCode, transactionId, manualEntry, transactionDate, journalEntryType.getValue(), - amount, description, entityType, entityId, referenceNumber, loanTransaction, savingsTransaction); + + public static JournalEntry createNew(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, + final String currencyCode, final String transactionId, final boolean manualEntry, final Date transactionDate, + final JournalEntryType journalEntryType, final BigDecimal amount, final String description, final Integer entityType, + final Long entityId, final String referenceNumber, final LoanTransaction loanTransaction, + final SavingsAccountTransaction savingsTransaction) { + return new JournalEntry(office, paymentDetail, glAccount, currencyCode, transactionId, manualEntry, transactionDate, + journalEntryType.getValue(), amount, description, entityType, entityId, referenceNumber, loanTransaction, + savingsTransaction); } protected JournalEntry() { // } - public JournalEntry(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, final String currencyCode, final String transactionId, - final boolean manualEntry, final Date transactionDate, final Integer type, final BigDecimal amount, final String description, - final Integer entityType, final Long entityId, final String referenceNumber, final LoanTransaction loanTransaction, - final SavingsAccountTransaction savingsTransaction) { + public JournalEntry(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, final String currencyCode, + final String transactionId, final boolean manualEntry, final Date transactionDate, final Integer type, final BigDecimal amount, + final String description, final Integer entityType, final Long entityId, final String referenceNumber, + final LoanTransaction loanTransaction, final SavingsAccountTransaction savingsTransaction) { this.office = office; this.glAccount = glAccount; this.reversalJournalEntry = null; @@ -118,9 +120,9 @@ public class JournalEntry extends AbstractAuditableCustom { this.entityId = entityId; this.referenceNumber = referenceNumber; this.currencyCode = currencyCode; - this.loanTransaction = loanTransaction; + this.loanTransaction = loanTransaction; this.savingsTransaction = savingsTransaction; - this.paymentDetail=paymentDetail; + this.paymentDetail = paymentDetail; } public boolean isDebitEntry() { @@ -163,18 +165,16 @@ public class JournalEntry extends AbstractAuditableCustom { return this.currencyCode; } - public LoanTransaction getLoanTransaction() { return this.loanTransaction; } - public SavingsAccountTransaction getSavingsTransaction() { return this.savingsTransaction; } - - public PaymentDetail getPaymentDetails(){ - return this.paymentDetail; + + public PaymentDetail getPaymentDetails() { + return this.paymentDetail; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java index 0b350d1ea..b7dae13bf 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java @@ -173,7 +173,7 @@ public class AccountingProcessorHelper { } final SavingsTransactionDTO transaction = new SavingsTransactionDTO(transactionOfficeId, paymentTypeId, transactionId, - transactionDate, transactionType, amount, reversed, feePayments, penaltyPayments,overdraftAmount); + transactionDate, transactionType, amount, reversed, feePayments, penaltyPayments, overdraftAmount); newSavingsTransactions.add(transaction); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/CashBasedAccountingProcessorForSavings.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/CashBasedAccountingProcessorForSavings.java index ad50c3bf7..18879c1c2 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/CashBasedAccountingProcessorForSavings.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/CashBasedAccountingProcessorForSavings.java @@ -49,25 +49,24 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess if (savingsTransactionDTO.getTransactionType().isWithdrawal() && savingsTransactionDTO.isOverdraftTransaction()) { this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, - CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId, - paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal); - if(amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1){ + CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, + savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal); + if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal); } - } - else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) { + } else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) { this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, - CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, savingsProductId, - paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); - if(amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1){ + CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, + savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); + if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal); } } - + /** Handle Deposits and reversals of deposits **/ else if (savingsTransactionDTO.getTransactionType().isDeposit()) { this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, @@ -120,19 +119,17 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); } - + /** overdraft **/ else if (savingsTransactionDTO.getTransactionType().isOverdraftInterest()) { this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); - } - else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) { + } else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) { this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, - CASH_ACCOUNTS_FOR_SAVINGS.LOSSES_WRITTEN_OFF, CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, savingsProductId, - paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); - } - else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) { + CASH_ACCOUNTS_FOR_SAVINGS.LOSSES_WRITTEN_OFF, CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, + savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); + } else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) { this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java index 106a5c29a..c581ab149 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java @@ -13,8 +13,8 @@ import org.mifosplatform.infrastructure.core.service.Page; import org.mifosplatform.portfolio.group.service.SearchParameters; public interface JournalEntryReadPlatformService { - - JournalEntryData retrieveGLJournalEntryById(long glJournalEntryId, JournalEntryAssociationParametersData associationParametersData); + + JournalEntryData retrieveGLJournalEntryById(long glJournalEntryId, JournalEntryAssociationParametersData associationParametersData); Page retrieveAll(SearchParameters searchParameters, Long glAccountId, Boolean onlyManualEntries, Date fromDate, Date toDate, String transactionId, Integer entityType, JournalEntryAssociationParametersData associationParametersData); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryRunningBalanceUpdateServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryRunningBalanceUpdateServiceImpl.java index a088e2a41..3cd657f1c 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryRunningBalanceUpdateServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryRunningBalanceUpdateServiceImpl.java @@ -149,7 +149,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry List entryDatas = jdbcTemplate.query(entryMapper.organizationRunningBalanceSchema(), entryMapper, new Object[] { entityDate }); - if(entryDatas.size()>0){ + if (entryDatas.size() > 0) { String[] updateSql = new String[entryDatas.size()]; int i = 0; for (JournalEntryData entryData : entryDatas) { @@ -268,7 +268,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId); return new JournalEntryData(id, officeId, null, null, glAccountId, null, accountType, null, entryType, amount, null, null, - null, null, null, null, null, null, null, null, null, null, null,null, null); + null, null, null, null, null, null, null, null, null, null, null, null, null); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java index 24ea892da..c8fa6e227 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/AuditsApiResource.java @@ -85,11 +85,12 @@ public class AuditsApiResource { final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - if (parameters.isPaged()){ - final Page auditEntries = this.auditReadPlatformService.retrievePaginatedAuditEntries(extraCriteria, settings.isIncludeJson(), parameters); - return this.toApiJsonSerializer.serialize(settings, auditEntries, this.RESPONSE_DATA_PARAMETERS); + if (parameters.isPaged()) { + final Page auditEntries = this.auditReadPlatformService.retrievePaginatedAuditEntries(extraCriteria, + settings.isIncludeJson(), parameters); + return this.toApiJsonSerializer.serialize(settings, auditEntries, this.RESPONSE_DATA_PARAMETERS); } - + final Collection auditEntries = this.auditReadPlatformService.retrieveAuditEntries(extraCriteria, settings.isIncludeJson()); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java index d9278f271..02ed76875 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java @@ -329,10 +329,11 @@ public class CommandWrapper { public boolean isLoanChargeResource() { return this.entityName.equalsIgnoreCase("LOANCHARGE"); } + public boolean isLoanDisburseDetailResource() { return this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL"); } - + public boolean isCollateralResource() { return this.entityName.equalsIgnoreCase("COLLATERAL"); } @@ -380,11 +381,11 @@ public class CommandWrapper { public boolean isLoanWriteOff() { return this.actionName.equalsIgnoreCase("WRITEOFF") && this.entityName.equalsIgnoreCase("LOAN"); } - + public boolean isUndoLoanWriteOff() { return this.actionName.equalsIgnoreCase("UNDOWRITEOFF") && this.entityName.equalsIgnoreCase("LOAN"); } - + public boolean isUpdateDisbursementDate() { return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL"); } @@ -603,7 +604,7 @@ public class CommandWrapper { public boolean isHolidayResource() { return this.entityName.equalsIgnoreCase("HOLIDAY"); } - + public boolean isHolidayActivation() { return this.entityName.equalsIgnoreCase("HOLIDAY") && this.actionName.equalsIgnoreCase("ACTIVATE") && this.entityId != null; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformService.java index 83d2f9613..9d4d1e925 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformService.java @@ -15,7 +15,7 @@ import org.mifosplatform.infrastructure.core.service.Page; public interface AuditReadPlatformService { Collection retrieveAuditEntries(String extraCriteria, boolean includeJson); - + Page retrievePaginatedAuditEntries(String extraCriteria, boolean includeJson, PaginationParameters parameters); Collection retrieveAllEntriesToBeChecked(String extraCriteria, boolean includeJson); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java index 00f85c2b8..fab9cffa7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java @@ -159,18 +159,19 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService { if (StringUtils.isNotBlank(extraCriteria)) { updatedExtraCriteria = " where (" + extraCriteria + ")"; } - + updatedExtraCriteria += " order by aud.id DESC limit " + PaginationParameters.getCheckedLimit(null); return retrieveEntries("audit", updatedExtraCriteria, includeJson); } - + @Override - public Page retrievePaginatedAuditEntries(final String extraCriteria, final boolean includeJson, final PaginationParameters parameters) { - + public Page retrievePaginatedAuditEntries(final String extraCriteria, final boolean includeJson, + final PaginationParameters parameters) { + this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "audits"); final AppUser currentUser = this.context.authenticatedUser(); final String hierarchy = currentUser.getOffice().getHierarchy(); - + String updatedExtraCriteria = ""; if (StringUtils.isNotBlank(extraCriteria)) { updatedExtraCriteria = " where (" + extraCriteria + ")"; @@ -181,19 +182,19 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService { sqlBuilder.append("select SQL_CALC_FOUND_ROWS "); sqlBuilder.append(rm.schema(includeJson, hierarchy)); sqlBuilder.append(' ').append(updatedExtraCriteria); - + if (parameters.isOrderByRequested()) { sqlBuilder.append(' ').append(parameters.orderBySql()); - }else { + } else { sqlBuilder.append(' ').append(' ').append(" order by aud.id DESC"); } - + if (parameters.isLimited()) { sqlBuilder.append(' ').append(parameters.limitSql()); } - + logger.info("sql: " + sqlBuilder.toString()); - + final String sqlCountRows = "SELECT FOUND_ROWS()"; return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), new Object[] {}, rm); } @@ -243,7 +244,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService { return this.jdbcTemplate.query(sql, rm, new Object[] {}); } - + @Override public AuditData retrieveAuditEntry(final Long auditId) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java index bcac311f6..8419a112d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java @@ -59,7 +59,7 @@ public class CommandWrapperBuilder { this.entityName = "CONFIGURATION"; this.entityId = configId; - this.href = "/configurations/"+configId; + this.href = "/configurations/" + configId; return this; } @@ -574,7 +574,7 @@ public class CommandWrapperBuilder { this.href = "/loans/" + loanId + "/transactions/template?command=writeoff"; return this; } - + public CommandWrapperBuilder undoWriteOffLoanTransaction(final Long loanId) { this.actionName = "UNDOWRITEOFF"; this.entityName = "LOAN"; @@ -584,7 +584,6 @@ public class CommandWrapperBuilder { return this; } - public CommandWrapperBuilder closeLoanAsRescheduledTransaction(final Long loanId) { this.actionName = "CLOSEASRESCHEDULED"; this.entityName = "LOAN"; @@ -629,8 +628,8 @@ public class CommandWrapperBuilder { this.href = "/loans/" + loanId; return this; } - - public CommandWrapperBuilder updateDisbusementDate(final Long loanId,final Long disbursementId) { + + public CommandWrapperBuilder updateDisbusementDate(final Long loanId, final Long disbursementId) { this.actionName = "UPDATE"; this.entityName = "DISBURSEMENTDETAIL"; this.entityId = disbursementId; @@ -639,7 +638,6 @@ public class CommandWrapperBuilder { return this; } - public CommandWrapperBuilder deleteLoanApplication(final Long loanId) { this.actionName = "DELETE"; this.entityName = "LOAN"; @@ -827,7 +825,6 @@ public class CommandWrapperBuilder { return this; } - public CommandWrapperBuilder createSavingProduct() { this.actionName = "CREATE"; this.entityName = "SAVINGSPRODUCT"; @@ -1332,7 +1329,7 @@ public class CommandWrapperBuilder { this.href = "/holidays/template"; return this; } - + public CommandWrapperBuilder activateHoliday(final Long holidayId) { this.actionName = "ACTIVATE"; this.entityName = "HOLIDAY"; @@ -1340,15 +1337,15 @@ public class CommandWrapperBuilder { this.href = "/holidays/" + holidayId + "command=activate"; return this; } - + public CommandWrapperBuilder updateHoliday(final Long holidayId) { this.actionName = "UPDATE"; this.entityName = "HOLIDAY"; this.entityId = holidayId; - this.href = "/holidays/" + holidayId ; + this.href = "/holidays/" + holidayId; return this; } - + public CommandWrapperBuilder deleteHoliday(final Long holidayId) { this.actionName = "DELETE"; this.entityName = "HOLIDAY"; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java index ccb64d6d6..f64306300 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java @@ -72,7 +72,6 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker); } catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) { - result = this.processAndLogCommandService.logCommand(e.getCommandSourceResult()); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java index 3aca59986..f8348a4ec 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java @@ -362,11 +362,11 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer } else if (wrapper.isPayLoanCharge()) { handler = this.applicationContext.getBean("payLoanChargeCommandHandler", NewCommandSourceHandler.class); } - } else if(wrapper.isLoanDisburseDetailResource()){ - if(wrapper.isUpdateDisbursementDate()){ + } else if (wrapper.isLoanDisburseDetailResource()) { + if (wrapper.isUpdateDisbursementDate()) { handler = this.applicationContext.getBean("updateLoanDisbuseDateCommandHandler", NewCommandSourceHandler.class); } - }else if (wrapper.isGLAccountResource()) { + } else if (wrapper.isGLAccountResource()) { if (wrapper.isCreate()) { handler = this.applicationContext.getBean("createGLAccountCommandHandler", NewCommandSourceHandler.class); } else if (wrapper.isUpdate()) { @@ -391,9 +391,9 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer handler = this.applicationContext.getBean("createJournalEntryCommandHandler", NewCommandSourceHandler.class); } else if (wrapper.isRevertJournalEntry()) { handler = this.applicationContext.getBean("reverseJournalEntryCommandHandler", NewCommandSourceHandler.class); - }else if(wrapper.isUpdateRunningbalance()){ + } else if (wrapper.isUpdateRunningbalance()) { handler = this.applicationContext.getBean("updateRunningBalanceCommandHandler", NewCommandSourceHandler.class); - }else { + } else { throw new UnsupportedCommandException(wrapper.commandName()); } } else if (wrapper.isSavingsProductResource()) { @@ -435,9 +435,12 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer handler = this.applicationContext.getBean("calculateInterestSavingsAccountCommandHandler", NewCommandSourceHandler.class); } else if (wrapper.isSavingsAccountInterestPosting()) { handler = this.applicationContext.getBean("postInterestSavingsAccountCommandHandler", NewCommandSourceHandler.class); - } /*else if (wrapper.isSavingsAccountApplyAnnualFee()) { - handler = this.applicationContext.getBean("applyAnnualFeeSavingsAccountCommandHandler", NewCommandSourceHandler.class); - } */else if (wrapper.isSavingsAccountUndoTransaction()) { + } /* + * else if (wrapper.isSavingsAccountApplyAnnualFee()) { handler = + * this.applicationContext.getBean( + * "applyAnnualFeeSavingsAccountCommandHandler", + * NewCommandSourceHandler.class); } + */else if (wrapper.isSavingsAccountUndoTransaction()) { handler = this.applicationContext.getBean("undoTransactionSavingsAccountCommandHandler", NewCommandSourceHandler.class); } else if (wrapper.isAdjustSavingsAccountTransaction()) { handler = this.applicationContext.getBean("savingsTransactionAdjustmentCommandHandler", NewCommandSourceHandler.class); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java index 421d9637b..dc8ba0267 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java @@ -51,12 +51,11 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl final String name = rs.getString("name"); final boolean enabled = rs.getBoolean("enabled"); - final Long value = rs.getLong("value"); + final Long value = rs.getLong("value"); final Long id = rs.getLong("id"); - return new GlobalConfigurationPropertyData(name, enabled,value,id); + return new GlobalConfigurationPropertyData(name, enabled, value, id); } } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java index d3d7a350e..cc49db79e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java @@ -28,7 +28,7 @@ import com.google.gson.reflect.TypeToken; /** * Immutable representation of a command. - * + * * Wraps the provided JSON with convenience functions for extracting parameter * values and checking for changes against an existing value. */ @@ -317,9 +317,9 @@ public final class JsonCommand { } public Map mapValueOfParameterNamed(final String json) { - final Type typeOfMap = new TypeToken>() {}.getType(); - final Map value = this.fromApiJsonHelper.extractDataMap(typeOfMap, json); - return value; + final Type typeOfMap = new TypeToken>() {}.getType(); + final Map value = this.fromApiJsonHelper.extractDataMap(typeOfMap, json); + return value; } public boolean isChangeInBigDecimalParameterNamedDefaultingZeroToNull(final String parameterName, final BigDecimal existingValue) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/DataValidatorBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/DataValidatorBuilder.java index 009445a54..1beaded8a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/DataValidatorBuilder.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/DataValidatorBuilder.java @@ -364,17 +364,17 @@ public class DataValidatorBuilder { } return this; } - + public DataValidatorBuilder integerGreaterThanNumber(Integer number) { if (this.value == null && this.ignoreNullValue) { return this; } if (this.value != null) { final Integer intValue = Integer.valueOf(this.value.toString()); - if (intValue < number+1) { + if (intValue < number + 1) { final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") .append(this.parameter).append(".not.greater.than.specified.number"); - final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append( - " must be greater than ").append(number); + final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter) + .append(" must be greater than ").append(number); final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), this.parameter, intValue, number); this.dataValidationErrors.add(error); @@ -382,7 +382,7 @@ public class DataValidatorBuilder { } return this; } - + public DataValidatorBuilder integerSameAsNumber(Integer number) { if (this.value == null && this.ignoreNullValue) { return this; } @@ -391,8 +391,8 @@ public class DataValidatorBuilder { if (intValue != number) { final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") .append(this.parameter).append(".not.equal.to.specified.number"); - final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append( - " must be same as").append(number); + final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter) + .append(" must be same as").append(number); final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), this.parameter, intValue, number); this.dataValidationErrors.add(error); @@ -401,7 +401,6 @@ public class DataValidatorBuilder { return this; } - /* * should be used with .notNull() before it */ diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParameters.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParameters.java index efb1a192b..c4eff368a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParameters.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParameters.java @@ -19,17 +19,17 @@ public class PaginationParameters { private final Integer limit; private final String orderBy; private final String sortOrder; - - public static PaginationParameters instance (Boolean paged, Integer offset, Integer limit, String orderBy, String sortOrder){ - if( null == paged) { + + public static PaginationParameters instance(Boolean paged, Integer offset, Integer limit, String orderBy, String sortOrder) { + if (null == paged) { paged = false; } - + final Integer maxLimitAllowed = getCheckedLimit(limit); - + return new PaginationParameters(paged, offset, maxLimitAllowed, orderBy, sortOrder); } - + private PaginationParameters(boolean paged, Integer offset, Integer limit, String orderBy, String sortOrder) { this.paged = paged; this.offset = offset; @@ -37,7 +37,7 @@ public class PaginationParameters { this.orderBy = orderBy; this.sortOrder = sortOrder; } - + public static Integer getCheckedLimit(final Integer limit) { final Integer maxLimitAllowed = 200; @@ -53,27 +53,27 @@ public class PaginationParameters { return checkedLimit; } - + public boolean isPaged() { return this.paged; } - + public Integer getOffset() { return this.offset; } - + public Integer getLimit() { return this.limit; } - + public String getOrderBy() { return this.orderBy; } - + public String getSortOrder() { return this.sortOrder; } - + public boolean isOrderByRequested() { return StringUtils.isNotBlank(this.orderBy); } @@ -81,7 +81,7 @@ public class PaginationParameters { public boolean isSortOrderProvided() { return StringUtils.isNotBlank(this.sortOrder); } - + public boolean isLimited() { return this.limit != null && this.limit.intValue() > 0; } @@ -89,10 +89,10 @@ public class PaginationParameters { public boolean isOffset() { return this.offset != null; } - - public String orderBySql(){ + + public String orderBySql() { final StringBuffer sql = new StringBuffer(); - + if (this.isOrderByRequested()) { sql.append(" order by ").append(this.getOrderBy()); if (this.isSortOrderProvided()) { @@ -101,15 +101,15 @@ public class PaginationParameters { } return sql.toString(); } - - public String limitSql(){ + + public String limitSql() { final StringBuffer sql = new StringBuffer(); if (this.isLimited()) { sql.append(" limit ").append(this.getLimit()); if (this.isOffset()) { sql.append(" offset ").append(this.getOffset()); } - } + } return sql.toString(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParametersDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParametersDataValidator.java index c6f086acf..4bab152f3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParametersDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/PaginationParametersDataValidator.java @@ -16,25 +16,31 @@ import org.springframework.stereotype.Component; @Component public class PaginationParametersDataValidator { + public static Set sortOrderValues = new HashSet(Arrays.asList("ASC", "DESC")); + public void validateParameterValues(PaginationParameters parameters, final Set supportedOrdeByValues, final String resourceName) { - + final List dataValidationErrors = new ArrayList(); - - if (parameters.isOrderByRequested() && !supportedOrdeByValues.contains(parameters.getOrderBy())){ - final String defaultUserMessage = "The orderBy value '" + parameters.getOrderBy() + "' is not supported. The supported orderBy values are " + supportedOrdeByValues.toString(); - final ApiParameterError error = ApiParameterError.parameterError("validation.msg."+resourceName+".orderBy.value.is.not.supported", - defaultUserMessage, "orderBy", parameters.getOrderBy(), supportedOrdeByValues.toString()); + + if (parameters.isOrderByRequested() && !supportedOrdeByValues.contains(parameters.getOrderBy())) { + final String defaultUserMessage = "The orderBy value '" + parameters.getOrderBy() + + "' is not supported. The supported orderBy values are " + supportedOrdeByValues.toString(); + final ApiParameterError error = ApiParameterError.parameterError("validation.msg." + resourceName + + ".orderBy.value.is.not.supported", defaultUserMessage, "orderBy", parameters.getOrderBy(), + supportedOrdeByValues.toString()); dataValidationErrors.add(error); } - - if (parameters.isSortOrderProvided() && !sortOrderValues.contains(parameters.getSortOrder().toUpperCase())){ - final String defaultUserMessage = "The sortOrder value '" + parameters.getSortOrder() + "' is not supported. The supported sortOrder values are " + sortOrderValues.toString(); - final ApiParameterError error = ApiParameterError.parameterError("validation.msg."+resourceName+".sortOrder.value.is.not.supported", - defaultUserMessage, "sortOrder", parameters.getSortOrder(), sortOrderValues.toString()); + + if (parameters.isSortOrderProvided() && !sortOrderValues.contains(parameters.getSortOrder().toUpperCase())) { + final String defaultUserMessage = "The sortOrder value '" + parameters.getSortOrder() + + "' is not supported. The supported sortOrder values are " + sortOrderValues.toString(); + final ApiParameterError error = ApiParameterError.parameterError("validation.msg." + resourceName + + ".sortOrder.value.is.not.supported", defaultUserMessage, "sortOrder", parameters.getSortOrder(), + sortOrderValues.toString()); dataValidationErrors.add(error); } - + throwExceptionIfValidationWarningsExist(dataValidationErrors); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/FromJsonHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/FromJsonHelper.java index 92f0268d8..e1daac334 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/FromJsonHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/FromJsonHelper.java @@ -148,7 +148,7 @@ public class FromJsonHelper { public MonthDay extractMonthDayNamed(final String parameterName, final JsonElement element) { return this.helperDelegator.extractMonthDayNamed(parameterName, element); } - + public MonthDay extractMonthDayNamed(final String parameterName, final JsonObject object, final String dateFormat, final Locale clientApplicationLocale) { return this.helperDelegator.extractMonthDayNamed(parameterName, object, dateFormat, clientApplicationLocale); @@ -220,7 +220,7 @@ public class FromJsonHelper { public String extractDateFormatParameter(final JsonObject element) { return this.helperDelegator.extractDateFormatParameter(element); } - + public String extractMonthDayFormatParameter(final JsonObject element) { return this.helperDelegator.extractMonthDayFormatParameter(element); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/JsonParserHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/JsonParserHelper.java index 1ae274ce9..407526c34 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/JsonParserHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/serialization/JsonParserHelper.java @@ -36,7 +36,7 @@ import com.google.gson.JsonPrimitive; public class JsonParserHelper { public boolean parameterExists(final String parameterName, final JsonElement element) { - if (element == null) {return false;} + if (element == null) { return false; } return element.getAsJsonObject().has(parameterName); } @@ -144,10 +144,10 @@ public class JsonParserHelper { /** * Method used to extract integers from unformatted strings. Ex: "1" , * "100002" etc - * + * * Please note that this method does not support extracting Integers from * locale specific formatted strings Ex "1,000" etc - * + * * @param parameterName * @param element * @param parametersPassedInRequest @@ -514,9 +514,9 @@ public class JsonParserHelper { final NumberFormatter numberFormatter = new NumberFormatter(); final Number parsedNumber = numberFormatter.parse(source, clientApplicationLocale); - if(parsedNumber instanceof BigDecimal){ - number = (BigDecimal)parsedNumber; - }else{ + if (parsedNumber instanceof BigDecimal) { + number = (BigDecimal) parsedNumber; + } else { number = BigDecimal.valueOf(Double.valueOf(parsedNumber.doubleValue())); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/DateUtils.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/DateUtils.java index dd8032f2d..aec12e287 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/DateUtils.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/DateUtils.java @@ -64,7 +64,7 @@ public class DateUtils { return formattedSqlDate; } - public static boolean isDateInTheFuture(final LocalDate localDate){ + public static boolean isDateInTheFuture(final LocalDate localDate) { return localDate.isAfter(getLocalDateOfTenant()); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java index f3f36d34d..62ceacc59 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java @@ -159,7 +159,7 @@ public final class ResultsetColumnHeaderData { private boolean isBigInt() { return "bigint".equalsIgnoreCase(this.columnType); } - + private boolean isBit() { return "bit".equalsIgnoreCase(this.columnType); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java index e09f2d44a..5f493aed9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java @@ -826,7 +826,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ + datatableName.toLowerCase().replaceAll("\\s", "_") + "_%'"; sqlArray = new String[2]; sqlArray[1] = deleteColumnCodeSql; - }else{ + } else { sqlArray = new String[1]; } final String sql = "DROP TABLE `" + datatableName + "`"; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java index 18becb349..9997e9de6 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java @@ -73,9 +73,7 @@ public class ImageReadPlatformServiceImpl implements ImageReadPlatformService { final ContentRepository contentRepository = this.contentRepositoryFactory.getRepository(imageData.storageType()); final ImageData result = contentRepository.fetchImage(imageData); - if (result.getContent() == null) { - throw new ImageNotFoundException("clients", clientId); - } + if (result.getContent() == null) { throw new ImageNotFoundException("clients", clientId); } return result; } catch (final EmptyResultDataAccessException e) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/jobs/service/JobRegisterServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/jobs/service/JobRegisterServiceImpl.java index f7a73d49d..23d3763fc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/jobs/service/JobRegisterServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/jobs/service/JobRegisterServiceImpl.java @@ -38,7 +38,7 @@ import org.springframework.stereotype.Service; * Service class to create and load batch jobs to Scheduler using * {@link SchedulerFactoryBean} ,{@link MethodInvokingJobDetailFactoryBean} and * {@link CronTriggerFactoryBean} - * + * */ @Service public class JobRegisterServiceImpl implements JobRegisterService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java index d07099ea1..dede38b88 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java @@ -41,7 +41,7 @@ public class SmsMessage extends AbstractPersistable { @Column(name = "status_enum", nullable = false) private Integer statusType; - @Column(name = "mobile_no", nullable = false, length=50) + @Column(name = "mobile_no", nullable = false, length = 50) private String mobileNo; @Column(name = "message", nullable = false) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java index f8715c461..72bee4aa3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java @@ -30,10 +30,8 @@ public class SmsMessageAssembler { private final FromJsonHelper fromApiJsonHelper; @Autowired - public SmsMessageAssembler(final SmsMessageRepository smsMessageRepository, - final GroupRepositoryWrapper groupRepositoryWrapper, - final ClientRepositoryWrapper clientRepository, - final StaffRepositoryWrapper staffRepository, + public SmsMessageAssembler(final SmsMessageRepository smsMessageRepository, final GroupRepositoryWrapper groupRepositoryWrapper, + final ClientRepositoryWrapper clientRepository, final StaffRepositoryWrapper staffRepository, final FromJsonHelper fromApiJsonHelper) { this.smsMessageRepository = smsMessageRepository; this.groupRepository = groupRepositoryWrapper; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageEnumerations.java index b514bb64f..e7cb31b08 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageEnumerations.java @@ -14,24 +14,29 @@ public class SmsMessageEnumerations { } public static EnumOptionData status(final SmsMessageStatusType status) { - EnumOptionData optionData = new EnumOptionData(SmsMessageStatusType.INVALID.getValue().longValue(), SmsMessageStatusType.INVALID.getCode(), - "Invalid"); + EnumOptionData optionData = new EnumOptionData(SmsMessageStatusType.INVALID.getValue().longValue(), + SmsMessageStatusType.INVALID.getCode(), "Invalid"); switch (status) { case INVALID: - optionData = new EnumOptionData(SmsMessageStatusType.INVALID.getValue().longValue(), SmsMessageStatusType.INVALID.getCode(), "Invalid"); + optionData = new EnumOptionData(SmsMessageStatusType.INVALID.getValue().longValue(), + SmsMessageStatusType.INVALID.getCode(), "Invalid"); break; case PENDING: - optionData = new EnumOptionData(SmsMessageStatusType.PENDING.getValue().longValue(), SmsMessageStatusType.PENDING.getCode(), "Pending"); + optionData = new EnumOptionData(SmsMessageStatusType.PENDING.getValue().longValue(), + SmsMessageStatusType.PENDING.getCode(), "Pending"); break; case SENT: - optionData = new EnumOptionData(SmsMessageStatusType.SENT.getValue().longValue(), SmsMessageStatusType.SENT.getCode(), "Sent"); - break; + optionData = new EnumOptionData(SmsMessageStatusType.SENT.getValue().longValue(), SmsMessageStatusType.SENT.getCode(), + "Sent"); + break; case DELIVERED: - optionData = new EnumOptionData(SmsMessageStatusType.DELIVERED.getValue().longValue(), SmsMessageStatusType.DELIVERED.getCode(), "Delivered"); - break; + optionData = new EnumOptionData(SmsMessageStatusType.DELIVERED.getValue().longValue(), + SmsMessageStatusType.DELIVERED.getCode(), "Delivered"); + break; case FAILED: - optionData = new EnumOptionData(SmsMessageStatusType.FAILED.getValue().longValue(), SmsMessageStatusType.FAILED.getCode(), "Failed"); - break; + optionData = new EnumOptionData(SmsMessageStatusType.FAILED.getValue().longValue(), SmsMessageStatusType.FAILED.getCode(), + "Failed"); + break; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/service/SmsWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/service/SmsWritePlatformServiceJpaRepositoryImpl.java index a6f4d3f14..45473cd34 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/service/SmsWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/service/SmsWritePlatformServiceJpaRepositoryImpl.java @@ -48,8 +48,11 @@ public class SmsWritePlatformServiceJpaRepositoryImpl implements SmsWritePlatfor final SmsMessage message = this.assembler.assembleFromJson(command); - // TODO: at this point we also want to fire off request using third party service to send SMS. - // TODO: decision to be made on wheter we 'wait' for response or use 'future/promise' to capture response and update the SmsMessage table + // TODO: at this point we also want to fire off request using third + // party service to send SMS. + // TODO: decision to be made on wheter we 'wait' for response or use + // 'future/promise' to capture response and update the SmsMessage + // table this.repository.save(message); return new CommandProcessingResultBuilder() // @@ -108,9 +111,8 @@ public class SmsWritePlatformServiceJpaRepositoryImpl implements SmsWritePlatfor private void handleDataIntegrityIssues(@SuppressWarnings("unused") final JsonCommand command, final DataIntegrityViolationException dve) { final Throwable realCause = dve.getMostSpecificCause(); - if (realCause.getMessage().contains("mobile_no")) { - throw new PlatformDataIntegrityException("error.msg.sms.no.mobile.no.exists", "The group, client or staff provided has no mobile no.", "id"); - } + if (realCause.getMessage().contains("mobile_no")) { throw new PlatformDataIntegrityException("error.msg.sms.no.mobile.no.exists", + "The group, client or staff provided has no mobile no.", "id"); } logger.error(dve.getMessage(), dve); throw new PlatformDataIntegrityException("error.msg.sms.unknown.data.integrity.issue", diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidayApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidayApiConstants.java index 1563342ee..933fcb736 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidayApiConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidayApiConstants.java @@ -25,8 +25,10 @@ public class HolidayApiConstants { public static final String status = "status"; public static final Set HOLIDAY_CREATE_OR_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, - dateFormatParamName, nameParamName, fromDateParamName, toDateParamName, descriptionParamName, officesParamName, repaymentsRescheduledToParamName)); - + dateFormatParamName, nameParamName, fromDateParamName, toDateParamName, descriptionParamName, officesParamName, + repaymentsRescheduledToParamName)); + public static final Set HOLIDAY_RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList(idParamName, nameParamName, - fromDateParamName, descriptionParamName, toDateParamName, repaymentsRescheduledToParamName, localeParamName, dateFormatParamName, status)); + fromDateParamName, descriptionParamName, toDateParamName, repaymentsRescheduledToParamName, localeParamName, + dateFormatParamName, status)); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidaysApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidaysApiResource.java index beb5c18b5..5343a56d0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidaysApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/api/HolidaysApiResource.java @@ -70,7 +70,7 @@ public class HolidaysApiResource { return this.toApiJsonSerializer.serialize(result); } - + @POST @Path("{holidayId}") @Consumes({ MediaType.APPLICATION_JSON }) @@ -95,7 +95,7 @@ public class HolidaysApiResource { return this.toApiJsonSerializer.serialize(result); } - + @GET @Path("{holidayId}") @Consumes({ MediaType.APPLICATION_JSON }) @@ -103,29 +103,27 @@ public class HolidaysApiResource { public String retrieveOne(@PathParam("holidayId") final Long holidayId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(HOLIDAY_RESOURCE_NAME); - + final HolidayData holidayData = this.holidayReadPlatformService.retrieveHoliday(holidayId); - + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - - + return this.toApiJsonSerializer.serialize(settings, holidayData, HOLIDAY_RESPONSE_DATA_PARAMETERS); } - + @PUT @Path("{holidayId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String update(@PathParam("holidayId") final Long holidayId, final String jsonRequestBody) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateHoliday(holidayId) - .withJson(jsonRequestBody).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateHoliday(holidayId).withJson(jsonRequestBody).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); return this.toApiJsonSerializer.serialize(result); } - + @DELETE @Path("{holidayId}") @Consumes({ MediaType.APPLICATION_JSON }) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayDataValidator.java index bf5bad476..485402ea2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/data/HolidayDataValidator.java @@ -38,7 +38,8 @@ public class HolidayDataValidator { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } final Type typeOfMap = new TypeToken>() {}.getType(); - this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, HolidayApiConstants.HOLIDAY_CREATE_OR_UPDATE_REQUEST_DATA_PARAMETERS); + this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, + HolidayApiConstants.HOLIDAY_CREATE_OR_UPDATE_REQUEST_DATA_PARAMETERS); final JsonElement element = this.fromApiJsonHelper.parse(json); final List dataValidationErrors = new ArrayList(); @@ -55,14 +56,15 @@ public class HolidayDataValidator { final LocalDate toDate = this.fromApiJsonHelper.extractLocalDateNamed(HolidayApiConstants.toDateParamName, element); baseDataValidator.reset().parameter(HolidayApiConstants.toDateParamName).value(toDate).notNull(); - final LocalDate repaymentsRescheduledTo = this.fromApiJsonHelper.extractLocalDateNamed(HolidayApiConstants.repaymentsRescheduledToParamName, - element); + final LocalDate repaymentsRescheduledTo = this.fromApiJsonHelper.extractLocalDateNamed( + HolidayApiConstants.repaymentsRescheduledToParamName, element); baseDataValidator.reset().parameter(HolidayApiConstants.repaymentsRescheduledToParamName).value(repaymentsRescheduledTo).notNull(); Set offices = null; final JsonObject topLevelJsonElement = element.getAsJsonObject(); - if (topLevelJsonElement.has(HolidayApiConstants.officesParamName) && topLevelJsonElement.get(HolidayApiConstants.officesParamName).isJsonArray()) { + if (topLevelJsonElement.has(HolidayApiConstants.officesParamName) + && topLevelJsonElement.get(HolidayApiConstants.officesParamName).isJsonArray()) { final JsonArray array = topLevelJsonElement.get(HolidayApiConstants.officesParamName).getAsJsonArray(); if (array.size() > 0) { @@ -78,7 +80,7 @@ public class HolidayDataValidator { baseDataValidator.reset().parameter(HolidayApiConstants.officesParamName).value(offices).notNull(); throwExceptionIfValidationWarningsExist(dataValidationErrors); } - + public void validateForUpdate(final String json) { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } @@ -111,13 +113,15 @@ public class HolidayDataValidator { if (this.fromApiJsonHelper.parameterExists(HolidayApiConstants.repaymentsRescheduledToParamName, element)) { final LocalDate repaymentsRescheduledTo = this.fromApiJsonHelper.extractLocalDateNamed( HolidayApiConstants.repaymentsRescheduledToParamName, element); - baseDataValidator.reset().parameter(HolidayApiConstants.repaymentsRescheduledToParamName).value(repaymentsRescheduledTo).notNull(); + baseDataValidator.reset().parameter(HolidayApiConstants.repaymentsRescheduledToParamName).value(repaymentsRescheduledTo) + .notNull(); } Set offices = null; final JsonObject topLevelJsonElement = element.getAsJsonObject(); if (this.fromApiJsonHelper.parameterExists(HolidayApiConstants.officesParamName, element)) { - if (topLevelJsonElement.has(HolidayApiConstants.officesParamName) && topLevelJsonElement.get(HolidayApiConstants.officesParamName).isJsonArray()) { + if (topLevelJsonElement.has(HolidayApiConstants.officesParamName) + && topLevelJsonElement.get(HolidayApiConstants.officesParamName).isJsonArray()) { final JsonArray array = topLevelJsonElement.get(HolidayApiConstants.officesParamName).getAsJsonArray(); if (array.size() > 0) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/Holiday.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/Holiday.java index 738ba940a..5caf6a5a9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/Holiday.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/Holiday.java @@ -66,7 +66,7 @@ public class Holiday extends AbstractPersistable { @Column(name = "status_enum", nullable = false) private Integer status; - + @Column(name = "processed", nullable = false) private boolean processed; @@ -81,20 +81,20 @@ public class Holiday extends AbstractPersistable { final String name = command.stringValueOfParameterNamed(HolidayApiConstants.nameParamName); final LocalDate fromDate = command.localDateValueOfParameterNamed(HolidayApiConstants.fromDateParamName); final LocalDate toDate = command.localDateValueOfParameterNamed(HolidayApiConstants.toDateParamName); - final LocalDate repaymentsRescheduledTo = command.localDateValueOfParameterNamed(HolidayApiConstants.repaymentsRescheduledToParamName); + final LocalDate repaymentsRescheduledTo = command + .localDateValueOfParameterNamed(HolidayApiConstants.repaymentsRescheduledToParamName); final Integer status = HolidayStatusType.PENDING_FOR_ACTIVATION.getValue(); final boolean processed = false;// default it to false. Only batch job // should update this field. final String description = command.stringValueOfParameterNamed(HolidayApiConstants.descriptionParamName); return new Holiday(name, fromDate, toDate, repaymentsRescheduledTo, status, processed, description, offices); } - + public Map update(final JsonCommand command) { final Map actualChanges = new LinkedHashMap(7); final List dataValidationErrors = new ArrayList(); - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) - .resource("holiday" + ".update"); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("holiday" + ".update"); final HolidayStatusType currentStatus = HolidayStatusType.fromInt(this.status); @@ -106,7 +106,7 @@ public class Holiday extends AbstractPersistable { actualChanges.put(nameParamName, newValue); this.name = StringUtils.defaultIfEmpty(newValue, null); } - + if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) { final String newValue = command.stringValueOfParameterNamed(descriptionParamName); actualChanges.put(descriptionParamName, newValue); @@ -171,7 +171,7 @@ public class Holiday extends AbstractPersistable { return actualChanges; } - + public boolean update(final Set newOffices) { if (newOffices == null) { return false; } @@ -260,21 +260,20 @@ public class Holiday extends AbstractPersistable { public void processed() { this.processed = true; } - + public void activate() { final List dataValidationErrors = new ArrayList(); - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) - .resource("holiday" + ".activate"); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("holiday" + ".activate"); final HolidayStatusType currentStatus = HolidayStatusType.fromInt(this.status); if (!currentStatus.isPendingActivation()) { baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("not.in.pending.for.activation.state"); if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } } - + this.status = HolidayStatusType.ACTIVE.getValue(); } - + public void delete() { final List dataValidationErrors = new ArrayList(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("holiday" + ".delete"); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepository.java index d9246a0bd..7c26ed707 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepository.java @@ -16,7 +16,8 @@ import org.springframework.data.repository.query.Param; public interface HolidayRepository extends JpaRepository, JpaSpecificationExecutor { @Query("select holiday from Holiday holiday, IN(holiday.offices) office where (holiday.fromDate >= :date OR :date <= holiday.toDate) and holiday.status = :status and office.id = :officeId") - List findByOfficeIdAndGreaterThanDate(@Param("officeId") Long officeId, @Param("date") Date date, @Param("status") Integer status); + List findByOfficeIdAndGreaterThanDate(@Param("officeId") Long officeId, @Param("date") Date date, + @Param("status") Integer status); @Query("from Holiday holiday where holiday.processed = false and holiday.status = :status") List findUnprocessed(@Param("status") Integer status); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepositoryWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepositoryWrapper.java index 4d040ad6d..ecb65e77f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepositoryWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayRepositoryWrapper.java @@ -37,8 +37,8 @@ public class HolidayRepositoryWrapper { public void save(final Holiday holiday) { this.repository.save(holiday); } - - public void save(final Iterable holidays){ + + public void save(final Iterable holidays) { this.repository.save(holidays); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayStatusType.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayStatusType.java index cffe51d66..e743c7c9a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayStatusType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/domain/HolidayStatusType.java @@ -5,7 +5,6 @@ */ package org.mifosplatform.organisation.holiday.domain; - /** * Enum representation of {@link Holiday} status states. */ @@ -15,7 +14,7 @@ public enum HolidayStatusType { PENDING_FOR_ACTIVATION(100, "holidayStatusType.pending.for.activation"), // ACTIVE(300, "holidayStatusType.active"), // DELETED(600, "savingsAccountStatusType.transfer.in.progress"); - + private final Integer value; private final String code; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayEnumerations.java index 038472eb6..4dcfdaa78 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayEnumerations.java @@ -26,10 +26,12 @@ public class HolidayEnumerations { HolidayStatusType.PENDING_FOR_ACTIVATION.getCode(), "Pending for activation"); break; case ACTIVE: - optionData = new EnumOptionData(HolidayStatusType.ACTIVE.getValue().longValue(), HolidayStatusType.ACTIVE.getCode(), "Active"); + optionData = new EnumOptionData(HolidayStatusType.ACTIVE.getValue().longValue(), HolidayStatusType.ACTIVE.getCode(), + "Active"); break; case DELETED: - optionData = new EnumOptionData(HolidayStatusType.DELETED.getValue().longValue(), HolidayStatusType.DELETED.getCode(), "Deleted"); + optionData = new EnumOptionData(HolidayStatusType.DELETED.getValue().longValue(), HolidayStatusType.DELETED.getCode(), + "Deleted"); break; } return optionData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformService.java index 5a66047f0..70ec8ac1e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformService.java @@ -8,6 +8,6 @@ import org.mifosplatform.organisation.holiday.data.HolidayData; public interface HolidayReadPlatformService { Collection retrieveAllHolidaysBySearchParamerters(final Long officeId, Date fromDate, Date toDate); - + HolidayData retrieveHoliday(final Long holidayId); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java index f8811207b..b08947612 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayReadPlatformServiceImpl.java @@ -115,5 +115,5 @@ public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformServic throw new HolidayNotFoundException(holidayId); } } - + } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformService.java index 1f0cf0301..e0655fb12 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformService.java @@ -7,14 +7,14 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; public interface HolidayWritePlatformService { CommandProcessingResult createHoliday(JsonCommand command); - + CommandProcessingResult updateHoliday(JsonCommand command); - + CommandProcessingResult activateHoliday(final Long holidayId); - + CommandProcessingResult deleteHoliday(final Long holidayId); - + boolean isHoliday(Long officeId, LocalDate transactionDate); - + boolean isTransactionAllowedOnHoliday(); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformServiceJpaRepositoryImpl.java index b2582ba1b..c2809ae9d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/holiday/service/HolidayWritePlatformServiceJpaRepositoryImpl.java @@ -51,8 +51,9 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit @Autowired public HolidayWritePlatformServiceJpaRepositoryImpl(final HolidayDataValidator fromApiJsonDeserializer, - final HolidayRepositoryWrapper holidayRepository, final PlatformSecurityContext context, final OfficeRepository officeRepository, - final FromJsonHelper fromApiJsonHelper, final WorkingDaysRepositoryWrapper daysRepositoryWrapper, final ConfigurationDomainService configurationDomainService) { + final HolidayRepositoryWrapper holidayRepository, final PlatformSecurityContext context, + final OfficeRepository officeRepository, final FromJsonHelper fromApiJsonHelper, + final WorkingDaysRepositoryWrapper daysRepositoryWrapper, final ConfigurationDomainService configurationDomainService) { this.fromApiJsonDeserializer = fromApiJsonDeserializer; this.holidayRepository = holidayRepository; this.context = context; @@ -84,7 +85,7 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit return CommandProcessingResult.empty(); } } - + @Transactional @Override public CommandProcessingResult updateHoliday(final JsonCommand command) { @@ -114,19 +115,18 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit return CommandProcessingResult.empty(); } } - + @Transactional @Override public CommandProcessingResult activateHoliday(final Long holidayId) { this.context.authenticatedUser(); final Holiday holiday = this.holidayRepository.findOneWithNotFoundDetection(holidayId); - + holiday.activate(); this.holidayRepository.saveAndFlush(holiday); - return new CommandProcessingResultBuilder() - .withEntityId(holiday.getId()).build(); + return new CommandProcessingResultBuilder().withEntityId(holiday.getId()).build(); } - + @Transactional @Override public CommandProcessingResult deleteHoliday(final Long holidayId) { @@ -134,14 +134,14 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit final Holiday holiday = this.holidayRepository.findOneWithNotFoundDetection(holidayId); holiday.delete(); this.holidayRepository.saveAndFlush(holiday); - return new CommandProcessingResultBuilder() - .withEntityId(holidayId).build(); + return new CommandProcessingResultBuilder().withEntityId(holidayId).build(); } private Set getSelectedOffices(final JsonCommand command) { Set offices = null; final JsonObject topLevelJsonElement = this.fromApiJsonHelper.parse(command.json()).getAsJsonObject(); - if (topLevelJsonElement.has(HolidayApiConstants.officesParamName) && topLevelJsonElement.get(HolidayApiConstants.officesParamName).isJsonArray()) { + if (topLevelJsonElement.has(HolidayApiConstants.officesParamName) + && topLevelJsonElement.get(HolidayApiConstants.officesParamName).isJsonArray()) { final JsonArray array = topLevelJsonElement.get(HolidayApiConstants.officesParamName).getAsJsonArray(); offices = new HashSet(array.size()); @@ -172,11 +172,13 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit private void validateInputDates(final JsonCommand command) { final LocalDate fromDate = command.localDateValueOfParameterNamed(HolidayApiConstants.fromDateParamName); final LocalDate toDate = command.localDateValueOfParameterNamed(HolidayApiConstants.toDateParamName); - final LocalDate repaymentsRescheduledTo = command.localDateValueOfParameterNamed(HolidayApiConstants.repaymentsRescheduledToParamName); + final LocalDate repaymentsRescheduledTo = command + .localDateValueOfParameterNamed(HolidayApiConstants.repaymentsRescheduledToParamName); this.validateInputDates(fromDate, toDate, repaymentsRescheduledTo); } + private void validateInputDates(final LocalDate fromDate, final LocalDate toDate, final LocalDate repaymentsRescheduledTo) { - + String defaultUserMessage = ""; if (toDate.isBefore(fromDate)) { @@ -226,5 +228,5 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit public boolean isTransactionAllowedOnHoliday() { return this.configurationDomainService.allowTransactionsOnHolidayEnabled(); } - + } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java index aa61b384d..0f8cbcece 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java @@ -78,7 +78,7 @@ public class StaffApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String retrieveStaff(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, @QueryParam("officeId") final Long officeId, - @DefaultValue("false") @QueryParam("staffInOfficeHierarchy") final boolean staffInOfficeHierarchy, + @DefaultValue("false") @QueryParam("staffInOfficeHierarchy") final boolean staffInOfficeHierarchy, @DefaultValue("false") @QueryParam("loanOfficersOnly") final boolean loanOfficersOnly, @DefaultValue("active") @QueryParam("status") final String status) { @@ -121,7 +121,7 @@ public class StaffApiResource { if (settings.isTemplate()) { final Collection allowedOffices = this.officeReadPlatformService.retrieveAllOfficesForDropdown(); staff = StaffData.templateData(staff, allowedOffices); - } + } return this.toApiJsonSerializer.serialize(settings, staff, this.RESPONSE_DATA_PARAMETERS); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java index 3ffbb3e1a..4eb67ee7d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java @@ -38,8 +38,10 @@ public class StaffData { } public static StaffData instance(final Long id, final String firstname, final String lastname, final String displayName, - final Long officeId, final String officeName, final Boolean isLoanOfficer, final String externalId, final String mobileNo, final boolean isActive) { - return new StaffData(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo, null, isActive); + final Long officeId, final String officeName, final Boolean isLoanOfficer, final String externalId, final String mobileNo, + final boolean isActive) { + return new StaffData(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo, null, + isActive); } private StaffData(final Long id, final String firstname, final String lastname, final String displayName, final Long officeId, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java index 777a0c09d..6bc4a3214 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java @@ -51,8 +51,8 @@ public class Staff extends AbstractPersistable { @Column(name = "organisational_role_enum", nullable = true) private Integer organisationalRoleType; - - @Column (name="is_active" , nullable = false) + + @Column(name = "is_active", nullable = false) private boolean active; @ManyToOne @@ -75,7 +75,7 @@ public class Staff extends AbstractPersistable { final String isLoanOfficerParamName = "isLoanOfficer"; final boolean isLoanOfficer = command.booleanPrimitiveValueOfParameterNamed(isLoanOfficerParamName); - + final String isActiveParamName = "isActive"; final Boolean isActive = command.booleanObjectValueOfParameterNamed(isActiveParamName); @@ -162,7 +162,7 @@ public class Staff extends AbstractPersistable { actualChanges.put(isLoanOfficerParamName, newValue); this.loanOfficer = newValue; } - + final String isActiveParamName = "isActive"; if (command.isChangeInBooleanParameterNamed(isActiveParamName, this.active)) { final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(isActiveParamName); @@ -180,11 +180,11 @@ public class Staff extends AbstractPersistable { public boolean isLoanOfficer() { return this.loanOfficer; } - + public boolean isNotActive() { return !isActive(); } - + public boolean isActive() { return this.active; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java index a18cedcba..319dee492 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java @@ -72,7 +72,7 @@ public final class StaffCommandFromApiJsonDeserializer { final Boolean loanOfficerFlag = this.fromApiJsonHelper.extractBooleanNamed("isLoanOfficer", element); baseDataValidator.reset().parameter("isLoanOfficer").value(loanOfficerFlag).notNull(); } - + if (this.fromApiJsonHelper.parameterExists("isActive", element)) { final Boolean activeFlag = this.fromApiJsonHelper.extractBooleanNamed("isActive", element); baseDataValidator.reset().parameter("isActive").value(activeFlag).notNull(); @@ -115,12 +115,12 @@ public final class StaffCommandFromApiJsonDeserializer { final Boolean loanOfficerFlag = this.fromApiJsonHelper.extractBooleanNamed("isLoanOfficer", element); baseDataValidator.reset().parameter("isLoanOfficer").value(loanOfficerFlag).notNull(); } - + if (this.fromApiJsonHelper.parameterExists("isActive", element)) { final Boolean activeFlag = this.fromApiJsonHelper.extractBooleanNamed("isActive", element); baseDataValidator.reset().parameter("isActive").value(activeFlag).notNull(); } - + throwExceptionIfValidationWarningsExist(dataValidationErrors); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java index e00ba566c..f66cb34a5 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java @@ -57,7 +57,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService { final String mobileNo = rs.getString("mobileNo"); final boolean isActive = rs.getBoolean("isActive"); - return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo, isActive); + return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo, + isActive); } } @@ -66,7 +67,7 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService { public String schema(final boolean loanOfficersOnly) { final StringBuilder sqlBuilder = new StringBuilder(200); - + sqlBuilder.append("s.id as id, s.office_id as officeId, ohierarchy.name as officeName,"); sqlBuilder.append("s.firstname as firstname, s.lastname as lastname,"); sqlBuilder.append("s.display_name as displayName, s.is_loan_officer as isLoanOfficer, s.external_id as externalId, "); @@ -98,7 +99,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService { final String mobileNo = rs.getString("mobileNo"); final boolean isActive = rs.getBoolean("isActive"); - return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo, isActive); + return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo, + isActive); } } @@ -165,7 +167,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService { } @Override - public Collection retrieveAllStaff(final String sqlSearch, final Long officeId, final boolean loanOfficersOnly, final String status) { + public Collection retrieveAllStaff(final String sqlSearch, final Long officeId, final boolean loanOfficersOnly, + final String status) { final String extraCriteria = getStaffCriteria(sqlSearch, officeId, loanOfficersOnly, status); return retrieveAllStaff(extraCriteria); } @@ -190,17 +193,17 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService { } if (officeId != null) { extraCriteria.append(" and office_id = ").append(officeId).append(" "); - } + } if (loanOfficersOnly) { extraCriteria.append(" and s.is_loan_officer is true "); } - // Passing status parameter to get ACTIVE (By Default), INACTIVE or ALL (Both active and Inactive) employees + // Passing status parameter to get ACTIVE (By Default), INACTIVE or ALL + // (Both active and Inactive) employees if (status.equalsIgnoreCase("active")) { extraCriteria.append(" and is_active = 1 "); } else if (status.equalsIgnoreCase("inActive")) { extraCriteria.append(" and is_active = 0 "); - } else if (status.equalsIgnoreCase("all")) {} - else { + } else if (status.equalsIgnoreCase("all")) {} else { throw new UnrecognizedQueryParamException("status", status, new Object[] { "all", "active", "inactive" }); } @@ -208,7 +211,7 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService { extraCriteria.delete(0, 4); } - //remove begin four letter including a space from the string. + // remove begin four letter including a space from the string. return extraCriteria.toString(); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java index b0d58377f..5db2ef828 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java @@ -100,6 +100,7 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla return CommandProcessingResult.empty(); } } + /* * Guaranteed to throw an exception no matter what the data integrity issue * is. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/workingdays/service/WorkingDaysWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/workingdays/service/WorkingDaysWritePlatformService.java index e71ae2ffd..56c3d3a0a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/workingdays/service/WorkingDaysWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/workingdays/service/WorkingDaysWritePlatformService.java @@ -3,8 +3,8 @@ package org.mifosplatform.organisation.workingdays.service; import org.joda.time.LocalDate; public interface WorkingDaysWritePlatformService { - + boolean isWorkingDay(LocalDate transactionDate); - + boolean isTransactionAllowedOnNonWorkingDay(); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/api/AccountTransfersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/api/AccountTransfersApiResource.java index 44ec1ce32..2e1d123d3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/api/AccountTransfersApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/api/AccountTransfersApiResource.java @@ -98,7 +98,8 @@ public class AccountTransfersApiResource { this.context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME); - final SearchParameters searchParameters = SearchParameters.forAccountTransfer(sqlSearch, externalId, offset, limit, orderBy, sortOrder); + final SearchParameters searchParameters = SearchParameters.forAccountTransfer(sqlSearch, externalId, offset, limit, orderBy, + sortOrder); final Page transfers = this.accountTransfersReadPlatformService.retrieveAll(searchParameters); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/data/AccountTransferDTO.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/data/AccountTransferDTO.java index 0233e7ef4..230d16a6a 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/data/AccountTransferDTO.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/data/AccountTransferDTO.java @@ -28,7 +28,8 @@ public class AccountTransferDTO { public AccountTransferDTO(final LocalDate transactionDate, final BigDecimal transactionAmount, final PortfolioAccountType fromAccountType, final PortfolioAccountType toAccountType, final Long fromAccountId, final Long toAccountId, final String description, final Locale locale, final DateTimeFormatter fmt, - final PaymentDetail paymentDetail, final Integer fromTransferType, final Integer toTransferType, final Long chargeId, Integer loanInstallmentNumber) { + final PaymentDetail paymentDetail, final Integer fromTransferType, final Integer toTransferType, final Long chargeId, + Integer loanInstallmentNumber) { this.transactionDate = transactionDate; this.transactionAmount = transactionAmount; this.fromAccountType = fromAccountType; @@ -97,7 +98,6 @@ public class AccountTransferDTO { return this.chargeId; } - public Integer getLoanInstallmentNumber() { return this.loanInstallmentNumber; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransfer.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransfer.java index 212e991a5..3d3ad317a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransfer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransfer.java @@ -176,7 +176,6 @@ public class AccountTransfer extends AbstractPersistable { return this.fromAccount; } - public void updateToLoanTransaction(LoanTransaction toLoanTransaction) { this.toLoanTransaction = toLoanTransaction; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransferRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransferRepository.java index 8fa7983af..7388291e6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransferRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/domain/AccountTransferRepository.java @@ -19,7 +19,7 @@ public interface AccountTransferRepository extends JpaRepository findAllByLoanId(@Param("accountNumber") Long accountNumber); - + @Query("from AccountTransfer at where at.toLoanTransaction.id= :loanTransactionId and at.reversed=false") AccountTransfer findByToLoanTransactionId(@Param("loanTransactionId") Long loanTransactionId); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java index 799f7b023..6fcd86d22 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java @@ -229,7 +229,8 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer final LoanTransaction loanRepaymentTransaction = this.loanAccountDomainService.makeChargePayment(toLoanAccount, accountTransferDTO.getChargeId(), accountTransferDTO.getTransactionDate(), accountTransferDTO.getTransactionAmount(), - accountTransferDTO.getPaymentDetail(), null, null, accountTransferDTO.getToTransferType(), accountTransferDTO.getLoanInstallmentNumber()); + accountTransferDTO.getPaymentDetail(), null, null, accountTransferDTO.getToTransferType(), + accountTransferDTO.getLoanInstallmentNumber()); final AccountTransfer transferTransaction = this.accountTransferAssembler.assembleSavingsToLoanTransfer(accountTransferDTO, fromSavingsAccount, toLoanAccount, withdrawal, loanRepaymentTransaction); @@ -239,12 +240,12 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer return transferTransactionId; } - + @Override @Transactional - public void updateLoanTransaction(final Long loanTransactionId,final LoanTransaction newLoanTransaction){ + public void updateLoanTransaction(final Long loanTransactionId, final LoanTransaction newLoanTransaction) { final AccountTransfer transferTransaction = this.accountTransferRepository.findByToLoanTransactionId(loanTransactionId); - if(transferTransaction!=null){ + if (transferTransaction != null) { transferTransaction.updateToLoanTransaction(newLoanTransaction); this.accountTransferRepository.save(transferTransaction); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java index e667a941f..38118e3ba 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java @@ -181,7 +181,7 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf"); final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf, currencyDisplaySymbol, currencyNameCode); - + final LocalDate submittedOnDate = JdbcSupport.getLocalDate(rs, "submittedOnDate"); final String submittedByUsername = rs.getString("submittedByUsername"); final String submittedByFirstname = rs.getString("submittedByFirstname"); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/CalendarConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/CalendarConstants.java index 7a1acedf3..95a030d5b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/CalendarConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/CalendarConstants.java @@ -10,7 +10,8 @@ import java.util.Set; public class CalendarConstants { - public static final String CALENDAR_RESOURCE_NAME = "calendar"; + public static final String CALENDAR_RESOURCE_NAME = "calendar"; + public static enum CALENDAR_SUPPORTED_PARAMETERS { CALENDAR_ID("id"), ENTITY_TYPE("entityType"), ENTITY_ID("entityId"), TITLE("title"), DESCRIPTION("description"), LOCATION( "location"), START_DATE("startDate"), END_DATE("endDate"), CREATED_DATE("createdDate"), DURATION("duration"), TYPE_ID( diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/api/CalendarsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/api/CalendarsApiResource.java index 6ed5872c3..7d9cda283 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/api/CalendarsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/api/CalendarsApiResource.java @@ -55,12 +55,12 @@ public class CalendarsApiResource { /** * The set of parameters that are supported in response for {@link Calendar} */ - private final Set RESPONSE_DATA_PARAMETERS = new HashSet( - Arrays.asList("id", "entityId", "entityType", "title", "description", "location", "startDate", "endDate", "duration", "type", - "repeating", "recurrence", "frequency", "interval", "repeatsOnDay", "remindBy", "firstReminder", "secondReminder", - "humanReadable", "createdDate", "lastUpdatedDate", "createdByUserId", "createdByUsername", "lastUpdatedByUserId", - "lastUpdatedByUsername", "recurringDates", "nextTenRecurringDates", "entityTypeOptions", "calendarTypeOptions", - "remindByOptions", "frequencyOptions", "repeatsOnDayOptions")); + private final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "entityId", "entityType", "title", + "description", "location", "startDate", "endDate", "duration", "type", "repeating", "recurrence", "frequency", "interval", + "repeatsOnDay", "remindBy", "firstReminder", "secondReminder", "humanReadable", "createdDate", "lastUpdatedDate", + "createdByUserId", "createdByUsername", "lastUpdatedByUserId", "lastUpdatedByUsername", "recurringDates", + "nextTenRecurringDates", "entityTypeOptions", "calendarTypeOptions", "remindByOptions", "frequencyOptions", + "repeatsOnDayOptions")); private final String resourceNameForPermissions = "CALENDAR"; private final PlatformSecurityContext context; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/data/CalendarData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/data/CalendarData.java index 4410779c9..299438926 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/data/CalendarData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/data/CalendarData.java @@ -60,12 +60,13 @@ public class CalendarData { final List frequencyOptions; final List repeatsOnDayOptions; - public static CalendarData instance(final Long id, final Long calendarInstanceId, final Long entityId, final EnumOptionData entityType, final String title, - final String description, final String location, final LocalDate startDate, final LocalDate endDate, final Integer duration, - final EnumOptionData type, final boolean repeating, final String recurrence, final EnumOptionData frequency, - final Integer interval, final EnumOptionData repeatsOnDay, final EnumOptionData remindBy, final Integer firstReminder, - final Integer secondReminder, final String humanReadable, final LocalDate createdDate, final LocalDate lastUpdatedDate, - final Long createdByUserId, final String createdByUsername, final Long lastUpdatedByUserId, final String lastUpdatedByUsername) { + public static CalendarData instance(final Long id, final Long calendarInstanceId, final Long entityId, final EnumOptionData entityType, + final String title, final String description, final String location, final LocalDate startDate, final LocalDate endDate, + final Integer duration, final EnumOptionData type, final boolean repeating, final String recurrence, + final EnumOptionData frequency, final Integer interval, final EnumOptionData repeatsOnDay, final EnumOptionData remindBy, + final Integer firstReminder, final Integer secondReminder, final String humanReadable, final LocalDate createdDate, + final LocalDate lastUpdatedDate, final Long createdByUserId, final String createdByUsername, final Long lastUpdatedByUserId, + final String lastUpdatedByUsername) { final Collection recurringDates = null; final Collection nextTenRecurringDates = null; @@ -77,8 +78,8 @@ public class CalendarData { final List frequencyOptions = null; final List repeatsOnDayOptions = null; - return new CalendarData(id, calendarInstanceId, entityId, entityType, title, description, location, startDate, endDate, duration, type, repeating, - recurrence, frequency, interval, repeatsOnDay, remindBy, firstReminder, secondReminder, recurringDates, + return new CalendarData(id, calendarInstanceId, entityId, entityType, title, description, location, startDate, endDate, duration, + type, repeating, recurrence, frequency, interval, repeatsOnDay, remindBy, firstReminder, secondReminder, recurringDates, nextTenRecurringDates, humanReadable, recentEligibleMeetingDate, createdDate, lastUpdatedDate, createdByUserId, createdByUsername, lastUpdatedByUserId, lastUpdatedByUsername, entityTypeOptions, calendarTypeOptions, remindByOptions, frequencyOptions, repeatsOnDayOptions); @@ -86,27 +87,27 @@ public class CalendarData { public static CalendarData withRecurringDates(final CalendarData calendarData, final Collection recurringDates, final Collection nextTenRecurringDates, final LocalDate recentEligibleMeetingDate) { - return new CalendarData(calendarData.id, calendarData.calendarInstanceId, calendarData.entityId, calendarData.entityType, calendarData.title, - calendarData.description, calendarData.location, calendarData.startDate, calendarData.endDate, calendarData.duration, - calendarData.type, calendarData.repeating, calendarData.recurrence, calendarData.frequency, calendarData.interval, - calendarData.repeatsOnDay, calendarData.remindBy, calendarData.firstReminder, calendarData.secondReminder, recurringDates, - nextTenRecurringDates, calendarData.humanReadable, recentEligibleMeetingDate, calendarData.createdDate, - calendarData.lastUpdatedDate, calendarData.createdByUserId, calendarData.createdByUsername, + return new CalendarData(calendarData.id, calendarData.calendarInstanceId, calendarData.entityId, calendarData.entityType, + calendarData.title, calendarData.description, calendarData.location, calendarData.startDate, calendarData.endDate, + calendarData.duration, calendarData.type, calendarData.repeating, calendarData.recurrence, calendarData.frequency, + calendarData.interval, calendarData.repeatsOnDay, calendarData.remindBy, calendarData.firstReminder, + calendarData.secondReminder, recurringDates, nextTenRecurringDates, calendarData.humanReadable, recentEligibleMeetingDate, + calendarData.createdDate, calendarData.lastUpdatedDate, calendarData.createdByUserId, calendarData.createdByUsername, calendarData.lastUpdatedByUserId, calendarData.lastUpdatedByUsername, calendarData.entityTypeOptions, calendarData.calendarTypeOptions, calendarData.remindByOptions, calendarData.frequencyOptions, calendarData.repeatsOnDayOptions); } - + public static CalendarData withRecentEligibleMeetingDate(final CalendarData calendarData, final LocalDate recentEligibleMeetingDate) { - return new CalendarData(calendarData.id, calendarData.calendarInstanceId, calendarData.entityId, calendarData.entityType, calendarData.title, - calendarData.description, calendarData.location, calendarData.startDate, calendarData.endDate, calendarData.duration, - calendarData.type, calendarData.repeating, calendarData.recurrence, calendarData.frequency, calendarData.interval, - calendarData.repeatsOnDay, calendarData.remindBy, calendarData.firstReminder, calendarData.secondReminder, calendarData.recurringDates, - calendarData.nextTenRecurringDates, calendarData.humanReadable, recentEligibleMeetingDate, calendarData.createdDate, - calendarData.lastUpdatedDate, calendarData.createdByUserId, calendarData.createdByUsername, - calendarData.lastUpdatedByUserId, calendarData.lastUpdatedByUsername, calendarData.entityTypeOptions, - calendarData.calendarTypeOptions, calendarData.remindByOptions, calendarData.frequencyOptions, - calendarData.repeatsOnDayOptions); + return new CalendarData(calendarData.id, calendarData.calendarInstanceId, calendarData.entityId, calendarData.entityType, + calendarData.title, calendarData.description, calendarData.location, calendarData.startDate, calendarData.endDate, + calendarData.duration, calendarData.type, calendarData.repeating, calendarData.recurrence, calendarData.frequency, + calendarData.interval, calendarData.repeatsOnDay, calendarData.remindBy, calendarData.firstReminder, + calendarData.secondReminder, calendarData.recurringDates, calendarData.nextTenRecurringDates, calendarData.humanReadable, + recentEligibleMeetingDate, calendarData.createdDate, calendarData.lastUpdatedDate, calendarData.createdByUserId, + calendarData.createdByUsername, calendarData.lastUpdatedByUserId, calendarData.lastUpdatedByUsername, + calendarData.entityTypeOptions, calendarData.calendarTypeOptions, calendarData.remindByOptions, + calendarData.frequencyOptions, calendarData.repeatsOnDayOptions); } public static CalendarData sensibleDefaultsForNewCalendarCreation() { @@ -147,8 +148,8 @@ public class CalendarData { final Long lastUpdatedByUserId = null; final String lastUpdatedByUsername = null; - return new CalendarData(id, calendarInstanceId, entityId, entityType, title, description, location, startDate, endDate, duration, type, repeating, - recurrence, frequency, interval, repeatsOnDay, remindBy, firstReminder, secondReminder, recurringDates, + return new CalendarData(id, calendarInstanceId, entityId, entityType, title, description, location, startDate, endDate, duration, + type, repeating, recurrence, frequency, interval, repeatsOnDay, remindBy, firstReminder, secondReminder, recurringDates, nextTenRecurringDates, humanReadable, recentEligibleMeetingDate, createdDate, lastUpdatedDate, createdByUserId, createdByUsername, lastUpdatedByUserId, lastUpdatedByUsername, entityTypeOptions, calendarTypeOptions, remindByOptions, frequencyOptions, repeatsOnDayOptions); @@ -158,26 +159,27 @@ public class CalendarData { final List calendarTypeOptions, final List remindByOptions, final List repeatsOptions, final List repeatsOnDayOptions) { - return new CalendarData(calendarData.id, calendarData.calendarInstanceId, calendarData.entityId, calendarData.entityType, calendarData.title, - calendarData.description, calendarData.location, calendarData.startDate, calendarData.endDate, calendarData.duration, - calendarData.type, calendarData.repeating, calendarData.recurrence, calendarData.frequency, calendarData.interval, - calendarData.repeatsOnDay, calendarData.remindBy, calendarData.firstReminder, calendarData.secondReminder, - calendarData.recurringDates, calendarData.nextTenRecurringDates, calendarData.humanReadable, + return new CalendarData(calendarData.id, calendarData.calendarInstanceId, calendarData.entityId, calendarData.entityType, + calendarData.title, calendarData.description, calendarData.location, calendarData.startDate, calendarData.endDate, + calendarData.duration, calendarData.type, calendarData.repeating, calendarData.recurrence, calendarData.frequency, + calendarData.interval, calendarData.repeatsOnDay, calendarData.remindBy, calendarData.firstReminder, + calendarData.secondReminder, calendarData.recurringDates, calendarData.nextTenRecurringDates, calendarData.humanReadable, calendarData.recentEligibleMeetingDate, calendarData.createdDate, calendarData.lastUpdatedDate, - calendarData.createdByUserId, calendarData.createdByUsername, calendarData.lastUpdatedByUserId, calendarData.lastUpdatedByUsername, - entityTypeOptions, calendarTypeOptions, remindByOptions, repeatsOptions, repeatsOnDayOptions); + calendarData.createdByUserId, calendarData.createdByUsername, calendarData.lastUpdatedByUserId, + calendarData.lastUpdatedByUsername, entityTypeOptions, calendarTypeOptions, remindByOptions, repeatsOptions, + repeatsOnDayOptions); } - private CalendarData(final Long id, final Long calendarInstanceId, final Long entityId, final EnumOptionData entityType, final String title, final String description, - final String location, final LocalDate startDate, final LocalDate endDate, final Integer duration, final EnumOptionData type, - final boolean repeating, final String recurrence, final EnumOptionData frequency, final Integer interval, - final EnumOptionData repeatsOnDay, final EnumOptionData remindBy, final Integer firstReminder, final Integer secondReminder, - final Collection recurringDates, final Collection nextTenRecurringDates, final String humanReadable, - final LocalDate recentEligibleMeetingDate, final LocalDate createdDate, final LocalDate lastUpdatedDate, - final Long createdByUserId, final String createdByUsername, final Long lastUpdatedByUserId, final String lastUpdatedByUsername, - final List entityTypeOptions, final List calendarTypeOptions, - final List remindByOptions, final List repeatsOptions, - final List repeatsOnDayOptions) { + private CalendarData(final Long id, final Long calendarInstanceId, final Long entityId, final EnumOptionData entityType, + final String title, final String description, final String location, final LocalDate startDate, final LocalDate endDate, + final Integer duration, final EnumOptionData type, final boolean repeating, final String recurrence, + final EnumOptionData frequency, final Integer interval, final EnumOptionData repeatsOnDay, final EnumOptionData remindBy, + final Integer firstReminder, final Integer secondReminder, final Collection recurringDates, + final Collection nextTenRecurringDates, final String humanReadable, final LocalDate recentEligibleMeetingDate, + final LocalDate createdDate, final LocalDate lastUpdatedDate, final Long createdByUserId, final String createdByUsername, + final Long lastUpdatedByUserId, final String lastUpdatedByUsername, final List entityTypeOptions, + final List calendarTypeOptions, final List remindByOptions, + final List repeatsOptions, final List repeatsOnDayOptions) { this.id = id; this.calendarInstanceId = calendarInstanceId; this.entityId = entityId; @@ -294,18 +296,17 @@ public class CalendarData { return this.humanReadable; } - public Long getCalendarInstanceId() { return this.calendarInstanceId; } - + public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { if (this.startDate != null && compareDate != null) { if (this.startDate.isBefore(compareDate) || this.startDate.equals(compareDate)) { return true; } } return false; } - + public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { if (this.endDate != null && compareDate != null) { if (this.endDate.isAfter(compareDate) || this.endDate.isEqual(compareDate)) { return true; } @@ -313,15 +314,13 @@ public class CalendarData { return false; } - public boolean isBetweenStartAndEndDate(final LocalDate compareDate){ - if (isStartDateBeforeOrEqual(compareDate)){ - if (this.endDate == null || isEndDateAfterOrEqual(compareDate)){ - return true; - } + public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { + if (isStartDateBeforeOrEqual(compareDate)) { + if (this.endDate == null || isEndDateAfterOrEqual(compareDate)) { return true; } } return false; } - + public boolean isValidRecurringDate(final LocalDate compareDate) { if (isBetweenStartAndEndDate(compareDate)) { return CalendarUtils.isValidRedurringDate(this.getRecurrence(), this.getStartDate(), compareDate); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/Calendar.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/Calendar.java index 4cabaa144..4722367ab 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/Calendar.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/Calendar.java @@ -84,7 +84,7 @@ public class Calendar extends AbstractAuditableCustom { @OneToMany(fetch = FetchType.EAGER) @JoinColumn(name = "calendar_id") private Set calendarHistory = new HashSet(); - + protected Calendar() { } @@ -182,13 +182,13 @@ public class Calendar extends AbstractAuditableCustom { final String valueAsInput = command.stringValueOfParameterNamed(startDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName); final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); - + if (newValue.isBefore(currentDate)) { final String defaultUserMessage = "New meeting effective from date cannot be in past"; - throw new CalendarDateException("new.start.date.cannot.be.in.past", defaultUserMessage, newValue, - getStartDateLocalDate()); - }else if (isStartDateAfter(newValue) && isStartDateBeforeOrEqual(currentDate)) { - //new meeting date should be on or after start date or current date + throw new CalendarDateException("new.start.date.cannot.be.in.past", defaultUserMessage, newValue, getStartDateLocalDate()); + } else if (isStartDateAfter(newValue) && isStartDateBeforeOrEqual(currentDate)) { + // new meeting date should be on or after start date or current + // date final String defaultUserMessage = "New meeting effective from date cannot be a date before existing meeting start date"; throw new CalendarDateException("new.start.date.before.existing.date", defaultUserMessage, newValue, getStartDateLocalDate()); @@ -244,8 +244,8 @@ public class Calendar extends AbstractAuditableCustom { this.repeating = newValue; } - //if repeating is false then update recurrence to NULL - if(!this.repeating) this.recurrence = null; + // if repeating is false then update recurrence to NULL + if (!this.repeating) this.recurrence = null; final List dataValidationErrors = new ArrayList(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(CALENDAR_RESOURCE_NAME); @@ -256,7 +256,7 @@ public class Calendar extends AbstractAuditableCustom { .failWithCodeNoParameterAddedToErrorCode("must.repeat.for.collection.calendar"); if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } } - + final String newRecurrence = Calendar.constructRecurrence(command, this); if (!StringUtils.isBlank(this.recurrence) && !newRecurrence.equalsIgnoreCase(this.recurrence)) { @@ -365,7 +365,7 @@ public class Calendar extends AbstractAuditableCustom { } return endDateLocalDate; } - + public Set history() { return this.calendarHistory; } @@ -374,38 +374,36 @@ public class Calendar extends AbstractAuditableCustom { if (this.startDate != null && compareDate != null && getStartDateLocalDate().isBefore(compareDate)) { return true; } return false; } - + public boolean isStartDateBeforeOrEqual(final LocalDate compareDate) { if (this.startDate != null && compareDate != null) { if (getStartDateLocalDate().isBefore(compareDate) || getStartDateLocalDate().equals(compareDate)) { return true; } } return false; } - + public boolean isStartDateAfter(final LocalDate compareDate) { if (this.startDate != null && compareDate != null && getStartDateLocalDate().isAfter(compareDate)) { return true; } return false; } - + public boolean isStartDateAfterOrEqual(final LocalDate compareDate) { if (this.startDate != null && compareDate != null) { if (getStartDateLocalDate().isAfter(compareDate) || getStartDateLocalDate().isEqual(compareDate)) { return true; } } return false; } - + public boolean isEndDateAfterOrEqual(final LocalDate compareDate) { if (this.endDate != null && compareDate != null) { if (getEndDateLocalDate().isAfter(compareDate) || getEndDateLocalDate().isEqual(compareDate)) { return true; } } return false; } - - public boolean isBetweenStartAndEndDate(final LocalDate compareDate){ - if (isStartDateBeforeOrEqual(compareDate)){ - if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)){ - return true; - } + + public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { + if (isStartDateBeforeOrEqual(compareDate)) { + if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)) { return true; } } return false; } @@ -443,7 +441,7 @@ public class Calendar extends AbstractAuditableCustom { } return ""; } - + public boolean isValidRecurringDate(final LocalDate compareDate) { if (isBetweenStartAndEndDate(compareDate)) { return CalendarUtils.isValidRedurringDate(getRecurrence(), getStartDateLocalDate(), diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarEntityType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarEntityType.java index 495a644ec..bf65b55c1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarEntityType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarEntityType.java @@ -82,7 +82,7 @@ public enum CalendarEntityType { public static boolean isCenter(final String name) { return CalendarEntityType.CENTERS.name().equalsIgnoreCase(name) ? true : false; } - + public static boolean isLoan(final Integer value) { return CalendarEntityType.LOANS.value.equals(value) ? true : false; } @@ -90,7 +90,7 @@ public enum CalendarEntityType { public static boolean isLoan(final String name) { return CalendarEntityType.LOANS.name().equalsIgnoreCase(name) ? true : false; } - + public static boolean isClient(final Integer value) { return CalendarEntityType.CLIENTS.value.equals(value) ? true : false; } @@ -98,19 +98,19 @@ public enum CalendarEntityType { public static boolean isClient(final String name) { return CalendarEntityType.CLIENTS.name().equalsIgnoreCase(name) ? true : false; } - + public boolean isCenter() { return this.value.equals(CalendarEntityType.CENTERS.getValue()); } - + public boolean isGroup() { return this.value.equals(CalendarEntityType.GROUPS.getValue()); } - + public boolean isLoan() { return this.value.equals(CalendarEntityType.LOANS.getValue()); } - + public boolean isClient() { return this.value.equals(CalendarEntityType.CLIENTS.getValue()); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarFrequencyType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarFrequencyType.java index a463edec2..f4985d3d0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarFrequencyType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarFrequencyType.java @@ -40,7 +40,7 @@ public enum CalendarFrequencyType { intToEnumMap.put(type.value, type); } } - + public static CalendarFrequencyType fromInt(final int i) { final CalendarFrequencyType type = intToEnumMap.get(Integer.valueOf(i)); return type; @@ -63,7 +63,7 @@ public enum CalendarFrequencyType { return frequency; } - + public static int getMinValue() { return minValue; } @@ -76,12 +76,12 @@ public enum CalendarFrequencyType { public String toString() { return name().toString(); } - - public boolean isWeekly(){ + + public boolean isWeekly() { return this.value.equals(CalendarFrequencyType.WEEKLY.value); } - - public boolean isInvalid(){ + + public boolean isInvalid() { return this.value.equals(CalendarFrequencyType.INVALID.value); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarHistory.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarHistory.java index 5f2d0bc53..5021b78e4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarHistory.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarHistory.java @@ -21,12 +21,12 @@ import org.springframework.data.jpa.domain.AbstractPersistable; @Entity @Table(name = "m_calendar_history") -public class CalendarHistory extends AbstractPersistable{ +public class CalendarHistory extends AbstractPersistable { @ManyToOne(optional = false) @JoinColumn(name = "calendar_id", referencedColumnName = "id", nullable = false) private Calendar calendar; - + @Column(name = "title", length = 50, nullable = false) private String title; @@ -75,7 +75,8 @@ public class CalendarHistory extends AbstractPersistable{ this.description = calendar.getDescription(); this.location = calendar.getLocation(); this.startDate = startDate; - this.endDate = calendar.getStartDate();//Calendar start date become end date for history data. + this.endDate = calendar.getStartDate();// Calendar start date become end + // date for history data. this.duration = calendar.getDuration(); this.typeId = calendar.getTypeId(); this.repeating = calendar.isRepeating(); @@ -84,7 +85,7 @@ public class CalendarHistory extends AbstractPersistable{ this.firstReminder = calendar.getFirstReminder(); this.secondReminder = calendar.getSecondReminder(); } - + public String getRecurrence() { return this.recurrence; } @@ -119,16 +120,14 @@ public class CalendarHistory extends AbstractPersistable{ return false; } - public boolean isBetweenStartAndEndDate(final LocalDate compareDate){ - if (isStartDateBeforeOrEqual(compareDate)){ - if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)){ - return true; - } + public boolean isBetweenStartAndEndDate(final LocalDate compareDate) { + if (isStartDateBeforeOrEqual(compareDate)) { + if (getEndDateLocalDate() == null || isEndDateAfterOrEqual(compareDate)) { return true; } } return false; } - - public void updateEndDate(Date historyCalEndDate){ + + public void updateEndDate(Date historyCalEndDate) { this.endDate = historyCalEndDate; } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarType.java index 409e790fc..092f8c9c1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarType.java @@ -66,8 +66,8 @@ public enum CalendarType { public String toString() { return name().toString(); } - - public boolean isCollection(){ + + public boolean isCollection() { return this.value.equals(CalendarType.COLLECTION.value); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarWeekDaysType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarWeekDaysType.java index 43ca2a71f..1845d5753 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarWeekDaysType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/domain/CalendarWeekDaysType.java @@ -35,14 +35,13 @@ public enum CalendarWeekDaysType { private static final Map intToEnumMap = new HashMap(); private static int minValue = CalendarWeekDaysType.MO.value; private static int maxValue = CalendarWeekDaysType.SU.value; - + static { for (final CalendarWeekDaysType type : CalendarWeekDaysType.values()) { intToEnumMap.put(type.value, type); } } - public static CalendarWeekDaysType fromInt(final int i) { final CalendarWeekDaysType type = intToEnumMap.get(Integer.valueOf(i)); return type; @@ -60,11 +59,11 @@ public enum CalendarWeekDaysType { public String toString() { return name().toString(); } - - public boolean isInvalid(){ + + public boolean isInvalid() { return this.value.equals(CalendarWeekDaysType.INVALID.value); } - + public static CalendarWeekDaysType fromString(final String weekDayString) { CalendarWeekDaysType weekDay = CalendarWeekDaysType.INVALID; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/serialization/CalendarCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/serialization/CalendarCommandFromApiJsonDeserializer.java index 68fcfb999..fc18c9859 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/serialization/CalendarCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/serialization/CalendarCommandFromApiJsonDeserializer.java @@ -151,8 +151,8 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element)) { final Integer interval = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element); - baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()).value(interval) - .notNull().integerGreaterThanZero(); + baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()).value(interval).notNull() + .integerGreaterThanZero(); } if (CalendarFrequencyType.fromInt(frequency).isWeekly()) { final Integer repeatsOnDay = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( @@ -261,8 +261,8 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element)) { final Integer interval = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element); - baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()).value(interval) - .notNull().integerGreaterThanZero(); + baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()).value(interval).notNull() + .integerGreaterThanZero(); } if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue(), element)) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformService.java index 79ab32f06..e0517d2ff 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformService.java @@ -16,9 +16,9 @@ public interface CalendarDropdownReadPlatformService { List retrieveCalendarTypeOptions(); List retrieveCalendarRemindByOptions(); - + List retrieveCalendarFrequencyTypeOptions(); - + List retrieveCalendarWeekDaysTypeOptions(); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformServiceImpl.java index 18a14db69..67a45b54d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarDropdownReadPlatformServiceImpl.java @@ -41,5 +41,5 @@ public class CalendarDropdownReadPlatformServiceImpl implements CalendarDropdown @Override public List retrieveCalendarWeekDaysTypeOptions() { return CalendarEnumerations.calendarWeekDaysType(CalendarWeekDaysType.values()); - } + } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarEnumerations.java index 5efc4c7f1..7a82bbceb 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarEnumerations.java @@ -67,39 +67,41 @@ public class CalendarEnumerations { } return optionDatas; } - + public static EnumOptionData calendarFrequencyType(final int id) { return calendarFrequencyType(CalendarFrequencyType.fromInt(id)); } public static EnumOptionData calendarFrequencyType(final CalendarFrequencyType calendarFrequencyType) { - final EnumOptionData optionData = new EnumOptionData(calendarFrequencyType.getValue().longValue(), calendarFrequencyType.getCode(), calendarFrequencyType.toString()); + final EnumOptionData optionData = new EnumOptionData(calendarFrequencyType.getValue().longValue(), calendarFrequencyType.getCode(), + calendarFrequencyType.toString()); return optionData; } public static List calendarFrequencyType(final CalendarFrequencyType[] calendarFrequencyTypes) { final List optionDatas = new ArrayList(); for (final CalendarFrequencyType calendarFrequencyType : calendarFrequencyTypes) { - if(!calendarFrequencyType.isInvalid()){ + if (!calendarFrequencyType.isInvalid()) { optionDatas.add(calendarFrequencyType(calendarFrequencyType)); } } return optionDatas; } - + public static EnumOptionData calendarWeekDaysType(final int id) { return calendarWeekDaysType(CalendarWeekDaysType.fromInt(id)); } public static EnumOptionData calendarWeekDaysType(final CalendarWeekDaysType calendarWeekDaysType) { - final EnumOptionData optionData = new EnumOptionData(calendarWeekDaysType.getValue().longValue(), calendarWeekDaysType.getCode(), calendarWeekDaysType.toString()); + final EnumOptionData optionData = new EnumOptionData(calendarWeekDaysType.getValue().longValue(), calendarWeekDaysType.getCode(), + calendarWeekDaysType.toString()); return optionData; } public static List calendarWeekDaysType(final CalendarWeekDaysType[] calendarWeekDaysTypes) { final List optionDatas = new ArrayList(); for (final CalendarWeekDaysType calendarWeekDaysType : calendarWeekDaysTypes) { - if(!calendarWeekDaysType.isInvalid()){ + if (!calendarWeekDaysType.isInvalid()) { optionDatas.add(calendarWeekDaysType(calendarWeekDaysType)); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformService.java index de901a4b0..ebf8973c7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformService.java @@ -34,7 +34,7 @@ public interface CalendarReadPlatformService { CalendarData retrieveLoanCalendar(final Long loanId); CalendarData retrieveCollctionCalendarByEntity(final Long entityId, final Integer entityTypeId); - + LocalDate generateNextEligibleMeetingDateForCollection(CalendarData calendarData, MeetingData lastMeetingData); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java index a91719d74..be5d039d4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarReadPlatformServiceImpl.java @@ -207,7 +207,8 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ return generateRecurringDate(calendarData, DateUtils.getLocalDateOfTenant(), tillDate, 10); } - private Collection generateRecurringDate(final CalendarData calendarData, final LocalDate fromDate, final LocalDate tillDate, final int maxCount) { + private Collection generateRecurringDate(final CalendarData calendarData, final LocalDate fromDate, + final LocalDate tillDate, final int maxCount) { if (!calendarData.isRepeating()) { return null; } final String rrule = calendarData.getRecurrence(); @@ -235,13 +236,13 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ private LocalDate getPeriodStartDate(final LocalDate seedDate, final LocalDate recurrenceStartDate, final LocalDate fromDate) { LocalDate periodStartDate = null; - if(fromDate != null) { + if (fromDate != null) { periodStartDate = fromDate; - }else { + } else { final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); if (seedDate.isBefore(currentDate.minusYears(1))) { periodStartDate = currentDate.minusYears(1); - }else{ + } else { periodStartDate = recurrenceStartDate; } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarUtils.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarUtils.java index 0334fdebc..20e6eec60 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarUtils.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarUtils.java @@ -286,17 +286,17 @@ public class CalendarUtils { final Recur recur = CalendarUtils.getICalRecur(recurringRule); return recur.getInterval(); } - - public static CalendarFrequencyType getFrequency(final String recurringRule){ + + public static CalendarFrequencyType getFrequency(final String recurringRule) { final Recur recur = CalendarUtils.getICalRecur(recurringRule); return CalendarFrequencyType.fromString(recur.getFrequency()); } - - public static CalendarWeekDaysType getRepeatsOnDay(final String recurringRule){ + + public static CalendarWeekDaysType getRepeatsOnDay(final String recurringRule) { final Recur recur = CalendarUtils.getICalRecur(recurringRule); final WeekDayList weekDays = recur.getDayList(); - if(weekDays.isEmpty()) return CalendarWeekDaysType.INVALID; - //supports only one day + if (weekDays.isEmpty()) return CalendarWeekDaysType.INVALID; + // supports only one day WeekDay weekDay = (WeekDay) weekDays.get(0); return CalendarWeekDaysType.fromString(weekDay.getDay()); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarWritePlatformServiceJpaRepositoryImpl.java index 4c50a6c28..c4f713117 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/calendar/service/CalendarWritePlatformServiceJpaRepositoryImpl.java @@ -131,7 +131,7 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } - + this.calendarRepository.save(newCalendar); final CalendarInstance newCalendarInstance = CalendarInstance.fromJson(newCalendar, command); @@ -154,27 +154,29 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr if (calendarForUpdate == null) { throw new CalendarNotFoundException(calendarId); } final Date oldStartDate = calendarForUpdate.getStartDate(); final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); - //create calendar history before updating calendar + // create calendar history before updating calendar final CalendarHistory calendarHistory = new CalendarHistory(calendarForUpdate, oldStartDate); final Map changes = calendarForUpdate.update(command); - + if (!changes.isEmpty()) { - //update calendar history table only if there is a change in calendar start date. - if(currentDate.isAfter(new LocalDate(oldStartDate))){ + // update calendar history table only if there is a change in + // calendar start date. + if (currentDate.isAfter(new LocalDate(oldStartDate))) { final Date endDate = calendarForUpdate.getStartDateLocalDate().minusDays(1).toDate(); calendarHistory.updateEndDate(endDate); this.calendarHistoryRepository.save(calendarHistory); } - + this.calendarRepository.saveAndFlush(calendarForUpdate); if (this.configurationDomainService.isRescheduleFutureRepaymentsEnabled() && calendarForUpdate.isRepeating()) { - //fetch all loan calendar instances associated with modifying calendar. + // fetch all loan calendar instances associated with modifying + // calendar. final Collection loanCalendarInstances = this.calendarInstanceRepository.findByCalendarIdAndEntityTypeId( calendarId, CalendarEntityType.LOANS.getValue()); if (!CollectionUtils.isEmpty(loanCalendarInstances)) { - //update all loans associated with modifying calendar + // update all loans associated with modifying calendar this.loanWritePlatformService.applyMeetingDateChanges(calendarForUpdate, loanCalendarInstances); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java index 7a27e36d1..57f69fd73 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java @@ -42,9 +42,9 @@ public class ChargeData implements Comparable, Serializable { private final List chargeAppliesToOptions;// private final List chargeTimeTypeOptions;// private final List chargePaymetModeOptions;// - + private final List loanChargeCalculationTypeOptions; - private final List loanChargeTimeTypeOptions; + private final List loanChargeTimeTypeOptions; private final List savingsChargeCalculationTypeOptions; private final List savingsChargeTimeTypeOptions; @@ -56,22 +56,23 @@ public class ChargeData implements Comparable, Serializable { return new ChargeData(null, null, null, null, null, null, null, null, false, false, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, - loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, null, null,null,null); + loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, null, null, null, null); } public static ChargeData withTemplate(final ChargeData charge, final ChargeData template) { return new ChargeData(charge.id, charge.name, charge.amount, charge.currency, charge.chargeTimeType, charge.chargeAppliesTo, - charge.chargeCalculationType, charge.chargePaymentMode, charge.penalty, charge.active,template.currencyOptions, + charge.chargeCalculationType, charge.chargePaymentMode, charge.penalty, charge.active, template.currencyOptions, template.chargeCalculationTypeOptions, template.chargeAppliesToOptions, template.chargeTimeTypeOptions, template.chargePaymetModeOptions, template.loanChargeCalculationTypeOptions, template.loanChargeTimeTypeOptions, - template.savingsChargeCalculationTypeOptions, template.savingsChargeTimeTypeOptions, charge.feeOnMonthDay, charge.feeInterval,charge.minCap,charge.maxCap); + template.savingsChargeCalculationTypeOptions, template.savingsChargeTimeTypeOptions, charge.feeOnMonthDay, + charge.feeInterval, charge.minCap, charge.maxCap); } public static ChargeData instance(final Long id, final String name, final BigDecimal amount, final CurrencyData currency, final EnumOptionData chargeTimeType, final EnumOptionData chargeAppliesTo, final EnumOptionData chargeCalculationType, - final EnumOptionData chargePaymentMode, final MonthDay feeOnMonthDay, final Integer feeInterval, final boolean penalty, final boolean active, - final BigDecimal minCap, final BigDecimal maxCap) { - + final EnumOptionData chargePaymentMode, final MonthDay feeOnMonthDay, final Integer feeInterval, final boolean penalty, + final boolean active, final BigDecimal minCap, final BigDecimal maxCap) { + final Collection currencyOptions = null; final List chargeCalculationTypeOptions = null; final List chargeAppliesToOptions = null; @@ -81,11 +82,11 @@ public class ChargeData implements Comparable, Serializable { final List loansChargeTimeTypeOptions = null; final List savingsChargeCalculationTypeOptions = null; final List savingsChargeTimeTypeOptions = null; - + return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode, penalty, active, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, - savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, feeOnMonthDay, feeInterval,minCap,maxCap); + savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap); } public static ChargeData lookup(final Long id, final String name, final boolean isPenalty) { @@ -110,11 +111,11 @@ public class ChargeData implements Comparable, Serializable { final List loansChargeTimeTypeOptions = null; final List savingsChargeCalculationTypeOptions = null; final List savingsChargeTimeTypeOptions = null; - + return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode, penalty, active, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, - savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, feeOnMonthDay, feeInterval,minCap,maxCap); + savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap); } private ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency, @@ -125,7 +126,7 @@ public class ChargeData implements Comparable, Serializable { final List chargePaymentModeOptions, final List loansChargeCalculationTypeOptions, final List loansChargeTimeTypeOptions, final List savingsChargeCalculationTypeOptions, final List savingsChargeTimeTypeOptions, final MonthDay feeOnMonthDay, final Integer feeInterval, - final BigDecimal minCap,final BigDecimal maxCap) { + final BigDecimal minCap, final BigDecimal maxCap) { this.id = id; this.name = name; this.amount = amount; @@ -177,7 +178,7 @@ public class ChargeData implements Comparable, Serializable { } return LoanChargeData.newLoanChargeDetails(this.id, this.name, this.currency, this.amount, percentage, this.chargeTimeType, - this.chargeCalculationType, this.penalty, this.chargePaymentMode,this.minCap,this.maxCap); + this.chargeCalculationType, this.penalty, this.chargePaymentMode, this.minCap, this.maxCap); } public SavingsAccountChargeData toSavingsAccountChargeData() { @@ -193,8 +194,9 @@ public class ChargeData implements Comparable, Serializable { final Collection chargeOptions = null; final LocalDate dueAsOfDate = null; - return SavingsAccountChargeData.instance(savingsChargeId, this.id, savingsAccountId, this.name, this.currency, this.amount, amountPaid, amountWaived, - amountWrittenOff, amountOutstanding, this.chargeTimeType, dueAsOfDate, this.chargeCalculationType, percentage, - amountPercentageAppliedTo, chargeOptions, this.penalty, this.feeOnMonthDay, this.feeInterval); + return SavingsAccountChargeData.instance(savingsChargeId, this.id, savingsAccountId, this.name, this.currency, this.amount, + amountPaid, amountWaived, amountWrittenOff, amountOutstanding, this.chargeTimeType, dueAsOfDate, + this.chargeCalculationType, percentage, amountPercentageAppliedTo, chargeOptions, this.penalty, this.feeOnMonthDay, + this.feeInterval); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java index 820754e81..4c543c3a9 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java @@ -124,7 +124,6 @@ public class Charge extends AbstractPersistable { this.active = active; this.chargePaymentMode = paymentMode == null ? null : paymentMode.getValue(); - final List dataValidationErrors = new ArrayList(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("charges"); @@ -161,7 +160,7 @@ public class Charge extends AbstractPersistable { .failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.loan"); } } - if(isPercentageOfAmount()){ + if (isPercentageOfAmount()) { this.minCap = minCap; this.maxCap = maxCap; } @@ -425,7 +424,7 @@ public class Charge extends AbstractPersistable { /** * Delete is a soft delete. Updates flag on charge so it wont appear * in query/report results. - * + * * Any fields with unique constraints and prepended with id of record. */ public void delete() { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeAppliesTo.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeAppliesTo.java index 71246b7f4..ec243dd7e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeAppliesTo.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeAppliesTo.java @@ -5,7 +5,6 @@ */ package org.mifosplatform.portfolio.charge.domain; - public enum ChargeAppliesTo { INVALID(0, "chargeAppliesTo.invalid"), // @@ -57,6 +56,6 @@ public enum ChargeAppliesTo { } public static Object[] validValues() { - return new Object[] {ChargeAppliesTo.LOAN.getValue(), ChargeAppliesTo.SAVINGS.getValue()}; + return new Object[] { ChargeAppliesTo.LOAN.getValue(), ChargeAppliesTo.SAVINGS.getValue() }; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeCalculationType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeCalculationType.java index 92e78543a..525d110f3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeCalculationType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeCalculationType.java @@ -31,9 +31,9 @@ public enum ChargeCalculationType { public static Object[] validValuesForLoan() { return new Integer[] { ChargeCalculationType.FLAT.getValue(), ChargeCalculationType.PERCENT_OF_AMOUNT.getValue(), - ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST.getValue(),ChargeCalculationType.PERCENT_OF_INTEREST.getValue() }; + ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST.getValue(), ChargeCalculationType.PERCENT_OF_INTEREST.getValue() }; } - + public static Object[] validValuesForSavings() { return new Integer[] { ChargeCalculationType.FLAT.getValue(), ChargeCalculationType.PERCENT_OF_AMOUNT.getValue() }; } @@ -76,8 +76,8 @@ public enum ChargeCalculationType { public boolean isAllowedSavingsChargeCalculationType() { return isFlat() || isPercentageOfAmount(); } - - public boolean isPercentageBased(){ + + public boolean isPercentageBased() { return isPercentageOfAmount() || isPercentageOfAmountAndInterest() || isPercentageOfInterest(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeTimeType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeTimeType.java index 793dec74f..11eed65a1 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeTimeType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/ChargeTimeType.java @@ -17,9 +17,10 @@ public enum ChargeTimeType { WITHDRAWAL_FEE(5, "chargeTimeType.withdrawalFee"), // only for savings ANNUAL_FEE(6, "chargeTimeType.annualFee"), // only for savings MONTHLY_FEE(7, "chargeTimeType.monthlyFee"), // only for savings - INSTALMENT_FEE(8, "chargeTimeType.instalmentFee"),// only for loan charges - OVERDUE_INSTALLMENT(9, "chargeTimeType.overdueInstallment"), // only for loan charges - OVERDRAFT_FEE(10,"chargeTimeType.overdraftFee");// only for savings + INSTALMENT_FEE(8, "chargeTimeType.instalmentFee"), // only for loan charges + OVERDUE_INSTALLMENT(9, "chargeTimeType.overdueInstallment"), // only for + // loan charges + OVERDRAFT_FEE(10, "chargeTimeType.overdraftFee");// only for savings private final Integer value; private final String code; @@ -39,13 +40,13 @@ public enum ChargeTimeType { public static Object[] validLoanValues() { return new Integer[] { ChargeTimeType.DISBURSEMENT.getValue(), ChargeTimeType.SPECIFIED_DUE_DATE.getValue(), - ChargeTimeType.INSTALMENT_FEE.getValue(),ChargeTimeType.OVERDUE_INSTALLMENT.getValue() }; + ChargeTimeType.INSTALMENT_FEE.getValue(), ChargeTimeType.OVERDUE_INSTALLMENT.getValue() }; } public static Object[] validSavingsValues() { return new Integer[] { ChargeTimeType.SPECIFIED_DUE_DATE.getValue(), ChargeTimeType.SAVINGS_ACTIVATION.getValue(), ChargeTimeType.SAVINGS_CLOSURE.getValue(), ChargeTimeType.WITHDRAWAL_FEE.getValue(), ChargeTimeType.ANNUAL_FEE.getValue(), - ChargeTimeType.MONTHLY_FEE.getValue(),ChargeTimeType.OVERDRAFT_FEE.getValue() }; + ChargeTimeType.MONTHLY_FEE.getValue(), ChargeTimeType.OVERDRAFT_FEE.getValue() }; } public static ChargeTimeType fromInt(final Integer chargeTime) { @@ -122,7 +123,7 @@ public enum ChargeTimeType { return this.value.equals(ChargeTimeType.INSTALMENT_FEE.getValue()); } - public boolean isOverdueInstallment(){ + public boolean isOverdueInstallment() { return this.value.equals(ChargeTimeType.OVERDUE_INSTALLMENT.getValue()); } @@ -134,10 +135,9 @@ public enum ChargeTimeType { return isOnSpecifiedDueDate() || isSavingsActivation() || isSavingsClosure() || isWithdrawalFee() || isAnnualFee() || isMonthlyFee() || isOverdraftFee(); } - + public boolean isOverdraftFee() { return this.value.equals(ChargeTimeType.OVERDRAFT_FEE.getValue()); } - - + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBePayedException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBePayedException.java index 0d01e1b2a..dce5de2bb 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBePayedException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBePayedException.java @@ -11,7 +11,7 @@ public class LoanChargeCannotBePayedException extends AbstractPlatformDomainRule /*** enum of reasons of why Loan Charge cannot be waived **/ public static enum LOAN_CHARGE_CANNOT_BE_PAYED_REASON { - ALREADY_PAID, ALREADY_WAIVED, LOAN_INACTIVE, CHARGE_NOT_ACCOUNT_TRANSFER,CHARGE_NOT_PAYABLE; + ALREADY_PAID, ALREADY_WAIVED, LOAN_INACTIVE, CHARGE_NOT_ACCOUNT_TRANSFER, CHARGE_NOT_PAYABLE; public String errorMessage() { if (name().toString().equalsIgnoreCase("ALREADY_PAID")) { @@ -21,10 +21,8 @@ public class LoanChargeCannotBePayedException extends AbstractPlatformDomainRule } else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) { return "This loan charge can be payed as the loan associated with it is currently inactive"; } else if (name().toString().equalsIgnoreCase("CHARGE_NOT_ACCOUNT_TRANSFER")) { - return "This loan charge can be payed as the charge payment mode is not account transfer"; - }else if (name().toString().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) { - return "This loan charge is not Payable through account transfer"; - } + return "This loan charge can be payed as the charge payment mode is not account transfer"; + } else if (name().toString().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) { return "This loan charge is not Payable through account transfer"; } return name().toString(); } @@ -37,10 +35,8 @@ public class LoanChargeCannotBePayedException extends AbstractPlatformDomainRule } else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) { return "error.msg.loan.charge.associated.loan.inactive"; } else if (name().toString().equalsIgnoreCase("CHARGE_NOT_ACCOUNT_TRANSFER")) { - return "error.msg.loan.charge.payment.mode.not.account.transfer"; - }else if (name().toString().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) { - return "error.msg.loan.charge.payment.not.allowed.account.transfer"; - } + return "error.msg.loan.charge.payment.mode.not.account.transfer"; + } else if (name().toString().equalsIgnoreCase("CHARGE_NOT_PAYABLE")) { return "error.msg.loan.charge.payment.not.allowed.account.transfer"; } return name().toString(); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeUpdatedException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeUpdatedException.java index 9496410cc..36f1e9671 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeUpdatedException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeUpdatedException.java @@ -18,9 +18,7 @@ public class LoanChargeCannotBeUpdatedException extends AbstractPlatformDomainRu return "This loan charge has been partially/completely paid"; } else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) { return "This loan charge has already been waived"; - } else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) { - return "This charge cannot be updated as the loan it is associated with is not in submitted and pending approval stage"; - } + } else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) { return "This charge cannot be updated as the loan it is associated with is not in submitted and pending approval stage"; } return name().toString(); } @@ -29,9 +27,7 @@ public class LoanChargeCannotBeUpdatedException extends AbstractPlatformDomainRu return "error.msg.loan.charge.already.paid"; } else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) { return "error.msg.loan.charge.already.waived"; - } else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) { - return "error.msg.loan.charge.associated.loan.not.in.submitted.and.pending.approval.stage"; - } + } else if (name().toString().equalsIgnoreCase("LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE")) { return "error.msg.loan.charge.associated.loan.not.in.submitted.and.pending.approval.stage"; } return name().toString(); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeWaivedException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeWaivedException.java index 3ad6c9e57..e5f84db46 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeWaivedException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeWaivedException.java @@ -18,12 +18,10 @@ public class LoanChargeCannotBeWaivedException extends AbstractPlatformDomainRul return "This loan charge has been completely paid"; } else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) { return "This loan charge has already been waived"; - } else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) { - return "This loan charge can be waived as the loan associated with it is currently inactive"; - } else if(name().toString().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")){ - return "This loan charge can be waived"; - } - + } else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) { + return "This loan charge can be waived as the loan associated with it is currently inactive"; + } else if (name().toString().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")) { return "This loan charge can be waived"; } + return name().toString(); } @@ -32,11 +30,9 @@ public class LoanChargeCannotBeWaivedException extends AbstractPlatformDomainRul return "error.msg.loan.charge.already.paid"; } else if (name().toString().equalsIgnoreCase("ALREADY_WAIVED")) { return "error.msg.loan.charge.already.waived"; - } else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) { - return "error.msg.loan.charge.associated.loan.inactive"; - } else if(name().toString().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")) { - return "error.msg.loan.charge.waive.not.allowed"; - } + } else if (name().toString().equalsIgnoreCase("LOAN_INACTIVE")) { + return "error.msg.loan.charge.associated.loan.inactive"; + } else if (name().toString().equalsIgnoreCase("WAIVE_NOT_ALLOWED_FOR_CHARGE")) { return "error.msg.loan.charge.waive.not.allowed"; } return name().toString(); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/serialization/ChargeDefinitionCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/serialization/ChargeDefinitionCommandFromApiJsonDeserializer.java index 9aa6836f8..8ee7fa471 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/serialization/ChargeDefinitionCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/serialization/ChargeDefinitionCommandFromApiJsonDeserializer.java @@ -76,17 +76,21 @@ public final class ChargeDefinitionCommandFromApiJsonDeserializer { final Integer chargeTimeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeTimeType", element); baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).notNull(); if (chargeTimeType != null) { - baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).isOneOfTheseValues(ChargeTimeType.validLoanValues()); + baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType) + .isOneOfTheseValues(ChargeTimeType.validLoanValues()); } final Integer chargePaymentMode = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargePaymentMode", element); - baseDataValidator.reset().parameter("chargePaymentMode").value(chargePaymentMode).notNull().isOneOfTheseValues(ChargePaymentMode.validValues()); + baseDataValidator.reset().parameter("chargePaymentMode").value(chargePaymentMode).notNull() + .isOneOfTheseValues(ChargePaymentMode.validValues()); if (chargePaymentMode != null) { - baseDataValidator.reset().parameter("chargePaymentMode").value(chargePaymentMode).isOneOfTheseValues(ChargePaymentMode.validValues()); + baseDataValidator.reset().parameter("chargePaymentMode").value(chargePaymentMode) + .isOneOfTheseValues(ChargePaymentMode.validValues()); } - + if (chargeCalculationType != null) { - baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType).isOneOfTheseValues(ChargeCalculationType.validValuesForLoan()); + baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType) + .isOneOfTheseValues(ChargeCalculationType.validValuesForLoan()); } } else if (appliesTo.isSavingsCharge()) { @@ -94,7 +98,8 @@ public final class ChargeDefinitionCommandFromApiJsonDeserializer { final Integer chargeTimeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeTimeType", element); baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).notNull(); if (chargeTimeType != null) { - baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).isOneOfTheseValues(ChargeTimeType.validSavingsValues()); + baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType) + .isOneOfTheseValues(ChargeTimeType.validSavingsValues()); } final ChargeTimeType ctt = ChargeTimeType.fromInt(chargeTimeType); @@ -110,9 +115,10 @@ public final class ChargeDefinitionCommandFromApiJsonDeserializer { final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed("feeOnMonthDay", element); baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull(); } - + if (chargeCalculationType != null) { - baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType).isOneOfTheseValues(ChargeCalculationType.validValuesForSavings()); + baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType) + .isOneOfTheseValues(ChargeCalculationType.validValuesForSavings()); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java index 60f6c9e17..aa9a76cfc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java @@ -18,13 +18,13 @@ public interface ChargeDropdownReadPlatformService { List retrieveCollectionTimeTypes(); List retrivePaymentModes(); - + List retrieveLoanCalculationTypes(); List retrieveLoanCollectionTimeTypes(); - + List retrieveSavingsCalculationTypes(); List retrieveSavingsCollectionTimeTypes(); - + } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java index 6367220a3..3ed1f06e7 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java @@ -26,9 +26,8 @@ public class ChargeDropdownReadPlatformServiceImpl implements ChargeDropdownRead return Arrays.asList(chargeCalculationType(ChargeCalculationType.FLAT), chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT), - chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST), - chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST) - ); + chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST), + chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST)); } @Override @@ -62,12 +61,16 @@ public class ChargeDropdownReadPlatformServiceImpl implements ChargeDropdownRead @Override public List retrieveLoanCalculationTypes() { - return Arrays.asList(chargeCalculationType(ChargeCalculationType.FLAT), chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT), chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST), chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST)); + return Arrays.asList(chargeCalculationType(ChargeCalculationType.FLAT), + chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT), + chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST), + chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST)); } @Override public List retrieveLoanCollectionTimeTypes() { - return Arrays.asList(chargeTimeType(ChargeTimeType.DISBURSEMENT), chargeTimeType(ChargeTimeType.SPECIFIED_DUE_DATE),chargeTimeType(ChargeTimeType.INSTALMENT_FEE),chargeTimeType(ChargeTimeType.OVERDUE_INSTALLMENT)); + return Arrays.asList(chargeTimeType(ChargeTimeType.DISBURSEMENT), chargeTimeType(ChargeTimeType.SPECIFIED_DUE_DATE), + chargeTimeType(ChargeTimeType.INSTALMENT_FEE), chargeTimeType(ChargeTimeType.OVERDUE_INSTALLMENT)); } @Override @@ -79,9 +82,8 @@ public class ChargeDropdownReadPlatformServiceImpl implements ChargeDropdownRead @Override public List retrieveSavingsCollectionTimeTypes() { return Arrays.asList(chargeTimeType(ChargeTimeType.SPECIFIED_DUE_DATE), chargeTimeType(ChargeTimeType.SAVINGS_ACTIVATION), - //chargeTimeType(ChargeTimeType.SAVINGS_CLOSURE), - chargeTimeType(ChargeTimeType.WITHDRAWAL_FEE), - chargeTimeType(ChargeTimeType.ANNUAL_FEE), chargeTimeType(ChargeTimeType.MONTHLY_FEE), - chargeTimeType(ChargeTimeType.OVERDRAFT_FEE)); + // chargeTimeType(ChargeTimeType.SAVINGS_CLOSURE), + chargeTimeType(ChargeTimeType.WITHDRAWAL_FEE), chargeTimeType(ChargeTimeType.ANNUAL_FEE), + chargeTimeType(ChargeTimeType.MONTHLY_FEE), chargeTimeType(ChargeTimeType.OVERDRAFT_FEE)); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java index aaa72766a..821765285 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java @@ -29,29 +29,37 @@ public class ChargeEnumerations { ChargeTimeType.SPECIFIED_DUE_DATE.getCode(), "Specified due date"); break; case SAVINGS_ACTIVATION: - optionData = new EnumOptionData(ChargeTimeType.SAVINGS_ACTIVATION.getValue().longValue(), ChargeTimeType.SAVINGS_ACTIVATION.getCode(), "Savings Activation"); + optionData = new EnumOptionData(ChargeTimeType.SAVINGS_ACTIVATION.getValue().longValue(), + ChargeTimeType.SAVINGS_ACTIVATION.getCode(), "Savings Activation"); break; case SAVINGS_CLOSURE: - optionData = new EnumOptionData(ChargeTimeType.SAVINGS_CLOSURE.getValue().longValue(), ChargeTimeType.SAVINGS_CLOSURE.getCode(), "Savings Closure"); + optionData = new EnumOptionData(ChargeTimeType.SAVINGS_CLOSURE.getValue().longValue(), + ChargeTimeType.SAVINGS_CLOSURE.getCode(), "Savings Closure"); break; case WITHDRAWAL_FEE: - optionData = new EnumOptionData(ChargeTimeType.WITHDRAWAL_FEE.getValue().longValue(), ChargeTimeType.WITHDRAWAL_FEE.getCode(), "Withdrawal Fee"); + optionData = new EnumOptionData(ChargeTimeType.WITHDRAWAL_FEE.getValue().longValue(), + ChargeTimeType.WITHDRAWAL_FEE.getCode(), "Withdrawal Fee"); break; case ANNUAL_FEE: - optionData = new EnumOptionData(ChargeTimeType.ANNUAL_FEE.getValue().longValue(), ChargeTimeType.ANNUAL_FEE.getCode(), "Annual Fee"); + optionData = new EnumOptionData(ChargeTimeType.ANNUAL_FEE.getValue().longValue(), ChargeTimeType.ANNUAL_FEE.getCode(), + "Annual Fee"); break; case MONTHLY_FEE: - optionData = new EnumOptionData(ChargeTimeType.MONTHLY_FEE.getValue().longValue(), ChargeTimeType.MONTHLY_FEE.getCode(), "Monthly Fee"); + optionData = new EnumOptionData(ChargeTimeType.MONTHLY_FEE.getValue().longValue(), ChargeTimeType.MONTHLY_FEE.getCode(), + "Monthly Fee"); break; case INSTALMENT_FEE: - optionData = new EnumOptionData(ChargeTimeType.INSTALMENT_FEE.getValue().longValue(), ChargeTimeType.INSTALMENT_FEE.getCode(), "Instalment Fee"); + optionData = new EnumOptionData(ChargeTimeType.INSTALMENT_FEE.getValue().longValue(), + ChargeTimeType.INSTALMENT_FEE.getCode(), "Instalment Fee"); break; case OVERDUE_INSTALLMENT: - optionData = new EnumOptionData(ChargeTimeType.OVERDUE_INSTALLMENT.getValue().longValue(),ChargeTimeType.OVERDUE_INSTALLMENT.getCode(),"overdue fees") ; + optionData = new EnumOptionData(ChargeTimeType.OVERDUE_INSTALLMENT.getValue().longValue(), + ChargeTimeType.OVERDUE_INSTALLMENT.getCode(), "overdue fees"); break; case OVERDRAFT_FEE: - optionData = new EnumOptionData(ChargeTimeType.OVERDRAFT_FEE.getValue().longValue(), ChargeTimeType.OVERDRAFT_FEE.getCode(), "Overdraft Fee"); - break; + optionData = new EnumOptionData(ChargeTimeType.OVERDRAFT_FEE.getValue().longValue(), + ChargeTimeType.OVERDRAFT_FEE.getCode(), "Overdraft Fee"); + break; default: optionData = new EnumOptionData(ChargeTimeType.INVALID.getValue().longValue(), ChargeTimeType.INVALID.getCode(), "Invalid"); break; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java index 313e441b3..7d5fd6607 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java @@ -141,12 +141,11 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService return "c.id as id, c.name as name, c.amount as amount, c.currency_code as currencyCode, " + "c.charge_applies_to_enum as chargeAppliesTo, c.charge_time_enum as chargeTime, " + "c.charge_payment_mode_enum as chargePaymentMode, " - + "c.charge_calculation_enum as chargeCalculation, c.is_penalty as penalty, " - + "c.is_active as active, oc.name as currencyName, oc.decimal_places as currencyDecimalPlaces, " + + "c.charge_calculation_enum as chargeCalculation, c.is_penalty as penalty, " + + "c.is_active as active, oc.name as currencyName, oc.decimal_places as currencyDecimalPlaces, " + "oc.currency_multiplesof as inMultiplesOf, oc.display_symbol as currencyDisplaySymbol, " - + "oc.internationalized_name_code as currencyNameCode, c.fee_on_day as feeOnDay, c.fee_on_month as feeOnMonth, " - + "c.fee_interval as feeInterval,c.min_cap as minCap,c.max_cap as maxCap " - + "from m_charge c " + + "oc.internationalized_name_code as currencyNameCode, c.fee_on_day as feeOnDay, c.fee_on_month as feeOnMonth, " + + "c.fee_interval as feeInterval,c.min_cap as minCap,c.max_cap as maxCap " + "from m_charge c " + "join m_organisation_currency oc on c.currency_code = oc.code"; } @@ -198,9 +197,9 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService } final BigDecimal minCap = rs.getBigDecimal("minCap"); final BigDecimal maxCap = rs.getBigDecimal("maxCap"); - + return ChargeData.instance(id, name, amount, currency, chargeTimeType, chargeAppliesToType, chargeCalculationType, - chargePaymentMode, feeOnMonthDay, feeInterval, penalty, active,minCap,maxCap); + chargePaymentMode, feeOnMonthDay, feeInterval, penalty, active, minCap, maxCap); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java index ed7bd1805..be5ff794e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java @@ -83,26 +83,23 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP final Map changes = chargeForUpdate.update(command); - // MIFOSX-900: Check if the Charge has been active before and now is deactivated: + // MIFOSX-900: Check if the Charge has been active before and now is + // deactivated: if (changes.containsKey("active")) { - // IF the key exists then it has changed (otherwise it would have been filtered), so check current state: - if(!chargeForUpdate.isActive()) - { + // IF the key exists then it has changed (otherwise it would + // have been filtered), so check current state: + if (!chargeForUpdate.isActive()) { // TODO: Change this function to only check the mappings!!! final Boolean isChargeExistWithLoans = isAnyLoanProductsAssociateWithThisCharge(chargeId); - final Boolean isChargeExistWithSavings = isAnySavingsProductsAssociateWithThisCharge(chargeId); - - if(isChargeExistWithLoans || isChargeExistWithSavings) - { - throw new ChargeCannotBeUpdatedException( - "error.msg.charge.cannot.be.updated.it.is.used.in.loan", - "This charge cannot be updated, it is used in loan"); - } + final Boolean isChargeExistWithSavings = isAnySavingsProductsAssociateWithThisCharge(chargeId); + + if (isChargeExistWithLoans || isChargeExistWithSavings) { throw new ChargeCannotBeUpdatedException( + "error.msg.charge.cannot.be.updated.it.is.used.in.loan", "This charge cannot be updated, it is used in loan"); } } } - if (!changes.isEmpty()) { - + if (!changes.isEmpty()) { + this.chargeRepository.save(chargeForUpdate); } @@ -124,7 +121,7 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP final Collection loanProducts = this.loanProductRepository.retrieveLoanProductsByChargeId(chargeId); final Boolean isChargeExistWithLoans = isAnyLoansAssociateWithThisCharge(chargeId); final Boolean isChargeExistWithSavings = isAnySavingsAssociateWithThisCharge(chargeId); - + // TODO: Change error messages around: if (!loanProducts.isEmpty() || isChargeExistWithLoans || isChargeExistWithSavings) { throw new ChargeCannotBeDeletedException( "error.msg.charge.cannot.be.deleted.it.is.already.used.in.loan", @@ -161,22 +158,21 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP final String isLoansUsingCharge = this.jdbcTemplate.queryForObject(sql, String.class, new Object[] { chargeId }); return new Boolean(isLoansUsingCharge); } - + private boolean isAnySavingsAssociateWithThisCharge(final Long chargeId) { final String sql = "select if((exists (select 1 from m_savings_account_charge sc where sc.charge_id = ?)) = 1, 'true', 'false')"; final String isSavingsUsingCharge = this.jdbcTemplate.queryForObject(sql, String.class, new Object[] { chargeId }); return new Boolean(isSavingsUsingCharge); } - - - private boolean isAnyLoanProductsAssociateWithThisCharge(final Long chargeId) { + + private boolean isAnyLoanProductsAssociateWithThisCharge(final Long chargeId) { final String sql = "select if((exists (select 1 from m_product_loan_charge lc where lc.charge_id = ?)) = 1, 'true', 'false')"; final String isLoansUsingCharge = this.jdbcTemplate.queryForObject(sql, String.class, new Object[] { chargeId }); return new Boolean(isLoansUsingCharge); } - + private boolean isAnySavingsProductsAssociateWithThisCharge(final Long chargeId) { final String sql = "select if((exists (select 1 from m_savings_product_charge sc where sc.charge_id = ?)) = 1, 'true', 'false')"; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java index 401cd6eb9..f81c5b94e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java @@ -37,8 +37,8 @@ public class ClientApiConstants { public static final String staffIdParamName = "staffId"; public static final String closureDateParamName = "closureDate"; public static final String closureReasonIdParamName = "closureReasonId"; - public static final String submittedOnDateParamName="submittedOnDate"; - public static final String savingsProductIdParamName="savingsProductId"; + public static final String submittedOnDateParamName = "submittedOnDate"; + public static final String savingsProductIdParamName = "savingsProductId"; // response parameters public static final String statusParamName = "status"; public static final String hierarchyParamName = "hierarchy"; @@ -63,11 +63,11 @@ public class ClientApiConstants { public static final Set CLIENT_CREATE_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, dateFormatParamName, groupIdParamName, accountNoParamName, externalIdParamName, mobileNoParamName, firstnameParamName, middlenameParamName, lastnameParamName, fullnameParamName, officeIdParamName, activeParamName, activationDateParamName, - staffIdParamName,submittedOnDateParamName,savingsProductIdParamName)); + staffIdParamName, submittedOnDateParamName, savingsProductIdParamName)); public static final Set CLIENT_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, dateFormatParamName, accountNoParamName, externalIdParamName, mobileNoParamName, firstnameParamName, middlenameParamName, - lastnameParamName, fullnameParamName, activeParamName, activationDateParamName, staffIdParamName,savingsProductIdParamName)); + lastnameParamName, fullnameParamName, activeParamName, activationDateParamName, staffIdParamName, savingsProductIdParamName)); /** * These parameters will match the class level parameters of diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java index 670197d14..c4e23f962 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java @@ -135,7 +135,6 @@ public class ClientsApiResource { clientData = ClientData.templateOnTop(clientData, templateData); } - return this.toApiJsonSerializer.serialize(settings, clientData, ClientApiConstants.CLIENT_RESPONSE_DATA_PARAMETERS); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java index defa0b860..b7cfe4e78 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java @@ -50,7 +50,7 @@ final public class ClientData implements Comparable { private final Long staffId; private final String staffName; private final ClientTimelineData timeline; - + private final Long savingsProductId; private final String savingsProductName; @@ -68,7 +68,7 @@ final public class ClientData implements Comparable { final Collection staffOptions, final Collection closureReasons, final Collection savingProductOptions) { return new ClientData(null, null, officeId, null, null, null, null, null, null, null, null, null, null, null, joinedDate, null, - null, null, officeOptions, null, staffOptions, closureReasons,null, savingProductOptions,null,null); + null, null, officeOptions, null, staffOptions, closureReasons, null, savingProductOptions, null, null); } @@ -78,8 +78,8 @@ final public class ClientData implements Comparable { clientData.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename, clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo, clientData.activationDate, clientData.imageId, clientData.staffId, clientData.staffName, templateData.officeOptions, - clientData.groups, templateData.staffOptions, null,null, templateData.savingProductOptions, - clientData.savingsProductId, clientData.savingsProductName); + clientData.groups, templateData.staffOptions, null, null, templateData.savingProductOptions, clientData.savingsProductId, + clientData.savingsProductName); } @@ -88,7 +88,7 @@ final public class ClientData implements Comparable { clientData.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename, clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo, clientData.activationDate, clientData.imageId, clientData.staffId, clientData.staffName, clientData.officeOptions, - parentGroups, clientData.staffOptions, null,clientData.timeline, clientData.savingProductOptions, + parentGroups, clientData.staffOptions, null, clientData.timeline, clientData.savingProductOptions, clientData.savingsProductId, clientData.savingsProductName); } @@ -98,13 +98,13 @@ final public class ClientData implements Comparable { final String officeName) { return new ClientData(accountNo, status, officeId, officeName, null, null, id, firstname, middlename, lastname, fullname, - displayName, null, null, null, null, null, null, null, null, null, null,null, null,null,null); + displayName, null, null, null, null, null, null, null, null, null, null, null, null, null, null); } public static ClientData lookup(final Long id, final String displayName, final Long officeId, final String officeName) { return new ClientData(null, null, officeId, officeName, null, null, id, null, null, null, null, displayName, null, null, null, - null, null, null, null, null, null, null,null, null,null,null); + null, null, null, null, null, null, null, null, null, null, null); } @@ -112,20 +112,20 @@ final public class ClientData implements Comparable { final Long transferToOfficeId, final String transferToOfficeName, final Long id, final String firstname, final String middlename, final String lastname, final String fullname, final String displayName, final String externalId, final String mobileNo, final LocalDate activationDate, final Long imageId, final Long staffId, final String staffName, - final ClientTimelineData timeline,final Long savingsProductId,final String savingsProductName) { + final ClientTimelineData timeline, final Long savingsProductId, final String savingsProductName) { return new ClientData(accountNo, status, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname, middlename, lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName, null, null, null, null, - timeline, null,savingsProductId,savingsProductName); + timeline, null, savingsProductId, savingsProductName); } - + private ClientData(final String accountNo, final EnumOptionData status, final Long officeId, final String officeName, final Long transferToOfficeId, final String transferToOfficeName, final Long id, final String firstname, final String middlename, final String lastname, final String fullname, final String displayName, final String externalId, final String mobileNo, final LocalDate activationDate, final Long imageId, final Long staffId, final String staffName, final Collection allowedOffices, final Collection groups, - final Collection staffOptions, final Collection closureReasons,final ClientTimelineData timeline, - final Collection savingProductOptions,final Long savingsProductId, final String savingsProductName) { + final Collection staffOptions, final Collection closureReasons, final ClientTimelineData timeline, + final Collection savingProductOptions, final Long savingsProductId, final String savingsProductName) { this.accountNo = accountNo; this.status = status; if (status != null) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java index 6d0d1b769..1fdccdcb5 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java @@ -68,10 +68,11 @@ public final class ClientDataValidator { final String accountNo = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.accountNoParamName, element); baseDataValidator.reset().parameter(ClientApiConstants.accountNoParamName).value(accountNo).notBlank().notExceedingLengthOf(20); } - + if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.savingsProductIdParamName, element)) { final Long savingsProductId = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.savingsProductIdParamName, element); - baseDataValidator.reset().parameter(ClientApiConstants.savingsProductIdParamName).value(savingsProductId).ignoreIfNull().longGreaterThanZero(); + baseDataValidator.reset().parameter(ClientApiConstants.savingsProductIdParamName).value(savingsProductId).ignoreIfNull() + .longGreaterThanZero(); } if (isFullnameProvided(element) || isIndividualNameProvided(element)) { @@ -137,9 +138,9 @@ public final class ClientDataValidator { baseDataValidator.reset().parameter(ClientApiConstants.activeParamName).value(active).trueOrFalseRequired(false); } - if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.submittedOnDateParamName, element)) - { - final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.submittedOnDateParamName, element); + if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.submittedOnDateParamName, element)) { + final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.submittedOnDateParamName, + element); baseDataValidator.reset().parameter(ClientApiConstants.submittedOnDateParamName).value(submittedOnDate).notNull(); } @@ -310,10 +311,11 @@ public final class ClientDataValidator { final Long staffId = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.staffIdParamName, element); baseDataValidator.reset().parameter(ClientApiConstants.staffIdParamName).value(staffId).ignoreIfNull().longGreaterThanZero(); } - + if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.savingsProductIdParamName, element)) { final Long savingsProductId = this.fromApiJsonHelper.extractLongNamed(ClientApiConstants.savingsProductIdParamName, element); - baseDataValidator.reset().parameter(ClientApiConstants.savingsProductIdParamName).value(savingsProductId).ignoreIfNull().longGreaterThanZero(); + baseDataValidator.reset().parameter(ClientApiConstants.savingsProductIdParamName).value(savingsProductId).ignoreIfNull() + .longGreaterThanZero(); } if (!atLeastOneParameterPassedForUpdate) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientTimelineData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientTimelineData.java index badc54527..29e804e19 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientTimelineData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientTimelineData.java @@ -33,12 +33,10 @@ public class ClientTimelineData { private final String closedByFirstname; private final String closedByLastname; - - public ClientTimelineData(final LocalDate submittedOnDate, final String submittedByUsername, - final String submittedByFirstname, final String submittedByLastname, final LocalDate activatedOnDate, - final String activatedByUsername, final String activatedByFirstname, final String activatedByLastname, - final LocalDate closedOnDate, final String closedByUsername, final String closedByFirstname, - final String closedByLastname) { + public ClientTimelineData(final LocalDate submittedOnDate, final String submittedByUsername, final String submittedByFirstname, + final String submittedByLastname, final LocalDate activatedOnDate, final String activatedByUsername, + final String activatedByFirstname, final String activatedByLastname, final LocalDate closedOnDate, + final String closedByUsername, final String closedByFirstname, final String closedByLastname) { this.submittedOnDate = submittedOnDate; this.submittedByUsername = submittedByUsername; this.submittedByFirstname = submittedByFirstname; @@ -56,5 +54,4 @@ public class ClientTimelineData { } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java index 9e119c2e6..0782cf676 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java @@ -139,7 +139,7 @@ public final class Client extends AbstractPersistable { @ManyToOne(optional = true) @JoinColumn(name = "activatedon_userid", nullable = true) private AppUser activatedBy; - + @ManyToOne @JoinColumn(name = "default_savings_product", nullable = true) private SavingsProduct savingsProduct; @@ -179,7 +179,7 @@ public final class Client extends AbstractPersistable { } return new Client(currentUser, status, clientOffice, clientParentGroup, accountNo, firstname, middlename, lastname, fullname, - activationDate, officeJoiningDate, externalId, mobileNo, staff, submittedOnDate,savingsProduct); + activationDate, officeJoiningDate, externalId, mobileNo, staff, submittedOnDate, savingsProduct); } protected Client() { @@ -404,7 +404,7 @@ public final class Client extends AbstractPersistable { final Long newValue = command.longValueOfParameterNamed(ClientApiConstants.savingsProductIdParamName); actualChanges.put(ClientApiConstants.savingsProductIdParamName, newValue); } - + final String dateFormatAsInput = command.dateFormat(); final String localeAsInput = command.locale(); @@ -640,7 +640,6 @@ public final class Client extends AbstractPersistable { return false; } - private Long savingsProductId() { Long savingsProductId = null; if (this.savingsProduct != null) { @@ -649,17 +648,14 @@ public final class Client extends AbstractPersistable { return savingsProductId; } - public SavingsProduct SavingsProduct() { return this.savingsProduct; } - public void updateSavingsProduct(SavingsProduct savingsProduct) { this.savingsProduct = savingsProduct; } - public AppUser activatedBy() { return this.activatedBy; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientActiveForUpdateException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientActiveForUpdateException.java index f78c38eda..2d6be2082 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientActiveForUpdateException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientActiveForUpdateException.java @@ -4,8 +4,9 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul public class ClientActiveForUpdateException extends AbstractPlatformDomainRuleException { - public ClientActiveForUpdateException(final Long clientId,final String parameterName) { - super("error.msg.client.active.for.update.parameter."+parameterName, "The Client with id `" + clientId + "` is active,can't update parameter "+parameterName, clientId,parameterName); + public ClientActiveForUpdateException(final Long clientId, final String parameterName) { + super("error.msg.client.active.for.update.parameter." + parameterName, "The Client with id `" + clientId + + "` is active,can't update parameter " + parameterName, clientId, parameterName); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java index 07a4c847e..fe483257f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java @@ -79,9 +79,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService final Long defaultOfficeId = defaultToUsersOfficeIfNull(officeId); final Collection offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown(); - + final Collection savingsProductDatas = this.savingsProductReadPlatformService.retrieveAllForLookupByType(true); - Collection staffOptions = null; @@ -96,7 +95,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService staffOptions = null; } - return ClientData.template(defaultOfficeId, new LocalDate(), offices, staffOptions, null,savingsProductDatas); + return ClientData.template(defaultOfficeId, new LocalDate(), offices, staffOptions, null, savingsProductDatas); } @Override @@ -105,10 +104,10 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService final String userOfficeHierarchy = this.context.officeHierarchy(); final String underHierarchySearchString = userOfficeHierarchy + "%"; -// if (searchParameters.isScopedByOfficeHierarchy()) { -// this.context.validateAccessRights(searchParameters.getHierarchy()); -// underHierarchySearchString = searchParameters.getHierarchy() + "%"; -// } + // if (searchParameters.isScopedByOfficeHierarchy()) { + // this.context.validateAccessRights(searchParameters.getHierarchy()); + // underHierarchySearchString = searchParameters.getHierarchy() + "%"; + // } final StringBuilder sqlBuilder = new StringBuilder(200); sqlBuilder.append("select SQL_CALC_FOUND_ROWS "); @@ -334,11 +333,10 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService final Long imageId = JdbcSupport.getLong(rs, "imageId"); final Long staffId = JdbcSupport.getLong(rs, "staffId"); final String staffName = rs.getString("staffName"); - + final Long savingsProductId = JdbcSupport.getLong(rs, "savingsProductId"); final String savingsProductName = rs.getString("savingsProductName"); - final LocalDate closedOnDate = JdbcSupport.getLocalDate(rs, "closedOnDate"); final String closedByUsername = rs.getString("closedByUsername"); final String closedByFirstname = rs.getString("closedByFirstname"); @@ -349,18 +347,17 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService final String submittedByFirstname = rs.getString("submittedByFirstname"); final String submittedByLastname = rs.getString("submittedByLastname"); - final String activatedByUsername = rs.getString("activatedByUsername"); final String activatedByFirstname = rs.getString("activatedByFirstname"); final String activatedByLastname = rs.getString("activatedByLastname"); - final ClientTimelineData timeline = new ClientTimelineData (submittedOnDate, submittedByUsername, submittedByFirstname, submittedByLastname, - activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, closedByUsername, - closedByFirstname, closedByLastname); + final ClientTimelineData timeline = new ClientTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname, + submittedByLastname, activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, + closedByUsername, closedByFirstname, closedByLastname); return ClientData.instance(accountNo, status, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname, - middlename, lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName,timeline, - savingsProductId, savingsProductName); + middlename, lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName, + timeline, savingsProductId, savingsProductName); } } @@ -394,7 +391,6 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService builder.append("c.fullname as fullname, c.display_name as displayName, "); builder.append("c.mobile_no as mobileNo, "); - builder.append("c.submittedon_date as submittedOnDate, "); builder.append("sbu.username as submittedByUsername, "); builder.append("sbu.firstname as submittedByFirstname, "); @@ -405,12 +401,11 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService builder.append("clu.firstname as closedByFirstname, "); builder.append("clu.lastname as closedByLastname, "); - // builder.append("c.submittedon as submittedOnDate, "); + // builder.append("c.submittedon as submittedOnDate, "); builder.append("acu.username as activatedByUsername, "); builder.append("acu.firstname as activatedByFirstname, "); builder.append("acu.lastname as activatedByLastname, "); - builder.append("c.activation_date as activationDate, c.image_id as imageId, "); builder.append("c.staff_id as staffId, s.display_name as staffName, "); builder.append("c.default_savings_product as savingsProductId, sp.name as savingsProductName "); @@ -460,7 +455,6 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService final Long savingsProductId = JdbcSupport.getLong(rs, "savingsProductId"); final String savingsProductName = rs.getString("savingsProductName"); - final LocalDate closedOnDate = JdbcSupport.getLocalDate(rs, "closedOnDate"); final String closedByUsername = rs.getString("closedByUsername"); final String closedByFirstname = rs.getString("closedByFirstname"); @@ -475,13 +469,13 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService final String activatedByFirstname = rs.getString("activatedByFirstname"); final String activatedByLastname = rs.getString("activatedByLastname"); - final ClientTimelineData timeline = new ClientTimelineData (submittedOnDate, submittedByUsername, submittedByFirstname, submittedByLastname, - activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, closedByUsername, - closedByFirstname, closedByLastname); + final ClientTimelineData timeline = new ClientTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname, + submittedByLastname, activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, + closedByUsername, closedByFirstname, closedByLastname); return ClientData.instance(accountNo, status, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname, - middlename, lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName,timeline, - savingsProductId, savingsProductName); + middlename, lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName, + timeline, savingsProductId, savingsProductName); } } @@ -593,7 +587,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService public ClientData retrieveAllClosureReasons(final String clientClosureReason) { final List closureReasons = new ArrayList( this.codeValueReadPlatformService.retrieveCodeValuesByCode(clientClosureReason)); - return ClientData.template(null, null, null, null, closureReasons,null); + return ClientData.template(null, null, null, null, closureReasons, null); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java index 156c59a24..57cb48b92 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java @@ -134,16 +134,18 @@ public class CentersApiResource { @QueryParam("externalId") final String externalId, @QueryParam("name") final String name, @QueryParam("underHierarchy") final String hierarchy, @QueryParam("paged") final Boolean paged, @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, - @QueryParam("meetingDate") final DateParam meetingDateParam, @QueryParam("dateFormat") final String dateFormat, + @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, + @QueryParam("meetingDate") final DateParam meetingDateParam, @QueryParam("dateFormat") final String dateFormat, @QueryParam("locale") final String locale) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (meetingDateParam != null && officeId != null) { - Date meetingDate = meetingDateParam.getDate("meetingDate", dateFormat, locale); - Collection staffCenterDataArray = this.centerReadPlatformService.retriveAllCentersByMeetingDate(officeId, meetingDate, staffId); - return this.toApiJsonSerializer.serialize(settings, staffCenterDataArray, GroupingTypesApiConstants.STAFF_CENTER_RESPONSE_DATA_PARAMETERS); + Date meetingDate = meetingDateParam.getDate("meetingDate", dateFormat, locale); + Collection staffCenterDataArray = this.centerReadPlatformService.retriveAllCentersByMeetingDate(officeId, + meetingDate, staffId); + return this.toApiJsonSerializer.serialize(settings, staffCenterDataArray, + GroupingTypesApiConstants.STAFF_CENTER_RESPONSE_DATA_PARAMETERS); } final PaginationParameters parameters = PaginationParameters.instance(paged, offset, limit, orderBy, sortOrder); final SearchParameters searchParameters = SearchParameters.forGroups(sqlSearch, officeId, staffId, externalId, name, hierarchy, @@ -187,11 +189,16 @@ public class CentersApiResource { if (collectionMeetingCalendar != null) { final boolean withHistory = true; final LocalDate tillDate = null; - final Collection recurringDates = this.calendarReadPlatformService.generateRecurringDates(collectionMeetingCalendar, withHistory, tillDate); - final Collection nextTenRecurringDates = this.calendarReadPlatformService.generateNextTenRecurringDates(collectionMeetingCalendar); - final MeetingData lastMeeting = this.meetingReadPlatformService.retrieveLastMeeting(collectionMeetingCalendar.getCalendarInstanceId()); - final LocalDate recentEligibleMeetingDate = this.calendarReadPlatformService.generateNextEligibleMeetingDateForCollection(collectionMeetingCalendar, lastMeeting); - collectionMeetingCalendar = CalendarData.withRecurringDates(collectionMeetingCalendar, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate); + final Collection recurringDates = this.calendarReadPlatformService.generateRecurringDates( + collectionMeetingCalendar, withHistory, tillDate); + final Collection nextTenRecurringDates = this.calendarReadPlatformService + .generateNextTenRecurringDates(collectionMeetingCalendar); + final MeetingData lastMeeting = this.meetingReadPlatformService.retrieveLastMeeting(collectionMeetingCalendar + .getCalendarInstanceId()); + final LocalDate recentEligibleMeetingDate = this.calendarReadPlatformService + .generateNextEligibleMeetingDateForCollection(collectionMeetingCalendar, lastMeeting); + collectionMeetingCalendar = CalendarData.withRecurringDates(collectionMeetingCalendar, recurringDates, + nextTenRecurringDates, recentEligibleMeetingDate); } } @@ -248,7 +255,7 @@ public class CentersApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String activate(@PathParam("centerId") final Long centerId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson, @Context final UriInfo uriInfo) { + final String apiRequestBodyAsJson, @Context final UriInfo uriInfo) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java index 96b58aeb2..844a55dd2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java @@ -57,23 +57,23 @@ public class GroupingTypesApiConstants { public static final String staffOptionsParamName = "staffOptions"; public static final String clientOptionsParamName = "clientOptions"; public static final String collectionMeetingCalendar = "collectionMeetingCalendar"; - public static final String timeLine ="timeline"; + public static final String timeLine = "timeline"; public static final String closureReasons = "closureReasons"; // group close parameters public static final String closureDateParamName = "closureDate"; public static final String closureReasonIdParamName = "closureReasonId"; - - //staff centres parameters + + // staff centres parameters public static final String meetingFallCenters = "meetingFallCenters"; - + public static final Set CENTER_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, dateFormatParamName, idParamName, nameParamName, externalIdParamName, officeIdParamName, staffIdParamName, activeParamName, - activationDateParamName, groupMembersParamName,submittedOnDateParamName)); + activationDateParamName, groupMembersParamName, submittedOnDateParamName)); public static final Set GROUP_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, dateFormatParamName, idParamName, nameParamName, externalIdParamName, centerIdParamName, officeIdParamName, staffIdParamName, activeParamName, - activationDateParamName, clientMembersParamName, collectionMeetingCalendar,submittedOnDateParamName)); + activationDateParamName, clientMembersParamName, collectionMeetingCalendar, submittedOnDateParamName)); public static final Set GROUP_ROLES_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(roleParamName, clientIdParamName)); @@ -105,7 +105,7 @@ public class GroupingTypesApiConstants { public static final Set GROUP_CLOSE_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, dateFormatParamName, closureDateParamName, closureReasonIdParamName)); - - public static final Set STAFF_CENTER_RESPONSE_DATA_PARAMETERS = new HashSet( - Arrays.asList(staffIdParamName, staffNameParamName, meetingFallCenters)); + + public static final Set STAFF_CENTER_RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList(staffIdParamName, + staffNameParamName, meetingFallCenters)); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java index 90c65311e..12ccce137 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java @@ -230,11 +230,16 @@ public class GroupsApiResource { if (collectionMeetingCalendar != null) { final boolean withHistory = true; final LocalDate tillDate = null; - final Collection recurringDates = this.calendarReadPlatformService.generateRecurringDates(collectionMeetingCalendar, withHistory, tillDate); - final Collection nextTenRecurringDates = this.calendarReadPlatformService.generateNextTenRecurringDates(collectionMeetingCalendar); - final MeetingData lastMeeting = this.meetingReadPlatformService.retrieveLastMeeting(collectionMeetingCalendar.getCalendarInstanceId()); - final LocalDate recentEligibleMeetingDate = this.calendarReadPlatformService.generateNextEligibleMeetingDateForCollection(collectionMeetingCalendar, lastMeeting); - collectionMeetingCalendar = CalendarData.withRecurringDates(collectionMeetingCalendar, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate); + final Collection recurringDates = this.calendarReadPlatformService.generateRecurringDates( + collectionMeetingCalendar, withHistory, tillDate); + final Collection nextTenRecurringDates = this.calendarReadPlatformService + .generateNextTenRecurringDates(collectionMeetingCalendar); + final MeetingData lastMeeting = this.meetingReadPlatformService.retrieveLastMeeting(collectionMeetingCalendar + .getCalendarInstanceId()); + final LocalDate recentEligibleMeetingDate = this.calendarReadPlatformService + .generateNextEligibleMeetingDateForCollection(collectionMeetingCalendar, lastMeeting); + collectionMeetingCalendar = CalendarData.withRecurringDates(collectionMeetingCalendar, recurringDates, + nextTenRecurringDates, recentEligibleMeetingDate); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java index 2a9d8575f..81afb65bc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java @@ -27,7 +27,7 @@ public class CenterData { private final Long staffId; private final String staffName; private final String hierarchy; - + private final EnumOptionData status; @SuppressWarnings("unused") private final boolean active; @@ -37,7 +37,7 @@ public class CenterData { // associations private final Collection groupMembers; - // template + // template private final Collection groupMembersOptions; private final CalendarData collectionMeetingCalendar; private final Collection closureReasons; @@ -154,11 +154,11 @@ public class CenterData { public String getHierarchy() { return this.hierarchy; } - + public CalendarData getCollectionMeetingCalendar() { - return collectionMeetingCalendar; - } - + return collectionMeetingCalendar; + } + public String getStaffName() { return this.staffName; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java index f7c77b018..025013ff0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java @@ -59,7 +59,7 @@ public class GroupGeneralData { final Collection groupRoles = null; final Collection closureReasons = null; return new GroupGeneralData(groupId, groupName, null, null, null, null, null, null, null, null, null, null, clientMembers, null, - null, null, null, groupRoles, null, null, null, null, closureReasons,null); + null, null, null, groupRoles, null, null, null, null, closureReasons, null); } public static GroupGeneralData template(final Long officeId, final Long centerId, final String centerName, final Long staffId, @@ -73,7 +73,7 @@ public class GroupGeneralData { return new GroupGeneralData(null, null, null, null, null, officeId, null, centerId, centerName, staffId, staffName, null, clientMembers, centerOptions, officeOptions, staffOptions, clientOptions, groupRoles, availableRoles, null, null, null, - closureReasons,null); + closureReasons, null); } public static GroupGeneralData withTemplate(final GroupGeneralData templatedGrouping, final GroupGeneralData grouping) { @@ -81,7 +81,8 @@ public class GroupGeneralData { grouping.officeId, grouping.officeName, grouping.centerId, grouping.centerName, grouping.staffId, grouping.staffName, grouping.hierarchy, grouping.clientMembers, templatedGrouping.centerOptions, templatedGrouping.officeOptions, templatedGrouping.staffOptions, templatedGrouping.clientOptions, grouping.groupRoles, templatedGrouping.availableRoles, - grouping.selectedRole, grouping.calendarsData, grouping.collectionMeetingCalendar, grouping.closureReasons,templatedGrouping.timeline); + grouping.selectedRole, grouping.calendarsData, grouping.collectionMeetingCalendar, grouping.closureReasons, + templatedGrouping.timeline); } public static GroupGeneralData withAssocations(final GroupGeneralData grouping, final Collection membersOfGroup, @@ -91,12 +92,12 @@ public class GroupGeneralData { grouping.officeId, grouping.officeName, grouping.centerId, grouping.centerName, grouping.staffId, grouping.staffName, grouping.hierarchy, membersOfGroup, grouping.centerOptions, grouping.officeOptions, grouping.staffOptions, grouping.clientOptions, groupRoles, grouping.availableRoles, grouping.selectedRole, calendarsData, - collectionMeetingCalendar, grouping.closureReasons,grouping.timeline); + collectionMeetingCalendar, grouping.closureReasons, grouping.timeline); } public static GroupGeneralData instance(final Long id, final String name, final String externalId, final EnumOptionData status, final LocalDate activationDate, final Long officeId, final String officeName, final Long centerId, final String centerName, - final Long staffId, final String staffName, final String hierarchy,final GroupTimelineData timeline) { + final Long staffId, final String staffName, final String hierarchy, final GroupTimelineData timeline) { final Collection clientMembers = null; final Collection centerOptions = null; @@ -112,7 +113,7 @@ public class GroupGeneralData { return new GroupGeneralData(id, name, externalId, status, activationDate, officeId, officeName, centerId, centerName, staffId, staffName, hierarchy, clientMembers, centerOptions, officeOptions, staffOptions, clientOptions, groupRoles, availableRoles, - role, calendarsData, collectionMeetingCalendar, closureReasons,timeline); + role, calendarsData, collectionMeetingCalendar, closureReasons, timeline); } private GroupGeneralData(final Long id, final String name, final String externalId, final EnumOptionData status, @@ -122,7 +123,7 @@ public class GroupGeneralData { final Collection staffOptions, final Collection clientOptions, final Collection groupRoles, final Collection availableRoles, final GroupRoleData role, final Collection calendarsData, final CalendarData collectionMeetingCalendar, - final Collection closureReasons,final GroupTimelineData timeline) { + final Collection closureReasons, final GroupTimelineData timeline) { this.id = id; this.name = name; this.externalId = externalId; @@ -192,7 +193,7 @@ public class GroupGeneralData { grouping.officeId, grouping.officeName, grouping.centerId, grouping.centerName, grouping.staffId, grouping.staffName, grouping.hierarchy, grouping.clientMembers, grouping.centerOptions, grouping.officeOptions, grouping.staffOptions, grouping.clientOptions, grouping.groupRoles, grouping.availableRoles, selectedRole, grouping.calendarsData, - grouping.collectionMeetingCalendar, grouping.closureReasons,null); + grouping.collectionMeetingCalendar, grouping.closureReasons, null); } public static GroupGeneralData withClosureReasons(final Collection closureReasons) { @@ -221,10 +222,9 @@ public class GroupGeneralData { return new GroupGeneralData(id, name, externalId, status, activationDate, officeId, officeName, centerId, centerName, staffId, staffName, hierarchy, clientMembers, centerOptions, officeOptions, staffOptions, clientOptions, groupRoles, availableRoles, - role, calendarsData, collectionMeetingCalendar, closureReasons,null); + role, calendarsData, collectionMeetingCalendar, closureReasons, null); } - public Collection clientMembers() { return this.clientMembers; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupTimelineData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupTimelineData.java index eba821873..bf6dafaa6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupTimelineData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupTimelineData.java @@ -8,7 +8,8 @@ package org.mifosplatform.portfolio.group.data; import org.joda.time.LocalDate; /** - * Immutable data object represent the important time-line events of a group/center. + * Immutable data object represent the important time-line events of a + * group/center. * */ @SuppressWarnings("unused") @@ -29,12 +30,10 @@ public class GroupTimelineData { private final String closedByFirstname; private final String closedByLastname; - - public GroupTimelineData(final LocalDate submittedOnDate, final String submittedByUsername, - final String submittedByFirstname, final String submittedByLastname, final LocalDate activatedOnDate, - final String activatedByUsername, final String activatedByFirstname, final String activatedByLastname, - final LocalDate closedOnDate, final String closedByUsername, final String closedByFirstname, - final String closedByLastname) { + public GroupTimelineData(final LocalDate submittedOnDate, final String submittedByUsername, final String submittedByFirstname, + final String submittedByLastname, final LocalDate activatedOnDate, final String activatedByUsername, + final String activatedByFirstname, final String activatedByLastname, final LocalDate closedOnDate, + final String closedByUsername, final String closedByFirstname, final String closedByLastname) { this.submittedOnDate = submittedOnDate; this.submittedByUsername = submittedByUsername; this.submittedByFirstname = submittedByFirstname; @@ -52,5 +51,4 @@ public class GroupTimelineData { } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/StaffCenterData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/StaffCenterData.java index 9567c998f..c59ebe675 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/StaffCenterData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/StaffCenterData.java @@ -4,26 +4,26 @@ import java.util.Collection; public class StaffCenterData { - private final Long staffId; - @SuppressWarnings("unused") - private final String staffName; - private final Collection meetingFallCenters; - - private StaffCenterData(final Long staffId, final String staffName, final Collection meetingFallCenters) { - this.staffId = staffId; - this.staffName = staffName; - this.meetingFallCenters = meetingFallCenters; - } - - public static StaffCenterData instance(final Long staffId, final String staffName, final Collection meetingFallCenters) { - return new StaffCenterData(staffId, staffName, meetingFallCenters); - } - public Long getStaffId() { - return staffId; - } - - public Collection getMeetingFallCenters() { - return meetingFallCenters; - } + private final Long staffId; + @SuppressWarnings("unused") + private final String staffName; + private final Collection meetingFallCenters; + + private StaffCenterData(final Long staffId, final String staffName, final Collection meetingFallCenters) { + this.staffId = staffId; + this.staffName = staffName; + this.meetingFallCenters = meetingFallCenters; + } + + public static StaffCenterData instance(final Long staffId, final String staffName, final Collection meetingFallCenters) { + return new StaffCenterData(staffId, staffName, meetingFallCenters); + } + + public Long getStaffId() { + return staffId; + } + + public Collection getMeetingFallCenters() { + return meetingFallCenters; + } } - \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/serialization/GroupingTypesDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/serialization/GroupingTypesDataValidator.java index 43e617b6d..62891ea8b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/serialization/GroupingTypesDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/serialization/GroupingTypesDataValidator.java @@ -97,10 +97,10 @@ public final class GroupingTypesDataValidator { baseDataValidator.reset().parameter(ClientApiConstants.activeParamName).value(active).trueOrFalseRequired(false); } - if (this.fromApiJsonHelper.parameterExists(GroupingTypesApiConstants.submittedOnDateParamName, element)) - { - final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed(GroupingTypesApiConstants.submittedOnDateParamName, element); - baseDataValidator.reset().parameter(GroupingTypesApiConstants.submittedOnDateParamName).value(submittedOnDate).notNull(); + if (this.fromApiJsonHelper.parameterExists(GroupingTypesApiConstants.submittedOnDateParamName, element)) { + final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed( + GroupingTypesApiConstants.submittedOnDateParamName, element); + baseDataValidator.reset().parameter(GroupingTypesApiConstants.submittedOnDateParamName).value(submittedOnDate).notNull(); } throwExceptionIfValidationWarningsExist(dataValidationErrors); @@ -161,9 +161,9 @@ public final class GroupingTypesDataValidator { baseDataValidator.reset().parameter(ClientApiConstants.activeParamName).value(active).trueOrFalseRequired(false); } - if (this.fromApiJsonHelper.parameterExists(GroupingTypesApiConstants.submittedOnDateParamName, element)) - { - final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed(GroupingTypesApiConstants.submittedOnDateParamName, element); + if (this.fromApiJsonHelper.parameterExists(GroupingTypesApiConstants.submittedOnDateParamName, element)) { + final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed( + GroupingTypesApiConstants.submittedOnDateParamName, element); baseDataValidator.reset().parameter(GroupingTypesApiConstants.submittedOnDateParamName).value(submittedOnDate).notNull(); } @@ -221,9 +221,9 @@ public final class GroupingTypesDataValidator { baseDataValidator.reset().parameter(ClientApiConstants.activeParamName).value(active).trueOrFalseRequired(false); } - if (this.fromApiJsonHelper.parameterExists(GroupingTypesApiConstants.submittedOnDateParamName, element)) - { - final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed(GroupingTypesApiConstants.submittedOnDateParamName, element); + if (this.fromApiJsonHelper.parameterExists(GroupingTypesApiConstants.submittedOnDateParamName, element)) { + final LocalDate submittedOnDate = this.fromApiJsonHelper.extractLocalDateNamed( + GroupingTypesApiConstants.submittedOnDateParamName, element); baseDataValidator.reset().parameter(GroupingTypesApiConstants.submittedOnDateParamName).value(submittedOnDate).notNull(); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/AllGroupTypesDataMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/AllGroupTypesDataMapper.java index c6295b459..fcf7f0c6d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/AllGroupTypesDataMapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/AllGroupTypesDataMapper.java @@ -37,7 +37,6 @@ public final class AllGroupTypesDataMapper implements RowMapper retrieveAllForDropdown(Long officeId); Page retrievePagedAll(SearchParameters searchParameters, PaginationParameters parameters); - + Collection retrieveAll(SearchParameters searchParameters, PaginationParameters parameters); GroupGeneralData retrieveCenterGroupTemplate(Long centerId); @@ -31,6 +31,6 @@ public interface CenterReadPlatformService { Collection retrieveAssociatedGroups(Long centerId); CenterData retrieveCenterWithClosureReasons(); - + Collection retriveAllCentersByMeetingDate(Long officeId, Date meetingDate, Long staffId); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/CenterReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/CenterReadPlatformServiceImpl.java index 0b40069d3..af807ddc1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/CenterReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/CenterReadPlatformServiceImpl.java @@ -135,24 +135,15 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService + "g.staff_id as staffId, s.display_name as staffName, " // + "g.status_enum as statusEnum, g.activation_date as activationDate, " // + "g.hierarchy as hierarchy, " // - + "g.closedon_date as closedOnDate, " - + "g.submittedon_date as submittedOnDate, " - + "sbu.username as submittedByUsername, " - + "sbu.firstname as submittedByFirstname, " - + "sbu.lastname as submittedByLastname, " - + "clu.username as closedByUsername, " - + "clu.firstname as closedByFirstname, " - + "clu.lastname as closedByLastname, " - + "acu.username as activatedByUsername, " + + "g.closedon_date as closedOnDate, " + "g.submittedon_date as submittedOnDate, " + "sbu.username as submittedByUsername, " + + "sbu.firstname as submittedByFirstname, " + "sbu.lastname as submittedByLastname, " + "clu.username as closedByUsername, " + + "clu.firstname as closedByFirstname, " + "clu.lastname as closedByLastname, " + "acu.username as activatedByUsername, " + "acu.firstname as activatedByFirstname, " + "acu.lastname as activatedByLastname " + "from m_group g " // - + "join m_office o on o.id = g.office_id " - + "left join m_staff s on s.id = g.staff_id " - + "left join m_group pg on pg.id = g.parent_id " - + "left join m_appuser sbu on sbu.id = g.submittedon_userid " - + "left join m_appuser acu on acu.id = g.activatedon_userid " - + "left join m_appuser clu on clu.id = g.closedon_userid "; + + "join m_office o on o.id = g.office_id " + "left join m_staff s on s.id = g.staff_id " + + "left join m_group pg on pg.id = g.parent_id " + "left join m_appuser sbu on sbu.id = g.submittedon_userid " + + "left join m_appuser acu on acu.id = g.activatedon_userid " + "left join m_appuser clu on clu.id = g.closedon_userid "; private static final class CenterDataMapper implements RowMapper { @@ -181,43 +172,43 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService final Long staffId = JdbcSupport.getLong(rs, "staffId"); final String staffName = rs.getString("staffName"); final String hierarchy = rs.getString("hierarchy"); - + final LocalDate closedOnDate = JdbcSupport.getLocalDate(rs, "closedOnDate"); final String closedByUsername = rs.getString("closedByUsername"); - final String closedByFirstname = rs.getString("closedByFirstname"); + final String closedByFirstname = rs.getString("closedByFirstname"); final String closedByLastname = rs.getString("closedByLastname"); - final LocalDate submittedOnDate = JdbcSupport.getLocalDate(rs, "submittedOnDate"); + final LocalDate submittedOnDate = JdbcSupport.getLocalDate(rs, "submittedOnDate"); final String submittedByUsername = rs.getString("submittedByUsername"); final String submittedByFirstname = rs.getString("submittedByFirstname"); final String submittedByLastname = rs.getString("submittedByLastname"); - final String activatedByUsername = rs.getString("activatedByUsername"); final String activatedByFirstname = rs.getString("activatedByFirstname"); - final String activatedByLastname = rs.getString("activatedByLastname"); - - final GroupTimelineData timeline = new GroupTimelineData (submittedOnDate, submittedByUsername, submittedByFirstname, submittedByLastname, - activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, closedByUsername, - closedByFirstname, closedByLastname); + final String activatedByLastname = rs.getString("activatedByLastname"); - return CenterData.instance(id, name, externalId, status, activationDate, officeId, officeName, staffId, staffName, hierarchy, timeline, null); + final GroupTimelineData timeline = new GroupTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname, + submittedByLastname, activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, + closedByUsername, closedByFirstname, closedByLastname); + + return CenterData.instance(id, name, externalId, status, activationDate, officeId, officeName, staffId, staffName, hierarchy, + timeline, null); } } - + private static final class CenterCalendarDataMapper implements RowMapper { private final String schemaSql; public CenterCalendarDataMapper() { - schemaSql = " select g.id as id, g.display_name as name, g.office_id as officeId, g.staff_id as staffId, s.display_name as staffName, g.external_id as externalId, " - +" g.status_enum as statusEnum, g.activation_date as activationDate, g.hierarchy as hierarchy, " - +" c.id as calendarId, ci.id as calendarInstanceId, ci.entity_id as entityId, " - +" ci.entity_type_enum as entityTypeId, c.title as title, c.description as description, " - +" c.location as location, c.start_date as startDate, c.end_date as endDate, c.recurrence as recurrence " - +" from m_calendar c join m_calendar_instance ci on ci.calendar_id=c.id and ci.entity_type_enum=4 join m_group g " - +" on g.id = ci.entity_id join m_staff s on g.staff_id = s.id where g.office_id=? "; + schemaSql = " select g.id as id, g.display_name as name, g.office_id as officeId, g.staff_id as staffId, s.display_name as staffName, g.external_id as externalId, " + + " g.status_enum as statusEnum, g.activation_date as activationDate, g.hierarchy as hierarchy, " + + " c.id as calendarId, ci.id as calendarInstanceId, ci.entity_id as entityId, " + + " ci.entity_type_enum as entityTypeId, c.title as title, c.description as description, " + + " c.location as location, c.start_date as startDate, c.end_date as endDate, c.recurrence as recurrence " + + " from m_calendar c join m_calendar_instance ci on ci.calendar_id=c.id and ci.entity_type_enum=4 join m_group g " + + " on g.id = ci.entity_id join m_staff s on g.staff_id = s.id where g.office_id=? "; } public String schema() { @@ -237,7 +228,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService final Long staffId = JdbcSupport.getLong(rs, "staffId"); final String staffName = rs.getString("staffName"); final String hierarchy = rs.getString("hierarchy"); - + final Long calendarId = rs.getLong("calendarId"); final Long calendarInstanceId = rs.getLong("calendarInstanceId"); final Long entityId = rs.getLong("entityId"); @@ -249,10 +240,12 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService final LocalDate startDate = JdbcSupport.getLocalDate(rs, "startDate"); final LocalDate endDate = JdbcSupport.getLocalDate(rs, "endDate"); final String recurrence = rs.getString("recurrence"); - - CalendarData calendarData = CalendarData.instance(calendarId, calendarInstanceId, entityId, entityType, title, description, location, startDate, - endDate, null, null, false, recurrence, null, null, null, null, null, null, null, null, null, null, null, null, null); - return CenterData.instance(id, name, externalId, status, activationDate, officeId, null, staffId, staffName, hierarchy, null, calendarData); + + CalendarData calendarData = CalendarData.instance(calendarId, calendarInstanceId, entityId, entityType, title, description, + location, startDate, endDate, null, null, false, recurrence, null, null, null, null, null, null, null, null, null, + null, null, null, null); + return CenterData.instance(id, name, externalId, status, activationDate, officeId, null, staffId, staffName, hierarchy, null, + calendarData); } } @@ -285,34 +278,33 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService final Long staffId = JdbcSupport.getLong(rs, "staffId"); final String staffName = rs.getString("staffName"); final String hierarchy = rs.getString("hierarchy"); - + final LocalDate closedOnDate = JdbcSupport.getLocalDate(rs, "closedOnDate"); final String closedByUsername = rs.getString("closedByUsername"); - final String closedByFirstname = rs.getString("closedByFirstname"); + final String closedByFirstname = rs.getString("closedByFirstname"); final String closedByLastname = rs.getString("closedByLastname"); - final LocalDate submittedOnDate = JdbcSupport.getLocalDate(rs, "submittedOnDate"); + final LocalDate submittedOnDate = JdbcSupport.getLocalDate(rs, "submittedOnDate"); final String submittedByUsername = rs.getString("submittedByUsername"); final String submittedByFirstname = rs.getString("submittedByFirstname"); final String submittedByLastname = rs.getString("submittedByLastname"); - final String activatedByUsername = rs.getString("activatedByUsername"); final String activatedByFirstname = rs.getString("activatedByFirstname"); - final String activatedByLastname = rs.getString("activatedByLastname"); - - final GroupTimelineData timeline = new GroupTimelineData (submittedOnDate, submittedByUsername, submittedByFirstname, submittedByLastname, - activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, closedByUsername, - closedByFirstname, closedByLastname); + final String activatedByLastname = rs.getString("activatedByLastname"); + + final GroupTimelineData timeline = new GroupTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname, + submittedByLastname, activationDate, activatedByUsername, activatedByFirstname, activatedByLastname, closedOnDate, + closedByUsername, closedByFirstname, closedByLastname); return GroupGeneralData.instance(id, name, externalId, status, activationDate, officeId, officeName, null, null, staffId, - staffName, hierarchy,timeline); + staffName, hierarchy, timeline); } } @Override public Page retrievePagedAll(final SearchParameters searchParameters, final PaginationParameters parameters) { - + this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "audits"); final AppUser currentUser = this.context.authenticatedUser(); final String hierarchy = currentUser.getOffice().getHierarchy(); @@ -344,10 +336,10 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), new Object[] { hierarchySearchString }, this.centerMapper); } - + @Override public Collection retrieveAll(SearchParameters searchParameters, PaginationParameters parameters) { - + this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "audits"); final AppUser currentUser = this.context.authenticatedUser(); final String hierarchy = currentUser.getOffice().getHierarchy(); @@ -375,7 +367,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService } } - return this.jdbcTemplate.query(sqlBuilder.toString(), this.centerMapper, new Object[] {hierarchySearchString}); + return this.jdbcTemplate.query(sqlBuilder.toString(), this.centerMapper, new Object[] { hierarchySearchString }); } @Override @@ -397,7 +389,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService final Long officeIdDefaulted = defaultToUsersOfficeIfNull(officeId); final Collection officeOptions = this.officeReadPlatformService.retrieveAllOfficesForDropdown(); - + final boolean loanOfficersOnly = false; Collection staffOptions = null; if (staffInSelectedOfficeOnly) { @@ -507,45 +499,46 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService return CenterData.withClosureReasons(closureReasons); } - @Override - public Collection retriveAllCentersByMeetingDate(final Long officeId, final Date meetingDate, final Long staffId) { - final CenterCalendarDataMapper centerCalendarMapper = new CenterCalendarDataMapper(); - String sql = centerCalendarMapper.schema(); - Collection centerDataArray = null; - - if (staffId != null) { - sql += " and g.staff_id=? "; - centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, new Object[] {officeId, staffId}); - } else { - centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, new Object[] {officeId}); - } - - Collection staffCenterDataArray = new ArrayList(); - Boolean flag = false; - for (CenterData centerData : centerDataArray) { - if (centerData.getCollectionMeetingCalendar().isValidRecurringDate(new LocalDate(meetingDate))){ - if (staffCenterDataArray.size() <= 0) { - Collection meetingFallCenter = new ArrayList(); - meetingFallCenter.add(centerData); - staffCenterDataArray.add(StaffCenterData.instance(centerData.staffId(), centerData.getStaffName(), meetingFallCenter)); - } else { - for(StaffCenterData staffCenterData : staffCenterDataArray) { - flag = false; - if (staffCenterData.getStaffId() == centerData.staffId()) { - staffCenterData.getMeetingFallCenters().add(centerData); - flag = true; - break; - } - } - if (!flag) { - Collection meetingFallCenter = new ArrayList(); - meetingFallCenter.add(centerData); - staffCenterDataArray.add(StaffCenterData.instance(centerData.staffId(), centerData.getStaffName(), meetingFallCenter)); - } - } - - } - } - return staffCenterDataArray; - } + @Override + public Collection retriveAllCentersByMeetingDate(final Long officeId, final Date meetingDate, final Long staffId) { + final CenterCalendarDataMapper centerCalendarMapper = new CenterCalendarDataMapper(); + String sql = centerCalendarMapper.schema(); + Collection centerDataArray = null; + + if (staffId != null) { + sql += " and g.staff_id=? "; + centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, new Object[] { officeId, staffId }); + } else { + centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, new Object[] { officeId }); + } + + Collection staffCenterDataArray = new ArrayList(); + Boolean flag = false; + for (CenterData centerData : centerDataArray) { + if (centerData.getCollectionMeetingCalendar().isValidRecurringDate(new LocalDate(meetingDate))) { + if (staffCenterDataArray.size() <= 0) { + Collection meetingFallCenter = new ArrayList(); + meetingFallCenter.add(centerData); + staffCenterDataArray.add(StaffCenterData.instance(centerData.staffId(), centerData.getStaffName(), meetingFallCenter)); + } else { + for (StaffCenterData staffCenterData : staffCenterDataArray) { + flag = false; + if (staffCenterData.getStaffId() == centerData.staffId()) { + staffCenterData.getMeetingFallCenters().add(centerData); + flag = true; + break; + } + } + if (!flag) { + Collection meetingFallCenter = new ArrayList(); + meetingFallCenter.add(centerData); + staffCenterDataArray.add(StaffCenterData.instance(centerData.staffId(), centerData.getStaffName(), + meetingFallCenter)); + } + } + + } + } + return staffCenterDataArray; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformService.java index b5a4460c2..8a8a5e07c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformService.java @@ -16,7 +16,7 @@ public interface GroupReadPlatformService { GroupGeneralData retrieveTemplate(Long officeId, boolean isCenterGroup, boolean staffInSelectedOfficeOnly); Page retrievePagedAll(SearchParameters searchParameters, PaginationParameters parameters); - + Collection retrieveAll(SearchParameters searchParameters, PaginationParameters parameters); GroupGeneralData retrieveOne(Long groupId); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java index 3ef510c5a..144951cf2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java @@ -58,14 +58,15 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService { private final AllGroupTypesDataMapper allGroupTypesDataMapper = new AllGroupTypesDataMapper(); private final PaginationHelper paginationHelper = new PaginationHelper(); private final PaginationParametersDataValidator paginationParametersDataValidator; - + private final static Set supportedOrderByValues = new HashSet(Arrays.asList("id", "name", "officeId", "officeName")); @Autowired public GroupReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource, final CenterReadPlatformService centerReadPlatformService, final ClientReadPlatformService clientReadPlatformService, final OfficeReadPlatformService officeReadPlatformService, final StaffReadPlatformService staffReadPlatformService, - final CodeValueReadPlatformService codeValueReadPlatformService, final PaginationParametersDataValidator paginationParametersDataValidator) { + final CodeValueReadPlatformService codeValueReadPlatformService, + final PaginationParametersDataValidator paginationParametersDataValidator) { this.context = context; this.jdbcTemplate = new JdbcTemplate(dataSource); this.centerReadPlatformService = centerReadPlatformService; @@ -160,7 +161,6 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService { return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), new Object[] { hierarchySearchString }, this.allGroupTypesDataMapper); } - @Override public Collection retrieveAll(SearchParameters searchParameters, final PaginationParameters parameters) { @@ -186,8 +186,8 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService { if (parameters.isLimited()) { sqlBuilder.append(parameters.limitSql()); } - - return this.jdbcTemplate.query(sqlBuilder.toString(), this.allGroupTypesDataMapper, new Object[] {hierarchySearchString}); + + return this.jdbcTemplate.query(sqlBuilder.toString(), this.allGroupTypesDataMapper, new Object[] { hierarchySearchString }); } // 'g.' preffix because of ERROR 1052 (23000): Column 'column_name' in where @@ -223,8 +223,8 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService { if (hierarchy != null) { extraCriteria.append(" and o.hierarchy like ").append(ApiParameterHelper.sqlEncodeString(hierarchy + "%")); } - - if (searchCriteria.isStaffIdPassed()){ + + if (searchCriteria.isStaffIdPassed()) { extraCriteria.append(" and g.staff_id = ").append(searchCriteria.getStaffId()); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java index 9f61cd56a..384132c38 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java @@ -137,12 +137,12 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group if (active && submittedOnDate.isAfter(activationDate)) { submittedOnDate = activationDate; } - if(command.hasParameter(GroupingTypesApiConstants.submittedOnDateParamName)){ + if (command.hasParameter(GroupingTypesApiConstants.submittedOnDateParamName)) { submittedOnDate = command.localDateValueOfParameterNamed(GroupingTypesApiConstants.submittedOnDateParamName); } final Group newGroup = Group.newGroup(groupOffice, staff, parentGroup, groupLevel, name, externalId, active, activationDate, - clientMembers, groupMembers,submittedOnDate,currentUser); + clientMembers, groupMembers, submittedOnDate, currentUser); // pre-save to generate id for use in group hierarchy this.groupRepository.save(newGroup); @@ -203,7 +203,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group final LocalDate activationDate = command.localDateValueOfParameterNamed("activationDate"); validateOfficeOpeningDateisAfterGroupOrCenterOpeningDate(group.getOffice(), group.getGroupLevel(), activationDate); - group.activate(currentUser,fmt, activationDate); + group.activate(currentUser, fmt, activationDate); this.groupRepository.saveAndFlush(group); @@ -442,7 +442,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group validateLoansAndSavingsForGroupOrCenterClose(group, closureDate); - group.close(currentUser,closureReason, closureDate); + group.close(currentUser, closureReason, closureDate); this.groupRepository.saveAndFlush(group); @@ -503,7 +503,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group final CodeValue closureReason = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection( GroupingTypesApiConstants.GROUP_CLOSURE_REASON, closureReasonId); - final AppUser currentUser = this.context.authenticatedUser(); + final AppUser currentUser = this.context.authenticatedUser(); if (center.hasActiveGroups()) { final String errorMessage = center.getGroupLevel().getLevelName() @@ -514,7 +514,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group validateLoansAndSavingsForGroupOrCenterClose(center, closureDate); - center.close(currentUser,closureReason, closureDate); + center.close(currentUser, closureReason, closureDate); this.groupRepository.saveAndFlush(center); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/SearchParameters.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/SearchParameters.java index 305d73695..47cb63cb0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/SearchParameters.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/SearchParameters.java @@ -21,15 +21,15 @@ public final class SearchParameters { private final String orderBy; private final String sortOrder; private final String accountNo; - - @SuppressWarnings("unused") - private final Long staffId; + + private final Long staffId; public static SearchParameters from(final String sqlSearch, final Long officeId, final String externalId, final String name, final String hierarchy) { final Long staffId = null; final String accountNo = null; - return new SearchParameters(sqlSearch, officeId, externalId, name, hierarchy, null, null, null, null, null, null, staffId, accountNo); + return new SearchParameters(sqlSearch, officeId, externalId, name, hierarchy, null, null, null, null, null, null, staffId, + accountNo); } public static SearchParameters forClients(final String sqlSearch, final Long officeId, final String externalId, @@ -39,13 +39,14 @@ public final class SearchParameters { final Integer maxLimitAllowed = getCheckedLimit(limit); final Long staffId = null; final String accountNo = null; - + return new SearchParameters(sqlSearch, officeId, externalId, displayName, hierarchy, firstname, lastname, offset, maxLimitAllowed, orderBy, sortOrder, staffId, accountNo); } - public static SearchParameters forGroups(final String sqlSearch, final Long officeId, final Long staffId, final String externalId, final String name, - final String hierarchy, final Integer offset, final Integer limit, final String orderBy, final String sortOrder) { + public static SearchParameters forGroups(final String sqlSearch, final Long officeId, final Long staffId, final String externalId, + final String name, final String hierarchy, final Integer offset, final Integer limit, final String orderBy, + final String sortOrder) { final Integer maxLimitAllowed = getCheckedLimit(limit); final String accountNo = null; @@ -59,8 +60,9 @@ public final class SearchParameters { final Integer maxLimitAllowed = getCheckedLimit(limit); final Long staffId = null; - - return new SearchParameters(sqlSearch, null, externalId, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, staffId, accountNo); + + return new SearchParameters(sqlSearch, null, externalId, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, + staffId, accountNo); } public static SearchParameters forJournalEntries(final Long officeId, final Integer offset, final Integer limit, final String orderBy, @@ -68,36 +70,39 @@ public final class SearchParameters { final Integer maxLimitAllowed = getCheckedLimit(limit); final Long staffId = null; - - return new SearchParameters(null, officeId, null, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, staffId, null); + + return new SearchParameters(null, officeId, null, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, staffId, + null); } public static SearchParameters forPagination(final Integer offset, final Integer limit, final String orderBy, final String sortOrder) { final Integer maxLimitAllowed = getCheckedLimit(limit); final Long staffId = null; - + return new SearchParameters(null, null, null, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, staffId, null); } - + public static SearchParameters forSavings(final String sqlSearch, final String externalId, final Integer offset, final Integer limit, final String orderBy, final String sortOrder) { final Integer maxLimitAllowed = getCheckedLimit(limit); final Long staffId = null; final String accountNo = null; - - return new SearchParameters(sqlSearch, null, externalId, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, staffId, accountNo); + + return new SearchParameters(sqlSearch, null, externalId, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, + staffId, accountNo); } - - public static SearchParameters forAccountTransfer(final String sqlSearch, final String externalId, final Integer offset, final Integer limit, - final String orderBy, final String sortOrder) { + + public static SearchParameters forAccountTransfer(final String sqlSearch, final String externalId, final Integer offset, + final Integer limit, final String orderBy, final String sortOrder) { final Integer maxLimitAllowed = getCheckedLimit(limit); final Long staffId = null; final String accountNo = null; - - return new SearchParameters(sqlSearch, null, externalId, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, staffId, accountNo); + + return new SearchParameters(sqlSearch, null, externalId, null, null, null, null, offset, maxLimitAllowed, orderBy, sortOrder, + staffId, accountNo); } private SearchParameters(final String sqlSearch, final Long officeId, final String externalId, final String name, @@ -201,17 +206,17 @@ public final class SearchParameters { public String getSortOrder() { return this.sortOrder; } - + public boolean isStaffIdPassed() { return this.staffId != null && this.staffId != 0; } - + public Long getStaffId() { return this.staffId; } - + public String getAccountNo() { return this.accountNo; } - + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanApiConstants.java index 97c8e2039..fc64b2ad2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanApiConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanApiConstants.java @@ -15,12 +15,12 @@ public interface LoanApiConstants { public static final String DISBURSEMENT_DATE_START_WITH_ERROR = "first.disbursement.date.must.start.with.expected.disbursement.date"; public static final String PRINCIPAL_AMOUNT_SHOULD_BE_SAME = "sum.of.multi.disburse.amounts.must.equal.with.total.principal"; - + public static final String DISBURSEMENT_DATE_UNIQUE_ERROR = "disbursement.date.must.be.unique.for.tranches"; - + public static final String disbursementIdParameterName = "id"; - + public static final String principalDisbursedParameterName = "transactionAmount"; - + public static final String ALREADY_DISBURSED = "can.not.change.disbursement.date"; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java index 48d42e70c..950f16979 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java @@ -49,7 +49,8 @@ public class LoanChargesApiResource { private final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "chargeId", "name", "penalty", "chargeTimeType", "dueAsOfDate", "chargeCalculationType", "percentage", "amountPercentageAppliedTo", "currency", - "amountWaived", "amountWrittenOff", "amountOutstanding", "amountOrPercentage", "amount", "amountPaid", "chargeOptions","installmentChargeData")); + "amountWaived", "amountWrittenOff", "amountOutstanding", "amountOrPercentage", "amount", "amountPaid", "chargeOptions", + "installmentChargeData")); private final String resourceNameForPermissions = "LOAN"; @@ -117,10 +118,11 @@ public class LoanChargesApiResource { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); final LoanChargeData loanCharge = this.loanChargeReadPlatformService.retrieveLoanChargeDetails(loanChargeId, loanId); - - final Collection installmentChargeData = this.loanChargeReadPlatformService.retrieveInstallmentLoanCharges(loanChargeId, true); - - final LoanChargeData loanChargeData = new LoanChargeData(loanCharge, installmentChargeData); + + final Collection installmentChargeData = this.loanChargeReadPlatformService + .retrieveInstallmentLoanCharges(loanChargeId, true); + + final LoanChargeData loanChargeData = new LoanChargeData(loanCharge, installmentChargeData); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.toApiJsonSerializer.serialize(settings, loanChargeData, this.RESPONSE_DATA_PARAMETERS); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanDisbursementDetailApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanDisbursementDetailApiResource.java index 0a1f8b0fb..acdce7225 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanDisbursementDetailApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanDisbursementDetailApiResource.java @@ -37,10 +37,10 @@ import org.springframework.stereotype.Component; @Component @Scope("singleton") public class LoanDisbursementDetailApiResource { - - private final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "expectedDisbursementDate","actualDisbursementDate", - "principal","approvedPrincipal")); - + + private final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "expectedDisbursementDate", + "actualDisbursementDate", "principal", "approvedPrincipal")); + private final String resourceNameForPermissions = "LOAN"; private final DefaultToApiJsonSerializer toApiJsonSerializer; @@ -48,10 +48,10 @@ public class LoanDisbursementDetailApiResource { private final PlatformSecurityContext context; private final ApiRequestParameterHelper apiRequestParameterHelper; private final LoanReadPlatformService loanReadPlatformService; - + @Autowired public LoanDisbursementDetailApiResource(final DefaultToApiJsonSerializer toApiJsonSerializer, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,final PlatformSecurityContext context, + final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, final PlatformSecurityContext context, final ApiRequestParameterHelper apiRequestParameterHelper, final LoanReadPlatformService loanReadPlatformService) { this.toApiJsonSerializer = toApiJsonSerializer; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; @@ -67,29 +67,27 @@ public class LoanDisbursementDetailApiResource { public String updateDisbursementDate(@PathParam("loanId") final Long loanId, @PathParam("disbursementId") final Long disbursementId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDisbusementDate(loanId,disbursementId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDisbusementDate(loanId, disbursementId) + .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); return this.toApiJsonSerializer.serialize(result); } - @GET @Path("{disbursementId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retriveDetail(@PathParam("loanId") final Long loanId,@PathParam("disbursementId") final Long disbursementId, + public String retriveDetail(@PathParam("loanId") final Long loanId, @PathParam("disbursementId") final Long disbursementId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); final DisbursementData disbursementData = this.loanReadPlatformService.retrieveLoanDisbursementDetail(loanId, disbursementId); - + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.toApiJsonSerializer.serialize(settings, disbursementData, this.RESPONSE_DATA_PARAMETERS); } - - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java index 69093b829..00731bffa 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java @@ -149,10 +149,10 @@ public class LoanTransactionsApiResource { } else if (is(commandParam, "close")) { final CommandWrapper commandRequest = builder.closeLoanTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - }else if (is(commandParam, "undowriteoff")) { + } else if (is(commandParam, "undowriteoff")) { final CommandWrapper commandRequest = builder.undoWriteOffLoanTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - } + } if (result == null) { throw new UnrecognizedQueryParamException("command", commandParam); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java index d4e2fe990..6727594fa 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java @@ -213,8 +213,8 @@ public class LoansApiResource { officeId = loanAccountClientDetails.officeId(); - newLoanAccount = newLoanAccount == null ? loanAccountClientDetails : LoanAccountData.populateClientDefaults( - newLoanAccount, loanAccountClientDetails); + newLoanAccount = newLoanAccount == null ? loanAccountClientDetails : LoanAccountData.populateClientDefaults(newLoanAccount, + loanAccountClientDetails); // if it's JLG loan add group details if (templateType.equals("jlg")) { @@ -238,16 +238,16 @@ public class LoansApiResource { calendarOptions = this.loanReadPlatformService.retrieveCalendars(groupId); newLoanAccount = newLoanAccount == null ? loanAccountGroupData : LoanAccountData.populateGroupDefaults(newLoanAccount, loanAccountGroupData); - if(productId != null){ + if (productId != null) { Map memberLoanCycle = new HashMap(); Collection members = loanAccountGroupData.groupData().clientMembers(); - for(ClientData clientData:members){ + for (ClientData clientData : members) { Integer loanCounter = this.loanReadPlatformService.retriveLoanCounter(clientData.id(), productId); memberLoanCycle.put(clientData.id(), loanCounter); } newLoanAccount = LoanAccountData.associateMemberVariations(newLoanAccount, memberLoanCycle); } - + } else { final String errorMsg = "Loan template type '" + templateType + "' is not supported"; throw new NotSupportedLoanTemplateTypeException(errorMsg, templateType); @@ -306,7 +306,7 @@ public class LoansApiResource { if (associationParameters.contains("all")) { associationParameters.addAll(Arrays.asList("repaymentSchedule", "transactions", "charges", "guarantors", "collateral", - "notes", "linkedAccount","multiDisburseDetails")); + "notes", "linkedAccount", "multiDisburseDetails")); } if (associationParameters.contains("guarantors")) { @@ -324,23 +324,24 @@ public class LoansApiResource { loanRepayments = currentLoanRepayments; } } - - if(associationParameters.contains("multiDisburseDetails") || associationParameters.contains("repaymentSchedule")){ + + if (associationParameters.contains("multiDisburseDetails") || associationParameters.contains("repaymentSchedule")) { mandatoryResponseParameters.add("multiDisburseDetails"); disbursementData = this.loanReadPlatformService.retrieveLoanDisbursementDetails(loanId); } - - if(associationParameters.contains("emiAmountVariations") || associationParameters.contains("repaymentSchedule")){ + if (associationParameters.contains("emiAmountVariations") || associationParameters.contains("repaymentSchedule")) { mandatoryResponseParameters.add("emiAmountVariations"); - emiAmountVariations = this.loanReadPlatformService.retrieveLoanTermVariations(loanId, LoanTermVariationType.EMI_AMOUNT.getValue()); + emiAmountVariations = this.loanReadPlatformService.retrieveLoanTermVariations(loanId, + LoanTermVariationType.EMI_AMOUNT.getValue()); } - + if (associationParameters.contains("repaymentSchedule")) { mandatoryResponseParameters.add("repaymentSchedule"); final RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData = loanBasicDetails.repaymentScheduleRelatedData(); - repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId, repaymentScheduleRelatedData, disbursementData); + repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId, repaymentScheduleRelatedData, + disbursementData); } if (associationParameters.contains("charges")) { @@ -376,7 +377,7 @@ public class LoansApiResource { mandatoryResponseParameters.add("linkedAccount"); linkedAccount = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId); } - + } Collection productOptions = null; @@ -441,7 +442,7 @@ public class LoansApiResource { charges, collateral, guarantors, meeting, productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers, loanPurposeOptions, - loanCollateralOptions, calendarOptions, notes, accountLinkingOptions, linkedAccount, disbursementData,emiAmountVariations); + loanCollateralOptions, calendarOptions, notes, accountLinkingOptions, linkedAccount, disbursementData, emiAmountVariations); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters(), mandatoryResponseParameters); @@ -451,15 +452,18 @@ public class LoansApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("externalId") final String externalId, -// @QueryParam("underHierarchy") final String hierarchy, + public String retrieveAll(@Context final UriInfo uriInfo, + @QueryParam("sqlSearch") final String sqlSearch, + @QueryParam("externalId") final String externalId, + // @QueryParam("underHierarchy") final String hierarchy, @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, @QueryParam("accountNo") final String accountNo) { + @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, + @QueryParam("accountNo") final String accountNo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); - final SearchParameters searchParameters = SearchParameters.forLoans(sqlSearch, externalId, offset, limit, orderBy, sortOrder, accountNo); + final SearchParameters searchParameters = SearchParameters.forLoans(sqlSearch, externalId, offset, limit, orderBy, sortOrder, + accountNo); final Page loanBasicDetails = this.loanReadPlatformService.retrieveAll(searchParameters); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/DisbursementData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/DisbursementData.java index 624e48804..04872b543 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/DisbursementData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/DisbursementData.java @@ -12,7 +12,7 @@ import org.joda.time.LocalDate; /** * Immutable data object representing disbursement information. */ -public class DisbursementData implements Comparable{ +public class DisbursementData implements Comparable { @SuppressWarnings("unused") private final Long id; @@ -21,11 +21,9 @@ public class DisbursementData implements Comparable{ private final BigDecimal principal; @SuppressWarnings("unused") private final BigDecimal approvedPrincipal; - - public DisbursementData(Long id, final LocalDate expectedDisbursementDate, - final LocalDate actualDisbursementDate, final BigDecimal principalDisbursed, - final BigDecimal approvedPrincipal) { + public DisbursementData(Long id, final LocalDate expectedDisbursementDate, final LocalDate actualDisbursementDate, + final BigDecimal principalDisbursed, final BigDecimal approvedPrincipal) { this.id = id; this.expectedDisbursementDate = expectedDisbursementDate; this.actualDisbursementDate = actualDisbursementDate; @@ -48,24 +46,22 @@ public class DisbursementData implements Comparable{ public boolean isDisbursed() { return this.actualDisbursementDate != null; } - + @Override public int compareTo(final DisbursementData obj) { if (obj == null) { return -1; } return obj.expectedDisbursementDate.compareTo(this.expectedDisbursementDate); } - + public boolean isDueForDisbursement(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive) { final LocalDate dueDate = disbursementDate(); return occursOnDayFromAndUpToAndIncluding(fromNotInclusive, upToAndInclusive, dueDate); } - + private boolean occursOnDayFromAndUpToAndIncluding(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive, final LocalDate target) { return target != null && target.isAfter(fromNotInclusive) && !target.isAfter(upToAndInclusive); } - - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanAccountData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanAccountData.java index 3f98d6167..197324aa0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanAccountData.java @@ -140,20 +140,21 @@ public class LoanAccountData { // linkable account details private final PortfolioAccountData linkedAccount; private final Collection accountLinkingOptions; - + private final Boolean multiDisburseLoan; - + private final BigDecimal fixedEmiAmount; - + private final BigDecimal maxOutstandingLoanBalance; - + private final Boolean canDisburse; - + private final Collection emiAmountVariations; - + private final LoanProductData product; - + private final Map memberVariations; + /** * Used to produce a {@link LoanAccountData} with only collateral options * for now. @@ -238,17 +239,18 @@ public class LoanAccountData { final LoanProductData product = null; return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group, loanType, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName, loanOfficerId, loanOfficerName, - currencyData, principal,principal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, numberOfRepayments, - repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, transactionProcessingStrategyName, - amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, - interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, + currencyData, principal, principal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, + numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, + transactionProcessingStrategyName, amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, + interestType, interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, timeline, summary, feeChargesDueAtDisbursementCharged, repaymentSchedule, transactions, charges, collateral, guarantors, calendarData, productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, transactionProcessingStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions, - syncDisbursementWithMeeting, loancounter, loanProductCounter, notes, accountLinkingOptions, linkedAccount, disbursementData, - multiDisburseLoan, fixedEmiAmount,maxOutstandingLoanBalance,emiAmountVariations,memberVariations, product); + syncDisbursementWithMeeting, loancounter, loanProductCounter, notes, accountLinkingOptions, linkedAccount, + disbursementData, multiDisburseLoan, fixedEmiAmount, maxOutstandingLoanBalance, emiAmountVariations, memberVariations, + product); } /** @@ -336,17 +338,17 @@ public class LoanAccountData { return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group, loanType, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName, loanOfficerId, loanOfficerName, - currencyData, principal,principal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, numberOfRepayments, - repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, transactionProcessingStrategyName, - amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, - interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, + currencyData, principal, principal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, + numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, + transactionProcessingStrategyName, amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, + interestType, interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, timeline, summary, feeChargesDueAtDisbursementCharged, repaymentSchedule, transactions, charges, collateral, guarantors, calendarData, productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions, syncDisbursementWithMeeting, loancounter, loanProductCounter, - notes, accountLinkingOptions, linkedAccount, disbursementData, multiDisburseLoan, fixedEmiAmount, maxOutstandingLoanBalance, - emiAmountVariations,memberVariations, product); + notes, accountLinkingOptions, linkedAccount, disbursementData, multiDisburseLoan, fixedEmiAmount, + maxOutstandingLoanBalance, emiAmountVariations, memberVariations, product); } public static LoanAccountData populateClientDefaults(final LoanAccountData acc, final LoanAccountData clientAcc) { @@ -354,19 +356,20 @@ public class LoanAccountData { return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, clientAcc.clientId, clientAcc.clientName, clientAcc.clientOfficeId, acc.group, acc.loanType, acc.loanProductId, acc.loanProductName, acc.loanProductDescription, acc.fundId, acc.fundName, acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, - acc.principal,acc.approvedPrincipal, acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, - acc.numberOfRepayments, acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, - acc.transactionProcessingStrategyName, acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, - acc.annualInterestRate, acc.interestType, acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, - acc.graceOnPrincipalPayment, acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, - clientAcc.timeline, acc.summary, acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, - acc.collateral, acc.guarantors, acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, - acc.repaymentFrequencyTypeOptions, acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, - acc.amortizationTypeOptions, acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, - acc.chargeOptions, null, acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, + acc.principal, acc.approvedPrincipal, acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, + acc.termPeriodFrequencyType, acc.numberOfRepayments, acc.repaymentEvery, acc.repaymentFrequencyType, + acc.transactionProcessingStrategyId, acc.transactionProcessingStrategyName, acc.amortizationType, + acc.interestRatePerPeriod, acc.interestRateFrequencyType, acc.annualInterestRate, acc.interestType, + acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, acc.graceOnPrincipalPayment, + acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, clientAcc.timeline, acc.summary, + acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, acc.collateral, acc.guarantors, + acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, acc.repaymentFrequencyTypeOptions, + acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions, + acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null, + acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, acc.notes, acc.accountLinkingOptions, - acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount,acc.maxOutstandingLoanBalance, - acc.emiAmountVariations,acc.memberVariations, acc.product); + acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount, acc.maxOutstandingLoanBalance, + acc.emiAmountVariations, acc.memberVariations, acc.product); } /** @@ -445,47 +448,47 @@ public class LoanAccountData { final Integer loanProductCounter = null; final Collection accountLinkingOptions = null; final PortfolioAccountData linkedAccount = null; - final Collection disbursementData = null; + final Collection disbursementData = null; final Boolean multiDisburseLoan = null; final BigDecimal fixedEmiAmount = null; final BigDecimal maxOutstandingBalance = null; - final Collection emiAmountVariations = null; + final Collection emiAmountVariations = null; final Map memberVariations = null; final LoanProductData product = null; return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group, loanType, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName, loanOfficerId, loanOfficerName, - currencyData, principal,principal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, numberOfRepayments, - repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, transactionProcessingStrategyName, - amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, - interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, + currencyData, principal, principal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, + numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, + transactionProcessingStrategyName, amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, + interestType, interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, timeline, summary, feeChargesDueAtDisbursementCharged, repaymentSchedule, transactions, charges, collateral, guarantors, calendarData, productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions, syncDisbursementWithMeeting, loancounter, loanProductCounter, - notes, accountLinkingOptions, linkedAccount, disbursementData, multiDisburseLoan, fixedEmiAmount,maxOutstandingBalance, - emiAmountVariations,memberVariations, product); + notes, accountLinkingOptions, linkedAccount, disbursementData, multiDisburseLoan, fixedEmiAmount, maxOutstandingBalance, + emiAmountVariations, memberVariations, product); } public static LoanAccountData populateGroupDefaults(final LoanAccountData acc, final LoanAccountData groupAcc) { return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId, groupAcc.group, acc.loanType, acc.loanProductId, acc.loanProductName, acc.loanProductDescription, acc.fundId, acc.fundName, - acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal,acc.approvedPrincipal, - acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, acc.numberOfRepayments, - acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, acc.transactionProcessingStrategyName, - acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, acc.annualInterestRate, acc.interestType, - acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, acc.graceOnPrincipalPayment, - acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, groupAcc.timeline, acc.summary, - acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, acc.collateral, acc.guarantors, - acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, acc.repaymentFrequencyTypeOptions, - acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions, - acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null, - acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, + acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal, + acc.approvedPrincipal, acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, + acc.numberOfRepayments, acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, + acc.transactionProcessingStrategyName, acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, + acc.annualInterestRate, acc.interestType, acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, + acc.graceOnPrincipalPayment, acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, + groupAcc.timeline, acc.summary, acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, + acc.collateral, acc.guarantors, acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, + acc.repaymentFrequencyTypeOptions, acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, + acc.amortizationTypeOptions, acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, + acc.chargeOptions, null, acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, acc.notes, acc.accountLinkingOptions, - acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount,acc.maxOutstandingLoanBalance, - acc.emiAmountVariations,acc.memberVariations, acc.product); + acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount, acc.maxOutstandingLoanBalance, + acc.emiAmountVariations, acc.memberVariations, acc.product); } public static LoanAccountData loanProductWithTemplateDefaults(final LoanProductData product, @@ -585,14 +588,14 @@ public class LoanAccountData { if (numberOfRepayments == null) { numberOfRepayments = product.getNumberOfRepayments(); } - + final Integer termFrequency = numberOfRepayments * product.getRepaymentEvery(); final BigDecimal fixedEmi = null; Map memberVariations = null; return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group, loanType, product.getId(), product.getName(), product.getDescription(), product.getFundId(), product.getFundName(), loanPurposeId, - loanPurposeName, loanOfficerId, loanOfficerName, product.getCurrency(), principal,principal, totalOverpaid, + loanPurposeName, loanOfficerId, loanOfficerName, product.getCurrency(), principal, principal, totalOverpaid, product.getInArrearsTolerance(), termFrequency, termPeriodFrequencyType, numberOfRepayments, product.getRepaymentEvery(), product.getRepaymentFrequencyType(), product.getTransactionProcessingStrategyId(), transactionProcessingStrategyName, product.getAmortizationType(), interestRatePerPeriod, product.getInterestRateFrequencyType(), @@ -603,8 +606,8 @@ public class LoanAccountData { repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions, syncDisbursementWithMeeting, loancounter, loanProductCounter, - notes, accountLinkingOptions, linkedAccount, disbursementData, product.getMultiDisburseLoan(), fixedEmi, product.getOutstandingLoanBalance(), - emiAmountVariations,memberVariations, product); + notes, accountLinkingOptions, linkedAccount, disbursementData, product.getMultiDisburseLoan(), fixedEmi, + product.getOutstandingLoanBalance(), emiAmountVariations, memberVariations, product); } public static LoanAccountData populateLoanProductDefaults(final LoanAccountData acc, final LoanProductData product) { @@ -642,20 +645,20 @@ public class LoanAccountData { return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId, acc.group, acc.loanType, product.getId(), product.getName(), product.getDescription(), product.getFundId(), product.getFundName(), acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, - product.getCurrency(), product.getPrincipal(),product.getPrincipal(), acc.totalOverpaid, product.getInArrearsTolerance(), termFrequency, - termPeriodFrequencyType, product.getNumberOfRepayments(), product.getRepaymentEvery(), product.getRepaymentFrequencyType(), - product.getTransactionProcessingStrategyId(), product.getTransactionProcessingStrategyName(), - product.getAmortizationType(), product.getInterestRatePerPeriod(), product.getInterestRateFrequencyType(), - product.getAnnualInterestRate(), product.getInterestType(), product.getInterestCalculationPeriodType(), - acc.expectedFirstRepaymentOnDate, product.getGraceOnPrincipalPayment(), product.getGraceOnInterestPayment(), - product.getGraceOnInterestCharged(), acc.interestChargedFromDate, acc.timeline, acc.summary, - acc.feeChargesAtDisbursementCharged, repaymentSchedule, transactions, charges, collateral, guarantors, calendarData, - productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions, + product.getCurrency(), product.getPrincipal(), product.getPrincipal(), acc.totalOverpaid, product.getInArrearsTolerance(), + termFrequency, termPeriodFrequencyType, product.getNumberOfRepayments(), product.getRepaymentEvery(), + product.getRepaymentFrequencyType(), product.getTransactionProcessingStrategyId(), + product.getTransactionProcessingStrategyName(), product.getAmortizationType(), product.getInterestRatePerPeriod(), + product.getInterestRateFrequencyType(), product.getAnnualInterestRate(), product.getInterestType(), + product.getInterestCalculationPeriodType(), acc.expectedFirstRepaymentOnDate, product.getGraceOnPrincipalPayment(), + product.getGraceOnInterestPayment(), product.getGraceOnInterestCharged(), acc.interestChargedFromDate, acc.timeline, + acc.summary, acc.feeChargesAtDisbursementCharged, repaymentSchedule, transactions, charges, collateral, guarantors, + calendarData, productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions, acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, notes, acc.accountLinkingOptions, - acc.linkedAccount, acc.disbursementDetails, product.getMultiDisburseLoan(), acc.fixedEmiAmount,product.getOutstandingLoanBalance(), - acc.emiAmountVariations,acc.memberVariations, product); + acc.linkedAccount, acc.disbursementDetails, product.getMultiDisburseLoan(), acc.fixedEmiAmount, + product.getOutstandingLoanBalance(), acc.emiAmountVariations, acc.memberVariations, product); } /* @@ -666,18 +669,17 @@ public class LoanAccountData { final String externalId, final Long clientId, final String clientName, final Long clientOfficeId, final GroupGeneralData group, final EnumOptionData loanType, final Long loanProductId, final String loanProductName, final String loanProductDescription, final Long fundId, final String fundName, final Long loanPurposeId, final String loanPurposeName, final Long loanOfficerId, - final String loanOfficerName, final CurrencyData currencyData, final BigDecimal principal,final BigDecimal approvedPrincipal, - final BigDecimal totalOverpaid, final BigDecimal inArrearsTolerance, - final Integer termFrequency, final EnumOptionData termPeriodFrequencyType, - final Integer numberOfRepayments, final Integer repaymentEvery, final EnumOptionData repaymentFrequencyType, - final Long transactionStrategyId, final String transactionStrategyName, final EnumOptionData amortizationType, - final BigDecimal interestRatePerPeriod, final EnumOptionData interestRateFrequencyType, final BigDecimal annualInterestRate, - final EnumOptionData interestType, final EnumOptionData interestCalculationPeriodType, + final String loanOfficerName, final CurrencyData currencyData, final BigDecimal principal, final BigDecimal approvedPrincipal, + final BigDecimal totalOverpaid, final BigDecimal inArrearsTolerance, final Integer termFrequency, + final EnumOptionData termPeriodFrequencyType, final Integer numberOfRepayments, final Integer repaymentEvery, + final EnumOptionData repaymentFrequencyType, final Long transactionStrategyId, final String transactionStrategyName, + final EnumOptionData amortizationType, final BigDecimal interestRatePerPeriod, final EnumOptionData interestRateFrequencyType, + final BigDecimal annualInterestRate, final EnumOptionData interestType, final EnumOptionData interestCalculationPeriodType, final LocalDate expectedFirstRepaymentOnDate, final Integer graceOnPrincipalPayment, final Integer graceOnInterestPayment, final Integer graceOnInterestCharged, final LocalDate interestChargedFromDate, final LoanApplicationTimelineData timeline, final LoanSummaryData loanSummary, final BigDecimal feeChargesDueAtDisbursementCharged, final Boolean syncDisbursementWithMeeting, final Integer loancounter, final Integer loanProductCounter, - final Boolean multiDisburseLoan,final BigDecimal fixedEmiAmont , final BigDecimal outstandingLoanBalance) { + final Boolean multiDisburseLoan, final BigDecimal fixedEmiAmont, final BigDecimal outstandingLoanBalance) { final LoanScheduleData repaymentSchedule = null; final Collection transactions = null; @@ -703,24 +705,24 @@ public class LoanAccountData { final Collection calendarOptions = null; final Collection accountLinkingOptions = null; final PortfolioAccountData linkedAccount = null; - final Collection disbursementData= null; - final Collection emiAmountVariations= null; + final Collection disbursementData = null; + final Collection emiAmountVariations = null; final Map memberVariations = null; final LoanProductData product = null; - + return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group, loanType, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName, loanOfficerId, loanOfficerName, - currencyData, principal,approvedPrincipal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, numberOfRepayments, - repaymentEvery, repaymentFrequencyType, transactionStrategyId, transactionStrategyName, amortizationType, - interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType, - expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, - interestChargedFromDate, timeline, loanSummary, feeChargesDueAtDisbursementCharged, repaymentSchedule, transactions, - charges, collateral, guarantors, calendarData, productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, - repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, - interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, - loanCollateralOptions, calendarOptions, syncDisbursementWithMeeting, loancounter, loanProductCounter, notes, - accountLinkingOptions, linkedAccount, disbursementData, multiDisburseLoan, fixedEmiAmont, outstandingLoanBalance,emiAmountVariations, - memberVariations, product); + currencyData, principal, approvedPrincipal, totalOverpaid, inArrearsTolerance, termFrequency, termPeriodFrequencyType, + numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionStrategyId, transactionStrategyName, + amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, + interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, + graceOnInterestCharged, interestChargedFromDate, timeline, loanSummary, feeChargesDueAtDisbursementCharged, + repaymentSchedule, transactions, charges, collateral, guarantors, calendarData, productOptions, termFrequencyTypeOptions, + repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, + interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, + loanPurposeOptions, loanCollateralOptions, calendarOptions, syncDisbursementWithMeeting, loancounter, loanProductCounter, + notes, accountLinkingOptions, linkedAccount, disbursementData, multiDisburseLoan, fixedEmiAmont, outstandingLoanBalance, + emiAmountVariations, memberVariations, product); } /* @@ -739,22 +741,23 @@ public class LoanAccountData { final Collection loanOfficerOptions, final Collection loanPurposeOptions, final Collection loanCollateralOptions, final Collection calendarOptions, final Collection notes, final Collection accountLinkingOptions, - final PortfolioAccountData linkedAccount,final Collection disbursementDetails, + final PortfolioAccountData linkedAccount, final Collection disbursementDetails, final Collection emiAmountVariations) { return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId, acc.group, acc.loanType, acc.loanProductId, acc.loanProductName, acc.loanProductDescription, acc.fundId, acc.fundName, - acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal,acc.approvedPrincipal, - acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, acc.numberOfRepayments, - acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, acc.transactionProcessingStrategyName, - acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, acc.annualInterestRate, acc.interestType, - acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, acc.graceOnPrincipalPayment, - acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, acc.timeline, acc.summary, - acc.feeChargesAtDisbursementCharged, repaymentSchedule, transactions, charges, collateral, guarantors, calendarData, - productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, transactionProcessingStrategyOptions, - interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, - fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions, - acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, notes, accountLinkingOptions, linkedAccount, disbursementDetails, - acc.multiDisburseLoan, acc.fixedEmiAmount,acc.maxOutstandingLoanBalance,emiAmountVariations,acc.memberVariations, acc.product); + acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal, + acc.approvedPrincipal, acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, + acc.numberOfRepayments, acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, + acc.transactionProcessingStrategyName, acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, + acc.annualInterestRate, acc.interestType, acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, + acc.graceOnPrincipalPayment, acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, + acc.timeline, acc.summary, acc.feeChargesAtDisbursementCharged, repaymentSchedule, transactions, charges, collateral, + guarantors, calendarData, productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, + transactionProcessingStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, + interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, + loanCollateralOptions, calendarOptions, acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, notes, + accountLinkingOptions, linkedAccount, disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount, + acc.maxOutstandingLoanBalance, emiAmountVariations, acc.memberVariations, acc.product); } public static LoanAccountData associationsAndTemplate(final LoanAccountData acc, final Collection productOptions, @@ -765,32 +768,32 @@ public class LoanAccountData { acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions, acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null, allowedLoanOfficers, acc.loanPurposeOptions, acc.loanCollateralOptions, calendarOptions, acc.notes, accountLinkingOptions, - acc.linkedAccount, acc.disbursementDetails,acc.emiAmountVariations); + acc.linkedAccount, acc.disbursementDetails, acc.emiAmountVariations); } public static LoanAccountData associateGroup(final LoanAccountData acc, final GroupGeneralData group) { return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId, group, acc.loanType, acc.loanProductId, acc.loanProductName, acc.loanProductDescription, acc.fundId, acc.fundName, - acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal,acc.approvedPrincipal, - acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, acc.numberOfRepayments, - acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, acc.transactionProcessingStrategyName, - acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, acc.annualInterestRate, acc.interestType, - acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, acc.graceOnPrincipalPayment, - acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, acc.timeline, acc.summary, - acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, acc.collateral, acc.guarantors, - acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, acc.repaymentFrequencyTypeOptions, - acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions, - acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null, - acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, + acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal, + acc.approvedPrincipal, acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, + acc.numberOfRepayments, acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, + acc.transactionProcessingStrategyName, acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, + acc.annualInterestRate, acc.interestType, acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, + acc.graceOnPrincipalPayment, acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, + acc.timeline, acc.summary, acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, + acc.collateral, acc.guarantors, acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, + acc.repaymentFrequencyTypeOptions, acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, + acc.amortizationTypeOptions, acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, + acc.chargeOptions, null, acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, acc.notes, acc.accountLinkingOptions, - acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount,acc.maxOutstandingLoanBalance, - acc.emiAmountVariations,acc.memberVariations, acc.product); + acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount, acc.maxOutstandingLoanBalance, + acc.emiAmountVariations, acc.memberVariations, acc.product); } - - public static LoanAccountData associateMemberVariations(final LoanAccountData acc,final Map memberLoanCycle) { - + + public static LoanAccountData associateMemberVariations(final LoanAccountData acc, final Map memberLoanCycle) { + final Map memberVariations = new HashMap(); - for(Map.Entry mapEntry : memberLoanCycle.entrySet()){ + for (Map.Entry mapEntry : memberLoanCycle.entrySet()) { BigDecimal principal = null; BigDecimal interestRatePerPeriod = null; Integer numberOfRepayments = null; @@ -820,27 +823,27 @@ public class LoanAccountData { numberOfRepayments = acc.product.getNumberOfRepayments(); } final Integer termFrequency = numberOfRepayments * acc.product.getRepaymentEvery(); - LoanBorrowerCycleData borrowerCycleData = new LoanBorrowerCycleData(principal, interestRatePerPeriod, numberOfRepayments,termFrequency); + LoanBorrowerCycleData borrowerCycleData = new LoanBorrowerCycleData(principal, interestRatePerPeriod, numberOfRepayments, + termFrequency); memberVariations.put(clientId, borrowerCycleData); - } - - + } + return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId, acc.group, acc.loanType, acc.loanProductId, acc.loanProductName, acc.loanProductDescription, acc.fundId, acc.fundName, - acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal,acc.approvedPrincipal, - acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, acc.numberOfRepayments, - acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, acc.transactionProcessingStrategyName, - acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, acc.annualInterestRate, acc.interestType, - acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, acc.graceOnPrincipalPayment, - acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, acc.timeline, acc.summary, - acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, acc.collateral, acc.guarantors, - acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, acc.repaymentFrequencyTypeOptions, - acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions, - acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null, - acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, + acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal, + acc.approvedPrincipal, acc.totalOverpaid, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, + acc.numberOfRepayments, acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, + acc.transactionProcessingStrategyName, acc.amortizationType, acc.interestRatePerPeriod, acc.interestRateFrequencyType, + acc.annualInterestRate, acc.interestType, acc.interestCalculationPeriodType, acc.expectedFirstRepaymentOnDate, + acc.graceOnPrincipalPayment, acc.graceOnInterestPayment, acc.graceOnInterestCharged, acc.interestChargedFromDate, + acc.timeline, acc.summary, acc.feeChargesAtDisbursementCharged, acc.repaymentSchedule, acc.transactions, acc.charges, + acc.collateral, acc.guarantors, acc.meeting, acc.productOptions, acc.termFrequencyTypeOptions, + acc.repaymentFrequencyTypeOptions, acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, + acc.amortizationTypeOptions, acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, + acc.chargeOptions, null, acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, acc.notes, acc.accountLinkingOptions, - acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount,acc.maxOutstandingLoanBalance, - acc.emiAmountVariations,memberVariations, acc.product); + acc.linkedAccount, acc.disbursementDetails, acc.multiDisburseLoan, acc.fixedEmiAmount, acc.maxOutstandingLoanBalance, + acc.emiAmountVariations, memberVariations, acc.product); } private LoanAccountData( @@ -890,9 +893,10 @@ public class LoanAccountData { final Collection loanCollateralOptions, final Collection calendarOptions, final Boolean syncDisbursementWithMeeting, final Integer loanCounter, final Integer loanProductCounter, final Collection notes, final Collection accountLinkingOptions, - final PortfolioAccountData linkedAccount,final Collection disbursementDetails,final Boolean multiDisburseLoan, BigDecimal fixedEmiAmount, - final BigDecimal maxOutstandingLoanBalance,final Collection emiAmountVariations, - final Map memberVariations, final LoanProductData product) { + final PortfolioAccountData linkedAccount, final Collection disbursementDetails, + final Boolean multiDisburseLoan, BigDecimal fixedEmiAmount, final BigDecimal maxOutstandingLoanBalance, + final Collection emiAmountVariations, final Map memberVariations, + final LoanProductData product) { this.id = id; this.accountNo = accountNo; this.status = status; @@ -1010,14 +1014,14 @@ public class LoanAccountData { this.multiDisburseLoan = multiDisburseLoan; this.fixedEmiAmount = fixedEmiAmount; this.maxOutstandingLoanBalance = maxOutstandingLoanBalance; - - if(this.status != null && LoanStatus.fromInt(this.status.id().intValue()).isApproved()){ + + if (this.status != null && LoanStatus.fromInt(this.status.id().intValue()).isApproved()) { this.canDisburse = true; - }else{ + } else { boolean canDisburse = false; - if(this.multiDisburseLoan != null && this.multiDisburseLoan && this.disbursementDetails != null){ - for(DisbursementData disbursementData : this.disbursementDetails){ - if(!disbursementData.isDisbursed()){ + if (this.multiDisburseLoan != null && this.multiDisburseLoan && this.disbursementDetails != null) { + for (DisbursementData disbursementData : this.disbursementDetails) { + if (!disbursementData.isDisbursed()) { canDisburse = true; } } @@ -1030,7 +1034,7 @@ public class LoanAccountData { } public RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData() { - return this.timeline.repaymentScheduleRelatedData(this.currency, this.principal,this.approvedPrincipal, this.inArrearsTolerance, + return this.timeline.repaymentScheduleRelatedData(this.currency, this.principal, this.approvedPrincipal, this.inArrearsTolerance, this.feeChargesAtDisbursementCharged); } @@ -1065,7 +1069,7 @@ public class LoanAccountData { public Long clientId() { return this.clientId; } - + private static BigDecimal fetchLoanCycleDefaultValue(Collection borrowerCycleVariationData, Integer loanCycleNumber) { BigDecimal defaultValue = null; @@ -1092,12 +1096,10 @@ public class LoanAccountData { return data.getBorrowerCycleNumber() == loanCycleNumber && data.getValueConditionType().equals(LoanProductValueConditionType.EQUAL); } - public LoanProductData product() { return this.product; } - public GroupGeneralData groupData() { return this.group; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanApplicationTimelineData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanApplicationTimelineData.java index 8a662234b..ab8209602 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanApplicationTimelineData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanApplicationTimelineData.java @@ -130,9 +130,9 @@ public class LoanApplicationTimelineData { this.writeOffByLastname = writeOffByLastname; } - public RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData(final CurrencyData currency, final BigDecimal principal,final BigDecimal approvedPrincipal, - final BigDecimal inArrearsTolerance, final BigDecimal totalFeeChargesAtDisbursement) { - return new RepaymentScheduleRelatedLoanData(this.expectedDisbursementDate, this.actualDisbursementDate, currency, principal,approvedPrincipal, - inArrearsTolerance, totalFeeChargesAtDisbursement); + public RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData(final CurrencyData currency, final BigDecimal principal, + final BigDecimal approvedPrincipal, final BigDecimal inArrearsTolerance, final BigDecimal totalFeeChargesAtDisbursement) { + return new RepaymentScheduleRelatedLoanData(this.expectedDisbursementDate, this.actualDisbursementDate, currency, principal, + approvedPrincipal, inArrearsTolerance, totalFeeChargesAtDisbursement); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanBorrowerCycleData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanBorrowerCycleData.java index 5d5db5fcb..6972ec407 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanBorrowerCycleData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanBorrowerCycleData.java @@ -2,17 +2,20 @@ package org.mifosplatform.portfolio.loanaccount.data; import java.math.BigDecimal; - public class LoanBorrowerCycleData { - - private final BigDecimal principal ; - private final BigDecimal interestRatePerPeriod ; + + @SuppressWarnings("unused") + private final BigDecimal principal; + @SuppressWarnings("unused") + private final BigDecimal interestRatePerPeriod; + @SuppressWarnings("unused") private final Integer numberOfRepayments; + @SuppressWarnings("unused") private final Integer termFrequency; - - public LoanBorrowerCycleData(final BigDecimal principal, final BigDecimal interestRatePerPeriod,final Integer numberOfRepayments,final Integer termFrequency) { - + public LoanBorrowerCycleData(final BigDecimal principal, final BigDecimal interestRatePerPeriod, final Integer numberOfRepayments, + final Integer termFrequency) { + this.principal = principal; this.interestRatePerPeriod = interestRatePerPeriod; this.numberOfRepayments = numberOfRepayments; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanChargeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanChargeData.java index 83d363b35..254a4717b 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanChargeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanChargeData.java @@ -62,13 +62,13 @@ public class LoanChargeData { private final BigDecimal minCap; private final BigDecimal maxCap; - + @SuppressWarnings("unused") private final Collection installmentChargeData; public static LoanChargeData template(final Collection chargeOptions) { return new LoanChargeData(null, null, null, null, null, null, null, null, chargeOptions, false, null, false, false, null, null, - null,null,null); + null, null, null); } /** @@ -80,7 +80,7 @@ public class LoanChargeData { final EnumOptionData chargeCalculationType, final boolean penalty, final EnumOptionData chargePaymentMode, final BigDecimal minCap, final BigDecimal maxCap) { return new LoanChargeData(null, chargeId, name, currency, amount, percentage, chargeTimeType, chargeCalculationType, null, penalty, - chargePaymentMode, false, false, null, minCap, maxCap,null, null); + chargePaymentMode, false, false, null, minCap, maxCap, null, null); } public LoanChargeData(final Long id, final Long chargeId, final String name, final CurrencyData currency, final BigDecimal amount, @@ -88,7 +88,8 @@ public class LoanChargeData { final BigDecimal amountOutstanding, final EnumOptionData chargeTimeType, final LocalDate dueDate, final EnumOptionData chargeCalculationType, final BigDecimal percentage, final BigDecimal amountPercentageAppliedTo, final boolean penalty, final EnumOptionData chargePaymentMode, final boolean paid, final boolean waived, final Long loanId, - final BigDecimal minCap, final BigDecimal maxCap,final BigDecimal amountOrPercentage, Collection installmentChargeData) { + final BigDecimal minCap, final BigDecimal maxCap, final BigDecimal amountOrPercentage, + Collection installmentChargeData) { this.id = id; this.chargeId = chargeId; this.name = name; @@ -109,13 +110,13 @@ public class LoanChargeData { this.waived = waived; this.minCap = minCap; this.maxCap = maxCap; - if(amountOrPercentage == null){ + if (amountOrPercentage == null) { if (chargeCalculationType != null && chargeCalculationType.getId().intValue() > 1) { this.amountOrPercentage = this.percentage; } else { this.amountOrPercentage = amount; } - }else{ + } else { this.amountOrPercentage = amountOrPercentage; } @@ -128,7 +129,8 @@ public class LoanChargeData { private LoanChargeData(final Long id, final Long chargeId, final String name, final CurrencyData currency, final BigDecimal amount, final BigDecimal percentage, final EnumOptionData chargeTimeType, final EnumOptionData chargeCalculationType, final Collection chargeOptions, final boolean penalty, final EnumOptionData chargePaymentMode, final boolean paid, - final boolean waived, final Long loanId, final BigDecimal minCap, final BigDecimal maxCap,final BigDecimal amountOrPercentage, Collection installmentChargeData) { + final boolean waived, final Long loanId, final BigDecimal minCap, final BigDecimal maxCap, final BigDecimal amountOrPercentage, + Collection installmentChargeData) { this.id = id; this.chargeId = chargeId; this.name = name; @@ -148,13 +150,13 @@ public class LoanChargeData { this.paid = paid; this.waived = waived; - if(amountOrPercentage == null){ + if (amountOrPercentage == null) { if (chargeCalculationType != null && chargeCalculationType.getId().intValue() > 1) { this.amountOrPercentage = this.percentage; } else { this.amountOrPercentage = amount; } - }else{ + } else { this.amountOrPercentage = amountOrPercentage; } @@ -166,7 +168,8 @@ public class LoanChargeData { this.installmentChargeData = installmentChargeData; } - public LoanChargeData(final Long id, final LocalDate dueAsOfDate, final BigDecimal amountOutstanding, EnumOptionData chargeTimeType, final Long loanId, Collection installmentChargeData) { + public LoanChargeData(final Long id, final LocalDate dueAsOfDate, final BigDecimal amountOutstanding, EnumOptionData chargeTimeType, + final Long loanId, Collection installmentChargeData) { this.id = id; this.chargeId = null; this.name = null; @@ -193,7 +196,7 @@ public class LoanChargeData { this.maxCap = null; this.installmentChargeData = installmentChargeData; } - + public LoanChargeData(LoanChargeData chargeData, Collection installmentChargeData) { this.id = chargeData.id; this.chargeId = chargeData.chargeId; @@ -221,7 +224,7 @@ public class LoanChargeData { this.loanId = chargeData.loanId; this.installmentChargeData = installmentChargeData; } - + public LoanChargeData(final Long id, final LocalDate dueAsOfDate, final BigDecimal amountOrPercentage) { this.id = id; this.chargeId = null; @@ -249,8 +252,6 @@ public class LoanChargeData { this.maxCap = null; this.installmentChargeData = null; } - - public boolean isChargePayable() { boolean isAccountTransfer = false; @@ -275,7 +276,7 @@ public class LoanChargeData { public BigDecimal getAmountOutstanding() { return this.amountOutstanding; } - + public boolean isInstallmentFee() { boolean isInstalmentFee = false; if (this.chargeTimeType != null) { @@ -284,7 +285,6 @@ public class LoanChargeData { return isInstalmentFee; } - public BigDecimal amountOrPercentage() { return this.amountOrPercentage; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanInstallmentChargeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanInstallmentChargeData.java index 841b916ee..e703923d5 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanInstallmentChargeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanInstallmentChargeData.java @@ -32,14 +32,12 @@ public class LoanInstallmentChargeData { return this.dueDate; } - public boolean isPaymentPending(){ + public boolean isPaymentPending() { return !(this.paid || this.waived); } - public BigDecimal getAmountOutstanding() { return this.amountOutstanding; } - } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanStatusEnumData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanStatusEnumData.java index eddbb1b39..b8df30e9c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanStatusEnumData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanStatusEnumData.java @@ -40,11 +40,11 @@ public class LoanStatusEnumData { public Long id() { return this.id; } - + public String code() { return this.code; } - + public String value() { return this.value; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTermVariationsData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTermVariationsData.java index 7d9f20bbc..00930a9c1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTermVariationsData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTermVariationsData.java @@ -13,25 +13,22 @@ public class LoanTermVariationsData { private final LocalDate termVariationApplicableFrom; private final BigDecimal termValue; - public LoanTermVariationsData(final Long id, final EnumOptionData termType, - final LocalDate termVariationApplicableFrom, final BigDecimal termValue) { + public LoanTermVariationsData(final Long id, final EnumOptionData termType, final LocalDate termVariationApplicableFrom, + final BigDecimal termValue) { this.id = id; this.termType = termType; this.termVariationApplicableFrom = termVariationApplicableFrom; this.termValue = termValue; } - public EnumOptionData getTermType() { return this.termType; } - public LocalDate getTermApplicableFrom() { return this.termVariationApplicableFrom; } - public BigDecimal getTermValue() { return this.termValue; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java index 481b140d4..bcfad68e6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java @@ -49,7 +49,7 @@ public class LoanTransactionData { loanTransactionData.type, loanTransactionData.paymentDetailData, loanTransactionData.currency, loanTransactionData.date, loanTransactionData.amount, loanTransactionData.principalPortion, loanTransactionData.interestPortion, loanTransactionData.feeChargesPortion, loanTransactionData.penaltyChargesPortion, loanTransactionData.overpaymentPortion, - paymentTypeOptions, loanTransactionData.externalId, loanTransactionData.transfer,loanTransactionData.fixedEmiAmount); + paymentTypeOptions, loanTransactionData.externalId, loanTransactionData.transfer, loanTransactionData.fixedEmiAmount); } public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType, @@ -58,7 +58,7 @@ public class LoanTransactionData { final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final String externalId, final AccountTransferData transfer, BigDecimal fixedEmiAmount) { this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, principalPortion, interestPortion, - feeChargesPortion, penaltyChargesPortion, overpaymentPortion, null, externalId, transfer,fixedEmiAmount); + feeChargesPortion, penaltyChargesPortion, overpaymentPortion, null, externalId, transfer, fixedEmiAmount); } public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java index 69cb3b5bf..6c241eb5c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java @@ -24,8 +24,8 @@ public class RepaymentScheduleRelatedLoanData { private final BigDecimal totalFeeChargesAtDisbursement; public RepaymentScheduleRelatedLoanData(final LocalDate expectedDisbursementDate, final LocalDate actualDisbursementDate, - final CurrencyData currency, final BigDecimal principal,final BigDecimal approvedPrincipal, final BigDecimal inArrearsTolerance, - final BigDecimal totalFeeChargesAtDisbursement) { + final CurrencyData currency, final BigDecimal principal, final BigDecimal approvedPrincipal, + final BigDecimal inArrearsTolerance, final BigDecimal totalFeeChargesAtDisbursement) { this.expectedDisbursementDate = expectedDisbursementDate; this.actualDisbursementDate = actualDisbursementDate; this.currency = currency; @@ -64,6 +64,7 @@ public class RepaymentScheduleRelatedLoanData { } public DisbursementData disbursementData() { - return new DisbursementData(null, this.expectedDisbursementDate, this.actualDisbursementDate, this.principal,this.approvedPrincipal); + return new DisbursementData(null, this.expectedDisbursementDate, this.actualDisbursementDate, this.principal, + this.approvedPrincipal); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/ChangedTransactionDetail.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/ChangedTransactionDetail.java index 69d0889e8..0523c6217 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/ChangedTransactionDetail.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/ChangedTransactionDetail.java @@ -16,7 +16,7 @@ import java.util.Map; */ public class ChangedTransactionDetail { - private final Map newTransactionMappings = new HashMap(); + private final Map newTransactionMappings = new HashMap(); public Map getNewTransactionMappings() { return this.newTransactionMappings; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/DefaultLoanLifecycleStateMachine.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/DefaultLoanLifecycleStateMachine.java index fa37e4813..8fe9abad6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/DefaultLoanLifecycleStateMachine.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/DefaultLoanLifecycleStateMachine.java @@ -90,11 +90,11 @@ public class DefaultLoanLifecycleStateMachine implements LoanLifecycleStateMachi } break; case LOAN_CLOSED: - break; + break; case WRITE_OFF_OUTSTANDING_UNDO: - break; + break; default: - break; + break; } return newState; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java index 339146a23..27bacd135 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java @@ -122,7 +122,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService { final List dataValidationErrors = new ArrayList(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.transaction"); if (realCause.getMessage().toLowerCase().contains("external_id_unique")) { - baseDataValidator.reset().parameter("externalId").value(newRepaymentTransaction.getExternalId()).failWithCode("value.must.be.unique"); + baseDataValidator.reset().parameter("externalId").value(newRepaymentTransaction.getExternalId()) + .failWithCode("value.must.be.unique"); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } @@ -135,13 +136,13 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService { * only in edge cases (when a payment is made before the latest payment * recorded against the loan) ***/ - + this.loanRepository.saveAndFlush(loan); if (changedTransactionDetail != null) { for (Map.Entry mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { this.loanTransactionRepository.save(mapEntry.getValue()); - //update loan with references to the newly created transactions + // update loan with references to the newly created transactions loan.getLoanTransactions().add(mapEntry.getValue()); updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue()); } @@ -187,7 +188,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService { loan.handlePayDisbursementTransaction(chargeId, newPaymentTransaction, existingTransactionIds, existingReversedTransactionIds); } else { loan.makeChargePayment(chargeId, defaultLoanLifecycleStateMachine(), existingTransactionIds, existingReversedTransactionIds, - allowTransactionsOnHoliday, holidays, workingDays, allowTransactionsOnNonWorkingDay, newPaymentTransaction, installmentNumber); + allowTransactionsOnHoliday, holidays, workingDays, allowTransactionsOnNonWorkingDay, newPaymentTransaction, + installmentNumber); } this.loanTransactionRepository.save(newPaymentTransaction); this.loanRepository.saveAndFlush(loan); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java index 37d85bc61..f376d3712 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanCharge.java @@ -108,11 +108,10 @@ public class LoanCharge extends AbstractPersistable { @LazyCollection(LazyCollectionOption.FALSE) @OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true) private final Set loanInstallmentCharge = new HashSet(); - + @Column(name = "is_active", nullable = false) private boolean active = true; - public static LoanCharge createNewFromJson(final Loan loan, final Charge chargeDefinition, final JsonCommand command) { final BigDecimal amount = command.bigDecimalValueOfParameterNamed("amount"); @@ -125,24 +124,25 @@ public class LoanCharge extends AbstractPersistable { switch (ChargeCalculationType.fromInt(chargeDefinition.getChargeCalculation())) { case PERCENT_OF_AMOUNT: amountPercentageAppliedTo = loan.getPrincpal().getAmount(); - break; + break; case PERCENT_OF_AMOUNT_AND_INTEREST: amountPercentageAppliedTo = loan.getPrincpal().getAmount().add(loan.getTotalInterest()); - break; + break; case PERCENT_OF_INTEREST: amountPercentageAppliedTo = loan.getTotalInterest(); break; default: - break; + break; } BigDecimal loanCharge = BigDecimal.ZERO; - if(ChargeTimeType.fromInt(chargeDefinition.getChargeTime()).equals(ChargeTimeType.INSTALMENT_FEE)){ + if (ChargeTimeType.fromInt(chargeDefinition.getChargeTime()).equals(ChargeTimeType.INSTALMENT_FEE)) { BigDecimal percentage = amount; - if(percentage == null){ + if (percentage == null) { percentage = chargeDefinition.getAmount(); } - loanCharge = loan.calculatePerInstallmentChargeAmount(ChargeCalculationType.fromInt(chargeDefinition.getChargeCalculation()),percentage); + loanCharge = loan.calculatePerInstallmentChargeAmount(ChargeCalculationType.fromInt(chargeDefinition.getChargeCalculation()), + percentage); } return new LoanCharge(loan, chargeDefinition, amountPercentageAppliedTo, amount, chargeTime, chargeCalculation, dueDate, @@ -154,8 +154,9 @@ public class LoanCharge extends AbstractPersistable { */ public static LoanCharge createNewWithoutLoan(final Charge chargeDefinition, final BigDecimal loanPrincipal, final BigDecimal amount, final ChargeTimeType chargeTime, final ChargeCalculationType chargeCalculation, final LocalDate dueDate, - final ChargePaymentMode chargePaymentMode,final Integer numberOfRepayments) { - return new LoanCharge(null, chargeDefinition, loanPrincipal, amount, chargeTime, chargeCalculation, dueDate, chargePaymentMode, numberOfRepayments, BigDecimal.ZERO); + final ChargePaymentMode chargePaymentMode, final Integer numberOfRepayments) { + return new LoanCharge(null, chargeDefinition, loanPrincipal, amount, chargeTime, chargeCalculation, dueDate, chargePaymentMode, + numberOfRepayments, BigDecimal.ZERO); } protected LoanCharge() { @@ -176,7 +177,8 @@ public class LoanCharge extends AbstractPersistable { this.chargeTime = chargeTime.getValue(); } - if (ChargeTimeType.fromInt(this.chargeTime).equals(ChargeTimeType.SPECIFIED_DUE_DATE) || ChargeTimeType.fromInt(this.chargeTime).equals(ChargeTimeType.OVERDUE_INSTALLMENT) ) { + if (ChargeTimeType.fromInt(this.chargeTime).equals(ChargeTimeType.SPECIFIED_DUE_DATE) + || ChargeTimeType.fromInt(this.chargeTime).equals(ChargeTimeType.OVERDUE_INSTALLMENT)) { if (dueDate == null) { final String defaultUserMessage = "Loan charge is missing due date."; @@ -203,11 +205,12 @@ public class LoanCharge extends AbstractPersistable { if (chargePaymentMode != null) { this.chargePaymentMode = chargePaymentMode.getValue(); } - populateDerivedFields(loanPrincipal, chargeAmount,numberOfRepayments, loanCharge); + populateDerivedFields(loanPrincipal, chargeAmount, numberOfRepayments, loanCharge); this.paid = determineIfFullyPaid(); } - private void populateDerivedFields(final BigDecimal amountPercentageAppliedTo, final BigDecimal chargeAmount,Integer numberOfRepayments, BigDecimal loanCharge) { + private void populateDerivedFields(final BigDecimal amountPercentageAppliedTo, final BigDecimal chargeAmount, + Integer numberOfRepayments, BigDecimal loanCharge) { switch (ChargeCalculationType.fromInt(this.chargeCalculation)) { case INVALID: @@ -223,12 +226,12 @@ public class LoanCharge extends AbstractPersistable { this.percentage = null; this.amountPercentageAppliedTo = null; this.amountPaid = null; - if(isInstalmentFee()){ - if(numberOfRepayments == null){ + if (isInstalmentFee()) { + if (numberOfRepayments == null) { numberOfRepayments = this.loan.repaymentScheduleDetail().getNumberOfRepayments(); } this.amount = chargeAmount.multiply(BigDecimal.valueOf(numberOfRepayments)); - }else{ + } else { this.amount = chargeAmount; } this.amountOutstanding = this.amount; @@ -240,7 +243,7 @@ public class LoanCharge extends AbstractPersistable { case PERCENT_OF_INTEREST: this.percentage = chargeAmount; this.amountPercentageAppliedTo = amountPercentageAppliedTo; - if(loanCharge.compareTo(BigDecimal.ZERO) == 0){ + if (loanCharge.compareTo(BigDecimal.ZERO) == 0) { loanCharge = percentageOf(this.amountPercentageAppliedTo); } this.amount = minimumAndMaximumCap(loanCharge); @@ -251,15 +254,15 @@ public class LoanCharge extends AbstractPersistable { break; } this.amountOrPercentage = chargeAmount; - if(this.loan!=null && isInstalmentFee()){ + if (this.loan != null && isInstalmentFee()) { final Set chargePerInstallments = this.loan.generateInstallmentLoanCharges(this); - if(this.loanInstallmentCharge.isEmpty()){ + if (this.loanInstallmentCharge.isEmpty()) { this.loanInstallmentCharge.addAll(chargePerInstallments); - }else{ + } else { int index = 0; final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()]; final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments); - for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){ + for (final LoanInstallmentCharge chargePerInstallment : this.loanInstallmentCharge) { chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]); } } @@ -279,7 +282,7 @@ public class LoanCharge extends AbstractPersistable { this.amountOutstanding = calculateAmountOutstanding(currency); this.paid = false; this.waived = false; - for(final LoanInstallmentCharge installmentCharge:this.loanInstallmentCharge){ + for (final LoanInstallmentCharge installmentCharge : this.loanInstallmentCharge) { installmentCharge.resetPaidAmount(currency); } } @@ -288,21 +291,21 @@ public class LoanCharge extends AbstractPersistable { this.amountPaid = BigDecimal.ZERO; this.amountOutstanding = calculateAmountOutstanding(currency); this.paid = false; - for(final LoanInstallmentCharge installmentCharge:this.loanInstallmentCharge){ + for (final LoanInstallmentCharge installmentCharge : this.loanInstallmentCharge) { installmentCharge.resetPaidAmount(currency); } } public Money waive(final MonetaryCurrency currency, final Integer loanInstallmentNumber) { - if(isInstalmentFee()){ + if (isInstalmentFee()) { final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber); final Money amountWaived = chargePerInstallment.waive(currency); - if(this.amountWaived == null){ + if (this.amountWaived == null) { this.amountWaived = BigDecimal.ZERO; } this.amountWaived = this.amountWaived.add(amountWaived.getAmount()); this.amountOutstanding = this.amountOutstanding.subtract(amountWaived.getAmount()); - if(determineIfFullyPaid()){ + if (determineIfFullyPaid()) { this.paid = false; this.waived = true; } @@ -324,7 +327,8 @@ public class LoanCharge extends AbstractPersistable { this.loan = loan; } - public void update(final BigDecimal amount, final LocalDate dueDate, final BigDecimal loanPrincipal, Integer numberOfRepayments, BigDecimal loanCharge) { + public void update(final BigDecimal amount, final LocalDate dueDate, final BigDecimal loanPrincipal, Integer numberOfRepayments, + BigDecimal loanCharge) { if (dueDate != null) { this.dueDate = dueDate.toDate(); } @@ -334,12 +338,12 @@ public class LoanCharge extends AbstractPersistable { case INVALID: break; case FLAT: - if(isInstalmentFee()){ - if(numberOfRepayments == null){ + if (isInstalmentFee()) { + if (numberOfRepayments == null) { numberOfRepayments = this.loan.repaymentScheduleDetail().getNumberOfRepayments(); } - this.amount = amount.multiply(BigDecimal.valueOf(numberOfRepayments)); - }else{ + this.amount = amount.multiply(BigDecimal.valueOf(numberOfRepayments)); + } else { this.amount = amount; } break; @@ -348,23 +352,23 @@ public class LoanCharge extends AbstractPersistable { case PERCENT_OF_INTEREST: this.percentage = amount; this.amountPercentageAppliedTo = loanPrincipal; - if(loanCharge.compareTo(BigDecimal.ZERO) == 0){ + if (loanCharge.compareTo(BigDecimal.ZERO) == 0) { loanCharge = percentageOf(this.amountPercentageAppliedTo); } this.amount = minimumAndMaximumCap(loanCharge); - break; + break; } this.amountOrPercentage = amount; this.amountOutstanding = calculateOutstanding(); - if(this.loan !=null && isInstalmentFee()){ + if (this.loan != null && isInstalmentFee()) { final Set chargePerInstallments = this.loan.generateInstallmentLoanCharges(this); - if(this.loanInstallmentCharge.isEmpty()){ + if (this.loanInstallmentCharge.isEmpty()) { this.loanInstallmentCharge.addAll(chargePerInstallments); - }else{ + } else { int index = 0; final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()]; final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments); - for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){ + for (final LoanInstallmentCharge chargePerInstallment : this.loanInstallmentCharge) { chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]); } } @@ -372,21 +376,21 @@ public class LoanCharge extends AbstractPersistable { } } - public void update(final BigDecimal amount, final LocalDate dueDate, final Integer numberOfRepayments){ + public void update(final BigDecimal amount, final LocalDate dueDate, final Integer numberOfRepayments) { BigDecimal amountPercentageAppliedTo = BigDecimal.ZERO; - if(this.loan!=null){ + if (this.loan != null) { switch (ChargeCalculationType.fromInt(this.chargeCalculation)) { case PERCENT_OF_AMOUNT: amountPercentageAppliedTo = this.loan.getPrincpal().getAmount(); - break; + break; case PERCENT_OF_AMOUNT_AND_INTEREST: amountPercentageAppliedTo = this.loan.getPrincpal().getAmount().add(this.loan.getTotalInterest()); - break; + break; case PERCENT_OF_INTEREST: amountPercentageAppliedTo = this.loan.getTotalInterest(); break; default: - break; + break; } } update(amount, dueDate, amountPercentageAppliedTo, numberOfRepayments, BigDecimal.ZERO); @@ -419,9 +423,9 @@ public class LoanCharge extends AbstractPersistable { case INVALID: break; case FLAT: - if(isInstalmentFee()){ - this.amount = newValue.multiply(BigDecimal.valueOf(this.loan.repaymentScheduleDetail().getNumberOfRepayments())); - }else{ + if (isInstalmentFee()) { + this.amount = newValue.multiply(BigDecimal.valueOf(this.loan.repaymentScheduleDetail().getNumberOfRepayments())); + } else { this.amount = newValue; } break; @@ -430,8 +434,9 @@ public class LoanCharge extends AbstractPersistable { case PERCENT_OF_INTEREST: this.percentage = newValue; this.amountPercentageAppliedTo = amount; - BigDecimal loanCharge = this.loan.calculatePerInstallmentChargeAmount(ChargeCalculationType.fromInt(this.chargeCalculation),this.percentage); - if(loanCharge.compareTo(BigDecimal.ZERO) == 0){ + BigDecimal loanCharge = this.loan.calculatePerInstallmentChargeAmount( + ChargeCalculationType.fromInt(this.chargeCalculation), this.percentage); + if (loanCharge.compareTo(BigDecimal.ZERO) == 0) { loanCharge = percentageOf(this.amountPercentageAppliedTo); } this.amount = minimumAndMaximumCap(loanCharge); @@ -439,15 +444,15 @@ public class LoanCharge extends AbstractPersistable { break; } this.amountOrPercentage = newValue; - if(isInstalmentFee()){ + if (isInstalmentFee()) { final Set chargePerInstallments = this.loan.generateInstallmentLoanCharges(this); - if(this.loanInstallmentCharge.isEmpty()){ + if (this.loanInstallmentCharge.isEmpty()) { this.loanInstallmentCharge.addAll(chargePerInstallments); - }else{ + } else { int index = 0; final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()]; final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments); - for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){ + for (final LoanInstallmentCharge chargePerInstallment : this.loanInstallmentCharge) { chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]); } } @@ -485,16 +490,12 @@ public class LoanCharge extends AbstractPersistable { } private boolean determineIfFullyPaid() { - if(this.amount == null){ - return true; - } + if (this.amount == null) { return true; } return BigDecimal.ZERO.compareTo(calculateOutstanding()) == 0; } private BigDecimal calculateOutstanding() { - if(this.amount == null){ - return null; - } + if (this.amount == null) { return null; } BigDecimal amountPaidLocal = BigDecimal.ZERO; if (this.amountPaid != null) { amountPaidLocal = this.amountPaid; @@ -519,7 +520,7 @@ public class LoanCharge extends AbstractPersistable { return percentageOf(value, this.percentage); } - public static BigDecimal percentageOf(final BigDecimal value,final BigDecimal percentage) { + public static BigDecimal percentageOf(final BigDecimal value, final BigDecimal percentage) { BigDecimal percentageOf = BigDecimal.ZERO; @@ -534,27 +535,28 @@ public class LoanCharge extends AbstractPersistable { /** * @param percentageOf * @returns a minimum cap or maximum cap set on charges if the criteria fits - * else it returns the percentageOf if the amount is within min and max cap + * else it returns the percentageOf if the amount is within min and + * max cap */ - private BigDecimal minimumAndMaximumCap(final BigDecimal percentageOf){ + private BigDecimal minimumAndMaximumCap(final BigDecimal percentageOf) { BigDecimal minMaxCap = BigDecimal.ZERO; - if(this.minCap !=null){ + if (this.minCap != null) { final int minimumCap = percentageOf.compareTo(this.minCap); - if(minimumCap == -1){ + if (minimumCap == -1) { minMaxCap = this.minCap; return minMaxCap; } } - if(this.maxCap !=null){ + if (this.maxCap != null) { final int maximumCap = percentageOf.compareTo(this.maxCap); - if(maximumCap == 1) { - minMaxCap = this.maxCap; - return minMaxCap; + if (maximumCap == 1) { + minMaxCap = this.maxCap; + return minMaxCap; } } minMaxCap = percentageOf; // this will round the amount value - if(this.loan != null && minMaxCap !=null){ + if (this.loan != null && minMaxCap != null) { minMaxCap = Money.of(this.loan.getCurrency(), minMaxCap).getAmount(); } return minMaxCap; @@ -637,20 +639,21 @@ public class LoanCharge extends AbstractPersistable { } /** - * @param feeAmount TODO + * @param feeAmount + * TODO * @param processAmount * Amount used to pay off this charge * @return Actual amount paid on this charge */ - public Money updatePaidAmountBy(final Money incrementBy,final Integer installmentNumber, final Money feeAmount) { + public Money updatePaidAmountBy(final Money incrementBy, final Integer installmentNumber, final Money feeAmount) { Money processAmount = Money.zero(incrementBy.getCurrency()); - if(isInstalmentFee()){ - if(installmentNumber == null){ + if (isInstalmentFee()) { + if (installmentNumber == null) { processAmount = getUnpaidInstallmentLoanCharge().updatePaidAmountBy(incrementBy, feeAmount); - }else{ + } else { processAmount = getInstallmentLoanCharge(installmentNumber).updatePaidAmountBy(incrementBy, feeAmount); } - }else{ + } else { processAmount = incrementBy; } Money amountPaidToDate = Money.of(processAmount.getCurrency(), this.amountPaid); @@ -739,58 +742,52 @@ public class LoanCharge extends AbstractPersistable { public LoanInstallmentCharge getInstallmentLoanCharge(final LocalDate periodDueDate) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { - if (periodDueDate.isEqual(loanChargePerInstallment.getRepaymentInstallment().getDueDate())) { - return loanChargePerInstallment; - } + if (periodDueDate.isEqual(loanChargePerInstallment.getRepaymentInstallment().getDueDate())) { return loanChargePerInstallment; } } return null; } public LoanInstallmentCharge getInstallmentLoanCharge(final Integer installmentNumber) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { - if (installmentNumber.equals(loanChargePerInstallment.getRepaymentInstallment().getInstallmentNumber().intValue()) ){ - return loanChargePerInstallment; - } + if (installmentNumber.equals(loanChargePerInstallment.getRepaymentInstallment().getInstallmentNumber().intValue())) { return loanChargePerInstallment; } } return null; } - public void clearLoanInstallmentCharges(){ + public void clearLoanInstallmentCharges() { this.loanInstallmentCharge.clear(); } - public void addLoanInstallmentCharges(final Collection installmentCharges){ + public void addLoanInstallmentCharges(final Collection installmentCharges) { this.loanInstallmentCharge.addAll(installmentCharges); } - public boolean hasNoLoanInstallmentCharges(){ + public boolean hasNoLoanInstallmentCharges() { return this.loanInstallmentCharge.isEmpty(); } - - public Set installmentCharges(){ + + public Set installmentCharges() { return this.loanInstallmentCharge; } - public LoanRepaymentScheduleInstallment fetchRepaymentInstallment(final Money trasferedAmount){ + public LoanRepaymentScheduleInstallment fetchRepaymentInstallment(final Money trasferedAmount) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { - if (loanChargePerInstallment.isPending() && - trasferedAmount.getAmount().equals(loanChargePerInstallment.getAmountThroughChargePayment(trasferedAmount.getCurrency()).getAmount()) ){ - return loanChargePerInstallment.getRepaymentInstallment(); - } + if (loanChargePerInstallment.isPending() + && trasferedAmount.getAmount().equals( + loanChargePerInstallment.getAmountThroughChargePayment(trasferedAmount.getCurrency()).getAmount())) { return loanChargePerInstallment + .getRepaymentInstallment(); } } return null; } - - public boolean isActive(){ + + public boolean isActive() { return this.active; } - public void setActive(boolean active) { this.active = active; } - public BigDecimal amountOrPercentage() { return this.amountOrPercentage; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanDisbursementDetails.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanDisbursementDetails.java index dc5b3324f..68c8252e3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanDisbursementDetails.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanDisbursementDetails.java @@ -24,7 +24,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable; @Table(name = "m_loan_disbursement_detail") public class LoanDisbursementDetails extends AbstractPersistable { - @SuppressWarnings("unused") @ManyToOne @JoinColumn(name = "loan_id", nullable = false) private Loan loan; @@ -39,7 +38,7 @@ public class LoanDisbursementDetails extends AbstractPersistable { @Column(name = "principal", scale = 6, precision = 19, nullable = false) private BigDecimal principal; - + @Column(name = "approved_principal", scale = 6, precision = 19, nullable = false) private BigDecimal approvedPrincipal; @@ -85,12 +84,11 @@ public class LoanDisbursementDetails extends AbstractPersistable { public BigDecimal principal() { return this.principal; } - - public void updatePrincipal(BigDecimal principal){ + + public void updatePrincipal(BigDecimal principal) { this.principal = principal; } - public Date getDisbursementDate() { Date disbursementDate = this.expectedDisbursementDate; if (this.actualDisbursementDate != null) { @@ -102,26 +100,24 @@ public class LoanDisbursementDetails extends AbstractPersistable { public DisbursementData toData() { LocalDate expectedDisburseDate = null; LocalDate actualDisburseDate = null; - if(this.expectedDisbursementDate != null){ + if (this.expectedDisbursementDate != null) { expectedDisburseDate = new LocalDate(this.expectedDisbursementDate); actualDisburseDate = expectedDisburseDate; } - if(getDisbursementDate() != null){ + if (getDisbursementDate() != null) { actualDisburseDate = new LocalDate(getDisbursementDate()); } - return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal,this.approvedPrincipal); + return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal, this.approvedPrincipal); } - public void updateActualDisbursementDate(Date actualDisbursementDate) { this.actualDisbursementDate = actualDisbursementDate; } - + public BigDecimal resetPrincipal() { return this.principal = this.approvedPrincipal; } - public void updateExpectedDisbursementDate(Date expectedDisbursementDate) { this.expectedDisbursementDate = expectedDisbursementDate; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanEvent.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanEvent.java index 185acf836..58a5a7ca7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanEvent.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanEvent.java @@ -23,7 +23,5 @@ public enum LoanEvent { WRITE_OFF_OUTSTANDING_UNDO, // LOAN_RESCHEDULE, // INTERST_REBATE_OWED, // - LOAN_OVERPAYMENT, LOAN_CHARGE_PAYMENT, - LOAN_CLOSED, - LOAN_EDIT_MULTI_DISBURSE_DATE; + LOAN_OVERPAYMENT, LOAN_CHARGE_PAYMENT, LOAN_CLOSED, LOAN_EDIT_MULTI_DISBURSE_DATE; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java index 58c88e5cb..224307cbe 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanInstallmentCharge.java @@ -53,12 +53,11 @@ public class LoanInstallmentCharge extends AbstractPersistable { @Column(name = "waived", nullable = false) private boolean waived = false; - public LoanInstallmentCharge() { // TODO Auto-generated constructor stub } - public LoanInstallmentCharge(final BigDecimal amount,final LoanCharge loanCharge,final LoanRepaymentScheduleInstallment installment) { + public LoanInstallmentCharge(final BigDecimal amount, final LoanCharge loanCharge, final LoanRepaymentScheduleInstallment installment) { this.loancharge = loanCharge; this.installment = installment; this.amount = amount; @@ -68,14 +67,13 @@ public class LoanInstallmentCharge extends AbstractPersistable { this.amountWrittenOff = null; } - public void copyFrom(final LoanInstallmentCharge loanChargePerInstallment){ + public void copyFrom(final LoanInstallmentCharge loanChargePerInstallment) { this.amount = loanChargePerInstallment.amount; this.installment = loanChargePerInstallment.installment; this.amountOutstanding = calculateOutstanding(); this.paid = determineIfFullyPaid(); } - public Money waive(final MonetaryCurrency currency) { this.amountWaived = this.amountOutstanding; this.amountOutstanding = BigDecimal.ZERO; @@ -84,22 +82,17 @@ public class LoanInstallmentCharge extends AbstractPersistable { return getAmountWaived(currency); } - public Money getAmountWaived(final MonetaryCurrency currency) { return Money.of(currency, this.amountWaived); } private boolean determineIfFullyPaid() { - if(this.amount == null){ - return true; - } + if (this.amount == null) { return true; } return BigDecimal.ZERO.compareTo(calculateOutstanding()) == 0; } private BigDecimal calculateOutstanding() { - if(this.amount == null){ - return null; - } + if (this.amount == null) { return null; } BigDecimal amountPaidLocal = BigDecimal.ZERO; if (this.amountPaid != null) { amountPaidLocal = this.amountPaid; @@ -120,7 +113,6 @@ public class LoanInstallmentCharge extends AbstractPersistable { return this.amount.subtract(totalAccountedFor); } - public BigDecimal getAmount() { return this.amount; } @@ -141,7 +133,6 @@ public class LoanInstallmentCharge extends AbstractPersistable { return getAmount(currency).minus(getAmountWaived(currency)).minus(getAmountPaid(currency)).getAmount(); } - public boolean isPaid() { return this.paid; } @@ -150,11 +141,10 @@ public class LoanInstallmentCharge extends AbstractPersistable { return this.waived; } - public boolean isPending(){ + public boolean isPending() { return !(isPaid() || isWaived()); } - public LoanRepaymentScheduleInstallment getRepaymentInstallment() { return this.installment; } @@ -182,7 +172,6 @@ public class LoanInstallmentCharge extends AbstractPersistable { return amountPaidOnThisCharge; } - public Money getAmountWrittenOff(final MonetaryCurrency currency) { return Money.of(currency, this.amountWrittenOff); } @@ -202,7 +191,6 @@ public class LoanInstallmentCharge extends AbstractPersistable { this.waived = false; } - public Money getAmountThroughChargePayment(final MonetaryCurrency currency) { return Money.of(currency, this.amountThroughChargePayment); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java index 10ff41c21..edee731db 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java @@ -30,14 +30,14 @@ public class LoanRepaymentScheduleProcessingWrapper { for (final LoanRepaymentScheduleInstallment period : repaymentPeriods) { final Money feeChargesDueForRepaymentPeriod = cumulativeFeeChargesDueWithin(startDate, period.getDueDate(), loanCharges, - currency,period,repaymentPeriods.size(), totalInterest); + currency, period, repaymentPeriods.size(), totalInterest); final Money feeChargesWaivedForRepaymentPeriod = cumulativeFeeChargesWaivedWithin(startDate, period.getDueDate(), loanCharges, currency); final Money feeChargesWrittenOffForRepaymentPeriod = cumulativeFeeChargesWrittenOffWithin(startDate, period.getDueDate(), loanCharges, currency); final Money penaltyChargesDueForRepaymentPeriod = cumulativePenaltyChargesDueWithin(startDate, period.getDueDate(), - loanCharges, currency,period,repaymentPeriods.size(), totalInterest); + loanCharges, currency, period, repaymentPeriods.size(), totalInterest); final Money penaltyChargesWaivedForRepaymentPeriod = cumulativePenaltyChargesWaivedWithin(startDate, period.getDueDate(), loanCharges, currency); final Money penaltyChargesWrittenOffForRepaymentPeriod = cumulativePenaltyChargesWrittenOffWithin(startDate, @@ -52,7 +52,8 @@ public class LoanRepaymentScheduleProcessingWrapper { } private Money cumulativeFeeChargesDueWithin(final LocalDate periodStart, final LocalDate periodEnd, final Set loanCharges, - final MonetaryCurrency monetaryCurrency,LoanRepaymentScheduleInstallment period,int numberOfRepayments,final Money totalInterest) { + final MonetaryCurrency monetaryCurrency, LoanRepaymentScheduleInstallment period, int numberOfRepayments, + final Money totalInterest) { Money cumulative = Money.zero(monetaryCurrency); @@ -74,8 +75,8 @@ public class LoanRepaymentScheduleProcessingWrapper { } else { cumulative = cumulative.plus(loanCharge.amount().divide(BigDecimal.valueOf(numberOfRepayments))); } - } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) && - loanCharge.getChargeCalculation().isPercentageBased()) { + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) + && loanCharge.getChargeCalculation().isPercentageBased()) { BigDecimal amount = BigDecimal.ZERO; if (loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest()) { amount = amount.add(period.getLoan().getPrincpal().getAmount()).add(totalInterest.getAmount()); @@ -101,13 +102,13 @@ public class LoanRepaymentScheduleProcessingWrapper { Money cumulative = Money.zero(currency); for (final LoanCharge loanCharge : loanCharges) { - if(loanCharge.isFeeCharge()){ - if(loanCharge.isInstalmentFee()){ + if (loanCharge.isFeeCharge()) { + if (loanCharge.isInstalmentFee()) { LoanInstallmentCharge loanChargePerInstallment = loanCharge.getInstallmentLoanCharge(periodEnd); - if(loanChargePerInstallment != null){ + if (loanChargePerInstallment != null) { cumulative = cumulative.plus(loanChargePerInstallment.getAmountWaived(currency)); } - }else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { cumulative = cumulative.plus(loanCharge.getAmountWaived(currency)); } } @@ -122,14 +123,14 @@ public class LoanRepaymentScheduleProcessingWrapper { Money cumulative = Money.zero(currency); for (final LoanCharge loanCharge : loanCharges) { - if(loanCharge.isFeeCharge()){ - if(loanCharge.isInstalmentFee()){ + if (loanCharge.isFeeCharge()) { + if (loanCharge.isInstalmentFee()) { LoanInstallmentCharge loanChargePerInstallment = loanCharge.getInstallmentLoanCharge(periodEnd); - if(loanChargePerInstallment != null){ + if (loanChargePerInstallment != null) { cumulative = cumulative.plus(loanChargePerInstallment.getAmountWrittenOff(currency)); } - }else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { - cumulative = cumulative.plus(loanCharge.getAmountWrittenOff(currency)); + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { + cumulative = cumulative.plus(loanCharge.getAmountWrittenOff(currency)); } } } @@ -138,7 +139,8 @@ public class LoanRepaymentScheduleProcessingWrapper { } private Money cumulativePenaltyChargesDueWithin(final LocalDate periodStart, final LocalDate periodEnd, - final Set loanCharges, final MonetaryCurrency currency,LoanRepaymentScheduleInstallment period,int numberOfRepayments, Money totalInterest) { + final Set loanCharges, final MonetaryCurrency currency, LoanRepaymentScheduleInstallment period, + int numberOfRepayments, Money totalInterest) { Money cumulative = Money.zero(currency); @@ -148,8 +150,8 @@ public class LoanRepaymentScheduleProcessingWrapper { if (loanCharge.getChargeCalculation().isPercentageBased()) { BigDecimal amount = BigDecimal.ZERO; if (loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest()) { - amount = amount.add(period.getPrincipal(currency).getAmount()) - .add(period.getInterestCharged(currency).getAmount()); + amount = amount.add(period.getPrincipal(currency).getAmount()).add( + period.getInterestCharged(currency).getAmount()); } else if (loanCharge.getChargeCalculation().isPercentageOfInterest()) { amount = amount.add(period.getInterestCharged(currency).getAmount()); } else { @@ -160,8 +162,8 @@ public class LoanRepaymentScheduleProcessingWrapper { } else { cumulative = cumulative.plus(loanCharge.amount().divide(BigDecimal.valueOf(numberOfRepayments))); } - } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) && - loanCharge.getChargeCalculation().isPercentageBased()) { + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) + && loanCharge.getChargeCalculation().isPercentageBased()) { BigDecimal amount = BigDecimal.ZERO; if (loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest()) { amount = amount.add(period.getLoan().getPrincpal().getAmount()).add(totalInterest.getAmount()); @@ -188,12 +190,12 @@ public class LoanRepaymentScheduleProcessingWrapper { for (final LoanCharge loanCharge : loanCharges) { if (loanCharge.isPenaltyCharge()) { - if(loanCharge.isInstalmentFee()){ + if (loanCharge.isInstalmentFee()) { LoanInstallmentCharge loanChargePerInstallment = loanCharge.getInstallmentLoanCharge(periodEnd); - if(loanChargePerInstallment != null){ + if (loanChargePerInstallment != null) { cumulative = cumulative.plus(loanChargePerInstallment.getAmountWaived(currency)); } - }else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { cumulative = cumulative.plus(loanCharge.getAmountWaived(currency)); } } @@ -209,13 +211,13 @@ public class LoanRepaymentScheduleProcessingWrapper { for (final LoanCharge loanCharge : loanCharges) { if (loanCharge.isPenaltyCharge()) { - if(loanCharge.isInstalmentFee()){ + if (loanCharge.isInstalmentFee()) { LoanInstallmentCharge loanChargePerInstallment = loanCharge.getInstallmentLoanCharge(periodEnd); - if(loanChargePerInstallment!= null){ + if (loanChargePerInstallment != null) { cumulative = cumulative.plus(loanChargePerInstallment.getAmountWrittenOff(currency)); } - }else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { - cumulative = cumulative.plus(loanCharge.getAmountWrittenOff(currency)); + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) { + cumulative = cumulative.plus(loanCharge.getAmountWrittenOff(currency)); } } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleTransactionProcessorFactory.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleTransactionProcessorFactory.java index ab565481f..f11d39e06 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleTransactionProcessorFactory.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanRepaymentScheduleTransactionProcessorFactory.java @@ -33,7 +33,7 @@ public class LoanRepaymentScheduleTransactionProcessorFactory { if (transactionProcessingStrategy.isHeavensfamilyStrategy()) { processor = new HeavensFamilyLoanRepaymentScheduleTransactionProcessor(); } - + if (transactionProcessingStrategy.isEarlyPaymentStrategy()) { processor = new EarlyPaymentLoanRepaymentScheduleTransactionProcessor(); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanSummary.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanSummary.java index 9c2c7fe43..ba6d3ad3c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanSummary.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanSummary.java @@ -275,12 +275,10 @@ public final class LoanSummary { this.totalOutstanding = totalOutstanding.getAmount(); } - public BigDecimal getTotalPrincipalDisbursed() { return this.totalPrincipalDisbursed; } - public BigDecimal getTotalPrincipalRepaid() { return this.totalPrincipalRepaid; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTermVariations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTermVariations.java index 3701ea1f5..d27479bd7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTermVariations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTermVariations.java @@ -21,54 +21,48 @@ import org.springframework.data.jpa.domain.AbstractPersistable; @Table(name = "m_loan_term_variations") public class LoanTermVariations extends AbstractPersistable { - @SuppressWarnings("unused") @ManyToOne(optional = false) @JoinColumn(name = "loan_id", nullable = false) private Loan loan; - + @Column(name = "term_type", nullable = false) private Integer termType; - + @Temporal(TemporalType.DATE) @Column(name = "applicable_from") private Date termApplicableFrom; - + @Column(name = "term_value", scale = 6, precision = 19) private BigDecimal termValue; - - public LoanTermVariations(final Integer termType,final Date termApplicableFrom,final BigDecimal termValue,final Loan loan){ - + public LoanTermVariations(final Integer termType, final Date termApplicableFrom, final BigDecimal termValue, final Loan loan) { + this.loan = loan; this.termApplicableFrom = termApplicableFrom; this.termType = termType; this.termValue = termValue; } - - protected LoanTermVariations(){ - + + protected LoanTermVariations() { + } - public LoanTermVariationType getTermType() { return LoanTermVariationType.fromInt(this.termType); } - + public LoanTermVariationsData toData() { LocalDate termStartDate = new LocalDate(this.termApplicableFrom); EnumOptionData type = LoanEnumerations.loanvariationType(this.termType); return new LoanTermVariationsData(getId(), type, termStartDate, this.termValue); } - public Date getTermApplicableFrom() { return this.termApplicableFrom; } - public BigDecimal getTermValue() { return this.termValue; } - } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java index 0d91e5232..02c91051a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java @@ -133,24 +133,24 @@ public final class LoanTransaction extends AbstractPersistable { } public static LoanTransaction initiateTransfer(final Office office, final Loan loan, final LocalDate transferDate) { - return new LoanTransaction(loan, office, LoanTransactionType.INITIATE_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay().toDate(), - loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() - .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() - .getTotalPenaltyChargesOutstanding(), null, false, null,null); + return new LoanTransaction(loan, office, LoanTransactionType.INITIATE_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay() + .toDate(), loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() + .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() + .getTotalPenaltyChargesOutstanding(), null, false, null, null); } public static LoanTransaction approveTransfer(final Office office, final Loan loan, final LocalDate transferDate) { - return new LoanTransaction(loan, office, LoanTransactionType.APPROVE_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay().toDate(), - loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() - .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() - .getTotalPenaltyChargesOutstanding(), null, false, null,null); + return new LoanTransaction(loan, office, LoanTransactionType.APPROVE_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay() + .toDate(), loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() + .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() + .getTotalPenaltyChargesOutstanding(), null, false, null, null); } public static LoanTransaction withdrawTransfer(final Office office, final Loan loan, final LocalDate transferDate) { - return new LoanTransaction(loan, office, LoanTransactionType.WITHDRAW_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay().toDate(), - loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() - .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() - .getTotalPenaltyChargesOutstanding(), null, false, null,null); + return new LoanTransaction(loan, office, LoanTransactionType.WITHDRAW_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay() + .toDate(), loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() + .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() + .getTotalPenaltyChargesOutstanding(), null, false, null, null); } public static LoanTransaction refund(final Office office, final Money amount, final PaymentDetail paymentDetail, @@ -162,7 +162,7 @@ public final class LoanTransaction extends AbstractPersistable { return new LoanTransaction(loanTransaction.loan, loanTransaction.office, loanTransaction.typeOf, loanTransaction.dateOf, loanTransaction.amount, loanTransaction.principalPortion, loanTransaction.interestPortion, loanTransaction.feeChargesPortion, loanTransaction.penaltyChargesPortion, loanTransaction.overPaymentPortion, - loanTransaction.reversed, loanTransaction.paymentDetail,loanTransaction.externalId); + loanTransaction.reversed, loanTransaction.paymentDetail, loanTransaction.externalId); } public static LoanTransaction applyLoanCharge(final Loan loan, final Office office, final Money amount, final LocalDate applyDate, @@ -187,7 +187,7 @@ public final class LoanTransaction extends AbstractPersistable { private LoanTransaction(final Loan loan, final Office office, final Integer typeOf, final Date dateOf, final BigDecimal amount, final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overPaymentPortion, final boolean reversed, - final PaymentDetail paymentDetail,final String externalId) { + final PaymentDetail paymentDetail, final String externalId) { super(); this.loan = loan; this.typeOf = typeOf; @@ -256,7 +256,7 @@ public final class LoanTransaction extends AbstractPersistable { /** * This updates the derived fields of a loan transaction for the principal, * interest and interest waived portions. - * + * * This accumulates the values passed to the already existent values for * each of the portions. */ @@ -503,7 +503,6 @@ public final class LoanTransaction extends AbstractPersistable { return LoanTransactionType.REFUND.equals(getTypeOf()) && isNotReversed(); } - public void updateExternalId(final String externalId) { this.externalId = externalId; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/transactionprocessor/impl/EarlyPaymentLoanRepaymentScheduleTransactionProcessor.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/transactionprocessor/impl/EarlyPaymentLoanRepaymentScheduleTransactionProcessor.java index bc953a5d9..12ead008f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/transactionprocessor/impl/EarlyPaymentLoanRepaymentScheduleTransactionProcessor.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/transactionprocessor/impl/EarlyPaymentLoanRepaymentScheduleTransactionProcessor.java @@ -19,18 +19,17 @@ import org.mifosplatform.portfolio.loanaccount.domain.transactionprocessor.LoanR * This {@link LoanRepaymentScheduleTransactionProcessor} defaults to having the * payment order of Interest first, then principal, penalties and fees. */ -public class EarlyPaymentLoanRepaymentScheduleTransactionProcessor extends - AbstractLoanRepaymentScheduleTransactionProcessor { +public class EarlyPaymentLoanRepaymentScheduleTransactionProcessor extends AbstractLoanRepaymentScheduleTransactionProcessor { /** * For early/'in advance' repayments, pay off in the same way as on-time * payments, interest first, principal, penalties and charges. */ + @SuppressWarnings("unused") @Override protected Money handleTransactionThatIsPaymentInAdvanceOfInstallment(final LoanRepaymentScheduleInstallment currentInstallment, final List installments, final LoanTransaction loanTransaction, final LocalDate transactionDate, final Money paymentInAdvance) { - final MonetaryCurrency currency = paymentInAdvance.getCurrency(); Money transactionAmountRemaining = paymentInAdvance; @@ -61,19 +60,19 @@ public class EarlyPaymentLoanRepaymentScheduleTransactionProcessor extends // Only allocate to principal: principalPortion = currentInstallment.payPrincipalComponent(transactionDate, transactionAmountRemaining); transactionAmountRemaining = transactionAmountRemaining.minus(principalPortion); - + loanTransaction.updateComponents(principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion); } return transactionAmountRemaining; - } /** * For late repayments, pay off in the same way as on-time payments, * interest first then principal. */ + @SuppressWarnings("unused") @Override protected Money handleTransactionThatIsALateRepaymentOfInstallment(final LoanRepaymentScheduleInstallment currentInstallment, final List installments, final LoanTransaction loanTransaction, @@ -132,7 +131,5 @@ public class EarlyPaymentLoanRepaymentScheduleTransactionProcessor extends return transactionAmountRemaining; } - - - + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanDisbursalException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanDisbursalException.java index d476dc52c..725d36ca4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanDisbursalException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/LoanDisbursalException.java @@ -9,7 +9,7 @@ public class LoanDisbursalException extends AbstractPlatformDomainRuleException + "` are not allowed to co-exist", new Object[] { cureentProduct, restrictedProduct }); } - public LoanDisbursalException(final String defaultUserMessage,final String entity,final Object... defaultUserMessageArgs) { - super("error.msg.loan." + entity , defaultUserMessage, defaultUserMessageArgs); + public LoanDisbursalException(final String defaultUserMessage, final String entity, final Object... defaultUserMessageArgs) { + super("error.msg.loan." + entity, defaultUserMessage, defaultUserMessageArgs); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/MultiDisbursementDataRequiredException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/MultiDisbursementDataRequiredException.java index 5d37381c0..dcda44bbc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/MultiDisbursementDataRequiredException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/exception/MultiDisbursementDataRequiredException.java @@ -4,7 +4,8 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul public class MultiDisbursementDataRequiredException extends AbstractPlatformDomainRuleException { - public MultiDisbursementDataRequiredException(final String entity, final String defaultUserMessage, final Object... defaultUserMessageArgs) { + public MultiDisbursementDataRequiredException(final String entity, final String defaultUserMessage, + final Object... defaultUserMessageArgs) { super("error.msg." + entity + ".required", defaultUserMessage, defaultUserMessageArgs); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java index 2e2c15022..676d393dd 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java @@ -76,36 +76,36 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener final LocalDate idealDisbursementDate = this.scheduledDateGenerator.idealDisbursementDateBasedOnFirstRepaymentDate( loanApplicationTerms.getLoanTermPeriodFrequencyType(), loanApplicationTerms.getRepaymentEvery(), firstRepaymentdate); - - LocalDate periodStartDateApplicableForInterest = periodStartDate; - + LocalDate periodStartDateApplicableForInterest = periodStartDate; + int periodNumber = 1; Money totalCumulativePrincipal = principalDisbursed.zero(); Money totalCumulativeInterest = principalDisbursed.zero(); Money totalOutstandingInterestPaymentDueToGrace = principalDisbursed.zero(); Money outstandingBalance = principalDisbursed; - if(loanApplicationTerms.isMultiDisburseLoan()){ - BigDecimal disburseAmt = getDisbursementAmount(loanApplicationTerms, periodStartDate, periods,chargesDueAtTimeOfDisbursement); + if (loanApplicationTerms.isMultiDisburseLoan()) { + BigDecimal disburseAmt = getDisbursementAmount(loanApplicationTerms, periodStartDate, periods, chargesDueAtTimeOfDisbursement); principalDisbursed = principalDisbursed.zero().plus(disburseAmt); loanApplicationTerms.setPrincipal(loanApplicationTerms.getPrincipal().zero().plus(disburseAmt)); outstandingBalance = outstandingBalance.zero().plus(disburseAmt); } - while(!outstandingBalance.isZero()) { + while (!outstandingBalance.isZero()) { actualRepaymentDate = this.scheduledDateGenerator.generateNextRepaymentDate(actualRepaymentDate, loanApplicationTerms); - LocalDate scheduledDueDate = this.scheduledDateGenerator.adjustRepaymentDate(actualRepaymentDate, loanApplicationTerms, + LocalDate scheduledDueDate = this.scheduledDateGenerator.adjustRepaymentDate(actualRepaymentDate, loanApplicationTerms, isHolidayEnabled, holidays, workingDays); final int daysInPeriod = Days.daysBetween(periodStartDate, scheduledDueDate).getDays(); - if(loanApplicationTerms.isMultiDisburseLoan()){ + if (loanApplicationTerms.isMultiDisburseLoan()) { loanApplicationTerms.setFixedEmiAmountForPeriod(scheduledDueDate); - BigDecimal disburseAmt = disbursementForPeriod(loanApplicationTerms, periodStartDate, scheduledDueDate, periods,BigDecimal.ZERO); + BigDecimal disburseAmt = disbursementForPeriod(loanApplicationTerms, periodStartDate, scheduledDueDate, periods, + BigDecimal.ZERO); principalDisbursed = principalDisbursed.plus(disburseAmt); loanApplicationTerms.setPrincipal(loanApplicationTerms.getPrincipal().plus(disburseAmt)); outstandingBalance = outstandingBalance.plus(disburseAmt); - if(loanApplicationTerms.getMaxOutstandingBalance() != null && - outstandingBalance.isGreaterThan(loanApplicationTerms.getMaxOutstandingBalance())){ - String errorMsg = "Outstanding balance must not exceed the amount: "+loanApplicationTerms.getMaxOutstandingBalance(); - throw new MultiDisbursementOutstandingAmoutException(errorMsg, - loanApplicationTerms.getMaxOutstandingBalance().getAmount(),disburseAmt); + if (loanApplicationTerms.getMaxOutstandingBalance() != null + && outstandingBalance.isGreaterThan(loanApplicationTerms.getMaxOutstandingBalance())) { + String errorMsg = "Outstanding balance must not exceed the amount: " + loanApplicationTerms.getMaxOutstandingBalance(); + throw new MultiDisbursementOutstandingAmoutException(errorMsg, loanApplicationTerms.getMaxOutstandingBalance() + .getAmount(), disburseAmt); } } int daysInPeriodApplicableForInterest = daysInPeriod; @@ -130,11 +130,11 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener totalCumulativeInterest, totalInterestChargedForFullLoanTerm, totalOutstandingInterestPaymentDueToGrace, daysInPeriodApplicableForInterest, outstandingBalance, loanApplicationTerms, periodNumber, mc); - if(loanApplicationTerms.getFixedEmiAmount() !=null - && loanApplicationTerms.getFixedEmiAmount().compareTo(principalInterestForThisPeriod.interest().getAmount()) != 1){ - String errorMsg = "EMI amount must be greter than : "+principalInterestForThisPeriod.interest().getAmount(); - throw new MultiDisbursementEmiAmountException(errorMsg, principalInterestForThisPeriod.interest().getAmount(), - loanApplicationTerms.getFixedEmiAmount()); + if (loanApplicationTerms.getFixedEmiAmount() != null + && loanApplicationTerms.getFixedEmiAmount().compareTo(principalInterestForThisPeriod.interest().getAmount()) != 1) { + String errorMsg = "EMI amount must be greter than : " + principalInterestForThisPeriod.interest().getAmount(); + throw new MultiDisbursementEmiAmountException(errorMsg, principalInterestForThisPeriod.interest().getAmount(), + loanApplicationTerms.getFixedEmiAmount()); } // update cumulative fields for principal & interest totalCumulativePrincipal = totalCumulativePrincipal.plus(principalInterestForThisPeriod.principal()); @@ -146,12 +146,12 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener Money feeChargesForInstallment = principalDisbursed.zero(); Money penaltyChargesForInstallment = principalDisbursed.zero(); - if(!(loanApplicationTerms.isMultiDisburseLoan() && loanApplicationTerms.getFixedEmiAmount()!=null)){ - // 7. determine fees and penalties + if (!(loanApplicationTerms.isMultiDisburseLoan() && loanApplicationTerms.getFixedEmiAmount() != null)) { + // 7. determine fees and penalties feeChargesForInstallment = cumulativeFeeChargesDueWithin(periodStartDate, scheduledDueDate, loanCharges, currency, principalInterestForThisPeriod, principalDisbursed, totalInterestChargedForFullLoanTerm, numberOfRepayments); - penaltyChargesForInstallment = cumulativePenaltyChargesDueWithin(periodStartDate, scheduledDueDate, loanCharges, - currency, principalInterestForThisPeriod, principalDisbursed, totalInterestChargedForFullLoanTerm, numberOfRepayments); + penaltyChargesForInstallment = cumulativePenaltyChargesDueWithin(periodStartDate, scheduledDueDate, loanCharges, currency, + principalInterestForThisPeriod, principalDisbursed, totalInterestChargedForFullLoanTerm, numberOfRepayments); } // 8. sum up real totalInstallmentDue from components final Money totalInstallmentDue = principalInterestForThisPeriod.principal() // @@ -177,25 +177,24 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener periodNumber++; } - - if(principalDisbursed.isNotEqualTo(expectedPrincipalDisburse)){ + + if (principalDisbursed.isNotEqualTo(expectedPrincipalDisburse)) { final String errorMsg = "One of the Disbursement date is not falling on Loan Schedule"; throw new MultiDisbursementDisbursementDateException(errorMsg); } - - if(loanApplicationTerms.isMultiDisburseLoan() && loanApplicationTerms.getFixedEmiAmount()!=null - && !loanCharges.isEmpty()){ + + if (loanApplicationTerms.isMultiDisburseLoan() && loanApplicationTerms.getFixedEmiAmount() != null && !loanCharges.isEmpty()) { // 7. determine fees and penalties - for(LoanScheduleModelPeriod loanScheduleModelPeriod:periods){ - if(loanScheduleModelPeriod.isRepaymentPeriod()){ - PrincipalInterest principalInterest = new PrincipalInterest(Money.of(currency, loanScheduleModelPeriod.principalDue()), + for (LoanScheduleModelPeriod loanScheduleModelPeriod : periods) { + if (loanScheduleModelPeriod.isRepaymentPeriod()) { + PrincipalInterest principalInterest = new PrincipalInterest(Money.of(currency, loanScheduleModelPeriod.principalDue()), Money.of(currency, loanScheduleModelPeriod.interestDue()), null); - Money feeChargesForInstallment = cumulativeFeeChargesDueWithin(loanScheduleModelPeriod.periodFromDate(), - loanScheduleModelPeriod.periodDueDate(), loanCharges, currency,principalInterest, principalDisbursed, + Money feeChargesForInstallment = cumulativeFeeChargesDueWithin(loanScheduleModelPeriod.periodFromDate(), + loanScheduleModelPeriod.periodDueDate(), loanCharges, currency, principalInterest, principalDisbursed, + totalCumulativeInterest, numberOfRepayments); + Money penaltyChargesForInstallment = cumulativePenaltyChargesDueWithin(loanScheduleModelPeriod.periodFromDate(), + loanScheduleModelPeriod.periodDueDate(), loanCharges, currency, principalInterest, principalDisbursed, totalCumulativeInterest, numberOfRepayments); - Money penaltyChargesForInstallment = cumulativePenaltyChargesDueWithin(loanScheduleModelPeriod.periodFromDate(), - loanScheduleModelPeriod.periodDueDate(), loanCharges, currency, principalInterest, principalDisbursed, totalCumulativeInterest, - numberOfRepayments); totalFeeChargesCharged = totalFeeChargesCharged.add(feeChargesForInstallment.getAmount()); totalPenaltyChargesCharged = totalPenaltyChargesCharged.add(penaltyChargesForInstallment.getAmount()); loanScheduleModelPeriod.addLoanCharges(feeChargesForInstallment.getAmount(), penaltyChargesForInstallment.getAmount()); @@ -226,30 +225,30 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener } return chargesDueAtTimeOfDisbursement; } - - private BigDecimal disbursementForPeriod(final LoanApplicationTerms loanApplicationTerms,LocalDate startDate,LocalDate endDate, - final Collection periods,final BigDecimal chargesDueAtTimeOfDisbursement){ + + private BigDecimal disbursementForPeriod(final LoanApplicationTerms loanApplicationTerms, LocalDate startDate, LocalDate endDate, + final Collection periods, final BigDecimal chargesDueAtTimeOfDisbursement) { BigDecimal principal = BigDecimal.ZERO; MonetaryCurrency currency = loanApplicationTerms.getPrincipal().getCurrency(); - for(DisbursementData disbursementData:loanApplicationTerms.getDisbursementDatas()){ - if(disbursementData.isDueForDisbursement(startDate, endDate)){ + for (DisbursementData disbursementData : loanApplicationTerms.getDisbursementDatas()) { + if (disbursementData.isDueForDisbursement(startDate, endDate)) { final LoanScheduleModelDisbursementPeriod disbursementPeriod = LoanScheduleModelDisbursementPeriod.disbursement( - disbursementData.disbursementDate(),Money.of(currency,disbursementData.amount()),chargesDueAtTimeOfDisbursement); + disbursementData.disbursementDate(), Money.of(currency, disbursementData.amount()), chargesDueAtTimeOfDisbursement); periods.add(disbursementPeriod); principal = principal.add(disbursementData.amount()); } } return principal; } - - private BigDecimal getDisbursementAmount(final LoanApplicationTerms loanApplicationTerms,LocalDate disbursementDate, - final Collection periods,final BigDecimal chargesDueAtTimeOfDisbursement){ + + private BigDecimal getDisbursementAmount(final LoanApplicationTerms loanApplicationTerms, LocalDate disbursementDate, + final Collection periods, final BigDecimal chargesDueAtTimeOfDisbursement) { BigDecimal principal = BigDecimal.ZERO; MonetaryCurrency currency = loanApplicationTerms.getPrincipal().getCurrency(); - for(DisbursementData disbursementData:loanApplicationTerms.getDisbursementDatas()){ - if(disbursementData.disbursementDate().equals(disbursementDate)){ + for (DisbursementData disbursementData : loanApplicationTerms.getDisbursementDatas()) { + if (disbursementData.disbursementDate().equals(disbursementDate)) { final LoanScheduleModelDisbursementPeriod disbursementPeriod = LoanScheduleModelDisbursementPeriod.disbursement( - disbursementData.disbursementDate(),Money.of(currency,disbursementData.amount()),chargesDueAtTimeOfDisbursement); + disbursementData.disbursementDate(), Money.of(currency, disbursementData.amount()), chargesDueAtTimeOfDisbursement); periods.add(disbursementPeriod); principal = principal.add(disbursementData.amount()); } @@ -260,10 +259,10 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener private Collection createNewLoanScheduleListWithDisbursementDetails(final int numberOfRepayments, final LoanApplicationTerms loanApplicationTerms, final BigDecimal chargesDueAtTimeOfDisbursement) { - Collection periods = null ; - if(loanApplicationTerms.isMultiDisburseLoan()){ + Collection periods = null; + if (loanApplicationTerms.isMultiDisburseLoan()) { periods = new ArrayList(numberOfRepayments + loanApplicationTerms.getDisbursementDatas().size()); - }else{ + } else { periods = new ArrayList(numberOfRepayments + 1); final LoanScheduleModelDisbursementPeriod disbursementPeriod = LoanScheduleModelDisbursementPeriod.disbursement( loanApplicationTerms, chargesDueAtTimeOfDisbursement); @@ -297,7 +296,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener } else { cumulative = cumulative.plus(loanCharge.amount().divide(BigDecimal.valueOf(numberOfRepayments))); } - } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) && loanCharge.getChargeCalculation().isPercentageBased()) { BigDecimal amount = BigDecimal.ZERO; if (loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest()) { @@ -343,7 +342,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener } else { cumulative = cumulative.plus(loanCharge.amount().divide(BigDecimal.valueOf(numberOfRepayments))); } - } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) + } else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) && loanCharge.getChargeCalculation().isPercentageBased()) { BigDecimal amount = BigDecimal.ZERO; if (loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest()) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java index 0ce3e671e..261ced038 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java @@ -19,14 +19,14 @@ import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; *
  • Equal installment payments
  • * *

    - * + * *

    * When amortized using equal principal payments, the principal * component of each installment is fixed and interest due is * calculated from the outstanding principal balance resulting in a * different total payment due for each installment. *

    - * + * *

    * When amortized using equal installments, the total payment due * for each installment is fixed and is calculated using the excel like diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java index aa233e515..3cfd16c84 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGenerator.java @@ -26,38 +26,35 @@ public class DefaultScheduledDateGenerator implements ScheduledDateGenerator { for (int repaymentPeriod = 1; repaymentPeriod <= numberOfRepayments; repaymentPeriod++) { lastRepaymentDate = generateNextRepaymentDate(lastRepaymentDate, loanApplicationTerms); - } + } lastRepaymentDate = adjustRepaymentDate(lastRepaymentDate, loanApplicationTerms, isHolidayEnabled, holidays, workingDays); return lastRepaymentDate; } - @Override - public LocalDate generateNextRepaymentDate(final LocalDate lastRepaymentDate,final LoanApplicationTerms loanApplicationTerms){ + public LocalDate generateNextRepaymentDate(final LocalDate lastRepaymentDate, final LoanApplicationTerms loanApplicationTerms) { final LocalDate firstRepaymentPeriodDate = loanApplicationTerms.getCalculatedRepaymentsStartingFromLocalDate(); LocalDate dueRepaymentPeriodDate = null; - if(firstRepaymentPeriodDate !=null && firstRepaymentPeriodDate.isAfter(lastRepaymentDate)){ + if (firstRepaymentPeriodDate != null && firstRepaymentPeriodDate.isAfter(lastRepaymentDate)) { dueRepaymentPeriodDate = firstRepaymentPeriodDate; - }else{ + } else { dueRepaymentPeriodDate = getRepaymentPeriodDate(loanApplicationTerms, lastRepaymentDate); } return dueRepaymentPeriodDate; } - + @Override - public LocalDate adjustRepaymentDate(final LocalDate dueRepaymentPeriodDate,final LoanApplicationTerms loanApplicationTerms,final boolean isHolidayEnabled, - final List holidays, final WorkingDays workingDays){ + public LocalDate adjustRepaymentDate(final LocalDate dueRepaymentPeriodDate, final LoanApplicationTerms loanApplicationTerms, + final boolean isHolidayEnabled, final List holidays, final WorkingDays workingDays) { LocalDate adjustedDate = dueRepaymentPeriodDate; final LocalDate nextDueRepaymentPeriodDate = getRepaymentPeriodDate(loanApplicationTerms, adjustedDate); - adjustedDate = WorkingDaysUtil.getOffSetDateIfNonWorkingDay(adjustedDate, nextDueRepaymentPeriodDate, - workingDays); + adjustedDate = WorkingDaysUtil.getOffSetDateIfNonWorkingDay(adjustedDate, nextDueRepaymentPeriodDate, workingDays); if (isHolidayEnabled) { adjustedDate = HolidayUtil.getRepaymentRescheduleDateToIfHoliday(adjustedDate, holidays); } return adjustedDate; } - - + private LocalDate getRepaymentPeriodDate(final LoanApplicationTerms loanApplicationTerms, final LocalDate startDate) { final int repaidEvery = loanApplicationTerms.getRepaymentEvery(); LocalDate dueRepaymentPeriodDate = startDate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/FinanicalFunctions.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/FinanicalFunctions.java index 9c78be4a4..b65eec29a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/FinanicalFunctions.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/FinanicalFunctions.java @@ -38,16 +38,17 @@ public class FinanicalFunctions { } return payment; } - - public static int nop(final double interestRateFraction, final double emiAmount, final double principal, - final double futureValue, final boolean type){ + + public static int nop(final double interestRateFraction, final double emiAmount, final double principal, final double futureValue, + final boolean type) { double numberOfPayments = 0; if (interestRateFraction == 0) { - numberOfPayments = ((Double)(-1 * (futureValue + principal) / emiAmount)).intValue(); - }else{ + numberOfPayments = ((Double) (-1 * (futureValue + principal) / emiAmount)).intValue(); + } else { final double r1 = interestRateFraction + 1; numberOfPayments = (futureValue + principal * Math.pow(r1, emiAmount)) * interestRateFraction - / ((type ? r1 : 1) * (1 - Math.pow(r1, emiAmount))); } + / ((type ? r1 : 1) * (1 - Math.pow(r1, emiAmount))); + } return Double.valueOf(numberOfPayments).intValue(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java index 49e2063ef..799a2cfa4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java @@ -55,7 +55,7 @@ public final class LoanApplicationTerms { * Integer representing the number of 'repayment frequencies' or * installments where 'grace' should apply to the payment of interest in a * loans repayment period (installment). - * + * * Note: Interest is still calculated taking into account the full * loan term, the interest is simply offset to a later period. */ @@ -65,7 +65,7 @@ public final class LoanApplicationTerms { * Integer representing the number of 'repayment frequencies' or * installments where 'grace' should apply to the charging of interest in a * loans repayment period (installment). - * + * * Note: The loan is interest-free for the period of time * indicated. */ @@ -73,7 +73,7 @@ public final class LoanApplicationTerms { /** * Legacy method of support 'grace' on the charging of interest on a loan. - * + * *

    * For the typical structured loan, its reasonable to use an integer to * indicate the number of 'repayment frequency' periods the 'grace' should @@ -89,15 +89,15 @@ public final class LoanApplicationTerms { // added private LocalDate loanEndDate; - + private List disbursementDatas; - + private boolean multiDisburseLoan; - + private BigDecimal fixedEmiAmount; - + private BigDecimal maxOutstandingBalance; - + private List emiAmountVariations; public static LoanApplicationTerms assembleFrom(final ApplicationCurrency currency, final Integer loanTermFrequency, @@ -109,7 +109,7 @@ public final class LoanApplicationTerms { final LocalDate expectedDisbursementDate, final LocalDate repaymentsStartingFromDate, final LocalDate calculatedRepaymentsStartingFromDate, final Integer graceOnPrincipalPayment, final Integer graceOnInterestPayment, final Integer graceOnInterestCharged, final LocalDate interestChargedFromDate, - final Money inArrearsTolerance,final boolean multiDisburseLoan,final BigDecimal emiAmount, + final Money inArrearsTolerance, final boolean multiDisburseLoan, final BigDecimal emiAmount, final List disbursementDatas, final BigDecimal maxOutstandingBalance, final List emiAmountVariations) { @@ -118,15 +118,15 @@ public final class LoanApplicationTerms { annualNominalInterestRate, interestCalculationPeriodMethod, principalMoney, expectedDisbursementDate, repaymentsStartingFromDate, calculatedRepaymentsStartingFromDate, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, inArrearsTolerance, multiDisburseLoan, emiAmount, disbursementDatas, - maxOutstandingBalance,emiAmountVariations); + maxOutstandingBalance, emiAmountVariations); } public static LoanApplicationTerms assembleFrom(final ApplicationCurrency applicationCurrency, final Integer loanTermFrequency, final PeriodFrequencyType loanTermPeriodFrequencyType, final LocalDate expectedDisbursementDate, final LocalDate repaymentsStartingFromDate, final LocalDate calculatedRepaymentsStartingFromDate, - final Money inArrearsTolerance, final LoanProductRelatedDetail loanProductRelatedDetail, - final boolean multiDisburseLoan,final BigDecimal emiAmount,final List disbursementDatas, - final BigDecimal maxOutstandingBalance,final List emiAmountVariations) { + final Money inArrearsTolerance, final LoanProductRelatedDetail loanProductRelatedDetail, final boolean multiDisburseLoan, + final BigDecimal emiAmount, final List disbursementDatas, final BigDecimal maxOutstandingBalance, + final List emiAmountVariations) { final Integer numberOfRepayments = loanProductRelatedDetail.getNumberOfRepayments(); final Integer repaymentEvery = loanProductRelatedDetail.getRepayEvery(); @@ -150,8 +150,8 @@ public final class LoanApplicationTerms { repaymentEvery, repaymentPeriodFrequencyType, amortizationMethod, interestMethod, interestRatePerPeriod, interestRatePeriodFrequencyType, annualNominalInterestRate, interestCalculationPeriodMethod, principalMoney, expectedDisbursementDate, repaymentsStartingFromDate, calculatedRepaymentsStartingFromDate, graceOnPrincipalPayment, - graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, inArrearsTolerance, multiDisburseLoan, - emiAmount, disbursementDatas, maxOutstandingBalance,emiAmountVariations); + graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, inArrearsTolerance, multiDisburseLoan, emiAmount, + disbursementDatas, maxOutstandingBalance, emiAmountVariations); } private LoanApplicationTerms(final ApplicationCurrency currency, final Integer loanTermFrequency, @@ -162,9 +162,9 @@ public final class LoanApplicationTerms { final InterestCalculationPeriodMethod interestCalculationPeriodMethod, final Money principal, final LocalDate expectedDisbursementDate, final LocalDate repaymentsStartingFromDate, final LocalDate calculatedRepaymentsStartingFromDate, final Integer principalGrace, final Integer interestPaymentGrace, - final Integer interestChargingGrace, final LocalDate interestChargedFromDate, final Money inArrearsTolerance, - final boolean multiDisburseLoan,final BigDecimal emiAmount,final List disbursementDatas, - final BigDecimal maxOutstandingBalance,final List emiAmountVariations) { + final Integer interestChargingGrace, final LocalDate interestChargedFromDate, final Money inArrearsTolerance, + final boolean multiDisburseLoan, final BigDecimal emiAmount, final List disbursementDatas, + final BigDecimal maxOutstandingBalance, final List emiAmountVariations) { this.currency = currency; this.loanTermFrequency = loanTermFrequency; this.loanTermPeriodFrequencyType = loanTermPeriodFrequencyType; @@ -207,10 +207,10 @@ public final class LoanApplicationTerms { // paid too much principal, subtract amount that overpays from // principal paid for period. adjusted = principalForPeriod.minus(totalPrincipalRemaining.abs()); - } else if(multiDisburseLoan){ + } else if (multiDisburseLoan) { final Money difference = this.principal.minus(totalCumulativePrincipalToDate); final Money halfPrincipalVal = principalForPeriod.dividedBy(2, RoundingMode.HALF_DOWN); - if(difference.isLessThan(halfPrincipalVal)){ + if (difference.isLessThan(halfPrincipalVal)) { adjusted = principalForPeriod.plus(difference.abs()); } } else if (isLastRepaymentPeriod(this.numberOfRepayments, periodNumber)) { @@ -253,7 +253,7 @@ public final class LoanApplicationTerms { /** * Calculates the total interest to be charged on loan taking into account * grace settings. - * + * */ public Money calculateTotalInterestCharged(final PaymentPeriodsInOneYearCalculator calculator, final MathContext mc) { @@ -303,7 +303,7 @@ public final class LoanApplicationTerms { final int periodsElapsed = periodNumber - 1; final BigDecimal periodicInterestRateForRepaymentPeriod = periodicInterestRate(calculator, mc); Money totalPmtForThisInstallment = calculateTotalDueForEqualInstallmentRepaymentPeriod( - periodicInterestRateForRepaymentPeriod, outstandingBalance, periodsElapsed); + periodicInterestRateForRepaymentPeriod, outstandingBalance, periodsElapsed); principalForInstallment = calculatePrincipalDueForInstallment(calculator, mc, periodNumber, totalPmtForThisInstallment, daysInPeriod, outstandingBalance); break; @@ -534,27 +534,28 @@ public final class LoanApplicationTerms { case DAILY: // For daily work out number of days in the period int numberOfDaysInPeriod = this.repaymentEvery; - final BigDecimal oneDayOfYearInterestRate = this.annualNominalInterestRate.divide(loanTermPeriodsInYearBigDecimal, mc).divide(divisor, mc); + final BigDecimal oneDayOfYearInterestRate = this.annualNominalInterestRate.divide(loanTermPeriodsInYearBigDecimal, mc) + .divide(divisor, mc); switch (this.repaymentPeriodFrequencyType) { case INVALID: - break; + break; case DAYS: final BigDecimal loanTermFrequencyBigDecimal = BigDecimal.valueOf(numberOfDaysInPeriod); periodicInterestRate = oneDayOfYearInterestRate.multiply(loanTermFrequencyBigDecimal, mc); - break; + break; case WEEKS: numberOfDaysInPeriod = this.repaymentEvery * 7; periodicInterestRate = oneDayOfYearInterestRate.multiply(BigDecimal.valueOf(numberOfDaysInPeriod), mc); - break; + break; case MONTHS: numberOfDaysInPeriod = this.repaymentEvery * 30; periodicInterestRate = oneDayOfYearInterestRate.multiply(BigDecimal.valueOf(numberOfDaysInPeriod), mc); - break; + break; case YEARS: numberOfDaysInPeriod = this.repaymentEvery * 365; periodicInterestRate = oneDayOfYearInterestRate.multiply(BigDecimal.valueOf(numberOfDaysInPeriod), mc); - break; + break; } break; case SAME_AS_REPAYMENT_PERIOD: @@ -636,10 +637,8 @@ public final class LoanApplicationTerms { } private double paymentPerPeriod(final BigDecimal periodicInterestRate, final Money balance, final int periodsElapsed) { - - if(multiDisburseLoan && fixedEmiAmount != null){ - return fixedEmiAmount.doubleValue(); - } + + if (multiDisburseLoan && fixedEmiAmount != null) { return fixedEmiAmount.doubleValue(); } final double futureValue = 0; final double principalDouble = balance.getAmount().multiply(BigDecimal.valueOf(-1)).doubleValue(); @@ -786,10 +785,10 @@ public final class LoanApplicationTerms { return dateValue; } - public void setPrincipal(Money principal){ + public void setPrincipal(Money principal) { this.principal = principal; } - + public LocalDate getInterestChargedFromLocalDate() { return this.interestChargedFromDate; } @@ -826,33 +825,29 @@ public final class LoanApplicationTerms { return this.principal; } - public List getDisbursementDatas() { return this.disbursementDatas; } - public boolean isMultiDisburseLoan() { return this.multiDisburseLoan; } - public Money getMaxOutstandingBalance() { return Money.of(getCurrency(), this.maxOutstandingBalance); } - public BigDecimal getFixedEmiAmount() { return this.fixedEmiAmount; } - - public void setFixedEmiAmountForPeriod(LocalDate periodDate){ + + public void setFixedEmiAmountForPeriod(LocalDate periodDate) { LocalDate startDate = expectedDisbursementDate; - for(LoanTermVariationsData loanVariationTermsData: this.emiAmountVariations){ - if(!periodDate.isBefore(loanVariationTermsData.getTermApplicableFrom()) - && !startDate.isAfter(loanVariationTermsData.getTermApplicableFrom())){ - this.fixedEmiAmount = loanVariationTermsData.getTermValue(); - startDate = loanVariationTermsData.getTermApplicableFrom(); + for (LoanTermVariationsData loanVariationTermsData : this.emiAmountVariations) { + if (!periodDate.isBefore(loanVariationTermsData.getTermApplicableFrom()) + && !startDate.isAfter(loanVariationTermsData.getTermApplicableFrom())) { + this.fixedEmiAmount = loanVariationTermsData.getTermValue(); + startDate = loanVariationTermsData.getTermApplicableFrom(); } } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelDisbursementPeriod.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelDisbursementPeriod.java index dbcab18b3..de2545579 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelDisbursementPeriod.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelDisbursementPeriod.java @@ -30,21 +30,19 @@ public final class LoanScheduleModelDisbursementPeriod implements LoanScheduleMo return new LoanScheduleModelDisbursementPeriod(periodNumber, loanApplicationTerms.getExpectedDisbursementDate(), loanApplicationTerms.getPrincipal(), chargesDueAtTimeOfDisbursement); } - - public static LoanScheduleModelDisbursementPeriod disbursement(final LocalDate disbursementDate,final Money principalDisbursed, - final BigDecimal chargesDueAtTimeOfDisbursement){ - return new LoanScheduleModelDisbursementPeriod(null, disbursementDate,principalDisbursed, chargesDueAtTimeOfDisbursement); + + public static LoanScheduleModelDisbursementPeriod disbursement(final LocalDate disbursementDate, final Money principalDisbursed, + final BigDecimal chargesDueAtTimeOfDisbursement) { + return new LoanScheduleModelDisbursementPeriod(null, disbursementDate, principalDisbursed, chargesDueAtTimeOfDisbursement); } - private LoanScheduleModelDisbursementPeriod(final Integer periodNumber,final LocalDate disbursementDate,final Money principalDisbursed, - final BigDecimal chargesDueAtTimeOfDisbursement) { + private LoanScheduleModelDisbursementPeriod(final Integer periodNumber, final LocalDate disbursementDate, + final Money principalDisbursed, final BigDecimal chargesDueAtTimeOfDisbursement) { this.periodNumber = periodNumber; this.disbursementDate = disbursementDate; this.principalDisbursed = principalDisbursed; this.chargesDueAtTimeOfDisbursement = chargesDueAtTimeOfDisbursement; } - - @Override public LoanSchedulePeriodData toData() { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelPeriod.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelPeriod.java index 45d42cd57..38c64b2a2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelPeriod.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelPeriod.java @@ -29,6 +29,6 @@ public interface LoanScheduleModelPeriod { BigDecimal feeChargesDue(); BigDecimal penaltyChargesDue(); - - void addLoanCharges(BigDecimal feeCharge,BigDecimal penaltyCharge); + + void addLoanCharges(BigDecimal feeCharge, BigDecimal penaltyCharge); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelRepaymentPeriod.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelRepaymentPeriod.java index 9c8b1966c..096516a6e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelRepaymentPeriod.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModelRepaymentPeriod.java @@ -34,7 +34,7 @@ public final class LoanScheduleModelRepaymentPeriod implements LoanScheduleModel return new LoanScheduleModelRepaymentPeriod(periodNumber, startDate, scheduledDueDate, principalDue, outstandingLoanBalance, interestDue, feeChargesDue, penaltyChargesDue, totalDue); } - + public LoanScheduleModelRepaymentPeriod(final int periodNumber, final LocalDate fromDate, final LocalDate dueDate, final Money principalDue, final Money outstandingLoanBalance, final Money interestDue, final Money feeChargesDue, final Money penaltyChargesDue, final Money totalDue) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java index e4464d319..78742ed62 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java @@ -41,7 +41,6 @@ import org.mifosplatform.portfolio.loanaccount.api.LoanApiConstants; import org.mifosplatform.portfolio.loanaccount.data.DisbursementData; import org.mifosplatform.portfolio.loanaccount.data.LoanTermVariationsData; import org.mifosplatform.portfolio.loanaccount.domain.LoanCharge; -import org.mifosplatform.portfolio.loanaccount.domain.LoanTermVariations; import org.mifosplatform.portfolio.loanaccount.domain.LoanTermVariationType; import org.mifosplatform.portfolio.loanaccount.exception.LoanApplicationDateException; import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.AprCalculator; @@ -199,24 +198,27 @@ public class LoanScheduleAssembler { // other final BigDecimal inArrearsTolerance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("inArrearsTolerance", element); final Money inArrearsToleranceMoney = Money.of(currency, inArrearsTolerance); - - final BigDecimal emiAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element); - final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.maxOutstandingBalanceParameterName, element); - - final List disbursementDatas = fetchDisbursementData(element.getAsJsonObject()); - + + final BigDecimal emiAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, + element); + final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( + LoanApiConstants.maxOutstandingBalanceParameterName, element); + + final List disbursementDatas = fetchDisbursementData(element.getAsJsonObject()); + final List loanVariationTermsData = new ArrayList(); - LoanTermVariationsData data = new LoanTermVariationsData(null, LoanEnumerations.loanvariationType(LoanTermVariationType.EMI_AMOUNT), expectedDisbursementDate, emiAmount); + LoanTermVariationsData data = new LoanTermVariationsData(null, + LoanEnumerations.loanvariationType(LoanTermVariationType.EMI_AMOUNT), expectedDisbursementDate, emiAmount); loanVariationTermsData.add(data); return LoanApplicationTerms.assembleFrom(applicationCurrency, loanTermFrequency, loanTermPeriodFrequencyType, numberOfRepayments, repaymentEvery, repaymentPeriodFrequencyType, amortizationMethod, interestMethod, interestRatePerPeriod, interestRatePeriodFrequencyType, annualNominalInterestRate, interestCalculationPeriodMethod, principalMoney, expectedDisbursementDate, repaymentsStartingFromDate, calculatedRepaymentsStartingFromDate, graceOnPrincipalPayment, - graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, inArrearsToleranceMoney,loanProduct.isMultiDisburseLoan(), - emiAmount,disbursementDatas, maxOutstandingBalance,loanVariationTermsData); + graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, inArrearsToleranceMoney, + loanProduct.isMultiDisburseLoan(), emiAmount, disbursementDatas, maxOutstandingBalance, loanVariationTermsData); } - + private List fetchDisbursementData(final JsonObject command) { final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(command); final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(command); @@ -231,14 +233,15 @@ public class LoanScheduleAssembler { BigDecimal principal = null; if (jsonObject.has(LoanApiConstants.disbursementDateParameterName)) { - expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName, jsonObject,dateFormat,locale); + expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed( + LoanApiConstants.disbursementDateParameterName, jsonObject, dateFormat, locale); } if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName) && jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).isJsonPrimitive() && StringUtils.isNotBlank((jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).getAsString()))) { principal = jsonObject.getAsJsonPrimitive(LoanApiConstants.disbursementPrincipalParameterName).getAsBigDecimal(); } - disbursementDatas.add(new DisbursementData(null, expectedDisbursementDate, null, principal,null)); + disbursementDatas.add(new DisbursementData(null, expectedDisbursementDate, null, principal, null)); i++; } while (i < disbursementDataArray.size()); } @@ -246,8 +249,6 @@ public class LoanScheduleAssembler { return disbursementDatas; } - - private void validateRepaymentsStartDateWithMeetingDates(final LocalDate repaymentsStartingFromDate, final Calendar calendar) { if (repaymentsStartingFromDate != null && !CalendarUtils.isValidRedurringDate(calendar.getRecurrence(), calendar.getStartDateLocalDate(), @@ -282,7 +283,8 @@ public class LoanScheduleAssembler { if (repaymentInterval % meetingInterval != 0) { // throw exception: Loan product frequency/interval throw new MeetingFrequencyMismatchException("loanapplication.repayment.interval", - "Loan repayment repaid every # must equal or multiple of meeting interval " + meetingInterval, meetingInterval, repaymentInterval); + "Loan repayment repaid every # must equal or multiple of meeting interval " + meetingInterval, meetingInterval, + repaymentInterval); } } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleCalculationPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleCalculationPlatformServiceImpl.java index 8d7728244..eb9484eaf 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleCalculationPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleCalculationPlatformServiceImpl.java @@ -51,7 +51,7 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC public LoanScheduleModel calculateLoanSchedule(final JsonQuery query) { this.fromApiJsonDeserializer.validate(query.json()); - + final List dataValidationErrors = new ArrayList(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan"); @@ -68,14 +68,13 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC } else if (groupId != null) { cycleNumber = this.loanReadPlatformService.retriveLoanCounter(groupId, AccountType.GROUP.getValue(), loanProduct.getId()); } - this.loanProductCommandFromApiJsonDeserializer.validateMinMaxConstraints(query.parsedJson(), baseDataValidator, - loanProduct, cycleNumber); + this.loanProductCommandFromApiJsonDeserializer.validateMinMaxConstraints(query.parsedJson(), baseDataValidator, loanProduct, + cycleNumber); } else { - this.loanProductCommandFromApiJsonDeserializer.validateMinMaxConstraints(query.parsedJson(), baseDataValidator, - loanProduct); + this.loanProductCommandFromApiJsonDeserializer.validateMinMaxConstraints(query.parsedJson(), baseDataValidator, loanProduct); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } - + return this.loanScheduleAssembler.assembleLoanScheduleFrom(query.parsedJson()); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/CalculateLoanScheduleQueryFromApiJsonHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/CalculateLoanScheduleQueryFromApiJsonHelper.java index 5fa159c33..05d78deef 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/CalculateLoanScheduleQueryFromApiJsonHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/CalculateLoanScheduleQueryFromApiJsonHelper.java @@ -43,8 +43,9 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper { "loanTermFrequencyType", "repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType", "expectedDisbursementDate", "repaymentsStartingFromDate", "graceOnPrincipalPayment", "graceOnInterestPayment", "graceOnInterestCharged", "interestChargedFromDate", "submittedOnDate", "submittedOnNote", "locale", - "dateFormat", "charges", "collateral", "syncDisbursementWithMeeting", "linkAccountId",LoanApiConstants.disbursementDataParameterName, - LoanApiConstants.emiAmountParameterName,LoanApiConstants.maxOutstandingBalanceParameterName)); + "dateFormat", "charges", "collateral", "syncDisbursementWithMeeting", "linkAccountId", + LoanApiConstants.disbursementDataParameterName, LoanApiConstants.emiAmountParameterName, + LoanApiConstants.maxOutstandingBalanceParameterName)); private final FromJsonHelper fromApiJsonHelper; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java index b53561b36..4b84619c9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java @@ -46,14 +46,18 @@ public final class LoanApplicationCommandFromApiJsonHelper { "loanType", "productId", "principal", "loanTermFrequency", "loanTermFrequencyType", "numberOfRepayments", "repaymentEvery", "repaymentFrequencyType", "interestRatePerPeriod", "amortizationType", "interestType", "interestCalculationPeriodType", "expectedDisbursementDate", "repaymentsStartingFromDate", "graceOnPrincipalPayment", "graceOnInterestPayment", - "graceOnInterestCharged", "interestChargedFromDate", // - "submittedOnDate", "submittedOnNote", // - "accountNo", "externalId", "fundId", "loanOfficerId", // optional - "loanPurposeId", "inArrearsTolerance", "charges", "collateral", // optional + "graceOnInterestCharged", + "interestChargedFromDate", // + "submittedOnDate", + "submittedOnNote", // + "accountNo", "externalId", "fundId", + "loanOfficerId", // optional + "loanPurposeId", "inArrearsTolerance", "charges", + "collateral", // optional "transactionProcessingStrategyId", // settings "calendarId", // optional "syncDisbursementWithMeeting",// optional - "linkAccountId",LoanApiConstants.disbursementDataParameterName,LoanApiConstants.emiAmountParameterName, + "linkAccountId", LoanApiConstants.disbursementDataParameterName, LoanApiConstants.emiAmountParameterName, LoanApiConstants.maxOutstandingBalanceParameterName)); private final FromJsonHelper fromApiJsonHelper; @@ -334,16 +338,19 @@ public final class LoanApplicationCommandFromApiJsonHelper { baseDataValidator.reset().parameter(calendarIdParameterName).value(calendarId).notNull().integerGreaterThanZero(); } - if(this.fromApiJsonHelper.parameterExists(LoanApiConstants.emiAmountParameterName, element)){ - final BigDecimal emiAnount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element); + if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.emiAmountParameterName, element)) { + final BigDecimal emiAnount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, + element); baseDataValidator.reset().parameter(LoanApiConstants.emiAmountParameterName).value(emiAnount).ignoreIfNull().positiveAmount(); } - if(this.fromApiJsonHelper.parameterExists(LoanApiConstants.maxOutstandingBalanceParameterName, element)){ - final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.maxOutstandingBalanceParameterName, element); - baseDataValidator.reset().parameter(LoanApiConstants.maxOutstandingBalanceParameterName).value(maxOutstandingBalance).ignoreIfNull().positiveAmount(); + if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.maxOutstandingBalanceParameterName, element)) { + final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( + LoanApiConstants.maxOutstandingBalanceParameterName, element); + baseDataValidator.reset().parameter(LoanApiConstants.maxOutstandingBalanceParameterName).value(maxOutstandingBalance) + .ignoreIfNull().positiveAmount(); } validateLoanMultiDisbursementdate(element, baseDataValidator, expectedDisbursementDate, principal); - + if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } } @@ -427,7 +434,8 @@ public final class LoanApplicationCommandFromApiJsonHelper { final String inArrearsToleranceParameterName = "inArrearsTolerance"; if (this.fromApiJsonHelper.parameterExists(inArrearsToleranceParameterName, element)) { atLeastOneParameterPassedForUpdate = true; - final BigDecimal inArrearsTolerance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(inArrearsToleranceParameterName, element); + final BigDecimal inArrearsTolerance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(inArrearsToleranceParameterName, + element); baseDataValidator.reset().parameter(inArrearsToleranceParameterName).value(inArrearsTolerance).ignoreIfNull().positiveAmount(); } @@ -512,8 +520,7 @@ public final class LoanApplicationCommandFromApiJsonHelper { element); baseDataValidator.reset().parameter(expectedDisbursementDateParameterName).value(expectedDisbursementDateStr).notBlank(); - expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed(expectedDisbursementDateParameterName, - element); + expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed(expectedDisbursementDateParameterName, element); baseDataValidator.reset().parameter(expectedDisbursementDateParameterName).value(expectedDisbursementDate).notNull(); } @@ -665,19 +672,21 @@ public final class LoanApplicationCommandFromApiJsonHelper { final Object forceError = null; baseDataValidator.reset().anyOfNotNull(forceError); } - - if(this.fromApiJsonHelper.parameterExists(LoanApiConstants.emiAmountParameterName, element)){ - final BigDecimal emiAnount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element); + + if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.emiAmountParameterName, element)) { + final BigDecimal emiAnount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, + element); baseDataValidator.reset().parameter(LoanApiConstants.emiAmountParameterName).value(emiAnount).ignoreIfNull().positiveAmount(); } - - if(this.fromApiJsonHelper.parameterExists(LoanApiConstants.maxOutstandingBalanceParameterName, element)){ - final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.maxOutstandingBalanceParameterName, element); - baseDataValidator.reset().parameter(LoanApiConstants.maxOutstandingBalanceParameterName).value(maxOutstandingBalance).ignoreIfNull().positiveAmount(); + + if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.maxOutstandingBalanceParameterName, element)) { + final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( + LoanApiConstants.maxOutstandingBalanceParameterName, element); + baseDataValidator.reset().parameter(LoanApiConstants.maxOutstandingBalanceParameterName).value(maxOutstandingBalance) + .ignoreIfNull().positiveAmount(); } - + validateLoanMultiDisbursementdate(element, baseDataValidator, expectedDisbursementDate, principal); - if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } @@ -747,18 +756,18 @@ public final class LoanApplicationCommandFromApiJsonHelper { if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } } - - - private void validateLoanMultiDisbursementdate(final JsonElement element, final DataValidatorBuilder baseDataValidator,LocalDate expectedDisbursement, - BigDecimal totalPrincipal){ + + private void validateLoanMultiDisbursementdate(final JsonElement element, final DataValidatorBuilder baseDataValidator, + LocalDate expectedDisbursement, BigDecimal totalPrincipal) { final JsonObject topLevelJsonElement = element.getAsJsonObject(); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(topLevelJsonElement); - if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.disbursementDataParameterName, element) && expectedDisbursement !=null - && totalPrincipal !=null) { - BigDecimal tatalDisbursement = BigDecimal.ZERO; + if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.disbursementDataParameterName, element) && expectedDisbursement != null + && totalPrincipal != null) { + BigDecimal tatalDisbursement = BigDecimal.ZERO; boolean isFirstinstallmentOnExpectedDisbursementDate = false; - final JsonArray variationArray= this.fromApiJsonHelper.extractJsonArrayNamed(LoanApiConstants.disbursementDataParameterName, element); + final JsonArray variationArray = this.fromApiJsonHelper.extractJsonArrayNamed(LoanApiConstants.disbursementDataParameterName, + element); List expectedDisbursementDates = new ArrayList(); if (variationArray != null && variationArray.size() > 0) { int i = 0; @@ -766,38 +775,45 @@ public final class LoanApplicationCommandFromApiJsonHelper { final JsonObject jsonObject = variationArray.get(i).getAsJsonObject(); BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalNamed( - LoanApiConstants.disbursementPrincipalParameterName, jsonObject,locale);; + LoanApiConstants.disbursementPrincipalParameterName, jsonObject, locale); + ; - LocalDate expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName, - jsonObject,dateFormat,locale); - if(expectedDisbursementDates.contains(expectedDisbursementDate)){ - baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName).failWithCode(LoanApiConstants.DISBURSEMENT_DATE_UNIQUE_ERROR); + LocalDate expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed( + LoanApiConstants.disbursementDateParameterName, jsonObject, dateFormat, locale); + if (expectedDisbursementDates.contains(expectedDisbursementDate)) { + baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName) + .failWithCode(LoanApiConstants.DISBURSEMENT_DATE_UNIQUE_ERROR); } expectedDisbursementDates.add(expectedDisbursementDate); - baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName).parameterAtIndexArray(LoanApiConstants.disbursementPrincipalParameterName, i).value(principal).notBlank(); - baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName).parameterAtIndexArray(LoanApiConstants.disbursementDateParameterName, i).value(expectedDisbursementDate).notNull(); - if(principal != null){ + baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName) + .parameterAtIndexArray(LoanApiConstants.disbursementPrincipalParameterName, i).value(principal).notBlank(); + baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName) + .parameterAtIndexArray(LoanApiConstants.disbursementDateParameterName, i).value(expectedDisbursementDate) + .notNull(); + if (principal != null) { tatalDisbursement = tatalDisbursement.add(principal); } - if(expectedDisbursement.equals(expectedDisbursementDate)){ + if (expectedDisbursement.equals(expectedDisbursementDate)) { isFirstinstallmentOnExpectedDisbursementDate = true; } i++; } while (i < variationArray.size()); - if(!isFirstinstallmentOnExpectedDisbursementDate){ - baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName).failWithCode(LoanApiConstants.DISBURSEMENT_DATE_START_WITH_ERROR); + if (!isFirstinstallmentOnExpectedDisbursementDate) { + baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName) + .failWithCode(LoanApiConstants.DISBURSEMENT_DATE_START_WITH_ERROR); } - if(!tatalDisbursement.equals(totalPrincipal)){ - baseDataValidator.reset().parameter(LoanApiConstants.disbursementPrincipalParameterName).failWithCode(LoanApiConstants.PRINCIPAL_AMOUNT_SHOULD_BE_SAME); + if (!tatalDisbursement.equals(totalPrincipal)) { + baseDataValidator.reset().parameter(LoanApiConstants.disbursementPrincipalParameterName) + .failWithCode(LoanApiConstants.PRINCIPAL_AMOUNT_SHOULD_BE_SAME); } final String interestTypeParameterName = "interestType"; final Integer interestType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(interestTypeParameterName, element); - baseDataValidator.reset().parameter(interestTypeParameterName).value(interestType).ignoreIfNull().integerSameAsNumber(InterestMethod.DECLINING_BALANCE.getValue()); + baseDataValidator.reset().parameter(interestTypeParameterName).value(interestType).ignoreIfNull() + .integerSameAsNumber(InterestMethod.DECLINING_BALANCE.getValue()); } - + } - } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java index ea9d93bc4..f1163c18e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/serialization/LoanEventApiJsonValidator.java @@ -54,7 +54,7 @@ public final class LoanEventApiJsonValidator { final Set disbursementParameters = new HashSet(Arrays.asList("actualDisbursementDate", "externalId", "note", "locale", "dateFormat", "paymentTypeId", "accountNumber", "checkNumber", "routingCode", "receiptNumber", "bankNumber", - LoanApiConstants.principalDisbursedParameterName,LoanApiConstants.emiAmountParameterName)); + LoanApiConstants.principalDisbursedParameterName, LoanApiConstants.emiAmountParameterName)); final Type typeOfMap = new TypeToken>() {}.getType(); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, disbursementParameters); @@ -68,12 +68,16 @@ public final class LoanEventApiJsonValidator { final String note = this.fromApiJsonHelper.extractStringNamed("note", element); baseDataValidator.reset().parameter("note").value(note).notExceedingLengthOf(1000); - - final BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.principalDisbursedParameterName, element); - baseDataValidator.reset().parameter(LoanApiConstants.principalDisbursedParameterName).value(principal).ignoreIfNull().positiveAmount(); - final BigDecimal emiAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element); - baseDataValidator.reset().parameter(LoanApiConstants.emiAmountParameterName).value(emiAmount).ignoreIfNull().positiveAmount().notGreaterThanMax(principal); + final BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( + LoanApiConstants.principalDisbursedParameterName, element); + baseDataValidator.reset().parameter(LoanApiConstants.principalDisbursedParameterName).value(principal).ignoreIfNull() + .positiveAmount(); + + final BigDecimal emiAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, + element); + baseDataValidator.reset().parameter(LoanApiConstants.emiAmountParameterName).value(emiAmount).ignoreIfNull().positiveAmount() + .notGreaterThanMax(principal); validatePaymentDetails(baseDataValidator, element); @@ -85,10 +89,10 @@ public final class LoanEventApiJsonValidator { final Calendar calendar = calendarInstance.getCalendar(); if (!calendar.isValidRecurringDate(actualDisbursementDate)) { // Disbursement date should fall on a meeting date - final String errorMessage = "Expected disbursement date '" + actualDisbursementDate.toString() - + "' does not fall on a meeting date."; - throw new NotValidRecurringDateException("loan.actual.disbursement.date", errorMessage, - actualDisbursementDate.toString(), calendar.getTitle()); + final String errorMessage = "Expected disbursement date '" + actualDisbursementDate.toString() + + "' does not fall on a meeting date."; + throw new NotValidRecurringDateException("loan.actual.disbursement.date", errorMessage, actualDisbursementDate.toString(), + calendar.getTitle()); } } } @@ -306,9 +310,11 @@ public final class LoanEventApiJsonValidator { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } Set transactionParameters = null; if (isChargeIdIncluded) { - transactionParameters = new HashSet(Arrays.asList("transactionDate", "locale", "dateFormat", "chargeId","dueDate","installmentNumber")); + transactionParameters = new HashSet(Arrays.asList("transactionDate", "locale", "dateFormat", "chargeId", "dueDate", + "installmentNumber")); } else { - transactionParameters = new HashSet(Arrays.asList("transactionDate", "locale", "dateFormat","dueDate","installmentNumber")); + transactionParameters = new HashSet(Arrays.asList("transactionDate", "locale", "dateFormat", "dueDate", + "installmentNumber")); } final Type typeOfMap = new TypeToken>() {}.getType(); @@ -330,12 +336,12 @@ public final class LoanEventApiJsonValidator { throwExceptionIfValidationWarningsExist(dataValidationErrors); } - + public void validateInstallmentChargeTransaction(final String json) { - if (StringUtils.isBlank(json)) { return;} + if (StringUtils.isBlank(json)) { return; } Set transactionParameters = new HashSet(Arrays.asList("dueDate", "locale", "dateFormat", "installmentNumber")); - + final Type typeOfMap = new TypeToken>() {}.getType(); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, transactionParameters); @@ -344,17 +350,18 @@ public final class LoanEventApiJsonValidator { .resource("loan.charge.waive.transaction"); final JsonElement element = this.fromApiJsonHelper.parse(json); - + final Integer installmentNumber = this.fromApiJsonHelper.extractIntegerWithLocaleNamed("installmentNumber", element); baseDataValidator.reset().parameter("installmentNumber").value(installmentNumber).ignoreIfNull().integerGreaterThanZero(); throwExceptionIfValidationWarningsExist(dataValidationErrors); } - - public void validateUpdateDisbursementDate(final String json,LoanDisbursementDetails loanDisbursementDetails) { + + public void validateUpdateDisbursementDate(final String json, LoanDisbursementDetails loanDisbursementDetails) { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } - final Set disbursementParameters = new HashSet(Arrays.asList(LoanApiConstants.disbursementDateParameterName,"locale", "dateFormat")); + final Set disbursementParameters = new HashSet(Arrays.asList(LoanApiConstants.disbursementDateParameterName, + "locale", "dateFormat")); final Type typeOfMap = new TypeToken>() {}.getType(); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, disbursementParameters); @@ -363,15 +370,16 @@ public final class LoanEventApiJsonValidator { final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.update.disbursement"); final JsonElement element = this.fromApiJsonHelper.parse(json); - final LocalDate actualDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName, element); + final LocalDate actualDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed( + LoanApiConstants.disbursementDateParameterName, element); baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName).value(actualDisbursementDate).notNull(); - - if(loanDisbursementDetails.actualDisbursementDate() != null){ - baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName).failWithCode(LoanApiConstants.ALREADY_DISBURSED); + + if (loanDisbursementDetails.actualDisbursementDate() != null) { + baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName) + .failWithCode(LoanApiConstants.ALREADY_DISBURSED); } - + throwExceptionIfValidationWarningsExist(dataValidationErrors); } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java index e2aa75d14..f392220c1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java @@ -192,20 +192,21 @@ public class LoanAssembler { Set disbursementDetails = null; BigDecimal fixedEmiAmount = null; BigDecimal maxOutstandingLoanBalance = null; - if(loanProduct.isMultiDisburseLoan()){ + if (loanProduct.isMultiDisburseLoan()) { disbursementDetails = fetchDisbursementData(element.getAsJsonObject()); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(element.getAsJsonObject()); fixedEmiAmount = this.fromApiJsonHelper.extractBigDecimalNamed(LoanApiConstants.emiAmountParameterName, element, locale); - maxOutstandingLoanBalance = this.fromApiJsonHelper.extractBigDecimalNamed(LoanApiConstants.maxOutstandingBalanceParameterName, element, locale); - if(disbursementDetails.isEmpty()){ + maxOutstandingLoanBalance = this.fromApiJsonHelper.extractBigDecimalNamed(LoanApiConstants.maxOutstandingBalanceParameterName, + element, locale); + if (disbursementDetails.isEmpty()) { final String errorMessage = "For this loan product, disbursement details must be provided"; throw new MultiDisbursementDataRequiredException(LoanApiConstants.disbursementDataParameterName, errorMessage); } - - if(disbursementDetails.size() > loanProduct.maxTrancheCount()){ - final String errorMessage = "Number of tranche shouldn't be greter than "+loanProduct.maxTrancheCount(); + + if (disbursementDetails.size() > loanProduct.maxTrancheCount()) { + final String errorMessage = "Number of tranche shouldn't be greter than " + loanProduct.maxTrancheCount(); throw new ExceedingTrancheCountException(LoanApiConstants.disbursementDataParameterName, errorMessage, - loanProduct.maxTrancheCount(),disbursementDetails.size()); + loanProduct.maxTrancheCount(), disbursementDetails.size()); } } @@ -249,12 +250,12 @@ public class LoanAssembler { loanApplication.setHelpers(defaultLoanLifecycleStateMachine(), this.loanSummaryWrapper, this.loanRepaymentScheduleTransactionProcessorFactory); - if(loanProduct.isMultiDisburseLoan()){ - for(final LoanDisbursementDetails loanDisbursementDetails:loanApplication.getDisbursementDetails()){ + if (loanProduct.isMultiDisburseLoan()) { + for (final LoanDisbursementDetails loanDisbursementDetails : loanApplication.getDisbursementDetails()) { loanDisbursementDetails.updateLoan(loanApplication); } } - + final LoanApplicationTerms loanApplicationTerms = this.loanScheduleAssembler.assembleLoanTerms(element); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); final List holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loanApplication.getOfficeId(), @@ -270,7 +271,6 @@ public class LoanAssembler { return loanApplication; } - private Set fetchDisbursementData(final JsonObject command) { final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(command); final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(command); @@ -285,10 +285,11 @@ public class LoanAssembler { BigDecimal principal = null; if (jsonObject.has(LoanApiConstants.disbursementDateParameterName)) { - LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName, jsonObject,dateFormat,locale); - if(date!=null){ - expectedDisbursementDate = date.toDate(); - } + LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName, + jsonObject, dateFormat, locale); + if (date != null) { + expectedDisbursementDate = date.toDate(); + } } if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName) && jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).isJsonPrimitive() @@ -302,8 +303,7 @@ public class LoanAssembler { } return disbursementDatas; } - - + private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() { final List allowedLoanStatuses = Arrays.asList(LoanStatus.values()); return new DefaultLoanLifecycleStateMachine(allowedLoanStatuses); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeAssembler.java index edee75cdf..53ecc2581 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeAssembler.java @@ -84,7 +84,7 @@ public class LoanChargeAssembler { chargePaymentModeEnum = ChargePaymentMode.fromInt(chargePaymentMode); } final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition, principal, amount, chargeTime, - chargeCalculation, dueDate, chargePaymentModeEnum,numberOfRepayments); + chargeCalculation, dueDate, chargePaymentModeEnum, numberOfRepayments); loanCharges.add(loanCharge); } else { final Long loanChargeId = id; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformService.java index dfc9f8d10..727e94945 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformService.java @@ -20,6 +20,6 @@ public interface LoanChargeReadPlatformService { LoanChargeData retrieveLoanChargeDetails(Long loanChargeId, Long loanId); Collection retrieveLoanChargesForFeePayment(Integer paymentMode, Integer loanStatus); - - Collection retrieveInstallmentLoanCharges(Long loanChargeId,boolean onlyPaymentPendingCharges); + + Collection retrieveInstallmentLoanCharges(Long loanChargeId, boolean onlyPaymentPendingCharges); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java index 4e1bf0ba3..45050c2a4 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanChargeReadPlatformServiceImpl.java @@ -160,7 +160,8 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform @Override public Collection retrieveLoanChargesForFeePayment(final Integer paymentMode, final Integer loanStatus) { final LoanChargeMapperWithLoanId rm = new LoanChargeMapperWithLoanId(); - final String sql = "select " + rm.schema() + final String sql = "select " + + rm.schema() + "where loan.loan_status_id= ? and lc.charge_payment_mode_enum=? and lc.waived =0 and lc.is_paid_derived=0 and lc.is_active = 1"; return this.jdbcTemplate.query(sql, rm, new Object[] { loanStatus, paymentMode }); } @@ -169,11 +170,8 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform public String schema() { return "lc.id as id, lc.due_for_collection_as_of_date as dueAsOfDate, " - + "lc.amount_outstanding_derived as amountOutstanding, " - + "lc.charge_time_enum as chargeTime, " - + "loan.id as loanId " - + "from m_loan_charge lc " - + "join m_loan loan on loan.id = lc.loan_id "; + + "lc.amount_outstanding_derived as amountOutstanding, " + "lc.charge_time_enum as chargeTime, " + "loan.id as loanId " + + "from m_loan_charge lc " + "join m_loan loan on loan.id = lc.loan_id "; } @Override @@ -185,18 +183,17 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform final BigDecimal amountOutstanding = rs.getBigDecimal("amountOutstanding"); final int chargeTime = rs.getInt("chargeTime"); final EnumOptionData chargeTimeType = ChargeEnumerations.chargeTimeType(chargeTime); - + return new LoanChargeData(id, dueAsOfDate, amountOutstanding, chargeTimeType, loanId, null); } } @Override - public Collection retrieveInstallmentLoanCharges(Long loanChargeId,boolean onlyPaymentPendingCharges) { + public Collection retrieveInstallmentLoanCharges(Long loanChargeId, boolean onlyPaymentPendingCharges) { final LoanInstallmentChargeMapper rm = new LoanInstallmentChargeMapper(); - String sql = "select " + rm.schema() - + "where lic.loan_charge_id= ? "; - if(onlyPaymentPendingCharges){ - sql = sql +"and lic.waived =0 and lic.is_paid_derived=0"; + String sql = "select " + rm.schema() + "where lic.loan_charge_id= ? "; + if (onlyPaymentPendingCharges) { + sql = sql + "and lic.waived =0 and lic.is_paid_derived=0"; } return this.jdbcTemplate.query(sql, rm, new Object[] { loanChargeId }); } @@ -205,11 +202,8 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform public String schema() { return " lsi.installment as installmentNumber, lsi.duedate as dueAsOfDate, " - + "lic.amount_outstanding_derived as amountOutstanding," - + "lic.amount as amount, " - + "lic.is_paid_derived as paid, " - + "lic.waived as waied " - + "from m_loan_installment_charge lic " + + "lic.amount_outstanding_derived as amountOutstanding," + "lic.amount as amount, " + "lic.is_paid_derived as paid, " + + "lic.waived as waied " + "from m_loan_installment_charge lic " + "join m_loan_repayment_schedule lsi on lsi.id = lic.loan_schedule_id "; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformService.java index 9afe0d543..90ac0a6f9 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformService.java @@ -23,7 +23,8 @@ public interface LoanReadPlatformService { LoanAccountData retrieveOne(Long loanId); - LoanScheduleData retrieveRepaymentSchedule(Long loanId, RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData, Collection disbursementData); + LoanScheduleData retrieveRepaymentSchedule(Long loanId, RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData, + Collection disbursementData); Collection retrieveLoanTransactions(Long loanId); @@ -58,9 +59,12 @@ public interface LoanReadPlatformService { Collection retrieveAllowedLoanOfficers(Long selectedOfficeId, boolean staffInSelectedOfficeOnly); /* - * musoni-specific at present - will find overdue scheduled installments that have a special 'overdue charge' associated with the loan product. - * - * The 'overdue-charge' is only ever applied once to an installment and as a result overdue installments with this charge already applied are not returned. + * musoni-specific at present - will find overdue scheduled installments + * that have a special 'overdue charge' associated with the loan product. + * + * The 'overdue-charge' is only ever applied once to an installment and as a + * result overdue installments with this charge already applied are not + * returned. */ Collection retrieveAllLoansWithOverdueInstallmentsNotAlreadyPenalized(final Long penaltyWaitPeriod); @@ -69,8 +73,8 @@ public interface LoanReadPlatformService { Integer retriveLoanCounter(Long clientId, Long productId); Collection retrieveLoanDisbursementDetails(Long loanId); - - DisbursementData retrieveLoanDisbursementDetail(Long loanId,Long disbursementId); - - Collection retrieveLoanTermVariations(Long loanId,Integer termType); + + DisbursementData retrieveLoanDisbursementDetail(Long loanId, Long disbursementId); + + Collection retrieveLoanTermVariations(Long loanId, Integer termType); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index 3add305cd..39c6669df 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -212,12 +212,12 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { sqlBuilder.append(" join m_office o on o.id = c.office_id"); sqlBuilder.append(" left join m_office transferToOffice on transferToOffice.id = c.transfer_to_office_id "); sqlBuilder.append(" where ( o.hierarchy like ? or transferToOffice.hierarchy like ?)"); - + int arrayPos = 2; - List extraCriterias = new ArrayList(); + List extraCriterias = new ArrayList(); extraCriterias.add(hierarchySearchString); extraCriterias.add(hierarchySearchString); - + String sqlQueryCriteria = searchParameters.getSqlSearch(); if (StringUtils.isNotBlank(sqlQueryCriteria)) { sqlQueryCriteria = sqlQueryCriteria.replaceAll("accountNo", "l.account_no"); @@ -225,14 +225,14 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { } if (StringUtils.isNotBlank(searchParameters.getExternalId())) { - sqlBuilder.append(" and l.external_id = ?"); + sqlBuilder.append(" and l.external_id = ?"); extraCriterias.add(searchParameters.getExternalId()); arrayPos = arrayPos + 1; } - + if (StringUtils.isNotBlank(searchParameters.getAccountNo())) { sqlBuilder.append(" and l.account_no = ?"); - extraCriterias.add(searchParameters.getAccountNo()); + extraCriterias.add(searchParameters.getAccountNo()); arrayPos = arrayPos + 1; } @@ -243,14 +243,14 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { sqlBuilder.append(' ').append(searchParameters.getSortOrder()); } } - + if (searchParameters.isLimited()) { sqlBuilder.append(" limit ").append(searchParameters.getLimit()); if (searchParameters.isOffset()) { sqlBuilder.append(" offset ").append(searchParameters.getOffset()); } } - + final Object[] objectArray = extraCriterias.toArray(); final Object[] finalObjectArray = Arrays.copyOf(objectArray, arrayPos); final String sqlCountRows = "SELECT FOUND_ROWS()"; @@ -342,7 +342,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final Collection paymentOptions = this.codeValueReadPlatformService .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate, - possibleNextRepaymentAmount.getAmount(), null, null, null, null, null, paymentOptions, null, null,null); + possibleNextRepaymentAmount.getAmount(), null, null, null, null, null, paymentOptions, null, null, null); } @Override @@ -386,8 +386,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.DISBURSEMENT); final Collection paymentOptions = this.codeValueReadPlatformService .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); - return new LoanTransactionData(null, null, null, transactionType, null, null, loan.getExpectedDisbursedOnLocalDateForTemplate(), loan.getDisburseAmountForTemplate(), - null,null, null, null, null, paymentOptions, null, null,loan.retriveLastEmiAmount()); + return new LoanTransactionData(null, null, null, transactionType, null, null, loan.getExpectedDisbursedOnLocalDateForTemplate(), + loan.getDisburseAmountForTemplate(), null, null, null, null, null, paymentOptions, null, null, loan.retriveLastEmiAmount()); } @Override @@ -699,13 +699,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { return LoanAccountData.basicLoanDetails(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, groupData, loanType, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName, - loanOfficerId, loanOfficerName, currencyData, principal,approvedPrincipal, totalOverpaid, inArrearsTolerance, termFrequency, - termPeriodFrequencyType, numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionStrategyId, - transactionStrategyName, amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, - interestType, interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, + loanOfficerId, loanOfficerName, currencyData, principal, approvedPrincipal, totalOverpaid, inArrearsTolerance, + termFrequency, termPeriodFrequencyType, numberOfRepayments, repaymentEvery, repaymentFrequencyType, + transactionStrategyId, transactionStrategyName, amortizationType, interestRatePerPeriod, interestRateFrequencyType, + annualInterestRate, interestType, interestCalculationPeriodType, expectedFirstRepaymentOnDate, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, timeline, loanSummary, feeChargesDueAtDisbursementCharged, syncDisbursementWithMeeting, loanCounter, loanProductCounter, multiDisburseLoan, - fixedEmiAmount,outstandingLoanBalance); + fixedEmiAmount, outstandingLoanBalance); } } @@ -751,7 +751,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { private LocalDate lastDueDate; private BigDecimal outstandingLoanPrincipalBalance; - public LoanScheduleResultSetExtractor(final RepaymentScheduleRelatedLoanData repaymentScheduleRelatedLoanData, Collection disbursementData) { + public LoanScheduleResultSetExtractor(final RepaymentScheduleRelatedLoanData repaymentScheduleRelatedLoanData, + Collection disbursementData) { this.currency = repaymentScheduleRelatedLoanData.getCurrency(); this.disbursement = repaymentScheduleRelatedLoanData.disbursementData(); this.totalFeeChargesDueAtDisbursement = repaymentScheduleRelatedLoanData.getTotalFeeChargesAtDisbursement(); @@ -782,14 +783,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final MonetaryCurrency monCurrency = new MonetaryCurrency(this.currency.code(), this.currency.decimalPlaces(), this.currency.currencyInMultiplesOf()); BigDecimal totalPrincipalDisbursed = BigDecimal.ZERO; - if(disbursementData == null || disbursementData.isEmpty()){ + if (disbursementData == null || disbursementData.isEmpty()) { periods.add(disbursementPeriod); totalPrincipalDisbursed = Money.of(monCurrency, this.disbursement.amount()).getAmount(); - }else{ - this.outstandingLoanPrincipalBalance = BigDecimal.ZERO; + } else { + this.outstandingLoanPrincipalBalance = BigDecimal.ZERO; } - - + Money totalPrincipalExpected = Money.zero(monCurrency); Money totalPrincipalPaid = Money.zero(monCurrency); Money totalInterestCharged = Money.zero(monCurrency); @@ -818,22 +818,19 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final LocalDate dueDate = JdbcSupport.getLocalDate(rs, "dueDate"); final LocalDate obligationsMetOnDate = JdbcSupport.getLocalDate(rs, "obligationsMetOnDate"); final boolean complete = rs.getBoolean("complete"); - - if(disbursementData!=null){ + + if (disbursementData != null) { BigDecimal principal = BigDecimal.ZERO; - for(DisbursementData data:disbursementData){ - if(fromDate.equals(this.disbursement.disbursementDate()) - && data.disbursementDate().equals(fromDate)){ + for (DisbursementData data : disbursementData) { + if (fromDate.equals(this.disbursement.disbursementDate()) && data.disbursementDate().equals(fromDate)) { principal = principal.add(data.amount()); final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod( - data.disbursementDate(), data.amount(), this.totalFeeChargesDueAtDisbursement, - data.isDisbursed()); + data.disbursementDate(), data.amount(), this.totalFeeChargesDueAtDisbursement, data.isDisbursed()); periods.add(periodData); - }else if(data.isDueForDisbursement(fromDate, dueDate)){ + } else if (data.isDueForDisbursement(fromDate, dueDate)) { principal = principal.add(data.amount()); final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod( - data.disbursementDate(), data.amount(), BigDecimal.ZERO, - data.isDisbursed()); + data.disbursementDate(), data.amount(), BigDecimal.ZERO, data.isDisbursed()); periods.add(periodData); } } @@ -935,7 +932,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { totalWrittenOff.getAmount(), totalRepaymentExpected.getAmount(), totalRepayment.getAmount(), totalPaidInAdvance.getAmount(), totalPaidLate.getAmount(), totalOutstanding.getAmount()); } - + } private static final class LoanTransactionsMapper implements RowMapper { @@ -1030,7 +1027,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { } return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currencyData, date, totalAmount, - principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overPaymentPortion, externalId, transfer, null); + principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overPaymentPortion, externalId, transfer, + null); } } @@ -1212,15 +1210,15 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { @Override public Integer retriveLoanCounter(final Long groupId, final Integer loanType, Long productId) { final String sql = "Select MAX(l.loan_product_counter) from m_loan l where l.group_id = ? and l.loan_type_enum = ? and l.product_id=?"; - return this.jdbcTemplate.queryForInt(sql, groupId, loanType,productId); + return this.jdbcTemplate.queryForInt(sql, groupId, loanType, productId); } @Override public Integer retriveLoanCounter(final Long clientId, Long productId) { final String sql = "Select MAX(l.loan_product_counter) from m_loan l where l.client_id = ? and l.product_id=?"; - return this.jdbcTemplate.queryForInt(sql, clientId,productId); + return this.jdbcTemplate.queryForInt(sql, clientId, productId); } - + @Override public Collection retrieveLoanDisbursementDetails(final Long loanId) { final LoanDisbursementDetailMapper rm = new LoanDisbursementDetailMapper(); @@ -1228,7 +1226,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { return this.jdbcTemplate.query(sql, rm, new Object[] { loanId }); } - private static final class LoanDisbursementDetailMapper implements RowMapper { public String schema() { @@ -1237,34 +1234,34 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { } @Override - public DisbursementData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) - throws SQLException { + public DisbursementData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { final Long id = rs.getLong("id"); final LocalDate expectedDisbursementdate = JdbcSupport.getLocalDate(rs, "expectedDisbursementdate"); final LocalDate actualDisbursementdate = JdbcSupport.getLocalDate(rs, "actualDisbursementdate"); final BigDecimal principal = rs.getBigDecimal("principal"); final BigDecimal approvedPrincipal = rs.getBigDecimal("approvedPrincipal"); - final DisbursementData disbursementData = new DisbursementData(id,expectedDisbursementdate,actualDisbursementdate,principal,approvedPrincipal); + final DisbursementData disbursementData = new DisbursementData(id, expectedDisbursementdate, actualDisbursementdate, principal, + approvedPrincipal); return disbursementData; } } @Override - public DisbursementData retrieveLoanDisbursementDetail(Long loanId,Long disbursementId) { + public DisbursementData retrieveLoanDisbursementDetail(Long loanId, Long disbursementId) { final LoanDisbursementDetailMapper rm = new LoanDisbursementDetailMapper(); final String sql = "select " + rm.schema() + " where dd.loan_id=? and dd.id=?"; - return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanId,disbursementId }); + return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanId, disbursementId }); } @Override public Collection retrieveLoanTermVariations(Long loanId, Integer termType) { final LoanTermVariationsMapper rm = new LoanTermVariationsMapper(); final String sql = "select " + rm.schema() + " where tv.loan_id=? and tv.term_type=?"; - return this.jdbcTemplate.query(sql, rm, new Object[] { loanId,termType }); + return this.jdbcTemplate.query(sql, rm, new Object[] { loanId, termType }); } - + private static final class LoanTermVariationsMapper implements RowMapper { public String schema() { @@ -1273,18 +1270,16 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { } @Override - public LoanTermVariationsData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) - throws SQLException { + public LoanTermVariationsData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { final Long id = rs.getLong("id"); final LocalDate variationApplicableFrom = JdbcSupport.getLocalDate(rs, "variationApplicableFrom"); final BigDecimal termValue = rs.getBigDecimal("termValue"); - final LoanTermVariationsData loanTermVariationsData = new LoanTermVariationsData(id,LoanEnumerations.loanvariationType(LoanTermVariationType.EMI_AMOUNT), - variationApplicableFrom,termValue); + final LoanTermVariationsData loanTermVariationsData = new LoanTermVariationsData(id, + LoanEnumerations.loanvariationType(LoanTermVariationType.EMI_AMOUNT), variationApplicableFrom, termValue); return loanTermVariationsData; } } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index f660abcee..c46f79d71 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -173,7 +173,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final AccountTransfersReadPlatformService accountTransfersReadPlatformService, final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService, final LoanChargeReadPlatformService loanChargeReadPlatformService, final LoanReadPlatformService loanReadPlatformService, - final FromJsonHelper fromApiJsonHelper,final AccountTransferRepository accountTransferRepository) { + final FromJsonHelper fromApiJsonHelper, final AccountTransferRepository accountTransferRepository) { this.context = context; this.loanEventApiJsonValidator = loanEventApiJsonValidator; this.loanAssembler = loanAssembler; @@ -252,12 +252,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled(); updateLoanCounters(loan, actualDisbursementDate); - loan.disburse(this.loanScheduleFactory, currentUser, command, applicationCurrency, - existingTransactionIds, existingReversedTransactionIds, changes, paymentDetail, calculatedRepaymentsStartingFromDate, isHolidayEnabled, - holidays,workingDays, allowTransactionsOnHoliday, allowTransactionsOnNonWorkingDay); + loan.disburse(this.loanScheduleFactory, currentUser, command, applicationCurrency, existingTransactionIds, + existingReversedTransactionIds, changes, paymentDetail, calculatedRepaymentsStartingFromDate, isHolidayEnabled, holidays, + workingDays, allowTransactionsOnHoliday, allowTransactionsOnNonWorkingDay); if (!changes.isEmpty()) { - try{ + try { this.loanRepository.saveAndFlush(loan); } catch (final DataIntegrityViolationException e) { final Throwable realCause = e.getCause(); @@ -270,17 +270,18 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf "validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } } - final String noteText = command.stringValueOfParameterNamed("note"); if (StringUtils.isNotBlank(noteText)) { final Note note = Note.loanNote(loan, noteText); this.noteRepository.save(note); } - - //fix me - //adding loan installment charges along with the actual disbursement, is trying to add 2 extra entries with null values. which is causing issues + + // fix me + // adding loan installment charges along with the actual + // disbursement, is trying to add 2 extra entries with null values. + // which is causing issues ChangedTransactionDetail changedTransactionDetail = loan.reprocessTransactionForDisbursement(); - try{ + try { this.loanRepository.saveAndFlush(loan); } catch (final DataIntegrityViolationException e) { final Throwable realCause = e.getCause(); @@ -292,7 +293,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException( "validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } } - + if (changedTransactionDetail != null) { for (final Map.Entry mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { this.loanTransactionRepository.save(mapEntry.getValue()); @@ -306,12 +307,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final Set loanCharges = loan.charges(); final Map disBuLoanCharges = new HashMap(); for (final LoanCharge loanCharge : loanCharges) { - if (loanCharge.isDueAtDisbursement() && loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer() + if (loanCharge.isDueAtDisbursement() && loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer() && loanCharge.isNotFullyPaid() && !loanCharge.isWaived()) { disBuLoanCharges.put(loanCharge.getId(), loanCharge.amountOutstanding()); - } + } } - + final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); for (final Map.Entry entrySet : disBuLoanCharges.entrySet()) { @@ -425,16 +426,19 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final Note note = Note.loanNote(loan, noteText); this.noteRepository.save(note); } - - //fix me - //adding loan installment charges along with the actual disbursement, is trying to add 2 extra entries with null values. which is causing issues + + // fix me + // adding loan installment charges along with the actual + // disbursement, is trying to add 2 extra entries with null + // values. which is causing issues ChangedTransactionDetail changedTransactionDetail = loan.reprocessTransactionForDisbursement(); - try{ + try { this.loanRepository.saveAndFlush(loan); } catch (final DataIntegrityViolationException e) { final Throwable realCause = e.getCause(); final List dataValidationErrors = new ArrayList(); - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.transaction"); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + .resource("loan.transaction"); if (realCause.getMessage().toLowerCase().contains("external_id_unique")) { baseDataValidator.reset().parameter("externalId").failWithCode("value.must.be.unique"); } @@ -453,10 +457,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final Set loanCharges = loan.charges(); final Map disBuLoanCharges = new HashMap(); for (final LoanCharge loanCharge : loanCharges) { - if (loanCharge.isDueAtDisbursement() && loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer() + if (loanCharge.isDueAtDisbursement() && loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer() && loanCharge.isNotFullyPaid() && !loanCharge.isWaived()) { disBuLoanCharges.put(loanCharge.getId(), loanCharge.amountOutstanding()); - } + } } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); @@ -608,9 +612,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) { throw new PlatformServiceUnavailableException( "error.msg.loan.transfer.transaction.update.not.allowed", "Loan transaction:" + transactionId + " update not allowed as it involves in account transfer", transactionId); } - if(loan.isClosedWrittenOff()){ throw new PlatformServiceUnavailableException( - "error.msg.loan.written.off.update.not.allowed", "Loan transaction:" + transactionId - + " update not allowed as loan status is written off", transactionId); } + if (loan.isClosedWrittenOff()) { throw new PlatformServiceUnavailableException("error.msg.loan.written.off.update.not.allowed", + "Loan transaction:" + transactionId + " update not allowed as loan status is written off", transactionId); } final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate"); final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount"); @@ -661,7 +664,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf if (changedTransactionDetail != null) { for (final Map.Entry mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { this.loanTransactionRepository.save(mapEntry.getValue()); - //update loan with references to the newly created transactions + // update loan with references to the newly created transactions loan.getLoanTransactions().add(mapEntry.getValue()); this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue()); } @@ -739,7 +742,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf if (changedTransactionDetail != null) { for (final Map.Entry mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { this.loanTransactionRepository.save(mapEntry.getValue()); - //update loan with references to the newly created transactions + // update loan with references to the newly created transactions loan.getLoanTransactions().add(mapEntry.getValue()); this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue()); } @@ -783,22 +786,22 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final List existingTransactionIds = new ArrayList(); final List existingReversedTransactionIds = new ArrayList(); - + final CalendarInstance calendarInstance = this.calendarInstanceRepository.findCalendarInstaneByLoanId(loan.getId(), CalendarEntityType.LOANS.getValue()); final LocalDate calculatedRepaymentsStartingFromDate = getCalculatedRepaymentsStartingFromDate(loan.getDisbursementDate(), loan, calendarInstance); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); - final List holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), - loan.getDisbursementDate().toDate()); + final List holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan + .getDisbursementDate().toDate()); final WorkingDays workingDays = this.workingDaysRepository.findOne(); updateLoanCounters(loan, loan.getDisbursementDate()); final MonetaryCurrency currency = loan.getCurrency(); final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency); - final ChangedTransactionDetail changedTransactionDetail = loan.closeAsWrittenOff(command, defaultLoanLifecycleStateMachine(), changes, - existingTransactionIds, existingReversedTransactionIds, currentUser, this.loanScheduleFactory, + final ChangedTransactionDetail changedTransactionDetail = loan.closeAsWrittenOff(command, defaultLoanLifecycleStateMachine(), + changes, existingTransactionIds, existingReversedTransactionIds, currentUser, this.loanScheduleFactory, applicationCurrency, calculatedRepaymentsStartingFromDate, isHolidayEnabled, holidays, workingDays); LoanTransaction writeoff = changedTransactionDetail.getNewTransactionMappings().remove(0L); this.loanTransactionRepository.save(writeoff); @@ -851,8 +854,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final LocalDate calculatedRepaymentsStartingFromDate = getCalculatedRepaymentsStartingFromDate(loan.getDisbursementDate(), loan, calendarInstance); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); - final List holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), - loan.getDisbursementDate().toDate()); + final List holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan + .getDisbursementDate().toDate()); final WorkingDays workingDays = this.workingDaysRepository.findOne(); updateLoanCounters(loan, loan.getDisbursementDate()); @@ -860,8 +863,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency); ChangedTransactionDetail changedTransactionDetail = loan.close(command, defaultLoanLifecycleStateMachine(), changes, - existingTransactionIds, existingReversedTransactionIds,this.loanScheduleFactory, - applicationCurrency, calculatedRepaymentsStartingFromDate, isHolidayEnabled, holidays, workingDays); + existingTransactionIds, existingReversedTransactionIds, this.loanScheduleFactory, applicationCurrency, + calculatedRepaymentsStartingFromDate, isHolidayEnabled, holidays, workingDays); final LoanTransaction possibleClosingTransaction = changedTransactionDetail.getNewTransactionMappings().remove(0L); if (possibleClosingTransaction != null) { this.loanTransactionRepository.save(possibleClosingTransaction); @@ -871,7 +874,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue()); } this.loanRepository.save(loan); - final String noteText = command.stringValueOfParameterNamed("note"); if (StringUtils.isNotBlank(noteText)) { @@ -1000,7 +1002,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf if (changedTransactionDetail != null) { for (final Map.Entry mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { this.loanTransactionRepository.save(mapEntry.getValue()); - //update loan with references to the newly created transactions + // update loan with references to the newly created + // transactions loan.getLoanTransactions().add(mapEntry.getValue()); this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue()); } @@ -1809,12 +1812,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf checkClientOrGroupActive(loan); final List existingTransactionIds = new ArrayList(); final List existingReversedTransactionIds = new ArrayList(); - if(!loan.isClosedWrittenOff()){ - throw new PlatformServiceUnavailableException( - "error.msg.loan.status.not.written.off.update.not.allowed", "Loan :" + loanId - + " update not allowed as loan status is not written off", loanId); - } - ChangedTransactionDetail changedTransactionDetail =loan.undoWrittenOff(existingTransactionIds,existingReversedTransactionIds); + if (!loan.isClosedWrittenOff()) { throw new PlatformServiceUnavailableException( + "error.msg.loan.status.not.written.off.update.not.allowed", "Loan :" + loanId + + " update not allowed as loan status is not written off", loanId); } + ChangedTransactionDetail changedTransactionDetail = loan.undoWrittenOff(existingTransactionIds, existingReversedTransactionIds); if (changedTransactionDetail != null) { for (final Map.Entry mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { this.loanTransactionRepository.save(mapEntry.getValue()); @@ -1822,31 +1823,31 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf } } this.loanRepository.save(loan); - + postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); return new CommandProcessingResultBuilder() // - .withOfficeId(loan.getOfficeId()) // - .withClientId(loan.getClientId()) // - .withGroupId(loan.getGroupId()) // - .withLoanId(loanId) // - .build(); + .withOfficeId(loan.getOfficeId()) // + .withClientId(loan.getClientId()) // + .withGroupId(loan.getGroupId()) // + .withLoanId(loanId) // + .build(); } - + @Override @Transactional - public CommandProcessingResult updateDisbursementDateForTranche(final Long loanId,final Long disbursementId, final JsonCommand command){ - + public CommandProcessingResult updateDisbursementDateForTranche(final Long loanId, final Long disbursementId, final JsonCommand command) { + final Loan loan = this.loanAssembler.assembleFrom(loanId); checkClientOrGroupActive(loan); - LoanDisbursementDetails loanDisbursementDetails = loan.fetchLoanDisbursementsById(disbursementId); - this.loanEventApiJsonValidator.validateUpdateDisbursementDate(command.json(),loanDisbursementDetails); + LoanDisbursementDetails loanDisbursementDetails = loan.fetchLoanDisbursementsById(disbursementId); + this.loanEventApiJsonValidator.validateUpdateDisbursementDate(command.json(), loanDisbursementDetails); final CalendarInstance calendarInstance = this.calendarInstanceRepository.findCalendarInstaneByLoanId(loan.getId(), CalendarEntityType.LOANS.getValue()); final LocalDate calculatedRepaymentsStartingFromDate = getCalculatedRepaymentsStartingFromDate(loan.getDisbursementDate(), loan, calendarInstance); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); - final List holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), - loan.getDisbursementDate().toDate()); + final List holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan + .getDisbursementDate().toDate()); final WorkingDays workingDays = this.workingDaysRepository.findOne(); final MonetaryCurrency currency = loan.getCurrency(); @@ -1854,29 +1855,29 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final List existingTransactionIds = new ArrayList(); final List existingReversedTransactionIds = new ArrayList(); final Map changes = new LinkedHashMap(); - final ChangedTransactionDetail changedTransactionDetail = loan.updateDisbursementDateForTranche(loanDisbursementDetails,command, existingTransactionIds, existingReversedTransactionIds, - changes,this.loanScheduleFactory,applicationCurrency, calculatedRepaymentsStartingFromDate, isHolidayEnabled, holidays, workingDays); - + final ChangedTransactionDetail changedTransactionDetail = loan.updateDisbursementDateForTranche(loanDisbursementDetails, command, + existingTransactionIds, existingReversedTransactionIds, changes, this.loanScheduleFactory, applicationCurrency, + calculatedRepaymentsStartingFromDate, isHolidayEnabled, holidays, workingDays); + this.loanRepository.saveAndFlush(loan); - + if (changedTransactionDetail != null) { for (Map.Entry mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue()); } } - + postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); - + return new CommandProcessingResultBuilder() // - .withOfficeId(loan.getOfficeId()) // - .withClientId(loan.getClientId()) // - .withGroupId(loan.getGroupId()) // - .withLoanId(loanId) // - .with(changes) - .build(); + .withOfficeId(loan.getOfficeId()) // + .withClientId(loan.getClientId()) // + .withGroupId(loan.getGroupId()) // + .withLoanId(loanId) // + .with(changes).build(); } - + private void updateLoanTransaction(final Long loanTransactionId, final LoanTransaction newLoanTransaction) { final AccountTransfer transferTransaction = this.accountTransferRepository.findByToLoanTransactionId(loanTransactionId); if (transferTransaction != null) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/LoanProductConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/LoanProductConstants.java index bba40d795..76897ee88 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/LoanProductConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/LoanProductConstants.java @@ -1,10 +1,9 @@ package org.mifosplatform.portfolio.loanproduct; - public interface LoanProductConstants { - + public static final String useBorrowerCycleParameterName = "useBorrowerCycle"; - + public static final String principalVariationsForBorrowerCycleParameterName = "principalVariationsForBorrowerCycle"; public static final String interestRateVariationsForBorrowerCycleParameterName = "interestRateVariationsForBorrowerCycle"; public static final String numberOfRepaymentVariationsForBorrowerCycleParameterName = "numberOfRepaymentVariationsForBorrowerCycle"; @@ -15,44 +14,43 @@ public interface LoanProductConstants { public static final String valueConditionTypeParamName = "valueConditionType"; public static final String borrowerCycleNumberParamName = "borrowerCycleNumber"; public static final String borrowerCycleIdParameterName = "id"; - - + public static final String principalPerCycleParameterName = "principalPerCycle"; public static final String minPrincipalPerCycleParameterName = "minPrincipalPerCycle"; public static final String maxPrincipalPerCycleParameterName = "maxPrincipalPerCycle"; public static final String principalValueUsageConditionParamName = "principalValueUsageCondition"; public static final String principalCycleNumbersParamName = "principalCycleNumbers"; - + public static final String numberOfRepaymentsPerCycleParameterName = "numberOfRepaymentsPerCycle"; public static final String minNumberOfRepaymentsPerCycleParameterName = "minNumberOfRepaymentsPerCycle"; public static final String maxNumberOfRepaymentsPerCycleParameterName = "maxNumberOfRepaymentsPerCycle"; public static final String repaymentValueUsageConditionParamName = "repaymentValueUsageCondition"; public static final String repaymentCycleNumberParamName = "repaymentCycleNumber"; - + public static final String interestRatePerPeriodPerCycleParameterName = "interestRatePerPeriodPerCycle"; public static final String minInterestRatePerPeriodPerCycleParameterName = "minInterestRatePerPeriodPerCycle"; public static final String maxInterestRatePerPeriodPerCycleParameterName = "maxInterestRatePerPeriodPerCycle"; public static final String interestRateValueUsageConditionParamName = "interestRateValueUsageCondition"; public static final String interestRateCycleNumberParamName = "interestRateCycleNumber"; - + public static final String principal = "principal"; public static final String minPrincipal = "minPrincipal"; public static final String maxPrincipal = "maxPrincipalValue"; - + public static final String interestRatePerPeriod = "interestRatePerPeriod"; public static final String minInterestRatePerPeriod = "minInterestRatePerPeriod"; public static final String maxInterestRatePerPeriod = "maxInterestRatePerPeriod"; - + public static final String numberOfRepayments = "numberOfRepayments"; public static final String minNumberOfRepayments = "minNumberOfRepayments"; public static final String maxNumberOfRepayments = "maxNumberOfRepayments"; - + public static final String VALUE_CONDITION_END_WITH_ERROR = "condition.type.must.end.with.greterthan"; public static final String VALUE_CONDITION_START_WITH_ERROR = "condition.type.must.start.with.equal"; public static final String shortName = "shortName"; - + public static final String multiDisburseLoanParameterName = "multiDisburseLoan"; public static final String maxTrancheCountParameterName = "maxTrancheCount"; public static final String outstandingLoanBalanceParameterName = "outstandingLoanBalance"; - + } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java index a55cbe902..cf50b8370 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -63,8 +63,8 @@ import org.springframework.stereotype.Component; @Scope("singleton") public class LoanProductsApiResource { - private final Set LOAN_PRODUCT_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "name", "shortName", "description", "fundId", - "fundName", "includeInBorrowerCycle", "currency", "principal", "minPrincipal", "maxPrincipal", "numberOfRepayments", + private final Set LOAN_PRODUCT_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "name", "shortName", "description", + "fundId", "fundName", "includeInBorrowerCycle", "currency", "principal", "minPrincipal", "maxPrincipal", "numberOfRepayments", "minNumberOfRepayments", "maxNumberOfRepayments", "repaymentEvery", "repaymentFrequencyType", "graceOnPrincipalPayment", "graceOnInterestPayment", "graceOnInterestCharged", "interestRatePerPeriod", "minInterestRatePerPeriod", "maxInterestRatePerPeriod", "interestRateFrequencyType", "annualInterestRate", "amortizationType", "interestType", @@ -264,13 +264,14 @@ public class LoanProductsApiResource { final List accountingRuleTypeOptions = this.accountingDropdownReadPlatformService .retrieveAccountingRuleTypeOptions(); - - final List loanCycleValueConditionTypeOptions = this.dropdownReadPlatformService.retrieveLoanCycleValueConditionTypeOptions(); + + final List loanCycleValueConditionTypeOptions = this.dropdownReadPlatformService + .retrieveLoanCycleValueConditionTypeOptions(); return new LoanProductData(productData, chargeOptions, penaltyOptions, paymentTypeOptions, currencyOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions, repaymentFrequencyTypeOptions, interestRateFrequencyTypeOptions, fundOptions, transactionProcessingStrategyOptions, accountOptions, - accountingRuleTypeOptions,loanCycleValueConditionTypeOptions); + accountingRuleTypeOptions, loanCycleValueConditionTypeOptions); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductBorrowerCycleVariationData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductBorrowerCycleVariationData.java index 8cfb44891..f8a29ccbc 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductBorrowerCycleVariationData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductBorrowerCycleVariationData.java @@ -6,7 +6,6 @@ import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductParamType; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductValueConditionType; - public class LoanProductBorrowerCycleVariationData { @SuppressWarnings("unused") @@ -20,9 +19,8 @@ public class LoanProductBorrowerCycleVariationData { private final BigDecimal maxValue; private final BigDecimal defaultValue; - - public LoanProductBorrowerCycleVariationData(final Long id,final Integer borrowerCycleNumber,final EnumOptionData paramType,final EnumOptionData valueConditionType,final BigDecimal defaultValue,final BigDecimal minValue, - final BigDecimal maxValue) { + public LoanProductBorrowerCycleVariationData(final Long id, final Integer borrowerCycleNumber, final EnumOptionData paramType, + final EnumOptionData valueConditionType, final BigDecimal defaultValue, final BigDecimal minValue, final BigDecimal maxValue) { this.id = id; this.borrowerCycleNumber = borrowerCycleNumber; this.paramType = paramType; @@ -32,21 +30,18 @@ public class LoanProductBorrowerCycleVariationData { this.defaultValue = defaultValue; } - public LoanProductParamType getParamType(){ + public LoanProductParamType getParamType() { return LoanProductParamType.fromInt(this.paramType.getId().intValue()); } - public Integer getBorrowerCycleNumber() { return this.borrowerCycleNumber; } - public LoanProductValueConditionType getValueConditionType() { return LoanProductValueConditionType.fromInt(this.valueConditionType.getId().intValue()); } - public BigDecimal getDefaultValue() { return this.defaultValue; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java index 24d8ac99b..16eb461ec 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java @@ -74,7 +74,7 @@ public class LoanProductData { // charges private final Collection charges; - + private final Collection principalVariationsForBorrowerCycle; private final Collection interestRateVariationsForBorrowerCycle; private final Collection numberOfRepaymentVariationsForBorrowerCycle; @@ -106,10 +106,11 @@ public class LoanProductData { private final Map> accountingMappingOptions; @SuppressWarnings("unused") private final List valueConditionTypeOptions; - + private final Boolean multiDisburseLoan; private final Integer maxTrancheCount; private final BigDecimal outstandingLoanBalance; + /** * Used when returning lookup information about loan product for dropdowns. */ @@ -142,9 +143,12 @@ public class LoanProductData { final Integer graceOnInterestPayment = null; final Integer graceOnInterestCharged = null; final Collection charges = null; - final Collection principalVariations = new ArrayList(1); - final Collection interestRateVariations = new ArrayList(1); - final Collection numberOfRepaymentVariations = new ArrayList(1); + final Collection principalVariations = new ArrayList( + 1); + final Collection interestRateVariations = new ArrayList( + 1); + final Collection numberOfRepaymentVariations = new ArrayList( + 1); final EnumOptionData accountingType = null; final boolean includeInBorrowerCycle = false; final boolean useBorrowerCycle = false; @@ -153,19 +157,19 @@ public class LoanProductData { final String status = null; final String externalId = null; final Boolean multiDisburseLoan = null; - final Integer maxTrancheCount = null; + final Integer maxTrancheCount = null; final BigDecimal outstandingLoanBalance = null; - return new LoanProductData(id, name,shortName, description, currency, principal, minPrincipal, maxPrincipal, tolerance, numberOfRepayments, - minNumberOfRepayments, maxNumberOfRepayments, repaymentEvery, interestRatePerPeriod, minInterestRatePerPeriod, - maxInterestRatePerPeriod, annualInterestRate, repaymentFrequencyType, interestRateFrequencyType, amortizationType, - interestType, interestCalculationPeriodType, fundId, fundName, transactionProcessingStrategyId, + return new LoanProductData(id, name, shortName, description, currency, principal, minPrincipal, maxPrincipal, tolerance, + numberOfRepayments, minNumberOfRepayments, maxNumberOfRepayments, repaymentEvery, interestRatePerPeriod, + minInterestRatePerPeriod, maxInterestRatePerPeriod, annualInterestRate, repaymentFrequencyType, interestRateFrequencyType, + amortizationType, interestType, interestCalculationPeriodType, fundId, fundName, transactionProcessingStrategyId, transactionProcessingStrategyName, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, charges, - accountingType, includeInBorrowerCycle, useBorrowerCycle, startDate, closeDate, status, externalId, principalVariations, + accountingType, includeInBorrowerCycle, useBorrowerCycle, startDate, closeDate, status, externalId, principalVariations, interestRateVariations, numberOfRepaymentVariations, multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); } public static LoanProductData lookupWithCurrency(final Long id, final String name, final CurrencyData currency) { - final String shortName = null; + final String shortName = null; final String description = null; final BigDecimal principal = null; final BigDecimal minPrincipal = null; @@ -200,21 +204,23 @@ public class LoanProductData { final LocalDate closeDate = null; final String status = null; final String externalId = null; - - final Collection principalVariations = new ArrayList(1); - final Collection interestRateVariations = new ArrayList(1); - final Collection numberOfRepaymentVariations = new ArrayList(1); + + final Collection principalVariations = new ArrayList( + 1); + final Collection interestRateVariations = new ArrayList( + 1); + final Collection numberOfRepaymentVariations = new ArrayList( + 1); final Boolean multiDisburseLoan = null; - final Integer maxTrancheCount = null; + final Integer maxTrancheCount = null; final BigDecimal outstandingLoanBalance = null; - - return new LoanProductData(id, name, shortName, description, currency, principal, minPrincipal, maxPrincipal, tolerance, numberOfRepayments, - minNumberOfRepayments, maxNumberOfRepayments, repaymentEvery, interestRatePerPeriod, minInterestRatePerPeriod, - maxInterestRatePerPeriod, annualInterestRate, repaymentFrequencyType, interestRateFrequencyType, amortizationType, - interestType, interestCalculationPeriodType, fundId, fundName, transactionProcessingStrategyId, + return new LoanProductData(id, name, shortName, description, currency, principal, minPrincipal, maxPrincipal, tolerance, + numberOfRepayments, minNumberOfRepayments, maxNumberOfRepayments, repaymentEvery, interestRatePerPeriod, + minInterestRatePerPeriod, maxInterestRatePerPeriod, annualInterestRate, repaymentFrequencyType, interestRateFrequencyType, + amortizationType, interestType, interestCalculationPeriodType, fundId, fundName, transactionProcessingStrategyId, transactionProcessingStrategyName, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, charges, - accountingType, includeInBorrowerCycle, useBorrowerCycle, startDate, closeDate, status, externalId, principalVariations, + accountingType, includeInBorrowerCycle, useBorrowerCycle, startDate, closeDate, status, externalId, principalVariations, interestRateVariations, numberOfRepaymentVariations, multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); } @@ -253,10 +259,13 @@ public class LoanProductData { final Integer graceOnInterestCharged = null; final Collection charges = null; - final Collection principalVariationsForBorrowerCycle = new ArrayList(1); - final Collection interestRateVariationsForBorrowerCycle = new ArrayList(1); - final Collection numberOfRepaymentVariationsForBorrowerCycle = new ArrayList(1); - + final Collection principalVariationsForBorrowerCycle = new ArrayList( + 1); + final Collection interestRateVariationsForBorrowerCycle = new ArrayList( + 1); + final Collection numberOfRepaymentVariationsForBorrowerCycle = new ArrayList( + 1); + final EnumOptionData accountingType = AccountingEnumerations.accountingRuleType(AccountingRuleType.NONE); final boolean includeInBorrowerCycle = false; final boolean useBorrowerCycle = false; @@ -265,17 +274,17 @@ public class LoanProductData { final String status = null; final String externalId = null; final Boolean multiDisburseLoan = null; - final Integer maxTrancheCount = null; + final Integer maxTrancheCount = null; final BigDecimal outstandingLoanBalance = null; - - return new LoanProductData(id, name, shortName, description, currency, principal, minPrincipal, maxPrincipal, tolerance, numberOfRepayments, - minNumberOfRepayments, maxNumberOfRepayments, repaymentEvery, interestRatePerPeriod, minInterestRatePerPeriod, - maxInterestRatePerPeriod, annualInterestRate, repaymentFrequencyType, interestRateFrequencyType, amortizationType, - interestType, interestCalculationPeriodType, fundId, fundName, transactionProcessingStrategyId, + return new LoanProductData(id, name, shortName, description, currency, principal, minPrincipal, maxPrincipal, tolerance, + numberOfRepayments, minNumberOfRepayments, maxNumberOfRepayments, repaymentEvery, interestRatePerPeriod, + minInterestRatePerPeriod, maxInterestRatePerPeriod, annualInterestRate, repaymentFrequencyType, interestRateFrequencyType, + amortizationType, interestType, interestCalculationPeriodType, fundId, fundName, transactionProcessingStrategyId, transactionProcessingStrategyName, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, charges, - accountingType, includeInBorrowerCycle, useBorrowerCycle, startDate, closeDate, status, externalId, principalVariationsForBorrowerCycle, - interestRateVariationsForBorrowerCycle, numberOfRepaymentVariationsForBorrowerCycle, multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); + accountingType, includeInBorrowerCycle, useBorrowerCycle, startDate, closeDate, status, externalId, + principalVariationsForBorrowerCycle, interestRateVariationsForBorrowerCycle, numberOfRepaymentVariationsForBorrowerCycle, + multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); } public static LoanProductData withAccountingDetails(final LoanProductData productData, final Map accountingMappings, @@ -299,10 +308,11 @@ public class LoanProductData { final Long transactionProcessingStrategyId, final String transactionProcessingStrategyName, final Integer graceOnPrincipalPayment, final Integer graceOnInterestPayment, final Integer graceOnInterestCharged, final Collection charges, final EnumOptionData accountingType, final boolean includeInBorrowerCycle, - boolean useBorrowerCycle, final LocalDate startDate, final LocalDate closeDate, final String status, final String externalId, - Collection principalVariations, Collection interestRateVariations, - Collection numberOfRepaymentVariations, Boolean multiDisburseLoan, Integer maxTrancheCount, - BigDecimal outstandingLoanBalance) { + boolean useBorrowerCycle, final LocalDate startDate, final LocalDate closeDate, final String status, final String externalId, + Collection principalVariations, + Collection interestRateVariations, + Collection numberOfRepaymentVariations, Boolean multiDisburseLoan, + Integer maxTrancheCount, BigDecimal outstandingLoanBalance) { this.id = id; this.name = name; this.shortName = shortName; @@ -375,7 +385,7 @@ public class LoanProductData { final List repaymentFrequencyTypeOptions, final List interestRateFrequencyTypeOptions, final Collection fundOptions, final Collection transactionStrategyOptions, final Map> accountingMappingOptions, final List accountingRuleOptions, - final List valueConditionTypeOptions) { + final List valueConditionTypeOptions) { this.id = productData.id; this.name = productData.name; this.shortName = productData.shortName; @@ -613,32 +623,26 @@ public class LoanProductData { return this.id.hashCode(); } - public boolean useBorrowerCycle() { return this.useBorrowerCycle; } - public Collection getPrincipalVariationsForBorrowerCycle() { return this.principalVariationsForBorrowerCycle; } - public Collection getInterestRateVariationsForBorrowerCycle() { return this.interestRateVariationsForBorrowerCycle; } - public Collection getNumberOfRepaymentVariationsForBorrowerCycle() { return this.numberOfRepaymentVariationsForBorrowerCycle; } - public Boolean getMultiDisburseLoan() { return this.multiDisburseLoan; } - public BigDecimal getOutstandingLoanBalance() { return this.outstandingLoanBalance; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java index b850e51ef..79a452bfc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java @@ -58,7 +58,7 @@ import com.google.gson.JsonObject; @Entity @Table(name = "m_product_loan", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "unq_name"), @UniqueConstraint(columnNames = { "external_id" }, name = "external_id_UNIQUE"), - @UniqueConstraint(columnNames = { "short_name" }, name = "unq_short_name")}) + @UniqueConstraint(columnNames = { "short_name" }, name = "unq_short_name") }) public class LoanProduct extends AbstractPersistable { @ManyToOne @@ -71,7 +71,7 @@ public class LoanProduct extends AbstractPersistable { @Column(name = "name", nullable = false, unique = true) private String name; - + @Column(name = "short_name", nullable = false, unique = true) private String shortName; @@ -96,7 +96,7 @@ public class LoanProduct extends AbstractPersistable { @Column(name = "use_borrower_cycle") private boolean useBorrowerCycle; - + @Embedded private LoanProductTrancheDetails loanProducTrancheDetails; @@ -168,22 +168,22 @@ public class LoanProduct extends AbstractPersistable { populateBorrowerCyclevariations(command, loanProductBorrowerCycleVariations); } - - final boolean multiDisburseLoan = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.multiDisburseLoanParameterName); - Integer maxTrancheCount = null; - BigDecimal outstandingLoanBalance = null; - if(multiDisburseLoan){ - outstandingLoanBalance = command.bigDecimalValueOfParameterNamed(LoanProductConstants.outstandingLoanBalanceParameterName); - maxTrancheCount = command.integerValueOfParameterNamed(LoanProductConstants.maxTrancheCountParameterName); - } - - - return new LoanProduct(fund, loanTransactionProcessingStrategy, name, shortName, description, currency, principal, minPrincipal, maxPrincipal, - interestRatePerPeriod, minInterestRatePerPeriod, maxInterestRatePerPeriod, interestFrequencyType, annualInterestRate, - interestMethod, interestCalculationPeriodMethod, repaymentEvery, repaymentFrequencyType, numberOfRepayments, - minNumberOfRepayments, maxNumberOfRepayments, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, - amortizationMethod, inArrearsTolerance, productCharges, accountingRuleType, includeInBorrowerCycle, startDate, closeDate, - externalId, useBorrowerCycle, loanProductBorrowerCycleVariations,multiDisburseLoan,maxTrancheCount,outstandingLoanBalance); + final boolean multiDisburseLoan = command + .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.multiDisburseLoanParameterName); + Integer maxTrancheCount = null; + BigDecimal outstandingLoanBalance = null; + if (multiDisburseLoan) { + outstandingLoanBalance = command.bigDecimalValueOfParameterNamed(LoanProductConstants.outstandingLoanBalanceParameterName); + maxTrancheCount = command.integerValueOfParameterNamed(LoanProductConstants.maxTrancheCountParameterName); + } + + return new LoanProduct(fund, loanTransactionProcessingStrategy, name, shortName, description, currency, principal, minPrincipal, + maxPrincipal, interestRatePerPeriod, minInterestRatePerPeriod, maxInterestRatePerPeriod, interestFrequencyType, + annualInterestRate, interestMethod, interestCalculationPeriodMethod, repaymentEvery, repaymentFrequencyType, + numberOfRepayments, minNumberOfRepayments, maxNumberOfRepayments, graceOnPrincipalPayment, graceOnInterestPayment, + graceOnInterestCharged, amortizationMethod, inArrearsTolerance, productCharges, accountingRuleType, includeInBorrowerCycle, + startDate, closeDate, externalId, useBorrowerCycle, loanProductBorrowerCycleVariations, multiDisburseLoan, maxTrancheCount, + outstandingLoanBalance); } /** @@ -380,7 +380,7 @@ public class LoanProduct extends AbstractPersistable { } public LoanProduct(final Fund fund, final LoanTransactionProcessingStrategy transactionProcessingStrategy, final String name, - final String shortName, final String description, final MonetaryCurrency currency, final BigDecimal defaultPrincipal, + final String shortName, final String description, final MonetaryCurrency currency, final BigDecimal defaultPrincipal, final BigDecimal defaultMinPrincipal, final BigDecimal defaultMaxPrincipal, final BigDecimal defaultNominalInterestRatePerPeriod, final BigDecimal defaultMinNominalInterestRatePerPeriod, final BigDecimal defaultMaxNominalInterestRatePerPeriod, final PeriodFrequencyType interestPeriodFrequencyType, @@ -392,8 +392,8 @@ public class LoanProduct extends AbstractPersistable { final AmortizationMethod amortizationMethod, final BigDecimal inArrearsTolerance, final List charges, final AccountingRuleType accountingRuleType, final boolean includeInBorrowerCycle, final LocalDate startDate, final LocalDate closeDate, final String externalId, final boolean useBorrowerCycle, - final Set loanProductBorrowerCycleVariations, - final boolean multiDisburseLoan,final Integer maxTrancheCount, final BigDecimal outstandingLoanBalance) { + final Set loanProductBorrowerCycleVariations, final boolean multiDisburseLoan, + final Integer maxTrancheCount, final BigDecimal outstandingLoanBalance) { this.fund = fund; this.transactionProcessingStrategy = transactionProcessingStrategy; this.name = name.trim(); @@ -438,7 +438,7 @@ public class LoanProduct extends AbstractPersistable { for (LoanProductBorrowerCycleVariations borrowerCycleVariations : this.borrowerCycleVariations) { borrowerCycleVariations.updateLoanProduct(this); } - this.loanProducTrancheDetails = new LoanProductTrancheDetails(multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); + this.loanProducTrancheDetails = new LoanProductTrancheDetails(multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); } public MonetaryCurrency getCurrency() { @@ -498,7 +498,7 @@ public class LoanProduct extends AbstractPersistable { actualChanges.put(nameParamName, newValue); this.name = newValue; } - + final String shortNameParamName = LoanProductConstants.shortName; if (command.isChangeInStringParameterNamed(shortNameParamName, this.shortName)) { final String newValue = command.stringValueOfParameterNamed(shortNameParamName); @@ -606,7 +606,6 @@ public class LoanProduct extends AbstractPersistable { return actualChanges; } - public boolean isCashBasedAccountingEnabled() { return AccountingRuleType.CASH_BASED.getValue().equals(this.accountingRule); } @@ -695,15 +694,15 @@ public class LoanProduct extends AbstractPersistable { public boolean useBorrowerCycle() { return this.useBorrowerCycle; } - - public boolean isMultiDisburseLoan(){ + + public boolean isMultiDisburseLoan() { return this.loanProducTrancheDetails.isMultiDisburseLoan(); } - + public BigDecimal outstandingLoanBalance() { return this.loanProducTrancheDetails.outstandingLoanBalance(); } - + public Integer maxTrancheCount() { return this.loanProducTrancheDetails.maxTrancheCount(); } @@ -724,27 +723,27 @@ public class LoanProduct extends AbstractPersistable { borrowerCycleVariations.put(LoanProductConstants.principal, this.loanProductRelatedDetail.getPrincipal().getAmount()); borrowerCycleVariations.put(LoanProductConstants.interestRatePerPeriod, this.loanProductRelatedDetail.getNominalInterestRatePerPeriod()); - if(this.loanProductRelatedDetail.getNumberOfRepayments() != null){ + if (this.loanProductRelatedDetail.getNumberOfRepayments() != null) { borrowerCycleVariations.put(LoanProductConstants.numberOfRepayments, - BigDecimal.valueOf(this.loanProductRelatedDetail.getNumberOfRepayments())); + BigDecimal.valueOf(this.loanProductRelatedDetail.getNumberOfRepayments())); } - if(this.loanProductMinMaxConstraints !=null){ + if (this.loanProductMinMaxConstraints != null) { borrowerCycleVariations.put(LoanProductConstants.minPrincipal, this.loanProductMinMaxConstraints.getMinPrincipal()); borrowerCycleVariations.put(LoanProductConstants.maxPrincipal, this.loanProductMinMaxConstraints.getMaxPrincipal()); borrowerCycleVariations.put(LoanProductConstants.minInterestRatePerPeriod, this.loanProductMinMaxConstraints.getMinNominalInterestRatePerPeriod()); borrowerCycleVariations.put(LoanProductConstants.maxInterestRatePerPeriod, this.loanProductMinMaxConstraints.getMaxNominalInterestRatePerPeriod()); - - if(this.loanProductMinMaxConstraints.getMinNumberOfRepayments() != null){ + + if (this.loanProductMinMaxConstraints.getMinNumberOfRepayments() != null) { borrowerCycleVariations.put(LoanProductConstants.minNumberOfRepayments, BigDecimal.valueOf(this.loanProductMinMaxConstraints.getMinNumberOfRepayments())); } - - if(this.loanProductMinMaxConstraints.getMaxNumberOfRepayments() != null){ - borrowerCycleVariations.put(LoanProductConstants.maxNumberOfRepayments, - BigDecimal.valueOf(this.loanProductMinMaxConstraints.getMaxNumberOfRepayments())); + + if (this.loanProductMinMaxConstraints.getMaxNumberOfRepayments() != null) { + borrowerCycleVariations.put(LoanProductConstants.maxNumberOfRepayments, + BigDecimal.valueOf(this.loanProductMinMaxConstraints.getMaxNumberOfRepayments())); } } if (cycleNumber > 0) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductParamType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductParamType.java index 3d2acf685..4c9e6b4f1 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductParamType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductParamType.java @@ -48,16 +48,16 @@ public enum LoanProductParamType { } return loanProductParamType; } - - public boolean isParamTypePrincipal(){ + + public boolean isParamTypePrincipal() { return LoanProductParamType.PRINCIPAL.getValue().equals(this.value); } - public boolean isParamTypeInterestTate(){ + public boolean isParamTypeInterestTate() { return LoanProductParamType.INTERESTRATE.getValue().equals(this.value); } - public boolean isParamTypeRepayment(){ + public boolean isParamTypeRepayment() { return LoanProductParamType.REPAYMENT.getValue().equals(this.value); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductRelatedDetail.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductRelatedDetail.java index 0df266ca9..d52a6058d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductRelatedDetail.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductRelatedDetail.java @@ -38,7 +38,7 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche @Column(name = "principal_amount", scale = 6, precision = 19, nullable = false) private BigDecimal principal; - + @Column(name = "nominal_interest_rate_per_period", scale = 6, precision = 19, nullable = false) private BigDecimal nominalInterestRatePerPeriod; @@ -155,9 +155,10 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche return Money.of(this.currency, this.principal); } - public void setPrincipal(BigDecimal principal){ + public void setPrincipal(BigDecimal principal) { this.principal = principal; } + public Money getInArrearsTolerance() { return Money.of(this.currency, this.inArrearsTolerance); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductTrancheDetails.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductTrancheDetails.java index 3144a225b..2281b3ecb 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductTrancheDetails.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductTrancheDetails.java @@ -59,17 +59,14 @@ public class LoanProductTrancheDetails { } } - public boolean isMultiDisburseLoan() { return this.multiDisburseLoan; } - public BigDecimal outstandingLoanBalance() { return this.outstandingLoanBalance; } - public Integer maxTrancheCount() { return this.maxTrancheCount; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductValueConditionType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductValueConditionType.java index 531821660..66f04d836 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductValueConditionType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductValueConditionType.java @@ -8,10 +8,10 @@ package org.mifosplatform.portfolio.loanproduct.domain; public enum LoanProductValueConditionType { INVALID(0, "LoanProductParamType.invalid"), // -// LESSTHAN(1,"LoanProductValueConditionType.lessthan"),// + // LESSTHAN(1,"LoanProductValueConditionType.lessthan"),// EQUAL(2, "LoanProductValueConditionType.equal"), // GRETERTHAN(3, "LoanProductValueConditionType.greterthan"); // - + private final Integer value; private final String code; @@ -45,12 +45,12 @@ public enum LoanProductValueConditionType { } return loanProductParamType; } - - public boolean isValueConditionTypeEqual(){ + + public boolean isValueConditionTypeEqual() { return LoanProductValueConditionType.EQUAL.getValue().equals(this.value); } - public boolean isValueConditionTypeGreterThan(){ + public boolean isValueConditionTypeGreterThan() { return LoanProductValueConditionType.GRETERTHAN.getValue().equals(this.value); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java index 634a13046..083720464 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java @@ -37,7 +37,7 @@ public class LoanTransactionProcessingStrategy extends AbstractPersistable public boolean isHeavensfamilyStrategy() { return "heavensfamily-strategy".equalsIgnoreCase(this.code); } - + public boolean isEarlyPaymentStrategy() { return "early-repayment-strategy".equalsIgnoreCase(this.code); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/serialization/LoanProductDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/serialization/LoanProductDataValidator.java index 91597ddce..a4977eacc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/serialization/LoanProductDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/serialization/LoanProductDataValidator.java @@ -55,10 +55,11 @@ public final class LoanProductDataValidator { LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(), - LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(),LoanProductConstants.useBorrowerCycleParameterName, - LoanProductConstants.principalVariationsForBorrowerCycleParameterName,LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, - LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName,LoanProductConstants.shortName, - LoanProductConstants.multiDisburseLoanParameterName,LoanProductConstants.outstandingLoanBalanceParameterName, + LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), LoanProductConstants.useBorrowerCycleParameterName, + LoanProductConstants.principalVariationsForBorrowerCycleParameterName, + LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, + LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, LoanProductConstants.shortName, + LoanProductConstants.multiDisburseLoanParameterName, LoanProductConstants.outstandingLoanBalanceParameterName, LoanProductConstants.maxTrancheCountParameterName)); private final FromJsonHelper fromApiJsonHelper; @@ -81,7 +82,7 @@ public final class LoanProductDataValidator { final String name = this.fromApiJsonHelper.extractStringNamed("name", element); baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100); - + final String shortName = this.fromApiJsonHelper.extractStringNamed(LoanProductConstants.shortName, element); baseDataValidator.reset().parameter(LoanProductConstants.shortName).value(shortName).notBlank().notExceedingLengthOf(4); @@ -319,16 +320,17 @@ public final class LoanProductDataValidator { baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue()) .value(receivablePenaltyAccountId).notNull().integerGreaterThanZero(); } - + if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.useBorrowerCycleParameterName, element)) { - final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.useBorrowerCycleParameterName, element); + final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.useBorrowerCycleParameterName, + element); baseDataValidator.reset().parameter(LoanProductConstants.useBorrowerCycleParameterName).value(useBorrowerCycle).ignoreIfNull() .validateForBooleanValue(); - if(useBorrowerCycle){ - validateBorrowerCycleVariations(element, baseDataValidator); + if (useBorrowerCycle) { + validateBorrowerCycleVariations(element, baseDataValidator); } } - + validateMultiDisburseLoanData(baseDataValidator, element); throwExceptionIfValidationWarningsExist(dataValidationErrors); @@ -338,23 +340,26 @@ public final class LoanProductDataValidator { Boolean multiDisburseLoan = false; if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.multiDisburseLoanParameterName, element)) { multiDisburseLoan = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.multiDisburseLoanParameterName, element); - baseDataValidator.reset().parameter(LoanProductConstants.multiDisburseLoanParameterName).value(multiDisburseLoan).ignoreIfNull() - .validateForBooleanValue(); + baseDataValidator.reset().parameter(LoanProductConstants.multiDisburseLoanParameterName).value(multiDisburseLoan) + .ignoreIfNull().validateForBooleanValue(); } - - if(multiDisburseLoan){ + + if (multiDisburseLoan) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.outstandingLoanBalanceParameterName, element)) { - final BigDecimal outstandingLoanBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanProductConstants.outstandingLoanBalanceParameterName, - element); - baseDataValidator.reset().parameter(LoanProductConstants.outstandingLoanBalanceParameterName).value(outstandingLoanBalance).ignoreIfNull() - .zeroOrPositiveAmount(); + final BigDecimal outstandingLoanBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( + LoanProductConstants.outstandingLoanBalanceParameterName, element); + baseDataValidator.reset().parameter(LoanProductConstants.outstandingLoanBalanceParameterName).value(outstandingLoanBalance) + .ignoreIfNull().zeroOrPositiveAmount(); } - - final Integer maxTrancheCount = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.maxTrancheCountParameterName, element,Locale.getDefault()); - baseDataValidator.reset().parameter(LoanProductConstants.maxTrancheCountParameterName).value(maxTrancheCount).notNull().integerGreaterThanZero(); - + + final Integer maxTrancheCount = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.maxTrancheCountParameterName, + element, Locale.getDefault()); + baseDataValidator.reset().parameter(LoanProductConstants.maxTrancheCountParameterName).value(maxTrancheCount).notNull() + .integerGreaterThanZero(); + final Integer interestType = this.fromApiJsonHelper.extractIntegerNamed("interestType", element, Locale.getDefault()); - baseDataValidator.reset().parameter("interestType").value(interestType).ignoreIfNull().integerSameAsNumber(InterestMethod.DECLINING_BALANCE.getValue()); + baseDataValidator.reset().parameter("interestType").value(interestType).ignoreIfNull() + .integerSameAsNumber(InterestMethod.DECLINING_BALANCE.getValue()); } } @@ -372,7 +377,7 @@ public final class LoanProductDataValidator { final String name = this.fromApiJsonHelper.extractStringNamed("name", element); baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100); } - + if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.shortName, element)) { final String shortName = this.fromApiJsonHelper.extractStringNamed(LoanProductConstants.shortName, element); baseDataValidator.reset().parameter(LoanProductConstants.shortName).value(shortName).notBlank().notExceedingLengthOf(4); @@ -601,17 +606,16 @@ public final class LoanProductDataValidator { validateMinMaxConstraints(element, baseDataValidator, loanProduct); if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.useBorrowerCycleParameterName, element)) { - final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.useBorrowerCycleParameterName, element); + final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.useBorrowerCycleParameterName, + element); baseDataValidator.reset().parameter(LoanProductConstants.useBorrowerCycleParameterName).value(useBorrowerCycle).ignoreIfNull() .validateForBooleanValue(); - if(useBorrowerCycle){ + if (useBorrowerCycle) { validateBorrowerCycleVariations(element, baseDataValidator); } } - - validateMultiDisburseLoanData(baseDataValidator, element); - + validateMultiDisburseLoanData(baseDataValidator, element); throwExceptionIfValidationWarningsExist(dataValidationErrors); } @@ -696,11 +700,11 @@ public final class LoanProductDataValidator { validateNominalInterestRatePerPeriodMinMaxConstraint(element, loanProduct, baseDataValidator); } - + public void validateMinMaxConstraints(final JsonElement element, final DataValidatorBuilder baseDataValidator, - final LoanProduct loanProduct,Integer cycleNumber) { - - final Map minmaxValues = loanProduct.fetchBorrowerCycleVariationsForCycleNumber(cycleNumber); + final LoanProduct loanProduct, Integer cycleNumber) { + + final Map minmaxValues = loanProduct.fetchBorrowerCycleVariationsForCycleNumber(cycleNumber); final String principalParameterName = "principal"; BigDecimal principalAmount = null; BigDecimal minPrincipalAmount = null; @@ -710,7 +714,7 @@ public final class LoanProductDataValidator { minPrincipalAmount = minmaxValues.get(LoanProductConstants.minPrincipal); maxPrincipalAmount = minmaxValues.get(LoanProductConstants.maxPrincipal); } - + if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) && (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1)) { baseDataValidator.reset().parameter(principalParameterName).value(principalAmount) @@ -719,25 +723,24 @@ public final class LoanProductDataValidator { if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) { baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notLessThanMin(minPrincipalAmount); } else if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) { - baseDataValidator.reset().parameter(principalParameterName).value(principalAmount) - .notGreaterThanMax(maxPrincipalAmount); + baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notGreaterThanMax(maxPrincipalAmount); } } - + final String numberOfRepaymentsParameterName = "numberOfRepayments"; Integer maxNumberOfRepayments = null; Integer minNumberOfRepayments = null; Integer numberOfRepayments = null; if (this.fromApiJsonHelper.parameterExists(numberOfRepaymentsParameterName, element)) { numberOfRepayments = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(numberOfRepaymentsParameterName, element); - if(minmaxValues.get(LoanProductConstants.minNumberOfRepayments)!=null){ + if (minmaxValues.get(LoanProductConstants.minNumberOfRepayments) != null) { minNumberOfRepayments = minmaxValues.get(LoanProductConstants.minNumberOfRepayments).intValueExact(); } - if(minmaxValues.get(LoanProductConstants.maxNumberOfRepayments)!=null){ + if (minmaxValues.get(LoanProductConstants.maxNumberOfRepayments) != null) { maxNumberOfRepayments = minmaxValues.get(LoanProductConstants.maxNumberOfRepayments).intValueExact(); } } - + if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) == 1) { if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) { baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) @@ -750,9 +753,7 @@ public final class LoanProductDataValidator { baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) .notLessThanMin(minNumberOfRepayments); } - - - + final String interestRatePerPeriodParameterName = "interestRatePerPeriod"; BigDecimal interestRatePerPeriod = null; BigDecimal minInterestRatePerPeriod = null; @@ -774,8 +775,7 @@ public final class LoanProductDataValidator { baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod) .notLessThanMin(minInterestRatePerPeriod); } - - + } private void validatePrincipalMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct, @@ -979,48 +979,54 @@ public final class LoanProductDataValidator { private void validateBorrowerCyclePrincipalVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) { validateBorrowerCycleVariations(element, baseDataValidator, LoanProductConstants.principalVariationsForBorrowerCycleParameterName, - LoanProductConstants.principalPerCycleParameterName, LoanProductConstants.minPrincipalPerCycleParameterName, - LoanProductConstants.maxPrincipalPerCycleParameterName, LoanProductConstants.principalValueUsageConditionParamName, + LoanProductConstants.principalPerCycleParameterName, LoanProductConstants.minPrincipalPerCycleParameterName, + LoanProductConstants.maxPrincipalPerCycleParameterName, LoanProductConstants.principalValueUsageConditionParamName, LoanProductConstants.principalCycleNumbersParamName); } private void validateBorrowerCycleRepaymentVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) { - validateBorrowerCycleVariations(element, baseDataValidator, LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, - LoanProductConstants.numberOfRepaymentsPerCycleParameterName, LoanProductConstants.minNumberOfRepaymentsPerCycleParameterName, - LoanProductConstants.maxNumberOfRepaymentsPerCycleParameterName, LoanProductConstants.repaymentValueUsageConditionParamName, - LoanProductConstants.repaymentCycleNumberParamName); + validateBorrowerCycleVariations(element, baseDataValidator, + LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, + LoanProductConstants.numberOfRepaymentsPerCycleParameterName, + LoanProductConstants.minNumberOfRepaymentsPerCycleParameterName, + LoanProductConstants.maxNumberOfRepaymentsPerCycleParameterName, + LoanProductConstants.repaymentValueUsageConditionParamName, LoanProductConstants.repaymentCycleNumberParamName); } private void validateBorrowerCycleInterestVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) { - validateBorrowerCycleVariations(element, baseDataValidator, LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, - LoanProductConstants.interestRatePerPeriodPerCycleParameterName,LoanProductConstants.minInterestRatePerPeriodPerCycleParameterName, - LoanProductConstants.maxInterestRatePerPeriodPerCycleParameterName,LoanProductConstants.interestRateValueUsageConditionParamName, - LoanProductConstants.interestRateCycleNumberParamName); + validateBorrowerCycleVariations(element, baseDataValidator, + LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, + LoanProductConstants.interestRatePerPeriodPerCycleParameterName, + LoanProductConstants.minInterestRatePerPeriodPerCycleParameterName, + LoanProductConstants.maxInterestRatePerPeriodPerCycleParameterName, + LoanProductConstants.interestRateValueUsageConditionParamName, LoanProductConstants.interestRateCycleNumberParamName); } private void validateBorrowerCycleVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator, - final String variationParameterName,final String defaultParameterName,final String minParameterName, - final String maxParameterName,final String valueUsageConditionParamName,final String cycleNumbersParamName) { + final String variationParameterName, final String defaultParameterName, final String minParameterName, + final String maxParameterName, final String valueUsageConditionParamName, final String cycleNumbersParamName) { final JsonObject topLevelJsonElement = element.getAsJsonObject(); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); Integer lastCycleNumber = 0; LoanProductValueConditionType lastConditionType = LoanProductValueConditionType.EQUAL; if (this.fromApiJsonHelper.parameterExists(variationParameterName, element)) { - final JsonArray variationArray= this.fromApiJsonHelper.extractJsonArrayNamed(variationParameterName, element); + final JsonArray variationArray = this.fromApiJsonHelper.extractJsonArrayNamed(variationParameterName, element); if (variationArray != null && variationArray.size() > 0) { int i = 0; do { final JsonObject jsonObject = variationArray.get(i).getAsJsonObject(); - BigDecimal defaultValue = this.fromApiJsonHelper.extractBigDecimalNamed( - LoanProductConstants.defaultValueParameterName, jsonObject,locale); - BigDecimal minValue = this.fromApiJsonHelper.extractBigDecimalNamed( - LoanProductConstants.minValueParameterName, jsonObject,locale); - BigDecimal maxValue = this.fromApiJsonHelper.extractBigDecimalNamed( - LoanProductConstants.maxValueParameterName, jsonObject,locale); - Integer cycleNumber = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.borrowerCycleNumberParamName, jsonObject, locale); - Integer valueUsageCondition = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.valueConditionTypeParamName, jsonObject, locale); - + BigDecimal defaultValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.defaultValueParameterName, + jsonObject, locale); + BigDecimal minValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.minValueParameterName, + jsonObject, locale); + BigDecimal maxValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.maxValueParameterName, + jsonObject, locale); + Integer cycleNumber = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.borrowerCycleNumberParamName, + jsonObject, locale); + Integer valueUsageCondition = this.fromApiJsonHelper.extractIntegerNamed( + LoanProductConstants.valueConditionTypeParamName, jsonObject, locale); + baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue).notBlank(); if (minValue != null) { baseDataValidator.reset().parameter(minParameterName).value(minValue).notGreaterThanMax(maxValue); @@ -1045,39 +1051,45 @@ public final class LoanProductDataValidator { if (valueUsageCondition != null) { conditionType = LoanProductValueConditionType.fromInt(valueUsageCondition); } - baseDataValidator.reset().parameter(valueUsageConditionParamName).value(valueUsageCondition).notNull().inMinMaxRange(LoanProductValueConditionType.EQUAL.getValue(), - LoanProductValueConditionType.GRETERTHAN.getValue()); + baseDataValidator + .reset() + .parameter(valueUsageConditionParamName) + .value(valueUsageCondition) + .notNull() + .inMinMaxRange(LoanProductValueConditionType.EQUAL.getValue(), + LoanProductValueConditionType.GRETERTHAN.getValue()); if (lastConditionType.equals(LoanProductValueConditionType.EQUAL) && conditionType.equals(LoanProductValueConditionType.GRETERTHAN)) { - if(lastCycleNumber == 0){ - baseDataValidator.reset().parameter(cycleNumbersParamName).failWithCode(LoanProductConstants.VALUE_CONDITION_START_WITH_ERROR); + if (lastCycleNumber == 0) { + baseDataValidator.reset().parameter(cycleNumbersParamName) + .failWithCode(LoanProductConstants.VALUE_CONDITION_START_WITH_ERROR); lastCycleNumber = 1; } baseDataValidator.reset().parameter(cycleNumbersParamName).value(cycleNumber).notNull() .integerSameAsNumber(lastCycleNumber); } else if (lastConditionType.equals(LoanProductValueConditionType.EQUAL)) { baseDataValidator.reset().parameter(cycleNumbersParamName).value(cycleNumber).notNull() - .integerSameAsNumber(lastCycleNumber+1); + .integerSameAsNumber(lastCycleNumber + 1); } else if (lastConditionType.equals(LoanProductValueConditionType.GRETERTHAN)) { baseDataValidator.reset().parameter(cycleNumbersParamName).value(cycleNumber).notNull() .integerGreaterThanNumber(lastCycleNumber); } - if(conditionType!=null){ + if (conditionType != null) { lastConditionType = conditionType; } - if(cycleNumber!=null){ + if (cycleNumber != null) { lastCycleNumber = cycleNumber; } i++; } while (i < variationArray.size()); - if(!lastConditionType.equals(LoanProductValueConditionType.GRETERTHAN)){ - baseDataValidator.reset().parameter(cycleNumbersParamName).failWithCode(LoanProductConstants.VALUE_CONDITION_END_WITH_ERROR); + if (!lastConditionType.equals(LoanProductValueConditionType.GRETERTHAN)) { + baseDataValidator.reset().parameter(cycleNumbersParamName) + .failWithCode(LoanProductConstants.VALUE_CONDITION_END_WITH_ERROR); } } } - } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java index bb7d2927c..2c0201adf 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java @@ -102,14 +102,14 @@ public class LoanDropdownReadPlatformServiceImpl implements LoanDropdownReadPlat return strategyOptions; } - + @Override public List retrieveLoanCycleValueConditionTypeOptions() { - final List repaymentFrequencyOptions = Arrays.asList(loanCycleValueConditionType(LoanProductValueConditionType.EQUAL), + final List repaymentFrequencyOptions = Arrays.asList( + loanCycleValueConditionType(LoanProductValueConditionType.EQUAL), loanCycleValueConditionType(LoanProductValueConditionType.GRETERTHAN)); return repaymentFrequencyOptions; } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java index ecd949165..b8d7726ab 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java @@ -314,13 +314,13 @@ public class LoanEnumerations { } return optionData; } - + public static EnumOptionData status(final LoanStatusEnumData status) { - + Long id = status.id(); String code = status.code(); String value = status.value(); - + return new EnumOptionData(id, code, value); } @@ -381,7 +381,7 @@ public class LoanEnumerations { return optionData; } - + public static EnumOptionData loanCycleValueConditionType(final int id) { return loanCycleValueConditionType(LoanProductValueConditionType.fromInt(id)); } @@ -390,14 +390,16 @@ public class LoanEnumerations { EnumOptionData optionData = null; switch (type) { case EQUAL: - optionData = new EnumOptionData(LoanProductValueConditionType.EQUAL.getValue().longValue(), LoanProductValueConditionType.EQUAL.getCode(), "equals"); + optionData = new EnumOptionData(LoanProductValueConditionType.EQUAL.getValue().longValue(), + LoanProductValueConditionType.EQUAL.getCode(), "equals"); break; case GRETERTHAN: - optionData = new EnumOptionData(LoanProductValueConditionType.GRETERTHAN.getValue().longValue(), LoanProductValueConditionType.GRETERTHAN.getCode(), "greter than"); + optionData = new EnumOptionData(LoanProductValueConditionType.GRETERTHAN.getValue().longValue(), + LoanProductValueConditionType.GRETERTHAN.getCode(), "greter than"); break; default: - optionData = new EnumOptionData(LoanProductValueConditionType.INVALID.getValue().longValue(), LoanProductValueConditionType.INVALID.getCode(), - "Invalid"); + optionData = new EnumOptionData(LoanProductValueConditionType.INVALID.getValue().longValue(), + LoanProductValueConditionType.INVALID.getCode(), "Invalid"); break; } return optionData; @@ -411,22 +413,25 @@ public class LoanEnumerations { EnumOptionData optionData = null; switch (type) { case PRINCIPAL: - optionData = new EnumOptionData(LoanProductParamType.PRINCIPAL.getValue().longValue(), LoanProductParamType.PRINCIPAL.getCode(), "principal"); + optionData = new EnumOptionData(LoanProductParamType.PRINCIPAL.getValue().longValue(), + LoanProductParamType.PRINCIPAL.getCode(), "principal"); break; case INTERESTRATE: - optionData = new EnumOptionData(LoanProductParamType.INTERESTRATE.getValue().longValue(),LoanProductParamType.INTERESTRATE.getCode(), "Interest rate"); + optionData = new EnumOptionData(LoanProductParamType.INTERESTRATE.getValue().longValue(), + LoanProductParamType.INTERESTRATE.getCode(), "Interest rate"); break; case REPAYMENT: - optionData = new EnumOptionData(LoanProductParamType.REPAYMENT.getValue().longValue(),LoanProductParamType.REPAYMENT.getCode(), "repayment"); + optionData = new EnumOptionData(LoanProductParamType.REPAYMENT.getValue().longValue(), + LoanProductParamType.REPAYMENT.getCode(), "repayment"); break; default: - optionData = new EnumOptionData(LoanProductParamType.INVALID.getValue().longValue(), LoanProductParamType.INVALID.getCode(), - "Invalid"); + optionData = new EnumOptionData(LoanProductParamType.INVALID.getValue().longValue(), + LoanProductParamType.INVALID.getCode(), "Invalid"); break; } return optionData; } - + public static EnumOptionData loanvariationType(final int id) { return loanvariationType(LoanTermVariationType.fromInt(id)); } @@ -435,16 +440,15 @@ public class LoanEnumerations { EnumOptionData optionData = null; switch (type) { case EMI_AMOUNT: - optionData = new EnumOptionData(LoanTermVariationType.EMI_AMOUNT.getValue().longValue(), LoanTermVariationType.EMI_AMOUNT.getCode(), "emiAmount"); + optionData = new EnumOptionData(LoanTermVariationType.EMI_AMOUNT.getValue().longValue(), + LoanTermVariationType.EMI_AMOUNT.getCode(), "emiAmount"); break; default: - optionData = new EnumOptionData(LoanTermVariationType.INVALID.getValue().longValue(), LoanTermVariationType.INVALID.getCode(), - "Invalid"); + optionData = new EnumOptionData(LoanTermVariationType.INVALID.getValue().longValue(), + LoanTermVariationType.INVALID.getCode(), "Invalid"); break; } return optionData; } - - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java index afdf71c25..fc2ef5abd 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java @@ -214,7 +214,6 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo } } } - final Boolean multiDisburseLoan = rs.getBoolean("multiDisburseLoan"); final Integer maxTrancheCount = rs.getInt("maxTrancheCount"); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java index 7b4ee21bb..72306489c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java @@ -240,8 +240,8 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro } else if (realCause.getMessage().contains("unq_short_name")) { final String shortName = command.stringValueOfParameterNamed("shortName"); - throw new PlatformDataIntegrityException("error.msg.product.loan.duplicate.short.name", "Loan product with short name `" + shortName - + "` already exists", "shortName", shortName); + throw new PlatformDataIntegrityException("error.msg.product.loan.duplicate.short.name", "Loan product with short name `" + + shortName + "` already exists", "shortName", shortName); } else if (realCause.getMessage().contains("Duplicate entry")) { final Object[] args = null; throw new PlatformDataIntegrityException("error.msg.product.loan.duplicate.charge", diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/api/MeetingsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/api/MeetingsApiResource.java index f1d1cde1b..3559e486b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/api/MeetingsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/api/MeetingsApiResource.java @@ -109,8 +109,10 @@ public class MeetingsApiResource { if (calendarId != null) { calendarData = this.calendarReadPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId); final boolean withHistory = true; - final Collection recurringDates = this.calendarReadPlatformService.generateRecurringDates(calendarData, withHistory, DateUtils.getLocalDateOfTenant()); - final Collection nextTenRecurringDates = this.calendarReadPlatformService.generateNextTenRecurringDates(calendarData); + final Collection recurringDates = this.calendarReadPlatformService.generateRecurringDates(calendarData, withHistory, + DateUtils.getLocalDateOfTenant()); + final Collection nextTenRecurringDates = this.calendarReadPlatformService + .generateNextTenRecurringDates(calendarData); final LocalDate recentEligibleMeetingDate = null; calendarData = CalendarData.withRecurringDates(calendarData, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/data/MeetingData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/data/MeetingData.java index 022412809..6615a8958 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/data/MeetingData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/data/MeetingData.java @@ -70,5 +70,5 @@ public class MeetingData { public LocalDate getMeetingDate() { return this.meetingDate; } - + } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformService.java index 962473094..499b76554 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformService.java @@ -18,6 +18,6 @@ public interface MeetingReadPlatformService { Collection retrieveMeetingsByEntityByCalendarType(final Long entityId, final Integer entityTypeId, final List calendarTypeOptions); - + MeetingData retrieveLastMeeting(Long calendarInstanceId); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformServiceImpl.java index b461fc652..84b7a07a1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/meeting/service/MeetingReadPlatformServiceImpl.java @@ -36,8 +36,8 @@ public class MeetingReadPlatformServiceImpl implements MeetingReadPlatformServic public String schema() { - return " select m.id as id, m.meeting_date as meetingDate from m_meeting m " + - "inner join m_calendar_instance ci on m.calendar_instance_id = ci.id "; + return " select m.id as id, m.meeting_date as meetingDate from m_meeting m " + + "inner join m_calendar_instance ci on m.calendar_instance_id = ci.id "; } @Override diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsAccountTransactionType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsAccountTransactionType.java index 28b196dcb..42d1bf828 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsAccountTransactionType.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsAccountTransactionType.java @@ -24,8 +24,7 @@ public enum SavingsAccountTransactionType { INITIATE_TRANSFER(12, "savingsAccountTransactionType.initiateTransfer"), // APPROVE_TRANSFER(13, "savingsAccountTransactionType.approveTransfer"), // WITHDRAW_TRANSFER(14, "savingsAccountTransactionType.withdrawTransfer"), // - REJECT_TRANSFER(15, "savingsAccountTransactionType.rejectTransfer"), - WRITTEN_OFF(16, "savingsAccountTransactionType.writtenoff"), // + REJECT_TRANSFER(15, "savingsAccountTransactionType.rejectTransfer"), WRITTEN_OFF(16, "savingsAccountTransactionType.writtenoff"), // OVERDRAFT_INTEREST(17, "savingsAccountTransactionType.overdraftInterest"); // private final Integer value; @@ -116,8 +115,8 @@ public enum SavingsAccountTransactionType { public boolean isPayCharge() { return this.value.equals(SavingsAccountTransactionType.PAY_CHARGE.getValue()); } - - public boolean isChargeTransaction(){ + + public boolean isChargeTransaction() { return isPayCharge() || isWithdrawalFee() || isAnnualFee(); } @@ -140,12 +139,12 @@ public enum SavingsAccountTransactionType { public boolean isTransferWithdrawal() { return this.value.equals(SavingsAccountTransactionType.WITHDRAW_TRANSFER.getValue()); } - - public boolean isWrittenoff(){ + + public boolean isWrittenoff() { return this.value.equals(SavingsAccountTransactionType.WRITTEN_OFF.getValue()); } - - public boolean isIncomeFromInterest(){ + + public boolean isIncomeFromInterest() { return this.value.equals(SavingsAccountTransactionType.OVERDRAFT_INTEREST.getValue()); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsApiConstants.java index b0a455e80..032324f50 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsApiConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/SavingsApiConstants.java @@ -82,7 +82,7 @@ public class SavingsApiConstants { public static final String withdrawalFeeAmountParamName = "withdrawalFeeAmount"; public static final String withdrawalFeeTypeParamName = "withdrawalFeeType"; public static final String withdrawalFeeForTransfersParamName = "withdrawalFeeForTransfers"; - public static final String feeAmountParamName = "feeAmount";//to be deleted + public static final String feeAmountParamName = "feeAmount";// to be deleted public static final String feeOnMonthDayParamName = "feeOnMonthDay"; public static final String feeIntervalParamName = "feeInterval"; public static final String accountingRuleParamName = "accountingRule"; @@ -125,19 +125,18 @@ public class SavingsApiConstants { public static final String chargePaymentModeParamName = "chargePaymentMode"; public static final String noteParamName = "note"; - - //Savings account associations + + // Savings account associations public static final String transactions = "transactions"; public static final String charges = "charges"; - public static final Set SAVINGS_PRODUCT_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, - monthDayFormatParamName, nameParamName, shortNameParamName, descriptionParamName, currencyCodeParamName, digitsAfterDecimalParamName, - inMultiplesOfParamName, nominalAnnualInterestRateParamName, interestCompoundingPeriodTypeParamName, - interestPostingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName, - minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName, - withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, withdrawalFeeForTransfersParamName, feeAmountParamName, - feeOnMonthDayParamName, accountingRuleParamName, chargesParamName, + monthDayFormatParamName, nameParamName, shortNameParamName, descriptionParamName, currencyCodeParamName, + digitsAfterDecimalParamName, inMultiplesOfParamName, nominalAnnualInterestRateParamName, + interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName, + interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, + lockinPeriodFrequencyTypeParamName, withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, + withdrawalFeeForTransfersParamName, feeAmountParamName, feeOnMonthDayParamName, accountingRuleParamName, chargesParamName, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), @@ -148,8 +147,7 @@ public class SavingsApiConstants { SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), - SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), - allowOverdraftParamName,overdraftLimitParamName)); + SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), allowOverdraftParamName, overdraftLimitParamName)); /** * These parameters will match the class level parameters of @@ -157,7 +155,7 @@ public class SavingsApiConstants { * parameters to match those of request parameters. */ public static final Set SAVINGS_PRODUCT_RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList(idParamName, - nameParamName, shortNameParamName, descriptionParamName, "currency", digitsAfterDecimalParamName, inMultiplesOfParamName, + nameParamName, shortNameParamName, descriptionParamName, "currency", digitsAfterDecimalParamName, inMultiplesOfParamName, nominalAnnualInterestRateParamName, interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName, withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, @@ -170,10 +168,10 @@ public class SavingsApiConstants { productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName, interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, - lockinPeriodFrequencyTypeParamName, - //withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, - withdrawalFeeForTransfersParamName, - feeAmountParamName, feeOnMonthDayParamName, chargesParamName,allowOverdraftParamName,overdraftLimitParamName)); + lockinPeriodFrequencyTypeParamName, + // withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, + withdrawalFeeForTransfersParamName, feeAmountParamName, feeOnMonthDayParamName, chargesParamName, allowOverdraftParamName, + overdraftLimitParamName)); /** * These parameters will match the class level parameters of @@ -211,7 +209,8 @@ public class SavingsApiConstants { amountPaidParamName, chargeOptionsParamName)); public static final Set SAVINGS_ACCOUNT_CHARGES_ADD_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList( - chargeIdParamName, amountParamName, dueAsOfDateParamName, dateFormatParamName, localeParamName, feeOnMonthDayParamName, monthDayFormatParamName, feeIntervalParamName)); + chargeIdParamName, amountParamName, dueAsOfDateParamName, dateFormatParamName, localeParamName, feeOnMonthDayParamName, + monthDayFormatParamName, feeIntervalParamName)); public static final Set SAVINGS_ACCOUNT_CHARGES_PAY_CHARGE_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList( amountParamName, dueAsOfDateParamName, dateFormatParamName, localeParamName)); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountsApiResource.java index cbe41e378..65645b090 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountsApiResource.java @@ -97,7 +97,7 @@ public class SavingsAccountsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, @QueryParam("externalId") final String externalId, -// @QueryParam("underHierarchy") final String hierarchy, + // @QueryParam("underHierarchy") final String hierarchy, @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountAnnualFeeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountAnnualFeeData.java index bb5cc910e..0fbd92cd9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountAnnualFeeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountAnnualFeeData.java @@ -14,7 +14,8 @@ public class SavingsAccountAnnualFeeData { private final String accountNo; private final LocalDate nextAnnualFeeDueDate; - public static SavingsAccountAnnualFeeData instance(final Long id, final Long accountId, final String accountNo, final LocalDate nextAnnualFeeDueDate) { + public static SavingsAccountAnnualFeeData instance(final Long id, final Long accountId, final String accountNo, + final LocalDate nextAnnualFeeDueDate) { return new SavingsAccountAnnualFeeData(id, accountId, accountNo, nextAnnualFeeDueDate); } @@ -36,7 +37,7 @@ public class SavingsAccountAnnualFeeData { public LocalDate getNextAnnualFeeDueDate() { return this.nextAnnualFeeDueDate; } - + public String getAccountNo() { return this.accountNo; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeData.java index 8dc6e2c67..8f0ff9b69 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeData.java @@ -25,7 +25,7 @@ public class SavingsAccountChargeData { @SuppressWarnings("unused") private final Long chargeId; - + @SuppressWarnings("unused") private final Long accountId; @@ -39,10 +39,10 @@ public class SavingsAccountChargeData { @SuppressWarnings("unused") private final MonthDay feeOnMonthDay; - + @SuppressWarnings("unused") private final Integer feeInterval; - + private final EnumOptionData chargeCalculationType; private final BigDecimal percentage; @@ -101,22 +101,24 @@ public class SavingsAccountChargeData { penalty, feeOnMonthDay, feeInterval); } - public static SavingsAccountChargeData instance(final Long id, final Long chargeId, final Long accountId, final String name, final CurrencyData currency, - final BigDecimal amount, final BigDecimal amountPaid, final BigDecimal amountWaived, final BigDecimal amountWrittenOff, - final BigDecimal amountOutstanding, final EnumOptionData chargeTimeType, final LocalDate dueAsOfDate, - final EnumOptionData chargeCalculationType, final BigDecimal percentage, final BigDecimal amountPercentageAppliedTo, - final Collection chargeOptions, final boolean penalty, final MonthDay feeOnMonthDay, final Integer feeInterval) { + public static SavingsAccountChargeData instance(final Long id, final Long chargeId, final Long accountId, final String name, + final CurrencyData currency, final BigDecimal amount, final BigDecimal amountPaid, final BigDecimal amountWaived, + final BigDecimal amountWrittenOff, final BigDecimal amountOutstanding, final EnumOptionData chargeTimeType, + final LocalDate dueAsOfDate, final EnumOptionData chargeCalculationType, final BigDecimal percentage, + final BigDecimal amountPercentageAppliedTo, final Collection chargeOptions, final boolean penalty, + final MonthDay feeOnMonthDay, final Integer feeInterval) { return new SavingsAccountChargeData(id, chargeId, accountId, name, chargeTimeType, dueAsOfDate, chargeCalculationType, percentage, amountPercentageAppliedTo, currency, amount, amountPaid, amountWaived, amountWrittenOff, amountOutstanding, chargeOptions, penalty, feeOnMonthDay, feeInterval); } - private SavingsAccountChargeData(final Long id, final Long chargeId, final Long accountId, final String name, final EnumOptionData chargeTimeType, - final LocalDate dueAsOfDate, final EnumOptionData chargeCalculationType, final BigDecimal percentage, - final BigDecimal amountPercentageAppliedTo, final CurrencyData currency, final BigDecimal amount, final BigDecimal amountPaid, - final BigDecimal amountWaived, final BigDecimal amountWrittenOff, final BigDecimal amountOutstanding, - final Collection chargeOptions, final boolean penalty, final MonthDay feeOnMonthDay, final Integer feeInterval) { + private SavingsAccountChargeData(final Long id, final Long chargeId, final Long accountId, final String name, + final EnumOptionData chargeTimeType, final LocalDate dueAsOfDate, final EnumOptionData chargeCalculationType, + final BigDecimal percentage, final BigDecimal amountPercentageAppliedTo, final CurrencyData currency, final BigDecimal amount, + final BigDecimal amountPaid, final BigDecimal amountWaived, final BigDecimal amountWrittenOff, + final BigDecimal amountOutstanding, final Collection chargeOptions, final boolean penalty, + final MonthDay feeOnMonthDay, final Integer feeInterval) { this.id = id; this.chargeId = chargeId; this.accountId = accountId; @@ -143,11 +145,11 @@ public class SavingsAccountChargeData { return (this.chargeCalculationType != null) && (this.chargeCalculationType.getId().intValue() > 1) ? this.percentage : this.amount; } - public boolean isWithdrawalFee(){ + public boolean isWithdrawalFee() { return ChargeTimeType.fromInt(this.chargeTimeType.getId().intValue()).isWithdrawalFee(); } - - public boolean isAnnualFee(){ + + public boolean isAnnualFee() { return ChargeTimeType.fromInt(this.chargeTimeType.getId().intValue()).isAnnualFee(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeDataValidator.java index 4931e08ad..a1ce10e9c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountChargeDataValidator.java @@ -63,15 +63,15 @@ public class SavingsAccountChargeDataValidator { baseDataValidator.reset().parameter(amountParamName).value(amount).notNull().positiveAmount(); if (this.fromApiJsonHelper.parameterExists(dueAsOfDateParamName, element)) { - final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, element); + final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, element); baseDataValidator.reset().parameter(dueAsOfDateParamName).value(transactionDate).notNull(); } - + if (this.fromApiJsonHelper.parameterExists(feeOnMonthDayParamName, element)) { - final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, element); + final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, element); baseDataValidator.reset().parameter(feeOnMonthDayParamName).value(monthDay).notNull(); } - + throwExceptionIfValidationWarningsExist(dataValidationErrors); } @@ -91,17 +91,18 @@ public class SavingsAccountChargeDataValidator { baseDataValidator.reset().parameter(amountParamName).value(amount).notNull().positiveAmount(); if (this.fromApiJsonHelper.parameterExists(dueAsOfDateParamName, element)) { - final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, element); + final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, element); baseDataValidator.reset().parameter(dueAsOfDateParamName).value(transactionDate).notNull(); } - + if (this.fromApiJsonHelper.parameterExists(feeOnMonthDayParamName, element)) { final String monthDayFormat = this.fromApiJsonHelper.extractMonthDayFormatParameter(element.getAsJsonObject()); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(element.getAsJsonObject()); - final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, element.getAsJsonObject(), monthDayFormat, locale); + final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, element.getAsJsonObject(), + monthDayFormat, locale); baseDataValidator.reset().parameter(feeOnMonthDayParamName).value(monthDay).notNull(); } - + if (this.fromApiJsonHelper.parameterExists(feeIntervalParamName, element)) { final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed(feeIntervalParamName, element, Locale.getDefault()); baseDataValidator.reset().parameter(feeIntervalParamName).value(feeInterval).notNull().inMinMaxRange(1, 12); @@ -125,12 +126,12 @@ public class SavingsAccountChargeDataValidator { final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(amountParamName, element); baseDataValidator.reset().parameter(amountParamName).value(amount).notNull().positiveAmount(); - final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, element); + final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, element); baseDataValidator.reset().parameter(dueAsOfDateParamName).value(transactionDate).notNull(); throwExceptionIfValidationWarningsExist(dataValidationErrors); } - + private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountData.java index aa24cf3dc..13bad5430 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountData.java @@ -69,7 +69,7 @@ public class SavingsAccountData { private final SavingsAccountChargeData withdrawalFee; @SuppressWarnings("unused") private final SavingsAccountChargeData annualFee; - + public static SavingsAccountData instance(final Long id, final String accountNo, final String externalId, final Long groupId, final String groupName, final Long clientId, final String clientName, final Long productId, final String productName, final Long fieldOfficerId, final String fieldOfficerName, final SavingsAccountStatusEnumData status, @@ -77,8 +77,8 @@ public class SavingsAccountData { final EnumOptionData interestCompoundingPeriodType, final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType, final EnumOptionData interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance, final Integer lockinPeriodFrequency, - final EnumOptionData lockinPeriodFrequencyType, final boolean withdrawalFeeForTransfers, final SavingsAccountSummaryData summary, - final boolean allowOverdraft,final BigDecimal overdraftLimit) { + final EnumOptionData lockinPeriodFrequencyType, final boolean withdrawalFeeForTransfers, + final SavingsAccountSummaryData summary, final boolean allowOverdraft, final BigDecimal overdraftLimit) { final Collection productOptions = null; final Collection fieldOfficerOptions = null; @@ -99,7 +99,7 @@ public class SavingsAccountData { lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, - withdrawalFeeTypeOptions, charges, chargeOptions,allowOverdraft,overdraftLimit); + withdrawalFeeTypeOptions, charges, chargeOptions, allowOverdraft, overdraftLimit); } public static SavingsAccountData lookup(final Long accountId, final String accountNo) { @@ -124,12 +124,12 @@ public class SavingsAccountData { final BigDecimal minRequiredOpeningBalance = null; final Integer lockinPeriodFrequency = null; final EnumOptionData lockinPeriodFrequencyType = null; -// final BigDecimal withdrawalFeeAmount = null; -// final EnumOptionData withdrawalFeeType = null; + // final BigDecimal withdrawalFeeAmount = null; + // final EnumOptionData withdrawalFeeType = null; final boolean withdrawalFeeForTransfers = false; -// final BigDecimal annualFeeAmount = null; -// final MonthDay annualFeeOnMonthDay = null; -// final LocalDate annualFeeNextDueDate = null; + // final BigDecimal annualFeeAmount = null; + // final MonthDay annualFeeOnMonthDay = null; + // final LocalDate annualFeeNextDueDate = null; final boolean allowOverdraft = false; final BigDecimal overdraftLimit = null; @@ -149,12 +149,12 @@ public class SavingsAccountData { final Collection chargeOptions = null; return new SavingsAccountData(accountId, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName, - fieldOfficerId , fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType, + fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, - withdrawalFeeTypeOptions, charges, chargeOptions,allowOverdraft,overdraftLimit); + withdrawalFeeTypeOptions, charges, chargeOptions, allowOverdraft, overdraftLimit); } public static SavingsAccountData withTemplateOptions(final SavingsAccountData account, final SavingsAccountData template, @@ -185,8 +185,7 @@ public class SavingsAccountData { template.productOptions, template.fieldOfficerOptions, template.interestCompoundingPeriodTypeOptions, template.interestPostingPeriodTypeOptions, template.interestCalculationTypeOptions, template.interestCalculationDaysInYearTypeOptions, template.lockinPeriodFrequencyTypeOptions, - template.withdrawalFeeTypeOptions, charges, template.chargeOptions,account.allowOverdraft, - account.overdraftLimit); + template.withdrawalFeeTypeOptions, charges, template.chargeOptions, account.allowOverdraft, account.overdraftLimit); } public static SavingsAccountData withTemplateOptions(final SavingsAccountData account, @@ -207,7 +206,7 @@ public class SavingsAccountData { account.lockinPeriodFrequencyType, account.withdrawalFeeForTransfers, account.summary, transactions, productOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, - withdrawalFeeTypeOptions, charges, chargeOptions,account.allowOverdraft,account.overdraftLimit); + withdrawalFeeTypeOptions, charges, chargeOptions, account.allowOverdraft, account.overdraftLimit); } public static SavingsAccountData withClientTemplate(final Long clientId, final String clientName, final Long groupId, @@ -231,15 +230,14 @@ public class SavingsAccountData { final BigDecimal minRequiredOpeningBalance = null; final Integer lockinPeriodFrequency = null; final EnumOptionData lockinPeriodFrequencyType = null; -// final BigDecimal withdrawalFeeAmount = null; -// final EnumOptionData withdrawalFeeType = null; + // final BigDecimal withdrawalFeeAmount = null; + // final EnumOptionData withdrawalFeeType = null; final boolean withdrawalFeeForTransfers = false; -// final BigDecimal annualFeeAmount = null; -// final MonthDay annualFeeOnMonthDay = null; -// final LocalDate annualFeeNextDueDate = null; + // final BigDecimal annualFeeAmount = null; + // final MonthDay annualFeeOnMonthDay = null; + // final LocalDate annualFeeNextDueDate = null; final boolean allowOverdraft = false; final BigDecimal overdraftLimit = null; - final SavingsAccountSummaryData summary = null; final Collection transactions = null; @@ -262,7 +260,7 @@ public class SavingsAccountData { lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, - withdrawalFeeTypeOptions, charges, chargeOptions,allowOverdraft,overdraftLimit); + withdrawalFeeTypeOptions, charges, chargeOptions, allowOverdraft, overdraftLimit); } private SavingsAccountData(final Long id, final String accountNo, final String externalId, final Long groupId, final String groupName, @@ -279,8 +277,8 @@ public class SavingsAccountData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection charges, final Collection chargeOptions, - final boolean allowOverdraft,final BigDecimal overdraftLimit) { + final Collection charges, final Collection chargeOptions, final boolean allowOverdraft, + final BigDecimal overdraftLimit) { this.id = id; this.accountNo = accountNo; this.externalId = externalId; @@ -303,12 +301,12 @@ public class SavingsAccountData { this.minRequiredOpeningBalance = minRequiredOpeningBalance; this.lockinPeriodFrequency = lockinPeriodFrequency; this.lockinPeriodFrequencyType = lockinPeriodFrequencyType; -// this.withdrawalFeeAmount = withdrawalFeeAmount; -// this.withdrawalFeeType = withdrawalFeeType; + // this.withdrawalFeeAmount = withdrawalFeeAmount; + // this.withdrawalFeeType = withdrawalFeeType; this.withdrawalFeeForTransfers = withdrawalFeeForTransfers; -// this.annualFeeAmount = annualFeeAmount; -// this.annualFeeOnMonthDay = annualFeeOnMonthDay; -// this.annualFeeNextDueDate = annualFeeNextDueDate; + // this.annualFeeAmount = annualFeeAmount; + // this.annualFeeOnMonthDay = annualFeeOnMonthDay; + // this.annualFeeNextDueDate = annualFeeNextDueDate; this.summary = summary; this.transactions = transactions; @@ -325,9 +323,9 @@ public class SavingsAccountData { this.charges = charges;// charges associated with Savings account // charges available for adding to Savings account this.chargeOptions = chargeOptions; - + this.withdrawalFee = getWithdrawalFee(); - + this.annualFee = getAnnualFee(); this.allowOverdraft = allowOverdraft; this.overdraftLimit = overdraftLimit; @@ -339,13 +337,13 @@ public class SavingsAccountData { } return null; } - + private SavingsAccountChargeData getAnnualFee() { for (SavingsAccountChargeData charge : this.charges()) { if (charge.isAnnualFee()) return charge; } return null; - } + } public Long id() { return this.id; @@ -381,7 +379,7 @@ public class SavingsAccountData { public int hashCode() { return new HashCodeBuilder(17, 37).append(this.id).append(this.accountNo).toHashCode(); } - + public Collection charges() { return (this.charges == null) ? new HashSet() : this.charges; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountDataValidator.java index 73e6e188d..98eb3aa74 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountDataValidator.java @@ -189,9 +189,9 @@ public class SavingsAccountDataValidator { } validateSavingsCharges(element, baseDataValidator); - + validateOverdraftParams(baseDataValidator, element); - + throwExceptionIfValidationWarningsExist(dataValidationErrors); } @@ -207,21 +207,25 @@ public class SavingsAccountDataValidator { final JsonObject savingsChargeElement = array.get(i).getAsJsonObject(); - //final Long id = this.fromApiJsonHelper.extractLongNamed(idParamName, savingsChargeElement); + // final Long id = + // this.fromApiJsonHelper.extractLongNamed(idParamName, + // savingsChargeElement); final Long chargeId = this.fromApiJsonHelper.extractLongNamed(chargeIdParamName, savingsChargeElement); baseDataValidator.reset().parameter(chargeIdParamName).value(chargeId).longGreaterThanZero(); final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed(amountParamName, savingsChargeElement, locale); baseDataValidator.reset().parameter(amountParamName).value(amount).notNull().positiveAmount(); - + if (this.fromApiJsonHelper.parameterExists(feeOnMonthDayParamName, savingsChargeElement)) { - final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, savingsChargeElement, monthDayFormat, locale); + final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, savingsChargeElement, + monthDayFormat, locale); baseDataValidator.reset().parameter(feeOnMonthDayParamName).value(monthDay).notNull(); } - + if (this.fromApiJsonHelper.parameterExists(feeIntervalParamName, savingsChargeElement)) { - final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed(feeIntervalParamName, savingsChargeElement, Locale.getDefault()); + final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed(feeIntervalParamName, savingsChargeElement, + Locale.getDefault()); baseDataValidator.reset().parameter(feeIntervalParamName).value(feeInterval).notNull().inMinMaxRange(1, 12); } } @@ -370,20 +374,17 @@ public class SavingsAccountDataValidator { private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } } - + private void validateOverdraftParams(final DataValidatorBuilder baseDataValidator, final JsonElement element) { if (this.fromApiJsonHelper.parameterExists(allowOverdraftParamName, element)) { - final Boolean allowOverdraft = this.fromApiJsonHelper.extractBooleanNamed( - allowOverdraftParamName, element); - baseDataValidator.reset().parameter(allowOverdraftParamName).value(allowOverdraft) - .ignoreIfNull().validateForBooleanValue(); + final Boolean allowOverdraft = this.fromApiJsonHelper.extractBooleanNamed(allowOverdraftParamName, element); + baseDataValidator.reset().parameter(allowOverdraftParamName).value(allowOverdraft).ignoreIfNull().validateForBooleanValue(); } - + if (this.fromApiJsonHelper.parameterExists(overdraftLimitParamName, element)) { - final BigDecimal overdraftLimit = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( - overdraftLimitParamName, element); + final BigDecimal overdraftLimit = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(overdraftLimitParamName, element); baseDataValidator.reset().parameter(overdraftLimitParamName).value(overdraftLimit).ignoreIfNull().zeroOrPositiveAmount(); } - + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionEnumData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionEnumData.java index 90321ffe9..f6a7b16ec 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionEnumData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionEnumData.java @@ -26,8 +26,8 @@ public class SavingsAccountTransactionEnumData { private final boolean withdrawTransfer; private final boolean rejectTransfer; private final boolean overdraftInterest; - private final boolean writtenoff ; - private final boolean overdraftFee =true; + private final boolean writtenoff; + private final boolean overdraftFee = true; public SavingsAccountTransactionEnumData(final Long id, final String code, final String value) { this.id = id; @@ -45,7 +45,8 @@ public class SavingsAccountTransactionEnumData { this.rejectTransfer = Long.valueOf(SavingsAccountTransactionType.REJECT_TRANSFER.getValue()).equals(this.id); this.writtenoff = Long.valueOf(SavingsAccountTransactionType.WRITTEN_OFF.getValue()).equals(this.id); this.overdraftInterest = Long.valueOf(SavingsAccountTransactionType.OVERDRAFT_INTEREST.getValue()).equals(this.id); -// this.overdraftFee = Long.valueOf(SavingsAccountTransactionType.OVERDRAFT_INTEREST.getValue()).equals(this.id); + // this.overdraftFee = + // Long.valueOf(SavingsAccountTransactionType.OVERDRAFT_INTEREST.getValue()).equals(this.id); } public Long getId() { @@ -95,12 +96,11 @@ public class SavingsAccountTransactionEnumData { public boolean isRejectTransfer() { return this.rejectTransfer; } - + public boolean isOverdraftInterest() { return this.overdraftInterest; } - public boolean isWrittenoff() { return this.writtenoff; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java index d40fb769b..eee26ade8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java @@ -94,7 +94,6 @@ public class SavingsProductData { final boolean allowOverdraft = false; final BigDecimal overdraftLimit = null; - return new SavingsProductData(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, accountingRule, accountingMappings, @@ -102,20 +101,20 @@ public class SavingsProductData { interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, - penaltyToIncomeAccountMappings,allowOverdraft,overdraftLimit); + penaltyToIncomeAccountMappings, allowOverdraft, overdraftLimit); } public static SavingsProductData withCharges(final SavingsProductData product, final Collection charges) { - return new SavingsProductData(product.id, product.name, product.shortName, product.description, product.currency, product.nominalAnnualInterestRate, - product.interestCompoundingPeriodType, product.interestPostingPeriodType, product.interestCalculationType, - product.interestCalculationDaysInYearType, product.minRequiredOpeningBalance, product.lockinPeriodFrequency, - product.lockinPeriodFrequencyType, product.withdrawalFeeForTransfers, product.accountingRule, product.accountingMappings, - product.paymentChannelToFundSourceMappings, product.currencyOptions, product.interestCompoundingPeriodTypeOptions, - product.interestPostingPeriodTypeOptions, product.interestCalculationTypeOptions, - product.interestCalculationDaysInYearTypeOptions, product.lockinPeriodFrequencyTypeOptions, - product.withdrawalFeeTypeOptions, product.paymentTypeOptions, product.accountingRuleOptions, - product.accountingMappingOptions, charges, product.chargeOptions, product.penaltyOptions, - product.feeToIncomeAccountMappings, product.penaltyToIncomeAccountMappings,product.allowOverdraft,product.overdraftLimit); + return new SavingsProductData(product.id, product.name, product.shortName, product.description, product.currency, + product.nominalAnnualInterestRate, product.interestCompoundingPeriodType, product.interestPostingPeriodType, + product.interestCalculationType, product.interestCalculationDaysInYearType, product.minRequiredOpeningBalance, + product.lockinPeriodFrequency, product.lockinPeriodFrequencyType, product.withdrawalFeeForTransfers, + product.accountingRule, product.accountingMappings, product.paymentChannelToFundSourceMappings, product.currencyOptions, + product.interestCompoundingPeriodTypeOptions, product.interestPostingPeriodTypeOptions, + product.interestCalculationTypeOptions, product.interestCalculationDaysInYearTypeOptions, + product.lockinPeriodFrequencyTypeOptions, product.withdrawalFeeTypeOptions, product.paymentTypeOptions, + product.accountingRuleOptions, product.accountingMappingOptions, charges, product.chargeOptions, product.penaltyOptions, + product.feeToIncomeAccountMappings, product.penaltyToIncomeAccountMappings, product.allowOverdraft, product.overdraftLimit); } /** @@ -133,7 +132,7 @@ public class SavingsProductData { final Collection penaltyOptions) { return new SavingsProductData(existingProduct.id, existingProduct.name, existingProduct.shortName, existingProduct.description, - existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType, + existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType, existingProduct.interestPostingPeriodType, existingProduct.interestCalculationType, existingProduct.interestCalculationDaysInYearType, existingProduct.minRequiredOpeningBalance, existingProduct.lockinPeriodFrequency, existingProduct.lockinPeriodFrequencyType, @@ -142,8 +141,8 @@ public class SavingsProductData { interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, - existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings, - existingProduct.allowOverdraft,existingProduct.overdraftLimit); + existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings, existingProduct.allowOverdraft, + existingProduct.overdraftLimit); } public static SavingsProductData withAccountingDetails(final SavingsProductData existingProduct, @@ -166,7 +165,7 @@ public class SavingsProductData { final Collection penaltyOptions = null; return new SavingsProductData(existingProduct.id, existingProduct.name, existingProduct.shortName, existingProduct.description, - existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType, + existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType, existingProduct.interestPostingPeriodType, existingProduct.interestCalculationType, existingProduct.interestCalculationDaysInYearType, existingProduct.minRequiredOpeningBalance, existingProduct.lockinPeriodFrequency, existingProduct.lockinPeriodFrequencyType, @@ -175,15 +174,15 @@ public class SavingsProductData { interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, - penaltyToIncomeAccountMappings,existingProduct.allowOverdraft,existingProduct.overdraftLimit); + penaltyToIncomeAccountMappings, existingProduct.allowOverdraft, existingProduct.overdraftLimit); } - public static SavingsProductData instance(final Long id, final String name, final String shortName, final String description, - final CurrencyData currency, final BigDecimal nominalAnnualInterestRate, final EnumOptionData interestCompoundingPeriodType, + public static SavingsProductData instance(final Long id, final String name, final String shortName, final String description, + final CurrencyData currency, final BigDecimal nominalAnnualInterestRate, final EnumOptionData interestCompoundingPeriodType, final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType, final EnumOptionData interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance, final Integer lockinPeriodFrequency, final EnumOptionData lockinPeriodFrequencyType, final boolean withdrawalFeeForTransfers, - final EnumOptionData accountingType,final boolean allowOverdraft,final BigDecimal overdraftLimit) { + final EnumOptionData accountingType, final boolean allowOverdraft, final BigDecimal overdraftLimit) { final Map accountingMappings = null; final Collection paymentChannelToFundSourceMappings = null; @@ -211,12 +210,12 @@ public class SavingsProductData { interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, - penaltyToIncomeAccountMappings,allowOverdraft,overdraftLimit); + penaltyToIncomeAccountMappings, allowOverdraft, overdraftLimit); } public static SavingsProductData lookup(final Long id, final String name) { - final String shortName = null; + final String shortName = null; final CurrencyData currency = null; final String description = null; final BigDecimal nominalAnnualInterestRate = null; @@ -249,21 +248,19 @@ public class SavingsProductData { final Collection penaltyOptions = null; final Collection feeToIncomeAccountMappings = null; final Collection penaltyToIncomeAccountMappings = null; - - return new SavingsProductData(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, - lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, - accountingType, accountingMappings, paymentChannelToFundSourceMappings, - currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, - interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, - accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, - penaltyToIncomeAccountMappings,allowOverdraft,overdraftLimit); + lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, accountingType, accountingMappings, + paymentChannelToFundSourceMappings, currencyOptions, interestCompoundingPeriodTypeOptions, + interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, + lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, + accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, + penaltyToIncomeAccountMappings, allowOverdraft, overdraftLimit); } - private SavingsProductData(final Long id, final String name, final String shortName, final String description, final CurrencyData currency, - final BigDecimal nominalAnnualInterestRate, final EnumOptionData interestCompoundingPeriodType, + private SavingsProductData(final Long id, final String name, final String shortName, final String description, + final CurrencyData currency, final BigDecimal nominalAnnualInterestRate, final EnumOptionData interestCompoundingPeriodType, final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType, final EnumOptionData interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance, final Integer lockinPeriodFrequency, final EnumOptionData lockinPeriodFrequencyType, final boolean withdrawalFeeForTransfers, @@ -278,8 +275,8 @@ public class SavingsProductData { final Map> accountingMappingOptions, final Collection charges, final Collection chargeOptions, final Collection penaltyOptions, final Collection feeToIncomeAccountMappings, - final Collection penaltyToIncomeAccountMappings, - final boolean allowOverdraft,final BigDecimal overdraftLimit) { + final Collection penaltyToIncomeAccountMappings, final boolean allowOverdraft, + final BigDecimal overdraftLimit) { this.id = id; this.name = name; this.shortName = shortName; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductDataValidator.java index 7ca576e1c..059160dde 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductDataValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductDataValidator.java @@ -79,7 +79,7 @@ public class SavingsProductDataValidator { final String name = this.fromApiJsonHelper.extractStringNamed(nameParamName, element); baseDataValidator.reset().parameter(nameParamName).value(name).notBlank().notExceedingLengthOf(100); - + final String shortName = this.fromApiJsonHelper.extractStringNamed(shortNameParamName, element); baseDataValidator.reset().parameter(shortNameParamName).value(shortName).notBlank().notExceedingLengthOf(4); @@ -154,32 +154,41 @@ public class SavingsProductDataValidator { } } - /*if (this.fromApiJsonHelper.parameterExists(withdrawalFeeAmountParamName, element)) { - - final BigDecimal withdrawalFeeAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(withdrawalFeeAmountParamName, - element); - baseDataValidator.reset().parameter(withdrawalFeeAmountParamName).value(withdrawalFeeAmount).zeroOrPositiveAmount(); - - if (withdrawalFeeAmount != null) { - final Integer withdrawalFeeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element); - baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType) - .isOneOfTheseValues(SavingsWithdrawalFeesType.integerValues()); - } - } - - if (this.fromApiJsonHelper.parameterExists(withdrawalFeeTypeParamName, element)) { - final Integer withdrawalFeeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element); - baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType).ignoreIfNull() - .isOneOfTheseValues(1, 2); - - if (withdrawalFeeType != null) { - final BigDecimal withdrawalFeeAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( - withdrawalFeeAmountParamName, element); - baseDataValidator.reset().parameter(withdrawalFeeAmountParamName).value(withdrawalFeeAmount).notNull() - .zeroOrPositiveAmount(); - } - } -*/ + /* + * if + * (this.fromApiJsonHelper.parameterExists(withdrawalFeeAmountParamName, + * element)) { + * + * final BigDecimal withdrawalFeeAmount = + * this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed + * (withdrawalFeeAmountParamName, element); + * baseDataValidator.reset().parameter + * (withdrawalFeeAmountParamName).value + * (withdrawalFeeAmount).zeroOrPositiveAmount(); + * + * if (withdrawalFeeAmount != null) { final Integer withdrawalFeeType = + * this.fromApiJsonHelper.extractIntegerSansLocaleNamed( + * withdrawalFeeTypeParamName, element); + * baseDataValidator.reset().parameter + * (withdrawalFeeTypeParamName).value(withdrawalFeeType) + * .isOneOfTheseValues(SavingsWithdrawalFeesType.integerValues()); } } + * + * if + * (this.fromApiJsonHelper.parameterExists(withdrawalFeeTypeParamName, + * element)) { final Integer withdrawalFeeType = + * this.fromApiJsonHelper.extractIntegerSansLocaleNamed + * (withdrawalFeeTypeParamName, element); + * baseDataValidator.reset().parameter + * (withdrawalFeeTypeParamName).value(withdrawalFeeType).ignoreIfNull() + * .isOneOfTheseValues(1, 2); + * + * if (withdrawalFeeType != null) { final BigDecimal withdrawalFeeAmount + * = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( + * withdrawalFeeAmountParamName, element); + * baseDataValidator.reset().parameter + * (withdrawalFeeAmountParamName).value(withdrawalFeeAmount).notNull() + * .zeroOrPositiveAmount(); } } + */ if (this.fromApiJsonHelper.parameterExists(withdrawalFeeForTransfersParamName, element)) { final Boolean isWithdrawalFeeApplicableForTransfers = this.fromApiJsonHelper.extractBooleanNamed( withdrawalFeeForTransfersParamName, element); @@ -201,8 +210,7 @@ public class SavingsProductDataValidator { final MonthDay monthDayOfAnnualFee = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, element); if (monthDayOfAnnualFee != null) { - final BigDecimal annualFeeAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(feeAmountParamName, - element); + final BigDecimal annualFeeAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(feeAmountParamName, element); baseDataValidator.reset().parameter(feeAmountParamName).value(annualFeeAmount).notNull().zeroOrPositiveAmount(); } } @@ -242,7 +250,7 @@ public class SavingsProductDataValidator { SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()) .value(incomeFromPenaltyId).notNull().integerGreaterThanZero(); - + final Long overdraftControlAccountId = this.fromApiJsonHelper.extractLongNamed( SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element); baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue()) @@ -255,14 +263,13 @@ public class SavingsProductDataValidator { final Long writtenoff = this.fromApiJsonHelper.extractLongNamed( SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); - baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()) - .value(writtenoff).notNull().integerGreaterThanZero(); - + baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff) + .notNull().integerGreaterThanZero(); validatePaymentChannelFundSourceMappings(baseDataValidator, element); validateChargeToIncomeAccountMappings(baseDataValidator, element); } - + validateOverdraftParams(baseDataValidator, element); throwExceptionIfValidationWarningsExist(dataValidationErrors); @@ -284,11 +291,11 @@ public class SavingsProductDataValidator { final String name = this.fromApiJsonHelper.extractStringNamed(nameParamName, element); baseDataValidator.reset().parameter(nameParamName).value(name).notBlank().notExceedingLengthOf(100); } - + if (this.fromApiJsonHelper.parameterExists(shortNameParamName, element)) { - final String shortName = this.fromApiJsonHelper.extractStringNamed(shortNameParamName, element); + final String shortName = this.fromApiJsonHelper.extractStringNamed(shortNameParamName, element); baseDataValidator.reset().parameter(shortNameParamName).value(shortName).notBlank().notExceedingLengthOf(4); - } + } if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) { final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element); @@ -403,7 +410,7 @@ public class SavingsProductDataValidator { SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId) .ignoreIfNull().integerGreaterThanZero(); - + final Long overdraftAccountId = this.fromApiJsonHelper.extractLongNamed( SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element); baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue()) @@ -411,19 +418,18 @@ public class SavingsProductDataValidator { final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed( SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), element); - baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue()) - .value(incomeFromInterest).ignoreIfNull().integerGreaterThanZero(); + baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue()).value(incomeFromInterest) + .ignoreIfNull().integerGreaterThanZero(); - final Long writtenoff = this.fromApiJsonHelper.extractLongNamed( - SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); - baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()) - .value(writtenoff).ignoreIfNull().integerGreaterThanZero(); + final Long writtenoff = this.fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), + element); + baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff) + .ignoreIfNull().integerGreaterThanZero(); - validatePaymentChannelFundSourceMappings(baseDataValidator, element); validateChargeToIncomeAccountMappings(baseDataValidator, element); validateOverdraftParams(baseDataValidator, element); - + throwExceptionIfValidationWarningsExist(dataValidationErrors); } @@ -504,21 +510,18 @@ public class SavingsProductDataValidator { } } } - + private void validateOverdraftParams(final DataValidatorBuilder baseDataValidator, final JsonElement element) { if (this.fromApiJsonHelper.parameterExists(allowOverdraftParamName, element)) { - final Boolean allowOverdraft = this.fromApiJsonHelper.extractBooleanNamed( - allowOverdraftParamName, element); - baseDataValidator.reset().parameter(allowOverdraftParamName).value(allowOverdraft) - .ignoreIfNull().validateForBooleanValue(); + final Boolean allowOverdraft = this.fromApiJsonHelper.extractBooleanNamed(allowOverdraftParamName, element); + baseDataValidator.reset().parameter(allowOverdraftParamName).value(allowOverdraft).ignoreIfNull().validateForBooleanValue(); } - + if (this.fromApiJsonHelper.parameterExists(overdraftLimitParamName, element)) { - final BigDecimal overdraftLimit = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( - overdraftLimitParamName, element); + final BigDecimal overdraftLimit = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(overdraftLimitParamName, element); baseDataValidator.reset().parameter(overdraftLimitParamName).value(overdraftLimit).ignoreIfNull().zeroOrPositiveAmount(); } - + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountAssembler.java index e1c1952d8..9b8023462 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountAssembler.java @@ -25,7 +25,6 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.submittedO import static org.mifosplatform.portfolio.savings.SavingsApiConstants.withdrawalFeeForTransfersParamName; import java.math.BigDecimal; -import java.util.Date; import java.util.Set; import org.joda.time.LocalDate; @@ -49,11 +48,11 @@ import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType; import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType; import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType; import org.mifosplatform.portfolio.savings.exception.SavingsProductNotFoundException; +import org.mifosplatform.useradministration.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.google.gson.JsonElement; -import org.mifosplatform.useradministration.domain.AppUser; @Service public class SavingsAccountAssembler { @@ -92,7 +91,7 @@ public class SavingsAccountAssembler { public SavingsAccount assembleFrom(final JsonCommand command, final AppUser submittedBy) { final JsonElement element = command.parsedJson(); - + final String accountNo = this.fromApiJsonHelper.extractStringNamed(accountNoParamName, element); final String externalId = this.fromApiJsonHelper.extractStringNamed(externalIdParamName, element); final Long productId = this.fromApiJsonHelper.extractLongNamed(productIdParamName, element); @@ -202,25 +201,24 @@ public class SavingsAccountAssembler { iswithdrawalFeeApplicableForTransfer = command.booleanPrimitiveValueOfParameterNamed(withdrawalFeeForTransfersParamName); } - final Set charges = this.savingsAccountChargeAssembler.fromParsedJson(element, product.currency().getCode()); - + boolean allowOverdraft = false; if (command.parameterExists(allowOverdraftParamName)) { allowOverdraft = command.booleanPrimitiveValueOfParameterNamed(allowOverdraftParamName); } - final BigDecimal overdraftLimit = command - .bigDecimalValueOfParameterNamedDefaultToNullIfZero(overdraftLimitParamName); - + final BigDecimal overdraftLimit = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(overdraftLimitParamName); + final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, fieldOfficer, accountNo, - externalId, accountType, submittedOnDate, submittedBy, interestRate, interestCompoundingPeriodType, interestPostingPeriodType, - interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, - lockinPeriodFrequencyType, iswithdrawalFeeApplicableForTransfer, charges,allowOverdraft,overdraftLimit); + externalId, accountType, submittedOnDate, submittedBy, interestRate, interestCompoundingPeriodType, + interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, + lockinPeriodFrequency, lockinPeriodFrequencyType, iswithdrawalFeeApplicableForTransfer, charges, allowOverdraft, + overdraftLimit); account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); account.validateNewApplicationState(DateUtils.getLocalDateOfTenant()); - + account.validateAccountValuesWithProduct(); return account; @@ -231,13 +229,14 @@ public class SavingsAccountAssembler { account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); return account; } - + /** * Assembles a new {@link SavingsAccount} from JSON details passed in * request inheriting details where relevant from chosen * {@link SavingsProduct}. */ - public SavingsAccount assembleFrom(final Client client ,final Group group, final SavingsProduct product,final LocalDate appliedonDate,final AppUser appliedBy) { + public SavingsAccount assembleFrom(final Client client, final Group group, final SavingsProduct product, final LocalDate appliedonDate, + final AppUser appliedBy) { AccountType accountType = AccountType.INVALID; if (client != null) { @@ -247,10 +246,10 @@ public class SavingsAccountAssembler { if (group != null) { accountType = AccountType.GROUP; - if(group.isNotActive()){ + if (group.isNotActive()) { if (group.isCenter()) { throw new CenterNotActiveException(group.getId()); } - throw new GroupNotActiveException(group.getId()); - } + throw new GroupNotActiveException(group.getId()); + } } if (group != null && client != null) { @@ -260,22 +259,20 @@ public class SavingsAccountAssembler { final Set charges = this.savingsAccountChargeAssembler.fromSavingsProduct(product); - - final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, null, null, - null, accountType, appliedonDate, appliedBy, product.nominalAnnualInterestRate(), product.interestCompoundingPeriodType(), - product.interestPostingPeriodType(), - product.interestCalculationType(), product.interestCalculationDaysInYearType(), product.minRequiredOpeningBalance(), product.lockinPeriodFrequency(), - product.lockinPeriodFrequencyType(), product.isWithdrawalFeeApplicableForTransfer(), charges ,product.isAllowOverdraft(),product.overdraftLimit()); + final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, null, null, null, + accountType, appliedonDate, appliedBy, product.nominalAnnualInterestRate(), product.interestCompoundingPeriodType(), + product.interestPostingPeriodType(), product.interestCalculationType(), product.interestCalculationDaysInYearType(), + product.minRequiredOpeningBalance(), product.lockinPeriodFrequency(), product.lockinPeriodFrequencyType(), + product.isWithdrawalFeeApplicableForTransfer(), charges, product.isAllowOverdraft(), product.overdraftLimit()); account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); account.validateNewApplicationState(DateUtils.getLocalDateOfTenant()); - + account.validateAccountValuesWithProduct(); return account; } - public void assignSavingAccountHelpers(final SavingsAccount savingsAccount) { savingsAccount.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java index ecd0c22f8..b3b0f2650 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountCharge.java @@ -185,11 +185,11 @@ public class SavingsAccountCharge extends AbstractPersistable { final BigDecimal transactionAmount = new BigDecimal(0); populateDerivedFields(transactionAmount, chargeAmount); - + if (this.isWithdrawalFee()) { this.amountOutstanding = BigDecimal.ZERO; } - + this.paid = determineIfFullyPaid(); this.status = status; } @@ -198,9 +198,10 @@ public class SavingsAccountCharge extends AbstractPersistable { if (isMonthlyFee() || isAnnualFee()) { // FIXME: AA: If charge is percentage of x amount then need to // update amount outstanding accordingly. - // Right now annual and monthly charges supports charge calculation type flat. + // Right now annual and monthly charges supports charge calculation + // type flat. this.amountOutstanding = this.amount; - this.paid = false;//reset to false for recurring fee. + this.paid = false;// reset to false for recurring fee. this.waived = false; } } @@ -276,13 +277,13 @@ public class SavingsAccountCharge extends AbstractPersistable { amountPaid = amountPaid.minus(transactionAmount); this.amountPaid = amountPaid.getAmount(); this.amountOutstanding = calculateAmountOutstanding(currency); - + if (this.isWithdrawalFee()) { this.amountOutstanding = BigDecimal.ZERO; } - //to reset amount outstanding for annual and monthly fee + // to reset amount outstanding for annual and monthly fee recalculateAmountOutstanding(); - updateToPreviousDueDate();//reset annual and monthly due date. + updateToPreviousDueDate();// reset annual and monthly due date. this.paid = false; } @@ -290,10 +291,10 @@ public class SavingsAccountCharge extends AbstractPersistable { this.amountWaived = this.amountOutstanding; this.amountOutstanding = BigDecimal.ZERO; this.waived = true; - + recalculateAmountOutstanding(); updateToNextDueDate(); - + return getAmountWaived(currency); } @@ -303,7 +304,7 @@ public class SavingsAccountCharge extends AbstractPersistable { this.amountWaived = amountWaived.getAmount(); this.amountOutstanding = calculateAmountOutstanding(currency); this.waived = false; - + recalculateAmountOutstanding(); updateToPreviousDueDate(); } @@ -316,13 +317,13 @@ public class SavingsAccountCharge extends AbstractPersistable { this.amountPaid = amountPaidToDate.getAmount(); this.amountOutstanding = amountOutstanding.getAmount(); this.paid = determineIfFullyPaid(); - + if (BigDecimal.ZERO.compareTo(this.amountOutstanding) == 0) { - //full outstanding is paid, update to next due date + // full outstanding is paid, update to next due date updateToNextDueDate(); recalculateAmountOutstanding(); } - + return Money.of(currency, this.amountOutstanding); } @@ -614,8 +615,8 @@ public class SavingsAccountCharge extends AbstractPersistable { public boolean isWithdrawalFee() { return ChargeTimeType.fromInt(this.chargeTime).isWithdrawalFee(); } - - public boolean isOverdraftFee(){ + + public boolean isOverdraftFee() { return ChargeTimeType.fromInt(this.chargeTime).isOverdraftFee(); } @@ -686,15 +687,15 @@ public class SavingsAccountCharge extends AbstractPersistable { } public void updateToNextDueDate() { - if(isAnnualFee() || isMonthlyFee()){ + if (isAnnualFee() || isMonthlyFee()) { LocalDate nextDueLocalDate = new LocalDate(dueDate); int maxDayOfMonth = nextDueLocalDate.dayOfMonth().withMaximumValue().getDayOfMonth(); int newDayOfMonth = (this.feeOnDay.intValue() < maxDayOfMonth) ? this.feeOnDay.intValue() : maxDayOfMonth; nextDueLocalDate = nextDueLocalDate.withDayOfMonth(newDayOfMonth); - if(isAnnualFee()){ + if (isAnnualFee()) { nextDueLocalDate = nextDueLocalDate.withMonthOfYear(this.feeOnMonth).plusYears(1); - }else if(isMonthlyFee()){ + } else if (isMonthlyFee()) { nextDueLocalDate = nextDueLocalDate.plusMonths(this.feeInterval); } @@ -703,19 +704,19 @@ public class SavingsAccountCharge extends AbstractPersistable { } public void updateToPreviousDueDate() { - if(isAnnualFee() || isMonthlyFee()){ + if (isAnnualFee() || isMonthlyFee()) { LocalDate nextDueLocalDate = new LocalDate(dueDate); - if(isAnnualFee()){ + if (isAnnualFee()) { nextDueLocalDate = nextDueLocalDate.withMonthOfYear(this.feeOnMonth).minusYears(1); - }else if(isMonthlyFee()){ + } else if (isMonthlyFee()) { nextDueLocalDate = nextDueLocalDate.minusMonths(this.feeInterval); } - - //set day of month + + // set day of month int maxDayOfMonth = nextDueLocalDate.dayOfMonth().withMaximumValue().getDayOfMonth(); int newDayOfMonth = (this.feeOnDay.intValue() < maxDayOfMonth) ? this.feeOnDay.intValue() : maxDayOfMonth; nextDueLocalDate = nextDueLocalDate.withDayOfMonth(newDayOfMonth); - + this.dueDate = nextDueLocalDate.toDate(); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeAssembler.java index 7bc6976c7..fdbd3c420 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeAssembler.java @@ -82,8 +82,10 @@ public class SavingsAccountChargeAssembler { final LocalDate dueDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, savingsChargeElement, dateFormat, locale); - final MonthDay feeOnMonthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, savingsChargeElement, monthDayFormat, locale); - final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed(feeIntervalParamName, savingsChargeElement, locale); + final MonthDay feeOnMonthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, + savingsChargeElement, monthDayFormat, locale); + final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed(feeIntervalParamName, savingsChargeElement, + locale); if (id == null) { final Charge chargeDefinition = this.chargeRepository.findOneWithNotFoundDetection(chargeId); @@ -98,12 +100,12 @@ public class SavingsAccountChargeAssembler { if (chargeTimeType != null) { chargeTime = ChargeTimeType.fromInt(chargeTimeType); } - + ChargeCalculationType chargeCalculation = null; if (chargeCalculationType != null) { chargeCalculation = ChargeCalculationType.fromInt(chargeCalculationType); } - + final boolean status = true; final SavingsAccountCharge savingsAccountCharge = SavingsAccountCharge.createNewWithoutSavingsAccount( chargeDefinition, amount, chargeTime, chargeCalculation, dueDate, status, feeOnMonthDay, feeInterval); @@ -125,7 +127,7 @@ public class SavingsAccountChargeAssembler { this.validateSavingsCharges(savingsAccountCharges, productCurrencyCode); return savingsAccountCharges; } - + public Set fromSavingsProduct(final SavingsProduct savingsProduct) { final Set savingsAccountCharges = new HashSet(); @@ -135,23 +137,22 @@ public class SavingsAccountChargeAssembler { if (charge.getChargeTime() != null) { chargeTime = ChargeTimeType.fromInt(charge.getChargeTime()); } - if(chargeTime !=null && chargeTime.isOnSpecifiedDueDate()){ + if (chargeTime != null && chargeTime.isOnSpecifiedDueDate()) { continue; } - + ChargeCalculationType chargeCalculation = null; if (charge.getChargeCalculation() != null) { chargeCalculation = ChargeCalculationType.fromInt(charge.getChargeCalculation()); } final boolean status = true; - final SavingsAccountCharge savingsAccountCharge = SavingsAccountCharge.createNewWithoutSavingsAccount( - charge, charge.getAmount(),chargeTime ,chargeCalculation , null, status, charge.getFeeOnMonthDay(), charge.feeInterval()); + final SavingsAccountCharge savingsAccountCharge = SavingsAccountCharge.createNewWithoutSavingsAccount(charge, + charge.getAmount(), chargeTime, chargeCalculation, null, status, charge.getFeeOnMonthDay(), charge.feeInterval()); savingsAccountCharges.add(savingsAccountCharge); } return savingsAccountCharges; } - - + private void validateSavingsCharges(final Set charges, final String productCurrencyCode) { final List dataValidationErrors = new ArrayList(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) @@ -159,11 +160,11 @@ public class SavingsAccountChargeAssembler { boolean isOneWithdrawalPresent = false; boolean isOneAnnualPresent = false; for (SavingsAccountCharge charge : charges) { - if(!charge.hasCurrencyCodeOf(productCurrencyCode)){ + if (!charge.hasCurrencyCodeOf(productCurrencyCode)) { baseDataValidator.reset().parameter("currency").value(charge.getCharge().getId()) .failWithCodeNoParameterAddedToErrorCode("currency.and.charge.currency.not.same"); } - + if (charge.isWithdrawalFee()) { if (isOneWithdrawalPresent) { baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("multiple.withdrawal.fee.per.account.not.supported"); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepository.java index 714988d9d..577b69fb7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepository.java @@ -17,7 +17,7 @@ public interface SavingsAccountChargeRepository extends JpaRepository { SavingsAccountCharge findByIdAndSavingsAccountId(Long id, Long savingsAccountId); - + @Query("from SavingsAccountCharge sac where sac.dueDate <=:transactionDate and sac.waived = 0 and sac.paid=0 order by sac.dueDate") List findPendingCharges(@Param("transactionDate") Date transactionDate); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepositoryWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepositoryWrapper.java index 8aba4acb6..a9c4f5a6b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepositoryWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountChargeRepositoryWrapper.java @@ -39,8 +39,8 @@ public class SavingsAccountChargeRepositoryWrapper { if (savingsAccountCharge == null) { throw new SavingsAccountChargeNotFoundException(id); } return savingsAccountCharge; } - - public List findPendingCharges(final Date transactionDate){ + + public List findPendingCharges(final Date transactionDate) { return this.repository.findPendingCharges(transactionDate); } @@ -48,10 +48,10 @@ public class SavingsAccountChargeRepositoryWrapper { this.repository.save(savingsAccountCharge); } - public void save(final Iterable savingsAccountCharges){ + public void save(final Iterable savingsAccountCharges) { this.repository.save(savingsAccountCharges); } - + public void saveAndFlush(final SavingsAccountCharge savingsAccountCharge) { this.repository.saveAndFlush(savingsAccountCharge); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java index 3fc878cb1..ad39f6402 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java @@ -54,7 +54,7 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi final Set existingReversedTransactionIds = new HashSet(); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail,new Date()); + paymentDetail, new Date()); final SavingsAccountTransaction withdrawal = account.withdraw(transactionDTO, applyWithdrawFee); final MathContext mc = MathContext.DECIMAL64; @@ -83,7 +83,7 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi final Set existingReversedTransactionIds = new HashSet(); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail,new Date()); + paymentDetail, new Date()); final SavingsAccountTransaction deposit = account.deposit(transactionDTO); final MathContext mc = MathContext.DECIMAL64; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountSummary.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountSummary.java index 3a79cef14..3ca03edf4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountSummary.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountSummary.java @@ -50,13 +50,13 @@ public final class SavingsAccountSummary { @Column(name = "account_balance_derived", scale = 6, precision = 19) private BigDecimal accountBalance = BigDecimal.ZERO; - //TODO: AA do we need this data to be persisted. + // TODO: AA do we need this data to be persisted. @Transient private BigDecimal totalFeeChargesWaived = BigDecimal.ZERO; - + @Transient private BigDecimal totalPenaltyChargesWaived = BigDecimal.ZERO; - + protected SavingsAccountSummary() { // } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java index 863e9221e..9c4367bd4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransaction.java @@ -89,10 +89,10 @@ public final class SavingsAccountTransaction extends AbstractPersistable { @LazyCollection(LazyCollectionOption.FALSE) @OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccountTransaction", orphanRemoval = true) private final Set savingsAccountChargesPaid = new HashSet(); - + @Column(name = "overdraft_amount_derived", scale = 6, precision = 19, nullable = true) private BigDecimal overdraftAmount; - + @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_date", nullable = false) private final Date createdDate; @@ -107,14 +107,14 @@ public final class SavingsAccountTransaction extends AbstractPersistable { final PaymentDetail paymentDetail, final LocalDate date, final Money amount, Date createdDate) { final boolean isReversed = false; return new SavingsAccountTransaction(savingsAccount, office, paymentDetail, SavingsAccountTransactionType.DEPOSIT.getValue(), date, - createdDate, amount, isReversed); + createdDate, amount, isReversed); } public static SavingsAccountTransaction withdrawal(final SavingsAccount savingsAccount, final Office office, final PaymentDetail paymentDetail, final LocalDate date, final Money amount, Date createdDate) { final boolean isReversed = false; return new SavingsAccountTransaction(savingsAccount, office, paymentDetail, SavingsAccountTransactionType.WITHDRAWAL.getValue(), - date,createdDate, amount, isReversed); + date, createdDate, amount, isReversed); } public static SavingsAccountTransaction interestPosting(final SavingsAccount savingsAccount, final Office office, final LocalDate date, @@ -156,45 +156,45 @@ public final class SavingsAccountTransaction extends AbstractPersistable { final boolean isReversed = false; final PaymentDetail paymentDetail = null; return new SavingsAccountTransaction(savingsAccount, office, paymentDetail, - SavingsAccountTransactionType.INITIATE_TRANSFER.getValue(), date, new Date(),savingsAccount.getSummary().getAccountBalance(), - isReversed); + SavingsAccountTransactionType.INITIATE_TRANSFER.getValue(), date, new Date(), savingsAccount.getSummary() + .getAccountBalance(), isReversed); } public static SavingsAccountTransaction approveTransfer(final SavingsAccount savingsAccount, final Office office, final LocalDate date) { final boolean isReversed = false; final PaymentDetail paymentDetail = null; return new SavingsAccountTransaction(savingsAccount, office, paymentDetail, - SavingsAccountTransactionType.APPROVE_TRANSFER.getValue(), date,new Date(), savingsAccount.getSummary().getAccountBalance(), - isReversed); + SavingsAccountTransactionType.APPROVE_TRANSFER.getValue(), date, new Date(), savingsAccount.getSummary() + .getAccountBalance(), isReversed); } public static SavingsAccountTransaction withdrawTransfer(final SavingsAccount savingsAccount, final Office office, final LocalDate date) { final boolean isReversed = false; final PaymentDetail paymentDetail = null; return new SavingsAccountTransaction(savingsAccount, office, paymentDetail, - SavingsAccountTransactionType.WITHDRAW_TRANSFER.getValue(), date,new Date(), savingsAccount.getSummary().getAccountBalance(), - isReversed); - } - - public static SavingsAccountTransaction copyTransaction(SavingsAccountTransaction accountTransaction) { - return new SavingsAccountTransaction(accountTransaction.savingsAccount, accountTransaction.office, accountTransaction.paymentDetail, - accountTransaction.typeOf, accountTransaction.transactionLocalDate(),accountTransaction.createdDate, accountTransaction.amount, - accountTransaction.reversed); + SavingsAccountTransactionType.WITHDRAW_TRANSFER.getValue(), date, new Date(), savingsAccount.getSummary() + .getAccountBalance(), isReversed); } + public static SavingsAccountTransaction copyTransaction(SavingsAccountTransaction accountTransaction) { + return new SavingsAccountTransaction(accountTransaction.savingsAccount, accountTransaction.office, + accountTransaction.paymentDetail, accountTransaction.typeOf, accountTransaction.transactionLocalDate(), + accountTransaction.createdDate, accountTransaction.amount, accountTransaction.reversed); + } private SavingsAccountTransaction(final SavingsAccount savingsAccount, final Office office, final Integer typeOf, final LocalDate transactionLocalDate, final Money amount, final boolean isReversed) { - this(savingsAccount, office, null, typeOf, transactionLocalDate, new Date(),amount, isReversed); + this(savingsAccount, office, null, typeOf, transactionLocalDate, new Date(), amount, isReversed); } private SavingsAccountTransaction(final SavingsAccount savingsAccount, final Office office, final PaymentDetail paymentDetail, - final Integer typeOf, final LocalDate transactionLocalDate,final Date createdDate, final Money amount, final boolean isReversed) { - this(savingsAccount, office, paymentDetail, typeOf, transactionLocalDate,createdDate, amount.getAmount(), isReversed); + final Integer typeOf, final LocalDate transactionLocalDate, final Date createdDate, final Money amount, final boolean isReversed) { + this(savingsAccount, office, paymentDetail, typeOf, transactionLocalDate, createdDate, amount.getAmount(), isReversed); } private SavingsAccountTransaction(final SavingsAccount savingsAccount, final Office office, final PaymentDetail paymentDetail, - final Integer typeOf, final LocalDate transactionLocalDate, final Date createdDate, final BigDecimal amount, final boolean isReversed) { + final Integer typeOf, final LocalDate transactionLocalDate, final Date createdDate, final BigDecimal amount, + final boolean isReversed) { this.savingsAccount = savingsAccount; this.office = office; this.typeOf = typeOf; @@ -220,7 +220,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable { public boolean isDeposit() { return SavingsAccountTransactionType.fromInt(this.typeOf).isDeposit(); } - + public boolean isDepositAndNotReversed() { return SavingsAccountTransactionType.fromInt(this.typeOf).isDeposit() && isNotReversed(); } @@ -229,10 +229,10 @@ public final class SavingsAccountTransaction extends AbstractPersistable { return SavingsAccountTransactionType.fromInt(this.typeOf).isWithdrawal(); } - public boolean isPostInterestCalculationRequired(){ + public boolean isPostInterestCalculationRequired() { return this.isDeposit() || this.isChargeTransaction(); } - + public boolean isInterestPostingAndNotReversed() { return SavingsAccountTransactionType.fromInt(this.typeOf).isInterestPosting() && isNotReversed(); } @@ -240,7 +240,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable { public boolean isWithdrawalFeeAndNotReversed() { return SavingsAccountTransactionType.fromInt(this.typeOf).isWithdrawalFee() && isNotReversed(); } - + public boolean isWithdrawalFee() { return SavingsAccountTransactionType.fromInt(this.typeOf).isWithdrawalFee(); } @@ -297,12 +297,12 @@ public final class SavingsAccountTransaction extends AbstractPersistable { } public void updateCumulativeBalanceAndDates(final MonetaryCurrency currency, final LocalDate endOfBalanceDate) { - //balance end date should not be before transaction date - if (endOfBalanceDate != null && endOfBalanceDate.isBefore(this.transactionLocalDate())){ + // balance end date should not be before transaction date + if (endOfBalanceDate != null && endOfBalanceDate.isBefore(this.transactionLocalDate())) { this.balanceEndDate = this.transactionLocalDate().toDate(); - }else if(endOfBalanceDate != null){ + } else if (endOfBalanceDate != null) { this.balanceEndDate = endOfBalanceDate.toDate(); - }else{ + } else { this.balanceEndDate = null; } this.balanceNumberOfDays = LocalDateInterval.create(getTransactionLocalDate(), endOfBalanceDate).daysInPeriodInclusiveOfEndDate(); @@ -353,9 +353,9 @@ public final class SavingsAccountTransaction extends AbstractPersistable { } /*** - * Sending data in a map, though in savings we currently expect a transaction to - * always repay a single charge (or may repay a part of a single charge - * too) + * Sending data in a map, though in savings we currently expect a + * transaction to always repay a single charge (or may repay a part of a + * single charge too) ***/ if (!this.savingsAccountChargesPaid.isEmpty()) { final List> savingsChargesPaidData = new ArrayList>(); @@ -493,16 +493,16 @@ public final class SavingsAccountTransaction extends AbstractPersistable { public boolean isPayCharge() { return SavingsAccountTransactionType.fromInt(this.typeOf).isPayCharge(); } - - public boolean isChargeTransaction(){ + + public boolean isChargeTransaction() { return SavingsAccountTransactionType.fromInt(this.typeOf).isChargeTransaction(); } - - public boolean isChargeTransactionAndNotReversed(){ + + public boolean isChargeTransactionAndNotReversed() { return SavingsAccountTransactionType.fromInt(this.typeOf).isChargeTransaction() && isNotReversed(); } - - public boolean isWaiveCharge(){ + + public boolean isWaiveCharge() { return SavingsAccountTransactionType.fromInt(this.typeOf).isWaiveCharge(); } @@ -551,18 +551,16 @@ public final class SavingsAccountTransaction extends AbstractPersistable { return this.savingsAccountChargesPaid; } - public void updateOverdraftAmount(BigDecimal overdraftAmount) { this.overdraftAmount = overdraftAmount; } - + public Money getOverdraftAmount(final MonetaryCurrency currency) { return Money.of(currency, this.overdraftAmount); } - public Date createdDate() { - return this.createdDate; - } - + public Date createdDate() { + return this.createdDate; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransactionComparator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransactionComparator.java index fc54d7a74..e90000b2a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransactionComparator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccountTransactionComparator.java @@ -15,15 +15,15 @@ public class SavingsAccountTransactionComparator implements Comparator transactions) { Money total = Money.zero(currency); for (final SavingsAccountTransaction transaction : transactions) { @@ -98,7 +98,7 @@ public final class SavingsAccountTransactionSummaryWrapper { } return total.getAmountDefaultedToNullIfZero(); } - + public BigDecimal calculateTotalPenaltyChargeWaived(final MonetaryCurrency currency, final List transactions) { Money total = Money.zero(currency); for (final SavingsAccountTransaction transaction : transactions) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProduct.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProduct.java index 5ff37f00a..d748f4c8c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProduct.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProduct.java @@ -63,12 +63,12 @@ import com.google.gson.JsonArray; @Entity @Table(name = "m_savings_product", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "sp_unq_name"), - @UniqueConstraint(columnNames = { "short_name" }, name = "sp_unq_short_name")}) + @UniqueConstraint(columnNames = { "short_name" }, name = "sp_unq_short_name") }) public class SavingsProduct extends AbstractPersistable { @Column(name = "name", nullable = false, unique = true) private String name; - + @Column(name = "short_name", nullable = false, unique = true) private String shortName; @@ -131,25 +131,26 @@ public class SavingsProduct extends AbstractPersistable { @ManyToMany @JoinTable(name = "m_savings_product_charge", joinColumns = @JoinColumn(name = "savings_product_id"), inverseJoinColumns = @JoinColumn(name = "charge_id")) private Set charges; - + @Column(name = "allow_overdraft") private boolean allowOverdraft; - + @Column(name = "overdraft_limit", scale = 6, precision = 19, nullable = true) private BigDecimal overdraftLimit; - - public static SavingsProduct createNew(final String name, final String shortName, final String description, final MonetaryCurrency currency, - final BigDecimal interestRate, final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType, + + public static SavingsProduct createNew(final String name, final String shortName, final String description, + final MonetaryCurrency currency, final BigDecimal interestRate, + final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType, final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType, final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance, final Integer lockinPeriodFrequency, final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final boolean withdrawalFeeApplicableForTransfer, final AccountingRuleType accountingRuleType, final Set charges, - final boolean allowOverdraft,final BigDecimal overdraftLimit) { + final boolean allowOverdraft, final BigDecimal overdraftLimit) { - return new SavingsProduct(name, shortName, description, currency, interestRate, interestCompoundingPeriodType, interestPostingPeriodType, - interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, - lockinPeriodFrequencyType, withdrawalFeeApplicableForTransfer, accountingRuleType, charges, - allowOverdraft,overdraftLimit); + return new SavingsProduct(name, shortName, description, currency, interestRate, interestCompoundingPeriodType, + interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, + lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeApplicableForTransfer, accountingRuleType, charges, + allowOverdraft, overdraftLimit); } protected SavingsProduct() { @@ -157,13 +158,13 @@ public class SavingsProduct extends AbstractPersistable { this.description = null; } - private SavingsProduct(final String name, final String shortName, final String description, final MonetaryCurrency currency, final BigDecimal interestRate, - final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType, + private SavingsProduct(final String name, final String shortName, final String description, final MonetaryCurrency currency, + final BigDecimal interestRate, final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType, final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType, final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance, final Integer lockinPeriodFrequency, final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final boolean withdrawalFeeApplicableForTransfer, final AccountingRuleType accountingRuleType, final Set charges, - final boolean allowOverdraft,final BigDecimal overdraftLimit) { + final boolean allowOverdraft, final BigDecimal overdraftLimit) { this.name = name; this.shortName = shortName; @@ -184,13 +185,14 @@ public class SavingsProduct extends AbstractPersistable { if (lockinPeriodFrequency != null && lockinPeriodFrequencyType != null) { this.lockinPeriodFrequencyType = lockinPeriodFrequencyType.getValue(); } - + this.withdrawalFeeApplicableForTransfer = withdrawalFeeApplicableForTransfer; - /* this.annualFeeAmount = annualFeeAmount; - if (annualFeeAmount != null && annualFeeOnMonthDay != null) { - this.annualFeeOnMonth = annualFeeOnMonthDay.getMonthOfYear(); - this.annualFeeOnDay = annualFeeOnMonthDay.getDayOfMonth(); - }*/ + /* + * this.annualFeeAmount = annualFeeAmount; if (annualFeeAmount != null + * && annualFeeOnMonthDay != null) { this.annualFeeOnMonth = + * annualFeeOnMonthDay.getMonthOfYear(); this.annualFeeOnDay = + * annualFeeOnMonthDay.getDayOfMonth(); } + */ if (accountingRuleType != null) { this.accountingRule = accountingRuleType.getValue(); @@ -201,8 +203,8 @@ public class SavingsProduct extends AbstractPersistable { } validateLockinDetails(); - //validateWithdrawalFeeDetails(); - //validateAnnualFeeDetails(); + // validateWithdrawalFeeDetails(); + // validateAnnualFeeDetails(); this.allowOverdraft = allowOverdraft; this.overdraftLimit = overdraftLimit; } @@ -258,7 +260,7 @@ public class SavingsProduct extends AbstractPersistable { actualChanges.put(nameParamName, newValue); this.name = newValue; } - + if (command.isChangeInStringParameterNamed(shortNameParamName, this.name)) { final String newValue = command.stringValueOfParameterNamed(shortNameParamName); actualChanges.put(shortNameParamName, newValue); @@ -354,20 +356,24 @@ public class SavingsProduct extends AbstractPersistable { if (this.lockinPeriodFrequency == null) { this.lockinPeriodFrequencyType = null; } -/* - if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull(withdrawalFeeAmountParamName, this.withdrawalFeeAmount)) { - final BigDecimal newValue = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(withdrawalFeeAmountParamName); - actualChanges.put(withdrawalFeeAmountParamName, newValue); - actualChanges.put(localeParamName, localeAsInput); - this.withdrawalFeeAmount = newValue; - } - - if (command.isChangeInIntegerParameterNamedDefaultingZeroToNull(withdrawalFeeTypeParamName, this.withdrawalFeeType)) { - final Integer newValue = command.integerValueOfParameterNamedDefaultToNullIfZero(withdrawalFeeTypeParamName); - actualChanges.put(withdrawalFeeTypeParamName, newValue); - this.withdrawalFeeType = newValue != null ? SavingsWithdrawalFeesType.fromInt(newValue).getValue() : newValue; - } -*/ + /* + * if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull( + * withdrawalFeeAmountParamName, this.withdrawalFeeAmount)) { final + * BigDecimal newValue = + * command.bigDecimalValueOfParameterNamedDefaultToNullIfZero + * (withdrawalFeeAmountParamName); + * actualChanges.put(withdrawalFeeAmountParamName, newValue); + * actualChanges.put(localeParamName, localeAsInput); + * this.withdrawalFeeAmount = newValue; } + * + * if (command.isChangeInIntegerParameterNamedDefaultingZeroToNull( + * withdrawalFeeTypeParamName, this.withdrawalFeeType)) { final Integer + * newValue = command.integerValueOfParameterNamedDefaultToNullIfZero( + * withdrawalFeeTypeParamName); + * actualChanges.put(withdrawalFeeTypeParamName, newValue); + * this.withdrawalFeeType = newValue != null ? + * SavingsWithdrawalFeesType.fromInt(newValue).getValue() : newValue; } + */ if (command.isChangeInBooleanParameterNamed(withdrawalFeeForTransfersParamName, this.withdrawalFeeApplicableForTransfer)) { final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(withdrawalFeeForTransfersParamName); actualChanges.put(withdrawalFeeForTransfersParamName, newValue); @@ -375,40 +381,45 @@ public class SavingsProduct extends AbstractPersistable { } // set period type to null if frequency is null -// if (this.withdrawalFeeAmount == null) { -// this.withdrawalFeeType = null; -// } + // if (this.withdrawalFeeAmount == null) { + // this.withdrawalFeeType = null; + // } -/* if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull(feeAmountParamName, this.annualFeeAmount)) { - final BigDecimal newValue = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(feeAmountParamName); - actualChanges.put(feeAmountParamName, newValue); - actualChanges.put(localeParamName, localeAsInput); - this.annualFeeAmount = newValue; - } + /* + * if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull( + * feeAmountParamName, this.annualFeeAmount)) { final BigDecimal + * newValue = + * command.bigDecimalValueOfParameterNamedDefaultToNullIfZero( + * feeAmountParamName); actualChanges.put(feeAmountParamName, newValue); + * actualChanges.put(localeParamName, localeAsInput); + * this.annualFeeAmount = newValue; } + * + * if (command.isChangeInIntegerParameterNamedDefaultingZeroToNull( + * feeOnMonthDayParamName, this.annualFeeOnDay)) { final MonthDay + * monthDay = command.extractMonthDayNamed(feeOnMonthDayParamName); + * final String actualValueEntered = + * command.stringValueOfParameterNamed(feeOnMonthDayParamName); final + * Integer newValue = monthDay != null ? monthDay.getDayOfMonth() : + * null; actualChanges.put(feeOnMonthDayParamName, actualValueEntered); + * actualChanges.put(localeParamName, localeAsInput); + * this.annualFeeOnDay = newValue; } + * + * if (command.isChangeInIntegerParameterNamedDefaultingZeroToNull( + * feeOnMonthDayParamName, this.annualFeeOnMonth)) { final MonthDay + * monthDay = command.extractMonthDayNamed(feeOnMonthDayParamName); + * final String actualValueEntered = + * command.stringValueOfParameterNamed(feeOnMonthDayParamName); final + * Integer newValue = monthDay != null ? monthDay.getMonthOfYear() : + * null; actualChanges.put(feeOnMonthDayParamName, actualValueEntered); + * actualChanges.put(localeParamName, localeAsInput); + * this.annualFeeOnMonth = newValue; } + */ - if (command.isChangeInIntegerParameterNamedDefaultingZeroToNull(feeOnMonthDayParamName, this.annualFeeOnDay)) { - final MonthDay monthDay = command.extractMonthDayNamed(feeOnMonthDayParamName); - final String actualValueEntered = command.stringValueOfParameterNamed(feeOnMonthDayParamName); - final Integer newValue = monthDay != null ? monthDay.getDayOfMonth() : null; - actualChanges.put(feeOnMonthDayParamName, actualValueEntered); - actualChanges.put(localeParamName, localeAsInput); - this.annualFeeOnDay = newValue; - } - - if (command.isChangeInIntegerParameterNamedDefaultingZeroToNull(feeOnMonthDayParamName, this.annualFeeOnMonth)) { - final MonthDay monthDay = command.extractMonthDayNamed(feeOnMonthDayParamName); - final String actualValueEntered = command.stringValueOfParameterNamed(feeOnMonthDayParamName); - final Integer newValue = monthDay != null ? monthDay.getMonthOfYear() : null; - actualChanges.put(feeOnMonthDayParamName, actualValueEntered); - actualChanges.put(localeParamName, localeAsInput); - this.annualFeeOnMonth = newValue; - }*/ - -// // set period type to null if frequency is null -// if (this.annualFeeAmount == null) { -// this.annualFeeOnDay = null; -// this.annualFeeOnMonth = null; -// } + // // set period type to null if frequency is null + // if (this.annualFeeAmount == null) { + // this.annualFeeOnDay = null; + // this.annualFeeOnMonth = null; + // } if (command.isChangeInIntegerParameterNamed(accountingRuleParamName, this.accountingRule)) { final Integer newValue = command.integerValueOfParameterNamed(accountingRuleParamName); @@ -429,70 +440,76 @@ public class SavingsProduct extends AbstractPersistable { actualChanges.put(allowOverdraftParamName, newValue); this.allowOverdraft = newValue; } - - if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull(overdraftLimitParamName, - this.overdraftLimit)) { + + if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull(overdraftLimitParamName, this.overdraftLimit)) { final BigDecimal newValue = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(overdraftLimitParamName); actualChanges.put(overdraftLimitParamName, newValue); actualChanges.put(localeParamName, localeAsInput); this.overdraftLimit = newValue; } - if(!this.allowOverdraft){ - this.overdraftLimit = null; - } - + if (!this.allowOverdraft) { + this.overdraftLimit = null; + } + validateLockinDetails(); - //validateWithdrawalFeeDetails(); - //validateAnnualFeeDetails(); + // validateWithdrawalFeeDetails(); + // validateAnnualFeeDetails(); return actualChanges; } -/* private void validateAnnualFeeDetails() { - - final List dataValidationErrors = new ArrayList(); - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) - .resource(SAVINGS_PRODUCT_RESOURCE_NAME); - - if (this.annualFeeAmount == null) { - - if (this.annualFeeOnMonth != null || this.annualFeeOnDay != null) { - baseDataValidator.reset().parameter(feeAmountParamName).value(this.annualFeeAmount).notNull(); - } - } else { - - if (this.annualFeeOnMonth == null || this.annualFeeOnDay == null) { - baseDataValidator.reset().parameter(feeOnMonthDayParamName).value(this.annualFeeOnMonth).notNull(); - } - - baseDataValidator.reset().parameter(feeAmountParamName).value(this.annualFeeAmount).zeroOrPositiveAmount(); - } - - if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } - } -*/ -/* private void validateWithdrawalFeeDetails() { - - final List dataValidationErrors = new ArrayList(); - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) - .resource(SAVINGS_PRODUCT_RESOURCE_NAME); - - if (this.withdrawalFeeAmount == null) { - baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(this.withdrawalFeeType).ignoreIfNull() - .isOneOfTheseValues(1, 2); - - if (this.withdrawalFeeType != null) { - baseDataValidator.reset().parameter(withdrawalFeeAmountParamName).value(this.withdrawalFeeAmount).notNull(); - } - } else { - baseDataValidator.reset().parameter(withdrawalFeeAmountParamName).value(this.withdrawalFeeAmount).zeroOrPositiveAmount(); - baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(this.withdrawalFeeType).notNull() - .isOneOfTheseValues(1, 2); - } - - if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } - } -*/ + /* + * private void validateAnnualFeeDetails() { + * + * final List dataValidationErrors = new + * ArrayList(); final DataValidatorBuilder + * baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + * .resource(SAVINGS_PRODUCT_RESOURCE_NAME); + * + * if (this.annualFeeAmount == null) { + * + * if (this.annualFeeOnMonth != null || this.annualFeeOnDay != null) { + * baseDataValidator + * .reset().parameter(feeAmountParamName).value(this.annualFeeAmount + * ).notNull(); } } else { + * + * if (this.annualFeeOnMonth == null || this.annualFeeOnDay == null) { + * baseDataValidator + * .reset().parameter(feeOnMonthDayParamName).value(this.annualFeeOnMonth + * ).notNull(); } + * + * baseDataValidator.reset().parameter(feeAmountParamName).value(this. + * annualFeeAmount).zeroOrPositiveAmount(); } + * + * if (!dataValidationErrors.isEmpty()) { throw new + * PlatformApiDataValidationException(dataValidationErrors); } } + */ + /* + * private void validateWithdrawalFeeDetails() { + * + * final List dataValidationErrors = new + * ArrayList(); final DataValidatorBuilder + * baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + * .resource(SAVINGS_PRODUCT_RESOURCE_NAME); + * + * if (this.withdrawalFeeAmount == null) { + * baseDataValidator.reset().parameter + * (withdrawalFeeTypeParamName).value(this.withdrawalFeeType).ignoreIfNull() + * .isOneOfTheseValues(1, 2); + * + * if (this.withdrawalFeeType != null) { + * baseDataValidator.reset().parameter( + * withdrawalFeeAmountParamName).value(this.withdrawalFeeAmount).notNull(); + * } } else { + * baseDataValidator.reset().parameter(withdrawalFeeAmountParamName + * ).value(this.withdrawalFeeAmount).zeroOrPositiveAmount(); + * baseDataValidator + * .reset().parameter(withdrawalFeeTypeParamName).value(this + * .withdrawalFeeType).notNull() .isOneOfTheseValues(1, 2); } + * + * if (!dataValidationErrors.isEmpty()) { throw new + * PlatformApiDataValidationException(dataValidationErrors); } } + */ private void validateLockinDetails() { final List dataValidationErrors = new ArrayList(); @@ -548,22 +565,18 @@ public class SavingsProduct extends AbstractPersistable { return updated; } - public BigDecimal overdraftLimit() { return this.overdraftLimit; } - public boolean isWithdrawalFeeApplicableForTransfer() { return this.withdrawalFeeApplicableForTransfer; } - public boolean isAllowOverdraft() { return this.allowOverdraft; } - public Set charges() { return this.charges; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductAssembler.java index 3124326db..da1473147 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductAssembler.java @@ -25,7 +25,6 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.shortNameP import static org.mifosplatform.portfolio.savings.SavingsApiConstants.allowOverdraftParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.overdraftLimitParamName; - import java.math.BigDecimal; import java.util.HashSet; import java.util.Set; @@ -115,19 +114,18 @@ public class SavingsProductAssembler { // Savings product charges final Set charges = assembleListOfSavingsProductCharges(command, currencyCode); - + boolean allowOverdraft = false; if (command.parameterExists(allowOverdraftParamName)) { allowOverdraft = command.booleanPrimitiveValueOfParameterNamed(allowOverdraftParamName); } - final BigDecimal overdraftLimit = command - .bigDecimalValueOfParameterNamedDefaultToNullIfZero(overdraftLimitParamName); + final BigDecimal overdraftLimit = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(overdraftLimitParamName); return SavingsProduct.createNew(name, shortName, description, currency, interestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, iswithdrawalFeeApplicableForTransfer, accountingRuleType, charges, - allowOverdraft,overdraftLimit); + allowOverdraft, overdraftLimit); } public Set assembleListOfSavingsProductCharges(final JsonCommand command, final String savingsProductCurrencyCode) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductChargeAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductChargeAssembler.java index 3665c3cdf..40edeaca2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductChargeAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsProductChargeAssembler.java @@ -73,9 +73,11 @@ public class SavingsProductChargeAssembler { savingsChargeElement, locale); final LocalDate dueDate = this.fromApiJsonHelper.extractLocalDateNamed(dueAsOfDateParamName, savingsChargeElement, dateFormat, locale); - final MonthDay feeOnMonthDay = this.fromApiJsonHelper.extractMonthDayNamed(feeOnMonthDayParamName, savingsChargeElement); - final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed(feeIntervalParamName, savingsChargeElement, locale); - + final MonthDay feeOnMonthDay = this.fromApiJsonHelper + .extractMonthDayNamed(feeOnMonthDayParamName, savingsChargeElement); + final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed(feeIntervalParamName, savingsChargeElement, + locale); + if (id == null) { final Charge chargeDefinition = this.chargeRepository.findOneWithNotFoundDetection(chargeId); final ChargeTimeType chargeTime = null; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/handler/ApplyAnnualFeeSavingsAccountCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/handler/ApplyAnnualFeeSavingsAccountCommandHandler.java index 1ffb43227..3fe462819 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/handler/ApplyAnnualFeeSavingsAccountCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/handler/ApplyAnnualFeeSavingsAccountCommandHandler.java @@ -32,7 +32,9 @@ public class ApplyAnnualFeeSavingsAccountCommandHandler implements NewCommandSou @SuppressWarnings("unused") final LocalDate annualFeeTransactionDate = command.localDateValueOfParameterNamed("annualFeeTransactionDate"); - //return this.writePlatformService.applyAnnualFee(command.getSavingsId(), annualFeeTransactionDate); + // return + // this.writePlatformService.applyAnnualFee(command.getSavingsId(), + // annualFeeTransactionDate); return null; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformService.java index 9fc9b6ae9..6de5b8bd4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformService.java @@ -18,8 +18,8 @@ public interface SavingsAccountChargeReadPlatformService { Collection retrieveSavingsAccountCharges(Long savingsAccountId); SavingsAccountChargeData retrieveSavingsAccountChargeDetails(Long savingsAccountChargeId, Long savingsAccountId); - + Collection retrieveChargesWithAnnualFeeDue(); - + Collection retrieveChargesWithDue(); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformServiceImpl.java index 7d9663d19..34d4f8920 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountChargeReadPlatformServiceImpl.java @@ -38,8 +38,8 @@ public class SavingsAccountChargeReadPlatformServiceImpl implements SavingsAccou private final JdbcTemplate jdbcTemplate; private final PlatformSecurityContext context; private final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService; - - //mappers + + // mappers private final SavingsAccountChargeDueMapper chargeDueMapper; @Autowired diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformService.java index a05275a49..f93b9fa03 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformService.java @@ -26,7 +26,8 @@ public interface SavingsAccountReadPlatformService { Collection retrieveAllTransactions(Long savingsId); - //Collection retrieveAccountsWithAnnualFeeDue(); + // Collection + // retrieveAccountsWithAnnualFeeDue(); SavingsAccountTransactionData retrieveSavingsTransaction(Long savingsId, Long transactionId); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java index 3c3ece46a..8918a50e2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java @@ -72,7 +72,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead private final SavingsAccountTransactionTemplateMapper transactionTemplateMapper; private final SavingsAccountTransactionsMapper transactionsMapper; private final SavingAccountMapper savingAccountMapper; - //private final SavingsAccountAnnualFeeMapper annualFeeMapper; + // private final SavingsAccountAnnualFeeMapper annualFeeMapper; // pagination private final PaginationHelper paginationHelper = new PaginationHelper(); @@ -93,7 +93,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead this.transactionTemplateMapper = new SavingsAccountTransactionTemplateMapper(); this.transactionsMapper = new SavingsAccountTransactionsMapper(); this.savingAccountMapper = new SavingAccountMapper(); - //this.annualFeeMapper = new SavingsAccountAnnualFeeMapper(); + // this.annualFeeMapper = new SavingsAccountAnnualFeeMapper(); this.chargeReadPlatformService = chargeReadPlatformService; } @@ -220,15 +220,15 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead sqlBuilder.append("sa.min_required_opening_balance as minRequiredOpeningBalance, "); sqlBuilder.append("sa.lockin_period_frequency as lockinPeriodFrequency,"); sqlBuilder.append("sa.lockin_period_frequency_enum as lockinPeriodFrequencyType, "); -// sqlBuilder.append("sa.withdrawal_fee_amount as withdrawalFeeAmount,"); -// sqlBuilder.append("sa.withdrawal_fee_type_enum as withdrawalFeeTypeEnum, "); + // sqlBuilder.append("sa.withdrawal_fee_amount as withdrawalFeeAmount,"); + // sqlBuilder.append("sa.withdrawal_fee_type_enum as withdrawalFeeTypeEnum, "); sqlBuilder.append("sa.withdrawal_fee_for_transfer as withdrawalFeeForTransfers, "); sqlBuilder.append("sa.allow_overdraft as allowOverdraft, "); sqlBuilder.append("sa.overdraft_limit as overdraftLimit, "); -// sqlBuilder.append("sa.annual_fee_amount as annualFeeAmount,"); -// sqlBuilder.append("sa.annual_fee_on_month as annualFeeOnMonth, "); -// sqlBuilder.append("sa.annual_fee_on_day as annualFeeOnDay, "); -// sqlBuilder.append("sa.annual_fee_next_due_date as annualFeeNextDueDate, "); + // sqlBuilder.append("sa.annual_fee_amount as annualFeeAmount,"); + // sqlBuilder.append("sa.annual_fee_on_month as annualFeeOnMonth, "); + // sqlBuilder.append("sa.annual_fee_on_day as annualFeeOnDay, "); + // sqlBuilder.append("sa.annual_fee_next_due_date as annualFeeNextDueDate, "); sqlBuilder.append("sa.total_deposits_derived as totalDeposits, "); sqlBuilder.append("sa.total_withdrawals_derived as totalWithdrawals, "); sqlBuilder.append("sa.total_withdrawal_fees_derived as totalWithdrawalFees, "); @@ -351,30 +351,37 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead lockinPeriodFrequencyType = SavingsEnumerations.lockinPeriodFrequencyType(lockinPeriodType); } - /*final BigDecimal withdrawalFeeAmount = rs.getBigDecimal("withdrawalFeeAmount"); - - EnumOptionData withdrawalFeeType = null; - final Integer withdrawalFeeTypeValue = JdbcSupport.getInteger(rs, "withdrawalFeeTypeEnum"); - if (withdrawalFeeTypeValue != null) { - withdrawalFeeType = SavingsEnumerations.withdrawalFeeType(withdrawalFeeTypeValue); - }*/ + /* + * final BigDecimal withdrawalFeeAmount = + * rs.getBigDecimal("withdrawalFeeAmount"); + * + * EnumOptionData withdrawalFeeType = null; final Integer + * withdrawalFeeTypeValue = JdbcSupport.getInteger(rs, + * "withdrawalFeeTypeEnum"); if (withdrawalFeeTypeValue != null) { + * withdrawalFeeType = + * SavingsEnumerations.withdrawalFeeType(withdrawalFeeTypeValue); } + */ final boolean withdrawalFeeForTransfers = rs.getBoolean("withdrawalFeeForTransfers"); - + final boolean allowOverdraft = rs.getBoolean("allowOverdraft"); final BigDecimal overdraftLimit = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "overdraftLimit"); - /*final BigDecimal annualFeeAmount = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "annualFeeAmount"); - - MonthDay annualFeeOnMonthDay = null; - final Integer annualFeeOnMonth = JdbcSupport.getInteger(rs, "annualFeeOnMonth"); - final Integer annualFeeOnDay = JdbcSupport.getInteger(rs, "annualFeeOnDay"); - if (annualFeeAmount != null && annualFeeOnDay != null) { - annualFeeOnMonthDay = new MonthDay(annualFeeOnMonth, annualFeeOnDay); - } - - final LocalDate annualFeeNextDueDate = JdbcSupport.getLocalDate(rs, "annualFeeNextDueDate"); -*/ + /* + * final BigDecimal annualFeeAmount = + * JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, + * "annualFeeAmount"); + * + * MonthDay annualFeeOnMonthDay = null; final Integer + * annualFeeOnMonth = JdbcSupport.getInteger(rs, + * "annualFeeOnMonth"); final Integer annualFeeOnDay = + * JdbcSupport.getInteger(rs, "annualFeeOnDay"); if (annualFeeAmount + * != null && annualFeeOnDay != null) { annualFeeOnMonthDay = new + * MonthDay(annualFeeOnMonth, annualFeeOnDay); } + * + * final LocalDate annualFeeNextDueDate = + * JdbcSupport.getLocalDate(rs, "annualFeeNextDueDate"); + */ final BigDecimal totalDeposits = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "totalDeposits"); final BigDecimal totalWithdrawals = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "totalWithdrawals"); final BigDecimal totalWithdrawalFees = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "totalWithdrawalFees"); @@ -393,7 +400,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead return SavingsAccountData.instance(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName, fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, - lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary,allowOverdraft,overdraftLimit); + lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, allowOverdraft, overdraftLimit); } } @@ -543,7 +550,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead @Override public Collection retrieveAllTransactions(final Long savingsId) { - final String sql = "select " + this.transactionsMapper.schema() + " where sa.id = ? order by tr.transaction_date DESC, tr.created_date DESC, tr.id DESC"; + final String sql = "select " + this.transactionsMapper.schema() + + " where sa.id = ? order by tr.transaction_date DESC, tr.created_date DESC, tr.id DESC"; return this.jdbcTemplate.query(sql, this.transactionsMapper, new Object[] { savingsId }); } @@ -556,13 +564,16 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead return this.jdbcTemplate.queryForObject(sql, this.transactionsMapper, new Object[] { savingsId, transactionId }); } - /*@Override - public Collection retrieveAccountsWithAnnualFeeDue() { - final String sql = "select " + this.annualFeeMapper.schema() - + " where sa.annual_fee_next_due_date is not null and sa.annual_fee_next_due_date <= NOW()"; - - return this.jdbcTemplate.query(sql, this.annualFeeMapper, new Object[] {}); - }*/ + /* + * @Override public Collection + * retrieveAccountsWithAnnualFeeDue() { final String sql = "select " + + * this.annualFeeMapper.schema() + + * " where sa.annual_fee_next_due_date is not null and sa.annual_fee_next_due_date <= NOW()" + * ; + * + * return this.jdbcTemplate.query(sql, this.annualFeeMapper, new Object[] + * {}); } + */ private static final class SavingsAccountTransactionsMapper implements RowMapper { @@ -734,14 +745,14 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead sqlBuilder.append("sp.min_required_opening_balance as minRequiredOpeningBalance, "); sqlBuilder.append("sp.lockin_period_frequency as lockinPeriodFrequency,"); sqlBuilder.append("sp.lockin_period_frequency_enum as lockinPeriodFrequencyType, "); -// sqlBuilder.append("sp.withdrawal_fee_amount as withdrawalFeeAmount,"); -// sqlBuilder.append("sp.withdrawal_fee_type_enum as withdrawalFeeTypeEnum, "); + // sqlBuilder.append("sp.withdrawal_fee_amount as withdrawalFeeAmount,"); + // sqlBuilder.append("sp.withdrawal_fee_type_enum as withdrawalFeeTypeEnum, "); sqlBuilder.append("sp.withdrawal_fee_for_transfer as withdrawalFeeForTransfers, "); sqlBuilder.append("sp.allow_overdraft as allowOverdraft, "); sqlBuilder.append("sp.overdraft_limit as overdraftLimit "); -// sqlBuilder.append("sp.annual_fee_amount as annualFeeAmount,"); -// sqlBuilder.append("sp.annual_fee_on_month as annualFeeOnMonth, "); -// sqlBuilder.append("sp.annual_fee_on_day as annualFeeOnDay "); + // sqlBuilder.append("sp.annual_fee_amount as annualFeeAmount,"); + // sqlBuilder.append("sp.annual_fee_on_month as annualFeeOnMonth, "); + // sqlBuilder.append("sp.annual_fee_on_day as annualFeeOnDay "); sqlBuilder.append("from m_savings_product sp "); sqlBuilder.append("join m_currency curr on curr.code = sp.currency_code "); @@ -793,27 +804,33 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead lockinPeriodFrequencyType = SavingsEnumerations.lockinPeriodFrequencyType(lockinPeriodType); } -// final BigDecimal withdrawalFeeAmount = rs.getBigDecimal("withdrawalFeeAmount"); + // final BigDecimal withdrawalFeeAmount = + // rs.getBigDecimal("withdrawalFeeAmount"); -/* EnumOptionData withdrawalFeeType = null; - final Integer withdrawalFeeTypeValue = JdbcSupport.getInteger(rs, "withdrawalFeeTypeEnum"); - if (withdrawalFeeTypeValue != null) { - withdrawalFeeType = SavingsEnumerations.withdrawalFeeType(withdrawalFeeTypeValue); - } -*/ + /* + * EnumOptionData withdrawalFeeType = null; final Integer + * withdrawalFeeTypeValue = JdbcSupport.getInteger(rs, + * "withdrawalFeeTypeEnum"); if (withdrawalFeeTypeValue != null) { + * withdrawalFeeType = + * SavingsEnumerations.withdrawalFeeType(withdrawalFeeTypeValue); } + */ final boolean withdrawalFeeForTransfers = rs.getBoolean("withdrawalFeeForTransfers"); - + final boolean allowOverdraft = rs.getBoolean("allowOverdraft"); final BigDecimal overdraftLimit = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "overdraftLimit"); - //final BigDecimal annualFeeAmount = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "annualFeeAmount"); + // final BigDecimal annualFeeAmount = + // JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, + // "annualFeeAmount"); - /*MonthDay annualFeeOnMonthDay = null; - final Integer annualFeeOnMonth = JdbcSupport.getInteger(rs, "annualFeeOnMonth"); - final Integer annualFeeOnDay = JdbcSupport.getInteger(rs, "annualFeeOnDay"); - if (annualFeeAmount != null && annualFeeOnDay != null) { - annualFeeOnMonthDay = new MonthDay(annualFeeOnMonth, annualFeeOnDay); - }*/ + /* + * MonthDay annualFeeOnMonthDay = null; final Integer + * annualFeeOnMonth = JdbcSupport.getInteger(rs, + * "annualFeeOnMonth"); final Integer annualFeeOnDay = + * JdbcSupport.getInteger(rs, "annualFeeOnDay"); if (annualFeeAmount + * != null && annualFeeOnDay != null) { annualFeeOnMonthDay = new + * MonthDay(annualFeeOnMonth, annualFeeOnDay); } + */ Long clientId = null; String clientName = null; @@ -832,7 +849,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead final Long fieldOfficerId = null; final String fieldOfficerName = null; final SavingsAccountStatusEnumData status = null; -// final LocalDate annualFeeNextDueDate = null; + // final LocalDate annualFeeNextDueDate = null; final SavingsAccountSummaryData summary = null; final SavingsAccountApplicationTimelineData timeline = SavingsAccountApplicationTimelineData.templateDefault(); @@ -840,35 +857,35 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead return SavingsAccountData.instance(null, null, null, groupId, groupName, clientId, clientName, productId, productName, fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualIterestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, - lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary,allowOverdraft,overdraftLimit); + lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, allowOverdraft, overdraftLimit); } } - /*private static final class SavingsAccountAnnualFeeMapper implements RowMapper { - - private final String schemaSql; - - public SavingsAccountAnnualFeeMapper() { - final StringBuilder sqlBuilder = new StringBuilder(200); - sqlBuilder.append("sa.id as id, sa.account_no as accountNo, "); - sqlBuilder.append("sa.annual_fee_next_due_date as annualFeeNextDueDate "); - sqlBuilder.append("from m_savings_account sa "); - - this.schemaSql = sqlBuilder.toString(); - } - - public String schema() { - return this.schemaSql; - } - - @Override - public SavingsAccountAnnualFeeData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { - - final Long id = rs.getLong("id"); - final String accountNo = rs.getString("accountNo"); - final LocalDate annualFeeNextDueDate = JdbcSupport.getLocalDate(rs, "annualFeeNextDueDate"); - - return SavingsAccountAnnualFeeData.instance(id, accountNo, annualFeeNextDueDate); - } - }*/ + /* + * private static final class SavingsAccountAnnualFeeMapper implements + * RowMapper { + * + * private final String schemaSql; + * + * public SavingsAccountAnnualFeeMapper() { final StringBuilder sqlBuilder = + * new StringBuilder(200); + * sqlBuilder.append("sa.id as id, sa.account_no as accountNo, "); + * sqlBuilder + * .append("sa.annual_fee_next_due_date as annualFeeNextDueDate "); + * sqlBuilder.append("from m_savings_account sa "); + * + * this.schemaSql = sqlBuilder.toString(); } + * + * public String schema() { return this.schemaSql; } + * + * @Override public SavingsAccountAnnualFeeData mapRow(final ResultSet rs, + * @SuppressWarnings("unused") final int rowNum) throws SQLException { + * + * final Long id = rs.getLong("id"); final String accountNo = + * rs.getString("accountNo"); final LocalDate annualFeeNextDueDate = + * JdbcSupport.getLocalDate(rs, "annualFeeNextDueDate"); + * + * return SavingsAccountAnnualFeeData.instance(id, accountNo, + * annualFeeNextDueDate); } } + */ } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformService.java index 1fa993980..836b93b19 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformService.java @@ -51,6 +51,6 @@ public interface SavingsAccountWritePlatformService { CommandProcessingResult waiveCharge(Long savingsAccountId, Long savingsAccountChargeId); CommandProcessingResult payCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command); - + void applyChargeDue(final Long savingsAccountChargeId, final Long accountId); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java index 2434b048f..774115cd1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java @@ -152,7 +152,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi final Map changes = account.activate(user, command, DateUtils.getLocalDateOfTenant()); if (!changes.isEmpty()) { - + final MathContext mc = MathContext.DECIMAL64; if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) { final LocalDate today = DateUtils.getLocalDateOfTenant(); @@ -316,11 +316,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN); account.postInterest(mc, today); - + // for generating transaction id's List transactions = account.getTransactions(); - for(SavingsAccountTransaction accountTransaction:transactions){ - if(accountTransaction.getId() == null){ + for (SavingsAccountTransaction accountTransaction : transactions) { + if (accountTransaction.getId() == null) { this.savingsAccountTransactionRepository.save(accountTransaction); } } @@ -376,7 +376,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi account.undoTransaction(transactionId + 1); } } - + checkClientOrGroupActive(account); if (savingsAccountTransaction.isPostInterestCalculationRequired() && account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) { @@ -442,7 +442,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi SavingsAccountTransaction transaction = null; final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail,savingsAccountTransaction.createdDate()); + paymentDetail, savingsAccountTransaction.createdDate()); if (savingsAccountTransaction.isDeposit()) { transaction = account.deposit(transactionDTO); } else { @@ -624,7 +624,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi final Locale locale = command.extractLocale(); final String format = command.dateFormat(); - final DateTimeFormatter fmt = StringUtils.isNotBlank(format) ? DateTimeFormat.forPattern(format).withLocale(locale) : DateTimeFormat.forPattern("dd MM yyyy"); + final DateTimeFormatter fmt = StringUtils.isNotBlank(format) ? DateTimeFormat.forPattern(format).withLocale(locale) + : DateTimeFormat.forPattern("dd MM yyyy"); final Long chargeDefinitionId = command.longValueOfParameterNamed(chargeIdParamName); final Charge chargeDefinition = this.chargeRepository.findOneWithNotFoundDetection(chargeDefinitionId); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsApplicationProcessWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsApplicationProcessWritePlatformService.java index bf76b59f7..24afa2d3b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsApplicationProcessWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsApplicationProcessWritePlatformService.java @@ -24,6 +24,6 @@ public interface SavingsApplicationProcessWritePlatformService { CommandProcessingResult rejectApplication(Long savingsId, JsonCommand command); CommandProcessingResult applicantWithdrawsFromApplication(Long savingsId, JsonCommand command); - + CommandProcessingResult createActiveApplication(SavingsAccountDataDTO savingsAccountDataDTO); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java index e770ab4dd..55f4d2e54 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java @@ -14,7 +14,7 @@ public interface SavingsProductReadPlatformService { Collection retrieveAll(); Collection retrieveAllForLookup(); - + Collection retrieveAllForLookupByType(boolean isOverdraftType); SavingsProductData retrieveOne(Long productId); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java index 1e8f2a06d..45cc49f1f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java @@ -74,7 +74,8 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead public SavingProductMapper() { final StringBuilder sqlBuilder = new StringBuilder(400); sqlBuilder.append("sp.id as id, sp.name as name, sp.short_name as shortName, sp.description as description, "); - sqlBuilder.append("sp.currency_code as currencyCode, sp.currency_digits as currencyDigits, sp.currency_multiplesof as inMultiplesOf, "); + sqlBuilder + .append("sp.currency_code as currencyCode, sp.currency_digits as currencyDigits, sp.currency_multiplesof as inMultiplesOf, "); sqlBuilder.append("curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, "); sqlBuilder.append("curr.display_symbol as currencyDisplaySymbol, "); sqlBuilder.append("sp.nominal_annual_interest_rate as nominalAnnualInterestRate, "); @@ -85,14 +86,14 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead sqlBuilder.append("sp.min_required_opening_balance as minRequiredOpeningBalance, "); sqlBuilder.append("sp.lockin_period_frequency as lockinPeriodFrequency,"); sqlBuilder.append("sp.lockin_period_frequency_enum as lockinPeriodFrequencyType, "); -// sqlBuilder.append("sp.withdrawal_fee_amount as withdrawalFeeAmount,"); -// sqlBuilder.append("sp.withdrawal_fee_type_enum as withdrawalFeeTypeEnum, "); + // sqlBuilder.append("sp.withdrawal_fee_amount as withdrawalFeeAmount,"); + // sqlBuilder.append("sp.withdrawal_fee_type_enum as withdrawalFeeTypeEnum, "); sqlBuilder.append("sp.withdrawal_fee_for_transfer as withdrawalFeeForTransfers, "); sqlBuilder.append("sp.allow_overdraft as allowOverdraft, "); sqlBuilder.append("sp.overdraft_limit as overdraftLimit, "); -// sqlBuilder.append("sp.annual_fee_amount as annualFeeAmount,"); -// sqlBuilder.append("sp.annual_fee_on_month as annualFeeOnMonth, "); -// sqlBuilder.append("sp.annual_fee_on_day as annualFeeOnDay, "); + // sqlBuilder.append("sp.annual_fee_amount as annualFeeAmount,"); + // sqlBuilder.append("sp.annual_fee_on_month as annualFeeOnMonth, "); + // sqlBuilder.append("sp.annual_fee_on_day as annualFeeOnDay, "); sqlBuilder.append("sp.accounting_type as accountingType "); sqlBuilder.append("from m_savings_product sp "); sqlBuilder.append("join m_currency curr on curr.code = sp.currency_code "); @@ -151,29 +152,35 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead lockinPeriodFrequencyType = SavingsEnumerations.lockinPeriodFrequencyType(lockinPeriodFrequencyTypeValue); } - /*final BigDecimal withdrawalFeeAmount = rs.getBigDecimal("withdrawalFeeAmount"); - - EnumOptionData withdrawalFeeType = null; - final Integer withdrawalFeeTypeValue = JdbcSupport.getInteger(rs, "withdrawalFeeTypeEnum"); - if (withdrawalFeeTypeValue != null) { - withdrawalFeeType = SavingsEnumerations.withdrawalFeeType(withdrawalFeeTypeValue); - } -*/ + /* + * final BigDecimal withdrawalFeeAmount = + * rs.getBigDecimal("withdrawalFeeAmount"); + * + * EnumOptionData withdrawalFeeType = null; final Integer + * withdrawalFeeTypeValue = JdbcSupport.getInteger(rs, + * "withdrawalFeeTypeEnum"); if (withdrawalFeeTypeValue != null) { + * withdrawalFeeType = + * SavingsEnumerations.withdrawalFeeType(withdrawalFeeTypeValue); } + */ final boolean withdrawalFeeForTransfers = rs.getBoolean("withdrawalFeeForTransfers"); final boolean allowOverdraft = rs.getBoolean("allowOverdraft"); final BigDecimal overdraftLimit = rs.getBigDecimal("overdraftLimit"); -/* final BigDecimal annualFeeAmount = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "annualFeeAmount"); - - MonthDay annualFeeOnMonthDay = null; - final Integer annualFeeOnMonth = JdbcSupport.getInteger(rs, "annualFeeOnMonth"); - final Integer annualFeeOnDay = JdbcSupport.getInteger(rs, "annualFeeOnDay"); - if (annualFeeAmount != null && annualFeeOnDay != null) { - annualFeeOnMonthDay = new MonthDay(annualFeeOnMonth, annualFeeOnDay); - } -*/ - return SavingsProductData.instance(id, name, shortName, description, currency, nominalAnnualInterestRate, compoundingInterestPeriodType, - interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, - lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, accountingRuleType,allowOverdraft,overdraftLimit); + /* + * final BigDecimal annualFeeAmount = + * JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, + * "annualFeeAmount"); + * + * MonthDay annualFeeOnMonthDay = null; final Integer + * annualFeeOnMonth = JdbcSupport.getInteger(rs, + * "annualFeeOnMonth"); final Integer annualFeeOnDay = + * JdbcSupport.getInteger(rs, "annualFeeOnDay"); if (annualFeeAmount + * != null && annualFeeOnDay != null) { annualFeeOnMonthDay = new + * MonthDay(annualFeeOnMonth, annualFeeOnDay); } + */ + return SavingsProductData.instance(id, name, shortName, description, currency, nominalAnnualInterestRate, + compoundingInterestPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, + minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, + accountingRuleType, allowOverdraft, overdraftLimit); } } @@ -197,7 +204,7 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead public Collection retrieveAllForLookupByType(boolean isOverdraftType) { final String sql = "select " + this.savingsProductLookupsRowMapper.schema() + " where sp.allow_overdraft=?"; - return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper,isOverdraftType); + return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, isOverdraftType); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductWritePlatformServiceJpaRepositoryImpl.java index bd530effa..1f41ed907 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductWritePlatformServiceJpaRepositoryImpl.java @@ -67,9 +67,9 @@ public class SavingsProductWritePlatformServiceJpaRepositoryImpl implements Savi + "` already exists", "name", name); } else if (realCause.getMessage().contains("sp_unq_short_name")) { - final String shortName = command.stringValueOfParameterNamed("shortName"); - throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.short.name", "Savings product with short name `" - + shortName + "` already exists", "shortName", shortName); + final String shortName = command.stringValueOfParameterNamed("shortName"); + throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.short.name", "Savings product with short name `" + + shortName + "` already exists", "shortName", shortName); } logAsErrorUnexpectedDataIntegrityException(dae); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/SearchConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/SearchConstants.java index 22ddd929c..d6043a8a8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/SearchConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/SearchConstants.java @@ -100,7 +100,7 @@ public class SearchConstants { return this.value; } } - + public static enum SEARCH_LOAN_DATE { APPROVAL_DATE("approvalDate"), CREATED_DATE("createdDate"), DISBURSAL_DATE("disbursalDate"); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/api/SearchApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/api/SearchApiResource.java index fc21af0ff..a493abaaf 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/api/SearchApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/api/SearchApiResource.java @@ -55,7 +55,7 @@ public class SearchApiResource { this.fromApiJsonDeserializer = fromApiJsonDeserializer; } - + @GET @Path("/template") @Consumes({ MediaType.APPLICATION_JSON }) @@ -81,17 +81,18 @@ public class SearchApiResource { final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.toApiJsonSerializer.serialize(settings, searchResults, this.searchResponseParameters); } - + @POST @Path("/advance") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String advancedSearch(@Context final UriInfo uriInfo,final String json) { - + public String advancedSearch(@Context final UriInfo uriInfo, final String json) { + final AdHocQuerySearchConditions searchConditions = this.fromApiJsonDeserializer.retrieveSearchConditions(json); - - final Collection searchResults = this.searchReadPlatformService.retrieveAdHocQueryMatchingData(searchConditions); - + + final Collection searchResults = this.searchReadPlatformService + .retrieveAdHocQueryMatchingData(searchConditions); + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.toApiJsonSerializer.serialize(settings, searchResults); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConditions.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConditions.java index d9077c76d..12a8bee4f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConditions.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConditions.java @@ -26,13 +26,13 @@ public class AdHocQuerySearchConditions { private final BigDecimal maxOutstandingAmount; private final BigDecimal outstandingAmount; - public static AdHocQuerySearchConditions instance(final List loanStatus, - final List loanProducts, final List offices, final String loanDateOption, final LocalDate loanFromDate, - final LocalDate loanToDate, final Boolean includeOutStandingAmountPercentage, - final String outStandingAmountPercentageCondition, final BigDecimal minOutStandingAmountPercentage, - final BigDecimal maxOutStandingAmountPercentage, final BigDecimal outStandingAmountPercentage, - final Boolean includeOutstandingAmountParamName, final String outstandingAmountCondition, - final BigDecimal minOutstandingAmount, final BigDecimal maxOutstandingAmount, final BigDecimal outstandingAmount) { + public static AdHocQuerySearchConditions instance(final List loanStatus, final List loanProducts, + final List offices, final String loanDateOption, final LocalDate loanFromDate, final LocalDate loanToDate, + final Boolean includeOutStandingAmountPercentage, final String outStandingAmountPercentageCondition, + final BigDecimal minOutStandingAmountPercentage, final BigDecimal maxOutStandingAmountPercentage, + final BigDecimal outStandingAmountPercentage, final Boolean includeOutstandingAmountParamName, + final String outstandingAmountCondition, final BigDecimal minOutstandingAmount, final BigDecimal maxOutstandingAmount, + final BigDecimal outstandingAmount) { return new AdHocQuerySearchConditions(loanStatus, loanProducts, offices, loanDateOption, loanFromDate, loanToDate, includeOutStandingAmountPercentage, outStandingAmountPercentageCondition, minOutStandingAmountPercentage, @@ -41,8 +41,8 @@ public class AdHocQuerySearchConditions { } - public AdHocQuerySearchConditions(final List loanStatus, final List loanProducts, - final List offices, final String loanDateOption, final LocalDate loanFromDate, final LocalDate loanToDate, + public AdHocQuerySearchConditions(final List loanStatus, final List loanProducts, final List offices, + final String loanDateOption, final LocalDate loanFromDate, final LocalDate loanToDate, final Boolean includeOutStandingAmountPercentage, final String outStandingAmountPercentageCondition, final BigDecimal minOutStandingAmountPercentage, final BigDecimal maxOutStandingAmountPercentage, final BigDecimal outStandingAmountPercentage, final Boolean includeOutstandingAmount, final String outstandingAmountCondition, @@ -93,7 +93,8 @@ public class AdHocQuerySearchConditions { } if (statusCode.equalsIgnoreCase("arrears")) { - //TODO - No status code is there for loans which are in active bad standing + // TODO - No status code is there for loans which are in + // active bad standing } if (statusCode.equalsIgnoreCase("all")) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConstants.java index 90e0212fb..c452cf48d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/AdHocQuerySearchConstants.java @@ -37,9 +37,9 @@ public interface AdHocQuerySearchConstants { public static final Set AD_HOC_SEARCH_QUERY_CONDITIONS = new HashSet( Arrays.asList("between", "<=", ">=", "<", ">", "=")); - - public static final Object[] loanDateOptions = {"approvalDate", "createdDate", "disbursalDate"}; - public static final Object[] entityTypeOptions = {"clients", "groups", "loans", "clientIdentifiers"}; - public static final Object[] loanStatusOptions = {"all", "active", "overpaid", "arrears", "closed", "writeoff"}; + + public static final Object[] loanDateOptions = { "approvalDate", "createdDate", "disbursalDate" }; + public static final Object[] entityTypeOptions = { "clients", "groups", "loans", "clientIdentifiers" }; + public static final Object[] loanStatusOptions = { "all", "active", "overpaid", "arrears", "closed", "writeoff" }; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/SearchData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/SearchData.java index a66538322..2b07a9ed1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/SearchData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/data/SearchData.java @@ -58,7 +58,7 @@ public class SearchData { public String getParentName() { return this.parentName; } - + public EnumOptionData getEntityStatus() { return this.entityStatus; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/service/SearchReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/service/SearchReadPlatformServiceImpl.java index 28ee0f481..da22188a8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/service/SearchReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/search/service/SearchReadPlatformServiceImpl.java @@ -46,7 +46,7 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService @Autowired public SearchReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource, - final LoanProductReadPlatformService loanProductReadPlatformService, final OfficeReadPlatformService officeReadPlatformService ) { + final LoanProductReadPlatformService loanProductReadPlatformService, final OfficeReadPlatformService officeReadPlatformService) { this.context = context; this.namedParameterjdbcTemplate = new NamedParameterJdbcTemplate(dataSource); this.loanProductReadPlatformService = loanProductReadPlatformService; @@ -161,23 +161,23 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService final Long parentId = JdbcSupport.getLong(rs, "parentId"); final String parentName = rs.getString("parentName"); final Integer entityStatusEnum = JdbcSupport.getInteger(rs, "entityStatusEnum"); - + EnumOptionData entityStatus = new EnumOptionData(0L, "", ""); - - if(entityType.equalsIgnoreCase("client") || entityType.equalsIgnoreCase("clientidentifier")) { + + if (entityType.equalsIgnoreCase("client") || entityType.equalsIgnoreCase("clientidentifier")) { entityStatus = ClientEnumerations.status(entityStatusEnum); } - - else if(entityType.equalsIgnoreCase("group") || entityType.equalsIgnoreCase("center")) { + + else if (entityType.equalsIgnoreCase("group") || entityType.equalsIgnoreCase("center")) { entityStatus = GroupingTypeEnumerations.status(entityStatusEnum); } - - else if(entityType.equalsIgnoreCase("loan")) { + + else if (entityType.equalsIgnoreCase("loan")) { LoanStatusEnumData loanStatusEnumData = LoanEnumerations.status(entityStatusEnum); - + entityStatus = LoanEnumerations.status(loanStatusEnumData); } - + return new SearchData(entityId, entityAccountNo, entityExternalId, entityName, entityType, parentId, parentName, entityStatus); } @@ -185,12 +185,12 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService @Override public AdHocSearchQueryData retrieveAdHocQueryTemplate() { - + this.context.authenticatedUser(); - + final Collection loanProducts = this.loanProductReadPlatformService.retrieveAllLoanProductsForLookup(); final Collection offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown(); - + return AdHocSearchQueryData.template(loanProducts, offices); } @@ -209,38 +209,40 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService private boolean isWhereClauseAdded = false; - //TODO- build the query dynamically based on selected entity types, for now adding query for only loan entity. + // TODO- build the query dynamically based on selected entity types, for + // now adding query for only loan entity. public String schema(final AdHocQuerySearchConditions searchConditions, final MapSqlParameterSource params) { final StringBuffer sql = new StringBuffer(); - sql.append("Select a.name as officeName, a.Product as productName, a.cnt as 'count', a.outstandingAmt as outstanding, a.percentOut as percentOut ") - .append("from (select mo.name, mp.name Product, sum(ifnull(ml.total_expected_repayment_derived,0.0)) TotalAmt, count(*) cnt, ") - .append("sum(ifnull(ml.total_outstanding_derived,0.0)) outstandingAmt, ") - .append("(sum(ifnull(ml.total_outstanding_derived,0.0)) * 100 / sum(ifnull(ml.total_expected_repayment_derived,0.0))) percentOut ") - .append("from m_loan ml inner join m_product_loan mp on mp.id=ml.product_id ") - .append("inner join m_client mc on mc.id=ml.client_id ") - .append("inner join m_office mo on mo.id=mc.office_id "); - + sql.append( + "Select a.name as officeName, a.Product as productName, a.cnt as 'count', a.outstandingAmt as outstanding, a.percentOut as percentOut ") + .append("from (select mo.name, mp.name Product, sum(ifnull(ml.total_expected_repayment_derived,0.0)) TotalAmt, count(*) cnt, ") + .append("sum(ifnull(ml.total_outstanding_derived,0.0)) outstandingAmt, ") + .append("(sum(ifnull(ml.total_outstanding_derived,0.0)) * 100 / sum(ifnull(ml.total_expected_repayment_derived,0.0))) percentOut ") + .append("from m_loan ml inner join m_product_loan mp on mp.id=ml.product_id ") + .append("inner join m_client mc on mc.id=ml.client_id ").append("inner join m_office mo on mo.id=mc.office_id "); + if (searchConditions.getLoanStatus() != null && searchConditions.getLoanStatus().size() > 0) { - //If user requests for all statuses no need to add loanStatus filter + // If user requests for all statuses no need to add loanStatus + // filter if (!searchConditions.getLoanStatus().contains("all")) { checkAndUpdateWhereClause(sql); params.addValue("loanStatus", searchConditions.getLoanStatus()); sql.append(" ml.loan_status_id in (:loanStatus) "); } } - - if (searchConditions.getLoanProducts() != null && searchConditions.getLoanProducts().size() > 0 ) { + + if (searchConditions.getLoanProducts() != null && searchConditions.getLoanProducts().size() > 0) { checkAndUpdateWhereClause(sql); params.addValue("loanProducts", searchConditions.getLoanProducts()); sql.append(" mp.id in (:loanProducts) "); } - + if (searchConditions.getOffices() != null && searchConditions.getOffices().size() > 0) { checkAndUpdateWhereClause(sql); params.addValue("offices", searchConditions.getOffices()); sql.append(" mo.id in (:offices) "); } - + if (StringUtils.isNotBlank(searchConditions.getLoanDateOption())) { if (searchConditions.getLoanDateOption().equals(SearchConstants.SEARCH_LOAN_DATE.APPROVAL_DATE.getValue())) { checkAndUpdateWhereClause(sql); @@ -259,50 +261,53 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService sql.append(" ( ml.disbursedon_date between :loanFromDate and :loanToDate ) "); } } - + sql.append(" group by mo.id) a "); - - //update isWhereClauseAdded to false to add filters for derived table + + // update isWhereClauseAdded to false to add filters for derived + // table isWhereClauseAdded = false; - + if (searchConditions.getIncludeOutStandingAmountPercentage()) { if (searchConditions.getOutStandingAmountPercentageCondition().equals("between")) { checkAndUpdateWhereClause(sql); - // params.addValue("outStandingAmountPercentageCondition", searchConditions.getOutStandingAmountPercentageCondition()); + // params.addValue("outStandingAmountPercentageCondition", + // searchConditions.getOutStandingAmountPercentageCondition()); params.addValue("minOutStandingAmountPercentage", searchConditions.getMinOutStandingAmountPercentage()); params.addValue("maxOutStandingAmountPercentage", searchConditions.getMaxOutStandingAmountPercentage()); sql.append(" ( a.percentOut between :minOutStandingAmountPercentage and :maxOutStandingAmountPercentage ) "); } else { checkAndUpdateWhereClause(sql); - // params.addValue("outStandingAmountPercentageCondition", searchConditions.getOutStandingAmountPercentageCondition()); + // params.addValue("outStandingAmountPercentageCondition", + // searchConditions.getOutStandingAmountPercentageCondition()); params.addValue("outStandingAmountPercentage", searchConditions.getOutStandingAmountPercentage()); - sql.append(" a.percentOut ") - .append(searchConditions.getOutStandingAmountPercentageCondition()) - .append(" :outStandingAmountPercentage "); + sql.append(" a.percentOut ").append(searchConditions.getOutStandingAmountPercentageCondition()) + .append(" :outStandingAmountPercentage "); } } - + if (searchConditions.getIncludeOutstandingAmount()) { if (searchConditions.getOutstandingAmountCondition().equals("between")) { checkAndUpdateWhereClause(sql); - // params.addValue("outstandingAmountCondition", searchConditions.getOutstandingAmountCondition()); + // params.addValue("outstandingAmountCondition", + // searchConditions.getOutstandingAmountCondition()); params.addValue("minOutstandingAmount", searchConditions.getMinOutstandingAmount()); params.addValue("maxOutstandingAmount", searchConditions.getMaxOutstandingAmount()); sql.append(" ( a.outstandingAmt between :minOutstandingAmount and :maxOutstandingAmount ) "); } else { checkAndUpdateWhereClause(sql); - // params.addValue("outstandingAmountCondition", searchConditions.getOutstandingAmountCondition()); + // params.addValue("outstandingAmountCondition", + // searchConditions.getOutstandingAmountCondition()); params.addValue("outstandingAmount", searchConditions.getOutstandingAmount()); - sql.append(" a.outstandingAmt ") - .append(searchConditions.getOutstandingAmountCondition()) - .append(" :outstandingAmount "); + sql.append(" a.outstandingAmt ").append(searchConditions.getOutstandingAmountCondition()) + .append(" :outstandingAmount "); } } - + return sql.toString(); } - - private void checkAndUpdateWhereClause(final StringBuffer sql){ + + private void checkAndUpdateWhereClause(final StringBuffer sql) { if (isWhereClauseAdded) { sql.append(" and "); } else { @@ -317,11 +322,13 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService final String officeName = rs.getString("officeName"); final String loanProductName = rs.getString("productName"); final Integer count = JdbcSupport.getInteger(rs, "count"); - final BigDecimal loanOutStanding = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "outstanding").setScale(2, RoundingMode.HALF_UP); - final Double percentage = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "percentOut").setScale(2, RoundingMode.HALF_UP).doubleValue(); + final BigDecimal loanOutStanding = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "outstanding").setScale(2, + RoundingMode.HALF_UP); + final Double percentage = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "percentOut").setScale(2, RoundingMode.HALF_UP) + .doubleValue(); return AdHocSearchQueryData.matchedResult(officeName, loanProductName, count, loanOutStanding, percentage); } - + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/resources/META-INF/orm.xml b/mifosng-provider/src/main/resources/META-INF/orm.xml index fd0b58f51..9705d686e 100644 --- a/mifosng-provider/src/main/resources/META-INF/orm.xml +++ b/mifosng-provider/src/main/resources/META-INF/orm.xml @@ -1,11 +1,7 @@ - + - + diff --git a/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml b/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml index 9fa928554..157d7912c 100644 --- a/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml +++ b/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml @@ -1,18 +1,11 @@ - + - - + + - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/mifosng-provider/src/main/resources/META-INF/spring/cache.xml b/mifosng-provider/src/main/resources/META-INF/spring/cache.xml index f63c5743c..3328b4755 100644 --- a/mifosng-provider/src/main/resources/META-INF/spring/cache.xml +++ b/mifosng-provider/src/main/resources/META-INF/spring/cache.xml @@ -1,16 +1,10 @@ - + - - + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - + + + + + \ No newline at end of file diff --git a/mifosng-provider/src/main/resources/META-INF/spring/securityContext.xml b/mifosng-provider/src/main/resources/META-INF/spring/securityContext.xml index bf1733949..7918b2531 100644 --- a/mifosng-provider/src/main/resources/META-INF/spring/securityContext.xml +++ b/mifosng-provider/src/main/resources/META-INF/spring/securityContext.xml @@ -1,11 +1,7 @@ - + - - - - - - - + + + + + + + - + - - + + - - - - - - - - - + + + + + + + + + - + \ No newline at end of file diff --git a/mifosng-provider/src/main/resources/logback.xml b/mifosng-provider/src/main/resources/logback.xml index efeacad10..ad938dc2f 100644 --- a/mifosng-provider/src/main/resources/logback.xml +++ b/mifosng-provider/src/main/resources/logback.xml @@ -1,39 +1,36 @@ - + - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + - - ${catalina.base}/logs/mifos-platform.log - true - - - %-4relative [%thread] %-5level %logger{35} - %msg%n - - - - - - - - - - - + + ${catalina.base}/logs/mifos-platform.log + true + + + %-4relative [%thread] %-5level %logger{35} - %msg%n + + - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/mifosng-provider/src/main/webapp/META-INF/context.xml b/mifosng-provider/src/main/webapp/META-INF/context.xml index 2c1c56955..ab9567a5d 100644 --- a/mifosng-provider/src/main/webapp/META-INF/context.xml +++ b/mifosng-provider/src/main/webapp/META-INF/context.xml @@ -1,9 +1,8 @@ - + - + \ No newline at end of file diff --git a/mifosng-provider/src/main/webapp/WEB-INF/web.xml b/mifosng-provider/src/main/webapp/WEB-INF/web.xml index e99407078..7aa76807e 100644 --- a/mifosng-provider/src/main/webapp/WEB-INF/web.xml +++ b/mifosng-provider/src/main/webapp/WEB-INF/web.xml @@ -1,22 +1,20 @@ - - + + Mifos Platform - A provider of microfinance services which applications can consume once authenticated and authorized. + A provider of microfinance services which applications can + consume once authenticated and authorized. - webAppRootKey - mifosplatform.root - + webAppRootKey + mifosplatform.root + contextConfigLocation @@ -35,7 +33,7 @@ org.springframework.web.context.ContextLoaderListener - + jersey-serlvet @@ -45,19 +43,16 @@ true - + - com.sun.jersey.spi.container.ContainerResponseFilters - org.mifosplatform.infrastructure.core.filters.ResponseCorsFilter + com.sun.jersey.spi.container.ContainerResponseFilters + org.mifosplatform.infrastructure.core.filters.ResponseCorsFilter 1 - + jersey-serlvet /api/v1/* diff --git a/mifosng-provider/src/test/java/org/mifosplatform/mix/report/service/XBRLBuilderTest.java b/mifosng-provider/src/test/java/org/mifosplatform/mix/report/service/XBRLBuilderTest.java index cdc8c888e..0b25e6c7b 100644 --- a/mifosng-provider/src/test/java/org/mifosplatform/mix/report/service/XBRLBuilderTest.java +++ b/mifosng-provider/src/test/java/org/mifosplatform/mix/report/service/XBRLBuilderTest.java @@ -45,6 +45,7 @@ public class XBRLBuilderTest { } + @SuppressWarnings("null") @Test public void shouldCorrectlyBuildMap() { diff --git a/mifosng-provider/src/test/resources/META-INF/context.xml b/mifosng-provider/src/test/resources/META-INF/context.xml index d9556190e..bf9d7fcc8 100644 --- a/mifosng-provider/src/test/resources/META-INF/context.xml +++ b/mifosng-provider/src/test/resources/META-INF/context.xml @@ -1,13 +1,7 @@ - + \ No newline at end of file diff --git a/mifosng-provider/src/test/resources/META-INF/testContext.xml b/mifosng-provider/src/test/resources/META-INF/testContext.xml index 9b1c7a6da..7768df157 100644 --- a/mifosng-provider/src/test/resources/META-INF/testContext.xml +++ b/mifosng-provider/src/test/resources/META-INF/testContext.xml @@ -1,11 +1,9 @@ - - - - - - - - - org.mifosplatform.template - org.mifosplatform.commands.domain + + + + + + + + + + org.mifosplatform.template + org.mifosplatform.commands.domain org.mifosplatform.useradministration.domain org.mifosplatform.organisation.office.domain org.mifosplatform.organisation.staff.domain - org.mifosplatform.infrastructure.core.serialization - - - - - - - - org.hibernate.dialect.MySQLInnoDBDialect - create - - - - - - - - - + + + + + org.hibernate.dialect.MySQLInnoDBDialect + create + + + + + + + + + - + org.mifosplatform.useradministration.*"> + - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file