MokuLakshithReddy commented on code in PR #155:
URL: 
https://github.com/apache/fineract-consumer-facing/pull/155#discussion_r4371474692


##########
consumer/src/main/java/org/apache/fineract/consumer/savings/command/service/SavingsCommandServiceImpl.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fineract.consumer.savings.command.service;
+
+import java.time.LocalDate;
+import java.util.Set;
+import java.util.UUID;
+import java.util.function.Supplier;
+import lombok.RequiredArgsConstructor;
+import org.apache.fineract.consumer.infrastructure.access.data.ConsumerAction;
+import 
org.apache.fineract.consumer.infrastructure.access.service.AccessPolicyEvaluator;
+import 
org.apache.fineract.consumer.infrastructure.access.service.OwnedAccountsCache;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.EnumOptionData;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsAccountIdRequest;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsAccountIdResponse;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsRequest;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsResponse;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PutSavingsAccountsAccountIdRequest;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PutSavingsAccountsAccountIdResponse;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.SavingsAccountData;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.service.FineractCaller;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.service.SavingsAccountApiClient;
+import 
org.apache.fineract.consumer.infrastructure.idempotency.service.IdempotencyKeyDeriver;
+import 
org.apache.fineract.consumer.infrastructure.idempotency.service.IdempotencyKeyHolder;
+import 
org.apache.fineract.consumer.savings.command.data.ModifySavingsApplicationCommand;
+import 
org.apache.fineract.consumer.savings.command.data.SavingsApplicationCommandData;
+import 
org.apache.fineract.consumer.savings.command.data.SubmitSavingsApplicationCommand;
+import 
org.apache.fineract.consumer.savings.command.data.WithdrawSavingsApplicationCommand;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsApplicationInvalidException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandAccessDeniedException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandInProgressException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandNotFoundException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandUpstreamUnavailableException;
+import org.apache.fineract.consumer.user.query.data.UserQueryData;
+import org.apache.fineract.consumer.user.query.service.UserQueryService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.oauth2.jwt.Jwt;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class SavingsCommandServiceImpl implements SavingsCommandService {
+
+    private static final String LOCALE = "en";
+    private static final String DATE_FORMAT = "yyyy-MM-dd";
+    private static final Long SAVINGS_DEPOSIT_TYPE_ID = 100L;
+
+    @Value("${consumer.savings.command.allowed-product-ids:}")
+    private Set<Long> allowedProductIds;
+
+    private final UserQueryService userQueryService;
+    private final AccessPolicyEvaluator accessPolicyEvaluator;
+    private final OwnedAccountsCache ownedAccountsCache;
+    private final IdempotencyKeyHolder idempotencyKeyHolder;
+    private final SavingsAccountApiClient savingsAccountApiClient;
+
+    @Override
+    public SavingsApplicationCommandData submitApplication(Jwt jwt, 
SubmitSavingsApplicationCommand command) {
+        accessPolicyEvaluator.authorize(jwt, 
ConsumerAction.SAVINGS_APPLICATION_SUBMIT);
+        validateProductAllowList(command.getProductId());
+        Long clientId = resolveClientId(jwt);
+        LocalDate submittedOnDate = LocalDate.now();
+        PostSavingsAccountsRequest request = buildSubmitRequest(command, 
clientId, submittedOnDate);
+        PostSavingsAccountsResponse response = callWithIdempotency(jwt, 
command.getIdempotencyKey(),
+                () -> 
savingsAccountApiClient.submitSavingsApplication(request));
+        ownedAccountsCache.evict(clientId);
+        return SavingsApplicationCommandData.builder()
+                .savingsId(response.getSavingsId())
+                .resourceId(response.getResourceId())
+                .clientId(clientId)
+                .build();
+    }
+
+    @Override
+    public SavingsApplicationCommandData modifyApplication(Jwt jwt, 
ModifySavingsApplicationCommand command) {
+        accessPolicyEvaluator.authorize(jwt, 
ConsumerAction.SAVINGS_APPLICATION_MODIFY, command.getSavingsId(),
+                SavingsCommandAccessDeniedException::new);
+        validateProductAllowList(command.getProductId());
+        validateSavingsDepositType(command.getSavingsId());

Review Comment:
   Updated to pass explicit ZoneOffset.UTC (LocalDate.now(ZoneOffset.UTC)) 
across all application command flows to eliminate the [JavaTimeDefaultTimeZone] 
warning.



##########
consumer/src/main/java/org/apache/fineract/consumer/savings/command/service/SavingsCommandServiceImpl.java:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fineract.consumer.savings.command.service;
+
+import java.time.LocalDate;
+import java.util.Set;
+import java.util.UUID;
+import java.util.function.Supplier;
+import lombok.RequiredArgsConstructor;
+import org.apache.fineract.consumer.infrastructure.access.data.ConsumerAction;
+import 
org.apache.fineract.consumer.infrastructure.access.service.AccessPolicyEvaluator;
+import 
org.apache.fineract.consumer.infrastructure.access.service.OwnedAccountsCache;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.EnumOptionData;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsAccountIdRequest;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsAccountIdResponse;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsRequest;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PostSavingsAccountsResponse;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PutSavingsAccountsAccountIdRequest;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.PutSavingsAccountsAccountIdResponse;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.generated.model.SavingsAccountData;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.service.FineractCaller;
+import 
org.apache.fineract.consumer.infrastructure.fineractclient.service.SavingsAccountApiClient;
+import 
org.apache.fineract.consumer.infrastructure.idempotency.service.IdempotencyKeyDeriver;
+import 
org.apache.fineract.consumer.infrastructure.idempotency.service.IdempotencyKeyHolder;
+import 
org.apache.fineract.consumer.savings.command.data.ModifySavingsApplicationCommand;
+import 
org.apache.fineract.consumer.savings.command.data.SavingsApplicationCommandData;
+import 
org.apache.fineract.consumer.savings.command.data.SubmitSavingsApplicationCommand;
+import 
org.apache.fineract.consumer.savings.command.data.WithdrawSavingsApplicationCommand;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsApplicationInvalidException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandAccessDeniedException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandInProgressException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandNotFoundException;
+import 
org.apache.fineract.consumer.savings.command.exception.SavingsCommandUpstreamUnavailableException;
+import org.apache.fineract.consumer.user.query.data.UserQueryData;
+import org.apache.fineract.consumer.user.query.service.UserQueryService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.oauth2.jwt.Jwt;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class SavingsCommandServiceImpl implements SavingsCommandService {
+
+    private static final String LOCALE = "en";
+    private static final String DATE_FORMAT = "yyyy-MM-dd";
+    private static final Long SAVINGS_DEPOSIT_TYPE_ID = 100L;
+
+    @Value("${consumer.savings.command.allowed-product-ids:}")
+    private Set<Long> allowedProductIds;
+
+    private final UserQueryService userQueryService;
+    private final AccessPolicyEvaluator accessPolicyEvaluator;
+    private final OwnedAccountsCache ownedAccountsCache;
+    private final IdempotencyKeyHolder idempotencyKeyHolder;
+    private final SavingsAccountApiClient savingsAccountApiClient;
+
+    @Override
+    public SavingsApplicationCommandData submitApplication(Jwt jwt, 
SubmitSavingsApplicationCommand command) {
+        accessPolicyEvaluator.authorize(jwt, 
ConsumerAction.SAVINGS_APPLICATION_SUBMIT);
+        validateProductAllowList(command.getProductId());
+        Long clientId = resolveClientId(jwt);
+        LocalDate submittedOnDate = LocalDate.now();
+        PostSavingsAccountsRequest request = buildSubmitRequest(command, 
clientId, submittedOnDate);
+        PostSavingsAccountsResponse response = callWithIdempotency(jwt, 
command.getIdempotencyKey(),
+                () -> 
savingsAccountApiClient.submitSavingsApplication(request));
+        ownedAccountsCache.evict(clientId);
+        return SavingsApplicationCommandData.builder()
+                .savingsId(response.getSavingsId())
+                .resourceId(response.getResourceId())
+                .clientId(clientId)
+                .build();
+    }
+
+    @Override
+    public SavingsApplicationCommandData modifyApplication(Jwt jwt, 
ModifySavingsApplicationCommand command) {
+        accessPolicyEvaluator.authorize(jwt, 
ConsumerAction.SAVINGS_APPLICATION_MODIFY, command.getSavingsId(),
+                SavingsCommandAccessDeniedException::new);
+        validateProductAllowList(command.getProductId());
+        validateSavingsDepositType(command.getSavingsId());
+        Long clientId = resolveClientId(jwt);
+        LocalDate submittedOnDate = LocalDate.now();
+        PutSavingsAccountsAccountIdRequest request = 
buildModifyRequest(command, submittedOnDate);
+        PutSavingsAccountsAccountIdResponse response = 
callWithIdempotency(jwt, command.getIdempotencyKey(),
+                () -> 
savingsAccountApiClient.updateSavingsAccount(command.getSavingsId(), request, 
null));
+        return SavingsApplicationCommandData.builder()
+                .savingsId(command.getSavingsId())
+                .resourceId(response.getResourceId())
+                .clientId(clientId)
+                .build();
+    }
+
+    @Override
+    public SavingsApplicationCommandData withdrawApplication(Jwt jwt, 
WithdrawSavingsApplicationCommand command) {
+        accessPolicyEvaluator.authorize(jwt, 
ConsumerAction.SAVINGS_APPLICATION_WITHDRAW, command.getSavingsId(),
+                SavingsCommandAccessDeniedException::new);
+        validateSavingsDepositType(command.getSavingsId());
+        Long clientId = resolveClientId(jwt);
+        LocalDate withdrawnOnDate = LocalDate.now();

Review Comment:
   Updated to LocalDate.now(ZoneOffset.UTC) here as well.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to