FINERACT-1847: Removing Edit function from Goodwill Credit or Payout Refund or Merchant Issued Refund transactions on API level
This commit is contained in:
committed by
Adam Saghy
parent
66e4ac6194
commit
6d3cac8c02
+4
@@ -651,6 +651,10 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
return getTypeOf().isChargeback() && isNotReversed();
|
||||
}
|
||||
|
||||
public boolean isEditable() {
|
||||
return !(isChargeback() || isGoodwillCredit() || isPayoutRefund() || isMerchantIssuedRefund());
|
||||
}
|
||||
|
||||
public boolean isPenaltyPayment() {
|
||||
boolean isPenalty = false;
|
||||
if (isChargePayment()) {
|
||||
|
||||
-1
@@ -37,7 +37,6 @@ public class LoanRepaymentAdjustmentCommandHandler implements NewCommandSourceHa
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.adjustLoanTransaction(command.getLoanId(), command.entityId(), command);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -163,6 +163,7 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepositor
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.DateMismatchException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.ExceedingTrancheCountException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTransactionTypeException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.InvalidPaidInAdvanceAmountException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanForeclosureException;
|
||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanMultiDisbursementException;
|
||||
@@ -1066,16 +1067,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
transactionId);
|
||||
}
|
||||
|
||||
if (transactionToAdjust.isChargeback()) {
|
||||
throw new PlatformServiceUnavailableException("error.msg.loan.transaction.update.not.allowed", "Loan transaction:"
|
||||
+ transactionId + " update not allowed as loan transaction is charge back and is linked to other transaction",
|
||||
transactionId);
|
||||
}
|
||||
|
||||
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
|
||||
final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount");
|
||||
final ExternalId txnExternalId = externalIdFactory.createFromCommand(command, LoanApiConstants.externalIdParameterName);
|
||||
|
||||
final boolean isAdjustCommand = (transactionAmount.compareTo(BigDecimal.ZERO) > 0);
|
||||
if (isAdjustCommand && !transactionToAdjust.isEditable()) {
|
||||
final String errorMessage = "Loan transaction: " + transactionId + " update not allowed as loan transaction is a "
|
||||
+ transactionToAdjust.getTypeOf().getCode();
|
||||
throw new InvalidLoanTransactionTypeException("transaction", "error.msg.loan.transaction.update.not.allowed", errorMessage);
|
||||
}
|
||||
|
||||
// We dont need auto generation for reversal external id... if it is not provided, it remains null (empty)
|
||||
final String reversalExternalId = command.stringValueOfParameterNamedAllowingNull(LoanApiConstants.REVERSAL_EXTERNAL_ID_PARAMNAME);
|
||||
final ExternalId reversalTxnExternalId = ExternalIdFactory.produce(reversalExternalId);
|
||||
|
||||
Reference in New Issue
Block a user