Unstable integration test due different timezones
This commit is contained in:
committed by
Arnold Gálovics
parent
7e680729fc
commit
55949bf8b0
+6
@@ -88,8 +88,14 @@ public class ClientEntityImportHandler implements ImportHandler {
|
|||||||
String name = ImportHandlerUtils.readAsString(ClientEntityConstants.NAME_COL, row);
|
String name = ImportHandlerUtils.readAsString(ClientEntityConstants.NAME_COL, row);
|
||||||
String officeName = ImportHandlerUtils.readAsString(ClientEntityConstants.OFFICE_NAME_COL, row);
|
String officeName = ImportHandlerUtils.readAsString(ClientEntityConstants.OFFICE_NAME_COL, row);
|
||||||
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
|
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
|
||||||
|
if (officeId == 0L) {
|
||||||
|
officeId = null;
|
||||||
|
}
|
||||||
String staffName = ImportHandlerUtils.readAsString(ClientEntityConstants.STAFF_NAME_COL, row);
|
String staffName = ImportHandlerUtils.readAsString(ClientEntityConstants.STAFF_NAME_COL, row);
|
||||||
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
|
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
|
||||||
|
if (staffId == 0L) {
|
||||||
|
staffId = null;
|
||||||
|
}
|
||||||
LocalDate incorportionDate = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_DATE_COL, row);
|
LocalDate incorportionDate = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_DATE_COL, row);
|
||||||
LocalDate incorporationTill = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_VALID_TILL_COL, row);
|
LocalDate incorporationTill = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_VALID_TILL_COL, row);
|
||||||
String mobileNo = null;
|
String mobileNo = null;
|
||||||
|
|||||||
+6
@@ -88,8 +88,14 @@ public class ClientPersonImportHandler implements ImportHandler {
|
|||||||
String middleName = ImportHandlerUtils.readAsString(ClientPersonConstants.MIDDLE_NAME_COL, row);
|
String middleName = ImportHandlerUtils.readAsString(ClientPersonConstants.MIDDLE_NAME_COL, row);
|
||||||
String officeName = ImportHandlerUtils.readAsString(ClientPersonConstants.OFFICE_NAME_COL, row);
|
String officeName = ImportHandlerUtils.readAsString(ClientPersonConstants.OFFICE_NAME_COL, row);
|
||||||
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
|
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
|
||||||
|
if (officeId == 0L) {
|
||||||
|
officeId = null;
|
||||||
|
}
|
||||||
String staffName = ImportHandlerUtils.readAsString(ClientPersonConstants.STAFF_NAME_COL, row);
|
String staffName = ImportHandlerUtils.readAsString(ClientPersonConstants.STAFF_NAME_COL, row);
|
||||||
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
|
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
|
||||||
|
if (staffId == 0L) {
|
||||||
|
staffId = null;
|
||||||
|
}
|
||||||
String externalId = ImportHandlerUtils.readAsString(ClientPersonConstants.EXTERNAL_ID_COL, row);
|
String externalId = ImportHandlerUtils.readAsString(ClientPersonConstants.EXTERNAL_ID_COL, row);
|
||||||
LocalDate submittedOn = ImportHandlerUtils.readAsDate(ClientPersonConstants.SUBMITTED_ON_COL, row);
|
LocalDate submittedOn = ImportHandlerUtils.readAsDate(ClientPersonConstants.SUBMITTED_ON_COL, row);
|
||||||
LocalDate activationDate = ImportHandlerUtils.readAsDate(ClientPersonConstants.ACTIVATION_DATE_COL, row);
|
LocalDate activationDate = ImportHandlerUtils.readAsDate(ClientPersonConstants.ACTIVATION_DATE_COL, row);
|
||||||
|
|||||||
+29
-3
@@ -19,6 +19,7 @@
|
|||||||
package org.apache.fineract.infrastructure.core.service;
|
package org.apache.fineract.infrastructure.core.service;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -74,6 +75,10 @@ public final class DateUtils {
|
|||||||
return createDate(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
|
return createDate(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDate convertToLocalDate(final Date dateToConvert, final ZoneId zoneId) {
|
||||||
|
return dateToConvert.toInstant().atZone(zoneId).toLocalDate();
|
||||||
|
}
|
||||||
|
|
||||||
public static Date createDate(int year, int month, int day) {
|
public static Date createDate(int year, int month, int day) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.YEAR, year);
|
cal.set(Calendar.YEAR, year);
|
||||||
@@ -97,10 +102,27 @@ public final class DateUtils {
|
|||||||
return today;
|
return today;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LocalDate parseLocalDate(final String stringDate, final String pattern) {
|
public static Date parseDate(final String stringDate, final String pattern, final ZoneId zoneId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final DateTimeFormatter dateStringFormat = DateTimeFormatter.ofPattern(pattern).withZone(getDateTimeZoneOfTenant());
|
return new SimpleDateFormat(pattern).parse(stringDate);
|
||||||
|
} catch (final ParseException e) {
|
||||||
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
|
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.pattern",
|
||||||
|
"The parameter date (" + stringDate + ") is invalid w.r.t. pattern " + pattern, "date", stringDate, pattern);
|
||||||
|
dataValidationErrors.add(error);
|
||||||
|
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
|
||||||
|
dataValidationErrors, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocalDate parseLocalDate(final String stringDate, final String pattern, final ZoneId zoneId) {
|
||||||
|
try {
|
||||||
|
DateTimeFormatter dateStringFormat;
|
||||||
|
if (zoneId != null) {
|
||||||
|
dateStringFormat = DateTimeFormatter.ofPattern(pattern).withZone(zoneId);
|
||||||
|
} else {
|
||||||
|
dateStringFormat = DateTimeFormatter.ofPattern(pattern);
|
||||||
|
}
|
||||||
final ZonedDateTime dateTime = ZonedDateTime.parse(stringDate, dateStringFormat);
|
final ZonedDateTime dateTime = ZonedDateTime.parse(stringDate, dateStringFormat);
|
||||||
return dateTime.toLocalDate();
|
return dateTime.toLocalDate();
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
@@ -113,6 +135,10 @@ public final class DateUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDate parseLocalDate(final String stringDate, final String pattern) {
|
||||||
|
return parseLocalDate(stringDate, pattern, getDateTimeZoneOfTenant());
|
||||||
|
}
|
||||||
|
|
||||||
public static String formatToSqlDate(final Date date) {
|
public static String formatToSqlDate(final Date date) {
|
||||||
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
df.setTimeZone(getTimeZoneOfTenant());
|
df.setTimeZone(getTimeZoneOfTenant());
|
||||||
|
|||||||
+1
-1
@@ -199,11 +199,11 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
|
|||||||
Collection<StandingInstructionData> instructionDatas = this.standingInstructionReadPlatformService
|
Collection<StandingInstructionData> instructionDatas = this.standingInstructionReadPlatformService
|
||||||
.retrieveAll(StandingInstructionStatus.ACTIVE.getValue());
|
.retrieveAll(StandingInstructionStatus.ACTIVE.getValue());
|
||||||
List<Throwable> errors = new ArrayList<>();
|
List<Throwable> errors = new ArrayList<>();
|
||||||
|
LocalDate transactionDate = DateUtils.getLocalDateOfTenant();
|
||||||
for (StandingInstructionData data : instructionDatas) {
|
for (StandingInstructionData data : instructionDatas) {
|
||||||
boolean isDueForTransfer = false;
|
boolean isDueForTransfer = false;
|
||||||
AccountTransferRecurrenceType recurrenceType = data.recurrenceType();
|
AccountTransferRecurrenceType recurrenceType = data.recurrenceType();
|
||||||
StandingInstructionType instructionType = data.instructionType();
|
StandingInstructionType instructionType = data.instructionType();
|
||||||
LocalDate transactionDate = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
|
|
||||||
if (recurrenceType.isPeriodicRecurrence()) {
|
if (recurrenceType.isPeriodicRecurrence()) {
|
||||||
final ScheduledDateGenerator scheduledDateGenerator = new DefaultScheduledDateGenerator();
|
final ScheduledDateGenerator scheduledDateGenerator = new DefaultScheduledDateGenerator();
|
||||||
PeriodFrequencyType frequencyType = data.recurrenceFrequency();
|
PeriodFrequencyType frequencyType = data.recurrenceFrequency();
|
||||||
|
|||||||
+24
-31
@@ -33,12 +33,17 @@ import java.text.DecimalFormatSymbols;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||||
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
||||||
@@ -66,13 +71,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
|
|||||||
import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
|
import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
@Order(2)
|
|
||||||
public class AccountingScenarioIntegrationTest {
|
public class AccountingScenarioIntegrationTest {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class);
|
||||||
@@ -110,13 +113,13 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
private AccountHelper accountHelper;
|
private AccountHelper accountHelper;
|
||||||
private JournalEntryHelper journalEntryHelper;
|
private JournalEntryHelper journalEntryHelper;
|
||||||
private SavingsAccountHelper savingsAccountHelper;
|
private SavingsAccountHelper savingsAccountHelper;
|
||||||
private FixedDepositProductHelper fixedDepositProductHelper;
|
|
||||||
private FixedDepositAccountHelper fixedDepositAccountHelper;
|
private FixedDepositAccountHelper fixedDepositAccountHelper;
|
||||||
private RecurringDepositProductHelper recurringDepositProductHelper;
|
|
||||||
private RecurringDepositAccountHelper recurringDepositAccountHelper;
|
private RecurringDepositAccountHelper recurringDepositAccountHelper;
|
||||||
private SchedulerJobHelper schedulerJobHelper;
|
private SchedulerJobHelper schedulerJobHelper;
|
||||||
private PeriodicAccrualAccountingHelper periodicAccrualAccountingHelper;
|
private PeriodicAccrualAccountingHelper periodicAccrualAccountingHelper;
|
||||||
|
|
||||||
|
private TimeZone systemTimeZone;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
@@ -129,6 +132,8 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
this.journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
|
this.journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
|
||||||
this.schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
this.schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
||||||
this.periodicAccrualAccountingHelper = new PeriodicAccrualAccountingHelper(requestSpec, responseSpec);
|
this.periodicAccrualAccountingHelper = new PeriodicAccrualAccountingHelper(requestSpec, responseSpec);
|
||||||
|
|
||||||
|
this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -361,7 +366,6 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFixedDepositAccountingFlow() {
|
public void testFixedDepositAccountingFlow() {
|
||||||
this.fixedDepositProductHelper = new FixedDepositProductHelper(requestSpec, responseSpec);
|
|
||||||
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
|
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
|
||||||
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
|
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
|
||||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(requestSpec, responseSpec);
|
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(requestSpec, responseSpec);
|
||||||
@@ -440,7 +444,6 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRecurringDepositAccountingFlow() {
|
public void testRecurringDepositAccountingFlow() {
|
||||||
this.recurringDepositProductHelper = new RecurringDepositProductHelper(requestSpec, responseSpec);
|
|
||||||
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
|
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
|
||||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(requestSpec, responseSpec);
|
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(requestSpec, responseSpec);
|
||||||
|
|
||||||
@@ -806,20 +809,14 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||||
|
|
||||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
|
||||||
|
|
||||||
Calendar todayDate = Calendar.getInstance();
|
final LocalDate localDate = LocalDate.now(this.systemTimeZone.toZoneId());
|
||||||
final String currentDate = dateFormat.format(todayDate.getTime());
|
final ZonedDateTime currentDate = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, this.systemTimeZone.toZoneId());
|
||||||
|
ZonedDateTime zonedDate = currentDate.minusDays(4);
|
||||||
|
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(zonedDate);
|
||||||
|
|
||||||
todayDate.add(Calendar.DATE, -4);
|
zonedDate = currentDate.minusDays(2);
|
||||||
|
|
||||||
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime());
|
|
||||||
|
|
||||||
todayDate.add(Calendar.MONTH, 2);
|
|
||||||
final String FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime());
|
|
||||||
|
|
||||||
todayDate = Calendar.getInstance();
|
|
||||||
todayDate.add(Calendar.DATE, -2);
|
|
||||||
|
|
||||||
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
|
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
|
||||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID,
|
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID,
|
||||||
@@ -827,10 +824,10 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||||
|
|
||||||
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
|
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
|
||||||
String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
|
String.valueOf(flatSpecifiedDueDate), dateFormat.format(zonedDate), String.valueOf(PENALTY_PORTION)));
|
||||||
todayDate.add(Calendar.DATE, 1);
|
zonedDate = zonedDate.plusDays(1);
|
||||||
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
|
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper
|
||||||
String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION)));
|
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), dateFormat.format(zonedDate), String.valueOf(FEE_PORTION)));
|
||||||
|
|
||||||
// CHECK ACCOUNT ENTRIES
|
// CHECK ACCOUNT ENTRIES
|
||||||
LOG.info("Entries ......");
|
LOG.info("Entries ......");
|
||||||
@@ -865,7 +862,7 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
float interest4Days = totalInterest / totalDaysInPeriod * 4;
|
float interest4Days = totalInterest / totalDaysInPeriod * 4;
|
||||||
interest4Days = Float.parseFloat(numberFormat.format(interest4Days));
|
interest4Days = Float.parseFloat(numberFormat.format(interest4Days));
|
||||||
|
|
||||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(currentDate), interest4Days, FEE_PORTION,
|
this.loanTransactionHelper.checkAccrualTransactionForRepayment(currentDate.toLocalDate(), interest4Days, FEE_PORTION,
|
||||||
PENALTY_PORTION, loanID);
|
PENALTY_PORTION, loanID);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -916,17 +913,15 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
|
|
||||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||||
|
|
||||||
Calendar todayDate = Calendar.getInstance();
|
Calendar todayDate = Calendar.getInstance(this.systemTimeZone);
|
||||||
final String currentDate = dateFormat.format(todayDate.getTime());
|
|
||||||
|
|
||||||
todayDate.add(Calendar.DATE, -4);
|
todayDate.add(Calendar.DATE, -4);
|
||||||
|
|
||||||
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime());
|
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime());
|
||||||
|
|
||||||
todayDate.add(Calendar.MONTH, 2);
|
todayDate.add(Calendar.MONTH, 2);
|
||||||
final String FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime());
|
|
||||||
|
|
||||||
todayDate = Calendar.getInstance();
|
todayDate = Calendar.getInstance(this.systemTimeZone);
|
||||||
todayDate.add(Calendar.DATE, -2);
|
todayDate.add(Calendar.DATE, -2);
|
||||||
|
|
||||||
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
|
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
|
||||||
@@ -1123,10 +1118,8 @@ public class AccountingScenarioIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate getDateAsLocalDate(String dateAsString) throws ParseException {
|
private LocalDate getDateAsLocalDate(String dateAsString) throws ParseException {
|
||||||
DateFormat df = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
final Date dateParsed = DateUtils.parseDate(dateAsString, "dd MMMM yyyy", null);
|
||||||
LocalDate date = LocalDate.ofInstant(df.parse(dateAsString).toInstant(), DateUtils.getDateTimeZoneOfTenant());
|
return DateUtils.convertToLocalDate(dateParsed, this.systemTimeZone.toZoneId());
|
||||||
|
|
||||||
return date;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-11
@@ -32,14 +32,20 @@ import java.text.DateFormat;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TimeZone;
|
||||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||||
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
||||||
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||||
@@ -94,6 +100,8 @@ public class SchedulerJobsTestResults {
|
|||||||
private JournalEntryHelper journalEntryHelper;
|
private JournalEntryHelper journalEntryHelper;
|
||||||
private StandingInstructionsHelper standingInstructionsHelper;
|
private StandingInstructionsHelper standingInstructionsHelper;
|
||||||
|
|
||||||
|
private TimeZone systemTimeZone;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
@@ -103,6 +111,8 @@ public class SchedulerJobsTestResults {
|
|||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
|
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
|
||||||
this.journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
|
this.journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
|
||||||
|
|
||||||
|
this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
@@ -459,18 +469,20 @@ public class SchedulerJobsTestResults {
|
|||||||
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
|
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
|
||||||
this.standingInstructionsHelper = new StandingInstructionsHelper(requestSpec, responseSpec);
|
this.standingInstructionsHelper = new StandingInstructionsHelper(requestSpec, responseSpec);
|
||||||
|
|
||||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
|
||||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM", Locale.US);
|
final DateTimeFormatter monthDayFormat = DateTimeFormatter.ofPattern("dd MMMM", Locale.US);
|
||||||
|
|
||||||
Calendar todaysDate = Calendar.getInstance();
|
// Create the LocalDate with the Zone used by default
|
||||||
|
final LocalDate localDate = LocalDate.now(this.systemTimeZone.toZoneId());
|
||||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
ZonedDateTime currentDate = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, this.systemTimeZone.toZoneId());
|
||||||
|
// When the Stanging Instruction will be applied
|
||||||
todaysDate.add(Calendar.WEEK_OF_YEAR, -1);
|
final String MONTH_DAY = monthDayFormat.format(currentDate.toLocalDate());
|
||||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
// Standing Instruction valid from (One week before today)
|
||||||
|
currentDate = currentDate.minus(Duration.ofDays(7));
|
||||||
todaysDate.add(Calendar.YEAR, 1);
|
final String VALID_FROM = dateFormat.format(currentDate);
|
||||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
// Standing Instruction valid to (One year after)
|
||||||
|
currentDate = currentDate.plus(1, ChronoUnit.YEARS);
|
||||||
|
final String VALID_TO = dateFormat.format(currentDate);
|
||||||
|
|
||||||
final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
||||||
Assertions.assertNotNull(clientID);
|
Assertions.assertNotNull(clientID);
|
||||||
|
|||||||
+12
-11
@@ -31,9 +31,9 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -70,7 +70,6 @@ public class LoanImportHandlerTest {
|
|||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(LoanImportHandlerTest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(LoanImportHandlerTest.class);
|
||||||
private static final String CREATE_CLIENT_URL = "/fineract-provider/api/v1/clients?" + Utils.TENANT_IDENTIFIER;
|
private static final String CREATE_CLIENT_URL = "/fineract-provider/api/v1/clients?" + Utils.TENANT_IDENTIFIER;
|
||||||
private static final String CREATE_CHARGE_URL = "/fineract-provider/api/v1/charges?" + Utils.TENANT_IDENTIFIER;
|
|
||||||
public static final String DATE_FORMAT = "dd MMMM yyyy";
|
public static final String DATE_FORMAT = "dd MMMM yyyy";
|
||||||
|
|
||||||
private ResponseSpecification responseSpec;
|
private ResponseSpecification responseSpec;
|
||||||
@@ -167,7 +166,7 @@ public class LoanImportHandlerTest {
|
|||||||
Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
|
Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
|
||||||
|
|
||||||
LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
||||||
Workbook workbook = loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy");
|
Workbook workbook = loanTransactionHelper.getLoanWorkbook(DATE_FORMAT);
|
||||||
|
|
||||||
// insert dummy data into loan Sheet
|
// insert dummy data into loan Sheet
|
||||||
Sheet loanSheet = workbook.getSheet(TemplatePopulateImportConstants.LOANS_SHEET_NAME);
|
Sheet loanSheet = workbook.getSheet(TemplatePopulateImportConstants.LOANS_SHEET_NAME);
|
||||||
@@ -179,11 +178,13 @@ public class LoanImportHandlerTest {
|
|||||||
firstLoanRow.createCell(LoanConstants.CLIENT_EXTERNAL_ID).setCellValue(externalId);
|
firstLoanRow.createCell(LoanConstants.CLIENT_EXTERNAL_ID).setCellValue(externalId);
|
||||||
firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name"));
|
firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name"));
|
||||||
firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
|
firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
|
||||||
Date date = simpleDateFormat.parse("13 May 2017");
|
final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(DATE_FORMAT, Locale.US);
|
||||||
firstLoanRow.createCell(LoanConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
|
final LocalDate localDate = LocalDate.parse("17 May 2017", dateFormat);
|
||||||
firstLoanRow.createCell(LoanConstants.APPROVED_DATE_COL).setCellValue(date);
|
|
||||||
firstLoanRow.createCell(LoanConstants.DISBURSED_DATE_COL).setCellValue(date);
|
firstLoanRow.createCell(LoanConstants.SUBMITTED_ON_DATE_COL).setCellValue(localDate);
|
||||||
|
firstLoanRow.createCell(LoanConstants.APPROVED_DATE_COL).setCellValue(localDate);
|
||||||
|
firstLoanRow.createCell(LoanConstants.DISBURSED_DATE_COL).setCellValue(localDate);
|
||||||
firstLoanRow.createCell(LoanConstants.DISBURSED_PAYMENT_TYPE_COL).setCellValue(paymentTypeName);
|
firstLoanRow.createCell(LoanConstants.DISBURSED_PAYMENT_TYPE_COL).setCellValue(paymentTypeName);
|
||||||
firstLoanRow.createCell(LoanConstants.FUND_NAME_COL).setCellValue(fundName);
|
firstLoanRow.createCell(LoanConstants.FUND_NAME_COL).setCellValue(fundName);
|
||||||
firstLoanRow.createCell(LoanConstants.PRINCIPAL_COL).setCellValue(loanProductJson.getFloat("principal"));
|
firstLoanRow.createCell(LoanConstants.PRINCIPAL_COL).setCellValue(loanProductJson.getFloat("principal"));
|
||||||
@@ -208,9 +209,9 @@ public class LoanImportHandlerTest {
|
|||||||
firstLoanRow.createCell(LoanConstants.GRACE_ON_PRINCIPAL_PAYMENT_COL).setCellValue(0);
|
firstLoanRow.createCell(LoanConstants.GRACE_ON_PRINCIPAL_PAYMENT_COL).setCellValue(0);
|
||||||
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0);
|
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0);
|
||||||
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_CHARGED_COL).setCellValue(0);
|
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_CHARGED_COL).setCellValue(0);
|
||||||
firstLoanRow.createCell(LoanConstants.FIRST_REPAYMENT_COL).setCellValue(date);
|
firstLoanRow.createCell(LoanConstants.FIRST_REPAYMENT_COL).setCellValue(localDate);
|
||||||
firstLoanRow.createCell(LoanConstants.TOTAL_AMOUNT_REPAID_COL).setCellValue(6000);
|
firstLoanRow.createCell(LoanConstants.TOTAL_AMOUNT_REPAID_COL).setCellValue(6000);
|
||||||
firstLoanRow.createCell(LoanConstants.LAST_REPAYMENT_DATE_COL).setCellValue(date);
|
firstLoanRow.createCell(LoanConstants.LAST_REPAYMENT_DATE_COL).setCellValue(localDate);
|
||||||
firstLoanRow.createCell(LoanConstants.REPAYMENT_TYPE_COL).setCellValue(paymentTypeName);
|
firstLoanRow.createCell(LoanConstants.REPAYMENT_TYPE_COL).setCellValue(paymentTypeName);
|
||||||
firstLoanRow.createCell(LoanConstants.LOAN_COLLATERAL_ID).setCellValue(collaterals.get(0).get("clientCollateralId").toString());
|
firstLoanRow.createCell(LoanConstants.LOAN_COLLATERAL_ID).setCellValue(collaterals.get(0).get("clientCollateralId").toString());
|
||||||
firstLoanRow.createCell(LoanConstants.LOAN_COLLATERAL_QUANTITY).setCellValue(collaterals.get(0).get("quantity").toString());
|
firstLoanRow.createCell(LoanConstants.LOAN_COLLATERAL_QUANTITY).setCellValue(collaterals.get(0).get("quantity").toString());
|
||||||
|
|||||||
+1
-1
@@ -788,7 +788,7 @@ public class LoanTransactionHelper {
|
|||||||
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
|
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
|
||||||
accrualEntryDateAsArray.get(2));
|
accrualEntryDateAsArray.get(2));
|
||||||
|
|
||||||
if (transactionDate.equals(accrualEntryDate)) {
|
if (transactionDate.isEqual(accrualEntryDate)) {
|
||||||
isTransactionFound = true;
|
isTransactionFound = true;
|
||||||
assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
|
assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
|
||||||
"Mismatch in transaction amounts");
|
"Mismatch in transaction amounts");
|
||||||
|
|||||||
Reference in New Issue
Block a user