diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/WaterDaoImpl.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/WaterDaoImpl.java index 84f89fff7..0ba3d13be 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/WaterDaoImpl.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/WaterDaoImpl.java @@ -1,6 +1,10 @@ package org.egov.waterconnection.repository; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -36,6 +40,7 @@ import org.egov.waterconnection.web.models.WaterConnection; import org.egov.waterconnection.web.models.WaterConnectionRequest; import org.egov.waterconnection.web.models.WaterConnectionResponse; +import org.egov.waterconnection.web.models.collection.Payment; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.core.JdbcTemplate; @@ -50,6 +55,8 @@ public class WaterDaoImpl implements WaterDao { @Autowired + private LedgerReportRowMapper ledgerReportRowMapper; + @Autowired private DemandNotGeneratedRowMapper demandNotGeneratedRowMapper; @Autowired @@ -669,17 +676,70 @@ public List getInactiveConsumerReport(Long monthStar return inactiveConsumerReportList; } - public List getConsumersByPreviousMeterReading(Long previousMeterReading, String tenantId) - { - StringBuilder query=new StringBuilder(wsQueryBuilder.DEMAND_NOT_GENERATED_QUERY); + public List getConsumersByPreviousMeterReading(Long previousMeterReading, String tenantId) { + StringBuilder query = new StringBuilder(wsQueryBuilder.DEMAND_NOT_GENERATED_QUERY); - List preparedStatement=new ArrayList<>(); + List preparedStatement = new ArrayList<>(); preparedStatement.add(tenantId); preparedStatement.add(previousMeterReading); preparedStatement.add(tenantId); - log.info("Query for consumer demand not generated "+ query +" prepared statement "+ preparedStatement); - List consumersDemandNotGeneratedList=jdbcTemplate.query(query.toString(),preparedStatement.toArray(),demandNotGeneratedRowMapper); + log.info("Query for consumer demand not generated " + query + " prepared statement " + preparedStatement); + List consumersDemandNotGeneratedList = jdbcTemplate.query(query.toString(), preparedStatement.toArray(), demandNotGeneratedRowMapper); return consumersDemandNotGeneratedList; } + + public List> getLedgerReport(String consumercode, String tenantId, Integer offset, Integer limit, String year,RequestInfoWrapper requestInfoWrapper) { + String[] years = year.split("-"); + if (years.length != 2) { + throw new IllegalArgumentException("Invalid fiscal year format"); + } + int startYear = Integer.parseInt(years[0]); + int endYear = Integer.parseInt(years[1]); + + LocalDate startDate = LocalDate.of(startYear, 4, 1); + LocalDate endDate = LocalDate.of(startYear + 1, 3, 31); + + Long startDateTime = LocalDateTime.of(startDate.getYear(), startDate.getMonth(), startDate.getDayOfMonth(), 0, 0, 0) + .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + Long endDateTime = LocalDateTime.of(endDate, LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + + StringBuilder query = new StringBuilder(wsQueryBuilder.LEDGER_REPORT_QUERY); + + List preparedStatement = new ArrayList<>(); + preparedStatement.add(consumercode); + preparedStatement.add(tenantId); + preparedStatement.add(startDateTime); + preparedStatement.add(endDateTime); + + Integer newlimit = wsConfiguration.getDefaultLimit(); + Integer newoffset = wsConfiguration.getDefaultOffset(); + if (limit == null && offset == null) + newlimit = wsConfiguration.getMaxLimit(); + if (limit != null && limit <= wsConfiguration.getMaxLimit()) + newlimit = limit; + if (limit != null && limit >= wsConfiguration.getMaxLimit()) + newlimit = wsConfiguration.getMaxLimit(); + + if (offset != null) + newoffset = offset; + + if (newlimit > 0) { + query.append(" offset ? limit ? ;"); + preparedStatement.add(newoffset); + preparedStatement.add(newlimit); + } + + log.info("Query of ledger report:" + query + "and prepared statement" + preparedStatement); + ledgerReportRowMapper.setTenantId(tenantId); + ledgerReportRowMapper.setRequestInfo(requestInfoWrapper); + ledgerReportRowMapper.setStartYear(startYear); + ledgerReportRowMapper.setEndYear(endYear); + ledgerReportRowMapper.setConsumerCode(consumercode); + List> ledgerReportList= jdbcTemplate.query(query.toString(), preparedStatement.toArray(), ledgerReportRowMapper); + int fromIndex = Math.min(newoffset, ledgerReportList.size()); + int toIndex = Math.min(fromIndex + newlimit, ledgerReportList.size()); + return ledgerReportList.subList(fromIndex, toIndex); +// return ledgerReportList; + } } diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/builder/WsQueryBuilder.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/builder/WsQueryBuilder.java index 35d1ac9cc..6740e8dfa 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/builder/WsQueryBuilder.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/builder/WsQueryBuilder.java @@ -193,7 +193,26 @@ public class WsQueryBuilder { "(select distinct consumercode from egbs_demand_v1 d inner join egbs_demanddetail_v1 dd on dd.demandid = d.id " + "where dd.taxheadcode='10101' and d.status ='ACTIVE' and d.businessservice='WS' and " + "d.tenantid=?) order by connectionno;"; - + + public static final String LEDGER_REPORT_QUERY = "SELECT connectionholder.userid as uuid,conn.connectionno as connectionNo,conn.oldconnectionno," + + "dem.taxperiodfrom as startdate,dem.taxperiodto as enddate," + + "dem.createdtime as demandGenerationDate," + + "dd.taxheadcode as code,dd.taxamount as taxamount " + + "FROM eg_ws_connection conn INNER JOIN eg_ws_connectionholder connectionholder " + + "ON connectionholder.connectionid = conn.id " + + "INNER JOIN egbs_demand_v1 dem ON dem.consumercode = conn.connectionno INNER JOIN " + + "egbs_demanddetail_v1 dd ON dd.demandid = dem.id " + + "WHERE dem.consumercode = ? AND conn.tenantId = ? AND dem.status = 'ACTIVE' " + + "AND taxperiodfrom>=? AND taxperiodto<=? "+ + "ORDER BY startdate"; + + public static final String TAX_AMOUNT_QUERY="SELECT SUM(taxamount) FROM egbs_demanddetail_v1 WHERE " + + "demandid IN (SELECT id FROM egbs_demand_v1 WHERE consumercode = ? AND taxperiodfrom < ? AND status='ACTIVE');"; + + public static final String TOTAL_AMOUNT_PAID_QUERY="SELECT SUM(totalamountpaid) FROM egcl_payment WHERE " + + "id IN (SELECT paymentid FROM egcl_paymentdetail WHERE billid IN " + + "(SELECT billid FROM egbs_billdetail_v1 WHERE consumercode = ?)) AND createdtime < ? AND paymentstatus!='CANCELLED';"; + /** * * @param criteria The WaterCriteria 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 new file mode 100644 index 000000000..b3e49e72d --- /dev/null +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/repository/rowmapper/LedgerReportRowMapper.java @@ -0,0 +1,247 @@ +package org.egov.waterconnection.repository.rowmapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.models.auth.In; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.egov.waterconnection.repository.ServiceRequestRepository; +import org.egov.waterconnection.repository.builder.WsQueryBuilder; +import org.egov.waterconnection.util.WaterServicesUtil; +import org.egov.waterconnection.web.models.*; +import org.egov.waterconnection.web.models.collection.Payment; +import org.egov.waterconnection.web.models.collection.PaymentResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.ResultSetExtractor; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.Instant; +import java.time.LocalDate; +import java.time.YearMonth; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.time.temporal.ChronoUnit; + + +@Slf4j +@Component +@Setter +public class LedgerReportRowMapper implements ResultSetExtractor>> { + + @Autowired + private WaterServicesUtil waterServiceUtil; + + @Autowired + private ObjectMapper mapper; + + @Autowired + private ServiceRequestRepository serviceRequestRepository; + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + private WsQueryBuilder wsQueryBuilder; + + String tenantId; + RequestInfoWrapper requestInfoWrapper; + Integer startYear; + Integer endYear; + String consumerCode; + + public void setRequestInfo(RequestInfoWrapper requestInfoWrapper) { + this.requestInfoWrapper = requestInfoWrapper; + } + + @Override + public List> extractData(ResultSet resultSet) throws SQLException, DataAccessException { + List> monthlyRecordsList = new ArrayList<>(); + Map ledgerReports = new HashMap<>(); + YearMonth startMonth = YearMonth.of(startYear, 4); + YearMonth endMonth; + YearMonth now = YearMonth.now(); + + if (startYear == now.getYear() || (startYear == now.getYear() - 1 && now.getMonthValue() <= 3)) { + endMonth = now; + } else { + endMonth = YearMonth.of(startYear + 1, 3); + } + + YearMonth currentMonth = startMonth; + + while (!currentMonth.isAfter(endMonth)) { + String monthAndYear = currentMonth.format(DateTimeFormatter.ofPattern("MMMM yyyy")); + LedgerReport ledgerReport = new LedgerReport(); + ledgerReport.setDemand(new DemandLedgerReport()); + ledgerReport.getDemand().setMonthAndYear(monthAndYear); + ledgerReport.getDemand().setConnectionNo(consumerCode); + ledgerReports.put(monthAndYear, ledgerReport); + currentMonth = currentMonth.plusMonths(1); + } + + while (resultSet.next()) { + Long dateLong = resultSet.getLong("enddate"); + LocalDate date = Instant.ofEpochMilli(dateLong).atZone(ZoneId.systemDefault()).toLocalDate(); + String monthAndYear = date.format(DateTimeFormatter.ofPattern("MMMM yyyy")); + + String code = resultSet.getString("code"); + + BigDecimal taxamount = resultSet.getBigDecimal("taxamount"); + + Long demandGenerationDateLong = resultSet.getLong("demandgenerationdate"); + LocalDate demandGenerationDateLocal = Instant.ofEpochMilli(demandGenerationDateLong).atZone(ZoneId.systemDefault()).toLocalDate(); + + LedgerReport ledgerReport = ledgerReports.get(monthAndYear); + + if (ledgerReport.getPayment() == null) { + ledgerReport.setPayment(new ArrayList<>()); + } + + if (code.equals("10102")) { + ledgerReport.getDemand().setArrears(taxamount != null ? taxamount : BigDecimal.ZERO); + ledgerReport.getDemand().setMonthAndYear(monthAndYear); + } else if (code.equals("WS_TIME_PENALTY") || code.equals("10201")) { + ledgerReport.getDemand().setPenalty(taxamount != null ? taxamount : BigDecimal.ZERO); + BigDecimal amount = ledgerReport.getDemand().getTaxamount() != null ? ledgerReport.getDemand().getTaxamount() : BigDecimal.ZERO; + ledgerReport.getDemand().setTotalForCurrentMonth((taxamount != null ? taxamount : BigDecimal.ZERO).add(amount)); + ledgerReport.getDemand().setTotal_due_amount(ledgerReport.getDemand().getTotalForCurrentMonth().add(ledgerReport.getDemand().getArrears() != null ? ledgerReport.getDemand().getArrears() : BigDecimal.ZERO)); + } else if (code.equals("10101")) { + ledgerReport.getDemand().setMonthAndYear(monthAndYear); + ledgerReport.getDemand().setDemandGenerationDate(demandGenerationDateLong); + ledgerReport.getDemand().setTaxamount(taxamount); + ledgerReport.getDemand().setTotalForCurrentMonth(ledgerReport.getDemand().getTaxamount().add(ledgerReport.getDemand().getPenalty() != null ? ledgerReport.getDemand().getPenalty() : BigDecimal.ZERO)); + long dueDateMillis = demandGenerationDateLocal.plus(10, ChronoUnit.DAYS).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); + long penaltyAppliedDateMillis = demandGenerationDateLocal.plus(11, ChronoUnit.DAYS).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); + ledgerReport.getDemand().setDueDate(dueDateMillis); + ledgerReport.getDemand().setPenaltyAppliedDate(penaltyAppliedDateMillis); + Long startDate = resultSet.getLong("startdate"); + String connectionno = resultSet.getString("connectionno"); + BigDecimal taxAmountResult = getMonthlyTaxAmount(startDate, connectionno); + BigDecimal totalAmountPaidResult = getMonthlyTotalAmountPaid(startDate, connectionno); + ledgerReport.getDemand().setArrears(taxAmountResult.subtract(totalAmountPaidResult)); + ledgerReport.getDemand().setTotal_due_amount(ledgerReport.getDemand().getTotalForCurrentMonth().add(ledgerReport.getDemand().getArrears())); + } + ledgerReport.getDemand().setConnectionNo(resultSet.getString("connectionno")); + ledgerReport.getDemand().setOldConnectionNo(resultSet.getString("oldconnectionno")); + ledgerReport.getDemand().setUserId(resultSet.getString("uuid")); + log.info("Data inserted into map " + ledgerReport.toString()); + ledgerReports.put(monthAndYear, ledgerReport); + } + for (Map.Entry entry : ledgerReports.entrySet()) { + Map record = new HashMap<>(); + record.put(entry.getKey(), entry.getValue()); + monthlyRecordsList.add(record); + } + log.info("ledger report list" + monthlyRecordsList); + if (!monthlyRecordsList.isEmpty()) { + addPaymentToLedger(monthlyRecordsList); + } + monthlyRecordsList.sort(new Comparator>() { + @Override + public int compare(Map o1, Map o2) { + String monthAndYear1 = (String) o1.keySet().iterator().next(); + String monthAndYear2 = (String) o2.keySet().iterator().next(); + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM yyyy", Locale.ENGLISH); + YearMonth yearMonth1 = YearMonth.parse(monthAndYear1, formatter); + YearMonth yearMonth2 = YearMonth.parse(monthAndYear2, formatter); + + return yearMonth1.compareTo(yearMonth2); + } + }); + return monthlyRecordsList; + } + + public List addPaymentDetails(String consumerCode) { + if(consumerCode==null) + return null; + String service = "WS"; + StringBuilder URL = waterServiceUtil.getcollectionURL(); + URL.append(service).append("/_search").append("?").append("consumerCodes=").append(consumerCode) + .append("&").append("tenantId=").append(tenantId); + Object response = serviceRequestRepository.fetchResult(URL, requestInfoWrapper); + log.info("line 226 response " + response.toString()); + PaymentResponse paymentResponse = mapper.convertValue(response, PaymentResponse.class); + return paymentResponse.getPayments(); + } + + private void addPaymentToLedger(List> monthlyRecordList) { + for (Map record : monthlyRecordList) { + LedgerReport ledgerReport = (LedgerReport) record.values().iterator().next(); + if (ledgerReport.getDemand() == null) { + log.info("DemandLedgerReport is null for LedgerReport: {}", ledgerReport); + } + String consumerCode = ledgerReport.getDemand().getConnectionNo(); + log.info("consumer code is " + consumerCode); + List payments = addPaymentDetails(consumerCode); + boolean paymentMatched = false; + if(payments!=null) + { + for (Payment payment : payments) { + Long transactionDateLong = payment.getTransactionDate(); + LocalDate transactionDate = Instant.ofEpochMilli(transactionDateLong).atZone(ZoneId.systemDefault()).toLocalDate(); + String transactionMonthAndYear = transactionDate.format(DateTimeFormatter.ofPattern("MMMM yyyy")); + if (ledgerReport.getDemand().getMonthAndYear().equals(transactionMonthAndYear)) { + PaymentLedgerReport paymentLedgerReport = new PaymentLedgerReport(); + paymentLedgerReport.setCollectionDate(transactionDateLong); + paymentLedgerReport.setReceiptNo(payment.getPaymentDetails().get(0).getReceiptNumber()); + paymentLedgerReport.setPaid(payment.getTotalAmountPaid()); + BigDecimal totalDueAmount=ledgerReport.getDemand().getTotal_due_amount(); + if(totalDueAmount.equals(BigDecimal.ZERO)) + { + paymentLedgerReport.setBalanceLeft(payment.getTotalDue().subtract(paymentLedgerReport.getPaid())); + } + else + { + paymentLedgerReport.setBalanceLeft(totalDueAmount.subtract(paymentLedgerReport.getPaid())); + } + if (ledgerReport.getPayment() == null) { + ledgerReport.setPayment(new ArrayList<>()); + } + ledgerReport.getPayment().add(paymentLedgerReport); + paymentMatched = true; + } + } + } + if (!paymentMatched) { + PaymentLedgerReport defaultPaymentLedgerReport = new PaymentLedgerReport(); + defaultPaymentLedgerReport.setCollectionDate(null); + defaultPaymentLedgerReport.setReceiptNo("N/A"); + defaultPaymentLedgerReport.setPaid(BigDecimal.ZERO); + defaultPaymentLedgerReport.setBalanceLeft(ledgerReport.getDemand().getTotal_due_amount()); + + if (ledgerReport.getPayment() == null) { + ledgerReport.setPayment(new ArrayList<>()); + } + ledgerReport.getPayment().add(defaultPaymentLedgerReport); + } + } + } + + private BigDecimal getMonthlyTaxAmount(Long startDate, String consumerCode) { + StringBuilder taxAmountQuery = new StringBuilder(wsQueryBuilder.TAX_AMOUNT_QUERY); + List taxAmountParams = new ArrayList<>(); + taxAmountParams.add(consumerCode); + taxAmountParams.add(startDate); + BigDecimal ans = jdbcTemplate.queryForObject(taxAmountQuery.toString(), taxAmountParams.toArray(), BigDecimal.class); + if (ans != null) + return ans; + return BigDecimal.ZERO; + } + + private BigDecimal getMonthlyTotalAmountPaid(Long startDate, String consumerCode) { + StringBuilder totalAmountPaidQuery = new StringBuilder(wsQueryBuilder.TOTAL_AMOUNT_PAID_QUERY); + List totalAmountPaidParams = new ArrayList<>(); + totalAmountPaidParams.add(consumerCode); + totalAmountPaidParams.add(startDate); + BigDecimal ans = jdbcTemplate.queryForObject(totalAmountPaidQuery.toString(), totalAmountPaidParams.toArray(), BigDecimal.class); + if (ans != null) + return ans; + return BigDecimal.ZERO; + } +} diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterService.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterService.java index e4c9ed73b..0ab401e9c 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterService.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterService.java @@ -1,6 +1,7 @@ package org.egov.waterconnection.service; import java.util.List; +import java.util.Map; import javax.validation.Valid; @@ -54,4 +55,6 @@ List collectionReport(String paymentStartDate, String paym List inactiveConsumerReport(String monthStartDate,String monthEndDate,String tenantId, @Valid Integer offset, @Valid Integer limit, RequestInfo requestInfo); WaterConnectionResponse getConsumersWithDemandNotGenerated(String previousMeterReading, String tenantId,RequestInfo requestInfo); + + List> ledgerReport(String consumercode, String tenantId, Integer offset, Integer limit, String year,RequestInfoWrapper requestInfoWrapper); } diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterServiceImpl.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterServiceImpl.java index ba0803984..339ddd13c 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterServiceImpl.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/service/WaterServiceImpl.java @@ -8,6 +8,7 @@ import java.text.SimpleDateFormat; import java.time.*; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; import java.util.Arrays; @@ -862,4 +863,11 @@ public WaterConnectionResponse getConsumersWithDemandNotGenerated(String previou SearchCriteria criteria=SearchCriteria.builder().connectionNoSet(connectionNo).tenantId(tenantId).build(); return search(criteria,requestInfo); } + + @Override + public List> ledgerReport(String consumercode, String tenantId, Integer offset, Integer limit, String year,RequestInfoWrapper requestInfoWrapper) + { + List> list = waterDaoImpl.getLedgerReport(consumercode, tenantId, offset, limit, year,requestInfoWrapper); + return list; + } } \ No newline at end of file diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/controller/WaterController.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/controller/WaterController.java index f4da10f1f..655cca28d 100644 --- a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/controller/WaterController.java +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/controller/WaterController.java @@ -1,6 +1,7 @@ package org.egov.waterconnection.web.controller; import java.util.List; +import java.util.Map; import javax.validation.Valid; @@ -244,4 +245,13 @@ public ResponseEntity getConsumersWithDemandNotGenerate return new ResponseEntity<>(response, HttpStatus.OK); } + @PostMapping("/ledger-report") + public ResponseEntity getLedgerReport(@Valid @RequestBody RequestInfoWrapper requestInfoWrapper, @RequestParam String consumercode, @RequestParam String tenantId, @RequestParam Integer offset, @RequestParam Integer limit, @RequestParam String year) { + List> list = waterService.ledgerReport(consumercode, tenantId, offset, limit, year,requestInfoWrapper); + LedgerReportResponse response = LedgerReportResponse.builder().ledgerReport(list). + responseInfo(responseInfoFactory.createResponseInfoFromRequestInfo(requestInfoWrapper.getRequestInfo(), true)). + tenantName(tenantId).financialYear(year).build(); + return new ResponseEntity<>(response, HttpStatus.OK); + } + } diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/DemandLedgerReport.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/DemandLedgerReport.java new file mode 100644 index 000000000..c7cad175e --- /dev/null +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/DemandLedgerReport.java @@ -0,0 +1,67 @@ +package org.egov.waterconnection.web.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DemandLedgerReport { + + @JsonProperty("consumerName") + private String consumerName = null; + + @JsonProperty("connectionNo") + private String connectionNo = null; + + @JsonProperty("oldConnectionNo") + private String oldConnectionNo = null; + + @JsonProperty("userId") + private String userId = null; + + @JsonProperty("month") + private String monthAndYear; + + @JsonProperty("demandGenerationDate") + private Long demandGenerationDate= 0L; + + @JsonProperty("code") + private String code = null; + + @JsonProperty("monthlyCharges") + private BigDecimal taxamount=BigDecimal.ZERO; + + @JsonProperty("penalty") + private BigDecimal penalty=BigDecimal.ZERO; + + @JsonProperty("totalForCurrentMonth") + private BigDecimal totalForCurrentMonth=BigDecimal.ZERO; + + @JsonProperty("previousMonthBalance") + private BigDecimal arrears=BigDecimal.ZERO; + + @JsonProperty("totalDues") + private BigDecimal total_due_amount=BigDecimal.ZERO; + + @JsonProperty("dueDateOfPayment") + private Long dueDate= 0L; + + @JsonProperty("penaltyAppliedOnDate") + private Long penaltyAppliedDate=0L; + +// public DemandLedgerReport(String monthAndYear) { +// this.monthAndYear = monthAndYear; +// this.taxamount = BigDecimal.ZERO; +// this.penalty = BigDecimal.ZERO; +// this.totalForCurrentMonth = BigDecimal.ZERO; +// this.arrears = BigDecimal.ZERO; +// this.total_due_amount = BigDecimal.ZERO; +// } +} 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 new file mode 100644 index 000000000..3dac0232e --- /dev/null +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReport.java @@ -0,0 +1,20 @@ +package org.egov.waterconnection.web.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.*; + +import java.util.ArrayList; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class LedgerReport +{ + @JsonProperty("demand") + private DemandLedgerReport demand=null; + + @JsonProperty("payment") + private List payment=new ArrayList<>(); +} diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReportResponse.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReportResponse.java new file mode 100644 index 000000000..0d00ce4cd --- /dev/null +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/LedgerReportResponse.java @@ -0,0 +1,24 @@ +package org.egov.waterconnection.web.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import org.egov.common.contract.response.ResponseInfo; + +import java.util.List; +import java.util.Map; + +@Builder +public class LedgerReportResponse +{ + @JsonProperty("ledgerReport") + private List> ledgerReport; + + @JsonProperty("tenantName") + private String tenantName; + + @JsonProperty("financialYear") + private String financialYear; + + @JsonProperty("responseInfo") + private ResponseInfo responseInfo = null; +} diff --git a/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/PaymentLedgerReport.java b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/PaymentLedgerReport.java new file mode 100644 index 000000000..692bf7672 --- /dev/null +++ b/municipal-services/ws-services/src/main/java/org/egov/waterconnection/web/models/PaymentLedgerReport.java @@ -0,0 +1,28 @@ +package org.egov.waterconnection.web.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class PaymentLedgerReport +{ + @JsonProperty("paymentCollectionDate") + private Long collectionDate; + + @JsonProperty("receiptNo") + private String receiptNo=null; + + @JsonProperty("amountPaid") + private BigDecimal paid= BigDecimal.ZERO; + + @JsonProperty("balanceLeft") + private BigDecimal balanceLeft=BigDecimal.ZERO; +}