FINERACT-1983: Date handling improvements - general
This commit is contained in:
+6
-6
@@ -119,7 +119,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
private SchedulerJobHelper schedulerJobHelper;
|
||||
private PeriodicAccrualAccountingHelper periodicAccrualAccountingHelper;
|
||||
|
||||
private TimeZone systemTimeZone;
|
||||
private TimeZone tenantTimeZone;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
@@ -135,7 +135,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
this.schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
||||
this.periodicAccrualAccountingHelper = new PeriodicAccrualAccountingHelper(requestSpec, responseSpec);
|
||||
|
||||
this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
|
||||
this.tenantTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -805,8 +805,8 @@ public class AccountingScenarioIntegrationTest {
|
||||
|
||||
final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
|
||||
|
||||
final LocalDate localDate = LocalDate.now(this.systemTimeZone.toZoneId());
|
||||
final ZonedDateTime currentDate = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, this.systemTimeZone.toZoneId());
|
||||
final LocalDate localDate = LocalDate.now(this.tenantTimeZone.toZoneId());
|
||||
final ZonedDateTime currentDate = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, this.tenantTimeZone.toZoneId());
|
||||
ZonedDateTime zonedDate = currentDate.minusDays(4);
|
||||
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(zonedDate);
|
||||
|
||||
@@ -907,7 +907,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
|
||||
Calendar todayDate = Calendar.getInstance(this.systemTimeZone);
|
||||
Calendar todayDate = Calendar.getInstance(this.tenantTimeZone);
|
||||
|
||||
todayDate.add(Calendar.DATE, -4);
|
||||
|
||||
@@ -915,7 +915,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
|
||||
todayDate.add(Calendar.MONTH, 2);
|
||||
|
||||
todayDate = Calendar.getInstance(this.systemTimeZone);
|
||||
todayDate = Calendar.getInstance(this.tenantTimeZone);
|
||||
todayDate.add(Calendar.DATE, -2);
|
||||
|
||||
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
|
||||
|
||||
+2
-1
@@ -87,6 +87,7 @@ import org.apache.fineract.client.models.PostLoansResponse;
|
||||
import org.apache.fineract.client.models.PutChargeTransactionChangesRequest;
|
||||
import org.apache.fineract.client.util.CallFailedRuntimeException;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
||||
@@ -6308,7 +6309,7 @@ public class ClientLoanIntegrationTest {
|
||||
LocalDate expectedMaturityDate = loanDetails.getTimeline().getExpectedMaturityDate();
|
||||
LocalDate actualMaturityDate = loanDetails.getTimeline().getActualMaturityDate();
|
||||
|
||||
assertTrue(expectedMaturityDate.isEqual(actualMaturityDate));
|
||||
assertTrue(DateUtils.isEqual(expectedMaturityDate, actualMaturityDate));
|
||||
|
||||
LOAN_TRANSACTION_HELPER.makeRepayment("04 September 2022", Float.parseFloat("500"), loanID);
|
||||
LOAN_TRANSACTION_HELPER.makeRepayment("05 September 2022", Float.parseFloat("700"), loanID);
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||
@@ -670,7 +671,7 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe
|
||||
LocalDate downPaymentEntryDate = LocalDate.of(downPaymentDateAsArray.get(0), downPaymentDateAsArray.get(1),
|
||||
downPaymentDateAsArray.get(2));
|
||||
|
||||
if (transactionDate.isEqual(downPaymentEntryDate)) {
|
||||
if (DateUtils.isEqual(transactionDate, downPaymentEntryDate)) {
|
||||
isTransactionFound = true;
|
||||
assertEquals(principalPortion, Float.valueOf(String.valueOf(transactions.get(i).get("principalPortion"))),
|
||||
"Mismatch in transaction amounts");
|
||||
|
||||
+3
-2
@@ -41,6 +41,7 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||
@@ -746,7 +747,7 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest {
|
||||
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
|
||||
accrualEntryDateAsArray.get(2));
|
||||
|
||||
if (transactionDate.isEqual(accrualEntryDate)) {
|
||||
if (DateUtils.isEqual(transactionDate, accrualEntryDate)) {
|
||||
isTransactionFound = true;
|
||||
verifyAmounts(0.0f, 0.0f, 10.0f, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
|
||||
Float.valueOf(String.valueOf(transactions.get(i).get("feeChargesPortion"))),
|
||||
@@ -875,7 +876,7 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest {
|
||||
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
|
||||
accrualEntryDateAsArray.get(2));
|
||||
|
||||
if (transactionDate.isEqual(accrualEntryDate)) {
|
||||
if (DateUtils.isEqual(transactionDate, accrualEntryDate)) {
|
||||
isTransactionFound = true;
|
||||
assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
|
||||
"Mismatch in transaction amounts");
|
||||
|
||||
+2
-1
@@ -38,6 +38,7 @@ import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||
@@ -267,7 +268,7 @@ public class LoanAccrualTransactionReversalTest {
|
||||
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
|
||||
accrualEntryDateAsArray.get(2));
|
||||
|
||||
if (transactionDate.isEqual(accrualEntryDate)) {
|
||||
if (DateUtils.isEqual(transactionDate, accrualEntryDate)) {
|
||||
isTransactionFound = true;
|
||||
assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
|
||||
"Mismatch in transaction amounts");
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
|
||||
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||
@@ -188,7 +189,7 @@ public class LoanMultipleDisbursementRepaymentScheduleTest {
|
||||
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
|
||||
accrualEntryDateAsArray.get(2));
|
||||
|
||||
if (transactionDate.isEqual(accrualEntryDate)) {
|
||||
if (DateUtils.isEqual(transactionDate, accrualEntryDate)) {
|
||||
isTransactionFound = true;
|
||||
assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
|
||||
"Mismatch in transaction amounts");
|
||||
|
||||
+2
-1
@@ -41,6 +41,7 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
|
||||
import org.apache.fineract.client.models.PutLoanProductsProductIdRequest;
|
||||
import org.apache.fineract.client.models.PutLoanProductsProductIdResponse;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.CommonConstants;
|
||||
@@ -605,7 +606,7 @@ public class LoanProductWithDownPaymentConfigurationTest {
|
||||
LocalDate downPaymentEntryDate = LocalDate.of(downPaymentDateAsArray.get(0), downPaymentDateAsArray.get(1),
|
||||
downPaymentDateAsArray.get(2));
|
||||
|
||||
if (transactionDate.isEqual(downPaymentEntryDate)) {
|
||||
if (DateUtils.isEqual(transactionDate, downPaymentEntryDate)) {
|
||||
isTransactionFound = true;
|
||||
assertEquals(principalPortion, Float.valueOf(String.valueOf(transactions.get(i).get("principalPortion"))),
|
||||
"Mismatch in transaction amounts");
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
import org.apache.fineract.client.models.GetOfficesResponse;
|
||||
import org.apache.fineract.client.models.PutOfficesOfficeIdResponse;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.common.OfficeDomain;
|
||||
import org.apache.fineract.integrationtests.common.OfficeHelper;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
@@ -97,6 +98,6 @@ public class OfficeIntegrationTest {
|
||||
GetOfficesResponse newOffice = officeResult.body();
|
||||
|
||||
Assertions.assertTrue(name.equals(newOffice.getName()));
|
||||
Assertions.assertTrue(newOffice.getOpeningDate().isEqual(LocalDate.of(2007, 7, 2)));
|
||||
Assertions.assertTrue(DateUtils.isEqual(newOffice.getOpeningDate(), LocalDate.of(2007, 7, 2)));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -41,6 +41,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.fineract.client.models.PutJobsJobIDRequest;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.client.IntegrationTest;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.slf4j.Logger;
|
||||
@@ -185,8 +186,7 @@ public class SchedulerJobHelper extends IntegrationTest {
|
||||
}
|
||||
Instant jobRunStartTime = df.parse(jobRunStartText, Instant::from);
|
||||
Instant jobRunEndTime = df.parse(jobRunEndText, Instant::from);
|
||||
return (jobRunStartTime.equals(beforeExecuteTime) || jobRunStartTime.isAfter(beforeExecuteTime))
|
||||
&& (jobRunEndTime.equals(jobRunStartTime) || jobRunEndTime.isAfter(jobRunStartTime));
|
||||
return !jobRunStartTime.isBefore(beforeExecuteTime) && !jobRunEndTime.isBefore(jobRunStartTime);
|
||||
});
|
||||
|
||||
// Verify triggerType
|
||||
@@ -206,7 +206,7 @@ public class SchedulerJobHelper extends IntegrationTest {
|
||||
|
||||
public void fastForwardTime(LocalDate lastBusinessDateBeforeFastForward, LocalDate dateToFastForward, String jobName,
|
||||
ResponseSpecification responseSpec) {
|
||||
while (lastBusinessDateBeforeFastForward.isBefore(dateToFastForward)) {
|
||||
while (DateUtils.isBefore(lastBusinessDateBeforeFastForward, dateToFastForward)) {
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.COB_DATE, lastBusinessDateBeforeFastForward);
|
||||
executeAndAwaitJob(jobName);
|
||||
lastBusinessDateBeforeFastForward = lastBusinessDateBeforeFastForward.plusDays(1);
|
||||
|
||||
+2
-1
@@ -83,6 +83,7 @@ import org.apache.fineract.client.models.PutLoansLoanIdChargesChargeIdResponse;
|
||||
import org.apache.fineract.client.models.PutLoansLoanIdRequest;
|
||||
import org.apache.fineract.client.models.PutLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.util.JSON;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.integrationtests.client.IntegrationTest;
|
||||
import org.apache.fineract.integrationtests.common.CommonConstants;
|
||||
import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
|
||||
@@ -1437,7 +1438,7 @@ public class LoanTransactionHelper extends IntegrationTest {
|
||||
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
|
||||
accrualEntryDateAsArray.get(2));
|
||||
|
||||
if (transactionDate.isEqual(accrualEntryDate)) {
|
||||
if (DateUtils.isEqual(transactionDate, accrualEntryDate)) {
|
||||
isTransactionFound = true;
|
||||
assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
|
||||
"Mismatch in transaction amounts");
|
||||
|
||||
+2
-4
@@ -48,7 +48,6 @@ import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -122,8 +121,7 @@ public class DatatableAdvancedQueryTest {
|
||||
@Test
|
||||
public void testDatatableAdvancedQuery() {
|
||||
String datatable = createAndVerifyDatatable(SAVINGS_TRANSACTION_APP_TABLE_NAME, null, false);
|
||||
|
||||
LocalDate today = LocalDate.now(ZoneId.systemDefault());
|
||||
LocalDate today = Utils.getLocalDateOfTenant();
|
||||
String todayS = DateUtils.format(today, SAVINGS_DATE_FORMAT);
|
||||
LocalDate yesterday = today.minus(1, ChronoUnit.DAYS);
|
||||
String yesterdayS = DateUtils.format(yesterday, SAVINGS_DATE_FORMAT);
|
||||
@@ -207,7 +205,7 @@ public class DatatableAdvancedQueryTest {
|
||||
public void testApptableWithDatatableAdvancedQuery() {
|
||||
String datatable = createAndVerifyDatatable(SAVINGS_TRANSACTION_APP_TABLE_NAME, null, false);
|
||||
|
||||
LocalDate today = LocalDate.now(ZoneId.systemDefault());
|
||||
LocalDate today = Utils.getLocalDateOfTenant();
|
||||
String todayS = DateUtils.format(today, SAVINGS_DATE_FORMAT);
|
||||
LocalDate yesterday = today.minus(1, ChronoUnit.DAYS);
|
||||
String yesterdayS = DateUtils.format(yesterday, SAVINGS_DATE_FORMAT);
|
||||
|
||||
Reference in New Issue
Block a user