|
33 | 33 | import it.gov.pagopa.idpay.transactions.utils.ExceptionConstants.ExceptionCode; |
34 | 34 | import it.gov.pagopa.idpay.transactions.utils.ExceptionConstants.ExceptionMessage; |
35 | 35 | import it.gov.pagopa.idpay.transactions.utils.Utilities; |
36 | | -import java.time.LocalDate; |
37 | 36 | import lombok.Data; |
38 | 37 | import lombok.extern.slf4j.Slf4j; |
39 | 38 | import org.springframework.dao.DuplicateKeyException; |
40 | 39 | import org.springframework.data.domain.Page; |
41 | 40 | import org.springframework.data.domain.PageImpl; |
42 | 41 | import org.springframework.data.domain.Pageable; |
| 42 | +import org.springframework.data.mongodb.core.ReactiveMongoTemplate; |
43 | 43 | import org.springframework.data.mongodb.core.query.Criteria; |
44 | 44 | import org.springframework.data.mongodb.core.query.Query; |
45 | | -import org.springframework.data.mongodb.core.ReactiveMongoTemplate; |
46 | 45 | import org.springframework.http.HttpStatus; |
47 | 46 | import org.springframework.scheduling.annotation.Scheduled; |
48 | 47 | import org.springframework.stereotype.Service; |
|
54 | 53 | import java.io.InputStream; |
55 | 54 | import java.nio.charset.StandardCharsets; |
56 | 55 | import java.text.NumberFormat; |
| 56 | +import java.time.LocalDate; |
57 | 57 | import java.time.LocalDateTime; |
58 | 58 | import java.time.YearMonth; |
59 | 59 | import java.time.format.DateTimeFormatter; |
|
69 | 69 | import static it.gov.pagopa.idpay.transactions.utils.ExceptionConstants.ExceptionMessage.*; |
70 | 70 | import static org.springframework.http.HttpStatus.BAD_REQUEST; |
71 | 71 | import static org.springframework.http.HttpStatus.NOT_FOUND; |
72 | | -import static it.gov.pagopa.idpay.transactions.utils.ExceptionConstants.ExceptionMessage.ERROR_MESSAGE_NOT_FOUND_REWARD_BATCH_SENT; |
73 | 72 |
|
74 | 73 | @Service |
75 | 74 | @Slf4j |
@@ -332,8 +331,7 @@ public Mono<RewardBatch> suspendTransactions(String rewardBatchId, String initia |
332 | 331 |
|
333 | 332 | private static ReasonDTO generateReasonDto(TransactionsRequest request) { |
334 | 333 | LocalDateTime now = LocalDateTime.now(); |
335 | | - ReasonDTO reason = new ReasonDTO(now, request.getReason()); |
336 | | - return reason; |
| 334 | + return new ReasonDTO(now, request.getReason()); |
337 | 335 | } |
338 | 336 |
|
339 | 337 | void validChecksError(ChecksErrorDTO dto) { |
@@ -381,7 +379,17 @@ public Mono<RewardBatch> rejectTransactions(String rewardBatchId, String initiat |
381 | 379 | .map(trxId -> Pair.of(trxId, batch.getMonth()))) |
382 | 380 | .flatMap(trxId2ActualBatchMont -> rewardTransactionRepository |
383 | 381 | .updateStatusAndReturnOld(rewardBatchId, trxId2ActualBatchMont.getLeft(), RewardBatchTrxStatus.REJECTED, reason, trxId2ActualBatchMont.getRight(), checksErrorModel) |
384 | | - .map(trxOld -> Pair.of(trxOld, trxId2ActualBatchMont.getRight())) |
| 382 | + .map(trxOld -> { |
| 383 | + if (trxOld != null) { |
| 384 | + log.info( |
| 385 | + "[REJECT_TRANSACTION] Transaction {} rejected. batchId: {}, initiativeId: {}", |
| 386 | + trxOld.getId(), |
| 387 | + Utilities.sanitizeString(rewardBatchId), |
| 388 | + Utilities.sanitizeString(initiativeId) |
| 389 | + ); |
| 390 | + } |
| 391 | + return Pair.of(trxOld, trxId2ActualBatchMont.getRight()); |
| 392 | + }) |
385 | 393 | ) |
386 | 394 | .reduce(new BatchCountersDTO(0L, 0L, 0L, 0L, 0L), |
387 | 395 | (acc, trxOld2ActualRewardBatchMonth) -> { |
|
0 commit comments