galovics commented on code in PR #3318: URL: https://github.com/apache/fineract/pull/3318#discussion_r1271816349
########## fineract-investor/src/main/java/org/apache/fineract/investor/service/LoanAccountOwnerTransferServiceImpl.java: ########## @@ -0,0 +1,206 @@ +/** + * 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.investor.service; + +import static org.apache.fineract.infrastructure.core.service.DateUtils.getBusinessLocalDate; +import static org.apache.fineract.investor.data.ExternalTransferStatus.BUYBACK; +import static org.apache.fineract.investor.data.ExternalTransferStatus.CANCELLED; +import static org.apache.fineract.investor.data.ExternalTransferStatus.DECLINED; +import static org.apache.fineract.investor.data.ExternalTransferStatus.PENDING; +import static org.apache.fineract.investor.data.ExternalTransferSubStatus.BALANCE_NEGATIVE; +import static org.apache.fineract.investor.data.ExternalTransferSubStatus.BALANCE_ZERO; +import static org.apache.fineract.investor.data.ExternalTransferSubStatus.SAMEDAY_TRANSFERS; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.List; +import java.util.Objects; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.infrastructure.event.business.domain.loan.LoanAccountSnapshotBusinessEvent; +import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService; +import org.apache.fineract.interoperation.util.MathUtil; +import org.apache.fineract.investor.data.ExternalTransferStatus; +import org.apache.fineract.investor.data.ExternalTransferSubStatus; +import org.apache.fineract.investor.domain.ExternalAssetOwnerTransfer; +import org.apache.fineract.investor.domain.ExternalAssetOwnerTransferDetails; +import org.apache.fineract.investor.domain.ExternalAssetOwnerTransferLoanMappingRepository; +import org.apache.fineract.investor.domain.ExternalAssetOwnerTransferRepository; +import org.apache.fineract.investor.domain.LoanOwnershipTransferBusinessEvent; +import org.apache.fineract.portfolio.loanaccount.domain.Loan; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class LoanAccountOwnerTransferServiceImpl implements LoanAccountOwnerTransferService { + + public static final LocalDate FUTURE_DATE_9999_12_31 = LocalDate.of(9999, 12, 31); + private final ExternalAssetOwnerTransferRepository externalAssetOwnerTransferRepository; + private final ExternalAssetOwnerTransferLoanMappingRepository externalAssetOwnerTransferLoanMappingRepository; + private final AccountingService accountingService; + private final BusinessEventNotifierService businessEventNotifierService; + + @Override + public void handleLoanClosedOrOverpaid(Loan loan) { Review Comment: I really really dislike the fact that you used an entity as a parameter here. It's super hard to understand what's happening to this entity anyway, it would've been much better to use a specific DTO that contains all the data you need to do the business logic. Bonus: you don't have a transaction around this service class. ########## fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanStatusChangePlatformServiceImpl.java: ########## @@ -54,6 +62,11 @@ public void onBusinessEvent(LoanStatusChangedBusinessEvent event) { if (loan.isOpen()) { loan.handleMaturityDateActivate(); } + + if (configurationReadPlatformService.retrieveGlobalConfiguration(ASSET_EXTERNALIZATION_OF_NON_ACTIVE_LOANS).isEnabled() Review Comment: Why didn't we create a separate listener within the investor module? -- 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]
