This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #693 from egovernments/PFM-4082
PFM-4082 Expense Bill Report
- Loading branch information
Showing
8 changed files
with
267 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...ices/src/main/java/org/egov/echallan/repository/rowmapper/ExpenseBillReportRowMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.egov.echallan.repository.rowmapper; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.egov.echallan.model.UserInfo; | ||
import org.egov.echallan.service.UserService; | ||
import org.egov.echallan.web.models.ExpenseBillReportData; | ||
import org.egov.echallan.web.models.ExpenseBillReportResponse; | ||
import org.egov.echallan.web.models.user.User; | ||
import org.egov.echallan.web.models.user.UserDetailResponse; | ||
import org.egov.echallan.web.models.user.UserSearchRequest; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.dao.DataAccessException; | ||
import org.springframework.jdbc.core.ResultSetExtractor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.*; | ||
|
||
@Component | ||
@Slf4j | ||
public class ExpenseBillReportRowMapper implements ResultSetExtractor<List<ExpenseBillReportData>> | ||
{ | ||
@Autowired | ||
private ObjectMapper mapper; | ||
|
||
@Autowired | ||
private UserService userService; | ||
|
||
@Override | ||
public List<ExpenseBillReportData> extractData(ResultSet resultSet) throws SQLException, DataAccessException { | ||
|
||
List<ExpenseBillReportData> expenseBillReportDataList=new ArrayList<>(); | ||
|
||
while(resultSet.next()) | ||
{ | ||
ExpenseBillReportData expenseBillReportData=new ExpenseBillReportData(); | ||
expenseBillReportData.setTypeOfExpense(resultSet.getString("typeofexpense")); | ||
expenseBillReportData.setVendorName(resultSet.getString("name")); | ||
expenseBillReportData.setAmount(resultSet.getLong("total_taxamount")); | ||
expenseBillReportData.setBillDate(resultSet.getLong("billdate")); | ||
expenseBillReportData.setTaxPeriodFrom(resultSet.getLong("taxperiodfrom")); | ||
expenseBillReportData.setTaxPeriodTo(resultSet.getLong("taxperiodto")); | ||
expenseBillReportData.setApplicationStatus(resultSet.getString("applicationstatus")); | ||
|
||
if(resultSet.getString("paiddate")!=null) | ||
expenseBillReportData.setPaidDate(resultSet.getLong("paiddate")); | ||
else | ||
expenseBillReportData.setPaidDate(0L); | ||
if(resultSet.getString("filestoreid")!=null) | ||
expenseBillReportData.setFilestoreid("Yes"); | ||
else | ||
expenseBillReportData.setFilestoreid("No"); | ||
if(Objects.equals(resultSet.getString("applicationstatus"), "CANCELLED")) { | ||
expenseBillReportData.setLastModifiedTime(resultSet.getLong("lastmodifiedtime")); | ||
expenseBillReportData.setLastModifiedByUuid(resultSet.getString("lastmodifiedbyUuid")); | ||
enrichExpenseHolderDetails(expenseBillReportData); | ||
} | ||
else | ||
{ | ||
expenseBillReportData.setLastModifiedTime(0L); | ||
expenseBillReportData.setLastModifiedBy(null); | ||
} | ||
expenseBillReportDataList.add(expenseBillReportData); | ||
} | ||
return expenseBillReportDataList; | ||
} | ||
|
||
private void enrichExpenseHolderDetails(ExpenseBillReportData expenseBillReportData) | ||
{ | ||
UserSearchRequest userSearchRequest=new UserSearchRequest(); | ||
userSearchRequest.setUuid(Collections.singletonList(expenseBillReportData.getLastModifiedByUuid())); | ||
log.info("Uuid's for searching users"+userSearchRequest.getUuid().toString()); | ||
|
||
UserDetailResponse userDetailResponse=userService.getUsers(userSearchRequest); | ||
log.info("User after searching"+userDetailResponse.getUser().toString()); | ||
|
||
enrichConnectionHolderInfo(userDetailResponse,expenseBillReportData); | ||
} | ||
|
||
private void enrichConnectionHolderInfo(UserDetailResponse userDetailResponse, ExpenseBillReportData expenseBillReportData) | ||
{ | ||
List<UserInfo> connectionHolderInfos= userDetailResponse.getUser(); | ||
if (connectionHolderInfos.isEmpty()) { | ||
return; | ||
} | ||
log.info("Users in enrichConnectionHolderInfo method"+connectionHolderInfos.toString()); | ||
expenseBillReportData.setLastModifiedBy(connectionHolderInfos.get(0).getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...s/echallan-services/src/main/java/org/egov/echallan/web/models/ExpenseBillReportData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.egov.echallan.web.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
import org.egov.echallan.model.Amount; | ||
import org.hibernate.validator.constraints.SafeHtml; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ExpenseBillReportData | ||
{ | ||
@JsonProperty("typeOfExpense") | ||
private String typeOfExpense; | ||
|
||
@JsonProperty("vendorName") | ||
private String vendorName; | ||
|
||
@JsonProperty("amount") | ||
private Long amount; | ||
|
||
@JsonProperty("billDate") | ||
private Long billDate; | ||
|
||
@JsonProperty("taxPeriodFrom") | ||
private Long taxPeriodFrom; | ||
|
||
@JsonProperty("taxPeriodTo") | ||
private Long taxPeriodTo; | ||
|
||
@JsonProperty("applicationStatus") | ||
private String applicationStatus; | ||
|
||
@JsonProperty("paidDate") | ||
private Long paidDate; | ||
|
||
@JsonProperty("filestoreid") | ||
@SafeHtml | ||
private String filestoreid; | ||
|
||
@JsonProperty("lastModifiedTime") | ||
private Long lastModifiedTime; | ||
|
||
@JsonProperty("lastModifiedByUuid") | ||
private String lastModifiedByUuid; | ||
|
||
@JsonProperty("lastModifiedBy") | ||
private String lastModifiedBy; | ||
|
||
@JsonProperty("tenantId") | ||
private String tenantId; | ||
} |
20 changes: 20 additions & 0 deletions
20
...hallan-services/src/main/java/org/egov/echallan/web/models/ExpenseBillReportResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.egov.echallan.web.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
import org.apache.coyote.RequestInfo; | ||
import org.egov.common.contract.response.ResponseInfo; | ||
|
||
import java.util.List; | ||
|
||
|
||
@Builder | ||
public class ExpenseBillReportResponse { | ||
|
||
@JsonProperty("ExpenseBillReportData") | ||
private List<ExpenseBillReportData> ExpenseBillReportData; | ||
|
||
@JsonProperty("responseInfo") | ||
private ResponseInfo responseInfo = null; | ||
|
||
} |