diff --git a/docs/system-architecture/404.css b/docs/system-architecture/404.css new file mode 100644 index 000000000..10dd45c41 --- /dev/null +++ b/docs/system-architecture/404.css @@ -0,0 +1,154 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + diff --git a/docs/system-architecture/404.html b/docs/system-architecture/404.html index fdace4ab1..dd1b6dca9 100644 --- a/docs/system-architecture/404.html +++ b/docs/system-architecture/404.html @@ -1,145 +1,16 @@ + Page Not Found :( - + + + + +

Not found :(

Sorry, but the page you were trying to view does not exist.

@@ -148,10 +19,15 @@
  • a mistyped address
  • an out-of-date link
  • + + +
    + + diff --git a/fineract-provider/WebContent/META-INF/MANIFEST.MF b/fineract-provider/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 000000000..254272e1c --- /dev/null +++ b/fineract-provider/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 331a41723..771fcde58 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -92,6 +92,7 @@ rat { excludes = [ '**/licenses/**', '**/*.md', + '**/MANIFEST.MF', '**/*.txt', '**/*.log', '**/fineractdev-eclipse-preferences.epf', diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccountingProcessorHelper.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccountingProcessorHelper.java index aeef6ced5..2e3c0f81c 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccountingProcessorHelper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/AccountingProcessorHelper.java @@ -379,18 +379,17 @@ public class AccountingProcessorHelper { * The target accounts for debits and credits are switched in case of a * reversal * - * @param office - * @param accountTypeToBeDebited - * Enum of the placeholder GLAccount to be debited - * @param accountTypeToBeCredited - * Enum of the placeholder of the GLAccount to be credited - * @param loanProductId - * @param paymentTypeId - * @param loanId - * @param transactionId - * @param transactionDate - * @param amount - * @param isReversal + * @param office office + * @param currencyCode currencyCode + * @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited + * @param accountTypeToBeCredited Enum of the placeholder of the GLAccount to be credited + * @param loanProductId loanProductId + * @param loanId loanId + * @param transactionId transactionId + * @param transactionDate transactionDate + * @param totalAmount totalAmount + * @param isReversal isReversal + * @param chargePaymentDTOs chargePaymentDTOs */ public void createAccrualBasedJournalEntriesAndReversalsForLoanCharges(final Office office, final String currencyCode, final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long loanProductId, final Long loanId, @@ -568,17 +567,17 @@ public class AccountingProcessorHelper { * reversal * * @param office - * @param accountTypeToBeDebited - * Enum of the placeholder GLAccount to be debited - * @param accountTypeToBeCredited - * Enum of the placeholder of the GLAccount to be credited + * @param currencyCode + * @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited + * @param accountTypeToBeCredited Enum of the placeholder of the GLAccount to be credited * @param savingsProductId * @param paymentTypeId - * @param loanId + * @param savingsId * @param transactionId * @param transactionDate * @param amount * @param isReversal + * @param taxDetails */ public void createCashBasedJournalEntriesAndReversalsForSavingsTax(final Office office, final String currencyCode, final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeDebited, final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeCredited, @@ -726,18 +725,18 @@ public class AccountingProcessorHelper { * The target accounts for debits and credits are switched in case of a * reversal * - * @param office - * @param accountTypeToBeDebited - * Enum of the placeholder GLAccount to be debited - * @param accountTypeToBeCredited - * Enum of the placeholder of the GLAccount to be credited - * @param savingsProductId - * @param paymentTypeId - * @param loanId - * @param transactionId - * @param transactionDate - * @param amount - * @param isReversal + * @param office office + * @param currencyCode currencyCode + * @param accountTypeToBeDebited Enum of the placeholder GLAccount to be debited + * @param accountTypeToBeCredited Enum of the placeholder of the GLAccount to be credited + * @param savingsProductId savingsProductId + * @param paymentTypeId paymentTypeId + * @param loanId loanId + * @param transactionId transactionId + * @param transactionDate transactionDate + * @param totalAmount totalAmount + * @param isReversal isReversal + * @param chargePaymentDTOs chargePaymentDTOs */ public void createCashBasedJournalEntriesAndReversalsForSavingsCharges(final Office office, final String currencyCode, final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeDebited, final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeCredited, diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java index 8183012ab..4901d2982 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplyLoanCommandStrategy.java @@ -33,9 +33,9 @@ import org.springframework.stereotype.Component; * Implements {@link org.apache.fineract.batch.command.CommandStrategy} and * applies a new loan on an existing client. It passes the contents of the body * from the BatchRequest to - * {@link org.apache.fineract.portfolio.client.api.LoansApiResource} and gets back + * {@link org.apache.fineract.portfolio.loanaccount.api.LoansApiResource} and gets back * the response. This class will also catch any errors raised by - * {@link org.apache.fineract.portfolio.client.api.LoansApiResource} and map those + * {@link org.apache.fineract.portfolio.loanaccount.api.LoansApiResource} and map those * errors to appropriate status codes in BatchResponse. * * @author Rishabh Shukla diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java index 8c97a569b..36456b3bf 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApplySavingsCommandStrategy.java @@ -33,9 +33,9 @@ import org.springframework.stereotype.Component; * Implements {@link org.apache.fineract.batch.command.CommandStrategy} and * applies a new savings on an existing client. It passes the contents of the * body from the BatchRequest to - * {@link org.apache.fineract.portfolio.client.api.SavingsAccountsApiResource} and + * {@link org.apache.fineract.portfolio.savings.api.SavingsAccountsApiResource} and * gets back the response. This class will also catch any errors raised by - * {@link org.apache.fineract.portfolio.client.api.SavingsAccountsApiResource} and + * {@link org.apache.fineract.portfolio.savings.api.SavingsAccountsApiResource} and * map those errors to appropriate status codes in BatchResponse. * * @author Rishabh Shukla diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java index dbe3629ac..bd7ef146e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/ApproveLoanCommandStrategy.java @@ -33,9 +33,9 @@ import org.springframework.stereotype.Component; * Implements {@link org.apache.fineract.batch.command.CommandStrategy} to handle * approval of a pending loan. It passes the contents of the body from the * BatchRequest to - * {@link org.apache.fineract.portfolio.client.api.LoansApiResource} and gets + * {@link org.apache.fineract.portfolio.loanaccount.api.LoansApiResource} and gets * back the response. This class will also catch any errors raised by - * {@link org.apache.fineract.portfolio.client.api.LoansApiResource} and map + * {@link org.apache.fineract.portfolio.loanaccount.api.LoansApiResource} and map * those errors to appropriate status codes in BatchResponse. * * @author Rishabh Shukla diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java index 5ec887e59..37294ab28 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CollectChargesCommandStrategy.java @@ -33,9 +33,9 @@ import org.springframework.stereotype.Component; * Implements {@link org.apache.fineract.batch.command.CommandStrategy} and * Collect Charges for a Loan. It passes the contents of the body from the * BatchRequest to - * {@link org.apache.fineract.portfolio.client.api.LoanChargesApiResource} and + * {@link org.apache.fineract.portfolio.loanaccount.api.LoanChargesApiResource} and * gets back the response. This class will also catch any errors raised by - * {@link org.apache.fineract.portfolio.client.api.LoanChargesApiResource} and map + * {@link org.apache.fineract.portfolio.loanaccount.api.LoanChargesApiResource} and map * those errors to appropriate status codes in BatchResponse. * * @author Rishabh Shukla diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java index 90678a8f6..eaa264dac 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/CreateChargeCommandStrategy.java @@ -32,9 +32,9 @@ import org.springframework.stereotype.Component; /** * Implements {@link org.apache.fineract.batch.command.CommandStrategy} and Create * Charge for a Loan. It passes the contents of the body from the BatchRequest - * to {@link org.apache.fineract.portfolio.client.api.LoanChargesApiResource} and + * to {@link org.apache.fineract.portfolio.loanaccount.api.LoanChargesApiResource} and * gets back the response. This class will also catch any errors raised by - * {@link org.apache.fineract.portfolio.client.api.LoanChargesApiResource} and map + * {@link org.apache.fineract.portfolio.loanaccount.api.LoanChargesApiResource} and map * those errors to appropriate status codes in BatchResponse. * * @author Rishabh Shukla diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java index 89ad9efa7..bcff2e998 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/command/internal/DisburseLoanCommandStrategy.java @@ -33,9 +33,9 @@ import org.springframework.stereotype.Component; * Implements {@link org.apache.fineract.batch.command.CommandStrategy} to handle * disburse of a loan. It passes the contents of the body from the * BatchRequest to - * {@link org.apache.fineract.portfolio.client.api.LoansApiResource} and gets + * {@link org.apache.fineract.portfolio.loanaccount.api.LoansApiResource} and gets * back the response. This class will also catch any errors raised by - * {@link org.apache.fineract.portfolio.client.api.LoansApiResource} and map + * {@link org.apache.fineract.portfolio.loanaccount.api.LoansApiResource} and map * those errors to appropriate status codes in BatchResponse. * * @author Rishabh Shukla diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/serialization/BatchRequestJsonHelper.java b/fineract-provider/src/main/java/org/apache/fineract/batch/serialization/BatchRequestJsonHelper.java index 723b085ea..c0fd136ad 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/serialization/BatchRequestJsonHelper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/serialization/BatchRequestJsonHelper.java @@ -46,7 +46,7 @@ public class BatchRequestJsonHelper extends FromJsonHelper { * JSON string. * * @param json - * @return List + * @return List<BatchRequest> */ public List extractList(final String json) { final Type listType = new TypeToken>() {}.getType(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiService.java b/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiService.java index 405312758..29aeb0b09 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiService.java @@ -45,7 +45,7 @@ public interface BatchApiService { * * @param requestList * @param uriInfo - * @return List + * @return List<BatchResponse> */ List handleBatchRequestsWithoutEnclosingTransaction(List requestList, UriInfo uriInfo); @@ -59,7 +59,7 @@ public interface BatchApiService { * * @param requestList * @param uriInfo - * @return List + * @return List<BatchResponse> */ List handleBatchRequestsWithEnclosingTransaction(List requestList, UriInfo uriInfo); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java b/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java index c0c3ed984..25932b4b5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java @@ -91,7 +91,7 @@ public class ResolutionHelper { * dependency hierarchy of that particular list. * * @param batchRequests - * @return List> + * @return List<ArrayList<BatchRequestNode>> */ public List getDependingRequests(final List batchRequests) { final List rootRequests = new ArrayList<>(); @@ -128,7 +128,7 @@ public class ResolutionHelper { * Request. * * @param request - * @param lastResponse + * @param parentResponse * @return BatchRequest */ public BatchRequest resoluteRequest(final BatchRequest request, final BatchResponse parentResponse) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/annotation/CommandType.java b/fineract-provider/src/main/java/org/apache/fineract/commands/annotation/CommandType.java index 2df98efab..e46ae1d20 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/annotation/CommandType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/annotation/CommandType.java @@ -21,8 +21,8 @@ package org.apache.fineract.commands.annotation; import java.lang.annotation.*; /** - * Specifies the command type for the annotated class.
    - *
    + * Specifies the command type for the annotated class.
    + *
    * The entity name (e.g. CLIENT, SAVINGSACCOUNT, LOANPRODUCT) and the action (e.g. CREATE, DELETE) must be given. * * @author Markus Geiss diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandSource.java b/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandSource.java index a19d22c2b..06b04b13e 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandSource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandSource.java @@ -95,6 +95,12 @@ public class CommandSource extends AbstractPersistableCustom { @Column(name = "transaction_id", length = 100) private String transactionId; + + @Column(name="creditbureau_id") + private Long creditBureauId; + + @Column(name="organisation_creditbureau_id") + private Long organisationCreditBureauId; public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) { return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.subentityId(), @@ -116,8 +122,25 @@ public class CommandSource extends AbstractPersistableCustom { this.maker = maker; this.madeOnDate = madeOnDateTime.toDate(); this.processingResult = CommandProcessingResultType.PROCESSED.getValue(); + } public Long getCreditBureauId() { + return this.creditBureauId; } + + public void setCreditBureauId(Long creditBureauId) { + this.creditBureauId = creditBureauId; + } + + + public Long getOrganisationCreditBureauId() { + return this.organisationCreditBureauId; + } + + + public void setOrganisationCreditBureauId(Long OrganisationCreditBureauId) { + this.organisationCreditBureauId = OrganisationCreditBureauId; + } + public void markAsChecked(final AppUser checker, final DateTime checkedOnDate) { this.checker = checker; this.checkedOnDate = checkedOnDate.toDate(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandWrapper.java index 3caa3a619..4590ba2c2 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandWrapper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandWrapper.java @@ -38,6 +38,8 @@ public class CommandWrapper { private final String json; private final String transactionId; private final Long productId; + private final Long creditBureauId; + private final Long organisationCreditBureauId; @SuppressWarnings("unused") private Long templateId; @@ -53,9 +55,10 @@ public class CommandWrapper { public static CommandWrapper fromExistingCommand(final Long commandId, final String actionName, final String entityName, final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId, final Long officeId, - final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId) { + final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId, + final Long creditBureauId,final Long organisationCreditBureauId) { return new CommandWrapper(commandId, actionName, entityName, resourceId, subresourceId, resourceGetUrl, productId, officeId, - groupId, clientId, loanId, savingsId, transactionId); + groupId, clientId, loanId, savingsId, transactionId,creditBureauId,organisationCreditBureauId); } private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId, @@ -75,11 +78,14 @@ public class CommandWrapper { this.json = null; this.transactionId = null; this.productId = productId; + this.creditBureauId=null; + this.organisationCreditBureauId=null; } public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String actionName, final String entityName, final Long entityId, final Long subentityId, final String href, - final String json, final String transactionId, final Long productId, final Long templateId) { + final String json, final String transactionId, final Long productId, final Long templateId, + final Long creditBureauId,final Long organisationCreditBureauId) { this.commandId = null; this.officeId = officeId; @@ -97,11 +103,14 @@ public class CommandWrapper { this.transactionId = transactionId; this.productId = productId; this.templateId = templateId; + this.creditBureauId=creditBureauId; + this.organisationCreditBureauId=organisationCreditBureauId; } private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId, final Long officeId, final Long groupId, - final Long clientId, final Long loanId, final Long savingsId, final String transactionId) { + final Long clientId, final Long loanId, final Long savingsId, final String transactionId, + final Long creditBureauId,final Long organisationCreditBureauId) { this.commandId = commandId; this.officeId = officeId; @@ -118,6 +127,16 @@ public class CommandWrapper { this.json = null; this.transactionId = transactionId; this.productId = productId; + this.creditBureauId=creditBureauId; + this.organisationCreditBureauId=organisationCreditBureauId; + } + + public Long getCreditBureauId() { + return this.creditBureauId; + } + + public Long getOrganisationCreditBureauId() { + return this.organisationCreditBureauId; } public String getHref() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java b/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java index 1312069cb..e75f4c83c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/provider/CommandHandlerProvider.java @@ -35,8 +35,9 @@ import org.springframework.stereotype.Component; import java.util.HashMap; /** - * {@link CommandHandlerProvider} provides {@link NewCommandSourceHandler}s for a given entity and action.
    - *
    + * {@link CommandHandlerProvider} provides {@link NewCommandSourceHandler}s for a given entity and action. + *
    + *
    * A {@link NewCommandSourceHandler} can be registered and the annotation {@link CommandType} is used to determine * the entity and the action the handler is capable to process. * @@ -60,8 +61,8 @@ public class CommandHandlerProvider implements ApplicationContextAware { } /** - * Returns a handler for the given entity and action.
    - *
    + * Returns a handler for the given entity and action.
    + *
    * Throws an {@link UnsupportedCommandException} if no handler * for the given entity, action combination can be found. * @param entity the entity to lookup the handler, must be given. diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java index 2ad6b2201..5bcd21a46 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java @@ -41,12 +41,48 @@ public class CommandWrapperBuilder { private String transactionId; private Long productId; private Long templateId; + private Long creditBureauId; + private Long organisationCreditBureauId; public CommandWrapper build() { return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName, this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, - this.templateId); + this.templateId,this.creditBureauId,this.organisationCreditBureauId); + } + + public CommandWrapperBuilder updateCreditBureau() { + this.actionName = "UPDATE"; + this.entityName = "ORGANISATIONCREDITBUREAU"; + this.entityId = null; + this.href = "/creditBureauConfiguration/template"; + return this; + } + + public CommandWrapperBuilder updateCreditBureauLoanProductMapping() { + this.actionName = "UPDATE"; + this.entityName = "CREDITBUREAU_LOANPRODUCT_MAPPING"; + this.entityId = null; + this.href = "/creditBureauConfiguration/template"; + return this; + } + + public CommandWrapperBuilder addOrganisationCreditBureau(final long organisationCreditBureauId) { + this.actionName = "CREATE"; + this.entityName = "ORGANISATIONCREDITBUREAU"; + this.entityId = organisationCreditBureauId; + this.href = "/creditBureauConfiguration/organizationCreditBureau/template"; + this.organisationCreditBureauId=organisationCreditBureauId; + return this; + } + + public CommandWrapperBuilder createCreditBureauLoanProductMapping(final long CreditBureauId) { + this.actionName = "CREATE"; + this.entityName = "CREDITBUREAU_LOANPRODUCT_MAPPING"; + this.entityId = CreditBureauId; + this.href = "/creditBureauConfiguration/template"; + this.creditBureauId=CreditBureauId; + return this; } public CommandWrapperBuilder addClientAddress(final long clientId,final long addressTypeId) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java index 481290ee4..b0e228ca1 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java @@ -92,7 +92,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json); command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(), wrapper.getEntityId(), wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getSavingsId(), - wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId()); + wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId(),wrapper.getCreditBureauId(),wrapper.getOrganisationCreditBureauId()); while (numberOfRetries <= maxNumberOfRetries) { try { result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker); @@ -139,13 +139,14 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio commandSourceInput.getEntityName(), commandSourceInput.resourceId(), commandSourceInput.subresourceId(), commandSourceInput.getResourceGetUrl(), commandSourceInput.getProductId(), commandSourceInput.getOfficeId(), commandSourceInput.getGroupId(), commandSourceInput.getClientId(), commandSourceInput.getLoanId(), - commandSourceInput.getSavingsId(), commandSourceInput.getTransactionId()); + commandSourceInput.getSavingsId(), commandSourceInput.getTransactionId(),commandSourceInput.getCreditBureauId(),commandSourceInput.getOrganisationCreditBureauId()); final JsonElement parsedCommand = this.fromApiJsonHelper.parse(commandSourceInput.json()); final JsonCommand command = JsonCommand.fromExistingCommand(makerCheckerId, commandSourceInput.json(), parsedCommand, this.fromApiJsonHelper, commandSourceInput.getEntityName(), commandSourceInput.resourceId(), commandSourceInput.subresourceId(), commandSourceInput.getGroupId(), commandSourceInput.getClientId(), commandSourceInput.getLoanId(), commandSourceInput.getSavingsId(), commandSourceInput.getTransactionId(), - commandSourceInput.getResourceGetUrl(), commandSourceInput.getProductId()); + commandSourceInput.getResourceGetUrl(), commandSourceInput.getProductId(),commandSourceInput.getCreditBureauId(), + commandSourceInput.getOrganisationCreditBureauId()); final boolean makerCheckerApproval = true; return this.processAndLogCommandService.processAndLogCommand(wrapper, command, makerCheckerApproval); diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/ApiRequestParameterHelper.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/ApiRequestParameterHelper.java index 396189016..b5150ecff 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/ApiRequestParameterHelper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/ApiRequestParameterHelper.java @@ -34,7 +34,7 @@ import org.springframework.stereotype.Component; *
  • Pretty printing through pretty=true, defaults to false
  • *
  • Partial response through fields=id, name etc, when empty, the full data * is returned by default.
  • - * */ @Component public class ApiRequestParameterHelper { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java index d06d12840..9b8356db6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java @@ -64,28 +64,31 @@ public final class JsonCommand { private final String transactionId; private final String url; private final Long productId; + private final Long creditBureauId; + private final Long organisationCreditBureauId; public static JsonCommand from(final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId, - final Long loanId, final Long savingsId, final String transactionId, final String url, final Long productId) { + final Long loanId, final Long savingsId, final String transactionId, final String url, final Long productId, + final Long creditBureauId,final Long organisationCreditBureauId) { return new JsonCommand(null, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId, - clientId, loanId, savingsId, transactionId, url, productId); + clientId, loanId, savingsId, transactionId, url, productId,creditBureauId,organisationCreditBureauId); } public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, - final String url, final Long productId) { + final String url, final Long productId,final Long creditBureauId,final Long organisationCreditBureauId) { return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, null, null, - null, null, null, url, productId); + null, null, null, url, productId,creditBureauId,organisationCreditBureauId); } public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId, final String url, - final Long productId) { + final Long productId,Long creditBureauId,final Long organisationCreditBureauId) { return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId, - clientId, loanId, savingsId, transactionId, url, productId); + clientId, loanId, savingsId, transactionId, url, productId,creditBureauId,organisationCreditBureauId); } @@ -93,13 +96,13 @@ public final class JsonCommand { final String jsonCommand = command.fromApiJsonHelper.toJson(parsedCommand); return new JsonCommand(command.commandId, jsonCommand, parsedCommand, command.fromApiJsonHelper, command.entityName, command.resourceId, command.subresourceId, command.groupId, command.clientId, command.loanId, command.savingsId, - command.transactionId, command.url, command.productId); + command.transactionId, command.url, command.productId,command.creditBureauId,command.organisationCreditBureauId); } public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId, final String url, - final Long productId) { + final Long productId,final Long creditBureauId, final Long organisationCreditBureauId) { this.commandId = commandId; this.jsonCommand = jsonCommand; @@ -115,6 +118,16 @@ public final class JsonCommand { this.transactionId = transactionId; this.url = url; this.productId = productId; + this.creditBureauId=creditBureauId; + this.organisationCreditBureauId=organisationCreditBureauId; + } + + public Long getOrganisationCreditBureauId() { + return this.organisationCreditBureauId; + } + + public Long getCreditBureauId() { + return this.creditBureauId; } public String json() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/AbstractApplicationConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/AbstractApplicationConfiguration.java index 2d2e312f6..7823a0dd7 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/AbstractApplicationConfiguration.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/AbstractApplicationConfiguration.java @@ -32,7 +32,7 @@ import org.springframework.context.annotation.PropertySource; * Base Spring Configuration with what's common to all Configuration subclasses. * * Notably the EnableAutoConfiguration excludes relevant for (and often adjusted - * when upgrading versions of) Spring Boot, the "old" (pre. Spring Boot & + * when upgrading versions of) Spring Boot, the "old" (pre. Spring Boot & * MariaDB4j) fineract appContext.xml which all configurations need, and the * web.xml successor WebXmlConfiguration. * diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WarWebApplicationInitializer.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WarWebApplicationInitializer.java index 907f8273c..7d1df1d61 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WarWebApplicationInitializer.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WarWebApplicationInitializer.java @@ -28,7 +28,7 @@ import org.springframework.context.annotation.ImportResource; * Configuration just adds the JNDI-based DataSource lookup to its * AbstractApplicationConfiguration. * - * This (intentionally) only configures the original (pre-Spring Boot & + * This (intentionally) only configures the original (pre-Spring Boot & * MariaDB4j) fineract Spring Beans, and does NOT include the embedded Tomcat * (incl. TomcatSSLConfiguration) nor the MariaDB4jSetupService or * MariaDB4jDataSourceConfiguration, and not even the DataSourceConfiguration diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java index def8d8815..1ee136163 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java @@ -145,7 +145,7 @@ public class DataValidatorBuilder { * param and if it has invalid value or value not passed then call this * method, this method is always used with input as false */ - public DataValidatorBuilder trueOrFalseRequired(final boolean trueOfFalseFieldProvided) { + public DataValidatorBuilder trueOrFalseRequired1(final boolean trueOfFalseFieldProvided) { if (!trueOfFalseFieldProvided && !this.ignoreNullValue) { final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") .append(this.parameter).append(".must.be.true.or.false"); @@ -157,6 +157,27 @@ public class DataValidatorBuilder { } return this; } + + + public DataValidatorBuilder trueOrFalseRequired(final Object trueOfFalseField) + { + + if(trueOfFalseField!=null) + { + if((!trueOfFalseField.toString().equalsIgnoreCase("true")) && (!trueOfFalseField.toString().equalsIgnoreCase("false")) ) + { + final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") + .append(this.parameter).append(".must.be.true.or.false"); + final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append( + " must be set as true or false."); + final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), this.parameter); + this.dataValidationErrors.add(error); + } + } + + return this; + } public DataValidatorBuilder notNull() { if (this.value == null && !this.ignoreNullValue) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/CommandProcessingResultJsonSerializer.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/CommandProcessingResultJsonSerializer.java index 29bc8111d..1c8e1dbe4 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/CommandProcessingResultJsonSerializer.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/CommandProcessingResultJsonSerializer.java @@ -31,7 +31,7 @@ import com.google.gson.GsonBuilder; /** *

    - * A google gson implementation of {@link ExcludeNothingJsonSerializer} + * A google gson implementation of * contract. *

    * diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson.java index 5c819c768..a6e8e2ae4 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson.java @@ -31,7 +31,7 @@ import com.google.gson.GsonBuilder; /** *

    - * A google gson implementation of {@link ExcludeNothingJsonSerializer} + * A google gson implementation of * contract. *

    * diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson.java index b649905e0..b24c20661 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson.java @@ -31,7 +31,7 @@ import com.google.gson.GsonBuilder; /** *

    - * A google gson implementation of {@link ExcludeNothingJsonSerializer} + * A google gson implementation of * contract. *

    * diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/FromJsonHelper.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/FromJsonHelper.java index 9d14ea91b..94eb77cee 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/FromJsonHelper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/serialization/FromJsonHelper.java @@ -115,7 +115,7 @@ public class FromJsonHelper { /** * @param parentPropertyName * The full json path to this property,the value is appended to - * the parameter name while generating an error message
    + * the parameter name while generating an error message
    * Ex: property "name" in Object "person" would be named as * "person.name" * @param object diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/api/CreditBureauConfigurationAPI.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/api/CreditBureauConfigurationAPI.java new file mode 100644 index 000000000..2838ce3a0 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/api/CreditBureauConfigurationAPI.java @@ -0,0 +1,239 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.infrastructure.creditbureau.api; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + +import org.apache.fineract.commands.domain.CommandWrapper; +import org.apache.fineract.commands.service.CommandWrapperBuilder; +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; +import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; +import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauConfigurationData; +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauData; +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauLoanProductMappingData; +import org.apache.fineract.infrastructure.creditbureau.data.OrganisationCreditBureauData; +import org.apache.fineract.infrastructure.creditbureau.service.CreditBureauLoanProductMappingReadPlatformService; +import org.apache.fineract.infrastructure.creditbureau.service.CreditBureauReadConfigurationService; +import org.apache.fineract.infrastructure.creditbureau.service.CreditBureauReadPlatformService; +import org.apache.fineract.infrastructure.creditbureau.service.OrganisationCreditBureauReadPlatformService; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Path("/CreditBureauConfiguration") +@Component +@Scope("singleton") +public class CreditBureauConfigurationAPI { + private final Set RESPONSE_DATA_PARAMETERS = new HashSet<>( + Arrays.asList("creditBureauId", "alias", "country", "creditBureauProductId", "startDate", "endDate", "isActive")); + private final String resourceNameForPermissions = "CreditBureau"; + private final PlatformSecurityContext context; + private final CreditBureauReadPlatformService readPlatformService; + private final DefaultToApiJsonSerializer toApiJsonSerializer; + private final CreditBureauLoanProductMappingReadPlatformService readPlatformServiceCreditBureauLoanProduct; + private final OrganisationCreditBureauReadPlatformService readPlatformServiceOrganisationCreditBureau; + private final DefaultToApiJsonSerializer toApiJsonSerializerCreditBureauLoanProduct; + private final DefaultToApiJsonSerializer toApiJsonSerializerOrganisationCreditBureau; + private final DefaultToApiJsonSerializer toApiJsonSerializerReport; + private final ApiRequestParameterHelper apiRequestParameterHelper; + private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; + private final CreditBureauReadConfigurationService creditBureauConfiguration; + + @Autowired + public CreditBureauConfigurationAPI(final PlatformSecurityContext context, + final CreditBureauReadPlatformService readPlatformService, + final DefaultToApiJsonSerializer toApiJsonSerializer, + final CreditBureauLoanProductMappingReadPlatformService readPlatformServiceCreditBureauLoanProduct, + final DefaultToApiJsonSerializer toApiJsonSerializerCreditBureauLoanProduct, + final OrganisationCreditBureauReadPlatformService readPlatformServiceOrganisationCreditBureau, + final DefaultToApiJsonSerializer toApiJsonSerializerOrganisationCreditBureau, + final ApiRequestParameterHelper apiRequestParameterHelper, + final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, + final DefaultToApiJsonSerializer toApiJsonSerializerReport, + final CreditBureauReadConfigurationService creditBureauConfiguration) { + this.context = context; + this.readPlatformService = readPlatformService; + this.apiRequestParameterHelper = apiRequestParameterHelper; + this.readPlatformServiceCreditBureauLoanProduct = readPlatformServiceCreditBureauLoanProduct; + this.toApiJsonSerializerCreditBureauLoanProduct = toApiJsonSerializerCreditBureauLoanProduct; + this.readPlatformServiceOrganisationCreditBureau = readPlatformServiceOrganisationCreditBureau; + this.toApiJsonSerializerOrganisationCreditBureau = toApiJsonSerializerOrganisationCreditBureau; + this.toApiJsonSerializer = toApiJsonSerializer; + this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; + this.toApiJsonSerializerReport = toApiJsonSerializerReport; + this.creditBureauConfiguration = creditBureauConfiguration; + + } + + @GET + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String getCreditBureau(@Context final UriInfo uriInfo) { + this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); + + final Collection creditBureau = this.readPlatformService.retrieveCreditBureau(); + + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper + .process(uriInfo.getQueryParameters()); + return this.toApiJsonSerializer.serialize(settings, creditBureau, this.RESPONSE_DATA_PARAMETERS); + + } + + @GET + @Path("/mappings") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String getCreditBureauLoanProductMapping(@Context final UriInfo uriInfo) { + this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); + + final Collection creditBureauLoanProductMapping = this.readPlatformServiceCreditBureauLoanProduct + .readCreditBureauLoanProductMapping(); + + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper + .process(uriInfo.getQueryParameters()); + return this.toApiJsonSerializerCreditBureauLoanProduct.serialize(settings, creditBureauLoanProductMapping, this.RESPONSE_DATA_PARAMETERS); + + } + + @GET + @Path("/organisationCreditBureau") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String getOrganisationCreditBureau(@Context final UriInfo uriInfo) { + this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); + + final Collection organisationCreditBureau = this.readPlatformServiceOrganisationCreditBureau + .retrieveOrgCreditBureau(); + + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper + .process(uriInfo.getQueryParameters()); + return this.toApiJsonSerializerOrganisationCreditBureau.serialize(settings, organisationCreditBureau, + this.RESPONSE_DATA_PARAMETERS); + + } + + @GET + @Path("/config/{organisationCreditBureauId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String getConfiguration(@PathParam("organisationCreditBureauId") final Long organisationCreditBureauId, @Context final UriInfo uriInfo) { + // System.out.println("config triggered"); + + this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); + + final Collection configurationData = this.creditBureauConfiguration + .readConfigurationByOrganisationCreditBureauId(organisationCreditBureauId); + + return this.toApiJsonSerializerReport.serialize(configurationData); + } + + + @GET + @Path("/loanProduct") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String fetchLoanProducts(@Context final UriInfo uriInfo) { + this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); + + final Collection creditBureauLoanProductMapping = this.readPlatformServiceCreditBureauLoanProduct + .fetchLoanProducts(); + + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper + .process(uriInfo.getQueryParameters()); + return this.toApiJsonSerializerCreditBureauLoanProduct.serialize(settings, creditBureauLoanProductMapping, this.RESPONSE_DATA_PARAMETERS); + } + + @PUT + @Path("/organisationCreditBureau") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String updateCreditBureau(final String apiRequestBodyAsJson) { + + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCreditBureau() + .withJson(apiRequestBodyAsJson).build(); + + final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + + return this.toApiJsonSerializer.serialize(result); + } + + @PUT + @Path("/mappings") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String updateCreditBureauLoanProductMapping(final String apiRequestBodyAsJson) { + + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCreditBureauLoanProductMapping() + .withJson(apiRequestBodyAsJson).build(); + + final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + + return this.toApiJsonSerializer.serialize(result); + } + + @POST + @Path("/organisationCreditBureau/{organisationCreditBureauId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String addOrganisationCreditBureau(@PathParam("organisationCreditBureauId") final Long organisationCreditBureauId, final String apiRequestBodyAsJson) { + + final CommandWrapper commandRequest = new CommandWrapperBuilder().addOrganisationCreditBureau(organisationCreditBureauId) + .withJson(apiRequestBodyAsJson).build(); + + final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + + return this.toApiJsonSerializer.serialize(result); + } + + @POST + @Path("/mappings/{CreditBureauId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String createCreditBureauLoanProductMapping(@PathParam("CreditBureauId") final Long CreditBureauId, final String apiRequestBodyAsJson) { + + final CommandWrapper commandRequest = new CommandWrapperBuilder().createCreditBureauLoanProductMapping(CreditBureauId) + .withJson(apiRequestBodyAsJson).build(); + + final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + + return this.toApiJsonSerializer.serialize(result); + } + + + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauConfigurationData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauConfigurationData.java new file mode 100644 index 000000000..ad47d1c77 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauConfigurationData.java @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.data; + +public class CreditBureauConfigurationData { + private final long creditBureauConfigurationId; + + private final String configurationKey; + + private final String value; + + private final long organizationCreditBureauId; + + private final String description; + + private CreditBureauConfigurationData(final long creditBureauConfigurationId, final String configurationKey, + final String value, final long organizationCreditBureauId, final String description) { + this.creditBureauConfigurationId = creditBureauConfigurationId; + this.configurationKey = configurationKey; + this.value = value; + this.organizationCreditBureauId = organizationCreditBureauId; + this.description = description; + + } + + public static CreditBureauConfigurationData instance(final long creditBureauConfigurationId, final String configurationKey, + final String value, final long organizationCreditBureauId, final String description) { + return new CreditBureauConfigurationData(creditBureauConfigurationId, configurationKey, value, + organizationCreditBureauId, description); + } + + public long getCreditBureauConfigurationId() { + return this.creditBureauConfigurationId; + } + + public String getConfigurationKey() { + return this.configurationKey; + } + + public String getValue() { + return this.value; + } + + public long getOrganizationCreditBureauId() { + return this.organizationCreditBureauId; + } + + public String getDescription() { + return this.description; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauData.java new file mode 100644 index 000000000..d1cf2ead2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauData.java @@ -0,0 +1,77 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.data; + +public class CreditBureauData { + + private final long creditBureauId; + + private final String creditBureauName; + + private final String country; + + private final String productName; + + private final String creditBureauSummary; + + private final long implementationKey; + + private CreditBureauData(final long creditBureauId, final String creditBureauName, final String country, + final String productName, final String creditBureauSummary, final long implementationKey) { + this.creditBureauId = creditBureauId; + this.creditBureauName = creditBureauName; + this.country = country; + this.productName = productName; + this.creditBureauSummary = creditBureauSummary; + this.implementationKey = implementationKey; + + } + + public static CreditBureauData instance(final long creditBureauId, final String creditBureauName, + final String country, final String productName, final String creditBureauSummary, final long implementationKey) { + + return new CreditBureauData(creditBureauId, creditBureauName, country, productName, creditBureauSummary, + implementationKey); + } + + public String getCreditBureauSummary() { + return this.creditBureauSummary; + } + + public long getCreditBureauId() { + return this.creditBureauId; + } + + public String getCreditBureauName() { + return this.creditBureauName; + } + + public String getCountry() { + return this.country; + } + + public String getProductName() { + return this.productName; + } + + public long getImplementationKey() { + return this.implementationKey; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauLoanProductMappingData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauLoanProductMappingData.java new file mode 100644 index 000000000..356e003fe --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauLoanProductMappingData.java @@ -0,0 +1,112 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.data; + +public class CreditBureauLoanProductMappingData { + + private final long creditbureauLoanProductMappingId; + + private final long organisationCreditBureauId; + + private final String alias; + + private final String creditbureauSummary; + + private final String loanProductName; + + private final long loanProductId; + + private final boolean isCreditCheckMandatory; + + private final boolean skipCrediCheckInFailure; + + private final long stalePeriod; + + private final boolean is_active; + + private CreditBureauLoanProductMappingData(final long creditbureauLoanProductMappingId, + final long organisationCreditBureauId, final String alias, final String creditbureauSummary, + final String loanProductName, final long loanProductId, final boolean isCreditCheckMandatory, + final boolean skipCrediCheckInFailure, final long stalePeriod, final boolean is_active) { + this.creditbureauLoanProductMappingId = creditbureauLoanProductMappingId; + this.organisationCreditBureauId = organisationCreditBureauId; + this.alias = alias; + this.creditbureauSummary = creditbureauSummary; + this.loanProductName = loanProductName; + this.loanProductId = loanProductId; + this.isCreditCheckMandatory = isCreditCheckMandatory; + this.skipCrediCheckInFailure = skipCrediCheckInFailure; + this.stalePeriod = stalePeriod; + this.is_active = is_active; + } + + public static CreditBureauLoanProductMappingData instance(final long creditbureauLoanProductMappingId, + final long organisationCreditBureauId, final String alias, final String creditbureauSummary, + final String loanProductName, final long loanProductId, final boolean isCreditCheckMandatory, + final boolean skipCrediCheckInFailure, final long stalePeriod, final boolean is_active) { + return new CreditBureauLoanProductMappingData(creditbureauLoanProductMappingId, organisationCreditBureauId, alias, + creditbureauSummary, loanProductName, loanProductId, isCreditCheckMandatory, skipCrediCheckInFailure, + stalePeriod, is_active); + } + + public static CreditBureauLoanProductMappingData instance1(final String loanProductName, final long loanProductId) { + return new CreditBureauLoanProductMappingData(0, 0, "", "", loanProductName, loanProductId, false, false, 0, false); + } + + public long getCreditbureauLoanProductMappingId() { + return this.creditbureauLoanProductMappingId; + } + + public String getAlias() { + return this.alias; + } + + public String getCreditbureauSummary() { + return this.creditbureauSummary; + } + + public String getLoanProductName() { + return this.loanProductName; + } + + public long getOrganisationCreditBureauId() { + return this.organisationCreditBureauId; + } + + public long getLoanProductId() { + return this.loanProductId; + } + + public boolean isCreditCheckMandatory() { + return this.isCreditCheckMandatory; + } + + public boolean isSkipCrediCheckInFailure() { + return this.skipCrediCheckInFailure; + } + + public long getStalePeriod() { + return this.stalePeriod; + } + + public boolean isIs_active() { + return this.is_active; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauMasterData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauMasterData.java new file mode 100644 index 000000000..bf73b810a --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauMasterData.java @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.data; + +public class CreditBureauMasterData { + + private final long creditBureauId; + + private final String creditBureauName; + + private final String country; + + public static CreditBureauMasterData instance(final Long creditBureauId, final String creditBureauName, final String country) { + return new CreditBureauMasterData(creditBureauId, creditBureauName, country); + } + + private CreditBureauMasterData(final Long creditBureauId, final String creditBureauName, final String country) { + this.creditBureauId = creditBureauId; + this.creditBureauName = creditBureauName; + this.country = country; + + } + + public String getCreditBureauName() { + return this.creditBureauName; + } + + public String getCountry() { + return this.country; + } + + public Long getCreditBureauId() { + return this.creditBureauId; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauProduct.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauProduct.java new file mode 100644 index 000000000..d5f88fdd1 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/CreditBureauProduct.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.data; + +public class CreditBureauProduct { + + private final long creditBureauProductId; + + private final String creditBureauProductName; + + private final long creditBureauMasterId; + + private CreditBureauProduct(final long creditBureauProductId, final String creditBureauProductName, + final long creditBureauMasterId) { + this.creditBureauProductId = creditBureauProductId; + this.creditBureauProductName = creditBureauProductName; + this.creditBureauMasterId = creditBureauMasterId; + } + + public static CreditBureauProduct instance(final long creditBureauProductId, final String creditBureauProductName, + final long creditBureauMasterId) { + return new CreditBureauProduct(creditBureauProductId, creditBureauProductName, creditBureauMasterId); + } + + public long getCreditBureauProductId() { + return this.creditBureauProductId; + } + + public String getCreditBureauProductName() { + return this.creditBureauProductName; + } + + public long getCreditBureauMasterId() { + return this.creditBureauMasterId; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/OrganisationCreditBureauData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/OrganisationCreditBureauData.java new file mode 100644 index 000000000..c08c2be6e --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/data/OrganisationCreditBureauData.java @@ -0,0 +1,91 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.data; + +public class OrganisationCreditBureauData { + + private final long organisationCreditBureauId; + + private final String alias; + + private final long creditBureauId; + + private final String creditBureauName; + + private final String creditBureauProduct; + + private final String creditBureauCountry; + + private final String creditBureauSummary; + + private final boolean is_active; + + private OrganisationCreditBureauData(final long organisationCreditBureauId, final String alias, + final long creditBureauId, final String creditBureauName, final String creditBureauProduct, + final String creditBureauCountry, final String creditBureauSummary, final boolean is_active) { + this.organisationCreditBureauId = organisationCreditBureauId; + this.alias = alias; + this.creditBureauId = creditBureauId; + this.creditBureauName = creditBureauName; + this.creditBureauProduct = creditBureauProduct; + this.creditBureauCountry = creditBureauCountry; + this.creditBureauSummary = creditBureauSummary; + this.is_active = is_active; + } + + public static OrganisationCreditBureauData instance(final long organisationCreditBureauId, final String alias, + final long creditBureauId, final String creditBureauName, final String creditBureauProduct, + final String creditBureauCountry, final String creditBureauSummary, final boolean is_active) { + return new OrganisationCreditBureauData(organisationCreditBureauId, alias, creditBureauId, creditBureauName, + creditBureauProduct, creditBureauCountry, creditBureauSummary, is_active); + } + + public long getOrganisationCreditBureauId() { + return this.organisationCreditBureauId; + } + + public String getCreditBureauName() { + return this.creditBureauName; + } + + public String getCreditBureauProduct() { + return this.creditBureauProduct; + } + + public String getCreditBureauCountry() { + return this.creditBureauCountry; + } + + public String getCreditBureauSummary() { + return this.creditBureauSummary; + } + + public String getAlias() { + return this.alias; + } + + public long getCreditBureauId() { + return this.creditBureauId; + } + + public boolean isActive() { + return this.is_active; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureau.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureau.java new file mode 100644 index 000000000..ad3fab76a --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureau.java @@ -0,0 +1,112 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.domain; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; + +@Entity +@Table(name = "m_creditbureau") +public class CreditBureau extends AbstractPersistableCustom { + + + private String name; + + private String product; + + private String country; + + private String implementationKey; + + @OneToMany(mappedBy = "organisation_creditbureau", cascade = CascadeType.ALL) + private List CreditBureauLoanProductMapping = new ArrayList<>(); + + public CreditBureau(String name, String product, String country, String implementationKey, + List CreditBureauLoanProductMapping) { + this.name = name; + this.product = product; + this.country = country; + this.implementationKey = implementationKey; + this.CreditBureauLoanProductMapping = CreditBureauLoanProductMapping; + } + + public CreditBureau() { + + } + + public static CreditBureau fromJson(final JsonCommand command) { + + final String tname = command.stringValueOfParameterNamed("name"); + final String tproduct = command.stringValueOfParameterNamed("product"); + final String tcountry = command.stringValueOfParameterNamed("country"); + final String timplementationKey = command.stringValueOfParameterNamed("implementationKey"); + + return new CreditBureau(tname, tproduct, tcountry, timplementationKey, null); + + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProduct() { + return this.product; + } + + public void setProduct(String product) { + this.product = product; + } + + public String getCountry() { + return this.country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getImplementationKey() { + return this.implementationKey; + } + + public void setImplementationKey(String implementationKey) { + this.implementationKey = implementationKey; + } + + public List getCreditBureauLpMapping() { + return this.CreditBureauLoanProductMapping; + } + + public void setCreditBureauLpMapping(List CreditBureauLoanProductMapping) { + this.CreditBureauLoanProductMapping = CreditBureauLoanProductMapping; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauConfiguration.java new file mode 100644 index 000000000..bdd7f6f9a --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauConfiguration.java @@ -0,0 +1,101 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.domain; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; + +@Entity +@Table(name = "m_creditbureau_configuration") +public class CreditBureauConfiguration extends AbstractPersistableCustom { + @Column(name = "configkey") + private String configurationKey; + + @Column(name = "value") + private String value; + + @Column(name = "description") + private String description; + + @ManyToOne + @JoinColumn(name = "organisation_creditbureau_id") + private OrganisationCreditBureau organisationCreditbureau; + + public CreditBureauConfiguration() { + + } + + public CreditBureauConfiguration(String configkey, String value, String description, + OrganisationCreditBureau organisationCreditbureau) { + this.configurationKey = configkey; + this.value = value; + this.description = description; + this.organisationCreditbureau = organisationCreditbureau; + + } + + public CreditBureauConfiguration fromJson(JsonCommand command, OrganisationCreditBureau organisation_creditbureau) { + final String configkey = command.stringValueOfParameterNamed("configkey"); + final String value = command.stringValueOfParameterNamed("value"); + final String description = command.stringValueOfParameterNamed("description"); + + return new CreditBureauConfiguration(configkey, value, description, organisation_creditbureau); + + } + + public String getConfigkey() { + return this.configurationKey; + } + + public void setConfigkey(String configkey) { + this.configurationKey = configkey; + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public OrganisationCreditBureau getOrganisation_creditbureau() { + return this.organisationCreditbureau; + } + + public void setOrganisation_creditbureau(OrganisationCreditBureau organisation_creditbureau) { + this.organisationCreditbureau = organisation_creditbureau; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauLoanProductMapping.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauLoanProductMapping.java new file mode 100644 index 000000000..8c3cdb423 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauLoanProductMapping.java @@ -0,0 +1,150 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.domain; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct; +import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; + +@Entity +@Table(name = "m_creditbureau_loanproduct_mapping") +public class CreditBureauLoanProductMapping extends AbstractPersistableCustom { + + @Column(name = "is_CreditCheck_Mandatory") + private boolean isCreditCheckMandatory; + + @Column(name = "skip_CreditCheck_in_Failure") + private boolean skipCreditCheckInFailure; + + @Column(name = "stale_Period") + private int stalePeriod; + + private boolean is_active; + + @ManyToOne + private OrganisationCreditBureau organisation_creditbureau; + + @OneToOne + @JoinColumn(name="loan_product_id") + private LoanProduct loanProduct; + + public CreditBureauLoanProductMapping() { + + } + + public CreditBureauLoanProductMapping(boolean isCreditCheckMandatory, boolean skipCreditCheckInFailure, int stalePeriod, + boolean is_active, OrganisationCreditBureau organisationCreditbureau, LoanProduct loanProduct) { + this.isCreditCheckMandatory = isCreditCheckMandatory; + this.skipCreditCheckInFailure = skipCreditCheckInFailure; + this.stalePeriod = stalePeriod; + this.is_active = is_active; + this.organisation_creditbureau = organisationCreditbureau; + this.loanProduct = loanProduct; + } + + public static CreditBureauLoanProductMapping fromJson(final JsonCommand command, + OrganisationCreditBureau organisation_creditbureau, LoanProduct loanProduct) { + Boolean isCreditCheckMandatory=false; + Boolean skipCreditCheckInFailure=false; + Integer stalePeriod=-1; + Boolean is_active=false; + if((Boolean)command.booleanPrimitiveValueOfParameterNamed("isCreditcheckMandatory")!=null) + { + isCreditCheckMandatory = command.booleanPrimitiveValueOfParameterNamed("isCreditcheckMandatory"); + } + + if((Boolean)command.booleanPrimitiveValueOfParameterNamed("skipCreditcheckInFailure")!=null) + { + skipCreditCheckInFailure = command.booleanPrimitiveValueOfParameterNamed("skipCreditcheckInFailure"); + } + + if((Integer)command.integerValueOfParameterNamed("stalePeriod")!=null) + { + stalePeriod = command.integerValueOfParameterNamed("stalePeriod"); + } + + if((Boolean) command.booleanPrimitiveValueOfParameterNamed("is_active")) + { + is_active = command.booleanPrimitiveValueOfParameterNamed("is_active"); + } + + + return new CreditBureauLoanProductMapping(isCreditCheckMandatory, skipCreditCheckInFailure, stalePeriod, is_active, + organisation_creditbureau, loanProduct); + + } + + public boolean isCreditCheckMandatory() { + return this.isCreditCheckMandatory; + } + + public void setCreditCheckMandatory(boolean isCreditCheckMandatory) { + this.isCreditCheckMandatory = isCreditCheckMandatory; + } + + public boolean isSkipCreditCheckInFailure() { + return this.skipCreditCheckInFailure; + } + + public void setSkipCreditCheckInFailure(boolean skipCreditCheckInFailure) { + this.skipCreditCheckInFailure = skipCreditCheckInFailure; + } + + public int getStalePeriod() { + return this.stalePeriod; + } + + public void setStalePeriod(int stalePeriod) { + this.stalePeriod = stalePeriod; + } + + public boolean isIs_active() { + return this.is_active; + } + + public void setIs_active(boolean is_active) { + this.is_active = is_active; + } + + public OrganisationCreditBureau getOrganisationCreditbureau() { + return this.organisation_creditbureau; + } + + public void setOrganisationCreditbureau(OrganisationCreditBureau organisationCreditbureau) { + this.organisation_creditbureau = organisationCreditbureau; + } + + public LoanProduct getLoanProduct() { + return this.loanProduct; + } + + public void setLoanProduct(LoanProduct loanProduct) { + this.loanProduct = loanProduct; + } + + + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauLoanProductMappingRepository.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauLoanProductMappingRepository.java new file mode 100644 index 000000000..3280b83ee --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauLoanProductMappingRepository.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.domain; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +public interface CreditBureauLoanProductMappingRepository + extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauRepository.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauRepository.java new file mode 100644 index 000000000..03dee5b58 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/CreditBureauRepository.java @@ -0,0 +1,30 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.domain; + +//import org.apache.fineract.infrastructure.jobs.domain.ScheduledJobDetail; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +public interface CreditBureauRepository + extends JpaRepository, JpaSpecificationExecutor { + + // CreditBureau findOne(long id); + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/OrganisationCreditBureau.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/OrganisationCreditBureau.java new file mode 100644 index 000000000..8a88ed5b9 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/OrganisationCreditBureau.java @@ -0,0 +1,100 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.domain; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; + +@Entity +@Table(name = "m_organisation_creditbureau") +public class OrganisationCreditBureau extends AbstractPersistableCustom { + + private String alias; + + @OneToOne + private CreditBureau creditbureau; + + private boolean is_active; + + @OneToMany(mappedBy = "organisation_creditbureau", cascade = CascadeType.ALL) + private List creditBureauLoanProductMapping = new ArrayList<>(); + + public OrganisationCreditBureau(String alias, CreditBureau creditBureau, boolean is_active, + List creditBureauLoanProductMapping) { + this.alias = alias; + this.creditbureau = creditBureau; + this.is_active = is_active; + this.creditBureauLoanProductMapping = creditBureauLoanProductMapping; + } + + public OrganisationCreditBureau() { + + } + + public static OrganisationCreditBureau fromJson(final JsonCommand command, CreditBureau creditBureau) { + final String alias = command.stringValueOfParameterNamed("alias"); + final boolean is_active = command.booleanPrimitiveValueOfParameterNamed("is_active"); + + return new OrganisationCreditBureau(alias, creditBureau, is_active, null); + } + + public String getAlias() { + return this.alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public CreditBureau getCreditBureau() { + return this.creditbureau; + } + + public void setCreditBureau(CreditBureau creditBureau) { + this.creditbureau = creditBureau; + } + + public boolean isActive() { + return this.is_active; + } + + public void setIsActive(boolean is_active) { + this.is_active = is_active; + } + + public List getCreditBureauLoanProductMapping() { + return this.creditBureauLoanProductMapping; + } + + public void setCreditBureauLoanProductMapping(List creditBureauLoanProductMapping) { + this.creditBureauLoanProductMapping = creditBureauLoanProductMapping; + } + + + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/OrganisationCreditBureauRepository.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/OrganisationCreditBureauRepository.java new file mode 100644 index 000000000..b0b05c93b --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/domain/OrganisationCreditBureauRepository.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.domain; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +public interface OrganisationCreditBureauRepository + extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/AddOrganisationCreditBureauCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/AddOrganisationCreditBureauCommandHandler.java new file mode 100644 index 000000000..f9b0851e9 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/AddOrganisationCreditBureauCommandHandler.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.handler; + +import org.apache.fineract.commands.annotation.CommandType; +import org.apache.fineract.commands.handler.NewCommandSourceHandler; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.creditbureau.service.OrganisationCreditBureauWritePlatflormService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@CommandType(entity = "ORGANISATIONCREDITBUREAU", action = "CREATE") +public class AddOrganisationCreditBureauCommandHandler implements NewCommandSourceHandler { + + private final OrganisationCreditBureauWritePlatflormService writePlatformService; + + @Autowired + public AddOrganisationCreditBureauCommandHandler(final OrganisationCreditBureauWritePlatflormService writePlatformService) { + this.writePlatformService = writePlatformService; + } + + @Override + public CommandProcessingResult processCommand(JsonCommand command) { + + return this.writePlatformService.addOrganisationCreditBureau(command.getOrganisationCreditBureauId(), command); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/CreateCreditBureauLoanProductMappingCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/CreateCreditBureauLoanProductMappingCommandHandler.java new file mode 100644 index 000000000..2b68b3ed7 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/CreateCreditBureauLoanProductMappingCommandHandler.java @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.handler; + +import org.apache.fineract.commands.annotation.CommandType; +import org.apache.fineract.commands.handler.NewCommandSourceHandler; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.creditbureau.service.CreditBureauLoanProductMappingWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@CommandType(entity = "CREDITBUREAU_LOANPRODUCT_MAPPING", action = "CREATE") +public class CreateCreditBureauLoanProductMappingCommandHandler implements NewCommandSourceHandler { + + private final CreditBureauLoanProductMappingWritePlatformService writePlatformService; + + @Autowired + public CreateCreditBureauLoanProductMappingCommandHandler(final CreditBureauLoanProductMappingWritePlatformService writePlatformService) { + this.writePlatformService = writePlatformService; + } + + @Override + public CommandProcessingResult processCommand(JsonCommand command) { + + return this.writePlatformService.addCreditBureauLoanProductMapping(command.getCreditBureauId(), command); + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/UpdateCreditBureauCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/UpdateCreditBureauCommandHandler.java new file mode 100644 index 000000000..0af556053 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/UpdateCreditBureauCommandHandler.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.handler; + +import org.apache.fineract.commands.annotation.CommandType; +import org.apache.fineract.commands.handler.NewCommandSourceHandler; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.creditbureau.service.OrganisationCreditBureauWritePlatflormService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "ORGANISATIONCREDITBUREAU", action = "UPDATE") +public class UpdateCreditBureauCommandHandler implements NewCommandSourceHandler { + + private final OrganisationCreditBureauWritePlatflormService writePlatformService; + + @Autowired + public UpdateCreditBureauCommandHandler(final OrganisationCreditBureauWritePlatflormService writePlatformService) { + this.writePlatformService = writePlatformService; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { + + return this.writePlatformService.updateCreditBureau(command); + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/UpdateCreditBureauLoanProductMappingCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/UpdateCreditBureauLoanProductMappingCommandHandler.java new file mode 100644 index 000000000..aa3d8450c --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/handler/UpdateCreditBureauLoanProductMappingCommandHandler.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.handler; + +import org.apache.fineract.commands.annotation.CommandType; +import org.apache.fineract.commands.handler.NewCommandSourceHandler; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.creditbureau.service.CreditBureauLoanProductMappingWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "CREDITBUREAU_LOANPRODUCT_MAPPING", action = "UPDATE") +public class UpdateCreditBureauLoanProductMappingCommandHandler implements NewCommandSourceHandler { + + private final CreditBureauLoanProductMappingWritePlatformService writePlatformService; + + @Autowired + public UpdateCreditBureauLoanProductMappingCommandHandler(final CreditBureauLoanProductMappingWritePlatformService writePlatformService) { + + this.writePlatformService = writePlatformService; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { + + return this.writePlatformService.updateCreditBureauLoanProductMapping(command); + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/serialization/CreditBureauCommandFromApiJsonDeserializer.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/serialization/CreditBureauCommandFromApiJsonDeserializer.java new file mode 100644 index 000000000..fdc9acc37 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/serialization/CreditBureauCommandFromApiJsonDeserializer.java @@ -0,0 +1,90 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.serialization; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; +import org.apache.fineract.infrastructure.core.data.ApiParameterError; +import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; +import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; +import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; +import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; +import org.joda.time.LocalDate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; + +@Component +public class CreditBureauCommandFromApiJsonDeserializer { + + private final Set supportedParameters = new HashSet<>(Arrays.asList("alias", "is_active")); + + private final FromJsonHelper fromApiJsonHelper; + + @Autowired + public CreditBureauCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper) { + this.fromApiJsonHelper = fromApiJsonHelper; + } + + public void validateForCreate(final String json, final Long creditBureauId) { + if (StringUtils.isBlank(json)) { + throw new InvalidJsonException(); + } + + final Type typeOfMap = new TypeToken>() { + }.getType(); + this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters); + + final List dataValidationErrors = new ArrayList<>(); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + .resource("CreditBureau"); + + final JsonElement element = this.fromApiJsonHelper.parse(json); + + baseDataValidator.reset().value(creditBureauId).notBlank().integerGreaterThanZero(); + + final String alias = this.fromApiJsonHelper.extractStringNamed("alias", element); + baseDataValidator.reset().parameter("alias").value(alias).notNull().notBlank().notExceedingLengthOf(100); + + final String is_activeParameter = "is_active"; + if (this.fromApiJsonHelper.parameterExists(is_activeParameter, element)) { + final boolean is_active = this.fromApiJsonHelper.extractBooleanNamed("is_active", element); + baseDataValidator.reset().parameter("is_active").value(is_active).notNull().notBlank().trueOrFalseRequired(is_active); + } + + throwExceptionIfValidationWarningsExist(dataValidationErrors); + } + + private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { + if (!dataValidationErrors.isEmpty()) { + throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); + } + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/serialization/CreditBureauLoanProductCommandFromApiJsonDeserializer.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/serialization/CreditBureauLoanProductCommandFromApiJsonDeserializer.java new file mode 100644 index 000000000..4aa2fb69f --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/serialization/CreditBureauLoanProductCommandFromApiJsonDeserializer.java @@ -0,0 +1,137 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.serialization; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; +import org.apache.fineract.infrastructure.core.data.ApiParameterError; +import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; +import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; +import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; +import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; + +@Component +public class CreditBureauLoanProductCommandFromApiJsonDeserializer { + private final Set supportedParameters = new HashSet<>(Arrays.asList("loan_product_id", + "is_creditcheck_mandatory", "skip_creditcheck_in_failure", "stale_period", "is_active", "locale")); + + private final FromJsonHelper fromApiJsonHelper; + + @Autowired + public CreditBureauLoanProductCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper) { + this.fromApiJsonHelper = fromApiJsonHelper; + } + + public void validateForCreate(final String json, final Long cb_id) { + if (StringUtils.isBlank(json)) { + throw new InvalidJsonException(); + } + + final Type typeOfMap = new TypeToken>() { + }.getType(); + this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters); + + final List dataValidationErrors = new ArrayList<>(); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + .resource("CREDITBUREAU_LOANPRODUCT_MAPPING"); + + final JsonElement element = this.fromApiJsonHelper.parse(json); + + baseDataValidator.reset().value(cb_id).notBlank().integerGreaterThanZero(); + + final long loan_product_id = this.fromApiJsonHelper.extractLongNamed("loan_product_id", element); + baseDataValidator.reset().parameter("loan_product_id").value(loan_product_id).notBlank() + .integerGreaterThanZero(); + System.out.println("loan product id " + loan_product_id); + + if(this.fromApiJsonHelper.extractBooleanNamed("is_creditcheck_mandatory",element)!= null) + { + final boolean is_creditcheck_mandatory = this.fromApiJsonHelper.extractBooleanNamed("is_creditcheck_mandatory", + element); + baseDataValidator.reset().parameter("is_creditcheck_mandatory").value(is_creditcheck_mandatory).notBlank() + .trueOrFalseRequired(is_creditcheck_mandatory); + } + else + { + baseDataValidator.reset().parameter("is_creditcheck_mandatory").value(this.fromApiJsonHelper.extractBooleanNamed("is_creditcheck_mandatory", + element)).notBlank() + .trueOrFalseRequired(this.fromApiJsonHelper.extractBooleanNamed("is_creditcheck_mandatory", + element)); + } + + + if( this.fromApiJsonHelper.extractBooleanNamed("skip_creditcheck_in_failure", element)!=null) + { + final boolean skip_creditcheck_in_failure = this.fromApiJsonHelper.extractBooleanNamed("skip_creditcheck_in_failure", element); + baseDataValidator.reset().parameter("skip_creditcheck_in_failure").value(skip_creditcheck_in_failure).notBlank().trueOrFalseRequired(skip_creditcheck_in_failure); + + } + else + { + baseDataValidator.reset().parameter("skip_creditcheck_in_failure").value(this.fromApiJsonHelper.extractBooleanNamed("skip_creditcheck_in_failure", element)).notBlank().trueOrFalseRequired(this.fromApiJsonHelper.extractBooleanNamed("skip_creditcheck_in_failure", element)); + } + + + if(this.fromApiJsonHelper.extractLongNamed("stale_period", element)!=null) + { + final long stale_period = this.fromApiJsonHelper.extractLongNamed("stale_period", element); + baseDataValidator.reset().parameter("stale_period").value(stale_period).notBlank().integerGreaterThanZero(); + } + else + { + baseDataValidator.reset().parameter("stale_period").value(this.fromApiJsonHelper.extractLongNamed("stale_period", element)).notBlank().integerGreaterThanZero(); + } + + + if(this.fromApiJsonHelper.extractBooleanNamed("is_active", element)!=null) + { + Boolean is_active = this.fromApiJsonHelper.extractBooleanNamed("is_active", element); + if (is_active == null) { + is_active = false; + } else { + + baseDataValidator.reset().parameter("is_active").value(is_active).notBlank().trueOrFalseRequired(is_active); + } + } + + + + throwExceptionIfValidationWarningsExist(dataValidationErrors); + + } + + private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { + if (!dataValidationErrors.isEmpty()) { + throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); + } + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingReadPlatformService.java new file mode 100644 index 000000000..d5a74f26f --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingReadPlatformService.java @@ -0,0 +1,33 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.util.Collection; + +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauLoanProductMappingData; + +public interface CreditBureauLoanProductMappingReadPlatformService { + + Collection readCreditBureauLoanProductMapping(); + + Collection fetchLoanProducts(); + + CreditBureauLoanProductMappingData readMappingByLoanId(long loanProductId); + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingReadPlatformServiceImpl.java new file mode 100644 index 000000000..b5f7145e2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingReadPlatformServiceImpl.java @@ -0,0 +1,122 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; + +import org.apache.fineract.infrastructure.core.service.RoutingDataSource; +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauLoanProductMappingData; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; + +@Service +public class CreditBureauLoanProductMappingReadPlatformServiceImpl implements CreditBureauLoanProductMappingReadPlatformService { + private final JdbcTemplate jdbcTemplate; + private final PlatformSecurityContext context; + + @Autowired + public CreditBureauLoanProductMappingReadPlatformServiceImpl(final PlatformSecurityContext context, + final RoutingDataSource dataSource) { + this.context = context; + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + private static final class CreditBureauLoanProductMapper implements RowMapper { + + public String schema() { + return "cblp.id as mappingId, cblp.organisation_creditbureau_id as orgcbId," + + "orgcb.alias as alias,concat( cb.product,' - ' ,cb.name,' - ',cb.country) as creditbureau," + + "cblp.loan_product_id as lpId,lp.name as loan_product_name,cblp.is_creditcheck_mandatory as crCheck,cblp.skip_creditcheck_in_failure as skipcheck," + + "cblp.stale_period as staleperiod,cblp.is_active as is_active from" + + " m_creditbureau_loanproduct_mapping cblp, m_organisation_creditbureau orgcb,m_product_loan lp,m_creditbureau cb" + + " where cblp.organisation_creditbureau_id=orgcb.id and cblp.loan_product_id=lp.id and orgcb.creditbureau_id=cb.id"; + } + + @Override + public CreditBureauLoanProductMappingData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) + throws SQLException { + final Long mapping_id = rs.getLong("mappingId"); + final Long orgcbID = rs.getLong("orgcbId"); + final String alias = rs.getString("alias"); + final String credit_bureau_name = rs.getString("creditbureau"); + final String loan_product_name = rs.getString("loan_product_name"); + final Long lpId = rs.getLong("lpId"); + final boolean is_creditcheck_mandatory = rs.getBoolean("crCheck"); + final boolean skip_credit_check_in_failure = rs.getBoolean("skipcheck"); + final int stale_period = rs.getInt("staleperiod"); + final boolean is_active = rs.getBoolean("is_active"); + + return CreditBureauLoanProductMappingData.instance(mapping_id, orgcbID, alias, credit_bureau_name, loan_product_name, + lpId, is_creditcheck_mandatory, skip_credit_check_in_failure, stale_period, is_active); + } + } + + private static final class LoanProductMapper implements RowMapper { + + public String schema() { + return "lp.name as loan_product_name,lp.id as loanid from m_product_loan lp"; + } + + @Override + public CreditBureauLoanProductMappingData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) + throws SQLException { + final Long loanid = rs.getLong("loanid"); + + final String loan_product_name = rs.getString("loan_product_name"); + + return CreditBureauLoanProductMappingData.instance1(loan_product_name, loanid); + } + } + + @Override + public Collection readCreditBureauLoanProductMapping() { + this.context.authenticatedUser(); + + final CreditBureauLoanProductMapper rm = new CreditBureauLoanProductMapper(); + final String sql = "select " + rm.schema() + " order by cblp.id"; + + return this.jdbcTemplate.query(sql, rm, new Object[] {}); + } + + @Override + public CreditBureauLoanProductMappingData readMappingByLoanId(long loanProductId) { + this.context.authenticatedUser(); + + final CreditBureauLoanProductMapper rm = new CreditBureauLoanProductMapper(); + final String sql = "select " + rm.schema() + " and cblp.loan_product_id=?"; + + return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanProductId }); + } + + @Override + public Collection fetchLoanProducts() { + this.context.authenticatedUser(); + + final LoanProductMapper rm = new LoanProductMapper(); + final String sql = "select " + rm.schema() + " order by lp.id"; + + return this.jdbcTemplate.query(sql, rm, new Object[] {}); + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingWritePlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingWritePlatformService.java new file mode 100644 index 000000000..41e29770f --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingWritePlatformService.java @@ -0,0 +1,30 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; + +public interface CreditBureauLoanProductMappingWritePlatformService { + + CommandProcessingResult addCreditBureauLoanProductMapping(Long creditBureauId, JsonCommand command); + + CommandProcessingResult updateCreditBureauLoanProductMapping(JsonCommand command); + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingWritePlatformServiceImpl.java new file mode 100644 index 000000000..b6a04a7f1 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauLoanProductMappingWritePlatformServiceImpl.java @@ -0,0 +1,96 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; +import org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauLoanProductMapping; +import org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauLoanProductMappingRepository; +import org.apache.fineract.infrastructure.creditbureau.domain.OrganisationCreditBureau; +import org.apache.fineract.infrastructure.creditbureau.domain.OrganisationCreditBureauRepository; +import org.apache.fineract.infrastructure.creditbureau.serialization.CreditBureauLoanProductCommandFromApiJsonDeserializer; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct; +import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class CreditBureauLoanProductMappingWritePlatformServiceImpl implements CreditBureauLoanProductMappingWritePlatformService { + + private final PlatformSecurityContext context; + + private final CreditBureauLoanProductMappingRepository creditBureauLoanProductMappingRepository; + + private final OrganisationCreditBureauRepository organisationCreditBureauRepository; + + private final LoanProductRepository loanProductRepository; + + private final CreditBureauLoanProductCommandFromApiJsonDeserializer fromApiJsonDeserializer; + + @Autowired + public CreditBureauLoanProductMappingWritePlatformServiceImpl(final PlatformSecurityContext context, + final CreditBureauLoanProductMappingRepository creditbureauLoanProductMappingRepository, + final OrganisationCreditBureauRepository organisationCreditBureauRepository, LoanProductRepository loanProductRepository, + final CreditBureauLoanProductCommandFromApiJsonDeserializer fromApiJsonDeserializer) { + this.context = context; + this.creditBureauLoanProductMappingRepository = creditbureauLoanProductMappingRepository; + this.organisationCreditBureauRepository = organisationCreditBureauRepository; + this.loanProductRepository = loanProductRepository; + this.fromApiJsonDeserializer = fromApiJsonDeserializer; + + } + + @Transactional + @Override + public CommandProcessingResult addCreditBureauLoanProductMapping(Long creditBureau_id, JsonCommand command) { + this.context.authenticatedUser(); + + System.out.println("mapping called for creditBureau_id "+creditBureau_id); + this.fromApiJsonDeserializer.validateForCreate(command.json(), creditBureau_id); + + final long lpid = command.longValueOfParameterNamed("loan_product_id"); + + final OrganisationCreditBureau orgcb = this.organisationCreditBureauRepository.getOne(creditBureau_id); + + final LoanProduct lp = this.loanProductRepository.getOne(lpid); + + final CreditBureauLoanProductMapping cb_lp = CreditBureauLoanProductMapping.fromJson(command, orgcb, lp); + + this.creditBureauLoanProductMappingRepository.save(cb_lp); + + return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(cb_lp.getId()) + .build(); + + } + + @Override + public CommandProcessingResult updateCreditBureauLoanProductMapping(JsonCommand command) { + + final Long mappingid = command.longValueOfParameterNamed("creditbureauLoanProductMappingId"); + final boolean is_active = command.booleanPrimitiveValueOfParameterNamed("is_active"); + final CreditBureauLoanProductMapping cblpmapping = this.creditBureauLoanProductMappingRepository.getOne(mappingid); + cblpmapping.setIs_active(is_active); + this.creditBureauLoanProductMappingRepository.saveAndFlush(cblpmapping); + return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(cblpmapping.getId()) + .build(); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauMasterReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauMasterReadPlatformService.java new file mode 100644 index 000000000..ef295a83d --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauMasterReadPlatformService.java @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.util.Collection; + +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauMasterData; + +public interface CreditBureauMasterReadPlatformService { + + Collection retrieveCreditBureauByCountry(String country); + + Collection retrieveCreditBureauByCountry(); + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadConfigurationService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadConfigurationService.java new file mode 100644 index 000000000..5cdd959dc --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadConfigurationService.java @@ -0,0 +1,33 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.util.Collection; +import java.util.Map; + +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauConfigurationData; + +public interface CreditBureauReadConfigurationService { + + Collection readConfigurationByOrganisationCreditBureauId(long id); + + Map retrieveConfigMap(long id); + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadConfigurationServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadConfigurationServiceImpl.java new file mode 100644 index 000000000..6a3a9179c --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadConfigurationServiceImpl.java @@ -0,0 +1,102 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.fineract.infrastructure.core.service.RoutingDataSource; +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauConfigurationData; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; + +@Service +public class CreditBureauReadConfigurationServiceImpl implements CreditBureauReadConfigurationService { + + private final JdbcTemplate jdbcTemplate; + private final PlatformSecurityContext context; + + @Autowired + public CreditBureauReadConfigurationServiceImpl(final PlatformSecurityContext context, + final RoutingDataSource dataSource) { + this.context = context; + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + private static final class CbConfigMapper implements RowMapper { + public String schema() { + + return "cbconfig.id as configId,cbconfig.configkey,cbconfig.value as configValue," + + "cbconfig.organisation_creditbureau_id as orgCBId,cbconfig.description as description from m_creditbureau_configuration cbconfig "; + + } + + @Override + public CreditBureauConfigurationData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) + throws SQLException { + final long configId = rs.getLong("configId"); + final String configkey = rs.getString("configkey"); + final String configValue = rs.getString("configValue"); + final long orgCBId = rs.getLong("orgCBId"); + final String desc = rs.getString("description"); + + return CreditBureauConfigurationData.instance(configId, configkey, configValue, orgCBId, desc); + + } + } + + @Override + public Collection readConfigurationByOrganisationCreditBureauId(long id) { + + this.context.authenticatedUser(); + + final CbConfigMapper rm = new CbConfigMapper(); + final String sql = "select " + rm.schema() + " where cbconfig.organisation_creditbureau_id=?"; + + return this.jdbcTemplate.query(sql, rm, new Object[] { id }); + + } + + @Override + public Map retrieveConfigMap(long id) { + this.context.authenticatedUser(); + + final CbConfigMapper rm = new CbConfigMapper(); + final String sql = "select " + rm.schema() + " where cbconfig.organisation_creditbureau_id=" + id; + + List config = (List) this.jdbcTemplate.query(sql, + rm, new Object[] {}); + Map configuration = new HashMap(); + for (CreditBureauConfigurationData data : config) { + configuration.put(data.getConfigurationKey(), data.getValue()); + + } + + return configuration; + + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadPlatformService.java new file mode 100644 index 000000000..ebc64f0de --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadPlatformService.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.util.Collection; + +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauData; + +public interface CreditBureauReadPlatformService { + + Collection retrieveCreditBureau(); + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadPlatformServiceImpl.java new file mode 100644 index 000000000..ea90f8017 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/CreditBureauReadPlatformServiceImpl.java @@ -0,0 +1,77 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; + +import org.apache.fineract.infrastructure.core.service.RoutingDataSource; +import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauData; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; + +@Service +public class CreditBureauReadPlatformServiceImpl implements CreditBureauReadPlatformService { + + private final JdbcTemplate jdbcTemplate; + private final PlatformSecurityContext context; + + @Autowired + public CreditBureauReadPlatformServiceImpl(final PlatformSecurityContext context, + final RoutingDataSource dataSource) { + this.context = context; + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + private static final class CBMapper implements RowMapper { + public String schema() { + return "cb.id as creditBureauID,cb.name as creditBureauName,cb.product as creditBureauProduct," + + "cb.country as country,concat(cb.product,' - ',cb.name,' - ',cb.country) as cbSummary,cb.implementationKey as implementationKey from m_creditbureau cb"; + } + + @Override + public CreditBureauData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) + throws SQLException { + final long id = rs.getLong("creditBureauID"); + final String name = rs.getString("creditBureauName"); + final String product = rs.getString("creditBureauProduct"); + final String country = rs.getString("country"); + final String cbSummary = rs.getString("cbSummary"); + final long implementationKey = rs.getLong("implementationKey"); + + return CreditBureauData.instance(id, name, product, country, cbSummary, implementationKey); + + } + } + + @Override + public Collection retrieveCreditBureau() { + this.context.authenticatedUser(); + + final CBMapper rm = new CBMapper(); + final String sql = "select " + rm.schema() + " order by id"; + + return this.jdbcTemplate.query(sql, rm, new Object[] {}); + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauReadPlatformService.java new file mode 100644 index 000000000..bb74b08a2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauReadPlatformService.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.util.Collection; + +import org.apache.fineract.infrastructure.creditbureau.data.OrganisationCreditBureauData; + +public interface OrganisationCreditBureauReadPlatformService { + Collection retrieveOrgCreditBureau(); + + OrganisationCreditBureauData retrieveOrgCreditBureauById(long orgCbId); +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauReadPlatformServiceImpl.java new file mode 100644 index 000000000..f71166326 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauReadPlatformServiceImpl.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; + +import org.apache.fineract.infrastructure.core.service.RoutingDataSource; +import org.apache.fineract.infrastructure.creditbureau.data.OrganisationCreditBureauData; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; + +@Service +public class OrganisationCreditBureauReadPlatformServiceImpl implements OrganisationCreditBureauReadPlatformService { + + private final JdbcTemplate jdbcTemplate; + private final PlatformSecurityContext context; + + @Autowired + public OrganisationCreditBureauReadPlatformServiceImpl(final PlatformSecurityContext context, + final RoutingDataSource dataSource) { + this.context = context; + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + private static final class OrganisationCreditBureauMapper implements RowMapper { + public String schema() { + return "ocb.id as orgCbId,ocb.alias as orgCbAlias,cb.name as creditbureauName,cb.product as creditbureauProduct,cb.country as creditbureauCountry," + + "concat(cb.product,' - ',cb.name,' - ',cb.country) as CreditBureauSummary," + + "ocb.creditbureau_id as cbid,ocb.is_active as is_active" + + " from m_organisation_creditbureau ocb,m_creditbureau cb where ocb.creditbureau_id=cb.id"; + + } + + @Override + public OrganisationCreditBureauData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) + throws SQLException { + final long orgCbId = rs.getLong("orgCbId"); + final String orgCbAlias = rs.getString("orgCbAlias"); + final String creditbureauName = rs.getString("creditbureauName"); + final String creditbureauProduct = rs.getString("creditbureauProduct"); + final String creditbureauCountry = rs.getString("creditbureauCountry"); + final String CreditBureauSummary = rs.getString("CreditBureauSummary"); + final long cbid = rs.getLong("cbid"); + final boolean is_active = rs.getBoolean("is_active"); + + return OrganisationCreditBureauData.instance(orgCbId, orgCbAlias, cbid, creditbureauName, + creditbureauProduct, creditbureauCountry, CreditBureauSummary, is_active); + + } + } + + @Override + public Collection retrieveOrgCreditBureau() { + this.context.authenticatedUser(); + + final OrganisationCreditBureauMapper rm = new OrganisationCreditBureauMapper(); + final String sql = "select " + rm.schema() + " order by ocb.id"; + + return this.jdbcTemplate.query(sql, rm, new Object[] {}); + } + + @Override + public OrganisationCreditBureauData retrieveOrgCreditBureauById(long orgCbId) { + this.context.authenticatedUser(); + + final OrganisationCreditBureauMapper rm = new OrganisationCreditBureauMapper(); + final String sql = "select " + rm.schema() + " and ocb.id=?"; + + return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { orgCbId }); + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauWritePlatflormService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauWritePlatflormService.java new file mode 100644 index 000000000..21ffc7414 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauWritePlatflormService.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; + +public interface OrganisationCreditBureauWritePlatflormService { + + CommandProcessingResult addOrganisationCreditBureau(Long ocb_id, JsonCommand command); + + CommandProcessingResult updateCreditBureau(JsonCommand command); +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauWritePlatflormServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauWritePlatflormServiceImpl.java new file mode 100644 index 000000000..1131d586b --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/creditbureau/service/OrganisationCreditBureauWritePlatflormServiceImpl.java @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.creditbureau.service; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; +import org.apache.fineract.infrastructure.creditbureau.domain.CreditBureau; +import org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauRepository; +import org.apache.fineract.infrastructure.creditbureau.domain.OrganisationCreditBureau; +import org.apache.fineract.infrastructure.creditbureau.domain.OrganisationCreditBureauRepository; +import org.apache.fineract.infrastructure.creditbureau.serialization.CreditBureauCommandFromApiJsonDeserializer; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class OrganisationCreditBureauWritePlatflormServiceImpl + implements OrganisationCreditBureauWritePlatflormService { + + private final PlatformSecurityContext context; + + private final OrganisationCreditBureauRepository organisationCreditBureauRepository; + + private final CreditBureauRepository creditBureauRepository; + + private final CreditBureauCommandFromApiJsonDeserializer fromApiJsonDeserializer; + + @Autowired + public OrganisationCreditBureauWritePlatflormServiceImpl(final PlatformSecurityContext context, + final OrganisationCreditBureauRepository organisationCreditBureauRepository, final CreditBureauRepository creditBureauRepository, + final CreditBureauCommandFromApiJsonDeserializer fromApiJsonDeserializer) { + this.context = context; + this.organisationCreditBureauRepository = organisationCreditBureauRepository; + this.creditBureauRepository = creditBureauRepository; + this.fromApiJsonDeserializer = fromApiJsonDeserializer; + + } + + @Override + public CommandProcessingResult addOrganisationCreditBureau(Long creditBureauId, JsonCommand command) { + this.context.authenticatedUser(); + this.fromApiJsonDeserializer.validateForCreate(command.json(), creditBureauId); + + final CreditBureau creditBureau = this.creditBureauRepository.getOne(creditBureauId); + + final OrganisationCreditBureau organisationCreditBureau = OrganisationCreditBureau.fromJson(command, creditBureau); + + this.organisationCreditBureauRepository.save(organisationCreditBureau); + + return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(organisationCreditBureau.getId()) + .build(); + } + + @Transactional + @Override + public CommandProcessingResult updateCreditBureau(JsonCommand command) { + // this.context.authenticatedUser(); + // this.fromApiJsonDeserializer.validateForCreate(command.json()); + + final long creditbureauID = command.longValueOfParameterNamed("creditBureauId"); + //System.out.println("creditbureauID is " + creditbureauID); + + final boolean is_active = command.booleanPrimitiveValueOfParameterNamed("is_active"); + + final OrganisationCreditBureau orgcb = organisationCreditBureauRepository.getOne(creditbureauID); + + orgcb.setIsActive(is_active); + + organisationCreditBureauRepository.saveAndFlush(orgcb); + + return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(orgcb.getId()) + .build(); + + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java index 6b91255fb..e5b7055f5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java @@ -862,7 +862,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ final String apptableName = this.fromJsonHelper.extractStringNamed("apptableName", element); validateDatatableName(datatableName); - + int rowCount = getRowCount(datatableName); final List columnHeaderData = this.genericDataService.fillResultsetColumnHeaders(datatableName); final Map mapColumnNameDefinition = new HashMap<>(); for (final ResultsetColumnHeaderData columnHeader : columnHeaderData) { @@ -908,7 +908,10 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ if (changeColumns == null && addColumns == null && dropColumns == null) { return; } if (dropColumns != null) { - + if(rowCount>0){ + throw new GeneralPlatformDomainRuleException("error.msg.non.empty.datatable.column.cannot.be.deleted", + "Non-empty datatable columns can not be deleted."); + } StringBuilder sqlBuilder = new StringBuilder("ALTER TABLE `" + datatableName + "`"); final StringBuilder constrainBuilder = new StringBuilder(); final List codeMappings = new ArrayList<>(); @@ -931,7 +934,12 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ final StringBuilder constrainBuilder = new StringBuilder(); final Map codeMappings = new HashMap<>(); for (final JsonElement column : addColumns) { - parseDatatableColumnForAdd(column.getAsJsonObject(), sqlBuilder, datatableName.toLowerCase().replaceAll("\\s", "_"), + JsonObject columnAsJson = column.getAsJsonObject(); + if(rowCount>0 && columnAsJson.has("mandatory") && columnAsJson.get("mandatory").getAsBoolean()){ + throw new GeneralPlatformDomainRuleException("error.msg.non.empty.datatable.mandatory.column.cannot.be.added", + "Non empty datatable mandatory columns can not be added."); + } + parseDatatableColumnForAdd(columnAsJson, sqlBuilder, datatableName.toLowerCase().replaceAll("\\s", "_"), constrainBuilder, codeMappings, isConstraintApproach); } @@ -1050,11 +1058,15 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ } private void assertDataTableEmpty(final String datatableName) { - final String sql = "select count(*) from `" + datatableName + "`"; - final int rowCount = this.jdbcTemplate.queryForObject(sql, Integer.class); + final int rowCount = getRowCount(datatableName); if (rowCount != 0) { throw new GeneralPlatformDomainRuleException("error.msg.non.empty.datatable.cannot.be.deleted", "Non-empty datatable cannot be deleted."); } } + + private int getRowCount(final String datatableName){ + final String sql = "select count(*) from `" + datatableName + "`"; + return this.jdbcTemplate.queryForObject(sql, Integer.class); + } @Transactional @Override diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/documentmanagement/contentrepository/ContentRepositoryUtils.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/documentmanagement/contentrepository/ContentRepositoryUtils.java index 381577908..eb8d3220c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/documentmanagement/contentrepository/ContentRepositoryUtils.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/documentmanagement/contentrepository/ContentRepositoryUtils.java @@ -121,7 +121,7 @@ public class ContentRepositoryUtils { /** * Extracts Image from a Data URL * - * @param mimeType + * @param dataURL mimeType */ public static Base64EncodedImage extractImageFromDataURL(final String dataURL) { String fileExtension = ""; diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/domain/ReportMailingJob.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/domain/ReportMailingJob.java index c7f3bb7d4..0a29c560b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/domain/ReportMailingJob.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/domain/ReportMailingJob.java @@ -322,7 +322,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { * update the stretchy report entity associated with the credit check * * @param stretchyReport -- Report entity - * @return None + * **/ public void update(final Report stretchyReport) { if (stretchyReport != null) { @@ -333,7 +333,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { /** * delete the report mailing job, set the isDeleted property to 1 and alter the name * - * @return None + * **/ public void delete() { this.isDeleted = true; @@ -491,7 +491,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { /** * increase the numberOfRuns by 1 * - * @return None + * **/ public void increaseNumberOfRunsByOne() { this.numberOfRuns++; @@ -501,7 +501,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { * update the previousRunStatus * * @param previousRunStatus -- the status of the previous job execution - * @return None + * **/ public void updatePreviousRunStatus(final String previousRunStatus) { if (!StringUtils.isEmpty(previousRunStatus)) { @@ -513,7 +513,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { * update the previousRunDateTime * * @param previousRunDateTime -- previous run date - * @return None + * **/ public void updatePreviousRunDateTime(final DateTime previousRunDateTime) { if (previousRunDateTime != null) { @@ -525,7 +525,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { * update the nextRunDateTime * * @param nextRunDateTime -- the next run DateTime - * @return None + * **/ public void updateNextRunDateTime(final DateTime nextRunDateTime) { if (nextRunDateTime != null) { @@ -540,7 +540,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { /** * deactivate the report mailing job by setting the isActive property to 0 * - * @return None + * **/ public void deactivate() { this.isActive = false; @@ -550,7 +550,7 @@ public class ReportMailingJob extends AbstractAuditableCustom { * update the previousRunErrorLog property * * @param previousRunErrorLog -- the previous job run error log - * @return None + * **/ public void updatePreviousRunErrorLog(final String previousRunErrorLog) { this.previousRunErrorLog = previousRunErrorLog; diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/service/ReportMailingJobWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/service/ReportMailingJobWritePlatformServiceImpl.java index 02972a927..6e9f5e381 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/service/ReportMailingJobWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/service/ReportMailingJobWritePlatformServiceImpl.java @@ -301,7 +301,7 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo * @param reportMailingJob -- the report mailing job entity * @param errorLog -- StringBuilder object containing the error log if any * @param jobStartDateTime -- the start DateTime of the job - * @return None + * **/ private void updateReportMailingJobAfterJobExecution(final ReportMailingJob reportMailingJob, final StringBuilder errorLog, final DateTime jobStartDateTime) { @@ -374,7 +374,7 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo * @param errorLog -- StringBuilder object containing the error log if any * @param jobStartDateTime -- the start DateTime of the job * @param jobRunStatus -- the status of the job (success/error) - * @return None + * **/ private void createReportMailingJobRunHistroryAfterJobExecution(final ReportMailingJob reportMailingJob, final StringBuilder errorLog, final DateTime jobStartDateTime, final String jobRunStatus) { @@ -391,7 +391,7 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo * * @param jsonCommand -- JsonCommand object * @param dve -- data integrity exception object - * @return None + * **/ private void handleDataIntegrityIssues(final JsonCommand jsonCommand, final DataIntegrityViolationException dve) { final Throwable realCause = dve.getMostSpecificCause(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/validation/ReportMailingJobValidator.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/validation/ReportMailingJobValidator.java index c3bbaf851..d87140426 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/validation/ReportMailingJobValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/validation/ReportMailingJobValidator.java @@ -63,7 +63,7 @@ public class ReportMailingJobValidator { * validate the request to create a new report mailing job * * @param jsonCommand -- the JSON command object (instance of the JsonCommand class) - * @return None + * **/ public void validateCreateRequest(final JsonCommand jsonCommand) { final String jsonString = jsonCommand.json(); @@ -142,7 +142,7 @@ public class ReportMailingJobValidator { * validate the request to update a report mailing job * * @param jsonCommand -- the JSON command object (instance of the JsonCommand class) - * @return None + * **/ public void validateUpdateRequest(final JsonCommand jsonCommand) { final String jsonString = jsonCommand.json(); @@ -309,7 +309,7 @@ public class ReportMailingJobValidator { * throw a PlatformApiDataValidationException exception if there are validation errors * * @param dataValidationErrors -- list of ApiParameterError objects - * @return None + * **/ private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { if (!dataValidationErrors.isEmpty()) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/InvalidTenantIdentiferException.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/InvalidTenantIdentiferException.java index 68b161338..d2d7a8781 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/InvalidTenantIdentiferException.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/InvalidTenantIdentiferException.java @@ -22,7 +22,7 @@ package org.apache.fineract.infrastructure.security.exception; * {@link RuntimeException} thrown when an invalid tenant identifier is used in * request to platform. * - * @see CustomRequestHeaderAuthenticationFilter + * */ public class InvalidTenantIdentiferException extends RuntimeException { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageApiResponseData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageApiResponseData.java index d247bc79d..947bb3366 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageApiResponseData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageApiResponseData.java @@ -30,7 +30,7 @@ public class SmsMessageApiResponseData { /** * SmsMessageApiResponseData constructor * - * @return void + * **/ private SmsMessageApiResponseData(Integer httpStatusCode, List data) { this.httpStatusCode = httpStatusCode; @@ -40,7 +40,7 @@ public class SmsMessageApiResponseData { /** * Default SmsMessageApiResponseData constructor * - * @return void + * **/ protected SmsMessageApiResponseData() {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageDeliveryReportData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageDeliveryReportData.java index 91471b226..d8167fec8 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageDeliveryReportData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/data/SmsMessageDeliveryReportData.java @@ -33,7 +33,7 @@ public class SmsMessageDeliveryReportData { /** * SmsMessageDeliveryReportData constructor * - * @return void + * **/ private SmsMessageDeliveryReportData(Long id, String externalId, String addedOnDate, String deliveredOnDate, Integer deliveryStatus, Boolean hasError, String errorMessage) { @@ -49,7 +49,7 @@ public class SmsMessageDeliveryReportData { /** * Default SmsMessageDeliveryReportData constructor * - * @return void + * **/ protected SmsMessageDeliveryReportData() {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/CashierData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/CashierData.java index f6e61bb15..27367f77b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/CashierData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/CashierData.java @@ -34,7 +34,7 @@ import org.joda.time.LocalDate; * information, teller, and more. * * @author Markus Geiss -<<<<<<< HEAD + * @since 2.0.0 * @see org.apache.fineract.organisation.teller.domain.Cashier * @since 2.0.0 @@ -86,24 +86,27 @@ public final class CashierData implements Serializable { /** * Creates a new cashier. - *

    + * *

    The valid from/to dates may be used to define a time period in which * the cashier is assignable to a teller.

    - *

    + * *

    The start/end times may be used to define a time period in which * the cashier works part time.

    * - * @param id the primary key of this cashier - * @param officeId the primary key of the related office - * @param staffId the primary key of the related staff - * @param tellerId the primary key of the related teller + * @param id the primary key of this cashier + * @param officeId the primary key of the related office + * @param officeName the primary key of the related staff + * @param staffId the primary key of the related teller + * @param staffName + * @param tellerId the primary key of the related teller + * @param tellerName * @param description the description of this cashier - * @param validFrom the valid from date of this cashier - * @param validTo the valid to date of this cashier - * @param partTime the part time flag of this cashier - * @param startTime the start time of this cashier - * @param endTime the end time of this cashier - * @return the cashier + * @param startDate the valid from date of this cashier + * @param endDate the valid to date of this cashier + * @param isFullDay the part time flag of this cashier + * @param startTime the start time of this cashier + * @param endTime the end time of this cashier + * @return */ public static CashierData instance(final Long id, final Long officeId, String officeName, final Long staffId, final String staffName, final Long tellerId, final String tellerName, @@ -169,7 +172,7 @@ public final class CashierData implements Serializable { /** * Returns the valid from date of this cashier. - *

    + * *

    The valid from/to dates may be used to define a time period in which * the cashier is assignable to a teller.

    * @@ -181,7 +184,7 @@ public final class CashierData implements Serializable { /** * Returns the valid to date of this cashier. - *

    + * *

    The valid from/to dates may be used to define a time period in which * the cashier is assignable to a teller.

    * @@ -202,7 +205,7 @@ public final class CashierData implements Serializable { /** * Returns the start time of this cashier. - *

    + * *

    The start/end times may be used to define a time period in which * the cashier works part time.

    * @@ -214,7 +217,7 @@ public final class CashierData implements Serializable { /** * Returns the end time of this cashier. - *

    + * *

    The start/end times may be used to define a time period in which * the cashier works part time.

    * diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerData.java index e86f14f38..439fb72e2 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerData.java @@ -32,7 +32,7 @@ import java.util.Date; * {@code TellerData} represents an immutable data object for teller data. * * @version 1.0 -<<<<<<< HEAD + * @since 2.0.0 * @see java.io.Serializable * @since 2.0.0 diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerJournalData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerJournalData.java index 6ae4d32a1..284e7af57 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerJournalData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerJournalData.java @@ -25,7 +25,7 @@ import java.util.Date; * {@code TellerJournalData} represents an immutable journal data object. * * @version 1.0.0 -<<<<<<< HEAD + * @since 2.0.0 * @see java.io.Serializable * @since 2.0.0 diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerTransactionData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerTransactionData.java index e260a6a12..fcb955bfe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerTransactionData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/data/TellerTransactionData.java @@ -27,7 +27,7 @@ import java.util.Date; * {@code TellerTransactionData} represents an immutable data object for a transction. * * @version 1.0.0 -<<<<<<< HEAD + * @since 2.0.0 * @see java.io.Serializable * @since 2.0.0 diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/Cashier.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/Cashier.java index 1d5922faa..64ba634c2 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/Cashier.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/Cashier.java @@ -324,7 +324,7 @@ public class Cashier extends AbstractPersistableCustom { /** * Returns the valid from date of this cashier. - *

    + * *

    * The valid from/to dates may be used to define a time period in which the * cashier is assignable to a teller. @@ -346,13 +346,13 @@ public class Cashier extends AbstractPersistableCustom { /** * Sets the valid from date of this cashier. - *

    + * *

    * The valid from/to dates may be used to define a time period in which the * cashier is assignable to a teller. *

    * - * @param validFrom + * @param startDate validFrom * the valid from date of this cashier */ public void setStartDate(Date startDate) { @@ -361,7 +361,7 @@ public class Cashier extends AbstractPersistableCustom { /** * Returns the valid to date of this cashier. - *

    + * *

    * The valid from/to dates may be used to define a time period in which the * cashier is assignable to a teller. @@ -383,13 +383,13 @@ public class Cashier extends AbstractPersistableCustom { /** * Sets the valid to date of this cashier. - *

    + * *

    * The valid from/to dates may be used to define a time period in which the * cashier is assignable to a teller. *

    * - * @param validTo + * @param endDate validTo * the valid to date of this cashier */ public void setEndDate(Date endDate) { @@ -409,7 +409,7 @@ public class Cashier extends AbstractPersistableCustom { /** * Sets the part time flag of this cashier. * - * @param partTime + * @param isFullDay partTime * the part time flag of this cashier */ public void setFullDay(Boolean isFullDay) { @@ -418,7 +418,7 @@ public class Cashier extends AbstractPersistableCustom { /** * Returns the start time of this cashier. - *

    + * *

    * The start/end times may be used to define a time period in which the * cashier works part time. @@ -432,7 +432,7 @@ public class Cashier extends AbstractPersistableCustom { /** * Set the start time of this cashier. - *

    + * *

    * The start/end times may be used to define a time period in which the * cashier works part time. @@ -447,7 +447,7 @@ public class Cashier extends AbstractPersistableCustom { /** * Returns the end time of this cashier. - *

    + * *

    * The start/end times may be used to define a time period in which the * cashier works part time. @@ -461,7 +461,7 @@ public class Cashier extends AbstractPersistableCustom { /** * Sets the end time of this cashier. - *

    + * *

    * The start/end times may be used to define a time period in which the * cashier works part time. diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/CashierTransaction.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/CashierTransaction.java index 65af4dde5..dbffe3837 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/CashierTransaction.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/domain/CashierTransaction.java @@ -213,7 +213,7 @@ public class CashierTransaction extends AbstractPersistableCustom { /** * Sets the transaction type of this cashier transaction. * - * @param description the transaction type of this cashier transaction + * @param txnType description the transaction type of this cashier transaction */ public void setTxnType(Integer txnType) { this.txnType = txnType; @@ -239,7 +239,7 @@ public class CashierTransaction extends AbstractPersistableCustom { /** * Sets the transaction date of this cashier transaction. * - * @param transaction date of this cashier transaction + * @param txnDate transaction date of this cashier transaction */ public void setTxnDate(Date txnDate) { this.txnDate = txnDate; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarFrequencyType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarFrequencyType.java index e7aa8b757..ab39044a6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarFrequencyType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarFrequencyType.java @@ -107,8 +107,8 @@ public enum CalendarFrequencyType { * To convert from period frequency type tp calendar frequency type. This * method requires code refactoring. * - * @param periodFrequencyType - * @return + * @param periodFrequencyType periodFrequencyType + * @return CalendarFrequencyType */ public static CalendarFrequencyType from(final PeriodFrequencyType periodFrequencyType) { switch (periodFrequencyType) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java index b7656f880..62ece1107 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java @@ -144,8 +144,8 @@ public class ClientTransaction extends AbstractPersistableCustom { * Converts the content of this Client Transaction to a map which can be * passed to the accounting module * - * @param currencyData - * @return + * + * */ public Map toMapData() { final Map thisTransactionData = new LinkedHashMap<>(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/CollectionSheetConstants.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/CollectionSheetConstants.java index 9b8ca2f10..5ce58e489 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/CollectionSheetConstants.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/CollectionSheetConstants.java @@ -50,4 +50,5 @@ public class CollectionSheetConstants { public static final String loanIdParamName = "loanId"; public static final String savingsIdParamName = "savingsId"; public static final String transactionAmountParamName = "transactionAmount"; + public static final String depositAccountTypeParamName = "depositAccountType"; } \ No newline at end of file diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/CollectionSheetTransactionDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/CollectionSheetTransactionDataValidator.java index 826f4a352..ec6192e92 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/CollectionSheetTransactionDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/CollectionSheetTransactionDataValidator.java @@ -36,6 +36,7 @@ import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.portfolio.collectionsheet.CollectionSheetConstants; +import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.portfolio.paymentdetail.PaymentDetailConstants; import org.joda.time.LocalDate; import org.springframework.beans.factory.annotation.Autowired; @@ -138,7 +139,7 @@ public class CollectionSheetTransactionDataValidator { final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(CollectionSheetConstants .transactionDateParamName, element); baseDataValidator.reset().parameter(CollectionSheetConstants.transactionDateParamName).value(transactionDate) - .notNull(); + .notNull().validateDateBeforeOrEqual(DateUtils.getLocalDateOfTenant()); final String note = this.fromApiJsonHelper.extractStringNamed(CollectionSheetConstants.noteParamName, element); if (StringUtils.isNotBlank(note)) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/SavingsDueData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/SavingsDueData.java index c084b3e51..e09c29079 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/SavingsDueData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/data/SavingsDueData.java @@ -40,14 +40,16 @@ public class SavingsDueData { private final CurrencyData currency; @SuppressWarnings("unused") private BigDecimal dueAmount = BigDecimal.ZERO; + @SuppressWarnings("unused") + private String depositAccountType; public static SavingsDueData instance(final Long savingsId, final String accountId, final Integer accountStatusId, - final String productName, final Long productId, final CurrencyData currency, final BigDecimal dueAmount) { - return new SavingsDueData(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount); + final String productName, final Long productId, final CurrencyData currency, final BigDecimal dueAmount, final String depositAccountType) { + return new SavingsDueData(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount, depositAccountType); } private SavingsDueData(final Long savingsId, final String accountId, final Integer accountStatusId, final String productName, - final Long productId, final CurrencyData currency, final BigDecimal dueAmount) { + final Long productId, final CurrencyData currency, final BigDecimal dueAmount, final String depositAccountType) { this.savingsId = savingsId; this.accountId = accountId; this.accountStatusId = accountStatusId; @@ -55,6 +57,7 @@ public class SavingsDueData { this.productId = productId; this.currency = currency; this.dueAmount = dueAmount; + this.depositAccountType = depositAccountType; } public String productName() { @@ -64,5 +67,9 @@ public class SavingsDueData { public Long productId() { return this.productId; } + + public String getDepositAccountType() { + return depositAccountType; + } } \ No newline at end of file diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java index 8432d36f2..18be4d0a9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java @@ -235,7 +235,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe .append("if(ln.loan_status_id = 200 , ln.principal_amount , null) As disbursementAmount, ") .append("sum(ifnull(if(ln.loan_status_id = 300, ls.principal_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.principal_completed_derived, 0.0), 0.0)) As principalDue, ") .append("ln.principal_repaid_derived As principalPaid, ") - .append("sum(ifnull(if(ln.loan_status_id = 300, ls.interest_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.interest_completed_derived, 0.0), 0.0)) As interestDue, ") + .append("sum(ifnull(if(ln.loan_status_id = 300, ls.interest_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.interest_completed_derived, 0.0), 0.0) - IFNULL(IF(ln.loan_status_id = 300, ls.interest_waived_derived, 0.0), 0.0)) As interestDue, ") .append("ln.interest_repaid_derived As interestPaid, ") .append("sum(ifnull(if(ln.loan_status_id = 300, ls.fee_charges_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.fee_charges_completed_derived, 0.0), 0.0)) As feeDue, ") .append("ln.fee_charges_repaid_derived As feePaid, ") @@ -439,6 +439,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe for (SavingsDueData savingsDueData : savingsDatas) { final SavingsProductData savingsProduct = SavingsProductData.lookup(savingsDueData.productId(), savingsDueData.productName()); + savingsProduct.setDepositAccountType(savingsDueData.getDepositAccountType()); if (!savingsProducts.contains(savingsProduct)) { savingsProducts.add(savingsProduct); } @@ -515,6 +516,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe .append("sa.currency_multiplesof as inMultiplesOf, ") .append("rc.`name` as currencyName, ") .append("rc.display_symbol as currencyDisplaySymbol, ") + .append("if(sa.deposit_type_enum=100,'Saving Deposit',if(sa.deposit_type_enum=300,'Recurring Deposit','Current Deposit')) as depositAccountType, ") .append("rc.internationalized_name_code as currencyNameCode, ") .append("sum(ifnull(mss.deposit_amount,0) - ifnull(mss.deposit_amount_completed_derived,0)) as dueAmount ") @@ -526,8 +528,8 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe .append("JOIN m_client cl ON cl.id = gc.client_id ") .append("JOIN m_savings_account sa ON sa.client_id=cl.id and sa.status_enum=300 ") .append("JOIN m_savings_product sp ON sa.product_id=sp.id ") - .append("JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = true ") - .append("JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.duedate <= :dueDate ") + .append("LEFT JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = true ") + .append("LEFT JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.duedate <= :dueDate ") .append("LEFT JOIN m_currency rc on rc.`code` = sa.currency_code "); if (isCenterCollection) { @@ -655,25 +657,25 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe private SavingsDueDataMapper() {} @Override - public SavingsDueData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException { + public SavingsDueData mapRow(ResultSet rs, int rowNum) throws SQLException { final Long savingsId = rs.getLong("savingsId"); final String accountId = rs.getString("accountId"); final Integer accountStatusId = JdbcSupport.getInteger(rs, "accountStatusId"); final String productName = rs.getString("productShortName"); final Long productId = rs.getLong("productId"); final BigDecimal dueAmount = rs.getBigDecimal("dueAmount"); - final String currencyCode = rs.getString("currencyCode"); final String currencyName = rs.getString("currencyName"); final String currencyNameCode = rs.getString("currencyNameCode"); final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol"); final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits"); final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf"); + final String depositAccountType = rs.getString("depositAccountType"); // currency final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf, currencyDisplaySymbol, currencyNameCode); - return SavingsDueData.instance(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount); + return SavingsDueData.instance(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount, depositAccountType); } } @@ -818,7 +820,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe public IndividualMandatorySavingsCollectionsheetExtractor(final boolean checkForOfficeId, final boolean checkforStaffId) { final StringBuffer sb = new StringBuffer(400); - sb.append("SELECT cl.display_name As clientName, cl.id As clientId, "); + sb.append("SELECT if(sa.deposit_type_enum=100,'Saving Deposit',if(sa.deposit_type_enum=300,'Recurring Deposit','Current Deposit')) as depositAccountType, cl.display_name As clientName, cl.id As clientId, "); sb.append("sa.id As savingsId, sa.account_no As accountId, sa.status_enum As accountStatusId, "); sb.append("sp.short_name As productShortName, sp.id As productId, "); sb.append("sa.currency_code as currencyCode, sa.currency_digits as currencyDigits, sa.currency_multiplesof as inMultiplesOf, "); @@ -827,11 +829,11 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe sb.append("FROM m_savings_account sa "); sb.append("JOIN m_client cl ON cl.id = sa.client_id "); sb.append("JOIN m_savings_product sp ON sa.product_id=sp.id "); - sb.append("JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = false "); - sb.append("JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.completed_derived = 0 AND mss.duedate <= :dueDate "); + sb.append("LEFT JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = false "); + sb.append("LEFT JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.completed_derived = 0 AND mss.duedate <= :dueDate "); sb.append("LEFT JOIN m_office of ON of.id = cl.office_id AND of.hierarchy like :officeHierarchy "); sb.append("LEFT JOIN m_currency rc on rc.`code` = sa.currency_code "); - sb.append("WHERE sa.status_enum=300 and sa.group_id is null "); + sb.append("WHERE sa.status_enum=300 and sa.group_id is null and sa.deposit_type_enum in (100,300,400) "); sb.append("and (cl.status_enum = 300 or (cl.status_enum = 600 and cl.closedon_date >= :dueDate)) "); if (checkForOfficeId) { sb.append("and of.id = :officeId "); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInMonthType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInMonthType.java index 2910eae2b..a07ab43b7 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInMonthType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInMonthType.java @@ -21,9 +21,10 @@ import java.util.ArrayList; import java.util.List; /** - *

      + * * People typically use either of the following settings when calculating there * interest using the daily method: + *
        *
      • Actual or
      • *
      • 30
      • *
      diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInYearType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInYearType.java index 81c8b8631..f35c4a078 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInYearType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/common/domain/DaysInYearType.java @@ -22,9 +22,10 @@ import java.util.ArrayList; import java.util.List; /** - *
        + * * People typically use either of the following settings when calculating there * interest using the daily method: + *
          *
        • Actual or
        • *
        • 360 or
        • *
        • 364 or
        • diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java index f4008438a..34350c2bd 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java @@ -564,9 +564,6 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService LocalDate localDate = new LocalDate(meetingDate); final CenterCalendarDataMapper centerCalendarMapper = new CenterCalendarDataMapper(); String passeddate = formatter.print(localDate); - if (!isCentersHavingMeetingFrequencyBasedOnOfficeIdAndMeetingDate(officeId, passeddate, staffId)) { throw new GeneralPlatformDomainRuleException( - "error.msg.collection.sheet.can.not.be.selected.meeting.date.not.attached.to.any.center", - "Collection sheet can not be generated without meeting date " + passeddate + " attached to any center ", passeddate); } String sql = centerCalendarMapper.schema(); Collection centerDataArray = null; if (staffId != null) { @@ -617,27 +614,6 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService return staffCenterDataArray; } - @SuppressWarnings("deprecation") - private boolean isCentersHavingMeetingFrequencyBasedOnOfficeIdAndMeetingDate(final Long officeId, final String passeddate, - final Long staffId) { - final StringBuilder sb = new StringBuilder(100); - sb.append("SELECT COUNT(*) "); - sb.append("FROM m_calendar c "); - sb.append("JOIN m_calendar_instance ci ON ci.calendar_id=c.id AND ci.entity_type_enum=4 "); - sb.append("JOIN m_group ce ON ce.id = ci.entity_id "); - sb.append("JOIN m_group g ON g.parent_id = ce.id "); - sb.append("WHERE c.start_date = ? AND g.office_id= ? "); - int i = 0; - if (staffId != null) { - sb.append(" AND g.staff_id = ? "); - i = this.jdbcTemplate.queryForInt(sb.toString(), new Object[] { passeddate, officeId, staffId }); - } else { - i = this.jdbcTemplate.queryForInt(sb.toString(), new Object[] { passeddate, officeId }); - } - if (i > 0) { return true; } - return false; - } - public void validateForGenerateCollectionSheet(final Long staffId) { final List dataValidationErrors = new ArrayList<>(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java index 8da89c094..e3c51c761 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java @@ -320,11 +320,14 @@ public class LoansApiResource { Map memberLoanCycle = new HashMap<>(); Collection members = loanAccountGroupData.groupData().clientMembers(); accountLinkingOptions = new ArrayList<>(); - for (ClientData clientData : members) { - Integer loanCounter = this.loanReadPlatformService.retriveLoanCounter(clientData.id(), productId); - memberLoanCycle.put(clientData.id(), loanCounter); - accountLinkingOptions.addAll(getaccountLinkingOptions(newLoanAccount, clientData.id(), groupId)); + if(members != null){ + for (ClientData clientData : members) { + Integer loanCounter = this.loanReadPlatformService.retriveLoanCounter(clientData.id(), productId); + memberLoanCycle.put(clientData.id(), loanCounter); + accountLinkingOptions.addAll(getaccountLinkingOptions(newLoanAccount, clientData.id(), groupId)); + } } + newLoanAccount = LoanAccountData.associateMemberVariations(newLoanAccount, memberLoanCycle); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java index 73d8edf44..b71205e1a 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java @@ -5585,14 +5585,17 @@ public class Loan extends AbstractPersistableCustom { } /** + * @param applicationCurrency * @param restCalendarInstance * TODO * @param compoundingCalendarInstance * TODO + * @param loanCalendar * @param floatingRateDTO * TODO - * @param isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled - * @param loanCalendarInstance + * @param isSkipRepaymentonmonthFirst + * @param numberofdays + * @param holidayDetailDTO * Used for accessing the loan's calendar object * @return application terms of the Loan object **/ diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java index 8dc72071b..8c82ebf09 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java @@ -741,10 +741,14 @@ public class LoanCharge extends AbstractPersistableCustom { } /** + * @param incrementBy + * + * @param installmentNumber + * * @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) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanSummary.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanSummary.java index 769a7fe6c..8bff6dc30 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanSummary.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanSummary.java @@ -32,7 +32,7 @@ import org.apache.fineract.organisation.monetary.domain.Money; * Encapsulates all the summary details of a {@link Loan}. * * {@link LoanSummary} fields are updated through a scheduled job. see - - * {@link UpdateLoanSummariesScheduledJob}. + * */ @Embeddable public final class LoanSummary { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java index 0da639319..938177fb6 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java @@ -386,6 +386,11 @@ public class LoanTransaction extends AbstractPersistableCustom { * * This accumulates the values passed to the already existent values for * each of the portions. + * + * @param principal principal + * @param interest interest + * @param feeCharges feeCharges + * @param penaltyCharges penaltyCharges */ public void updateComponents(final Money principal, final Money interest, final Money feeCharges, final Money penaltyCharges) { final MonetaryCurrency currency = principal.getCurrency(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java index 1bbf261d2..2c564839e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java @@ -39,7 +39,7 @@ import org.joda.time.LocalDate; *
        • Equal principal payments
        • *
        • Equal installment payments
        • * - *

          + *

          * *

          * When amortized using equal principal payments, the principal diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java index e69471463..4c30ba805 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/LoanRescheduleRequestDataValidator.java @@ -81,7 +81,7 @@ public class LoanRescheduleRequestDataValidator { * * @param jsonCommand * the JSON command object (instance of the JsonCommand class) - * @return void + * **/ public void validateForCreateAction(final JsonCommand jsonCommand, final Loan loan) { @@ -214,7 +214,7 @@ public class LoanRescheduleRequestDataValidator { * * @param jsonCommand * the JSON command object (instance of the JsonCommand class) - * @return void + * **/ public void validateForApproveAction(final JsonCommand jsonCommand, LoanRescheduleRequest loanRescheduleRequest) { final String jsonString = jsonCommand.json(); @@ -283,7 +283,7 @@ public class LoanRescheduleRequestDataValidator { * * @param jsonCommand * the JSON command object (instance of the JsonCommand class) - * @return void + * **/ public void validateForRejectAction(final JsonCommand jsonCommand, LoanRescheduleRequest loanRescheduleRequest) { final String jsonString = jsonCommand.json(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java index 188d20af4..bf06f7712 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java @@ -267,7 +267,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom { * * @param approvedByUser the user who approved the request * @param approvedOnDate the date of the approval - * @return void + * **/ public void approve(final AppUser approvedByUser, final LocalDate approvedOnDate) { @@ -284,7 +284,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom { * * @param approvedByUser the user who approved the request * @param approvedOnDate the date of the approval - * @return void + * **/ public void reject(final AppUser approvedByUser, final LocalDate approvedOnDate) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/exception/LoanRescheduleRequestNotFoundException.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/exception/LoanRescheduleRequestNotFoundException.java index 9a8afcec5..9775290a3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/exception/LoanRescheduleRequestNotFoundException.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/exception/LoanRescheduleRequestNotFoundException.java @@ -29,7 +29,7 @@ public class LoanRescheduleRequestNotFoundException extends AbstractPlatformReso * LoanRescheduleRequestNotFoundException constructor * * @param requestId the loan reschedule request identifier - * @return void + * **/ public LoanRescheduleRequestNotFoundException(final Long requestId) { super("error.msg.loan.reschedule.request.id.invalid", diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java index 7eccf9a51..977e7ba41 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java @@ -118,7 +118,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche /** * LoanRescheduleRequestWritePlatformServiceImpl constructor * - * @return void + * **/ @Autowired public LoanRescheduleRequestWritePlatformServiceImpl(final CodeValueRepositoryWrapper codeValueRepositoryWrapper, @@ -585,7 +585,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche * * @param dve * data integrity violation exception - * @return void + * **/ private void handleDataIntegrityViolation(final DataIntegrityViolationException dve) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java index f7aeb603c..73f41cfdc 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java @@ -130,4 +130,6 @@ public interface LoanReadPlatformService { Collection retrieveLoanIdsWithPendingIncomePostingTransactions(); LoanTransactionData retrieveLoanForeclosureTemplate(final Long loanId, final LocalDate transactionDate); + + LoanAccountData retrieveLoanByLoanAccount(String loanAccountNumber); } \ No newline at end of file diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index 6912f3c5d..19ea4ae84 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -219,6 +219,22 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { throw new LoanNotFoundException(loanId); } } + + @Override + public LoanAccountData retrieveLoanByLoanAccount(String loanAccountNumber) + { + + + //final AppUser currentUser = this.context.authenticatedUser(); + this.context.authenticatedUser(); + final LoanMapper rm = new LoanMapper(); + + String sql="select "+rm.loanSchema()+" where l.account_no=?"; + + + return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanAccountNumber }); + + } @Override public LoanScheduleData retrieveRepaymentSchedule(final Long loanId, @@ -237,6 +253,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { throw new LoanNotFoundException(loanId); } } + + @Override public Collection retrieveLoanTransactions(final Long loanId) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 23270d512..98f86fce8 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -449,7 +449,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf * * @param loan * the disbursed loan - * @return void + * **/ private void createStandingInstruction(Loan loan) { @@ -2318,7 +2318,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf final JsonElement parsedCommand = this.fromApiJsonHelper.parse(overdueInstallment.toString()); final JsonCommand command = JsonCommand.from(overdueInstallment.toString(), parsedCommand, this.fromApiJsonHelper, null, null, - null, null, null, loanId, null, null, null, null); + null, null, null, loanId, null, null, null, null,null,null); LoanOverdueDTO overdueDTO = applyChargeToOverdueLoanInstallment(loanId, overdueInstallment.getChargeId(), overdueInstallment.getPeriodNumber(), command, loan, existingTransactionIds, existingReversedTransactionIds); loan = overdueDTO.getLoan(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java index 2cea623e7..8b4d560fe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java @@ -22,9 +22,10 @@ import java.util.HashMap; import java.util.Map; /*** - *

            + * * People typically use either of the following settings when defining interest * recalculation method: + *
              *
            • NONE
            • *
            • INTEREST
            • *
            • FEE
            • diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java index 48090ef17..06c239548 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java @@ -22,9 +22,10 @@ import java.util.HashMap; import java.util.Map; /*** - *
                + * * People typically use either of the following settings when defining interest * recalculation method: + *
                  *
                • SAME_AS_REPAYMENT_PERIOD
                • *
                • DAILY
                • *
                • WEEKLY
                • diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java index 0c81e9971..a74a26b1c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java @@ -22,9 +22,9 @@ import java.util.HashMap; import java.util.Map; /*** - *
                    - * People typically use either of the following settings when defining interest + * * People typically use either of the following settings when defining interest * recalculation method: + *
                      *
                    • RESCHEDULE_NEXT_REPAYMENTS
                    • *
                    • REDUCE_NUMBER_OF_INSTALLMENTS
                    • *
                    • REDUCE_EMI_AMOUNT
                    • diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountOnClosureType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountOnClosureType.java index c3f19a37d..78a506bb2 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountOnClosureType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountOnClosureType.java @@ -26,7 +26,7 @@ import org.apache.fineract.portfolio.savings.domain.RecurringDepositAccount; /** * An enumeration of different options available on account closure - * {@link FixedDepositAccount} & {@link RecurringDepositAccount}. + * {@link FixedDepositAccount} & {@link RecurringDepositAccount}. */ public enum DepositAccountOnClosureType { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationDaysInYearType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationDaysInYearType.java index 0630f9896..e9ec9b150 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationDaysInYearType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationDaysInYearType.java @@ -22,9 +22,10 @@ import java.util.ArrayList; import java.util.List; /** - *
                        + * * People typically use either of the following settings when calculating there * interest using the daily method: + *
                          *
                        • 360 and
                        • *
                        • 365
                        • *
                        diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationType.java index d9800f8d8..922e519a6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/SavingsInterestCalculationType.java @@ -22,8 +22,9 @@ import java.util.ArrayList; import java.util.List; /** - *
                          + * * There are two methods to calculate the interest on a savings account: + *
                            *
                          • The daily balance method; and
                          • *
                          • The average daily balance method.
                          • *
                          diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionDTO.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionDTO.java index fb91c850b..4cfaa304a 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionDTO.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountTransactionDTO.java @@ -35,9 +35,10 @@ public class SavingsAccountTransactionDTO { private final Date createdDate; private final Long savingsAccountId; private final AppUser appUser; + private final Integer depositAccountType; public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate, - final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate, final AppUser appUser) { + final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate, final AppUser appUser, final Integer depositAccountType) { this.formatter = formatter; this.transactionDate = transactionDate; this.transactionAmount = transactionAmount; @@ -45,6 +46,7 @@ public class SavingsAccountTransactionDTO { this.createdDate = createdDate; this.savingsAccountId = null; this.appUser = appUser; + this.depositAccountType = depositAccountType; } /** @@ -58,7 +60,7 @@ public class SavingsAccountTransactionDTO { * @param savingsAccountId */ public SavingsAccountTransactionDTO(DateTimeFormatter formatter, LocalDate transactionDate, BigDecimal transactionAmount, - PaymentDetail paymentDetail, Date createdDate, Long savingsAccountId, AppUser appUser) { + PaymentDetail paymentDetail, Date createdDate, Long savingsAccountId, AppUser appUser, final Integer depositAccountType) { this.formatter = formatter; this.transactionDate = transactionDate; this.transactionAmount = transactionAmount; @@ -66,6 +68,7 @@ public class SavingsAccountTransactionDTO { this.createdDate = createdDate; this.savingsAccountId = savingsAccountId; this.appUser = appUser; + this.depositAccountType = depositAccountType; } public DateTimeFormatter getFormatter() { @@ -95,4 +98,10 @@ public class SavingsAccountTransactionDTO { public AppUser getAppUser() { return this.appUser; } + + public Integer getAccountType() { + return this.depositAccountType; + } + + } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductData.java index f8bba2071..277126ecc 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductData.java @@ -61,6 +61,7 @@ public class SavingsProductData { private final BigDecimal minOverdraftForInterestCalculation; private final boolean withHoldTax; private final TaxGroupData taxGroup; + private String depositAccountType = null; // accounting private final EnumOptionData accountingRule; @@ -436,4 +437,14 @@ public class SavingsProductData { public String getName() { return this.name; } + + public String getDepositAccountType() { + return depositAccountType; + } + + public void setDepositAccountType(String depositAccountType) { + this.depositAccountType = depositAccountType; + } + + } \ No newline at end of file diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountAssembler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountAssembler.java index efc2e5853..80025bbce 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountAssembler.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountAssembler.java @@ -73,6 +73,7 @@ import org.apache.fineract.portfolio.accountdetails.domain.AccountType; import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; +import org.apache.fineract.portfolio.collectionsheet.CollectionSheetConstants; import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper; import org.apache.fineract.portfolio.group.exception.CenterNotActiveException; @@ -444,12 +445,14 @@ public class DepositAccountAssembler { final Long savingsId = this.fromApiJsonHelper.extractLongNamed(savingsIdParamName, savingsTransactionElement); final BigDecimal dueAmount = this.fromApiJsonHelper.extractBigDecimalNamed(transactionAmountParamName, savingsTransactionElement, locale); + final Integer depositAccountType = this.fromApiJsonHelper.extractIntegerNamed( + CollectionSheetConstants.depositAccountTypeParamName, savingsTransactionElement, locale); PaymentDetail detail = paymentDetail; if (paymentDetail == null) { detail = this.paymentDetailAssembler.fetchPaymentDetail(savingsTransactionElement); } final SavingsAccountTransactionDTO savingsAccountTransactionDTO = new SavingsAccountTransactionDTO(formatter, - transactionDate, dueAmount, detail, new Date(), savingsId, user); + transactionDate, dueAmount, detail, new Date(), savingsId, user, depositAccountType); savingsAccountTransactions.add(savingsAccountTransactionDTO); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainService.java index 9df5b6335..f97ed49ef 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainService.java @@ -37,6 +37,9 @@ public interface DepositAccountDomainService { SavingsAccountTransaction handleRDDeposit(RecurringDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate, BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction); + + SavingsAccountTransaction handleSavingDeposit(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate, + BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction); Long handleFDAccountClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command, LocalDate tenantsTodayDate, Map changes); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainServiceJpa.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainServiceJpa.java index ac277fb08..0b364f3f2 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainServiceJpa.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainServiceJpa.java @@ -163,6 +163,21 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi } return deposit; } + + @Transactional + @Override + public SavingsAccountTransaction handleSavingDeposit(final SavingsAccount account, final DateTimeFormatter fmt, + final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail, + final boolean isRegularTransaction) { + boolean isAccountTransfer = false; + final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(account, fmt, transactionDate, + transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction); + final Set existingTransactionIds = new HashSet<>(); + final Set existingReversedTransactionIds = new HashSet<>(); + updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); + postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); + return deposit; + } private boolean isAnyActivationChargesDue(final RecurringDepositAccount account) { for (final SavingsAccountCharge savingsAccountCharge : account.charges()) { @@ -191,7 +206,7 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi */ updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); /* - * <<<<<<< HEAD final SavingsAccountTransactionDTO transactionDTO = new + * final SavingsAccountTransactionDTO transactionDTO = new * SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, * paymentDetail, new Date()); final SavingsAccountTransaction deposit = * account.deposit(transactionDTO); boolean isInterestTransfer = false; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java index 9b020279e..8e276a933 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java @@ -523,7 +523,7 @@ public class RecurringDepositAccount extends SavingsAccount { final Money minRequiredOpeningBalance = Money.of(this.currency, this.minRequiredOpeningBalance); if (minRequiredOpeningBalance.isGreaterThanZero()) { final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, getActivationLocalDate(), - minRequiredOpeningBalance.getAmount(), null, new Date(), user); + minRequiredOpeningBalance.getAmount(), null, new Date(), user, accountType); deposit(transactionDTO); // update existing transactions so derived balance fields are diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java index dd72aea8d..32fdcd25d 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountDomainServiceJpa.java @@ -95,8 +95,9 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi final LocalDate postInterestOnDate = null; final Set existingReversedTransactionIds = new HashSet<>(); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); + Integer accountType = null; final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail, new Date(), user); + paymentDetail, new Date(), user, accountType); final SavingsAccountTransaction withdrawal = account.withdraw(transactionDTO, transactionBooleanValues.isApplyWithdrawFee()); final MathContext mc = MathContext.DECIMAL64; if (account.isBeforeLastPostingPeriod(transactionDate)) { @@ -157,8 +158,9 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi final Set existingTransactionIds = new HashSet<>(); final Set existingReversedTransactionIds = new HashSet<>(); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); + Integer accountType = null; final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail, new Date(), user); + paymentDetail, new Date(), user, accountType); final SavingsAccountTransaction deposit = account.deposit(transactionDTO, savingsAccountTransactionType); final LocalDate postInterestOnDate = null; final MathContext mc = MathContext.DECIMAL64; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java index 6b0402ed6..8726bddc4 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java @@ -699,13 +699,14 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo account.undoTransaction(transactionId); SavingsAccountTransaction transaction = null; + Integer accountType = null; if (savingsAccountTransaction.isDeposit()) { final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail, savingsAccountTransaction.createdDate(), user); + paymentDetail, savingsAccountTransaction.createdDate(), user, accountType); transaction = account.deposit(transactionDTO); } else { final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail, savingsAccountTransaction.createdDate(), user); + paymentDetail, savingsAccountTransaction.createdDate(), user, accountType); transaction = account.withdraw(transactionDTO, true); } final Long newtransactionId = saveTransactionToGenerateTransactionId(transaction); @@ -1353,22 +1354,37 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); this.journalEntryWritePlatformService.createJournalEntriesForSavings(accountingBridgeData); } - + @Transactional @Override public SavingsAccountTransaction mandatorySavingsAccountDeposit(final SavingsAccountTransactionDTO accountTransactionDTO) { boolean isRegularTransaction = false; - final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom( - accountTransactionDTO.getSavingsAccountId(), DepositAccountType.RECURRING_DEPOSIT); final PaymentDetail paymentDetail = accountTransactionDTO.getPaymentDetail(); if (paymentDetail != null && paymentDetail.getId() == null) { this.paymentDetailWritePlatformService.persistPaymentDetail(paymentDetail); } - return this.depositAccountDomainService.handleRDDeposit(account, accountTransactionDTO.getFormatter(), + if (accountTransactionDTO.getAccountType().equals(DepositAccountType.RECURRING_DEPOSIT.getValue())) { + RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom( + accountTransactionDTO.getSavingsAccountId(), DepositAccountType.RECURRING_DEPOSIT); + return this.depositAccountDomainService.handleRDDeposit(account, accountTransactionDTO.getFormatter(), + accountTransactionDTO.getTransactionDate(), accountTransactionDTO.getTransactionAmount(), paymentDetail, + isRegularTransaction); + } + SavingsAccount account = null; + if (accountTransactionDTO.getAccountType().equals(DepositAccountType.SAVINGS_DEPOSIT.getValue())) { + account = this.depositAccountAssembler.assembleFrom(accountTransactionDTO.getSavingsAccountId(), + DepositAccountType.SAVINGS_DEPOSIT); + } else { + account = this.depositAccountAssembler.assembleFrom(accountTransactionDTO.getSavingsAccountId(), + DepositAccountType.CURRENT_DEPOSIT); + } + return this.depositAccountDomainService.handleSavingDeposit(account, accountTransactionDTO.getFormatter(), accountTransactionDTO.getTransactionDate(), accountTransactionDTO.getTransactionAmount(), paymentDetail, isRegularTransaction); + } + private AppUser getAppUserIfPresent() { AppUser user = null; if (this.context != null) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java index 2064f57ee..8b3aa1df5 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java @@ -550,8 +550,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi SavingsAccountTransaction transaction = null; boolean isInterestTransfer = false; + Integer accountType = null; final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, - paymentDetail, savingsAccountTransaction.createdDate(), user); + paymentDetail, savingsAccountTransaction.createdDate(), user, accountType); if (savingsAccountTransaction.isDeposit()) { transaction = account.deposit(transactionDTO); } else { @@ -1315,7 +1316,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi * Disable all standing instructions linked to the savings account if the status is "closed" * * @param savingsAccount -- the savings account object - * @return None + * **/ @Transactional private void disableStandingInstructionsLinkedToClosedSavings(final SavingsAccount savingsAccount) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/ShareAccountCommandsServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/ShareAccountCommandsServiceImpl.java index 6f56afa12..926aa0dca 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/ShareAccountCommandsServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/ShareAccountCommandsServiceImpl.java @@ -47,7 +47,7 @@ public class ShareAccountCommandsServiceImpl implements AccountsCommandsService public Object handleCommand(Long accountId, String command, String jsonBody) { final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonBody); final JsonCommand jsonCommand = JsonCommand.from(jsonBody, parsedCommand, this.fromApiJsonHelper, null, null, null, null, null, - null, null, null, null, null); + null, null, null, null, null,null,null); if(ShareAccountApiConstants.APPROVE_COMMAND.equals(command)){ return approveShareAccount(accountId, jsonCommand) ; }if(ShareAccountApiConstants.REJECT_COMMAND.equals(command)){ diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java index ee3686383..e95d75c84 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java @@ -47,7 +47,7 @@ public class ShareProductCommandsServiceImpl implements ProductCommandsService { public Object handleCommand(Long productId, String command, String jsonBody) { final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonBody); final JsonCommand jsonCommand = JsonCommand.from(jsonBody, parsedCommand, this.fromApiJsonHelper, null, null, null, null, null, - null, null, null, null, null); + null, null, null, null, null,null,null); if (ShareProductApiConstants.PREIEW_DIVIDENDS_COMMAND_STRING.equals(command)) { return null ; } else if (ShareProductApiConstants.POST_DIVIDENdS_COMMAND_STRING.equals(command)) { return postDividends(productId, diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/transfer/service/TransferWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/transfer/service/TransferWritePlatformServiceJpaRepositoryImpl.java index 7dfc6d675..d037c1612 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/transfer/service/TransferWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/transfer/service/TransferWritePlatformServiceJpaRepositoryImpl.java @@ -140,11 +140,12 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr } /**** - * Variables that would make sense
                          + * Variables that would make sense
                          *
                            *
                          • inheritDestinationGroupLoanOfficer: Default true
                          • *
                          • newStaffId: Optional field with Id of new Loan Officer to be linked * to this client and all his JLG loans for this group
                          • + *
                          * ***/ @Transactional public void transferClientBetweenGroups(final Group sourceGroup, final Client client, final Group destinationGroup, @@ -248,10 +249,9 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr /** * This API is meant for transferring clients between branches mainly by - * Organizations following an Individual lending Model
                          + * Organizations following an Individual lending Model
                          * * @param clientId - * @param destinationOfficeId * @param jsonCommand * @return **/ @@ -277,13 +277,12 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr /** * This API is meant for transferring clients between branches mainly by - * Organizations following an Individual lending Model
                          + * Organizations following an Individual lending Model
                          * If the Client is linked to any Groups, we can optionally choose to have * all the linkages broken and all JLG Loans are converted into Individual * Loans * * @param clientId - * @param destinationOfficeId * @param jsonCommand * @return **/ @@ -306,13 +305,12 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr /** * This API is meant for transferring clients between branches mainly by - * Organizations following an Individual lending Model
                          + * Organizations following an Individual lending Model
                          * If the Client is linked to any Groups, we can optionally choose to have * all the linkages broken and all JLG Loans are converted into Individual * Loans * * @param clientId - * @param destinationOfficeId * @param jsonCommand * @return **/ diff --git a/fineract-provider/src/main/resources/META-INF/spring/appContext.xml b/fineract-provider/src/main/resources/META-INF/spring/appContext.xml index 80ebec663..9fe95d447 100644 --- a/fineract-provider/src/main/resources/META-INF/spring/appContext.xml +++ b/fineract-provider/src/main/resources/META-INF/spring/appContext.xml @@ -43,6 +43,7 @@ org.apache.fineract.commands.service.*, org.apache.fineract.commands.*, org.apache.fineract.audit.*, + org.apache.fineract.infrastructure.creditbureau.*, org.apache.fineract.infrastructure.*, org.apache.fineract.scheduledjobs.*, org.apache.fineract.organisation.*, @@ -69,7 +70,6 @@ - diff --git a/fineract-provider/src/main/resources/sql/migrations/core_db/V327__creditbureau_configuration.sql b/fineract-provider/src/main/resources/sql/migrations/core_db/V327__creditbureau_configuration.sql new file mode 100644 index 000000000..d1ebd03b6 --- /dev/null +++ b/fineract-provider/src/main/resources/sql/migrations/core_db/V327__creditbureau_configuration.sql @@ -0,0 +1,89 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + + -- credit bureau tables +CREATE TABLE `m_creditbureau` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `product` varchar(100) NOT NULL, + `country` varchar(100) NOT NULL, + `implementationKey` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `unique impl` (`name`,`product`,`country`,`implementationKey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `m_organisation_creditbureau` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `alias` varchar(50) NOT NULL, + `creditbureau_id` bigint(20) NOT NULL, + `is_active` tinyint(4) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `morgcb` (`alias`,`creditbureau_id`), + KEY `orgcb_cbfk` (`creditbureau_id`), + CONSTRAINT `orgcb_cbfk` FOREIGN KEY (`creditbureau_id`) REFERENCES `m_creditbureau` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + + + +CREATE TABLE `m_creditbureau_configuration` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `configkey` varchar(50) DEFAULT NULL, + `value` varchar(50) DEFAULT NULL, + `organisation_creditbureau_id` bigint(20) DEFAULT NULL, + `description` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `mcbconfig` (`configkey`,`organisation_creditbureau_id`), + KEY `cbConfigfk1` (`organisation_creditbureau_id`), + CONSTRAINT `cbConfigfk1` FOREIGN KEY (`organisation_creditbureau_id`) REFERENCES `m_organisation_creditbureau` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + + + + +CREATE TABLE `m_creditbureau_loanproduct_mapping` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `organisation_creditbureau_id` bigint(20) NOT NULL, + `loan_product_id` bigint(20) NOT NULL, + `is_creditcheck_mandatory` tinyint(1) DEFAULT NULL, + `skip_creditcheck_in_failure` tinyint(1) DEFAULT NULL, + `stale_period` int(11) DEFAULT NULL, + `is_active` tinyint(1) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `cblpunique_key` (`organisation_creditbureau_id`,`loan_product_id`), + KEY `fk_cb_lp2` (`loan_product_id`), + CONSTRAINT `cblpfk2` FOREIGN KEY (`organisation_creditbureau_id`) REFERENCES `m_organisation_creditbureau` (`id`), + CONSTRAINT `fk_cb_lp2` FOREIGN KEY (`loan_product_id`) REFERENCES `m_product_loan` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +-- modify `m_portfolio_command_source` command + +ALTER TABLE `m_portfolio_command_source` + ADD COLUMN `creditbureau_id` BIGINT(20) NULL DEFAULT NULL AFTER `transaction_id`, + ADD COLUMN `organisation_creditbureau_id` BIGINT(20) NULL DEFAULT NULL AFTER `creditbureau_id`; + + +-- permissions +INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('configuration', 'CREATE_CREDITBUREAU_LOANPRODUCT_MAPPING', 'CREDITBUREAU_LOANPRODUCT_MAPPING', 'CREATE', 0); +INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('configuration', 'CREATE_ORGANISATIONCREDITBUREAU', 'ORGANISATIONCREDITBUREAU', 'CREATE', 0); +INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('configuration', 'UPDATE_ORGANISATIONCREDITBUREAU', 'ORGANISATIONCREDITBUREAU', 'UPDATE', 0); +INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('configuration', 'UPDATE_CREDITBUREAU_LOANPRODUCT_MAPPING', 'CREDITBUREAU_LOANPRODUCT_MAPPING', 'UPDATE', 0); diff --git a/fineract-provider/src/test/java/org/apache/fineract/commands/provider/CommandHandlerProviderTest.java b/fineract-provider/src/test/java/org/apache/fineract/commands/provider/CommandHandlerProviderTest.java index 811845bf3..a3e9aa6db 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/commands/provider/CommandHandlerProviderTest.java +++ b/fineract-provider/src/test/java/org/apache/fineract/commands/provider/CommandHandlerProviderTest.java @@ -56,7 +56,7 @@ public class CommandHandlerProviderTest { final CommandProcessingResult result = registeredHandler.processCommand( - JsonCommand.fromExistingCommand(testCommandId, null, null, null, null, null, null, null, null)); + JsonCommand.fromExistingCommand(testCommandId, null, null, null, null, null, null, null, null,null,null)); Assert.assertEquals(testCommandId, result.commandId()); } catch (UnsupportedCommandException ucex) { Assert.fail();