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

Updated fees register contract api version and fixed incorrect fee issue #116

Merged
merged 5 commits into from
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.payment.api.contract;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
Expand All @@ -11,7 +12,6 @@

import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;

import java.math.BigDecimal;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
Expand All @@ -33,4 +33,10 @@ public class FeeDto {
@NotNull
@Digits(integer = 10, fraction = 2, message = "Fee calculated amount cannot have more than 2 decimal places")
private BigDecimal calculatedAmount;

@JsonIgnore
private String memoLine;
@JsonIgnore
private String naturalAccountCode;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -111,14 +110,13 @@ public static class LinkDto {

public String toCardPaymentCsv() {


SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss zzz");

StringJoiner sb = new StringJoiner(",")
.add(getServiceName())
.add(getPaymentGroupReference())
.add(getPaymentReference())
.add(getCcdCaseNumber())
.add(getCaseReference())
.add(sdf.format(getDateCreated()))
.add(sdf.format(getDateUpdated()))
.add(getStatus())
Expand All @@ -130,15 +128,26 @@ public String toCardPaymentCsv() {
StringJoiner feeSb = new StringJoiner(",");

for (FeeDto fee : getFees()) {

feeSb.add(fee.getCode()).add(fee.getVersion()).add(fee.getCalculatedAmount().toString());
String memolineWithQuotes="";
if (null!=fee.getMemoLine()){
memolineWithQuotes = new StringBuffer().append('"').append(fee.getMemoLine()).append('"').toString();
}
String naturalAccountCode="";
if (null!=fee.getNaturalAccountCode()){
naturalAccountCode= fee.getNaturalAccountCode();
}
feeSb.add(fee.getCode())
.add(fee.getVersion())
.add(fee.getCalculatedAmount().toString())
.add(memolineWithQuotes)
.add(naturalAccountCode);
}


return sb.merge(feeSb).toString();
}



public String toCreditAccountPaymentCsv() {

SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss zzz");
Expand All @@ -163,15 +172,22 @@ public String toCreditAccountPaymentCsv() {
StringJoiner feeSb = new StringJoiner(",");

for (FeeDto fee : getFees()) {

feeSb.add(fee.getCode()).add(fee.getVersion()).add(fee.getCalculatedAmount().toString());
String memolineWithQuotes="";
if (null!=fee.getMemoLine()){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it good idea to do it with Optional?

memolineWithQuotes = new StringBuffer().append('"').append(fee.getMemoLine()).append('"').toString();
}
String naturalAccountCode="";
if (null!=fee.getNaturalAccountCode()){
naturalAccountCode= fee.getNaturalAccountCode();
}
feeSb.add(fee.getCode())
.add(fee.getVersion())
.add(fee.getCalculatedAmount().toString())
.add(memolineWithQuotes)
.add(naturalAccountCode);
}


return sb.merge(feeSb).toString();
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import lombok.SneakyThrows;
import org.springframework.hateoas.mvc.ControllerLinkBuilder;
import org.springframework.stereotype.Component;
import uk.gov.hmcts.payment.api.contract.*;
import uk.gov.hmcts.payment.api.contract.FeeDto;
import uk.gov.hmcts.payment.api.contract.PaymentDto;
import uk.gov.hmcts.payment.api.contract.StatusHistoryDto;
import uk.gov.hmcts.payment.api.contract.util.CurrencyCode;
import uk.gov.hmcts.payment.api.controllers.CardPaymentController;
import uk.gov.hmcts.payment.api.model.Fee;
Expand Down Expand Up @@ -67,9 +69,9 @@ public PaymentDto toRetrievePaymentStatusesDto(PaymentFeeLink paymentFeeLink) {
.build();
}

public PaymentCsvDto toReconciliationResponseDto(PaymentFeeLink paymentFeeLink) {
public PaymentDto toReconciliationResponseDto(PaymentFeeLink paymentFeeLink) {
Payment payment = paymentFeeLink.getPayments().get(0);
return PaymentCsvDto.paymentCsvDtoWith()
return PaymentDto.payment2DtoWith()
.paymentReference(payment.getReference())
.paymentGroupReference(paymentFeeLink.getPaymentReference())
.serviceName(payment.getServiceType())
Expand All @@ -83,7 +85,7 @@ public PaymentCsvDto toReconciliationResponseDto(PaymentFeeLink paymentFeeLink)
.dateCreated(payment.getDateCreated())
.dateUpdated(payment.getDateUpdated())
.method(payment.getPaymentMethod().getName())
.fees(toFeeCsvDtos(paymentFeeLink.getFees()))
.fees(toFeeDtos(paymentFeeLink.getFees()))
.build();

}
Expand All @@ -92,11 +94,6 @@ private List<FeeDto> toFeeDtos(List<Fee> fees) {
return fees.stream().map(this::toFeeDto).collect(Collectors.toList());
}

private List<FeeCsvDto> toFeeCsvDtos(List<Fee> fees) {
return fees.stream().map(this::toFeeCsvDto).collect(Collectors.toList());
}


public List<Fee> toFees(List<FeeDto> feeDtos) {
return feeDtos.stream().map(this::toFee).collect(Collectors.toList());
}
Expand All @@ -109,12 +106,6 @@ private FeeDto toFeeDto(Fee fee) {
return FeeDto.feeDtoWith().calculatedAmount(fee.getCalculatedAmount()).code(fee.getCode()).version(fee.getVersion()).build();
}


private FeeCsvDto toFeeCsvDto(Fee fee) {
return FeeCsvDto.feeCsvDtoWith().calculatedAmount(fee.getCalculatedAmount()).code(fee.getCode()).version(fee.getVersion())
.memoLine("").naturalAccountCode("").build();
}

private List<StatusHistoryDto> toStatusHistoryDtos(List<StatusHistory> statusHistories) {
return statusHistories.stream().map(this::toStatusHistoryDto).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public PaymentDto toPaymentDto(Payment payment) {
.siteId(payment.getSiteId())
.build();
}
public PaymentCsvDto toReconciliationResponseDto(PaymentFeeLink paymentFeeLink) {
public PaymentDto toReconciliationResponseDto(PaymentFeeLink paymentFeeLink) {
Payment payment = paymentFeeLink.getPayments().get(0);
return PaymentCsvDto.paymentCsvDtoWith()
return PaymentDto.payment2DtoWith()
.paymentReference(payment.getReference())
.paymentGroupReference(paymentFeeLink.getPaymentReference())
.serviceName(payment.getServiceType())
Expand All @@ -148,7 +148,7 @@ public PaymentCsvDto toReconciliationResponseDto(PaymentFeeLink paymentFeeLink)
.dateCreated(payment.getDateCreated())
.dateUpdated(payment.getDateUpdated())
.method(payment.getPaymentMethod().getName())
.fees(toFeeCsvDtos(paymentFeeLink.getFees()))
.fees(toFeeDtos(paymentFeeLink.getFees()))
.build();

}
Expand All @@ -161,9 +161,6 @@ public List<Payment> toPaymentsRequest(List<CreditAccountPaymentRequest> creditA
public List<FeeDto> toFeeDtos(List<Fee> fees) {
return fees.stream().map(this::toFeeDto).collect(Collectors.toList());
}
private List<FeeCsvDto> toFeeCsvDtos(List<Fee> fees) {
return fees.stream().map(this::toFeeCsvDto).collect(Collectors.toList());
}


public List<Fee> toFees(List<FeeDto> feeDtos) {
Expand All @@ -177,10 +174,6 @@ public Fee toFee(FeeDto feeDto) {
public FeeDto toFeeDto(Fee fee) {
return FeeDto.feeDtoWith().calculatedAmount(fee.getCalculatedAmount()).code(fee.getCode()).version(fee.getVersion()).build();
}
private FeeCsvDto toFeeCsvDto(Fee fee) {
return FeeCsvDto.feeCsvDtoWith().calculatedAmount(fee.getCalculatedAmount()).code(fee.getCode()).version(fee.getVersion())
.memoLine("").naturalAccountCode("").build();
}


@SneakyThrows(NoSuchMethodException.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.payment.api.fees.client;
package uk.gov.hmcts.payment.api.reports;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down
Loading