FINERACT-1983: Date handling improvements - general

This commit is contained in:
jmarta
2023-10-25 22:41:23 +02:00
committed by Adam Saghy
parent 71afd6dead
commit e602fa6b3c
147 changed files with 797 additions and 1028 deletions
@@ -37,6 +37,7 @@ import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioPr
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMapping;
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMappingRepository;
import org.apache.fineract.accounting.producttoaccountmapping.exception.ProductToGLAccountMappingNotFoundException;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.office.domain.Office;
import org.springframework.stereotype.Service;
@@ -61,7 +62,7 @@ public class InvestorAccountingHelper {
**/
GLClosure gLClosure = getLatestClosureByBranch(officeId);
if (gLClosure != null) {
if (gLClosure.getClosingDate().isAfter(transactionDate) || gLClosure.getClosingDate().isEqual(transactionDate)) {
if (!DateUtils.isAfter(transactionDate, gLClosure.getClosingDate())) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, gLClosure.getClosingDate(), null,
null);
}
@@ -170,7 +170,7 @@ public class ExternalAssetOwnersWriteServiceImpl implements ExternalAssetOwnersW
throw new ExternalAssetOwnerInitiateTransferException(
String.format("This loan cannot be bought back, effective transfer is not in right state: %s",
effectiveTransfers.get(0).getStatus()));
} else if (settlementDate.isBefore(effectiveTransfers.get(0).getSettlementDate())) {
} else if (DateUtils.isBefore(settlementDate, effectiveTransfers.get(0).getSettlementDate())) {
throw new ExternalAssetOwnerInitiateTransferException(
String.format("This loan cannot be bought back, settlement date is earlier than effective transfer settlement date: %s",
effectiveTransfers.get(0).getSettlementDate()));
@@ -251,7 +251,7 @@ public class ExternalAssetOwnersWriteServiceImpl implements ExternalAssetOwnersW
}
private void validateSettlementDate(LocalDate settlementDate) {
if (settlementDate.isBefore(ThreadLocalContextUtil.getBusinessDate())) {
if (DateUtils.isBeforeBusinessDate(settlementDate)) {
throw new ExternalAssetOwnerInitiateTransferException("Settlement date cannot be in the past");
}
}