Skip to content

Commit

Permalink
Merge branch 'main' into bug(CSTM-CPC-1017)Fix-Pet-UUID-Generation-an…
Browse files Browse the repository at this point in the history
…d-Pet-Type-Appearance
  • Loading branch information
Nmazza1 authored Oct 24, 2023
2 parents c9d3a62 + e8e258b commit e40d4a6
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public Mono<BillResponseDTO> getBilling(final String billId) {
return webClientBuilder.build().get()
.uri(billServiceUrl + "/{billId}", billId)
.retrieve()
.bodyToMono(BillResponseDTO.class);
.bodyToMono(BillResponseDTO.class)
.doOnNext(t -> t.setTaxedAmount(((t.getAmount() * 15)/100)+ t.getAmount()))
.doOnNext(t -> t.setTaxedAmount(Math.round(t.getTaxedAmount() * 100.0) / 100.0));
}
public Flux<BillResponseDTO> getBillsByOwnerId(final String customerId) {
return webClientBuilder.build().get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class BillDetails {
private String vetId;
private String visitType;
private double amount;
private double taxedAmount;
private BillStatus billStatus;
private LocalDate dueDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BillResponseDTO {
private String vetId;
private LocalDate date;
private double amount;
private double taxedAmount;
private BillStatus billStatus;
private LocalDate dueDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ <h5>Due Date: <strong>{{$ctrl.bills.dueDate}}</strong></h5>
<hr>
<br>
<h5>Final Amount Due: {{$ctrl.bills.amount}}</h5>
<h5 ng-if="show">Final Amount Including Taxes: {{$ctrl.bills.taxedAmount}}</h5>
<button class="newBtn btn btn-primary" ng-click="show = !show"> {{show? "Hide amount including taxes" : "Show amount including taxes"}}</button>
<hr>
<br>
<div>
Expand Down Expand Up @@ -78,6 +80,10 @@ <h5>Final Amount Due: {{$ctrl.bills.amount}}</h5>
window.print();
}


function changeShow(){
show = !show;
}
</script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private void prepareResponse(Consumer<MockResponse> consumer) {
private final BillResponseDTO billResponseDTO = BillResponseDTO.builder()
.billId("1")
.amount(100.0)
.taxedAmount(115.0)
.customerId("1")
.vetId("1")
.visitType("Check up")
Expand All @@ -70,6 +71,7 @@ private void prepareResponse(Consumer<MockResponse> consumer) {
private final BillResponseDTO billResponseDTO2 = BillResponseDTO.builder()
.billId("2")
.amount(150.0)
.taxedAmount(172.5)
.customerId("2")
.vetId("2")
.visitType("Check up")
Expand All @@ -81,6 +83,7 @@ private void prepareResponse(Consumer<MockResponse> consumer) {
private final BillResponseDTO billResponseDTO3 = BillResponseDTO.builder()
.billId("3")
.amount(250.0)
.taxedAmount(287.5)
.customerId("3")
.vetId("3")
.visitType("Check up")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1921,10 +1921,10 @@ void shouldThrowMethodNotAllowedWhenDeletePetsIsMissingPetId(){

@Test
void shouldGetAllBills() {
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, BillStatus.PAID,null);
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, 28.75,BillStatus.PAID,null);


BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, BillStatus.UNPAID,null);
BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, 31.05,BillStatus.UNPAID,null);
when(billServiceClient.getAllBilling()).thenReturn(Flux.just(billResponseDTO,billResponseDTO2));

client.get()
Expand All @@ -1940,9 +1940,9 @@ void shouldGetAllBills() {

@Test
void shouldGetAllPaidBills() {
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, BillStatus.PAID,null);
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, 28.75,BillStatus.PAID,null);

BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, BillStatus.PAID,null);
BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, 31.05, BillStatus.PAID,null);
when(billServiceClient.getAllPaidBilling()).thenReturn(Flux.just(billResponseDTO,billResponseDTO2));

client.get()
Expand All @@ -1958,9 +1958,9 @@ void shouldGetAllPaidBills() {

@Test
void shouldGetAllUnpaidBills() {
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, BillStatus.UNPAID, null);
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, 28.75, BillStatus.UNPAID, null);

BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, BillStatus.UNPAID,null);
BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, 31.05,BillStatus.UNPAID,null);
when(billServiceClient.getAllUnpaidBilling()).thenReturn(Flux.just(billResponseDTO,billResponseDTO2));

client.get()
Expand All @@ -1976,9 +1976,9 @@ void shouldGetAllUnpaidBills() {

@Test
void shouldGetAllOverdueBills() {
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, BillStatus.OVERDUE,null);
BillResponseDTO billResponseDTO = new BillResponseDTO("BillUUID","1","Test type","1",null,25.00, 28.75, BillStatus.OVERDUE,null);

BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, BillStatus.OVERDUE, null);
BillResponseDTO billResponseDTO2 = new BillResponseDTO("BillUUID2","2","Test type","2",null,27.00, 31.05, BillStatus.OVERDUE, null);
when(billServiceClient.getAllOverdueBilling()).thenReturn(Flux.just(billResponseDTO,billResponseDTO2));

client.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class BillServiceImpl implements BillService{
@Override
public Mono<BillResponseDTO> getBillByBillId(String billUUID) {

return billRepository.findByBillId(billUUID).map(EntityDtoUtil::toBillResponseDto);
return billRepository.findByBillId(billUUID).map(EntityDtoUtil::toBillResponseDto)
.doOnNext(t -> t.setTaxedAmount(((t.getAmount() * 15)/100)+ t.getAmount()))
.doOnNext(t -> t.setTaxedAmount(Math.round(t.getTaxedAmount() * 100.0) / 100.0));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Bill {
private String vetLastName;
private LocalDate date;
private double amount;
private double taxedAmount;
private BillStatus billStatus;

private LocalDate dueDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class BillResponseDTO {
private String vetId;
private LocalDate date;
private double amount;
private double taxedAmount;
private BillStatus billStatus;
private LocalDate dueDate;

Expand Down

0 comments on commit e40d4a6

Please sign in to comment.