[FINERACT-1926] POST API for asset externalization

This commit is contained in:
taskain7
2023-05-24 11:26:54 +02:00
committed by Adam Saghy
parent fd27401de4
commit 045f0ec121
40 changed files with 1257 additions and 25 deletions
@@ -3622,4 +3622,20 @@ public class CommandWrapperBuilder {
this.href = "/loans/" + loanId + "/transactions?command=undo-charge-off";
return this;
}
public CommandWrapperBuilder saleLoanToExternalAssetOwner(final Long loanId) {
this.actionName = "SALE";
this.entityName = "LOAN";
this.loanId = loanId;
this.href = "/external-asset-owners/transfers/loans/" + loanId;
return this;
}
public CommandWrapperBuilder buybackLoanToExternalAssetOwner(final Long loanId) {
this.actionName = "BUYBACK";
this.entityName = "LOAN";
this.loanId = loanId;
this.href = "/external-asset-owners/transfers/loans/" + loanId;
return this;
}
}
@@ -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.commands.service;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
public interface PortfolioCommandSourceWritePlatformService {
CommandProcessingResult logCommandSource(CommandWrapper commandRequest);
CommandProcessingResult approveEntry(Long id);
Long rejectEntry(Long id);
Long deleteEntry(Long makerCheckerId);
}
@@ -0,0 +1,79 @@
/**
* 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.cache.domain;
import java.util.HashMap;
import java.util.Map;
public enum CacheType {
INVALID(0, "cacheType.invalid"), //
NO_CACHE(1, "cacheType.noCache"), //
SINGLE_NODE(2, "cacheType.singleNode"), //
MULTI_NODE(3, "cacheType.multiNode");
private final Integer value;
private final String code;
private static final Map<Integer, CacheType> intToEnumMap = new HashMap<>();
static {
for (final CacheType type : CacheType.values()) {
intToEnumMap.put(type.value, type);
}
}
public static CacheType fromInt(final Integer value) {
CacheType type = intToEnumMap.get(value);
if (type == null) {
type = INVALID;
}
return type;
}
CacheType(final Integer value, final String code) {
this.value = value;
this.code = code;
}
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
}
public Integer getValue() {
return this.value;
}
public String getCode() {
return this.code;
}
public boolean isNoCache() {
return NO_CACHE.getValue().equals(this.value);
}
public boolean isEhcache() {
return SINGLE_NODE.getValue().equals(this.value);
}
public boolean isDistributedCache() {
return MULTI_NODE.getValue().equals(this.value);
}
}
@@ -0,0 +1,142 @@
/**
* 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.configuration.domain;
import java.time.LocalDate;
import org.apache.fineract.infrastructure.cache.domain.CacheType;
public interface ConfigurationDomainService {
boolean isMakerCheckerEnabledForTask(String taskPermissionCode);
boolean isAmazonS3Enabled();
boolean isRescheduleFutureRepaymentsEnabled();
boolean isRescheduleRepaymentsOnHolidaysEnabled();
boolean allowTransactionsOnHolidayEnabled();
boolean allowTransactionsOnNonWorkingDayEnabled();
boolean isConstraintApproachEnabledForDatatables();
boolean isEhcacheEnabled();
void updateCache(CacheType cacheType);
Long retrievePenaltyWaitPeriod();
boolean isPasswordForcedResetEnable();
Long retrievePasswordLiveTime();
Long retrieveGraceOnPenaltyPostingPeriod();
Long retrieveOpeningBalancesContraAccount();
boolean isSavingsInterestPostingAtCurrentPeriodEnd();
Integer retrieveFinancialYearBeginningMonth();
Integer retrieveMinAllowedClientsInGroup();
Integer retrieveMaxAllowedClientsInGroup();
boolean isMeetingMandatoryForJLGLoans();
int getRoundingMode();
boolean isBackdatePenaltiesEnabled();
boolean isOrganisationstartDateEnabled();
LocalDate retrieveOrganisationStartDate();
boolean isPaymentTypeApplicableForDisbursementCharge();
boolean isInterestChargedFromDateSameAsDisbursementDate();
boolean isSkippingMeetingOnFirstDayOfMonthEnabled();
boolean isInterestToBeRecoveredFirstWhenGreaterThanEMI();
boolean isPrincipalCompoundingDisabledForOverdueLoans();
Long retreivePeroidInNumberOfDaysForSkipMeetingDate();
boolean isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled();
boolean isDailyTPTLimitEnabled();
Long getDailyTPTLimit();
void removeGlobalConfigurationPropertyDataFromCache(String propertyName);
boolean isSMSOTPDeliveryEnabled();
boolean isEmailOTPDeliveryEnabled();
Integer retrieveOTPCharacterLength();
Integer retrieveOTPLiveTime();
boolean isSubRatesEnabled();
boolean isFirstRepaymentDateAfterRescheduleAllowedOnHoliday();
String getAccountMappingForPaymentType();
String getAccountMappingForCharge();
boolean isNextDayFixedDepositInterestTransferEnabledForPeriodEnd();
boolean retrievePivotDateConfig();
boolean isRelaxingDaysConfigForPivotDateEnabled();
Long retrieveRelaxingDaysConfigForPivotDate();
boolean isBusinessDateEnabled();
boolean isCOBDateAdjustmentEnabled();
boolean isReversalTransactionAllowed();
Long retrieveExternalEventsPurgeDaysCriteria();
Long retrieveProcessedCommandsPurgeDaysCriteria();
Long retrieveRepaymentDueDays();
Long retrieveRepaymentOverdueDays();
boolean isExternalIdAutoGenerationEnabled();
boolean isAddressEnabled();
boolean isCOBBulkEventEnabled();
Long retrieveExternalEventBatchSize();
String retrieveReportExportS3FolderName();
String getAccrualDateConfigForCharge();
}
@@ -0,0 +1,145 @@
/**
* 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.core.data;
import java.util.Map;
import org.apache.fineract.infrastructure.core.domain.ExternalId;
/**
* Represents the successful result of an REST API call that results in processing a command.
*/
public class CommandProcessingResultBuilder {
private Long commandId;
private Long officeId;
private Long groupId;
private Long clientId;
private Long loanId;
private Long savingsId;
private String resourceIdentifier;
private Long entityId;
private Long subEntityId;
private Long gsimId;
private Long glimId;
private String transactionId;
private Map<String, Object> changes;
private Map<String, Object> creditBureauReportData;
private Long productId;
private boolean rollbackTransaction = false;
private ExternalId entityExternalId = ExternalId.empty();
private ExternalId subEntityExternalId = ExternalId.empty();
public CommandProcessingResult build() {
return CommandProcessingResult.fromDetails(this.commandId, this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId,
this.resourceIdentifier, this.entityId, this.gsimId, this.glimId, this.creditBureauReportData, this.transactionId,
this.changes, this.productId, this.rollbackTransaction, this.subEntityId, this.entityExternalId, this.subEntityExternalId);
}
public CommandProcessingResultBuilder withCommandId(final Long withCommandId) {
this.commandId = withCommandId;
return this;
}
public CommandProcessingResultBuilder with(final Map<String, Object> withChanges) {
this.changes = withChanges;
return this;
}
public CommandProcessingResultBuilder withResourceIdAsString(final String withResourceIdentifier) {
this.resourceIdentifier = withResourceIdentifier;
return this;
}
public CommandProcessingResultBuilder withEntityId(final Long withEntityId) {
this.entityId = withEntityId;
return this;
}
public CommandProcessingResultBuilder withSubEntityId(final Long withSubEntityId) {
this.subEntityId = withSubEntityId;
return this;
}
public CommandProcessingResultBuilder withOfficeId(final Long withOfficeId) {
this.officeId = withOfficeId;
return this;
}
public CommandProcessingResultBuilder withClientId(final Long withClientId) {
this.clientId = withClientId;
return this;
}
public CommandProcessingResultBuilder withGroupId(final Long withGroupId) {
this.groupId = withGroupId;
return this;
}
public CommandProcessingResultBuilder withLoanId(final Long withLoanId) {
this.loanId = withLoanId;
return this;
}
public CommandProcessingResultBuilder withSavingsId(final Long withSavingsId) {
this.savingsId = withSavingsId;
return this;
}
public CommandProcessingResultBuilder withTransactionId(final String withTransactionId) {
this.transactionId = withTransactionId;
return this;
}
public CommandProcessingResultBuilder withProductId(final Long productId) {
this.productId = productId;
return this;
}
public CommandProcessingResultBuilder withGsimId(final Long gsimId) {
this.gsimId = gsimId;
return this;
}
public CommandProcessingResultBuilder withGlimId(final Long glimId) {
this.glimId = glimId;
return this;
}
public CommandProcessingResultBuilder withCreditReport(final Map<String, Object> withCreditReport) {
this.creditBureauReportData = withCreditReport;
return this;
}
public CommandProcessingResultBuilder setRollbackTransaction(final boolean rollbackTransaction) {
this.rollbackTransaction = this.rollbackTransaction || rollbackTransaction;
return this;
}
public CommandProcessingResultBuilder withEntityExternalId(final ExternalId entityExternalId) {
this.entityExternalId = entityExternalId;
return this;
}
public CommandProcessingResultBuilder withSubEntityExternalId(final ExternalId subEntityExternalId) {
this.subEntityExternalId = subEntityExternalId;
return this;
}
}
@@ -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.core.data;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.fineract.infrastructure.core.domain.ExternalId;
@Data
@AllArgsConstructor
public class LoanIdAndExternalIdData {
private Long loanId;
private ExternalId loanExternalId;
}
@@ -0,0 +1,44 @@
/**
* 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.core.exception;
public class UnrecognizedQueryParamException extends RuntimeException {
private final String queryParamKey;
private final String queryParamValue;
private final Object[] supportedParams;
public UnrecognizedQueryParamException(final String queryParamKey, final String queryParamValue, final Object... supportedParams) {
this.queryParamKey = queryParamKey;
this.queryParamValue = queryParamValue;
this.supportedParams = supportedParams;
}
public String getQueryParamKey() {
return this.queryParamKey;
}
public String getQueryParamValue() {
return this.queryParamValue;
}
public Object[] getSupportedParams() {
return this.supportedParams;
}
}
@@ -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.core.service;
import org.apache.commons.lang3.StringUtils;
public final class CommandParameterUtil {
private CommandParameterUtil() {}
public static boolean is(final String commandParam, final String commandValue) {
return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue);
}
}
@@ -0,0 +1,60 @@
/**
* 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.core.service;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.ExternalId;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class ExternalIdFactory {
private final ConfigurationDomainService configurationDomainService;
public static ExternalId produce(String value) {
return StringUtils.isBlank(value) ? ExternalId.empty() : new ExternalId(value);
}
public ExternalId createFromCommand(JsonCommand command, final String externalIdKey) {
String externalIdStr = null;
if (command.parsedJson() != null) {
externalIdStr = command.stringValueOfParameterNamedAllowingNull(externalIdKey);
}
return create(externalIdStr);
}
public ExternalId create(String externalIdStr) {
if (StringUtils.isBlank(externalIdStr)) {
if (configurationDomainService.isExternalIdAutoGenerationEnabled()) {
return ExternalId.generate();
} else {
return ExternalId.empty();
}
}
return new ExternalId(externalIdStr);
}
public ExternalId create() {
return create(null);
}
}
@@ -0,0 +1,28 @@
/**
* 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.portfolio.loanaccount.service;
import org.apache.fineract.infrastructure.core.data.LoanIdAndExternalIdData;
public interface LoanReadPlatformServiceCommon {
LoanIdAndExternalIdData getTransferableLoanIdAndExternalId(Long loanId);
Long getLoanIdByLoanExternalId(String externalId);
}