-
Notifications
You must be signed in to change notification settings - Fork 20
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
Develop #815
Develop #815
Changes from all commits
adee4f3
645cd99
26f5665
3c97434
5a5a22b
5928845
cdc5b77
6721992
27a36d1
2942721
0d997a6
b4e6559
64f9ab6
2c9ef9d
c6b30bc
fd4ca00
ec48fd2
0b31f54
3b01e83
230f137
0749c5d
9ab94c2
2e6945a
511cb08
e8c6b0f
1d8c2ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,8 @@ public void setValues(PreparedStatement ps, int index) throws SQLException { | |
AuditDetails auditDetails = bill.getAuditDetails(); | ||
|
||
ps.setString(1, bill.getId()); | ||
ps.setString(15, bill.getUserId()); | ||
ps.setString(16, bill.getConsumerCode()); | ||
Comment on lines
+72
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure correct parameter ordering in the prepared statement for The order of parameters |
||
ps.setString(2, bill.getTenantId()); | ||
ps.setString(3, bill.getPayerName()); | ||
ps.setString(4, bill.getPayerAddress()); | ||
|
@@ -82,8 +84,8 @@ public void setValues(PreparedStatement ps, int index) throws SQLException { | |
ps.setString(12, bill.getMobileNumber()); | ||
ps.setString(13, bill.getStatus().toString()); | ||
ps.setObject(14, util.getPGObject(bill.getAdditionalDetails())); | ||
ps.setString(15, bill.getConsumerCode()); | ||
ps.setString(16, bill.getTenantId()); | ||
// ps.setString(15, bill.getConsumerCode()); | ||
// ps.setString(16, bill.getTenantId()); | ||
|
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,9 @@ public class BillQueryBuilder { | |
public static final String BILL_STATUS_UPDATE_BASE_QUERY = "UPDATE egbs_bill_v1 SET status=?, lastmodifieddate=? {replace} WHERE status='ACTIVE' AND tenantId = ? "; | ||
|
||
public static final String INSERT_BILL_QUERY = "INSERT into egbs_bill_v1 " | ||
+ " (id, tenantid, payername, payeraddress, payeremail, isactive, iscancelled, createdby, createddate, lastmodifiedby, lastmodifieddate, mobilenumber, status, additionaldetails)" | ||
+ " SELECT ?,?,?,?,?,?,?,?,?,?,?,?,?,? " | ||
+ " WHERE NOT EXISTS (SELECT distinct(consumercode) FROM egbs_bill_v1 bill INNER JOIN egbs_billdetail_v1 billd ON bill.id=billd.billid " | ||
+ " WHERE status = 'ACTIVE' AND consumerCode = ? AND bill.tenantid = ?)"; | ||
+"(id, tenantid, payername, payeraddress, payeremail, isactive, iscancelled, createdby, createddate, lastmodifiedby, lastmodifieddate," | ||
+" mobilenumber, status, additionaldetails, payerid, consumercode)" | ||
+"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; | ||
|
||
|
||
public static final String INSERT_BILLDETAILS_QUERY = "INSERT into egbs_billdetail_v1 " | ||
|
@@ -49,7 +48,7 @@ public class BillQueryBuilder { | |
+ " INNER JOIN (SELECT bd_consumercode, min(b_createddate) as mindate FROM billresult GROUP BY bd_consumercode) as uniqbill" | ||
+ " ON uniqbill.bd_consumercode=billresult.bd_consumercode AND uniqbill.mindate=billresult.b_createddate "; | ||
|
||
public static final String BILL_BASE_QUERY = "SELECT b.id AS b_id,b.mobilenumber, b.tenantid AS b_tenantid," | ||
public static final String BILL_BASE_QUERY = "SELECT b.id AS b_id,b.mobilenumber, b.tenantid AS b_tenantid,b.payerid AS b_payerid," | ||
+ " b.payername AS b_payername, b.payeraddress AS b_payeraddress, b.payeremail AS b_payeremail,b.filestoreid AS b_fileStoreId," | ||
+ " b.isactive AS b_isactive, b.iscancelled AS b_iscancelled, b.createdby AS b_createdby, b.status as b_status," | ||
+ " b.createddate AS b_createddate, b.lastmodifiedby AS b_lastmodifiedby, b.lastmodifieddate AS b_lastmodifieddate," | ||
|
@@ -82,9 +81,9 @@ public String getBillQuery(BillSearchCriteria billSearchCriteria, List<Object> p | |
} | ||
addWhereClause(billQuery, preparedStatementValues, billSearchCriteria); | ||
|
||
if(billSearchCriteria!=null && billSearchCriteria.getReturnAllBills()) { | ||
return billQuery.toString(); | ||
} | ||
// if(billSearchCriteria!=null && billSearchCriteria.getReturnAllBills()) { | ||
// return billQuery.toString(); | ||
// } | ||
Comment on lines
+84
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented out conditional return statement. The conditional return statement in |
||
StringBuilder maxQuery = addPagingClause(billQuery, preparedStatementValues, billSearchCriteria); | ||
|
||
return maxQuery.toString(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ | |
import java.util.UUID; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Importing Please verify if the |
||
|
||
import org.egov.common.contract.request.RequestInfo; | ||
import org.egov.demand.config.ApplicationProperties; | ||
|
@@ -99,6 +100,10 @@ | |
import org.springframework.util.CollectionUtils; | ||
import org.springframework.util.ObjectUtils; | ||
import org.springframework.util.StringUtils; | ||
import org.egov.demand.producer.Producer; | ||
import org.egov.demand.web.contract.UserResponse; | ||
import org.egov.demand.web.contract.UserSearchRequest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
|
@@ -138,9 +143,20 @@ public class BillServicev2 { | |
|
||
@Autowired | ||
private BillValidator billValidator; | ||
|
||
@Autowired | ||
private Producer producer; | ||
|
||
@Autowired | ||
private ObjectMapper mapper; | ||
|
||
@Value("${kafka.topics.cancel.bill.topic.name}") | ||
private String billCancelTopic; | ||
|
||
@Value("${kafka.topics.billgen.topic.name}") | ||
private String notifTopicName; | ||
|
||
private static List<String> ownerPlainRequestFieldsList; | ||
|
||
/** | ||
* Cancell bill operation can be carried by this method, based on consumerCodes | ||
|
@@ -154,6 +170,7 @@ public class BillServicev2 { | |
public Integer cancelBill(UpdateBillRequest updateBillRequest) { | ||
|
||
UpdateBillCriteria cancelBillCriteria = updateBillRequest.getUpdateBillCriteria(); | ||
billValidator.validateBillSearchRequest(cancelBillCriteria); | ||
Set<String> consumerCodes = cancelBillCriteria.getConsumerCodes(); | ||
cancelBillCriteria.setStatusToBeUpdated(BillStatus.CANCELLED); | ||
|
||
|
@@ -162,10 +179,31 @@ public Integer cancelBill(UpdateBillRequest updateBillRequest) { | |
throw new CustomException("EG_BS_CANCEL_BILL_ERROR", "Only one consumer code can be provided in the Cancel request"); | ||
} else { | ||
|
||
return billRepository.updateBillStatus(cancelBillCriteria); | ||
int result = billRepository.updateBillStatus(cancelBillCriteria); | ||
sendNotificationForBillCancellation(updateBillRequest.getRequestInfo(), cancelBillCriteria); | ||
return result; | ||
} | ||
} | ||
|
||
private void sendNotificationForBillCancellation(RequestInfo requestInfo, UpdateBillCriteria cancelBillCriteria) { | ||
Set<String> consumerCodes = cancelBillCriteria.getConsumerCodes(); | ||
if(CollectionUtils.isEmpty(consumerCodes)) | ||
return; | ||
|
||
List<BillV2> bills = billRepository.findBill(BillSearchCriteria.builder() | ||
.service(cancelBillCriteria.getBusinessService()) | ||
.tenantId(cancelBillCriteria.getTenantId()) | ||
.consumerCode(consumerCodes) | ||
.build()); | ||
|
||
if (CollectionUtils.isEmpty(bills)) | ||
return; | ||
|
||
BillRequestV2 req = BillRequestV2.builder().bills(bills).requestInfo(requestInfo).build(); | ||
producer.push(billCancelTopic, req); | ||
|
||
} | ||
|
||
/** | ||
* Fetches the bill for given parameters | ||
* | ||
|
@@ -428,6 +466,7 @@ private List<BillV2> prepareBill(List<Demand> demands, RequestInfo requestInfo) | |
.status(BillStatus.ACTIVE) | ||
.billDetails(billDetails) | ||
.totalAmount(billAmount) | ||
.userId(payer.getUuid()) | ||
.billNumber(billNumber) | ||
.tenantId(tenantId) | ||
.id(billId) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -172,5 +172,21 @@ private Constants() {} | |||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
public static final String COUNT_REPLACE_CANCEL_BILL_MSG = "{count}"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// Bill cancel | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELLATION_REASON_MSG= "reasonMessage"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELLATION_REASON_CODE= "reason"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELL_REASON_MSG_NOT_FOUND = "EG_BS_CANCELL_REASON_MSG_NOT"; | ||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELL_REASON_MSG_NOT_FOUND_MSG = "Cancell Reason message with key " + "'" + CANCELLATION_REASON_MSG + "'" + " is madnatory Text field in additionalDetails of Bill cancell Request"; | ||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELL_REASON_MSG_EMPTY_MSG = "Cancell Reason message cannot be empty"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELL_REASON_CODE_NOT_FOUND = "EG_BS_CANCELL_REASON_CODE_NOT"; | ||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELL_REASON_CODE_NOT_FOUND_MSG = "Cancellation Reason with key " + "'" + CANCELLATION_REASON_CODE + "'" + " is a madnatory Text field in additionalDetails of Bill cancell Request"; | ||||||||||||||||||||||||||||||||||||||||||||||
public static final String CANCELL_REASON_CODE_EMPTY_MSG = "Cancell Reason code cannot be empty"; | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+178
to
+188
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure spelling and grammar in exception messages. - public static final String CANCELL_REASON_MSG_NOT_FOUND_MSG = "Cancell Reason message with key " + "'" + CANCELLATION_REASON_MSG + "'" + " is madnatory Text field in additionalDetails of Bill cancell Request";
+ public static final String CANCELL_REASON_MSG_NOT_FOUND_MSG = "Cancellation Reason message with key " + "'" + CANCELLATION_REASON_MSG + "'" + " is a mandatory Text field in additionalDetails of Bill cancellation Request";
- public static final String CANCELL_REASON_CODE_NOT_FOUND_MSG = "Cancellation Reason with key " + "'" + CANCELLATION_REASON_CODE + "'" + " is a madnatory Text field in additionalDetails of Bill cancell Request";
+ public static final String CANCELL_REASON_CODE_NOT_FOUND_MSG = "Cancellation Reason with key " + "'" + CANCELLATION_REASON_CODE + "'" + " is a mandatory Text field in additionalDetails of Bill cancellation Request"; Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
public static final String PENALTY_PATH_CODE = "$.MdmsRes.ws-services-calculation.Penalty"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
package org.egov.demand.web.validator; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import static org.egov.demand.util.Constants.BILL_GEN_MANDATORY_FIELDS_MISSING_KEY; | ||
import static org.egov.demand.util.Constants.BILL_GEN_MANDATORY_FIELDS_MISSING_MSG; | ||
|
||
import org.egov.common.contract.request.RequestInfo; | ||
import org.egov.demand.model.BillSearchCriteria; | ||
import org.egov.demand.model.BillV2.BillStatus; | ||
import org.egov.demand.model.GenerateBillCriteria; | ||
import org.egov.demand.util.Util; | ||
import org.egov.tracer.model.CustomException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.CollectionUtils; | ||
import org.springframework.validation.Errors; | ||
import org.egov.demand.model.UpdateBillCriteria; | ||
import org.egov.demand.util.Constants; | ||
import org.springframework.util.StringUtils; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
@Component | ||
public class BillValidator { | ||
|
@@ -57,4 +65,28 @@ public void validateBillSearchCriteria(BillSearchCriteria billCriteria, RequestI | |
} | ||
} | ||
|
||
public void validateBillSearchRequest(UpdateBillCriteria cancelBillCriteria) { | ||
cancelBillCriteria.setStatusToBeUpdated(BillStatus.CANCELLED); | ||
JsonNode additionalDetails = cancelBillCriteria.getAdditionalDetails(); | ||
Map<String, String> errorMap = new HashMap<>(); | ||
JsonNode reasonMsg = additionalDetails.get(Constants.CANCELLATION_REASON_MSG); | ||
JsonNode reasonCode = additionalDetails.get(Constants.CANCELLATION_REASON_CODE); | ||
if (null != reasonCode && reasonCode.isTextual()) { | ||
if (StringUtils.isEmpty(reasonCode.textValue())) | ||
errorMap.put(Constants.CANCELL_REASON_CODE_NOT_FOUND, Constants.CANCELL_REASON_CODE_EMPTY_MSG); | ||
} else { | ||
errorMap.put(Constants.CANCELL_REASON_CODE_NOT_FOUND, Constants.CANCELL_REASON_CODE_NOT_FOUND_MSG); | ||
} | ||
|
||
if (null != reasonMsg && reasonMsg.isTextual()) { | ||
if (StringUtils.isEmpty(reasonMsg.textValue())) | ||
errorMap.put(Constants.CANCELL_REASON_MSG_NOT_FOUND, Constants.CANCELL_REASON_MSG_EMPTY_MSG); | ||
} else { | ||
errorMap.put(Constants.CANCELL_REASON_MSG_NOT_FOUND, Constants.CANCELL_REASON_MSG_NOT_FOUND_MSG); | ||
} | ||
if (!CollectionUtils.isEmpty(errorMap)) { | ||
throw new CustomException(errorMap); | ||
} | ||
} | ||
Comment on lines
+68
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE egbs_bill_v1 add column payerid character varying (128); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ALTER TABLE egbs_bill_v1 ADD COLUMN IF NOT EXISTS consumercode CHARACTER VARYING(256); | ||
|
||
UPDATE egbs_bill_v1 b SET consumerCode = bd.consumercode FROM egbs_billdetail_v1 bd WHERE bd.billid = b.id; | ||
|
||
ALTER TABLE egbs_bill_v1 ALTER COLUMN consumercode SET NOT NULL; | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS index_egbs_UNIQUE_ACTIVE_BILL ON egbs_bill_v1 (consumercode, tenantid, status) where status='ACTIVE'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of
userId
is aligned with the backend changes mentioned. Consider adding validation annotations (e.g.,@Size
,@NotNull
) if applicable, depending on the expected constraints foruserId
.