budaidev commented on code in PR #5117: URL: https://github.com/apache/fineract/pull/5117#discussion_r2450815174
########## fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/reaging/LoanReAmortizationInterestHandlingType.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.portfolio.loanaccount.domain.reaging; Review Comment: Any reason for LoanReAmortizationInterestHandlingType to be in the reaging package instead of the reamortization package? ########## fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/reamortization/LoanReAgingParameterRepository.java: ########## @@ -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.domain.reamortization; + +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; + +public interface LoanReAgingParameterRepository extends JpaRepository<LoanReAmortizationParameter, Long> { Review Comment: Doing only LoanReAmortizationParameter related operation in the LoanReAgingParameterRepository seems confusing ########## fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reamortization/LoanReAmortizationServiceImpl.java: ########## @@ -159,4 +168,20 @@ private LoanTransaction createReAmortizeTransaction(Loan loan, JsonCommand comma return new LoanTransaction(loan, loan.getOffice(), LoanTransactionType.REAMORTIZE, transactionDate, txPrincipalAmount, txPrincipalAmount, ZERO, ZERO, ZERO, null, false, null, txExternalId); } + + private LoanReAmortizationParameter createReAmortizationParameter(LoanTransaction reAmortizationTransaction, JsonCommand command) { + LoanReAmortizationInterestHandlingType reAmortizationInterestHandlingType = command.enumValueOfParameterNamed( + LoanReAmortizationApiConstants.reAmortizationInterestHandlingParamName, LoanReAmortizationInterestHandlingType.class); + if (reAmortizationInterestHandlingType == null) { + reAmortizationInterestHandlingType = LoanReAmortizationInterestHandlingType.DEFAULT; + } + + CodeValue reasonCodeValue = null; + if (command.parameterExists(LoanReAgingApiConstants.reasonCodeValueIdParamName)) { Review Comment: Isn't it LoanReAmortizationApiConstants instead of LoanReAgingApiConstants? ########## fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reamortization/LoanReAmortizationServiceImpl.java: ########## @@ -159,4 +168,20 @@ private LoanTransaction createReAmortizeTransaction(Loan loan, JsonCommand comma return new LoanTransaction(loan, loan.getOffice(), LoanTransactionType.REAMORTIZE, transactionDate, txPrincipalAmount, txPrincipalAmount, ZERO, ZERO, ZERO, null, false, null, txExternalId); } + + private LoanReAmortizationParameter createReAmortizationParameter(LoanTransaction reAmortizationTransaction, JsonCommand command) { + LoanReAmortizationInterestHandlingType reAmortizationInterestHandlingType = command.enumValueOfParameterNamed( + LoanReAmortizationApiConstants.reAmortizationInterestHandlingParamName, LoanReAmortizationInterestHandlingType.class); + if (reAmortizationInterestHandlingType == null) { + reAmortizationInterestHandlingType = LoanReAmortizationInterestHandlingType.DEFAULT; + } + + CodeValue reasonCodeValue = null; + if (command.parameterExists(LoanReAgingApiConstants.reasonCodeValueIdParamName)) { + reasonCodeValue = codeValueRepository.findByCodeNameAndId(LoanApiConstants.REAGE_REASONS, Review Comment: I might be wrong, but isn't it LoanApiConstants.REAMORTIZATION_REASONS? ########## fineract-provider/src/test/java/org/apache/fineract/portfolio/loanaccount/service/reamortization/LoanReAmortizationValidatorTest.java: ########## @@ -53,13 +53,21 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; @SuppressFBWarnings({ "VA_FORMAT_STRING_USES_NEWLINE" }) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) class LoanReAmortizationValidatorTest { private final LocalDate actualDate = LocalDate.now(Clock.systemUTC()); - private LoanReAmortizationValidator underTest = new LoanReAmortizationValidator(); + @InjectMocks + private LoanReAmortizationValidator underTest; Review Comment: You changed here to InjectMocks instead of the creation, how we handle the CodeValueRepository which is injected inside the LoanReAmortizationValidator? Do we validate if it is correct? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
