Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun… #1669

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
08f4ccf
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 11, 2024
5b9878b
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 11, 2024
00b3af7
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 11, 2024
a87a514
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 11, 2024
22cf38f
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 11, 2024
3cd2c66
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 12, 2024
36adfd3
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 12, 2024
43b4a07
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 12, 2024
e5967e7
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 12, 2024
5b628fc
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 12, 2024
d6d1e42
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 13, 2024
7826342
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
a94714a
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
f8220dc
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 13, 2024
069d013
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 13, 2024
5a82f6e
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 13, 2024
1d6c832
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
18b6c42
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
983a4c9
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
334fc0d
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
25a498a
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 13, 2024
e536fe0
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
5240c7a
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
048cc9e
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
2a58d0a
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
5ad3f3c
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 13, 2024
8e65b05
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
f0852e4
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
d5b55d7
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
e37dedc
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
500733f
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
b20ac11
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
84c3402
PAY-7103: Calculate the AMOUNT DUE and OVERPAYMENTS for ( Issue refun…
Thor-tech-of-metal Jun 14, 2024
d780a1a
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
11ec4b3
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
98993a5
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
8938843
Merge branch 'master' of github.com:hmcts/ccpay-payment-app into PAY-…
Thor-tech-of-metal Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import uk.gov.hmcts.payment.api.contract.util.CurrencyCode;

import javax.validation.constraints.NotEmpty;
Expand All @@ -30,6 +31,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Data
@ToString
public class PaymentDto {

private String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.util.MultiValueMap;
Expand Down Expand Up @@ -41,6 +43,8 @@
@Validated
public class CaseController {

private static final Logger LOG = LoggerFactory.getLogger(CaseController.class);

private final PaymentService<PaymentFeeLink, String> paymentService;
private final PaymentGroupService<PaymentFeeLink, String> paymentGroupService;
private final PaymentDtoMapper paymentDtoMapper;
Expand Down Expand Up @@ -110,9 +114,10 @@ public PaymentGroupResponse retrieveCasePaymentGroups(@PathVariable(name = "ccdc
throw new PaymentGroupNotFoundException("No Service found for given CaseType or HMCTS Org Id");
}
PaymentGroupResponse paymentGroupResponse = new PaymentGroupResponse(paymentGroups);

paymentGroupResponse = paymentRefundsService.checkRefundAgainstRemissionV2(headers, paymentGroupResponse, ccdCaseNumber);

LOG.info("Refund " + paymentGroupResponse.getPaymentGroups().get(0).getRefunds());
LOG.info("END case number:-----"+ ccdCaseNumber);
return paymentGroupResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@NoArgsConstructor
@Getter
@Setter
@ToString
public class PaymentGroupDto {

private String paymentGroupReference;
Expand All @@ -43,4 +44,6 @@ public class PaymentGroupDto {

private boolean isAnyPaymentDisputed;

private List<RefundDto> refunds;

}
8 changes: 6 additions & 2 deletions api/src/main/java/uk/gov/hmcts/payment/api/dto/RefundDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.payment.api.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
Expand All @@ -8,19 +9,22 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import uk.gov.hmcts.payment.api.model.ContactDetails;

import java.math.BigDecimal;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@JsonInclude(NON_NULL)
@Builder(builderMethodName = "buildRefundListDtoWith")
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@JsonInclude(NON_NULL)
@ToString
public class RefundDto {

private String ccdCaseNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@NoArgsConstructor
@Getter
@Setter
@ToString
public class RemissionDto {

private String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ ResponseEntity<RefundResponse> createAndValidateRetrospectiveRemissionRequest(


void deleteByRefundReference(String refundReference, MultiValueMap<String, String> headers);

RefundListDtoResponse getRefundsApprovedFromRefundService(String ccdCaseNumber, MultiValueMap<String, String> headers);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.time.temporal.ChronoUnit;

import org.apache.commons.lang3.EnumUtils;
import org.apache.poi.hpsf.Decimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -248,6 +247,21 @@ public ResponseEntity updateTheRemissionAmount(String paymentReference, Resubmit
}
return new ResponseEntity<>(null, HttpStatus.OK);
}


public RefundListDtoResponse getRefundsApprovedFromRefundService (String ccdCaseNumber, MultiValueMap<String, String> headers) {
final var refundListDtoResponse = getRefundsFromRefundService(ccdCaseNumber, headers);
if (refundListDtoResponse == null){
return RefundListDtoResponse.buildRefundListWith().refundList(new ArrayList<>()).build();
}
return RefundListDtoResponse.buildRefundListWith()
.refundList(refundListDtoResponse.getRefundList()
.stream()
.filter(e->e.getRefundStatus().getName().equals("Accepted")
).collect(Collectors.toList())
).build();
}

private RefundListDtoResponse getRefundsFromRefundService(String ccdCaseNumber, MultiValueMap<String, String> headers) {


Expand All @@ -267,12 +281,14 @@ private RefundListDtoResponse getRefundsFromRefundService(String ccdCaseNumber,

refundListDtoResponse = refundListDtoResponseEntity.hasBody() ? refundListDtoResponseEntity.getBody() : null;

} catch (HttpClientErrorException e) {

LOG.error("client err ", e);
} catch (Exception e) {
LOG.info("Catch the refund error for this case number: "+ ccdCaseNumber);
LOG.info("Catch the refund error", e.getMessage());
LOG.info("There has been an error calling refunds endpoint.", e);
e.printStackTrace();
LOG.info("Get cause: ", e.getCause());

refundListDtoResponse = null;

}

return refundListDtoResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ControllerExceptionHandler {
@ExceptionHandler(value = {RuntimeException.class})
@ResponseStatus(code = INTERNAL_SERVER_ERROR)
public void unknownException(RuntimeException e) {
LOG.error("GIVE ME A CLUE !!!!!");
e.printStackTrace();
LOG.error("Unknown error has occurred with errorMessage: " + e.getMessage(), e);
}

Expand Down
Loading