You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2020/02/21 11:05:37 UTC

[GitHub] [fineract] Ippezrobert commented on a change in pull request #714: Allow Using Custom Tenant date from database (Custom Requirement)

Ippezrobert commented on a change in pull request #714: Allow Using Custom Tenant date from database (Custom Requirement)
URL: https://github.com/apache/fineract/pull/714#discussion_r382523934
 
 

 ##########
 File path: fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java
 ##########
 @@ -59,28 +64,50 @@ public static Date getDateOfTenant() {
         return getLocalDateOfTenant().toDateTimeAtStartOfDay().toDate();
     }
 
-    public static LocalDate getLocalDateOfTenant() {
-
-        LocalDate today = new LocalDate();
-
+public static LocalDate getLocalDateOfTenant() {
+		SecurityContext context = SecurityContextHolder.getContext();
+        Authentication authentication = null;
+		LocalDate today = new LocalDate();
+		
+        if(context != null) {
+            authentication = context.getAuthentication();
+        }
+        if(authentication != null && authentication.isAuthenticated() && authentication.getPrincipal() instanceof AppUser) {
+            AppUser user = (AppUser) authentication.getPrincipal();
+			final Long officeId = user.getOffice().getId();
+			today = new LocalDate(OfficeRepository.getCurrentDateOfTenant(officeId));
 
 Review comment:
   Am getting error here 
   
   > error: non-static method getCurrentDateOfTenant(Long) cannot be referenced from a static context
   >                         today = new LocalDate(OfficeRepository.getCurrentDateOfTenant(officeId));

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services