minor change on client
Fineract Build & Cucumber tests (without E2E tests) / verify (progressive-loan, build-progressive-loan) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MariaDB / test (test-core-2) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MariaDB / test (test-core-3) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MariaDB / test (test-core-4) (push) Canceled after 0s
Fineract Docker Builds / build (false, docker-compose-postgresql.yml, postgresql) (push) Canceled after 0s
Fineract Build & Cucumber tests (without E2E tests) / verify (main, build-core) (push) Canceled after 0s
Fineract Build & Cucumber tests (without E2E tests) / verify (main, cucumber) (push) Canceled after 0s
Fineract Docker Builds / build (true, docker-compose.yml, mariadb) (push) Canceled after 0s
Fineract Documentation build / build (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 1 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 10 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 2 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 3 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 4 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 5 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 6 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 7 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 8 of 10) (push) Canceled after 0s
Fineract E2E Tests / E2E Tests (Shard 9 of 10) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MariaDB / test (test-core-1) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MariaDB / test (test-core-5) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MySQL / test (test-core-1) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MySQL / test (test-core-2) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MySQL / test (test-core-3) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MySQL / test (test-core-4) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - MySQL / test (test-core-5) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - PostgreSQL / test (test-core-1) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - PostgreSQL / test (test-core-2) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - PostgreSQL / test (test-core-3) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - PostgreSQL / test (test-core-4) (push) Canceled after 0s
Fineract Cargo & Unit- & Integration tests - PostgreSQL / test (test-core-5) (push) Canceled after 0s
Fineract Liquibase Only mode - PostgreSQL / test (push) Canceled after 0s
Fineract Messaging Smoke Tests / Smoke Test with ActiveMQ (push) Canceled after 0s
Fineract Messaging Smoke Tests / Smoke Test with Kafka (push) Canceled after 0s

