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

feat/BILL-CPC-933_Implement_Button_To_Calculate_Bill_With_Tax #572

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
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>
Copy link
Collaborator

Choose a reason for hiding this comment

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

You also could have done this by crating a style class that is hidden, and then when the button is clicked the style class is then shown! Just a small change, either way works well!

Copy link
Collaborator Author

@HennaCH HennaCH Oct 22, 2023

Choose a reason for hiding this comment

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

Ok, I will try your suggestion !

<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 @@ -15,13 +15,15 @@
public class BillServiceImpl implements BillService{

private final BillRepository billRepository;
// private final VetClient vetClient;

Check notice on line 18 in billing-service/src/main/java/com/petclinic/billing/businesslayer/BillServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Commented out code

Commented out code (2 lines)
// private final OwnerClient ownerClient;

@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 Expand Up @@ -109,7 +111,7 @@

}

// private Mono<RequestContextAdd> vetRequestResponse(RequestContextAdd rc) {

Check notice on line 114 in billing-service/src/main/java/com/petclinic/billing/businesslayer/BillServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Commented out code

Commented out code (12 lines)
// return
// this.vetClient.getVetByVetId(rc.getVetDTO().getVetId())
// .doOnNext(rc::setVetDTO)
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
Loading