From 587b4764d55e2b2edb474211d3ba23e701666803 Mon Sep 17 00:00:00 2001 From: Saloni-eGov Date: Fri, 9 Aug 2024 17:27:36 +0530 Subject: [PATCH] ISTE-229 --- .../rowmapper/LedgerReportRowMapper.java | 16 +++++++--------- .../waterconnection/web/models/LedgerReport.java | 7 +++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/rowmapper/LedgerReportRowMapper.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/rowmapper/LedgerReportRowMapper.java index 35127960f..caceb65cd 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/rowmapper/LedgerReportRowMapper.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/rowmapper/LedgerReportRowMapper.java @@ -192,6 +192,8 @@ private void addPaymentToLedger(List> monthlyRecordList) { boolean paymentMatched = false; if(payments!=null) { + BigDecimal totalPaymentInMonth=BigDecimal.ZERO; + BigDecimal totalBalanceLeftInMonth=BigDecimal.ZERO; for (Payment payment : payments) { Long transactionDateLong = payment.getTransactionDate(); LocalDate transactionDate = Instant.ofEpochMilli(transactionDateLong).atZone(ZoneId.systemDefault()).toLocalDate(); @@ -201,15 +203,9 @@ private void addPaymentToLedger(List> monthlyRecordList) { paymentLedgerReport.setCollectionDate(transactionDateLong); paymentLedgerReport.setReceiptNo(payment.getPaymentDetails().get(0).getReceiptNumber()); paymentLedgerReport.setPaid(payment.getTotalAmountPaid()); -// BigDecimal totalDueAmount=payment.getTotalDue(); -// if(totalDueAmount.equals(BigDecimal.ZERO)) -// { - paymentLedgerReport.setBalanceLeft(payment.getTotalDue().subtract(paymentLedgerReport.getPaid())); -// } -// else -// { -// paymentLedgerReport.setBalanceLeft(totalDueAmount.subtract(paymentLedgerReport.getPaid())); -// } + paymentLedgerReport.setBalanceLeft(payment.getTotalDue().subtract(paymentLedgerReport.getPaid())); + totalPaymentInMonth=totalPaymentInMonth.add(payment.getTotalAmountPaid()); + totalBalanceLeftInMonth=totalBalanceLeftInMonth.add(payment.getTotalDue()); if (ledgerReport.getPayment() == null) { ledgerReport.setPayment(new ArrayList<>()); } @@ -217,6 +213,8 @@ private void addPaymentToLedger(List> monthlyRecordList) { paymentMatched = true; } } + ledgerReport.setTotalBalanceLeftInMonth(totalPaymentInMonth); + ledgerReport.setTotalPaymentInMonth(totalPaymentInMonth); } if (!paymentMatched) { PaymentLedgerReport defaultPaymentLedgerReport = new PaymentLedgerReport(); diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReport.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReport.java index 3dac0232e..720e7f2cb 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReport.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReport.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -17,4 +18,10 @@ public class LedgerReport @JsonProperty("payment") private List payment=new ArrayList<>(); + + @JsonProperty("totalPaymentInMonth") + private BigDecimal totalPaymentInMonth=BigDecimal.ZERO; + + @JsonProperty("totalBalanceLeftInMonth") + private BigDecimal totalBalanceLeftInMonth=BigDecimal.ZERO; }