This commit is contained in:
2026-07-28 10:43:06 +05:30
parent bc30241950
commit 026d902199
164 changed files with 813 additions and 607 deletions
@@ -75,7 +75,7 @@ import org.springframework.stereotype.Component;
@Path("/v1/journalentries")
@Component
@Tag(name = "Journal Entries", description = """
A journal entry refers to the logging of transactions against general ledger accounts. A journal entry may consist of several line items, each of which is either a "debit" or a "credit". The total amount of the debits must equal the total amount of the credits or the journal entry is said to be "unbalanced"\s
A journal entry refers to the logging of transactions against general ledger accounts. A journal entry may consist of several line items, each of which is either a "debit" or a "credit". The total amount of the debits must equal the total amount of the credits or the journal entry is said to be "unbalanced"
A journal entry directly changes the account balances on the general ledger""")
@RequiredArgsConstructor
@@ -21,6 +21,7 @@ package org.apache.fineract.infrastructure.email.service;
import java.time.Year;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
public class EmailTemplateServiceImpl implements EmailTemplateService {
@@ -129,7 +130,7 @@ public class EmailTemplateServiceImpl implements EmailTemplateService {
+ escape(supportEmail) + "</a>"
+ " </p>"
+ " <p style=\"margin:0;font-size:12px;color:#94a3b8;\">"
+ " &copy; " + Year.now().getValue() + " " + escape(brandName) + ". All rights reserved."
+ " &copy; " + Year.now(DateUtils.getDateTimeZoneOfTenant()).getValue() + " " + escape(brandName) + ". All rights reserved."
+ " </p>"
+ " </td></tr>"
+ " </table>"
@@ -109,6 +109,7 @@ public class ImpsCryptoUtil {
}
/** Decrypt inbound payload using the CBS private key. */
@SuppressWarnings("StringSplitter")
public String decryptJson(String encryptedPayload) {
if (cbsPrivateKey == null) {
throw new IllegalStateException("CBS private key not loaded — check fineract.imps.cbs.private-key-path");
@@ -34,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* STUB implementation — returns hard-coded SUCCESS for every request and
@@ -108,7 +109,7 @@ public class ImpsCbsServiceImpl implements ImpsCbsService {
resp.setRefId(request.getRefId());
resp.setUtr(request.getUtr());
resp.setAmount(request.getAmount());
resp.setTimeStamp(OffsetDateTime.now().format(ISO_OFFSET));
resp.setTimeStamp(OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant()).format(ISO_OFFSET));
resp.setStatus("SUCCESS");
resp.setResponseCode("00");
AccountData payeeAcc = Optional.ofNullable(request.getPayee()).map(PartyData::getAccount).orElse(null);
@@ -28,7 +28,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Credentials;
import okhttp3.MediaType;
@@ -42,6 +41,7 @@ import org.apache.fineract.infrastructure.openproject.data.OpenProjectProjectDat
import org.apache.fineract.infrastructure.openproject.data.OpenProjectStatusSummaryData;
import org.apache.fineract.infrastructure.openproject.data.OpenProjectWorkPackageData;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@Slf4j
@@ -164,7 +164,7 @@ public class OpenProjectService {
}
// Set required custom field: "Last Follow-up Date" (customField8)
body.addProperty("customField8", LocalDate.now().toString());
body.addProperty("customField8", LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString());
if (typeName != null && !typeName.isBlank()) {
JsonObject links = new JsonObject();
@@ -47,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -127,7 +128,7 @@ public class RbiFeedFetchService {
NodeList items = doc.getElementsByTagName("item");
log.debug("RBI FeedFetchService - Parsed {} items from RSS for category: {}", items.getLength(), category);
List<RbiFeedItem> newItems = new ArrayList<>();
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
for (int i = 0; i < items.getLength(); i++) {
Element item = (Element) items.item(i);
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.infrastructure.security.otp.api;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.swagger.v3.oas.annotations.Operation;
@@ -107,7 +109,7 @@ public class EmailLoginOtpApiResource {
}
final String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) {
return fwd.split(",")[0].trim();
return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
}
return req.getRemoteAddr();
}
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.infrastructure.security.otp.api;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.swagger.v3.oas.annotations.Operation;
@@ -107,7 +109,7 @@ public class LoginOtpApiResource {
}
final String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) {
return fwd.split(",")[0].trim();
return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
}
return req.getRemoteAddr();
}
@@ -45,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
public class EmailLoginOtpServiceImpl implements EmailLoginOtpService {
@@ -128,7 +129,7 @@ public class EmailLoginOtpServiceImpl implements EmailLoginOtpService {
// Render the branded template — same look and feel for OTP, welcome, password-reset, alerts.
final String html = emailTemplateService.renderOtp(recipientName, otp, validityMinutes);
final String subject = "Your OTP for Login - " + appName + " (" + LocalDateTime.now().format(SUBJECT_TIMESTAMP) + ")";
final String subject = "Your OTP for Login - " + appName + " (" + LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).format(SUBJECT_TIMESTAMP) + ")";
final boolean sent = emailSenderService.sendHtml(email, subject, html);
if (sent) {
@@ -20,7 +20,6 @@ package org.apache.fineract.organisation.teller.service;
import jakarta.persistence.PersistenceException;
import java.util.Map;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -44,7 +43,6 @@ import org.apache.fineract.organisation.teller.domain.CashierTransactionReposito
import org.apache.fineract.organisation.teller.domain.CashierTxnType;
import org.apache.fineract.organisation.teller.domain.Teller;
import org.apache.fineract.organisation.teller.domain.TellerRepositoryWrapper;
import org.apache.fineract.organisation.teller.exception.CashierExistForTellerException;
import org.apache.fineract.organisation.teller.exception.CashierNotFoundException;
import org.apache.fineract.organisation.teller.exception.TellerAlreadyExistsException;
import org.apache.fineract.organisation.teller.serialization.TellerCommandFromApiJsonDeserializer;
@@ -33,6 +33,7 @@ import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/cashexchange")
@Component
@@ -94,7 +95,7 @@ public class CashExchangeApiResource {
header.setNote(note);
header.setCustomerIdProof(customerIdProof);
header.setIsReversed(false);
header.setCreatedAt(LocalDateTime.now());
header.setCreatedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
try {
AppUser user = this.context.authenticatedUser();
if (user != null) {
@@ -107,7 +108,9 @@ public class CashExchangeApiResource {
+ "JOIN m_appuser au ON au.staff_id = ms.id WHERE au.id = ?",
Long.class, user.getId());
header.setCashierId(cashierId);
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
}
} catch (Exception e) {
// resolving the current user must never block recording the exchange
@@ -160,14 +163,18 @@ public class CashExchangeApiResource {
try {
JsonObject json = JsonParser.parseString(body).getAsJsonObject();
reason = json.has("reason") && !json.get("reason").isJsonNull() ? json.get("reason").getAsString() : null;
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
exchange.setIsReversed(true);
exchange.setReversedAt(LocalDateTime.now());
exchange.setReversedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
exchange.setReverseReason(reason);
try {
AppUser user = this.context.authenticatedUser();
if (user != null) exchange.setReversedBy(user.getId());
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
repository.save(exchange);
JsonObject result = new JsonObject();
result.addProperty("resourceId", id);
@@ -59,6 +59,9 @@ import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import com.google.common.collect.Iterables;
import com.google.common.base.Splitter;
@Path("/v1/cashier/deposit-requests")
@Component
@@ -364,7 +367,7 @@ public class CashierDepositRequestApiResource {
final BigDecimal amount = new BigDecimal(record.get("amount").toString());
final Object ptId = record.get("payment_type_id");
final Object txnDateObj = record.get("txn_date");
final String txnDateStr = txnDateObj != null ? txnDateObj.toString().split(" ")[0] : null;
final String txnDateStr = txnDateObj != null ? Iterables.get(Splitter.on(' ').split(txnDateObj.toString()), 0) : null;
final String description = (String) record.get("description");
final String storedAccountType = (String) record.get("account_type");
@@ -513,7 +516,7 @@ public class CashierDepositRequestApiResource {
final BigDecimal amount = new BigDecimal(record.get("amount").toString());
final Object ptId = record.get("payment_type_id");
final Object txnDateObj = record.get("txn_date");
final String txnDateStr = txnDateObj != null ? txnDateObj.toString().split(" ")[0] : null;
final String txnDateStr = txnDateObj != null ? Iterables.get(Splitter.on(' ').split(txnDateObj.toString()), 0) : null;
final String description = (String) record.get("description");
if (savingsAccountId == null || !isCurrentAccountById(savingsAccountId)) {
@@ -559,7 +562,7 @@ public class CashierDepositRequestApiResource {
final Long savingsAccountId, final BigDecimal amount,
final Object paymentTypeId, final String txnDateStr, final String note) {
final String today = LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String date = txnDateStr != null && !txnDateStr.isBlank() ? formatForFineract(txnDateStr) : today;
final JsonObject payload = new JsonObject();
@@ -587,7 +590,7 @@ public class CashierDepositRequestApiResource {
final Long currentAccountId, final BigDecimal amount,
final Object paymentTypeId, final String txnDateStr, final String note) {
final String today = LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String date = txnDateStr != null && !txnDateStr.isBlank() ? formatForFineract(txnDateStr) : today;
final JsonObject payload = new JsonObject();
@@ -644,7 +647,7 @@ public class CashierDepositRequestApiResource {
final Object paymentTypeId, final String txnDateStr, final String note,
final boolean isDeposit) {
final String today = LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String date = txnDateStr != null && !txnDateStr.isBlank() ? formatForFineract(txnDateStr) : today;
// Deposit (CR): cashier receives cash → credit selected GL, debit cash vault (contra)
@@ -686,67 +689,6 @@ public class CashierDepositRequestApiResource {
return result.getTransactionId() != null ? result.getTransactionId() : null;
}
private void saveGlDenomination(final String denominationData,
final Map<?, ?> record, final String txnIdRaw) {
final JsonObject denomMap;
try {
denomMap = gson.fromJson(denominationData, JsonObject.class);
} catch (Exception e) {
return;
}
if (denomMap == null || denomMap.size() == 0) return;
// Convert hex transaction ID to Long (same logic as CashierGlDenominationApiResource)
Long txnId = null;
if (txnIdRaw != null && !txnIdRaw.isBlank()) {
try {
txnId = Long.valueOf(txnIdRaw);
} catch (NumberFormatException ignored) {
try {
final String hex = txnIdRaw.length() > 15 ? txnIdRaw.substring(txnIdRaw.length() - 15) : txnIdRaw;
txnId = Long.parseUnsignedLong(hex, 16);
} catch (NumberFormatException ignored2) {
txnId = null;
}
}
}
final String accountNo = (String) record.get("account_no");
final Object cashierIdObj = record.get("cashier_id");
final Long cashierId = cashierIdObj != null ? Long.valueOf(cashierIdObj.toString()) : null;
final String cashierUsername = (String) record.get("cashier_username");
for (final Map.Entry<String, com.google.gson.JsonElement> entry : denomMap.entrySet()) {
final int count;
try { count = entry.getValue().getAsInt(); } catch (Exception e) { continue; }
if (count <= 0) continue;
final String[] parts = entry.getKey().split(":", 2);
if (parts.length != 2) continue;
final String kind = parts[0];
final int value;
try { value = Integer.parseInt(parts[1]); } catch (Exception e) { continue; }
final List<Long> ids = jdbcTemplate.queryForList(
"SELECT id FROM m_denomination_master WHERE denomination = ? AND kind = ?"
+ " AND (deleted IS NULL OR deleted = false) LIMIT 1",
Long.class, value, kind);
if (ids.isEmpty()) continue;
final Long denomId = ids.get(0);
jdbcTemplate.update("""
INSERT INTO m_savings_txn_denomination
(txn_id, savings_account_id, account_no, client_id, denomination_id,
denomination_value, count, total_amount, txn_date, txn_type, officer_id, officer_username)
VALUES (?, NULL, ?, NULL, ?, ?, ?, ?, CURRENT_DATE, 'DEPOSIT', ?, ?)
""",
txnId, accountNo, denomId,
value, count, BigDecimal.valueOf((long) value * count),
cashierId, cashierUsername
);
}
}
/**
* Saves the denomination breakdown the cashier entered at submit time into
* m_savings_txn_denomination once the deposit is approved, so the cashier's
@@ -797,56 +739,6 @@ public class CashierDepositRequestApiResource {
}
}
private void saveDepositDenomination(final String denominationData,
final Map<?, ?> record, final Long txnId) {
final JsonObject denomMap;
try {
denomMap = gson.fromJson(denominationData, JsonObject.class);
} catch (Exception e) {
return; // malformed JSON — skip silently
}
if (denomMap == null || denomMap.size() == 0) return;
final Object saObj = record.get("savings_account_id");
final Long savingsAccountId = saObj != null ? Long.valueOf(saObj.toString()) : null;
final String accountNo = (String) record.get("account_no");
final Object clientIdObj = record.get("client_id");
final Long clientId = clientIdObj != null ? Long.valueOf(clientIdObj.toString()) : null;
final Object cashierIdObj = record.get("cashier_id");
final Long cashierId = cashierIdObj != null ? Long.valueOf(cashierIdObj.toString()) : null;
final String cashierUsername = (String) record.get("cashier_username");
for (final Map.Entry<String, JsonElement> entry : denomMap.entrySet()) {
final int count;
try { count = entry.getValue().getAsInt(); } catch (Exception e) { continue; }
if (count <= 0) continue;
final String[] parts = entry.getKey().split(":", 2); // "note:500" or "coin:1"
if (parts.length != 2) continue;
final String kind = parts[0];
final int value;
try { value = Integer.parseInt(parts[1]); } catch (Exception e) { continue; }
final List<Long> ids = jdbcTemplate.queryForList(
"SELECT id FROM m_denomination_master WHERE denomination = ? AND kind = ?"
+ " AND (deleted IS NULL OR deleted = false) LIMIT 1",
Long.class, value, kind);
if (ids.isEmpty()) continue;
final Long denomId = ids.get(0);
jdbcTemplate.update("""
INSERT INTO m_savings_txn_denomination
(txn_id, savings_account_id, account_no, client_id, denomination_id,
denomination_value, count, total_amount, txn_date, txn_type, officer_id, officer_username)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, CURRENT_DATE, 'DEPOSIT', ?, ?)
""",
txnId, savingsAccountId, accountNo, clientId, denomId,
value, count, BigDecimal.valueOf((long) value * count),
cashierId, cashierUsername
);
}
}
/**
* If a cash denomination breakdown is provided, its total must exactly equal
* the deposit amount — prevents the recorded vault movement from drifting
@@ -946,7 +838,7 @@ public class CashierDepositRequestApiResource {
final LocalDate ld = LocalDate.parse(isoDate, DateTimeFormatter.ISO_LOCAL_DATE);
return ld.format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
} catch (Exception e) {
return LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
return LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
}
}
@@ -31,6 +31,7 @@ import org.apache.fineract.portfolio.cashintercashier.domain.CashInterCashierRep
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/cashintercashier")
@Component
@@ -69,7 +70,7 @@ public class CashInterCashierApiResource {
}
final LocalDate transferDate = json.has("transferDate") && !json.get("transferDate").isJsonNull()
? LocalDate.parse(json.get("transferDate").getAsString()) : LocalDate.now();
? LocalDate.parse(json.get("transferDate").getAsString()) : LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
final String fromParty = json.has("fromParty") && !json.get("fromParty").isJsonNull()
? json.get("fromParty").getAsString() : null;
final String toParty = json.has("toParty") && !json.get("toParty").isJsonNull()
@@ -95,13 +96,15 @@ public class CashInterCashierApiResource {
header.setToParty(toParty);
header.setTransferAmount(total);
header.setNote(note);
header.setCreatedAt(LocalDateTime.now());
header.setCreatedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
header.setIsReversed(false);
try {
AppUser user = this.context.authenticatedUser();
header.setPerformedBy(user.getId());
header.setPerformedByUsername(user.getUsername());
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
CashInterCashier saved = repository.saveAndFlush(header);
saveDetails(saved.getId(), denominations);
@@ -128,13 +131,17 @@ public class CashInterCashierApiResource {
try {
JsonObject json = JsonParser.parseString(body).getAsJsonObject();
reason = json.has("reason") ? json.get("reason").getAsString() : null;
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
AppUser user = null;
try { user = this.context.authenticatedUser(); } catch (Exception ignored) {}
try { user = this.context.authenticatedUser(); } catch (Exception ignored) {
// intentionally ignored
}
record.setIsReversed(true);
record.setReversedAt(LocalDateTime.now());
record.setReversedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
record.setReverseReason(reason);
if (user != null) record.setReversedBy(user.getId());
repository.save(record);
@@ -32,6 +32,7 @@ import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/cashreconciliation")
@Component
@@ -62,7 +63,7 @@ public class CashReconciliationApiResource {
throw new PlatformDataIntegrityException("error.msg.cashreconciliation.cashier.required",
"cashierId query param is required.");
}
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now().toString();
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
// In: vault → cashier allocations — GROUP BY denomination_id+kind to keep coin and note separate
final String sqlIn1 = "SELECT ctd.denomination_id, ctd.denomination_value, COALESCE(dm.kind, 'note') AS kind, SUM(ctd.count) AS total_count "
@@ -187,7 +188,7 @@ public class CashReconciliationApiResource {
@Path("expected/me")
public String getExpectedForMe(@QueryParam("asOfDate") String asOfDate) {
context.authenticatedUser().validateHasPermissionTo("READ_CASHRECONCILIATION");
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now().toString();
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
Long appUserId;
try {
appUserId = context.authenticatedUser().getId();
@@ -223,7 +224,7 @@ public class CashReconciliationApiResource {
throw new PlatformDataIntegrityException("error.msg.cashreconciliation.cashier.required",
"cashierId query param is required.");
}
final String reconDate = (date != null && !date.isBlank()) ? date : LocalDate.now().toString();
final String reconDate = (date != null && !date.isBlank()) ? date : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
Integer count = jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM m_cash_reconciliation WHERE cashier_id = ? AND recon_date = CAST(? AS DATE)",
Integer.class, cashierId, reconDate);
@@ -247,7 +248,7 @@ public class CashReconciliationApiResource {
"cashierId is required.");
}
final LocalDate reconDate = json.has("reconDate") && !json.get("reconDate").isJsonNull()
? LocalDate.parse(json.get("reconDate").getAsString()) : LocalDate.now();
? LocalDate.parse(json.get("reconDate").getAsString()) : LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
final String cashierName = json.has("cashierName") && !json.get("cashierName").isJsonNull()
? json.get("cashierName").getAsString() : null;
final Long tellerId = json.has("tellerId") && !json.get("tellerId").isJsonNull()
@@ -299,12 +300,14 @@ public class CashReconciliationApiResource {
header.setVariance(variance);
header.setStatus(status);
header.setNote(note);
header.setCreatedAt(LocalDateTime.now());
header.setCreatedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
try {
AppUser user = this.context.authenticatedUser();
header.setPerformedBy(user.getId());
header.setPerformedByUsername(user.getUsername());
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
CashReconciliation saved = repository.saveAndFlush(header);
for (CashReconciliationDetail d : details) {
@@ -18,6 +18,7 @@ import org.apache.fineract.portfolio.cashreport.service.CashierRoleHelper;
import org.apache.fineract.portfolio.denominationmaster.service.DenominationBreakdownWriter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/cashreports")
@Component
@@ -34,7 +35,7 @@ public class CashReportApiResource {
@GET
@Path("closing")
public String closing(@QueryParam("date") String date) {
final String txnDate = (date != null && !date.isBlank()) ? date : LocalDate.now().toString();
final String txnDate = (date != null && !date.isBlank()) ? date : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
// Single query — conditional aggregation for deposit, withdrawal, net per denomination
final String sql = "SELECT std.denomination_id, std.denomination_value, COALESCE(dm.kind, 'note') AS kind, "
@@ -238,7 +239,7 @@ public class CashReportApiResource {
return gson.toJson(result);
}
final String today = LocalDate.now().toString();
final String today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
// Find the earliest transfer date before today for which no settlement exists on or after that date
final String sql = "SELECT MIN(ct.transfer_date) AS earliest_unsettled "
@@ -256,7 +257,9 @@ public class CashReportApiResource {
java.sql.Date earliestDate = null;
try {
earliestDate = jdbcTemplate.queryForObject(sql, java.sql.Date.class, cashierId, today, cashierId);
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
final boolean unsettled = earliestDate != null;
final String unsettledSince = earliestDate != null ? earliestDate.toString() : null;
@@ -265,7 +268,9 @@ public class CashReportApiResource {
if (unsettled) {
try {
pendingAmount = denominationBreakdownWriter.getCashierTotalCash(cashierId);
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
}
// Check whether today's morning cash transfer has been received
@@ -276,7 +281,9 @@ public class CashReportApiResource {
Integer todayTransferCount = 0;
try {
todayTransferCount = jdbcTemplate.queryForObject(morningTransferSql, Integer.class, cashierId, today);
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
final boolean morningTransferReceived = todayTransferCount != null && todayTransferCount > 0;
result.put("cashierId", cashierId);
@@ -295,7 +302,7 @@ public class CashReportApiResource {
@Path("cashier-position")
public String cashierPosition(@QueryParam("cashierId") Long cashierId,
@QueryParam("asOfDate") String asOfDate) {
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now().toString();
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
// CASHIER role: always scope to their own position only
final Long scopedId = cashierRoleHelper.getCashierIdForFiltering();
@@ -326,7 +333,7 @@ public class CashReportApiResource {
@GET
@Path("cashier-position/me")
public String cashierPositionMe(@QueryParam("asOfDate") String asOfDate) {
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now().toString();
final String dateFilter = (asOfDate != null && !asOfDate.isBlank()) ? asOfDate : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
Long appUserId;
try {
appUserId = context.authenticatedUser().getId();
@@ -362,7 +369,7 @@ public class CashReportApiResource {
@Path("cashier-morning")
public String cashierMorning(@QueryParam("cashierId") Long cashierId,
@QueryParam("date") String date) {
final String txnDate = (date != null && !date.isBlank()) ? date : LocalDate.now().toString();
final String txnDate = (date != null && !date.isBlank()) ? date : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
if (cashierId == null) {
Map<String, Object> empty = new LinkedHashMap<>();
empty.put("cashierId", null);
@@ -515,7 +522,9 @@ public class CashReportApiResource {
cashierName = jdbcTemplate.queryForObject(
"SELECT ms.display_name FROM m_cashiers mc JOIN m_staff ms ON ms.id = mc.staff_id WHERE mc.id = ?",
String.class, cashierId);
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
Map<String, Object> result = new LinkedHashMap<>();
result.put("cashierId", cashierId);
@@ -562,7 +571,7 @@ public class CashReportApiResource {
@QueryParam("offset") Integer offset,
@QueryParam("limit") Integer limit) {
final String txnDate = (date != null && !date.isBlank()) ? date : LocalDate.now().toString();
final String txnDate = (date != null && !date.isBlank()) ? date : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
final int resolvedLimit = (limit != null && limit > 0) ? limit : 20;
final int resolvedOffset = (offset != null && offset >= 0) ? offset : 0;
@@ -36,6 +36,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/cashsettlement")
@Component
@@ -70,7 +71,7 @@ public class CashSettlementApiResource {
}
final LocalDate settlementDate = json.has("settlementDate") && !json.get("settlementDate").isJsonNull()
? LocalDate.parse(json.get("settlementDate").getAsString()) : LocalDate.now();
? LocalDate.parse(json.get("settlementDate").getAsString()) : LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
final String fromParty = json.has("fromParty") && !json.get("fromParty").isJsonNull()
? json.get("fromParty").getAsString() : null;
final String toParty = json.has("toParty") && !json.get("toParty").isJsonNull()
@@ -116,13 +117,15 @@ public class CashSettlementApiResource {
header.setToParty(toParty);
header.setSettlementAmount(total);
header.setNote(note);
header.setCreatedAt(LocalDateTime.now());
header.setCreatedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
header.setIsReversed(false);
try {
AppUser user = this.context.authenticatedUser();
header.setPerformedBy(user.getId());
header.setPerformedByUsername(user.getUsername());
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
// Commit header + details first, then GL dispatch separately to avoid
// EclipseLink flushing pending detail rows inside Fineract's GL transaction.
@@ -142,7 +145,9 @@ public class CashSettlementApiResource {
Long resolved = jdbcTemplate.queryForObject(
"SELECT teller_id FROM m_cashiers WHERE id = ?", Long.class, fromCashierId);
if (resolved != null) glTellerId = resolved;
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
glDispatchService.settleCashFromCashier(glTellerId, fromCashierId, total,
currencyCode, settlementDate.format(DateTimeFormatter.ISO_LOCAL_DATE),
note != null ? note : "");
@@ -174,13 +179,17 @@ public class CashSettlementApiResource {
try {
JsonObject json = JsonParser.parseString(body).getAsJsonObject();
reason = json.has("reason") ? json.get("reason").getAsString() : null;
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
AppUser user = null;
try { user = this.context.authenticatedUser(); } catch (Exception ignored) {}
try { user = this.context.authenticatedUser(); } catch (Exception ignored) {
// intentionally ignored
}
settlement.setIsReversed(true);
settlement.setReversedAt(LocalDateTime.now());
settlement.setReversedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
settlement.setReverseReason(reason);
if (user != null) settlement.setReversedBy(user.getId());
repository.save(settlement);
@@ -192,12 +201,16 @@ public class CashSettlementApiResource {
Long resolved = jdbcTemplate.queryForObject(
"SELECT teller_id FROM m_cashiers WHERE id = ?", Long.class, settlement.getFromCashierId());
if (resolved != null) glTellerId = resolved;
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
glDispatchService.allocateCashToCashier(glTellerId,
settlement.getFromCashierId(), settlement.getSettlementAmount(), "INR",
LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE),
LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ISO_LOCAL_DATE),
"Reversal of cash settlement #" + id + (reason != null ? ": " + reason : ""));
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
}
JsonObject result = new JsonObject();
@@ -214,7 +227,7 @@ public class CashSettlementApiResource {
throw new PlatformDataIntegrityException("error.msg.cashsettlement.cashier.required",
"cashierId query param is required.");
}
final String settlementDate = (date != null && !date.isBlank()) ? date : LocalDate.now().toString();
final String settlementDate = (date != null && !date.isBlank()) ? date : LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
Integer count = jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM m_cash_settlement WHERE from_cashier_id = ? AND settlement_date = CAST(? AS DATE) AND (is_reversed IS NULL OR is_reversed = false)",
Integer.class, cashierId, settlementDate);
@@ -36,6 +36,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/cashtransfer")
@Component
@@ -105,7 +106,7 @@ public class CashTransferApiResource {
header.setToCashierId(toCashierId);
header.setTransferAmount(total);
header.setNote(note);
header.setCreatedAt(LocalDateTime.now());
header.setCreatedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
try {
AppUser user = this.context.authenticatedUser();
if (user != null) {
@@ -136,8 +137,10 @@ public class CashTransferApiResource {
Long resolved = jdbcTemplate.queryForObject(
"SELECT teller_id FROM m_cashiers WHERE id = ?", Long.class, toCashierId);
if (resolved != null) glTellerId = resolved;
} catch (Exception ignored) {}
final LocalDate txnDate = transferDate != null ? transferDate : LocalDate.now();
} catch (Exception ignored) {
// intentionally ignored
}
final LocalDate txnDate = transferDate != null ? transferDate : LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
glDispatchService.allocateCashToCashier(glTellerId, toCashierId, total,
currencyCode, txnDate.format(DateTimeFormatter.ISO_LOCAL_DATE),
note != null ? note : "");
@@ -169,15 +172,19 @@ public class CashTransferApiResource {
try {
JsonObject json = JsonParser.parseString(body).getAsJsonObject();
reason = json.has("reason") ? json.get("reason").getAsString() : null;
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
try {
AppUser user = this.context.authenticatedUser();
transfer.setReversedBy(user.getId());
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
transfer.setIsReversed(true);
transfer.setReversedAt(java.time.LocalDateTime.now());
transfer.setReversedAt(java.time.LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
transfer.setReverseReason(reason);
repository.save(transfer);
@@ -188,12 +195,16 @@ public class CashTransferApiResource {
Long resolved = jdbcTemplate.queryForObject(
"SELECT teller_id FROM m_cashiers WHERE id = ?", Long.class, transfer.getToCashierId());
if (resolved != null) glTellerId = resolved;
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
glDispatchService.settleCashFromCashier(glTellerId,
transfer.getToCashierId(), transfer.getTransferAmount(), "INR",
java.time.LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE),
java.time.LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ISO_LOCAL_DATE),
"Reversal of cash transfer #" + id + (reason != null ? ": " + reason : ""));
} catch (Exception ignored) {}
} catch (Exception ignored) {
// intentionally ignored
}
}
JsonObject result = new JsonObject();
@@ -38,6 +38,7 @@ import org.apache.fineract.portfolio.denominationmaster.domain.SavingsTxnDenomin
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Records cashier denomination breakdown for GL account transactions (journal entries).
@@ -90,7 +91,7 @@ public class CashierGlDenominationApiResource {
final String txnDateStr = fromJsonHelper.extractStringNamed("txnDate", root);
final LocalDate txnDate = (txnDateStr != null && !txnDateStr.isBlank())
? LocalDate.parse(txnDateStr)
: LocalDate.now();
: LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
if (!fromJsonHelper.parameterExists("denominationBreakdown", root)) {
return "{\"result\":\"skipped\"}";
@@ -109,7 +110,9 @@ public class CashierGlDenominationApiResource {
officerId = user.getId();
officerUsername = user.getUsername();
}
} catch (final Exception ignored) {}
} catch (final Exception ignored) {
// intentionally ignored
}
final String resolvedTxnType = (txnType != null && !txnType.isBlank())
? txnType.toUpperCase()
@@ -144,7 +147,7 @@ public class CashierGlDenominationApiResource {
.count(count)
.totalAmount(lineTotal)
.txnDate(txnDate)
.createdAt(LocalDateTime.now())
.createdAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()))
.txnType(resolvedTxnType)
.officerId(officerId)
.officerUsername(officerUsername)
@@ -29,6 +29,7 @@ import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Cashier Share Collection API — POST /v1/cashier/sharecollection
@@ -131,7 +132,7 @@ public class ShareCollectionApiResource {
final LocalDate entryDate;
try {
entryDate = transactionDateStr != null
? LocalDate.parse(transactionDateStr) : LocalDate.now();
? LocalDate.parse(transactionDateStr) : LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
} catch (DateTimeParseException e) {
throw new PlatformDataIntegrityException(
"error.msg.sharecollection.date.invalid",
@@ -193,7 +194,7 @@ public class ShareCollectionApiResource {
final String txnId = "SC-" + shareAccountId + "-" + System.currentTimeMillis();
final long userId = currentUser.getId();
final String collectorName = currentUser.getUsername();
final LocalDateTime now = LocalDateTime.now();
final LocalDateTime now = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
// ── Post GL journal entries ────────────────────────────────────────
// Dr Cash at Vault (SHARES_REFERENCE) = totalAmount
@@ -41,7 +41,6 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.cfcfrms.data.ComplaintStatsData;
import org.apache.fineract.portfolio.cfcfrms.data.ComplaintTicketData;
import org.apache.fineract.portfolio.cfcfrms.data.TimelineEventData;
import org.apache.fineract.portfolio.cfcfrms.service.CfcfrmsComplaintService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -56,7 +56,7 @@ import org.springframework.stereotype.Component;
* POST /v1/simulator/cfcfrms/verify-account – Verify account at bank
* POST /v1/simulator/cfcfrms/verify-transaction – Verify transaction ref
*
* --- STATUS & REPORTING ---
* --- STATUS &amp; REPORTING ---
* GET /v1/simulator/cfcfrms/complaint-status/{ref} – Complaint status from CFCFRMS side
* GET /v1/simulator/cfcfrms/bank-performance – Bank performance metrics
* </pre>
@@ -36,6 +36,7 @@ import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Seeds CFCFRMS complaint tickets, audit logs, and simulator logs on startup.
@@ -59,7 +60,7 @@ public class CfcfrmsDataSeeder {
}
LOG.info("Seeding CFCFRMS complaint data...");
final OffsetDateTime now = OffsetDateTime.now();
final OffsetDateTime now = OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant());
// ─── 3 RECEIVED ──────────────────────────────────────────────
seedTicket("TKT-20250318-001", "Rajesh Kumar Sharma", "9876543210",
@@ -46,6 +46,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -206,7 +207,7 @@ public class CfcfrmsComplaintServiceImpl implements CfcfrmsComplaintService {
final Map<String, Object> result = new HashMap<>();
result.put("escalatedTo", nextIfsc);
result.put("escalationRef", escalationRef);
result.put("timestamp", OffsetDateTime.now().toString());
result.put("timestamp", OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant()).toString());
return result;
}
@@ -218,7 +219,7 @@ public class CfcfrmsComplaintServiceImpl implements CfcfrmsComplaintService {
}
private String generateTicketId() {
final String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
final String date = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("yyyyMMdd"));
final int seq = (int) (ticketRepository.count() + 1);
return String.format("TKT-%s-%03d", date, seq);
}
@@ -25,12 +25,10 @@ import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.portfolio.cfcfrms.data.CfcfrmsConstants;
@@ -44,6 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -76,7 +75,7 @@ public class CfcfrmsSimulatorServiceImpl implements CfcfrmsSimulatorService {
final Map<String, Object> response = new LinkedHashMap<>();
response.put("cfcfrmsRef", cfcfrmsRef);
response.put("ticketId", ticketData.getTicketId());
response.put("pushedToBankAt", OffsetDateTime.now().toString());
response.put("pushedToBankAt", OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant()).toString());
response.put("bankAcknowledged", true);
response.put("message", "Complaint pushed to " + CfcfrmsConstants.BANK_IFSC + " successfully");
return response;
@@ -85,7 +84,7 @@ public class CfcfrmsSimulatorServiceImpl implements CfcfrmsSimulatorService {
@Override
public Map<String, Object> pushHoldDirective(final JsonObject json) {
final String cfcfrmsRef = getStringOrThrow(json, "cfcfrmsRef");
final String directiveRef = "DIR-" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
final String directiveRef = "DIR-" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-" + String.format("%04d", RANDOM.nextInt(10000));
final String directiveType = getStringOrThrow(json, "directiveType");
@@ -112,7 +111,7 @@ public class CfcfrmsSimulatorServiceImpl implements CfcfrmsSimulatorService {
response.put("directiveRef", directiveRef);
response.put("status", "DIRECTIVE_SENT");
response.put("bankResponse", bankResponse);
response.put("timestamp", OffsetDateTime.now().toString());
response.put("timestamp", OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant()).toString());
return response;
}
@@ -208,7 +207,7 @@ public class CfcfrmsSimulatorServiceImpl implements CfcfrmsSimulatorService {
public Map<String, Object> receiveEscalation(final JsonObject json) {
final String cfcfrmsRef = getStringOrThrow(json, "cfcfrmsRef");
final String ticketId = getStringOrThrow(json, "ticketId");
final String escalationRef = "ESC-" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MMdd"))
final String escalationRef = "ESC-" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("yyyy-MMdd"))
+ "-" + String.format("%04d", RANDOM.nextInt(10000));
// Extract nextBank from fundsMovedTo
@@ -268,7 +267,7 @@ public class CfcfrmsSimulatorServiceImpl implements CfcfrmsSimulatorService {
final Map<String, Object> response = new LinkedHashMap<>();
response.put("transactionFound", true);
response.put("transactionStatus", "COMPLETED");
response.put("transactionTimestamp", OffsetDateTime.now().minusHours(2).toString());
response.put("transactionTimestamp", OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant()).minusHours(2).toString());
response.put("senderAccount", json.has("accountNumber") ? json.get("accountNumber").getAsString() : "UNKNOWN");
response.put("receiverAccount", json.has("accountNumber") ? json.get("accountNumber").getAsString() : "UNKNOWN");
@@ -369,14 +368,14 @@ public class CfcfrmsSimulatorServiceImpl implements CfcfrmsSimulatorService {
.setScale(1, java.math.RoundingMode.HALF_UP) + "%"
: "0.0%";
response.put("tatComplianceRate", tatCompliance);
response.put("lastActivityAt", OffsetDateTime.now().toString());
response.put("lastActivityAt", OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant()).toString());
return response;
}
// ── Helpers ──
private String generateCfcfrmsRef() {
final String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MMdd"));
final String date = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("yyyy-MMdd"));
return "CFCFRMS-" + date + "-" + String.format("%04d", RANDOM.nextInt(10000));
}
@@ -201,7 +201,7 @@ public class NpciInwardPushService {
final String presentingBranchCode = getString(instrument, "depositBranchCode");
item.recordInwardMeta(getString(instrument, "serialNumber"), presentingBranchCode, batch.getReturnTatDeadline());
final Boolean instrumentStopPaymentFlag = instrument.has("stopPaymentFlag") && !instrument.get("stopPaymentFlag").isJsonNull()
final Boolean instrumentStopPaymentFlag = (instrument.has("stopPaymentFlag") && !instrument.get("stopPaymentFlag").isJsonNull())
? instrument.get("stopPaymentFlag").getAsBoolean()
: null;
item.recordSourceDetails(getString(instrument, "ctsReferenceNumber"), instrumentStopPaymentFlag,
@@ -70,6 +70,7 @@ import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/clerk/disbursement-requests")
@Component
@@ -383,7 +384,7 @@ public class ClerkDisbursementRequestApiResource {
final JsonArray creditEntries = gson.fromJson(creditEntriesJson, JsonArray.class);
final Object ptId = record.get("payment_type_id");
final String description = (String) record.get("description");
final String txnDateStr = LocalDate.now().toString();
final String txnDateStr = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
final Long sourceGlId = record.get("gl_account_id") != null
? ((Number) record.get("gl_account_id")).longValue() : null;
@@ -556,7 +557,7 @@ public class ClerkDisbursementRequestApiResource {
final String entryType = entry.has("accountType") ? entry.get("accountType").getAsString() : "SAVINGS";
final String acNo = entry.has("accountNo") ? entry.get("accountNo").getAsString() : "?";
final Long entryPtId = entry.has("paymentTypeId") && !entry.get("paymentTypeId").isJsonNull()
? entry.get("paymentTypeId").getAsLong()
? Long.valueOf(entry.get("paymentTypeId").getAsLong())
: (ptId != null ? ((Number) ptId).longValue() : null);
if ("GL".equals(entryType)) {
@@ -810,7 +811,7 @@ public class ClerkDisbursementRequestApiResource {
? req.get("currencyCode").getAsString() : "INR";
final String txnDateStr = req.has("transactionDate") && !req.get("transactionDate").isJsonNull()
? req.get("transactionDate").getAsString()
: LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
: LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ISO_LOCAL_DATE);
final String description = req.has("description") && !req.get("description").isJsonNull()
? req.get("description").getAsString() : null;
@@ -830,7 +831,6 @@ public class ClerkDisbursementRequestApiResource {
// Validate all entries: savings/current only (no GL), savingsAccountId present, amount > 0
final Set<Long> drAccountIds = new LinkedHashSet<>();
final Set<Long> crAccountIds = new LinkedHashSet<>();
for (final JsonObject e : drEntries) {
final String acTyp = e.has("accountType") ? e.get("accountType").getAsString() : "SAVINGS";
@@ -858,7 +858,6 @@ public class ClerkDisbursementRequestApiResource {
if (drAccountIds.contains(crId)) throw apiError(400,
"Account " + (e.has("accountNo") ? e.get("accountNo").getAsString() : crId)
+ " cannot appear on both DR and CR sides of the same transfer.");
crAccountIds.add(crId);
}
// Validate balanced entry: total DR == total CR
@@ -999,7 +998,7 @@ public class ClerkDisbursementRequestApiResource {
* under concurrent inserts on the same date.
*/
private String generateBtVoucherNo(final long logId) {
return "BT" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd"))
return "BT" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("yyMMdd"))
+ String.format("%05d", logId);
}
@@ -1053,7 +1052,9 @@ public class ClerkDisbursementRequestApiResource {
try {
final Long txnIdLong = Long.parseLong(txnId);
undoOps.add(() -> undoAccountTransaction(accountId, txnIdLong, isCurrentAccount));
} catch (NumberFormatException ignored) {}
} catch (NumberFormatException ignored) {
// intentionally ignored
}
}
private void undoAccountTransaction(final Long accountId, final Long transactionId,
@@ -1072,50 +1073,6 @@ public class ClerkDisbursementRequestApiResource {
commandsSourceWritePlatformService.logCommandSource(cmd);
}
private String executeSavingsDeposit(
final Long savingsAccountId, final BigDecimal amount,
final Long paymentTypeId, final String txnDateStr, final String note) {
final String date = formatForFineract(txnDateStr);
final JsonObject payload = new JsonObject();
payload.addProperty("locale", "en");
payload.addProperty("dateFormat", "dd MMMM yyyy");
payload.addProperty("transactionDate", date);
payload.addProperty("transactionAmount", amount);
if (paymentTypeId != null) payload.addProperty("paymentTypeId", paymentTypeId);
if (note != null && !note.isBlank()) payload.addProperty("note", note);
final CommandWrapper cmd = new CommandWrapperBuilder()
.savingsAccountDeposit(savingsAccountId)
.withJson(payload.toString())
.build();
fineractRequestContextHolder.setAttribute(SynchronousCommandProcessingService.COMMAND_SOURCE_ID, null);
final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(cmd);
return result.getResourceId() != null ? result.getResourceId().toString() : null;
}
private String executeCurrentAccountDeposit(
final Long currentAccountId, final BigDecimal amount,
final Long paymentTypeId, final String txnDateStr, final String note) {
final String date = formatForFineract(txnDateStr);
final JsonObject payload = new JsonObject();
payload.addProperty("locale", "en");
payload.addProperty("dateFormat", "dd MMMM yyyy");
payload.addProperty("transactionDate", date);
payload.addProperty("transactionAmount", amount);
if (paymentTypeId != null) payload.addProperty("paymentTypeId", paymentTypeId);
if (note != null && !note.isBlank()) payload.addProperty("note", note);
final CommandWrapper cmd = new CommandWrapperBuilder()
.currentAccountDeposit(currentAccountId)
.withJson(payload.toString())
.build();
fineractRequestContextHolder.setAttribute(SynchronousCommandProcessingService.COMMAND_SOURCE_ID, null);
final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(cmd);
return result.getResourceId() != null ? result.getResourceId().toString() : null;
}
private boolean isCurrentAccountById(final Long accountId) {
try {
final Integer count = jdbcTemplate.queryForObject(
@@ -1131,7 +1088,7 @@ public class ClerkDisbursementRequestApiResource {
final LocalDate ld = LocalDate.parse(isoDate, DateTimeFormatter.ISO_LOCAL_DATE);
return ld.format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
} catch (Exception e) {
return LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
return LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
}
}
@@ -1380,7 +1337,7 @@ public class ClerkDisbursementRequestApiResource {
? (BigDecimal) accts.get(0).get("account_balance_derived") : BigDecimal.ZERO;
final java.sql.Date sqlDate = java.sql.Date.valueOf(txnDate);
final OffsetDateTime now = OffsetDateTime.now();
final OffsetDateTime now = OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant());
final String refNo = UUID.randomUUID().toString().replace("-", "").substring(0, 20);
final Long userId = currentUser.getId();
@@ -1534,7 +1491,7 @@ public class ClerkDisbursementRequestApiResource {
+ ". Available: " + currentBalance + ", Requested: " + amount);
final java.sql.Date sqlDate = java.sql.Date.valueOf(txnDate);
final OffsetDateTime now = OffsetDateTime.now();
final OffsetDateTime now = OffsetDateTime.now(DateUtils.getDateTimeZoneOfTenant());
final String refNo = UUID.randomUUID().toString().replace("-", "").substring(0, 20);
final Long userId = currentUser.getId();
@@ -59,6 +59,9 @@ import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import com.google.common.collect.Iterables;
import com.google.common.base.Splitter;
@Path("/v1/clerk/withdrawal-requests")
@Component
@@ -437,7 +440,7 @@ public class ClerkWithdrawalRequestApiResource {
final BigDecimal amount = new BigDecimal(record.get("amount").toString());
final Object ptId = record.get("payment_type_id");
final Object txnDateObj = record.get("txn_date");
final String txnDateStr = txnDateObj != null ? txnDateObj.toString().split(" ")[0] : null;
final String txnDateStr = txnDateObj != null ? Iterables.get(Splitter.on(' ').split(txnDateObj.toString()), 0) : null;
final String description = (String) record.get("description");
String txnId = null;
@@ -713,7 +716,7 @@ public class ClerkWithdrawalRequestApiResource {
final Long savingsAccountId, final BigDecimal amount,
final Object paymentTypeId, final String txnDateStr, final String note) {
final String today = LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String date = txnDateStr != null && !txnDateStr.isBlank() ? formatForFineract(txnDateStr) : today;
final JsonObject payload = new JsonObject();
@@ -741,7 +744,7 @@ public class ClerkWithdrawalRequestApiResource {
final Long currentAccountId, final BigDecimal amount,
final Object paymentTypeId, final String txnDateStr, final String note) {
final String today = LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
final String date = txnDateStr != null && !txnDateStr.isBlank() ? formatForFineract(txnDateStr) : today;
final JsonObject payload = new JsonObject();
@@ -780,7 +783,7 @@ public class ClerkWithdrawalRequestApiResource {
final LocalDate ld = LocalDate.parse(isoDate, DateTimeFormatter.ISO_LOCAL_DATE);
return ld.format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
} catch (Exception e) {
return LocalDate.now().format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
return LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
}
}
@@ -39,6 +39,8 @@ import jakarta.ws.rs.core.MediaType;
import java.io.InputStream;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import java.time.LocalDate;
import java.time.Period;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@@ -158,7 +160,13 @@ public class ClientKycApiResource {
template.put("clientTypeName", clientTypeName);
template.put("legalFormId", legalFormId);
template.put("requiredDocuments", getRequiredDocuments(clientTypeName, legalFormId));
// Minor detection mirrors the frontend's own rule (age < 10) so the document list
// served here stays consistent with what the UI computes from the same date of birth.
final LocalDate dateOfBirth = client.dateOfBirth();
final boolean isMinor = dateOfBirth != null && Period.between(dateOfBirth, LocalDate.now()).getYears() < 10;
template.put("isMinor", isMinor);
template.put("requiredDocuments", getRequiredDocuments(clientTypeName, legalFormId, isMinor));
return toApiJsonSerializer.serialize(template);
}
@@ -166,11 +174,21 @@ public class ClientKycApiResource {
/**
* Returns required KYC documents based on client type (RBI Master Direction on KYC).
*/
private List<Map<String, Object>> getRequiredDocuments(final String clientTypeName, final Integer legalFormId) {
private List<Map<String, Object>> getRequiredDocuments(final String clientTypeName, final Integer legalFormId,
final boolean isMinor) {
final List<Map<String, Object>> docs = new ArrayList<>();
// Individual types (legalFormId=1)
if (legalFormId != null && legalFormId == 1) {
if (isMinor) {
// Minors cannot hold PAN, Voter ID, Driving Licence or an NREGA job card — RBI
// accepts Aadhaar, Passport, Birth Certificate or School ID Card instead.
docs.add(doc("Aadhaar Card", "AADHAAR", true));
docs.add(doc("Birth Certificate", "BIRTH_CERTIFICATE", false));
docs.add(doc("School ID Card", "SCHOOL_ID_CARD", false));
docs.add(doc("Passport", "PASSPORT", false));
return docs;
}
docs.add(doc("Aadhaar Card", "AADHAAR", true));
docs.add(doc("PAN Card", "PAN", true));
docs.add(doc("Voter ID", "VOTER_ID", false));
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicLong;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.portfolio.client.domain.ClientKyc;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Dummy / stub implementation of {@link CkycSftpUploadService}.
@@ -60,7 +61,7 @@ public class DummyCkycSftpUploadServiceImpl implements CkycSftpUploadService {
final String ckycNumber = generateCkycNumber(kyc.getClient().getId());
final String batchId = generateBatchId();
final LocalDate today = LocalDate.now();
final LocalDate today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
return CkycUploadResult.builder()
.ckycNumber(ckycNumber)
@@ -82,7 +83,7 @@ public class DummyCkycSftpUploadServiceImpl implements CkycSftpUploadService {
return CkycUploadResult.builder()
.status("FAILED")
.remarks("Uploaded file is not a valid ZIP archive (bad magic bytes).")
.uploadedOn(LocalDate.now())
.uploadedOn(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()))
.build();
}
@@ -92,7 +93,7 @@ public class DummyCkycSftpUploadServiceImpl implements CkycSftpUploadService {
return CkycUploadResult.builder()
.ckycNumber(ckycNumber)
.batchId(batchId)
.uploadedOn(LocalDate.now())
.uploadedOn(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()))
.status("SUCCESS")
.remarks("Dummy CKYC ZIP upload accepted (" + zipBytes.length + " bytes). "
+ "Replace with real CERSAI SFTP integration before go-live.")
@@ -112,7 +113,7 @@ public class DummyCkycSftpUploadServiceImpl implements CkycSftpUploadService {
}
private String generateBatchId() {
return "DUMMYCKYC-" + BATCH_ID_FORMAT.format(LocalDate.now()) + "-"
return "DUMMYCKYC-" + BATCH_ID_FORMAT.format(LocalDate.now(DateUtils.getDateTimeZoneOfTenant())) + "-"
+ String.format("%06d", BATCH_COUNTER.getAndIncrement());
}
}
@@ -50,6 +50,7 @@ import org.apache.fineract.portfolio.client.ckyc.domain.CkycBatchRepository;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -86,11 +87,11 @@ public class CkycBatchBuilderServiceImpl implements CkycBatchBuilderService {
throw new IllegalArgumentException("clientIds must not be empty");
}
final LocalDate today = LocalDate.now();
final LocalDate today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
final int seq = nextBatchSequenceForToday(today);
final String batchId = "BATCH-" + BATCH_ID_FMT.format(today) + "-" + String.format("%03d", seq);
// ZIP filename: "CERSAI-ZIP-<yyyy-MM-dd-HH-mm-ss>.zip" — hyphen-separated per spec.
final String filename = "CERSAI-ZIP-" + ZIP_NAME_TS_FMT.format(java.time.LocalDateTime.now()) + ".zip";
final String filename = "CERSAI-ZIP-" + ZIP_NAME_TS_FMT.format(java.time.LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant())) + ".zip";
final List<CkycBatchManifestEntry> manifest = new ArrayList<>();
final ByteArrayOutputStream zipBytesOut = new ByteArrayOutputStream();
@@ -26,7 +26,6 @@ import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -36,6 +35,7 @@ import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecific
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -219,6 +219,7 @@ public class CkycReportsReadServiceImpl implements CkycReportsReadService {
// ===== Customer List =====
@Override
@SuppressWarnings("StringSplitter")
public Map<String, Object> listCustomers(String name, String branch, String city, String gender, String state, String dateFrom,
String dateTo, Integer page, Integer pageSize, String sort) {
@@ -375,13 +376,13 @@ public class CkycReportsReadServiceImpl implements CkycReportsReadService {
switch (format != null ? format.toLowerCase() : "csv") {
case "txt":
contentType = "text/plain";
filename = "ckyc_export_" + LocalDate.now() + ".txt";
filename = "ckyc_export_" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()) + ".txt";
content = buildPipeDelimitedExport(rows);
break;
case "csv":
default:
contentType = "text/csv";
filename = "ckyc_export_" + LocalDate.now() + ".csv";
filename = "ckyc_export_" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()) + ".csv";
content = buildCsvExport(rows);
break;
}
@@ -431,7 +432,7 @@ public class CkycReportsReadServiceImpl implements CkycReportsReadService {
errors.add("Parse error: " + e.getMessage());
}
String fileId = "UPLOAD-" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + "-" + System.currentTimeMillis();
String fileId = "UPLOAD-" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("yyyyMMdd")) + "-" + System.currentTimeMillis();
result.put("fileId", fileId);
result.put("totalRecords", totalRecords);
result.put("customers", customers);
@@ -453,9 +454,9 @@ public class CkycReportsReadServiceImpl implements CkycReportsReadService {
@Override
public Response generateCkycFile(Map<String, Object> request) {
// Placeholder — delegates to CkycBatchBuilderService for actual ZIP generation
String content = "10|BATCH|" + LocalDate.now() + "|0\n";
String content = "10|BATCH|" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()) + "|0\n";
return Response.ok(content.getBytes(StandardCharsets.UTF_8), "text/plain")
.header("Content-Disposition", "attachment; filename=\"ckyc_submission_" + LocalDate.now() + ".txt\"")
.header("Content-Disposition", "attachment; filename=\"ckyc_submission_" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()) + ".txt\"")
.build();
}
@@ -572,7 +573,7 @@ public class CkycReportsReadServiceImpl implements CkycReportsReadService {
private String buildPipeDelimitedExport(List<Map<String, Object>> rows) {
StringBuilder sb = new StringBuilder();
sb.append("10|CKYC_EXPORT|").append(LocalDate.now()).append("|").append(rows.size()).append("\n");
sb.append("10|CKYC_EXPORT|").append(LocalDate.now(DateUtils.getDateTimeZoneOfTenant())).append("|").append(rows.size()).append("\n");
for (Map<String, Object> row : rows) {
sb.append("20|");
sb.append(val(row.get("cif"))).append("|");
@@ -47,6 +47,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Dummy / stub implementation of {@link CkycBatchSftpUploadService}.
@@ -149,10 +150,10 @@ public class DummyCkycBatchSftpUploadServiceImpl implements CkycBatchSftpUploadS
}
// 3) Build the ACK reference and timestamp
final LocalDateTime now = LocalDateTime.now();
final LocalDateTime now = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
final String ackReference = "CERSAI-ACK-" + ACK_TS_FMT.format(now) + "-"
+ String.format("%04d", ACK_COUNTER.getAndIncrement());
final LocalDate today = LocalDate.now();
final LocalDate today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
// 4) Parse manifest → generate a CKYC number per included client → persist on m_client_kyc
final List<Map<String, Object>> perClient = new ArrayList<>();
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.portfolio.client.contactverification.api;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.swagger.v3.oas.annotations.Operation;
@@ -152,7 +154,7 @@ public class ClientContactVerificationApiResource {
}
final String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) {
return fwd.split(",")[0].trim();
return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
}
return req.getRemoteAddr();
}
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.portfolio.client.contactverification.api;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.swagger.v3.oas.annotations.Operation;
@@ -147,7 +149,7 @@ public class ClientCreationContactVerificationApiResource {
}
final String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) {
return fwd.split(",")[0].trim();
return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
}
return req.getRemoteAddr();
}
@@ -53,6 +53,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.RestTemplate;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* See {@link ClientContactOtpService}. Deliberately does NOT touch {@code LoginOtpServiceImpl} /
@@ -209,7 +210,7 @@ public class ClientContactOtpServiceImpl implements ClientContactOtpService {
log.setExpiresAt(OffsetDateTime.now(ZoneOffset.UTC).plusSeconds(ttlSeconds));
final String html = emailTemplateService.renderOtp(null, otp, validityMinutes);
final String subject = "Your OTP for Contact Verification - " + appName + " (" + LocalDateTime.now().format(SUBJECT_TIMESTAMP)
final String subject = "Your OTP for Contact Verification - " + appName + " (" + LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).format(SUBJECT_TIMESTAMP)
+ ")";
final boolean sent = emailSenderService.sendHtml(emailAddress, subject, html);
@@ -34,6 +34,7 @@ import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Named;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Mapper(config = MapstructMapperConfig.class)
public interface ClientMapper {
@@ -271,7 +272,7 @@ public interface ClientMapper {
default void computeAge(Client source, @MappingTarget ClientData target) {
final LocalDate dob = source.getDateOfBirth();
if (dob != null) {
final Period age = Period.between(dob, LocalDate.now());
final Period age = Period.between(dob, LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
target.setAgeYears(age.getYears());
target.setAgeMonths(age.getMonths());
target.setAgeDays(age.getDays());
@@ -25,6 +25,7 @@ import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepository;
import org.apache.fineract.portfolio.client.domain.LegalForm;
import org.springframework.stereotype.Component;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Generates CIF numbers in the format <code>TTYYYYNNNNNN</code>:
@@ -90,6 +91,6 @@ public class CifNumberGenerator {
private int resolveYear(final Client client) {
final LocalDate submittedOn = client.getSubmittedOnDate();
return (submittedOn != null ? submittedOn : LocalDate.now()).getYear();
return (submittedOn != null ? submittedOn : LocalDate.now(DateUtils.getDateTimeZoneOfTenant())).getYear();
}
}
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* See {@link ClientChangeNotificationService}.
@@ -88,7 +89,7 @@ public class ClientChangeNotificationServiceImpl implements ClientChangeNotifica
final String alertTitle = fieldLabel + " Updated";
final String alertMessage = "Your " + fieldLabel.toLowerCase() + " on file was changed from "
+ describeForDisplay(fieldLabel, oldValue) + " to " + describeForDisplay(fieldLabel, newValue) + " on "
+ LocalDateTime.now().format(TIMESTAMP) + ". If you did not authorize this change, please contact us immediately.";
+ LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).format(TIMESTAMP) + ". If you did not authorize this change, please contact us immediately.";
final String html = emailTemplateService.renderAlert(recipientName, alertTitle, alertMessage);
final String subject = alertTitle + " - " + appName;
@@ -63,6 +63,7 @@ import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -488,7 +489,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
Integer ageMonths1 = null;
Integer ageDays1 = null;
if (dateOfBirth != null) {
final Period age = Period.between(dateOfBirth, LocalDate.now());
final Period age = Period.between(dateOfBirth, LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
ageYears1 = age.getYears();
ageMonths1 = age.getMonths();
ageDays1 = age.getDays();
@@ -879,7 +880,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
Integer ageMonths = null;
Integer ageDays = null;
if (dateOfBirth != null) {
final Period age = Period.between(dateOfBirth, LocalDate.now());
final Period age = Period.between(dateOfBirth, LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
ageYears = age.getYears();
ageMonths = age.getMonths();
ageDays = age.getDays();
@@ -1786,6 +1786,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
* verifying KYC names against ID documents). Null / blank → null so we don't accidentally
* persist an empty string in place of an unset field.
*/
@SuppressWarnings("StringSplitter")
private static String toTitleCase(final String raw) {
if (raw == null) {
return null;
@@ -582,21 +582,6 @@ public class CtsClearingWritePlatformServiceImpl implements CtsClearingWritePlat
}
}
/** SHA-256 hex digest of the given content, used as a visible integrity fingerprint in the CTS header. */
private String sha256Hex(final String content) {
try {
final java.security.MessageDigest digest = java.security.MessageDigest.getInstance("SHA-256");
final byte[] hash = digest.digest(content.getBytes(java.nio.charset.StandardCharsets.UTF_8));
final StringBuilder hex = new StringBuilder();
for (final byte b : hash) {
hex.append(String.format("%02x", b));
}
return hex.toString();
} catch (final java.security.NoSuchAlgorithmException e) {
throw new IllegalStateException("SHA-256 is not available", e);
}
}
/** Masks all but the last 4 characters of an account number (matches the CTS file convention of not exposing full numbers). */
private String maskAccountNumber(final String accountNumber) {
if (accountNumber == null || accountNumber.isBlank()) {
@@ -26,6 +26,7 @@ import org.apache.fineract.portfolio.denominationmaster.domain.DenominationMaste
import org.apache.fineract.portfolio.denominationmaster.domain.DenominationMasterRepository;
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.stereotype.Component;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/denominationmaster")
@Component
@@ -105,7 +106,7 @@ public class DenominationMasterApiResource {
writeAudit("ACTIVATE", dm, null);
} else if ("deactivate".equals(command)) {
dm.setIsActive(false);
dm.setDiscontinuedOn(LocalDate.now());
dm.setDiscontinuedOn(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
repository.save(dm);
writeAudit("DEACTIVATE", dm, null);
} else if ("restore".equals(command)) {
@@ -15,6 +15,7 @@ import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_denomination_master_audit")
@@ -77,7 +78,7 @@ public class DenominationMasterAudit {
a.changes = changes;
a.performedBy = performedBy;
a.performedByUsername = performedByUsername;
a.performedOn = LocalDateTime.now();
a.performedOn = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
return a;
}
}
@@ -26,6 +26,7 @@ import org.apache.fineract.portfolio.denominationmaster.domain.SavingsTxnDenomin
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Validates and persists the per-transaction cash denomination breakdown sent by the UI
@@ -163,7 +164,7 @@ public class DenominationBreakdownWriter {
}
if (cashierId == null) return;
final String today = java.time.LocalDate.now().toString();
final String today = java.time.LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
final String sql = "SELECT COUNT(*) FROM m_cash_transfer ct "
+ "WHERE ct.to_cashier_id = ? "
+ " AND ct.transfer_date < CAST(? AS DATE) "
@@ -203,7 +204,7 @@ public class DenominationBreakdownWriter {
}
if (cashierId == null) return;
final String today = java.time.LocalDate.now().toString();
final String today = java.time.LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).toString();
final String sql = "SELECT COUNT(*) FROM m_cash_transfer ct "
+ "WHERE ct.to_cashier_id = ? "
+ " AND ct.transfer_date = CAST(? AS DATE) "
@@ -511,7 +512,7 @@ public class DenominationBreakdownWriter {
.count(count)
.totalAmount(lineTotal)
.txnDate(txnDate)
.createdAt(LocalDateTime.now())
.createdAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()))
.txnType(resolvedTxnType)
.officerId(officerId)
.officerUsername(officerUsername)
@@ -1,6 +1,13 @@
package org.apache.fineract.portfolio.election.api;
import jakarta.ws.rs.*;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import lombok.RequiredArgsConstructor;
@@ -3,7 +3,17 @@ package org.apache.fineract.portfolio.election.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.*;
import jakarta.ws.rs.Consumes;
import com.google.common.collect.Iterables;
import com.google.common.base.Splitter;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@@ -138,6 +148,6 @@ public class CommitteeMeetingApiResource {
private String clientIp(HttpServletRequest req) {
String ip = req.getHeader("X-Forwarded-For");
return (ip != null && !ip.isBlank()) ? ip.split(",")[0].trim() : req.getRemoteAddr();
return (ip != null && !ip.isBlank()) ? Iterables.get(Splitter.on(',').split(ip), 0).trim() : req.getRemoteAddr();
}
}
@@ -4,7 +4,18 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import jakarta.ws.rs.*;
import jakarta.ws.rs.Consumes;
import com.google.common.collect.Iterables;
import com.google.common.base.Splitter;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@@ -125,6 +136,6 @@ public class DirectorAppointmentApiResource {
private String clientIp(HttpServletRequest req) {
String ip = req.getHeader("X-Forwarded-For");
return (ip != null && !ip.isBlank()) ? ip.split(",")[0].trim() : req.getRemoteAddr();
return (ip != null && !ip.isBlank()) ? Iterables.get(Splitter.on(',').split(ip), 0).trim() : req.getRemoteAddr();
}
}
@@ -15,6 +15,8 @@ import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.contentstore.service.ContentStoreService;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
@@ -123,7 +125,9 @@ public class ElectionCandidateApiResource {
if (existing != null && !existing.startsWith("data:") && existing.contains("|")) {
String[] ep = existing.split("\\|", 2);
if (ep.length == 2) {
try { contentStoreService.delete(ep[1]); } catch (Exception ignored) {}
try { contentStoreService.delete(ep[1]); } catch (Exception ignored) {
// intentionally ignored
}
}
}
@@ -218,7 +222,7 @@ public class ElectionCandidateApiResource {
private static String clientIp(HttpServletRequest req) {
if (req == null) return null;
String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) return fwd.split(",")[0].trim();
if (fwd != null && !fwd.isBlank()) return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
return req.getRemoteAddr();
}
@@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
@@ -17,6 +16,8 @@ import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.portfolio.election.data.ElectionConfigData;
import org.apache.fineract.portfolio.election.data.ElectionConfigRequest;
@@ -89,7 +90,9 @@ public class ElectionConfigApiResource {
throw e;
}
String updateDetails = null;
try { updateDetails = objectMapper.writeValueAsString(request); } catch (Exception ignored) {}
try { updateDetails = objectMapper.writeValueAsString(request); } catch (Exception ignored) {
// intentionally ignored
}
electionAuditService.log(ElectionAuditAction.UPDATE_ELECTION, "ELECTION", electionId, electionId,
"Election updated: " + request.getTitle(), updateDetails, clientIp(httpRequest));
return Response.ok(Map.of("resourceId", electionId)).build();
@@ -214,7 +217,7 @@ public class ElectionConfigApiResource {
private static String clientIp(HttpServletRequest req) {
if (req == null) return null;
String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) return fwd.split(",")[0].trim();
if (fwd != null && !fwd.isBlank()) return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
return req.getRemoteAddr();
}
@@ -15,6 +15,8 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.portfolio.election.data.ElectionApprovalActionRequest;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import org.apache.fineract.portfolio.election.data.ElectionApprovalStepData;
import org.apache.fineract.portfolio.election.data.ElectionNominationData;
import org.apache.fineract.portfolio.election.data.ElectionNominationRequest;
@@ -295,7 +297,7 @@ public class ElectionNominationApiResource {
private static String clientIp(HttpServletRequest req) {
if (req == null) return null;
String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) return fwd.split(",")[0].trim();
if (fwd != null && !fwd.isBlank()) return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
return req.getRemoteAddr();
}
@@ -15,6 +15,8 @@ import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
@@ -104,10 +106,10 @@ public class ElectionVotingApiResource {
}
winDet.append("]");
String declareDetails = wFirst ? null : winDet.toString();
String declareDesc = "Results declared" + (declareDetails != null ? " — " + (results.stream()
String declareDesc = "Results declared" + (declareDetails != null ? " — " + results.stream()
.filter(r -> Integer.valueOf(1).equals(r.getRankPosition()) || "WON".equalsIgnoreCase(r.getResult()))
.map(r -> r.getCandidateName() + " won " + r.getPostName())
.reduce((a, b) -> a + "; " + b).orElse("")) : "");
.reduce((a, b) -> a + "; " + b).orElse("") : "");
electionAuditService.log(ElectionAuditAction.DECLARE_RESULTS, "RESULT", electionId, electionId,
declareDesc, declareDetails, clientIp(httpRequest));
return Response.ok(results).build();
@@ -127,7 +129,7 @@ public class ElectionVotingApiResource {
private static String clientIp(HttpServletRequest req) {
if (req == null) return null;
String fwd = req.getHeader("X-Forwarded-For");
if (fwd != null && !fwd.isBlank()) return fwd.split(",")[0].trim();
if (fwd != null && !fwd.isBlank()) return Iterables.get(Splitter.on(',').split(fwd), 0).trim();
return req.getRemoteAddr();
}
@@ -2,7 +2,12 @@ package org.apache.fineract.portfolio.election.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.*;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import lombok.RequiredArgsConstructor;
@@ -2,7 +2,13 @@ package org.apache.fineract.portfolio.election.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.*;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import lombok.RequiredArgsConstructor;
@@ -1,6 +1,13 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -1,6 +1,13 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -1,6 +1,14 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -26,7 +26,7 @@ public class CommitteeMember {
private Long directorAppointmentId;
@Column(name = "added_date", nullable = false)
private LocalDate addedDate = LocalDate.now();
private LocalDate addedDate;
public static CommitteeMember create(Committee committee, Long directorAppointmentId) {
CommitteeMember m = new CommitteeMember();
@@ -1,6 +1,12 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -8,6 +14,7 @@ import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import java.time.LocalDate;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_director_appointment")
@@ -58,12 +65,12 @@ public class DirectorAppointment extends AbstractPersistableCustom<Long> {
@PrePersist
void onPersist() {
this.createdDate = LocalDateTime.now();
this.createdDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
}
@PreUpdate
void onUpdate() {
this.lastModifiedDate = LocalDateTime.now();
this.lastModifiedDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
}
public static DirectorAppointment create(Long electionId, Long candidateId,
@@ -14,6 +14,7 @@ import java.util.List;
@Repository
public interface DirectorAppointmentRepository extends JpaRepository<DirectorAppointment, Long> {
@Override
Page<DirectorAppointment> findAll(Pageable pageable);
Page<DirectorAppointment> findByStatus(DirectorAppointmentStatus status, Pageable pageable);
@@ -1,12 +1,20 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_approval_step")
@@ -63,7 +71,7 @@ public class ElectionApprovalStep extends AbstractPersistableCustom<Long> {
this.approverUserId = approverUserId;
this.status = ApprovalStepStatus.APPROVED;
this.remarks = remarks;
this.actionDate = LocalDateTime.now();
this.actionDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
this.familyDetailsVerified = familyVerified;
this.familyDetailsJson = familyJson;
}
@@ -72,6 +80,6 @@ public class ElectionApprovalStep extends AbstractPersistableCustom<Long> {
this.approverUserId = approverUserId;
this.status = ApprovalStepStatus.REJECTED;
this.remarks = remarks;
this.actionDate = LocalDateTime.now();
this.actionDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
}
}
@@ -14,6 +14,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_audit_log")
@@ -63,6 +64,6 @@ public class ElectionAuditLog {
@PrePersist
void prePersist() {
if (createdAt == null) createdAt = LocalDateTime.now();
if (createdAt == null) createdAt = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
}
}
@@ -1,12 +1,19 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_candidate")
@@ -67,7 +74,7 @@ public class ElectionCandidate extends AbstractPersistableCustom<Long> {
candidate.candidateName = candidateName;
candidate.serialNumber = serialNumber;
candidate.approvedBy = approvedBy;
candidate.approvedDate = LocalDateTime.now();
candidate.approvedDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
candidate.isActive = true;
return candidate;
}
@@ -1,6 +1,13 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -8,6 +15,7 @@ import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_ceo_precheck")
@@ -152,13 +160,13 @@ public class ElectionCeoPrecheck extends AbstractPersistableCustom<Long> {
public void generateNoDueCertificate(String certificateNumber) {
this.noDueCertificateNumber = certificateNumber;
this.noDueGeneratedDate = LocalDateTime.now();
this.noDueGeneratedDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
this.noDueCheckResult = CheckResult.PASS;
}
public void finalise(Long checkedBy, String remarks) {
this.checkedBy = checkedBy;
this.checkedDate = LocalDateTime.now();
this.checkedDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
this.remarks = remarks;
// NDC is generated manually after pre-check; only automated checks determine overall result
boolean autoChecksPass = directorLoanCheckResult == CheckResult.PASS
@@ -1,6 +1,13 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -9,6 +16,7 @@ import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDa
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_config")
@@ -78,7 +86,7 @@ public class ElectionConfig extends AbstractAuditableWithUTCDateTimeCustom<Long>
}
public boolean isNominationOpen() {
LocalDate today = LocalDate.now();
LocalDate today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
return status == ElectionStatus.ACTIVE
&& !today.isBefore(nominationStartDate)
&& !today.isAfter(nominationEndDate);
@@ -1,12 +1,20 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_eligibility_check")
@@ -71,7 +79,7 @@ public class ElectionEligibilityCheck extends AbstractPersistableCustom<Long> {
public void complete(Long checkedBy, String remarks, boolean passed) {
this.checkedBy = checkedBy;
this.checkedDate = LocalDateTime.now();
this.checkedDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
this.remarks = remarks;
this.overallResult = passed ? CheckResult.PASS : CheckResult.FAIL;
this.ageEligible = passed;
@@ -1,6 +1,16 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -10,6 +20,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_nomination",
@@ -121,7 +132,7 @@ public class ElectionNomination extends AbstractAuditableWithUTCDateTimeCustom<L
public void submit(String applicationNumber) {
this.applicationNumber = applicationNumber;
this.status = NominationStatus.SUBMITTED;
this.submittedDate = LocalDateTime.now();
this.submittedDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
}
public void markUnderReview() {
@@ -1,6 +1,11 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -1,12 +1,18 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_result")
@@ -53,7 +59,7 @@ public class ElectionResult extends AbstractPersistableCustom<Long> {
r.result = result;
r.rankPosition = rankPosition;
r.declaredBy = declaredBy;
r.declaredDate = LocalDateTime.now();
r.declaredDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
return r;
}
}
@@ -1,12 +1,19 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_vote",
@@ -50,7 +57,7 @@ public class ElectionVote extends AbstractPersistableCustom<Long> {
vote.electionPost = post;
vote.voterMemberId = voterMemberId;
vote.candidate = candidate;
vote.voteTimestamp = LocalDateTime.now();
vote.voteTimestamp = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
vote.boothId = boothId;
vote.ipAddress = ipAddress;
return vote;
@@ -1,11 +1,19 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_meeting_agenda_resolution")
@@ -41,7 +49,7 @@ public class MeetingAgendaResolution {
r.agendaId = agendaId;
r.resolution = resolution;
r.discussionNotes = notes;
r.resolvedAt = LocalDateTime.now();
r.resolvedAt = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
return r;
}
}
@@ -1,11 +1,20 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_meeting_member_vote",
@@ -46,7 +55,7 @@ public class MeetingMemberVote {
v.agendaId = agendaId;
v.memberId = memberId;
v.vote = vote;
v.votedAt = LocalDateTime.now();
v.votedAt = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
v.remark = (remark != null && !remark.isBlank()) ? remark.trim() : null;
return v;
}
@@ -1,12 +1,16 @@
package org.apache.fineract.portfolio.election.domain;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.UUID;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_election_meeting_vote_token")
@@ -49,12 +53,12 @@ public class MeetingVoteToken {
t.memberName = memberName;
t.designation = designation;
t.used = false;
t.createdAt = LocalDateTime.now();
t.createdAt = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
t.expiresAt = t.createdAt.plusDays(validDays);
return t;
}
public boolean isExpired() {
return LocalDateTime.now().isAfter(expiresAt);
return LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).isAfter(expiresAt);
}
}
@@ -32,6 +32,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -215,7 +216,7 @@ public class CommitteeMeetingServiceImpl implements CommitteeMeetingService {
private String buildMeetingInviteHtml(String recipientName, String committeeName, CommitteeMeeting meeting, boolean isUpdate) {
DateTimeFormatter dateFmt = DateTimeFormatter.ofPattern("dd MMMM yyyy");
String sentAt = java.time.LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd MMM yyyy, hh:mm a"));
String sentAt = java.time.LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("dd MMM yyyy, hh:mm a"));
String dateStr = meeting.getMeetingDate() != null ? meeting.getMeetingDate().format(dateFmt) : "—";
String timeStr = meeting.getMeetingTime() != null ? meeting.getMeetingTime() : "—";
boolean isOnline = meeting.getMode() == CommitteeMeetingMode.ONLINE;
@@ -381,7 +382,7 @@ public class CommitteeMeetingServiceImpl implements CommitteeMeetingService {
if (date == null) {
throw new IllegalArgumentException("Meeting date is required");
}
if (date.isBefore(LocalDate.now())) {
if (date.isBefore(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()))) {
throw new IllegalArgumentException("Meeting date cannot be in the past");
}
}
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -132,7 +133,7 @@ public class CommitteeServiceImpl implements CommitteeService {
@Override
public List<DirectorAppointmentData> getCurrentElectionDirectors() {
var currentElection = electionConfigRepository.findFirstWithActiveDuration(LocalDate.now());
var currentElection = electionConfigRepository.findFirstWithActiveDuration(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
// fallback: most recent RESULT_DECLARED election if none has active duration
if (currentElection.isEmpty()) {
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -109,12 +110,12 @@ public class DirectorAppointmentServiceImpl implements DirectorAppointmentServic
@Transactional
@Scheduled(cron = "0 0 0 * * *")
public void autoExpireByTenure() {
int updated = repository.expireByTenureDate(LocalDate.now());
int updated = repository.expireByTenureDate(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
if (updated > 0) {
log.info("Auto-expired {} director appointment(s) whose tenure ended.", updated);
auditService.log(ElectionAuditAction.UPDATE_DIRECTOR_APPOINTMENT, "DIRECTOR_APPOINTMENT", null, null,
"Scheduler auto-expired " + updated + " director appointment(s)",
"expiredCount=" + updated + ", date=" + LocalDate.now(), null);
"expiredCount=" + updated + ", date=" + LocalDate.now(DateUtils.getDateTimeZoneOfTenant()), null);
}
}
@@ -126,7 +127,9 @@ public class DirectorAppointmentServiceImpl implements DirectorAppointmentServic
DirectorAppointmentStatus statusEnum = null;
if (status != null && !status.isBlank()) {
try { statusEnum = DirectorAppointmentStatus.valueOf(status.toUpperCase()); } catch (Exception ignored) {}
try { statusEnum = DirectorAppointmentStatus.valueOf(status.toUpperCase()); } catch (Exception ignored) {
// intentionally ignored
}
}
if (electionId != null && statusEnum != null) {
@@ -177,7 +180,9 @@ public class DirectorAppointmentServiceImpl implements DirectorAppointmentServic
if (req.getAppointmentDate() != null) d.setAppointmentDate(req.getAppointmentDate());
if (req.getRemarks() != null) d.setRemarks(req.getRemarks());
if (req.getStatus() != null) {
try { d.setStatus(DirectorAppointmentStatus.valueOf(req.getStatus().toUpperCase())); } catch (Exception ignored) {}
try { d.setStatus(DirectorAppointmentStatus.valueOf(req.getStatus().toUpperCase())); } catch (Exception ignored) {
// intentionally ignored
}
}
if (req.getCandidateName() != null) d.setCandidateName(req.getCandidateName());
if (req.getPostName() != null) d.setPostName(req.getPostName());
@@ -234,10 +239,6 @@ public class DirectorAppointmentServiceImpl implements DirectorAppointmentServic
return toData(d, null, null);
}
private DirectorAppointmentData toData(DirectorAppointment d, String electionTitle) {
return toData(d, electionTitle, null);
}
private DirectorAppointmentData toData(DirectorAppointment d, String electionTitle, Long memberId) {
return DirectorAppointmentData.builder()
.id(d.getId())
@@ -15,6 +15,7 @@ import java.time.Period;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -318,7 +319,7 @@ public class ElectionAnalyticsServiceImpl implements ElectionAnalyticsService {
Object dob = info.get("date_of_birth");
if (dob instanceof java.sql.Date) {
LocalDate dobDate = ((java.sql.Date) dob).toLocalDate();
candidateAge = Period.between(dobDate, LocalDate.now()).getYears();
candidateAge = Period.between(dobDate, LocalDate.now(DateUtils.getDateTimeZoneOfTenant())).getYears();
}
// ── Voter pool ─────────────────────────────────────────────────────────
@@ -16,6 +16,7 @@ import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -104,7 +105,7 @@ public class ElectionCeoPreCheckServiceImpl implements ElectionCeoPreCheckServic
if (status == null || status != 300) {
String label = statusLabel(status);
precheck.completeKycCheck(CheckResult.FAIL, "KYC not verified (status: " + label + ")");
} else if (expiry != null && expiry.isBefore(LocalDate.now())) {
} else if (expiry != null && expiry.isBefore(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()))) {
precheck.completeKycCheck(CheckResult.FAIL, "KYC expired on " + expiry);
} else {
String expiryNote = expiry != null ? ", expires " + expiry : "";
@@ -155,7 +156,7 @@ public class ElectionCeoPreCheckServiceImpl implements ElectionCeoPreCheckServic
issues.add(name + ": No KYC record");
} else if (status != 300) {
issues.add(name + ": KYC not verified (" + statusLabel(status) + ")");
} else if (expiry != null && expiry.isBefore(LocalDate.now())) {
} else if (expiry != null && expiry.isBefore(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()))) {
issues.add(name + ": KYC expired on " + expiry);
}
}
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -18,7 +19,7 @@ public class ElectionNoDueCertificateServiceImpl implements ElectionNoDueCertifi
@Override
public String generateCertificateNumber(ElectionNomination nomination) {
String datePart = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String datePart = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern("yyyyMMdd"));
return "NDC-" + datePart + "-" + String.format("%06d", nomination.getId());
}
@@ -36,6 +36,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -315,7 +316,7 @@ public class ElectionReadPlatformServiceImpl implements ElectionReadPlatformServ
private ElectionNominationData toNominationData(ElectionNomination n) {
Integer age = null;
if (n.getDateOfBirth() != null) {
age = Period.between(n.getDateOfBirth(), LocalDate.now()).getYears();
age = Period.between(n.getDateOfBirth(), LocalDate.now(DateUtils.getDateTimeZoneOfTenant())).getYears();
}
return ElectionNominationData.builder()
.id(n.getId())
@@ -25,7 +25,6 @@ import org.apache.fineract.portfolio.election.domain.ElectionResult;
import org.apache.fineract.portfolio.election.domain.ElectionResultRepository;
import org.apache.fineract.portfolio.election.domain.ElectionStatus;
import org.apache.fineract.portfolio.election.domain.ElectionType;
import org.apache.fineract.portfolio.election.domain.ElectionVote;
import org.apache.fineract.portfolio.election.domain.ElectionVoteRepository;
import org.apache.fineract.portfolio.election.domain.NominationStatus;
import org.apache.fineract.portfolio.election.exception.ElectionAlreadyOngoingException;
@@ -36,7 +35,6 @@ import org.apache.fineract.portfolio.election.exception.ElectionNominationNotFou
import org.apache.fineract.portfolio.election.exception.ElectionNotActiveException;
import org.apache.fineract.portfolio.election.exception.InvalidNominationStateException;
import org.apache.fineract.portfolio.election.exception.NominationAlreadyExistsException;
import org.apache.fineract.portfolio.election.exception.VoteAlreadyCastException;
import org.apache.fineract.portfolio.election.exception.VoteCountExceedsShareAccountsException;
import org.apache.fineract.portfolio.election.exception.VoteCountsNotSavedException;
import org.apache.fineract.infrastructure.contentstore.service.ContentStoreService;
@@ -49,6 +47,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -93,7 +92,7 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
throw new ElectionAlreadyOngoingException();
}
electionConfigRepository.findFirstWithActiveDuration(LocalDate.now()).ifPresent(prev -> {
electionConfigRepository.findFirstWithActiveDuration(LocalDate.now(DateUtils.getDateTimeZoneOfTenant())).ifPresent(prev -> {
LocalDate expiryDate = prev.getElectionDate().plusYears(prev.getDurationYears());
throw new ElectionDurationActiveException(expiryDate);
});
@@ -158,7 +157,7 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
context.authenticatedUser().validateHasPermissionTo("UPDATE_ELECTION");
ElectionConfig election = electionConfigRepository.findById(electionId)
.orElseThrow(() -> new ElectionNotFoundException(electionId));
if (LocalDate.now().isBefore(election.getNominationEndDate())) {
if (LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).isBefore(election.getNominationEndDate())) {
throw new ElectionDateViolationException(
"Cannot close nominations before the nomination end date " + election.getNominationEndDate());
}
@@ -172,7 +171,7 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
context.authenticatedUser().validateHasPermissionTo("UPDATE_ELECTION");
ElectionConfig election = electionConfigRepository.findById(electionId)
.orElseThrow(() -> new ElectionNotFoundException(electionId));
if (LocalDate.now().isBefore(election.getElectionDate())) {
if (LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).isBefore(election.getElectionDate())) {
throw new ElectionDateViolationException(
"Cannot open voting before election date " + election.getElectionDate());
}
@@ -187,7 +186,7 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
ElectionConfig election = electionConfigRepository.findById(electionId)
.orElseThrow(() -> new ElectionNotFoundException(electionId));
if (LocalDate.now().isBefore(election.getElectionDate())) {
if (LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).isBefore(election.getElectionDate())) {
throw new ElectionDateViolationException(
"Cannot close voting before election date " + election.getElectionDate());
}
@@ -273,7 +272,7 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
throw new InvalidNominationStateException("withdraw", nomination.getStatus().name());
}
ElectionConfig election = nomination.getElectionConfig();
if (LocalDate.now().isAfter(election.getNominationEndDate())) {
if (LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).isAfter(election.getNominationEndDate())) {
throw new ElectionDateViolationException(
"Nomination withdrawal period has ended. Nominations closed on " + election.getNominationEndDate());
}
@@ -290,7 +289,7 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
throw new InvalidNominationStateException("resubmit", nomination.getStatus().name());
}
ElectionConfig election = nomination.getElectionConfig();
if (LocalDate.now().isAfter(election.getNominationEndDate())) {
if (LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).isAfter(election.getNominationEndDate())) {
throw new ElectionDateViolationException(
"Nomination resubmission period has ended. Nominations closed on " + election.getNominationEndDate());
}
@@ -466,7 +465,9 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
String symbol = candidate.getSymbol();
if (symbol != null && !symbol.startsWith("data:") && symbol.contains("|")) {
try { contentStoreService.delete(symbol.split("\\|", 2)[1]); } catch (Exception ignored) {}
try { contentStoreService.delete(symbol.split("\\|", 2)[1]); } catch (Exception ignored) {
// intentionally ignored
}
}
candidate.deactivate();
@@ -584,7 +585,7 @@ public class ElectionWritePlatformServiceImpl implements ElectionWritePlatformSe
ElectionConfig election = electionConfigRepository.findById(electionId)
.orElseThrow(() -> new ElectionNotFoundException(electionId));
LocalDate today = LocalDate.now();
LocalDate today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
LocalDate effectiveDate = election.getResultDate() != null ? election.getResultDate() : election.getElectionDate();
if (today.isBefore(effectiveDate)) {
throw new ElectionDateViolationException(
@@ -5,14 +5,41 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.email.service.EmailSenderService;
import org.springframework.beans.factory.annotation.Value;
import org.apache.fineract.portfolio.client.domain.ClientRepository;
import org.apache.fineract.portfolio.election.data.*;
import org.apache.fineract.portfolio.election.domain.*;
import org.apache.fineract.portfolio.election.data.AgendaResolutionRequest;
import org.apache.fineract.portfolio.election.data.AgendaVoteRequest;
import org.apache.fineract.portfolio.election.data.AgendaVoteSummaryData;
import org.apache.fineract.portfolio.election.data.MeetingVoteSubmitRequest;
import org.apache.fineract.portfolio.election.data.MeetingVotingPageData;
import org.apache.fineract.portfolio.election.domain.AgendaResolution;
import org.apache.fineract.portfolio.election.domain.AgendaVote;
import org.apache.fineract.portfolio.election.domain.Committee;
import org.apache.fineract.portfolio.election.domain.CommitteeMeeting;
import org.apache.fineract.portfolio.election.domain.CommitteeMeetingAgenda;
import org.apache.fineract.portfolio.election.domain.CommitteeMeetingRepository;
import org.apache.fineract.portfolio.election.domain.CommitteeMember;
import org.apache.fineract.portfolio.election.domain.CommitteeMemberRepository;
import org.apache.fineract.portfolio.election.domain.CommitteeRepository;
import org.apache.fineract.portfolio.election.domain.DirectorAppointment;
import org.apache.fineract.portfolio.election.domain.DirectorAppointmentRepository;
import org.apache.fineract.portfolio.election.domain.ElectionCandidate;
import org.apache.fineract.portfolio.election.domain.ElectionCandidateRepository;
import org.apache.fineract.portfolio.election.domain.MeetingAgendaResolution;
import org.apache.fineract.portfolio.election.domain.MeetingAgendaResolutionRepository;
import org.apache.fineract.portfolio.election.domain.MeetingMemberVote;
import org.apache.fineract.portfolio.election.domain.MeetingMemberVoteRepository;
import org.apache.fineract.portfolio.election.domain.MeetingVoteToken;
import org.apache.fineract.portfolio.election.domain.MeetingVoteTokenRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Slf4j
@Service
@@ -289,7 +316,7 @@ public class MeetingVoteService {
String baseUrl = frontendBaseUrl + "/#/vote/" + token;
String dateStr = meeting.getMeetingDate() != null
? meeting.getMeetingDate().format(DateTimeFormatter.ofPattern("dd MMMM yyyy")) : "—";
String sentAt = java.time.LocalDateTime.now()
String sentAt = java.time.LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant())
.format(DateTimeFormatter.ofPattern("dd MMM yyyy, hh:mm a"));
StringBuilder sb = new StringBuilder();
@@ -397,7 +424,7 @@ public class MeetingVoteService {
Map<Long, MeetingAgendaResolution> resMap) {
String dateStr = meeting.getMeetingDate() != null
? meeting.getMeetingDate().format(DateTimeFormatter.ofPattern("dd MMMM yyyy")) : "—";
String sentAt = java.time.LocalDateTime.now()
String sentAt = java.time.LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant())
.format(DateTimeFormatter.ofPattern("dd MMM yyyy, hh:mm a"));
StringBuilder sb = new StringBuilder();
@@ -31,6 +31,7 @@ import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/** Append-only audit row per state transition on a {@link FundTransfer}. */
@Entity
@@ -76,7 +77,7 @@ public class FundTransferEvent {
e.toStatus = to;
e.event = event;
e.payloadJson = payloadJson;
e.createdAt = LocalDateTime.now();
e.createdAt = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
e.createdBy = createdBy;
return e;
}
@@ -31,6 +31,7 @@ import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Short-lived token issued at /v1/transfers/verify and redeemed at
@@ -97,6 +98,6 @@ public class VerificationToken {
private Long redeemedFundTransferId;
public boolean isExpired() {
return LocalDateTime.now().isAfter(expiresAt);
return LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).isAfter(expiresAt);
}
}
@@ -54,6 +54,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Service
@RequiredArgsConstructor
@@ -85,7 +86,7 @@ public class FundTransferWritePlatformServiceImpl implements FundTransferWritePl
throw new IllegalArgumentException("amount must be > 0");
}
TransferChannel channel = TransferChannel.from(request.getChannel());
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
windowValidator.requireOpen(channel, LocalTime.from(now), now.getDayOfWeek());
AppUser cashier = context.authenticatedUser();
@@ -157,7 +158,7 @@ public class FundTransferWritePlatformServiceImpl implements FundTransferWritePl
transfer.setPayeeMaskName(token.getPayeeMaskName());
transfer.setAmount(token.getAmount());
transfer.setRemarks(remarks);
transfer.setInitiatedAt(LocalDateTime.now());
transfer.setInitiatedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
if (!needsApproval) {
executeStrategy(transfer);
@@ -210,7 +211,7 @@ public class FundTransferWritePlatformServiceImpl implements FundTransferWritePl
t.setStatus(FundTransferStatus.FAILED);
t.setResponseCode("REJ");
t.setResponseMessage(reason);
t.setSettledAt(LocalDateTime.now());
t.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
FundTransfer saved = fundTransferRepository.save(t);
eventRepository.save(FundTransferEvent.of(saved.getId(), prev, saved.getStatus(), "REJECTED", reason, approver.getId()));
return FundTransferReadPlatformServiceImpl.toData(saved);
@@ -235,7 +236,7 @@ public class FundTransferWritePlatformServiceImpl implements FundTransferWritePl
t.setStatus(FundTransferStatus.REVERSED);
t.setResponseCode("RCL");
t.setResponseMessage(reason == null ? "Recall initiated by ops" : reason);
t.setSettledAt(LocalDateTime.now());
t.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
FundTransfer saved = fundTransferRepository.save(t);
String payload = "reason=" + reason + ", switch=" + switchOutcome;
eventRepository.save(FundTransferEvent.of(saved.getId(), prev, saved.getStatus(), "RECALLED", payload, actor.getId()));
@@ -290,7 +291,7 @@ public class FundTransferWritePlatformServiceImpl implements FundTransferWritePl
transfer.setStatus(FundTransferStatus.FAILED);
transfer.setResponseCode("ERR");
transfer.setResponseMessage(ex.getMessage());
transfer.setSettledAt(LocalDateTime.now());
transfer.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
}
if (transfer.getDirection() == TransferDirection.OFF_US && suspenseLegId != null
@@ -362,6 +363,7 @@ public class FundTransferWritePlatformServiceImpl implements FundTransferWritePl
* Masks a display name to the IMPS RespValAdd convention: first letter of each
* word kept, rest replaced with up to 5 asterisks. "John Doe" → "J*** D**".
*/
@SuppressWarnings("StringSplitter")
static String maskName(String displayName) {
if (displayName == null || displayName.isBlank()) {
return null;
@@ -409,7 +411,7 @@ public class FundTransferWritePlatformServiceImpl implements FundTransferWritePl
if (limits.getPerDayMax() == null) {
return;
}
LocalDateTime startOfDay = LocalDate.now().atStartOfDay();
LocalDateTime startOfDay = LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).atStartOfDay();
BigDecimal already = fundTransferRepository.sumActiveOnChannelSince(payerAccountId, channel, startOfDay);
if (already.add(amount).compareTo(limits.getPerDayMax()) > 0) {
throw new IllegalStateException("daily limit exhausted for channel " + channel + " — already " + already
@@ -34,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Polls the IMPS switch for DEEMED transfers (responseCode=91) to resolve them
@@ -62,7 +63,7 @@ public class ImpsDeemedReconciliationService {
/** Picks all DEEMED rows in the window and tries to resolve each. Returns count touched. */
public int reconcileAll() {
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
LocalDateTime floor = now.minusHours(MAX_AGE_HOURS);
LocalDateTime ceiling = now.minusSeconds(MIN_AGE_SECONDS);
List<FundTransfer> deemed = fundTransferRepository.findDeemedNeedingReconciliation(floor, ceiling);
@@ -107,7 +108,7 @@ public class ImpsDeemedReconciliationService {
if (resp.getUtr() != null) {
transfer.setUtr(resp.getUtr());
}
transfer.setSettledAt(LocalDateTime.now());
transfer.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
if (newStatus == FundTransferStatus.FAILED) {
suspenseGl.reverseFromSuspense(transfer);
}
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Processes a NEFT batch cycle: picks all rows in QUEUED, sends each to the
@@ -100,7 +101,7 @@ public class NeftBatchProcessorService {
t.setSwitchTxnId(resp.getTxnId() == null ? t.getTxnRef() : resp.getTxnId());
t.setUtr(resp.getUtr());
if (mapped != FundTransferStatus.DEEMED) {
t.setSettledAt(LocalDateTime.now());
t.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
}
if (mapped == FundTransferStatus.FAILED) {
suspenseGl.reverseFromSuspense(t);
@@ -114,7 +115,7 @@ public class NeftBatchProcessorService {
t.setStatus(FundTransferStatus.FAILED);
t.setResponseCode("ERR");
t.setResponseMessage(ex.getMessage());
t.setSettledAt(LocalDateTime.now());
t.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
suspenseGl.reverseFromSuspense(t);
fundTransferRepository.save(t);
eventRepository.save(FundTransferEvent.of(t.getId(), prev, FundTransferStatus.FAILED,
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Moves money between the customer's savings account and the bank's "in transit"
@@ -129,7 +130,7 @@ public class SuspenseGlService {
}
private Long move(Long fromAccountId, Long toAccountId, FundTransfer t, String description) {
AccountTransferDTO dto = new AccountTransferDTO(LocalDate.now(), t.getAmount(), PortfolioAccountType.SAVINGS,
AccountTransferDTO dto = new AccountTransferDTO(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()), t.getAmount(), PortfolioAccountType.SAVINGS,
PortfolioAccountType.SAVINGS, fromAccountId, toAccountId, description, null, null, null, null, null, null, null,
AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, ExternalId.empty(), null, null, null,
Boolean.TRUE, Boolean.FALSE);
@@ -72,6 +72,7 @@ public class TransferChannelWindowValidator {
}
}
@SuppressWarnings("StringSplitter")
private static boolean isHourInWindow(LocalTime now, String spec) {
if (spec == null || spec.isBlank()) {
return true;
@@ -86,6 +87,7 @@ public class TransferChannelWindowValidator {
return hour >= start && hour < end;
}
@SuppressWarnings("StringSplitter")
private static boolean isDayInWindow(DayOfWeek now, String spec) {
if (spec == null || spec.isBlank()) {
return true;
@@ -29,6 +29,7 @@ import org.apache.fineract.portfolio.fundtransfer.domain.TransferChannel;
import org.apache.fineract.portfolio.fundtransfer.domain.TransferLimitConfig;
import org.apache.fineract.portfolio.fundtransfer.domain.TransferLimitConfigRepository;
import org.springframework.stereotype.Service;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Resolves effective per-customer-per-channel limits by overlaying any
@@ -47,7 +48,7 @@ public class TransferLimitResolver {
.orElseThrow(() -> new IllegalStateException(
"No active m_transfer_limit_config for channel " + channel + " — seed missing?"));
Optional<CustomerTransferLimit> override = customerRepository.findEffective(clientId, channel, LocalDate.now());
Optional<CustomerTransferLimit> override = customerRepository.findEffective(clientId, channel, LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
BigDecimal perTxnMax = override.map(CustomerTransferLimit::getPerTxnMax).orElse(null);
if (perTxnMax == null) {
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* Two-phase cleanup of {@code m_verification_token}:
@@ -51,7 +52,7 @@ public class VerificationTokenCleanupService {
@Transactional
public CleanupResult cleanup() {
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
int expired = repository.markExpired(now);
int deleted = repository.deleteTerminalOlderThan(now.minusHours(retentionHours));
log.info("[VerificationTokenCleanup] flipped {} → EXPIRED, deleted {} terminal token(s) older than {}h",
@@ -29,6 +29,7 @@ import org.apache.fineract.portfolio.fundtransfer.domain.VerificationTokenReposi
import org.apache.fineract.portfolio.fundtransfer.domain.VerificationTokenStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/** Issues + redeems verification tokens (the BANL → debit bridge). */
@Service
@@ -56,7 +57,7 @@ public class VerificationTokenService {
t.setPayeeMaskName(payeeMaskName);
t.setAmount(amount);
t.setStatus(VerificationTokenStatus.ISSUED);
t.setIssuedAt(LocalDateTime.now());
t.setIssuedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
t.setExpiresAt(t.getIssuedAt().plusSeconds(TTL_SECONDS));
return repository.save(t);
}
@@ -78,7 +79,7 @@ public class VerificationTokenService {
@Transactional
public void markRedeemed(VerificationToken t, Long fundTransferId) {
t.setStatus(VerificationTokenStatus.REDEEMED);
t.setRedeemedAt(LocalDateTime.now());
t.setRedeemedAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
t.setRedeemedFundTransferId(fundTransferId);
repository.save(t);
}
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* IMPS outward via LincPay's ReqPay endpoint. Maps the IMPS response code to
@@ -64,7 +65,7 @@ public class ImpsOutwardStrategy implements TransferStrategy {
transfer.setStatus(FundTransferStatus.FAILED);
transfer.setResponseCode("ERR");
transfer.setResponseMessage(ex.getMessage());
transfer.setSettledAt(LocalDateTime.now());
transfer.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
}
}
@@ -106,7 +107,7 @@ public class ImpsOutwardStrategy implements TransferStrategy {
};
transfer.setStatus(mapped);
if (mapped != FundTransferStatus.DEEMED) {
transfer.setSettledAt(LocalDateTime.now());
transfer.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
}
log.info("[ImpsOutwardStrategy] txnRef={} responseCode={} → status={} utr={}",
transfer.getTxnRef(), code, mapped, transfer.getUtr());
@@ -33,6 +33,7 @@ import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* On-us settlement — debits payer + credits payee atomically via Fineract's
@@ -54,7 +55,7 @@ public class InternalTransferStrategy implements TransferStrategy {
SavingsAccount payee = payeeLookup.findByAccountNumber(transfer.getPayeeAccountNumber()).orElseThrow(
() -> new IllegalStateException("Payee account vanished between verify and debit: " + transfer.getPayeeAccountNumber()));
AccountTransferDTO dto = new AccountTransferDTO(LocalDate.now(), transfer.getAmount(), PortfolioAccountType.SAVINGS,
AccountTransferDTO dto = new AccountTransferDTO(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()), transfer.getAmount(), PortfolioAccountType.SAVINGS,
PortfolioAccountType.SAVINGS, transfer.getPayerAccountId(), payee.getId(),
buildDescription(transfer), null, null, null, null, null, null, null,
AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, ExternalId.empty(), null, null, null,
@@ -68,7 +69,7 @@ public class InternalTransferStrategy implements TransferStrategy {
transfer.setStatus(FundTransferStatus.SUCCESS);
transfer.setResponseCode("00");
transfer.setResponseMessage("Internal transfer settled");
transfer.setSettledAt(LocalDateTime.now());
transfer.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
}
private static String buildDescription(FundTransfer t) {
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/**
* RTGS outward — realtime, same shape as IMPS but routed to {@code /RTGS/ReqPay}.
@@ -61,7 +62,7 @@ public class RtgsOutwardStrategy implements TransferStrategy {
transfer.setStatus(FundTransferStatus.FAILED);
transfer.setResponseCode("ERR");
transfer.setResponseMessage(ex.getMessage());
transfer.setSettledAt(LocalDateTime.now());
transfer.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
}
}
@@ -103,7 +104,7 @@ public class RtgsOutwardStrategy implements TransferStrategy {
};
transfer.setStatus(mapped);
if (mapped != FundTransferStatus.DEEMED) {
transfer.setSettledAt(LocalDateTime.now());
transfer.setSettledAt(LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
}
log.info("[RtgsOutwardStrategy] txnRef={} responseCode={} → status={} utr={}",
transfer.getTxnRef(), code, mapped, transfer.getUtr());
@@ -30,7 +30,6 @@ import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import java.io.InputStream;
import java.util.HashMap;
@@ -40,7 +40,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
@@ -55,6 +54,7 @@ import org.apache.fineract.portfolio.savings.DepositsApiConstants;
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Path("/v1/currentaccounts/{accountId}/transactions")
@Component
@@ -91,7 +91,7 @@ public class CurrentAccountTransactionsApiResource {
try {
template = jdbcTemplate.queryForObject(sql, (rs, rowNum) -> {
final Map<String, Object> map = new LinkedHashMap<>();
final LocalDate today = LocalDate.now();
final LocalDate today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
map.put("date", new int[] { today.getYear(), today.getMonthValue(), today.getDayOfMonth() });
final Map<String, Object> currency = new LinkedHashMap<>();
@@ -37,7 +37,6 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.UriInfo;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
@@ -20,6 +20,7 @@ import jakarta.persistence.Table;
import java.time.LocalDate;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_cbs_base_interest_rate_effective")
@@ -64,7 +65,7 @@ public class FdBaseInterestRateEffective {
e.isActive = true;
e.remarks = remarks;
e.createdById = createdById;
e.createdDate = LocalDate.now();
e.createdDate = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
return e;
}
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_cbs_base_interest_rate_slab_history")
@@ -70,7 +71,7 @@ public class FdBaseInterestRateSlabHistory {
s.toPeriod = toPeriod;
s.annualInterestRate = annualInterestRate;
s.seniorCitizenRate = seniorCitizenRate;
s.createdDate = LocalDate.now();
s.createdDate = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
return s;
}
}
@@ -20,6 +20,7 @@ import jakarta.persistence.Table;
import java.time.LocalDate;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_rd_base_interest_rate_effective")
@@ -59,7 +60,7 @@ public class RdBaseInterestRateEffective {
e.isActive = true;
e.remarks = remarks;
e.createdById = createdById;
e.createdDate = LocalDate.now();
e.createdDate = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
return e;
}

Some files were not shown because too many files have changed in this diff Show More