diff --git a/android-studio-bluetooth-printer/CHANGELOG.md b/android-studio-bluetooth-printer/CHANGELOG.md
new file mode 100644
index 0000000..2760fd0
--- /dev/null
+++ b/android-studio-bluetooth-printer/CHANGELOG.md
@@ -0,0 +1,10 @@
+Changelog
+All notable changes to this module will be documented in this file.
+
+### 1.0.1 - 2021-MAY-05
+
+- Added changes due to security fixes in Android App.
+
+### 1.0.0 - 2020-OCT-03
+
+- Added this module to generate APK to connect and print receipt
diff --git a/android-studio-bluetooth-printer/app/build.gradle b/android-studio-bluetooth-printer/app/build.gradle
index 94d06b7..5bda6e0 100644
--- a/android-studio-bluetooth-printer/app/build.gradle
+++ b/android-studio-bluetooth-printer/app/build.gradle
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 24
+ compileSdkVersion 26
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "anil.com.andoirdbluetoothprint"
minSdkVersion 19
- targetSdkVersion 24
+ targetSdkVersion 26
versionCode 1
- versionName "1.0"
+ versionName "1.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
diff --git a/android-studio-bluetooth-printer/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml b/android-studio-bluetooth-printer/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml
index 9358eea..24419f5 100644
--- a/android-studio-bluetooth-printer/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml
+++ b/android-studio-bluetooth-printer/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml
@@ -16,20 +16,20 @@
-
-
+
+
-
+
diff --git a/android-studio-bluetooth-printer/app/src/main/AndroidManifest.xml b/android-studio-bluetooth-printer/app/src/main/AndroidManifest.xml
index 8382f46..4acea50 100644
--- a/android-studio-bluetooth-printer/app/src/main/AndroidManifest.xml
+++ b/android-studio-bluetooth-printer/app/src/main/AndroidManifest.xml
@@ -11,18 +11,18 @@
-
-
+
+
-
+
@@ -34,6 +34,7 @@
+
\ No newline at end of file
diff --git a/android-studio-bluetooth-printer/app/src/main/java/anil/com/andoirdbluetoothprint/MainActivity.java b/android-studio-bluetooth-printer/app/src/main/java/anil/com/andoirdbluetoothprint/MainActivity.java
index 0592995..9dcbd0c 100644
--- a/android-studio-bluetooth-printer/app/src/main/java/anil/com/andoirdbluetoothprint/MainActivity.java
+++ b/android-studio-bluetooth-printer/app/src/main/java/anil/com/andoirdbluetoothprint/MainActivity.java
@@ -53,7 +53,7 @@ public void onResume() {
try{
updateReceiptText();
} catch (Exception ex) {
- ex.printStackTrace();
+ Log.e(TAG, "Receipt failed", ex);
}
}
@@ -74,7 +74,7 @@ public void onClick(View mView) {
openBluetoothPrinter();
printData();
}catch(Exception ex){
- ex.printStackTrace();
+ Log.e(TAG, "Printing Data Failed", ex);
}
}
});
@@ -107,7 +107,6 @@ void findBluetoothDevice(){
}
void openBluetoothPrinter() throws IOException{
-
try{
UUID uuidString = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
mBluetoothSocket = mBluetoothDevice.createRfcommSocketToServiceRecord(uuidString);
@@ -115,7 +114,7 @@ void openBluetoothPrinter() throws IOException{
outputStream = mBluetoothSocket.getOutputStream();
inputStream = mBluetoothSocket.getInputStream();
}catch(Exception ex){
- ex.printStackTrace();
+ Log.e(TAG, "Bluetooth connection failed", ex);
}
}
diff --git a/case-management/src/main/java/egov/casemanagement/web/controllers/CovaApiController.java b/case-management/src/main/java/egov/casemanagement/web/controllers/CovaApiController.java
index 6ae834d..7158331 100644
--- a/case-management/src/main/java/egov/casemanagement/web/controllers/CovaApiController.java
+++ b/case-management/src/main/java/egov/casemanagement/web/controllers/CovaApiController.java
@@ -10,6 +10,7 @@
import egov.casemanagement.service.CovaService;
import egov.casemanagement.web.models.HealthdetailCreateRequest;
import egov.casemanagement.web.models.RequestInfoWrapper;
+import org.apache.commons.io.IOUtils;
import org.egov.tracer.model.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -24,6 +25,7 @@
import javax.validation.Valid;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@@ -46,7 +48,18 @@ public CovaApiController(ObjectMapper objectMapper, CovaService covaService, @Va
this.covaService = covaService;
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
- JsonNode schema = JsonLoader.fromReader(new InputStreamReader(resource.getInputStream()));
+ InputStream inputStream = null;
+ JsonNode schema = null;
+ try{
+ inputStream = resource.getInputStream();
+ schema = JsonLoader.fromReader(new InputStreamReader(inputStream));
+ }
+ catch (IOException e){
+ throw new CustomException("IO ERROR","Failed to read the resource");
+ }
+ finally {
+ IOUtils.closeQuietly(inputStream);
+ }
jsonSchema = factory.getJsonSchema(schema);
}
diff --git a/case-management/src/main/java/egov/casemanagement/web/controllers/HealthdetailApiController.java b/case-management/src/main/java/egov/casemanagement/web/controllers/HealthdetailApiController.java
index d559713..1781ca0 100644
--- a/case-management/src/main/java/egov/casemanagement/web/controllers/HealthdetailApiController.java
+++ b/case-management/src/main/java/egov/casemanagement/web/controllers/HealthdetailApiController.java
@@ -10,6 +10,7 @@
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import egov.casemanagement.service.CaseService;
import egov.casemanagement.web.models.HealthdetailCreateRequest;
+import org.apache.commons.io.IOUtils;
import org.egov.tracer.model.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -23,6 +24,7 @@
import javax.validation.Valid;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
@@ -47,7 +49,21 @@ public HealthdetailApiController(ObjectMapper objectMapper, CaseService caseServ
this.caseService = caseService;
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
- JsonNode schema = JsonLoader.fromReader(new InputStreamReader(resource.getInputStream()));
+
+ InputStream inputStream = null;
+ JsonNode schema = null;
+
+ try {
+ inputStream = resource.getInputStream();
+ schema = JsonLoader.fromReader(new InputStreamReader(inputStream));
+ }
+ catch (IOException e){
+ throw new CustomException("IO ERROR","Failed to read the resource");
+ }
+ finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+
jsonSchema = factory.getJsonSchema(schema);
}
diff --git a/egov-custom-consumer/src/main/java/org/egov/cosumer/CustomConsumer.java b/egov-custom-consumer/src/main/java/org/egov/cosumer/CustomConsumer.java
index 0864cf4..933c043 100644
--- a/egov-custom-consumer/src/main/java/org/egov/cosumer/CustomConsumer.java
+++ b/egov-custom-consumer/src/main/java/org/egov/cosumer/CustomConsumer.java
@@ -1,6 +1,6 @@
package org.egov.cosumer;
-import java.util.HashMap;
+import java.util.Map;
import org.egov.service.SignOutService;
import org.egov.utils.JsonPathConstant;
@@ -10,7 +10,6 @@
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
@@ -23,29 +22,18 @@ public class CustomConsumer {
@Autowired
private SignOutService signOutService;
- @Autowired
- private ObjectMapper objectMapper;
-
@KafkaListener(topics = { "${egov.custom.async.filter.topic}" })
- public void listen(final HashMap record, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
+ public void listen(final Map record, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
log.info("CustomConsumer received request from topic: " + topic);
log.info("data: " + record);
log.info(record.keySet().toString());
-
- try {
- //String inputJson = objectMapper.writeValueAsString(record);
- DocumentContext documentContext = JsonPath.parse(record);
- String sourceUri = documentContext.read(JsonPathConstant.signOutUriJsonPath);
-
- if(sourceUri.equals(JsonPathConstant.signOutUri))
- signOutService.callFinanceForSignOut(documentContext);
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- // ObjectMapper mapper = new ObjectMapper();
+ DocumentContext documentContext = JsonPath.parse(record);
+ String sourceUri = documentContext.read(JsonPathConstant.signOutUriJsonPath);
+
+ if (sourceUri.equals(JsonPathConstant.signOutUri))
+ signOutService.callFinanceForSignOut(documentContext);
}
diff --git a/egov-custom-consumer/src/main/java/org/egov/service/SignOutService.java b/egov-custom-consumer/src/main/java/org/egov/service/SignOutService.java
index 6936f87..b2b725e 100644
--- a/egov-custom-consumer/src/main/java/org/egov/service/SignOutService.java
+++ b/egov-custom-consumer/src/main/java/org/egov/service/SignOutService.java
@@ -9,7 +9,6 @@
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
-import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import com.jayway.jsonpath.DocumentContext;
@@ -20,34 +19,25 @@
@Slf4j
public class SignOutService {
- @Autowired
- private RestTemplate restTemplate;
-
- @Value("${egov.coexistence.hostname}")
- private String coexistencehost;
-
- @Value("${egov.coexistence.singout.uri}")
- private String coexistencelogoutUri;
-
- public void callFinanceForSignOut(DocumentContext documentContext) {
- ResponseEntity> response = null;
- try {
- ;
- String accessToken = documentContext.read(JsonPathConstant.signOutAccessToken);
- documentContext = documentContext.delete(JsonPathConstant.userInfo);
- documentContext = documentContext.put(JsonPathConstant.requestInfo, "authToken", accessToken);
- LinkedHashMap jsonRequest = documentContext.read(JsonPathConstant.request);
-
- response = restTemplate.exchange(coexistencehost + coexistencelogoutUri, HttpMethod.POST,
- new HttpEntity<>(jsonRequest),
- ResponseEntity.class);
- log.info("SignOutService response :" + response.getStatusCode());
- } catch (HttpClientErrorException ex) {
- log.error(ex.getResponseBodyAsString());
- ex.printStackTrace();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
+ @Autowired
+ private RestTemplate restTemplate;
+
+ @Value("${egov.coexistence.hostname}")
+ private String coexistencehost;
+
+ @Value("${egov.coexistence.singout.uri}")
+ private String coexistencelogoutUri;
+
+ public void callFinanceForSignOut(DocumentContext documentContext) {
+ ResponseEntity> response = null;
+ String accessToken = documentContext.read(JsonPathConstant.signOutAccessToken);
+ documentContext = documentContext.delete(JsonPathConstant.userInfo);
+ documentContext = documentContext.put(JsonPathConstant.requestInfo, "authToken", accessToken);
+ LinkedHashMap jsonRequest = documentContext.read(JsonPathConstant.request);
+
+ response = restTemplate.exchange(coexistencehost + coexistencelogoutUri, HttpMethod.POST,
+ new HttpEntity<>(jsonRequest), ResponseEntity.class);
+ log.info("SignOutService response :" + response.getStatusCode());
+ }
}
diff --git a/egov-pdf/CHANGELOG.md b/egov-pdf/CHANGELOG.md
index 184687d..edd2e4b 100644
--- a/egov-pdf/CHANGELOG.md
+++ b/egov-pdf/CHANGELOG.md
@@ -1,7 +1,12 @@
# Changelog
All notable changes to this module will be documented in this file.
-## 1.0.1 -2021-01-12
+## 1.1.0 - 2021-05-12
+
+- Added rotes/middleware for amendment certificate, consolidate bill, TL bill and W&S bill and receipt PDF.
+- Fixed security issue.
+
+## 1.0.1 - 2021-01-12
- Added changes due to collection service dependency
## 1.0.0 - 2020-06-16
diff --git a/egov-pdf/package.json b/egov-pdf/package.json
index 04d632b..85b8b95 100644
--- a/egov-pdf/package.json
+++ b/egov-pdf/package.json
@@ -1,6 +1,6 @@
{
"name": "egov-pdf",
- "version": "1.0.1",
+ "version": "1.1.0",
"private": true,
"main": "index.js",
"scripts": {
diff --git a/egov-pdf/src/api.js b/egov-pdf/src/api.js
index f227418..987d85b 100644
--- a/egov-pdf/src/api.js
+++ b/egov-pdf/src/api.js
@@ -103,12 +103,12 @@ async function search_bill(consumerCode, tenantId, requestinfo) {
});
}
-async function search_tllicense(applicationNumber, tenantId, requestinfo) {
+async function search_tllicense(applicationNumber, tenantId, requestinfo, allowCitizenTOSearchOthersRecords) {
var params = {
tenantId: tenantId,
applicationNumber: applicationNumber,
};
- if (checkIfCitizen(requestinfo)) {
+ if (checkIfCitizen(requestinfo) && allowCitizenTOSearchOthersRecords != true) {
var mobileNumber = requestinfo.RequestInfo.userInfo.mobileNumber;
var userName = requestinfo.RequestInfo.userInfo.userName;
params["mobileNumber"] = mobileNumber || userName;
@@ -121,6 +121,42 @@ async function search_tllicense(applicationNumber, tenantId, requestinfo) {
});
}
+async function search_water(applicationNumber, tenantId, requestinfo, allowCitizenTOSearchOthersRecords) {
+ var params = {
+ tenantId: tenantId,
+ applicationNumber: applicationNumber,
+ };
+ if (checkIfCitizen(requestinfo) && allowCitizenTOSearchOthersRecords != true) {
+ var mobileNumber = requestinfo.RequestInfo.userInfo.mobileNumber;
+ var userName = requestinfo.RequestInfo.userInfo.userName;
+ params["mobileNumber"] = mobileNumber || userName;
+ }
+ return await axios({
+ method: "post",
+ url: url.resolve(config.host.wns, config.paths.water_search),
+ data: requestinfo,
+ params,
+ });
+}
+
+async function search_sewerage(applicationNumber, tenantId, requestinfo, allowCitizenTOSearchOthersRecords) {
+ var params = {
+ tenantId: tenantId,
+ applicationNumber: applicationNumber,
+ };
+ if (checkIfCitizen(requestinfo) && allowCitizenTOSearchOthersRecords != true) {
+ var mobileNumber = requestinfo.RequestInfo.userInfo.mobileNumber;
+ var userName = requestinfo.RequestInfo.userInfo.userName;
+ params["mobileNumber"] = mobileNumber || userName;
+ }
+ return await axios({
+ method: "post",
+ url: url.resolve(config.host.wns, config.paths.sewerage_search),
+ data: requestinfo,
+ params,
+ });
+}
+
async function search_mdms(tenantId, module, master, requestinfo) {
return await axios({
method: "post",
@@ -133,6 +169,56 @@ async function search_mdms(tenantId, module, master, requestinfo) {
});
}
+async function search_echallan(tenantId, challanNo,requestinfo) {
+ return await axios({
+ method: "post",
+ url: url.resolve(config.host.challan, config.paths.mcollect_challan_search),
+ data: requestinfo,
+ params: {
+ tenantId: tenantId,
+ challanNo: challanNo,
+ },
+ });
+}
+
+
+async function search_bill_genie(data,requestinfo) {
+ return await axios({
+ method: "post",
+ url: url.resolve(config.host.bill, config.paths.bill_genie_getBill),
+ data: Object.assign(requestinfo, data),
+ });
+}
+
+async function search_billV2(tenantId, consumerCode, serviceId, requestinfo) {
+ //console.log("search_billV2 consumerCode--",consumerCode,"tenantId",tenantId,"serviceId",serviceId);
+ return await axios({
+ method: "post",
+ url: url.resolve(config.host.mcollectBilling, config.paths.mcollect_bill),
+ data: requestinfo,
+ params: {
+ tenantId: tenantId,
+ consumerCode: consumerCode,
+ service:serviceId
+ },
+ });
+}
+
+async function search_amendment(tenantId, amendmentId, serviceId, requestinfo) {
+ //console.log("search_billV2 consumerCode--",amendmentId,"tenantId",tenantId,"serviceId",serviceId);
+ return await axios({
+ method: "post",
+ url: url.resolve(config.host.mcollectBilling, config.paths.bill_ammendment_search),
+ data: requestinfo,
+ params: {
+ tenantId: tenantId,
+ amendmentId: amendmentId,
+ businessService:serviceId
+ },
+ });
+}
+
+
async function create_pdf(tenantId, key, data, requestinfo) {
return await axios({
responseType: "stream",
@@ -164,4 +250,10 @@ module.exports = {
search_payment,
search_tllicense,
search_workflow,
+ search_echallan,
+ search_billV2,
+ search_bill_genie,
+ search_amendment,
+ search_water,
+ search_sewerage
};
diff --git a/egov-pdf/src/app.js b/egov-pdf/src/app.js
index 46407b1..945942f 100644
--- a/egov-pdf/src/app.js
+++ b/egov-pdf/src/app.js
@@ -8,7 +8,9 @@ var epassRouter = require("./routes/epass");
var tlRouter = require("./routes/tl");
var ptRouter = require("./routes/pt");
var paymentRouter = require("./routes/payments");
-// var billRouter = require("./routes/bills");
+var mcollectRouter = require("./routes/mcollect");
+var billRouter = require("./routes/bills");
+var wnsRouter = require("./routes/wns");
var app = express();
app.disable('x-powered-by');
@@ -26,8 +28,10 @@ app.use(express.static(path.join(__dirname, "public")));
app.use(config.app.contextPath + "/download/epass", epassRouter);
app.use(config.app.contextPath + "/download/TL", tlRouter);
app.use(config.app.contextPath + "/download/PT", ptRouter);
+app.use(config.app.contextPath + "/download/UC", mcollectRouter);
app.use(config.app.contextPath + "/download/PAYMENT", paymentRouter);
-// app.use(config.app.contextPath + "/download/BILL", billRouter);
+app.use(config.app.contextPath + "/download/BILL", billRouter);
+app.use(config.app.contextPath + "/download/WNS", wnsRouter);
// catch 404 and forward to error handler
app.use(function (req, res, next) {
diff --git a/egov-pdf/src/config.js b/egov-pdf/src/config.js
index 5482716..5f2fe63 100644
--- a/egov-pdf/src/config.js
+++ b/egov-pdf/src/config.js
@@ -25,6 +25,16 @@ module.exports = {
process.env.CONSOLIDATED_RECEIPT || "consolidatedreceipt",
consolidated_bill_template:
process.env.CONSOLIDATED_BILL || "consolidatedbill",
+ mcollect_challan_template:
+ process.env.MCOLLECT_CHALLAN || "mcollect-challan",
+ mcollect_bill_template:
+ process.env.MCOLLECT_BILL || "mcollect-bill",
+ bill_amendment_template:
+ process.env.BILL_AMENDMENT || "bill-amendment-credit-note",
+ wns_one_time_receipt:
+ process.env.WNS_ONE_TIME_RECEIPT || "ws-onetime-receipt",
+ wns_bill:
+ process.env.WNS_BILL || "ws-bill"
},
app: {
port: parseInt(process.env.APP_PORT) || 8080,
@@ -40,7 +50,10 @@ module.exports = {
user: process.env.EGOV_USER_HOST || HOST,
payments: process.env.EGOV_PAYMENTS_HOST || HOST,
bill: process.env.EGOV_SEARCHER_HOST || HOST,
- workflow: process.env.EGOV_WORKFLOW_HOST || HOST
+ workflow: process.env.EGOV_WORKFLOW_HOST || HOST,
+ challan: process.env.EGOV_ECHALLAN_HOST || 'http://echallan-services.egov:8080/',
+ mcollectBilling: process.env.EGOV_BILLING_HOST || 'http://billing-service.egov:8080/',
+ wns: process.env.EGOV_WNS_HOST || HOST
},
paths: {
pdf_create: "/pdf-service/v1/_createnosave",
@@ -52,6 +65,12 @@ module.exports = {
download_url: "/download/epass",
payment_search: "/collection-services/payments/$module/_search",
bill_search: "/egov-searcher/bill-genie/billswithaddranduser/_get",
- workflow_search: "/egov-workflow-v2/egov-wf/process/_search"
+ workflow_search: "/egov-workflow-v2/egov-wf/process/_search",
+ mcollect_challan_search:"/echallan-services/eChallan/v1/_search",
+ mcollect_bill:"/billing-service/bill/v2/_search",
+ bill_genie_getBill:"/egov-searcher/bill-genie/mcollectbills/_get",
+ bill_ammendment_search: "/billing-service/amendment/_search",
+ water_search: "ws-services/wc/_search",
+ sewerage_search: "sw-services/swc/_search"
},
};
\ No newline at end of file
diff --git a/egov-pdf/src/routes/bills.js b/egov-pdf/src/routes/bills.js
index 3cd46b3..745f9f3 100644
--- a/egov-pdf/src/routes/bills.js
+++ b/egov-pdf/src/routes/bills.js
@@ -1,71 +1,135 @@
-// var express = require("express");
-// var router = express.Router();
-// var url = require("url");
-// var config = require("../config");
+var express = require("express");
+var router = express.Router();
+ var url = require("url");
+ var config = require("../config");
-// var { search_bill, create_pdf } = require("../api");
+ var { search_billV2, search_amendment, create_pdf } = require("../api");
-// const { asyncMiddleware } = require("../utils/asyncMiddleware");
+ const { asyncMiddleware } = require("../utils/asyncMiddleware");
-// function renderError(res, errorMessage) {
-// res.render("error-message", { message: errorMessage });
-// }
+ function renderError(res, errorMessage) {
+ res.render("error-message", { message: errorMessage });
+ }
-// /* GET users listing. */
-// router.post(
-// "/consolidatedbill",
-// asyncMiddleware(async function (req, res, next) {
-// var tenantId = req.query.tenantId;
-// var consumerCode = req.query.consumerCode;
-// var requestinfo = req.body;
-// if (requestinfo == undefined) {
-// return renderError(res, "requestinfo can not be null");
-// }
-// if (!tenantId || !consumerCode) {
-// return renderError(
-// res,
-// "tenantId and consumerCode are mandatory to generate the bill"
-// );
-// }
-// try {
-// var resBill;
-// try {
-// resBill = await search_bill(consumerCode, tenantId, requestinfo);
-// } catch (ex) {
-// console.log(ex.stack);
-// if (ex.response && ex.response.data) console.log(ex.response.data);
-// return renderError(res, "Failed to query details of the bill");
-// }
-// var bills = resBill.data;
-// var pdfkey = config.pdf.consolidated_bill_template;
-// if (bills && bills.Bills && bills.Bills.length > 0) {
-// var pdfResponse;
-// try {
-// var billArray = { Bill: bills.Bills };
-// pdfResponse = await create_pdf(
-// tenantId,
-// pdfkey,
-// billArray,
-// requestinfo
-// );
-// } catch (ex) {
-// console.log(ex.stack);
-// if (ex.response && ex.response.data) console.log(ex.response.data);
-// return renderError(res, "Failed to generate PDF for the bill");
-// }
-// var filename = `${pdfkey}_${new Date().getTime()}`;
-// res.writeHead(200, {
-// "Content-Type": "application/pdf",
-// "Content-Disposition": `attachment; filename=${filename}.pdf`,
-// });
-// pdfResponse.data.pipe(res);
-// } else {
-// return renderError(res, "There is no bill for this code");
-// }
-// } catch (ex) {
-// console.log(ex.stack);
-// }
-// })
-// );
+ /* GET users listing. */
+ router.post(
+ "/consolidatedbill",
+ asyncMiddleware(async function (req, res, next) {
+ var tenantId = req.query.tenantId;
+ var consumerCode = req.query.consumerCode;
+ var bussinessService = req.query.bussinessService;
+ var requestinfo = req.body;
+ if (requestinfo == undefined) {
+ return renderError(res, "requestinfo can not be null");
+ }
+ if (!tenantId || !consumerCode) {
+ return renderError(
+ res,
+ "tenantId and consumerCode are mandatory to generate the bill"
+ );
+ }
+ try {
+ var resBill;
+ try {
+ resBill = await search_billV2(tenantId, consumerCode, bussinessService, requestinfo);
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to query details of the bill");
+ }
+ var bills = resBill.data;
+ var pdfkey = config.pdf.consolidated_bill_template;
-// module.exports = router;
+ if (bills && bills.Bill && bills.Bill.length > 0) {
+ console.log("Hi");
+ var pdfResponse;
+ try {
+ var billArray = { Bill: bills.Bill };
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ billArray,
+ requestinfo
+ );
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to generate PDF for the bill");
+ }
+
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no bill for this code");
+ }
+ } catch (ex) {
+ return renderError(res, "Failed to query details of the bill");
+ }
+ })
+ );
+
+ router.post(
+ "/billamendmentcertificate",
+ asyncMiddleware(async function (req, res, next) {
+ var tenantId = req.query.tenantId;
+ var amendmentId = req.query.amendmentId;
+ var bussinessService = req.query.bussinessService;
+ var requestinfo = req.body;
+
+ if (requestinfo == undefined) {
+ return renderError(res, "requestinfo can not be null");
+ }
+ if (!tenantId || !amendmentId) {
+ return renderError(
+ res,
+ "tenantId and amendmentId are mandatory to generate the bill"
+ );
+ }
+ try {
+ var billAmendment;
+ try {
+ billAmendment = await search_amendment(tenantId, amendmentId, bussinessService, requestinfo);
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to query details of the bill amendment");
+ }
+ var amendment = billAmendment.data;
+ var pdfkey = config.pdf.bill_amendment_template;
+
+ if (amendment && amendment.Amendments && amendment.Amendments.length > 0) {
+ var pdfResponse;
+ try {
+ var Amendments = { Amendments: amendment.Amendments };
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ Amendments,
+ requestinfo
+ );
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to generate PDF for the bill amendment");
+ }
+
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no bill amendment for this amendment id");
+ }
+ } catch (ex) {
+ return renderError(res, "Failed to query details of the bill amendment");
+ }
+ })
+ );
+
+ module.exports = router;
diff --git a/egov-pdf/src/routes/epass.js b/egov-pdf/src/routes/epass.js
index 6baa93d..2cb8dca 100644
--- a/egov-pdf/src/routes/epass.js
+++ b/egov-pdf/src/routes/epass.js
@@ -30,7 +30,7 @@ router.get('/', asyncMiddleware(async function(req, res, next) {
try {
resPass = await search_epass(uuid, tenantId);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data)
console.log(ex.response.data);
return renderError(res, "Failed to query details of the pass");
@@ -55,7 +55,7 @@ router.get('/', asyncMiddleware(async function(req, res, next) {
try{
pdfResponse = await create_pdf(tenantId, config.pdf.epass_pdf_template, passes);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data)
console.log(ex.response.data);
return renderError(res, "Failed to generate PDF for the pass");
@@ -70,11 +70,11 @@ router.get('/', asyncMiddleware(async function(req, res, next) {
});
pdfResponse.data.pipe(res);
} else {
- console.log(ex.stack);
+
return renderError(res, "There is no pass for this id");
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query details of the pass");
}
}));
diff --git a/egov-pdf/src/routes/mcollect.js b/egov-pdf/src/routes/mcollect.js
new file mode 100644
index 0000000..51ed987
--- /dev/null
+++ b/egov-pdf/src/routes/mcollect.js
@@ -0,0 +1,239 @@
+var express = require("express");
+var router = express.Router();
+var config = require("../config");
+
+var {
+ search_echallan,
+ search_billV2,
+ search_bill_genie,
+ create_pdf,
+ compareAmount,
+ search_payment_withReceiptNo,
+ } = require("../api");
+
+ const { asyncMiddleware } = require("../utils/asyncMiddleware");
+
+ function renderError(res, errorMessage, errorCode) {
+ if (errorCode == undefined) errorCode = 500;
+ res.status(errorCode).send({ errorMessage });
+ }
+
+ router.post(
+ "/mcollect-challan",
+ asyncMiddleware(async function (req, res, next) {
+ var tenantId = req.query.tenantId;
+ var challanNo = req.query.challanNo;
+ var requestinfo = req.body;
+ if (requestinfo == undefined) {
+ return renderError(res, "requestinfo can not be null", 400);
+ }
+ if (!tenantId || !challanNo) {
+ return renderError(
+ res,
+ "tenantId and challanNo are mandatory to generate the mcollect-challan",
+ 400
+ );
+ }
+ try {
+ try {
+ echallanDtls = await search_echallan(
+ tenantId,
+ challanNo,
+ requestinfo
+ );
+ } catch (ex) {
+ console.log("error",ex.stack);
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to query details of Challan", 500);
+ }
+
+ //console.log("data-",echallanDtls.data);
+ // console.log("data-",JSON.stringify(echallanDtls.data.challans[0]));
+ var echallans = echallanDtls.data;
+ var challanObj;
+ if (
+ echallans &&
+ echallans.challans &&
+ echallans.challans.length > 0
+ ) {
+ challanObj = echallans.challans[0];
+ if(challanObj.filestoreid)
+ {
+ respObj = {
+ filestoreIds:[challanObj.filestoreid],
+ ResponseInfo: requestinfo,
+ key: config.pdf.mcollect_challan_template
+ }
+ //console.log("respObj--",respObj);
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ res.end(JSON.stringify(respObj));
+ }
+ else
+ {
+ var businessService = echallans.challans[0].businessService;
+ var challanBill;
+ try {
+ challanBill = await search_billV2(
+ tenantId,
+ challanNo,
+ businessService,
+ requestinfo
+ );
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ `Failed to query bill for mcollect-challan`,
+ 500
+ );
+ }
+ var challanBillDtl = challanBill.data;
+ //console.log("challanBillDtl--",JSON.stringify(challanBillDtl));
+
+ if (challanBillDtl && challanBillDtl.Bill && challanBillDtl.Bill.length > 0) {
+ challanObj.totalAmount = challanBillDtl.Bill[0].totalAmount;
+ challanObj.billNo = challanBillDtl.Bill[0].billNumber;
+ challanObj.billDate = challanBillDtl.Bill[0].billDate;
+ var sortedObj = challanBillDtl.Bill[0].billDetails[0].billAccountDetails;
+ sortedObj.sort(compareAmount);
+ challanObj.amount = sortedObj;
+ challanObj.mobileNumber = challanObj.citizen.mobileNumber;
+ challanObj.serviceType= challanObj.businessService.split(".")[0];
+ //console.log("final obj--",challanObj);
+ var finalObj = {Challan :challanObj};
+ tenantId = tenantId.split('.')[0];
+ var pdfResponse;
+ var pdfkey = config.pdf.mcollect_challan_template;
+ try {
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ finalObj,
+ requestinfo
+ );
+ } catch (ex) {
+ //
+ // if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ "Failed to generate PDF for mcollect-challan receipt",
+ 500
+ );
+ }
+ //console.log("pdfResponse--",pdfResponse);
+ //console.log("pdfResponse--",pdfResponse.data);
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no bill for this id", 404);
+ }
+
+ }
+ } else {
+ return renderError(
+ res,
+ "There is no challan for you for this applicationNumber",
+ 404
+ );
+ }
+
+ } catch (ex) {
+ return renderError(res, "Failed to query details of Challan", 500);
+ }
+ })
+ );
+
+
+ router.post(
+ "/mcollect-bill",
+ asyncMiddleware(async function (req, res, next) {
+ var tenantId = req.query.tenantId;
+ var consumerCode = req.query.consumerCode;
+ var requestinfo = req.body;
+ if (requestinfo == undefined) {
+ return renderError(res, "requestinfo can not be null", 400);
+ }
+ if (!tenantId || !consumerCode) {
+ return renderError(
+ res,
+ "tenantId and consumerCode are mandatory to generate the mcollect-bill",
+ 400
+ );
+ }
+ var inpData = {searchCriteria :{consumerCode : consumerCode , tenantId:tenantId}};
+ try {
+ try {
+ echallanDtls = await search_bill_genie(
+ inpData,
+ requestinfo
+ );
+ } catch (ex) {
+ console.log("error",ex.stack);
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to query details of bill genie", 500);
+ }
+
+
+ //console.log("data-",echallanDtls.data.Bills[0]);
+ var echallansBill = echallanDtls.data;
+ var challanObj;
+ if (
+ echallansBill &&
+ echallansBill.Bills &&
+ echallansBill.Bills.length > 0
+ ) {
+ var sortedObj = echallansBill.Bills[0].billDetails[0].billAccountDetails;
+ sortedObj.sort(compareAmount);
+ echallansBill.Bills[0].billDetails[0].billAccountDetails = sortedObj;
+ challanObj = echallansBill.Bills;
+ //console.log("final obj--",challanObj);
+ var finalObj = {Bill :challanObj};
+ tenantId = tenantId.split('.')[0];
+ var pdfResponse;
+ var pdfkey = config.pdf.mcollect_bill_template;
+ try {
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ finalObj,
+ requestinfo
+ );
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ "Failed to generate PDF for mcollect bill",
+ 500
+ );
+ }
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+
+ } else {
+ return renderError(res, "There is no bill for this id", 404);
+ }
+
+
+ } catch (ex) {
+ return renderError(res, "Failed to query bill details of Challan", 500);
+ }
+ })
+ );
+
+
+
+ module.exports = router;
\ No newline at end of file
diff --git a/egov-pdf/src/routes/payments.js b/egov-pdf/src/routes/payments.js
index 23255b6..85ec200 100644
--- a/egov-pdf/src/routes/payments.js
+++ b/egov-pdf/src/routes/payments.js
@@ -34,7 +34,7 @@ router.post(
try {
resProperty = await search_payment(consumerCode, tenantId, requestinfo, bussinessService);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to query details of the payment", 500);
}
@@ -50,7 +50,7 @@ router.post(
requestinfo
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to generate PDF for payment", 500);
}
@@ -71,7 +71,7 @@ router.post(
);
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query details of the payment", 500);
}
})
);
diff --git a/egov-pdf/src/routes/pt.js b/egov-pdf/src/routes/pt.js
index b70072b..68971a7 100644
--- a/egov-pdf/src/routes/pt.js
+++ b/egov-pdf/src/routes/pt.js
@@ -40,7 +40,7 @@ router.post(
try {
resProperty = await search_property(uuid, tenantId, requestinfo);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to query details of the property", 500);
}
@@ -73,7 +73,7 @@ router.post(
400
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(
res,
@@ -91,7 +91,7 @@ router.post(
requestinfo
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to generate PDF for property", 500);
}
@@ -112,7 +112,7 @@ router.post(
);
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query certificate details of the property", 500);
}
})
);
@@ -137,7 +137,7 @@ router.post(
try {
resProperty = await search_property(uuid, tenantId, requestinfo, true);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to query details of the property", 500);
}
@@ -152,7 +152,7 @@ router.post(
try {
billresponse = await search_bill(propertyid, tenantId, requestinfo);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, `Failed to query bills for property`, 500);
}
@@ -169,7 +169,7 @@ router.post(
requestinfo
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to generate PDF for property", 500);
}
@@ -193,7 +193,7 @@ router.post(
);
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query bill details of the property", 500);
}
})
);
@@ -218,7 +218,7 @@ router.post(
try {
resProperty = await search_property(uuid, tenantId, requestinfo);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to query details of the property", 500);
}
@@ -239,7 +239,7 @@ router.post(
bussinessService
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, `Failed to query payment for property`, 500);
}
@@ -255,7 +255,7 @@ router.post(
requestinfo
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to generate PDF for property", 500);
}
@@ -279,7 +279,7 @@ router.post(
);
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query receipt details of the property", 500);
}
})
);
diff --git a/egov-pdf/src/routes/tl.js b/egov-pdf/src/routes/tl.js
index 286be11..bc28e57 100644
--- a/egov-pdf/src/routes/tl.js
+++ b/egov-pdf/src/routes/tl.js
@@ -4,7 +4,7 @@ var url = require("url");
var config = require("../config");
var {
- search_bill,
+ search_billV2,
search_payment,
search_tllicense,
create_pdf,
@@ -38,10 +38,10 @@ router.post(
restradelicense = await search_tllicense(
applicationNumber,
tenantId,
- requestinfo
+ requestinfo,
+ false
);
} catch (ex) {
- console.log(ex.stack);
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to query details of tradelicense", 500);
}
@@ -63,7 +63,6 @@ router.post(
bussinessService
);
} catch (ex) {
- console.log(ex.stack);
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(
res,
@@ -83,7 +82,7 @@ router.post(
requestinfo
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(
res,
@@ -108,7 +107,7 @@ router.post(
);
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query receipt details of tradelicense", 500);
}
})
);
@@ -135,10 +134,11 @@ router.post(
restradelicense = await search_tllicense(
applicationNumber,
tenantId,
- requestinfo
+ requestinfo,
+ false
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to query details of tradelicense", 500);
}
@@ -166,7 +166,7 @@ router.post(
requestinfo
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(
res,
@@ -188,7 +188,7 @@ router.post(
);
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query certificate details of tradelicense", 500);
}
})
);
@@ -215,10 +215,11 @@ router.post(
restradelicense = await search_tllicense(
applicationNumber,
tenantId,
- requestinfo
+ requestinfo,
+ false
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(res, "Failed to query details of tradelicense", 500);
}
@@ -253,7 +254,7 @@ router.post(
requestinfo
);
} catch (ex) {
- console.log(ex.stack);
+
if (ex.response && ex.response.data) console.log(ex.response.data);
return renderError(
res,
@@ -275,98 +276,103 @@ router.post(
);
}
} catch (ex) {
- console.log(ex.stack);
+ return renderError(res, "Failed to query certificate details of tradelicense", 500);
}
})
);
-// router.post(
-// "/tlbill",
-// asyncMiddleware(async function (req, res, next) {
-// var tenantId = req.query.tenantId;
-// var applicationNumber = req.query.applicationNumber;
-// var requestinfo = req.body;
-// if (requestinfo == undefined) {
-// return renderError(res, "requestinfo can not be null");
-// }
-// if (!tenantId || !applicationNumber) {
-// return renderError(
-// res,
-// "tenantId and applicationNumber are mandatory to generate the tlreceipt"
-// );
-// }
+ router.post(
+ "/tlbill",
+ asyncMiddleware(async function (req, res, next) {
+ var tenantId = req.query.tenantId;
+ var applicationNumber = req.query.applicationNumber;
+ var bussinessService = req.query.bussinessService;
+ var requestinfo = req.body;
+ if (requestinfo == undefined) {
+ return renderError(res, "requestinfo can not be null");
+ }
+ if (!tenantId || !applicationNumber) {
+ return renderError(
+ res,
+ "tenantId and applicationNumber are mandatory to generate the tlreceipt"
+ );
+ }
-// try {
-// try {
-// restradelicense = await search_tllicense(
-// applicationNumber,
-// tenantId,
-// requestinfo
-// );
-// } catch (ex) {
-// console.log(ex.stack);
-// if (ex.response && ex.response.data) console.log(ex.response.data);
-// return renderError(res, "Failed to query details of tradelicense");
-// }
-// var tradelicenses = restradelicense.data;
+ try {
+ try {
+ restradelicense = await search_tllicense(
+ applicationNumber,
+ tenantId,
+ requestinfo,
+ true
+ );
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to query details of tradelicense");
+ }
+
+ var tradelicenses = restradelicense.data;
-// if (
-// tradelicenses &&
-// tradelicenses.Licenses &&
-// tradelicenses.Licenses.length > 0
-// ) {
-// var applicationNumber = tradelicenses.Licenses[0].applicationNumber;
-// var billresponse;
-// try {
-// billresponse = await search_bill(
-// applicationNumber,
-// tenantId,
-// requestinfo
-// );
-// } catch (ex) {
-// console.log(ex.stack);
-// if (ex.response && ex.response.data) console.log(ex.response.data);
-// return renderError(res, `Failed to query bills for tradelicense`);
-// }
-// var bills = billresponse.data;
-// if (bills && bills.Bills && bills.Bills.length > 0) {
-// var pdfResponse;
-// var pdfkey = config.pdf.tlbill_pdf_template;
-// try {
-// var billArray = { Bill: bills.Bills };
-// pdfResponse = await create_pdf(
-// tenantId,
-// pdfkey,
-// billArray,
-// requestinfo
-// );
-// } catch (ex) {
-// console.log(ex.stack);
-// if (ex.response && ex.response.data) console.log(ex.response.data);
-// return renderError(
-// res,
-// "Failed to generate PDF for tradelicense bill"
-// );
-// }
-// var filename = `${pdfkey}_${new Date().getTime()}`;
-// res.writeHead(200, {
-// "Content-Type": "application/pdf",
-// "Content-Disposition": `attachment; filename=${filename}.pdf`,
-// });
-// pdfResponse.data.pipe(res);
-// } else {
-// return renderError(res, "There is no bill for this id");
-// }
-// } else {
-// return renderError(
-// res,
-// "There is no tradelicense for this applicationNumber"
-// );
-// }
-// } catch (ex) {
-// console.log(ex.stack);
-// }
-// })
-// );
+ if (
+ tradelicenses &&
+ tradelicenses.Licenses &&
+ tradelicenses.Licenses.length > 0
+ ) {
+ var applicationNumber = tradelicenses.Licenses[0].applicationNumber;
+ var billresponse;
+ try {
+ billresponse = await search_billV2(
+ tenantId,
+ applicationNumber,
+ bussinessService,
+ requestinfo
+ );
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, `Failed to query bills for tradelicense`);
+ }
+
+ var bills = billresponse.data;
+ if (bills && bills.Bill && bills.Bill.length > 0) {
+ var pdfResponse;
+ var pdfkey = config.pdf.tlbill_pdf_template;
+ try {
+ var billArray = { Bill: bills.Bill };
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ billArray,
+ requestinfo
+ );
+ } catch (ex) {
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ "Failed to generate PDF for tradelicense bill"
+ );
+ }
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no bill for this id");
+ }
+ } else {
+ return renderError(
+ res,
+ "There is no tradelicense for this applicationNumber"
+ );
+ }
+ } catch (ex) {
+ return renderError(res, "Failed to query bill details of tradelicense", 500);
+ }
+ })
+ );
module.exports = router;
diff --git a/egov-pdf/src/routes/wns.js b/egov-pdf/src/routes/wns.js
new file mode 100644
index 0000000..2b1ad44
--- /dev/null
+++ b/egov-pdf/src/routes/wns.js
@@ -0,0 +1,348 @@
+var express = require("express");
+var router = express.Router();
+var url = require("url");
+var config = require("../config");
+
+var {
+ search_water,
+ search_sewerage,
+ search_billV2,
+ search_payment,
+ create_pdf
+} = require("../api");
+
+const { asyncMiddleware } = require("../utils/asyncMiddleware");
+
+function renderError(res, errorMessage, errorCode) {
+ if (errorCode == undefined) errorCode = 500;
+ res.status(errorCode).send({ errorMessage });
+}
+
+
+router.post(
+ "/wnsbill",
+ asyncMiddleware(async function (req, res, next) {
+ var tenantId = req.query.tenantId;
+ var applicationNumber = req.query.applicationNumber;
+ var bussinessService = req.query.bussinessService;
+ var requestinfo = req.body;
+ var restWns;
+ if (requestinfo == undefined) {
+ return renderError(res, "requestinfo can not be null");
+ }
+ if (!tenantId || !applicationNumber) {
+ return renderError(
+ res,
+ "tenantId and applicationNumber are mandatory to generate the tlreceipt"
+ );
+ }
+
+ try {
+ try {
+ if(bussinessService === 'WS' || bussinessService === 'WS.ONE_TIME_FEE'){
+ restWns = await search_water(
+ applicationNumber,
+ tenantId,
+ requestinfo,
+ true
+ );
+ }
+ else{
+ restWns = await search_sewerage(
+ applicationNumber,
+ tenantId,
+ requestinfo,
+ true
+ );
+ }
+
+ } catch (ex) {
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to query details of water and sewerage application");
+ }
+
+ var connection = restWns.data;
+
+ if (
+ connection &&
+ connection.WaterConnection &&
+ connection.WaterConnection.length > 0
+ ) {
+ var consumerCode = bussinessService == "WS"? connection.WaterConnection[0].connectionNo : connection.WaterConnection[0].applicationNo;
+ var billresponse;
+ try {
+ billresponse = await search_billV2(
+ tenantId,
+ consumerCode,
+ bussinessService,
+ requestinfo
+ );
+ } catch (ex) {
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, `Failed to query bills for water application`);
+ }
+
+ var bills = billresponse.data;
+ if (bills && bills.Bill && bills.Bill.length > 0) {
+ var pdfResponse;
+ var pdfkey = config.pdf.wns_bill;
+ try {
+ var billArray = { Bill: bills.Bill };
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ billArray,
+ requestinfo
+ );
+ } catch (ex) {
+ let errorMessage;
+ if(bussinessService == 'WS')
+ errorMessage = "Failed to generate PDF for water connection bill";
+ if(bussinessService == 'WS.ONE_TIME_FEE')
+ errorMessage = "Failed to generate PDF for water one time fees bill";
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ errorMessage
+ );
+ }
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no bill for this application number");
+ }
+ }
+ else if (
+ connection &&
+ connection.SewerageConnections &&
+ connection.SewerageConnections.length > 0
+ ) {
+ var consumerCode = bussinessService == "SW"? connection.SewerageConnections[0].connectionNo : connection.SewerageConnections[0].applicationNo;
+ var billresponse;
+ try {
+ billresponse = await search_billV2(
+ tenantId,
+ consumerCode,
+ bussinessService,
+ requestinfo
+ );
+ } catch (ex) {
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, `Failed to query bills for sewerage application`);
+ }
+
+ var bills = billresponse.data;
+ if (bills && bills.Bill && bills.Bill.length > 0) {
+ var pdfResponse;
+ var pdfkey = config.pdf.wns_bill;
+ try {
+ var billArray = { Bill: bills.Bill };
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ billArray,
+ requestinfo
+ );
+ } catch (ex) {
+ let errorMessage;
+ if(bussinessService == 'SW')
+ errorMessage = "Failed to generate PDF for sewerage connection bill";
+ if(bussinessService == 'SW.ONE_TIME_FEE')
+ errorMessage = "Failed to generate PDF for sewerage one time fees bill";
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ errorMessage
+ );
+ }
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no bill for this application number");
+ }
+ }
+ else {
+ return renderError(
+ res,
+ "There is no water and sewerage applicaion for this applicationNumber"
+ );
+ }
+ } catch (ex) {
+ return renderError(res, `Failed to query bill for water and sewerage application`);
+ }
+ })
+ );
+
+ router.post(
+ "/wnsreceipt",
+ asyncMiddleware(async function (req, res, next) {
+ var tenantId = req.query.tenantId;
+ var applicationNumber = req.query.applicationNumber;
+ var bussinessService = req.query.bussinessService;
+ var requestinfo = req.body;
+ var restWns;
+ if (requestinfo == undefined) {
+ return renderError(res, "requestinfo can not be null");
+ }
+ if (!tenantId || !applicationNumber) {
+ return renderError(
+ res,
+ "tenantId and applicationNumber are mandatory to generate the tlreceipt"
+ );
+ }
+
+ try {
+ try {
+ if(bussinessService === 'WS' || bussinessService === 'WS.ONE_TIME_FEE'){
+ restWns = await search_water(
+ applicationNumber,
+ tenantId,
+ requestinfo,
+ false
+ );
+ }
+ else{
+ restWns = await search_sewerage(
+ applicationNumber,
+ tenantId,
+ requestinfo,
+ false
+ );
+ }
+
+ } catch (ex) {
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, "Failed to query details of water and sewerage application");
+ }
+ var connection = restWns.data;
+
+ if (
+ connection &&
+ connection.WaterConnection &&
+ connection.WaterConnection.length > 0
+ ) {
+ var consumerCode = bussinessService == "WS"? connection.WaterConnection[0].connectionNo : connection.WaterConnection[0].applicationNo;
+ var paymentresponse;
+ try {
+ paymentresponse = await search_payment(
+ consumerCode,
+ tenantId,
+ requestinfo,
+ bussinessService
+ );
+ } catch (ex) {
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, `Failed to query receipt for water application`);
+ }
+
+ var payments = paymentresponse.data;
+ if (payments && payments.Payments && payments.Payments.length > 0) {
+ var pdfResponse;
+ var pdfkey = config.pdf.wns_one_time_receipt;
+ try {
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ payments,
+ requestinfo
+ );
+ } catch (ex) {
+ let errorMessage;
+ if(bussinessService == 'WS')
+ errorMessage = "Failed to generate PDF for water connection receipt";
+ if(bussinessService == 'WS.ONE_TIME_FEE')
+ errorMessage = "Failed to generate PDF for water one time fees receipt";
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ errorMessage
+ );
+ }
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no receipt for this application number");
+ }
+ }
+ else if (
+ connection &&
+ connection.SewerageConnections &&
+ connection.SewerageConnections.length > 0
+ ) {
+ var consumerCode = bussinessService == "SW"? connection.SewerageConnections[0].connectionNo : connection.SewerageConnections[0].applicationNo;
+ var paymentresponse;
+ try {
+ paymentresponse = await search_payment(
+ consumerCode,
+ tenantId,
+ requestinfo,
+ bussinessService
+ );
+ } catch (ex) {
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(res, `Failed to query receipt for sewerage application`);
+ }
+
+ var payments = paymentresponse.data;
+ if (payments && payments.Payments && payments.Payments.length > 0) {
+ var pdfResponse;
+ var pdfkey = config.pdf.wns_one_time_receipt;
+ try {
+ pdfResponse = await create_pdf(
+ tenantId,
+ pdfkey,
+ payments,
+ requestinfo
+ );
+ } catch (ex) {
+ let errorMessage;
+ if(bussinessService == 'SW')
+ errorMessage = "Failed to generate PDF for sewerage connection receipt";
+ if(bussinessService == 'SW.ONE_TIME_FEE')
+ errorMessage = "Failed to generate PDF for sewerage one time fees receipt";
+
+ if (ex.response && ex.response.data) console.log(ex.response.data);
+ return renderError(
+ res,
+ errorMessage
+ );
+ }
+ var filename = `${pdfkey}_${new Date().getTime()}`;
+ res.writeHead(200, {
+ "Content-Type": "application/pdf",
+ "Content-Disposition": `attachment; filename=${filename}.pdf`,
+ });
+ pdfResponse.data.pipe(res);
+ } else {
+ return renderError(res, "There is no receipt for this application number");
+ }
+ }
+ else {
+ return renderError(
+ res,
+ "There is no water and sewerage applicaion for this applicationNumber"
+ );
+ }
+ } catch (ex) {
+ return renderError(res, `Failed to query receipt for water and sewerage application`);
+ }
+ })
+ );
+
+
+module.exports = router;