Open Arshadtpr opened 6 months ago
Referral for Junior Accountant/Accounts Payable Position
100008 100006 12165
-- public.wf_form_record_table definition
-- Drop table
-- DROP TABLE public.wf_form_record_table;
CREATE TABLE public.wf_form_record_table ( id serial4 NOT NULL, "module" varchar NULL, sub_module varchar NULL, table_name varchar NULL, fromqty varchar NULL, toqty varchar NULL, createdby varchar NULL, createdat timestamp DEFAULT now() NULL, updatedby varchar NULL, updatedat timestamp DEFAULT now() NULL, db_name varchar NULL, "condition" varchar NULL );
INSERT INTO public.wf_form_record_table (id, "module", sub_module, table_name, fromqty, toqty, createdby, createdat, updatedby, updatedat, db_name, "condition") VALUES(11, 'LICENSE', NULL, 'trade_kmc1_data.license_app_dtls', '1', '200000', NULL, '2023-10-13 17:00:05.476', NULL, '2023-10-13 17:00:05.476', 'digit', ' where "lic_app_no" ='); INSERT INTO public.wf_form_record_table (id, "module", sub_module, table_name, fromqty, toqty, createdby, createdat, updatedby, updatedat, db_name, "condition") VALUES(12, 'LICENSE', NULL, 'trade_kmc1_data.license_app_dtls', '1', '200000', NULL, '2023-10-13 17:00:05.476', NULL, '2023-10-13 17:00:05.476', 'digit', ' where "lic_app_no" ='); INSERT INTO public.wf_form_record_table (id, "module", sub_module, table_name, fromqty, toqty, createdby, createdat, updatedby, updatedat, db_name, "condition") VALUES(13, 'LICENSE_NEW', NULL, 'trade_kmc1_data.license_app_dtls', '1', '200000', NULL, '2023-10-13 17:00:05.476', NULL, '2023-10-13 17:00:05.476', 'digit', ' where "lic_app_no" =');
https://kmcuat.wb.gov.in/kmcreports/getScreenDetails https://kmcuat.wb.gov.in/kmcreports/getScreenDetails", https://kmcuat.wb.gov.in/kmcreports/saveMasterDataByScreenName", https://kmcuat.wb.gov.in/kmcreports/getSearchDetailsForScreen", https://kmcuat.wb.gov.in/kmcreports/getOpenApiById", https://kmcuat.wb.gov.in//filestore/v1/files', https://kmcuat.wb.gov.in//filestore/v1/files/url?', https://kmcuat.wb.gov.in//filestore/v1/files/url?', https://kmcuat.wb.gov.in/license_management/deleteWorkFlowFiles', https://kmcuat.wb.gov.in/license_management/saveMasterFileDetails', https://kmcuat.wb.gov.in/kmcreports/getPDFFileColumn', https://kmcuat.wb.gov.in/kmcreports/getExcelFileColumn',
VPN: SDC DB arsusm ArsU#*#120
which eventually gets called with:
onload='javascript:resizeIframe(this);'
const saveAndPrint = async (req, res) => { try { let request = req && req.body && req.body.reqData; let mihpayid = req && req?.body && req?.body?.mihpayid; let txnid = req && req?.body && req.body?.txnid; if (request && request.tokenInfo && request.hashInfo && request.collectionInfo) { const hashINFO = request.hashInfo; const tokenINFO = request.tokenInfo; const collectionINFO = request.collectionInfo; const demand = collectionINFO.demand; const operatorDetails = collectionINFO.operatorDetails; const type = collectionINFO.type ? collectionINFO.type : "1"; const suspense = collectionINFO.suspense ? collectionINFO.suspense : []; const paymentType = collectionINFO.paymentType ? collectionINFO.paymentType : "PORTAL"; const misc = collectionINFO.misc ? collectionINFO.misc : []; const chequeDetails = collectionINFO.chequeDetails ? collectionINFO.chequeDetails : []; var sequence = Math.floor(Math.random() 1000000); var sknce = Math.floor(Math.random() 10000); const billDetails = collectionINFO.billDetails; const currentDate = new Date(); const currentTime = moment(currentDate).format('YYYY-MM-DD hh:mm:ss'); let receiptDateTime = moment(currentDate).utcOffset('+05:30').format('DD-MM-YYYY hh:mm A'); const dDate = moment(currentDate).format('YYYY-MM-DD'); const dDate1 = moment(currentDate).format('YYYYMMDD'); const dDat2 = moment(currentDate).format('YYYYMMDDHHmmss'); const tokenValidate = await hashBusiness.validateToken(tokenINFO); let res; let intruArr = []; let paymentAmount = 0; // if (tokenValidate.data && tokenValidate.data.toLowerCase() === "valid token") { // hash validation goes here... let hashTokenFromUI = hashINFO.hashTk; let app_id = hashINFO.appId; const hashValue = await hashBusiness.verifyHash(app_id, hashTokenFromUI); console.log( collectionINFO ); if (hashValue) { // if (demand && billDetails) { if (paymentType === 'CC') { let receiptArr = []; let url = "https://www.kmcgov.in/KMCWebService/services/Ekmc2CommonCollectionMigrationService/getCounterWiseReceiptNo"; let data = { "moduleCode": "99", "collectionCenterCode": "1", "counterNo": "31", "financialYear": "2023-2024", "userId": "34563", "ipAddress": "172.16.6.162" }
let office = await commonService.searchOfficeCode(demand[0].receiptHdr.centre_code);
let result1;
let query = `SELECT coll_counter_wise_receipt_no as receiptNo
FROM coll_kmc1_data.coll_ip_counter_map
WHERE office_code = '${office}' and coll_counter_no = '${demand[0].receiptHdr.counter}' and financial_year = '2024-2025';`;
// let query = `SELECT coll_counter_wise_receipt_no as receiptNo
// FROM coll_kmc1_data.coll_ip_counter_map
// WHERE office_code = '${office}' and coll_counter_no = '3' and financial_year = '2023-2024';`;
const getReceiptNo = await receiptService.updateOrSelectQuery(query);
let receiptNo1 = getReceiptNo[0].receiptno;
// console.log('query', receiptNo1);
let dem_length = demand.length;
updateSeq = parseInt(receiptNo1) + parseInt(dem_length);
let counterNo = parseInt(demand[0].receiptHdr.counter);
//let counterNo = '3';
counterNo = addLeadingZeros(counterNo, 2);
if (demand[0].receiptDtls[0].demandType === "PD" || demand[0].receiptDtls[0].demandType === "LOI" || demand[0].receiptDtls[0].demandType === "FS" || demand[0].receiptDtls[0].demandType === "SUSP" || demand[0].receiptDtls[0].demandType === "MISC") {
dept_code = '02';
} else if (demand[0].receiptDtls[0].demandType === "SWM") {
dept_code = '16';
} else if (demand[0].receiptDtls[0].demandType === "SWM_MISC") {
dept_code = '16';
console.log(demand[0].receiptDtls[0].demandType);
} else if (demand[0].receiptDtls[0].demandType === "PAR") {
dept_code = '05';
console.log(demand[0].receiptDtls[0].demandType);
} else if (demand[0].receiptDtls[0].demandType === "BUS") {
dept_code = '75';
console.log(demand[0].receiptDtls[0].demandType);
}
else if (demand[0].receiptDtls[0].demandType === "MAT") {
dept_code = '44';
console.log(demand[0].receiptDtls[0].demandType);
}
else if (demand[0].receiptDtls[0].demandType === "PS" || demand[0].receiptDtls[0].demandType === "MS") {
dept_code = '36';
console.log(demand[0].receiptDtls[0].demandType);
}
else {
dept_code = '00'
}
let officeCode = addLeadingZeros(office, 2);
let receiptNo_cc2 = counterNo + dept_code + officeCode;
// const response = await axios.post(url, data);
// const result = response.data;
let result = {
statusCode: 400
}
if (result.statusCode == 200 && result.receiptSeqNo != null) {
recNumber = parseInt(result.receiptSeqNo);
// recNumber = addLeadingZeros(recNumber, 6);
receiptNo_cc2 = receiptNo_cc2 + dDate1;
insNo = parseInt(result.instrSlNo);
} else if (result.statusCode == 200 && result.receiptSeqNo == null) {
recNumber = parseInt(receiptNo1);
// recNumber = addLeadingZeros(recNumber, 6);
receiptNo_cc2 = receiptNo_cc2 + dDate1;
insNo = parseInt(result.instrSlNo);
}
else {
recNumber = parseInt(receiptNo1);
// recNumber = addLeadingZeros(recNumber, 6);
receiptNo_cc2 = receiptNo_cc2 + dDate1;
insNo = parseInt(recNumber);
}
// console.log(demand);
let recDetlArr = [];
// if(response.status == 200){
if (demand[0].receiptDtls[0].demandType === "PD" || demand[0].receiptDtls[0].demandType === "LOI" || demand[0].receiptDtls[0].demandType === "FS" || demand[0].receiptDtls[0].demandType === "SUSP" || demand[0].receiptDtls[0].demandType === "MISC") {
// console.log(demand[0].receiptDtls[0].demandType);
if (demand.length >= 1) { // Multi
let baseArr = [];
let arr = [];
let obj;
for (let j = 0; j < demand.length; j++) {
let seqn = Math.floor(Math.random() * 100000);
const demandDetails = demand[j].demandDetails;
const receiptHdr = demand[j].receiptHdr;
const receiptDtls = demand[j].receiptDtls;
//receiptDtls[j].
let recNo = sequence + j;
let demArr = [];
let barcode;
if (demandDetails.barcode.length < 44) {
barcode = demandDetails.barcode + Array(44 - demandDetails.barcode.length).fill('0').join('');
// console.log("Barcode", barcode);
} else {
barcode = demandDetails.barcode;
}
// console.log(result);
if (result.statusCode == 200 && result.receiptSeqNo != null) {
receiptNo = parseInt(result.receiptSeqNo) + j;
if (receiptNo === NaN) {
receiptNo = sknce;
}
receiptNo = receiptNo_cc2 + "" + addLeadingZeros(receiptNo, 6);
// console.log("rrrrrr1111", receiptNo);
intstruNo = parseInt(recNumber);
// intstruNo= parseInt(result.instrSlNo);
} else if (result.statusCode == 200 && result.receiptSeqNo == null) {
// console.log("7777", recNumber);
let res1 = (BigInt(recNumber) + BigInt(j)).toString()
receiptNo = receiptNo_cc2 + "" + addLeadingZeros(res1, 6);
// console.log("rrrrrr", receiptNo);
intstruNo = parseInt(recNumber);
}
else if (result.statusCode != 200 && result.receiptSeqNo == null) {
// console.log(recNumber);
let res1 = recNumber + j;
receiptNo = receiptNo_cc2 + "" + addLeadingZeros(res1, 6);
// console.log("receiptNo---", receiptNo);
receipt21 = receiptNo;
//receiptNo = (BigInt(receiptNo)).toString()
console.log("rrrrrr999", receiptNo);
intstruNo = Math.floor(Math.random() * 10000);
}
else {
receiptNo = sequence + j;
//instrSlNo=val;
};
// console.log("ReceiptNo", receiptNo);
receipt21 = receiptNo;
// console.log('receipt21', receipt21);
let revStamp = 0;
if (parseFloat(receiptHdr.receiptAmount) > 5000.00) {
revStamp = 1;
} else {
revStamp = 0;
}
obj = {
TRES_COLL_RECEIPT_YEAR: receiptHdr.financial_year,
TRES_COLL_RECEIPT_NO: receiptNo,
TRES_COLL_COLLECT_CENTER_CODE: office,
TRES_COLL_RECEIPT_DATE: receiptHdr.receipt_date,
TRES_COLL_RECEIPT_DATE_TIME: receiptHdr.receipt_time,
TRES_COLL_POSTING_DATE: receiptHdr.posting_date,
TRES_COLL_DEPARTMENT_CODE: receiptHdr.department,
TRES_COLL_RECEIPT_AMOUNT: receiptHdr.receiptAmount,
TRES_COLL_RECEIPT_AMOUNT_ENCR: Enc_num(receiptHdr.receiptEncr),
TRES_COLL_REBATE_AMOUNT: receiptHdr.rebateAmount,
TRES_COLL_REBATE_AMOUNT_ENCR: Enc_num(receiptHdr.rebateEncr),
TRES_COLL_INTEREST_AMOUNT: receiptHdr.interestAmount,
TRES_COLL_INTEREST_AMOUNT_ENCR: Enc_num(receiptHdr.interestEncr),
TRES_COLL_PENALTY_AMOUNT: receiptHdr.penaltyAmount,
TRES_COLL_PENALTY_AMOUNT_ENCR: Enc_num(receiptHdr.penaltyEncr),
TRES_COLL_INSTRUMENT_TYPE: receiptHdr.instruType,
TRES_COLL_RECEIPT_PRINT_COUNT: 1,
COLL_IP_ADDRESS: '172.16.105.80',
COLL_COUNTER_NO: receiptHdr.counter,
TRES_COLL_NO_OF_REV_STMP_AFXED: revStamp,
CREATE_UID: receiptHdr.empId,
CREATE_DATE: currentTime,
MODIFIED_UID: receiptHdr.empId,
MODIFIED_DATE: currentTime,
TRES_COLL_RECEIPT_PRINT_FLAG: 'P',
VERSION_NO: 1,
TRES_COLL_STATIONARY_NO: seqn,
TRES_COLL_STATIONERY_PREFIX: 'ZX',
TRES_COLL_BOUNCED_AMOUNT: '0.00',
//TRES_COLL_TYPE: | |
TRES_COLL_STATIONARY_NO_TO: seqn
}
receiptArr.push({receiptNo:receiptNo||"0",asseseeNo:demandDetails?.asseseeNo||"0"});
let receiptColl = await ccReceiptService.insertReceiptColl(receiptNo, JSON.stringify(demandDetails), demandDetails.mobileNo, receiptHdr.empId);
let arr = [];
let object;
if (type == 4) {
let misc_query = ``
}
recDetlArr = receiptDtls;
for (let i = 0; i < receiptDtls.length; i++) {
var dateMomentObject1 = moment(receiptDtls[i]?.presentationDate, "DD/MM/YYYY"); // 1st argument - string, 2nd argument - format
var dateObject1 = dateMomentObject1.toDate();
if (type == 2) {
let queryD = `select max(csd.demand_no) as max, csd.paid_by_name as "paid_by_name" from public.coll_suspense_data csd where csd.reference_no = '${demandDetails.asseseeNo}' and csd.suspense_amount ='${receiptDtls[i].demandAmount}' group by csd.paid_by_name;`;
result1 = await receiptService.updateOrSelectQuery(queryD);
receiptDtls[i].demand_no = result1[0].max;
}
let pdate1 = moment(dateObject1).format('YYYY-MM-DD hh:mm:ss.mmm');
// let pdate=new Date(receiptDtls[i].presentationDate);
// let pdate1=moment(pdate).format('YYYY-MM-DD hh:mm:ss.mmm');
// let rdate=new Date(receiptDtls[i].rebateDate);
// var dateString = "23/10/2015"; // Oct 23
var dateMomentObject = moment(receiptDtls[i].rebateDate, "DD/MM/YYYY"); // 1st argument - string, 2nd argument - format
var dateObject = dateMomentObject.toDate();
let rdate1 = moment(dateObject).format('YYYY-MM-DD hh:mm:ss.mmm');
// console.log(receiptDtls[i].presentationDate);
if (demandDetails.asseseeNo === demandDetails.barcode) {
if (type == 1 || type == 3) {
pdate1 = moment(receiptDtls[i].presentationDate).format('YYYY-MM-DD hh:mm:ss.mmm');
rdate1 = moment(receiptDtls[i].rebateDate).format('YYYY-MM-DD hh:mm:ss.mmm');
} else if (type == 2) {
pdate1 = receiptDtls[i].presentationDate;
rdate1 = receiptDtls[i].rebateDate
}
} else {
pdate1 = moment(receiptDtls[i].presentationDate).format('YYYY-MM-DD hh:mm:ss.mmm');
rdate1 = moment(receiptDtls[i].rebateDate).format('YYYY-MM-DD hh:mm:ss.mmm');
}
// console.log(pdate1, rdate1);
if (type == 2) {
object = {
TRES_COLL_RECEIPT_YEAR: receiptDtls[i].financial_year,
TRES_COLL_RECEIPT_NO: receiptNo,
TRES_COLL_COLLECT_CENTER_CODE: office,
TRES_COLL_DEMAND_INFO_1: getCurrentFinancialYear(),
TRES_COLL_DEMAND_INFO_2: receiptDtls[0].demand_no,
TRES_COLL_DEMAND_INFO_3: demandDetails.asseseeNo,
TRES_COLL_DEMAND_INFO_4: 3,
TRES_COLL_DEMAND_INFO_5: 0,
TRES_COLL_PRESENTATION_DATE: pdate1,
TRES_COLL_REBATE_DATE: rdate1,
//TRES_COLL_VALID_TILL_DATE | |
TRES_COLL_DEMAND_AMOUNT: receiptDtls[i].demandAmount,
TRES_COLL_DEMAND_AMOUNT_ENCR: Enc_num(receiptDtls[i].demandEncr),
TRES_COLL_PAYABLE_AMOUNT: receiptDtls[i].payableAmount,
TRES_COLL_PAYABLE_AMOUNT_ENCR: Enc_num(receiptDtls[i].payableEncr),
TRES_COLL_REBATE_AMOUNT: receiptDtls[i].rebateAmount,
TRES_COLL_REBATE_AMOUNT_ENCR: Enc_num(receiptDtls[i].rebateEncr),
TRES_COLL_INTEREST_AMOUNT: receiptDtls[i].interestAmount,
TRES_COLL_INTEREST_AMOUNT_ENCR: Enc_num(receiptDtls[i].interestEncr),
TRES_COLL_PENALTY_AMOUNT: receiptDtls[i].penaltyAmount,
TRES_COLL_PENALTY_AMOUNT_ENCR: Enc_num(receiptDtls[i].penaltyEncr),
CREATE_UID: receiptDtls[i].empId,
CREATE_DATE: currentTime,
MODIFIED_UID: receiptDtls[i].empId,
MODIFIED_DATE: currentTime,
TRES_COLL_BARCODE_MATCH_FLAG: 'Y',
VERSION_NO: 1,
TRES_COLL_DEPARTMENT_CODE: receiptDtls[i].department,
COLL_COUNTER_NO: receiptDtls[i].counter
}
} else {
object = {
TRES_COLL_RECEIPT_YEAR: receiptDtls[i].financial_year,
TRES_COLL_RECEIPT_NO: receiptNo,
TRES_COLL_COLLECT_CENTER_CODE: office,
TRES_COLL_DEMAND_INFO_1: receiptDtls[i].effectiveStorage,
TRES_COLL_DEMAND_INFO_2: receiptDtls[i].billQtr,
TRES_COLL_DEMAND_INFO_3: receiptDtls[i].demandNo,
TRES_COLL_DEMAND_INFO_4: receiptDtls[i].billType ? receiptDtls[i].billType : null,
TRES_COLL_DEMAND_INFO_5: (receiptDtls[i].billNo + receiptDtls[i].shareType) ? (receiptDtls[i].billNo + receiptDtls[i].shareType) : null,
TRES_COLL_PRESENTATION_DATE: pdate1,
TRES_COLL_REBATE_DATE: rdate1,
//TRES_COLL_VALID_TILL_DATE | |
TRES_COLL_DEMAND_AMOUNT: receiptDtls[i].demandAmount,
TRES_COLL_DEMAND_AMOUNT_ENCR: Enc_num(receiptDtls[i].demandEncr),
TRES_COLL_PAYABLE_AMOUNT: receiptDtls[i].payableAmount,
TRES_COLL_PAYABLE_AMOUNT_ENCR: Enc_num(receiptDtls[i].payableEncr),
TRES_COLL_REBATE_AMOUNT: receiptDtls[i].rebateAmount,
TRES_COLL_REBATE_AMOUNT_ENCR: Enc_num(receiptDtls[i].rebateEncr),
TRES_COLL_INTEREST_AMOUNT: receiptDtls[i].interestAmount,
TRES_COLL_INTEREST_AMOUNT_ENCR: Enc_num(receiptDtls[i].interestEncr),
TRES_COLL_PENALTY_AMOUNT: receiptDtls[i].penaltyAmount,
TRES_COLL_PENALTY_AMOUNT_ENCR: Enc_num(receiptDtls[i].penaltyEncr),
CREATE_UID: receiptDtls[i].empId,
CREATE_DATE: currentTime,
MODIFIED_UID: receiptDtls[i].empId,
MODIFIED_DATE: currentTime,
TRES_COLL_BARCODE_MATCH_FLAG: 'Y',
VERSION_NO: 1,
TRES_COLL_DEPARTMENT_CODE: receiptDtls[i].department,
COLL_COUNTER_NO: receiptDtls[i].counter
}
}
if (type == 2) {
let receiptDtls1 = `INSERT INTO pt_prod.asmt_receipt
(receipt_no, assesee_no, ward_no, office_code, receipt_date, receipt_status,payment_type, payment_amount, used_susp_amt, total_amount, create_id, create_date)
VALUES('${receiptNo}', '${receiptDtls[i].demandNo}', '${demandDetails.wardNo}', '${office}', '${currentTime}', 'A', '${receiptDtls[i].billType}', ${receiptDtls[i].payableAmount}, NULL,${receiptDtls[i].demandAmount}, '${receiptDtls[i].empId}', '${currentTime}');`;
const recDetails = await receiptService.updateOrInsertQuery(receiptDtls1);
// S
} else if (type == 4 || type == 5) {
// let receiptDtls1 = `INSERT INTO pt_prod.asmt_misc_receipt_dtls
// (asmt_receipt_no, asmt_receipt_date, create_uid, create_date,asmt_demand_no, asmt_receipt_year, asmt_receipt_amoint)
// VALUES('${receiptNo}', '${currentTime}', '${receiptDtls[i].empId}', '${currentTime}','${misc[0].demandNo}', '2021-2022', '${misc[0].misc_amount}');`
// let receiptDtls2 = `INSERT INTO pt_prod.asmt_misc_receipt
// (asmt_receipt_no, asmt_receipt_date, asmt_receipt_status,create_uid, create_date,asmt_demand_no, asmt_receipt_year, asmt_receipt_amoint)
// VALUES('${receiptNo}', '${currentTime}', 'A', '${receiptDtls[i].empId}', '${currentTime}','${misc[0].demandNo}', '2021-2022', '${misc[0].misc_amount}');
// `
// const recDetails = await receiptService.updateOrInsertQuery(receiptDtls1);
// const recDetails1 = await receiptService.updateOrInsertQuery(receiptDtls2);
}
if (type == 2) {
let sus_no_query = `select max(suspense_no :: INTEGER) as suspense_no from pt_prod.asmt_suspense;`
let sus_no1 = await receiptService.updateOrInsertQuery(sus_no_query);
let sus_no2 = parseInt(sus_no1[0].suspense_no) + 1;
let sus_query = `INSERT INTO pt_prod.asmt_suspense
(suspense_no, ward_no, office_code, assesee_no, old_susp_no, receipt_no, receipt_date, deposit_amt, initial_amt, balance_amt, mother_flg, status, entry_type, payment_remarks, mobile_no, create_id, create_date)
VALUES('${sus_no2}', '${demandDetails.wardNo}', '${office}', '${receiptDtls[0].demandNo}','${sus_no2}', '${receiptNo}', '${currentTime}', ${suspense[0].amount}, 0.00,${suspense[0].amount}, 'N','A', 'C', 'Common Collection', ${demandDetails.mobileNo}, '${receiptDtls[i].empId}', '${currentTime}');`;
const suspenseDtls = await receiptService.updateOrInsertQuery(sus_query);
let suspense_query = `INSERT INTO pt_prod.asmt_suspense_dtl
(suspense_no, ward_no, office_code, bill_no, used_amt, create_id, create_date)
VALUES('${sus_no2}', '${demandDetails.wardNo}', '${office}', '${receiptDtls[i].billNo}', ${suspense[0].amount},'${receiptDtls[i].empId}', '${currentTime}');
`;
const suspense_qry = await receiptService.updateOrInsertQuery(suspense_query);
}
if (barcode.length == 44 && barcode.substring(31, 35) === '0012') {
let ptDem = {
"asseseeNo": receiptDtls[i].demandNo,
"freshBillNo": receiptDtls[i].billNo,
"fromQtr": receiptDtls[i].fromQtr,
"toQtr": receiptDtls[i].toQtr,
"billType": receiptDtls[i].billType,
"payableAmt": (parseFloat(receiptDtls[i].payableAmount)),
"rebateAmount": receiptDtls[i].rebateAmount,
"interestAmount": receiptDtls[i].interestAmount,
"penaltyAmount": receiptDtls[i].penaltyAmount,
"netAmount": (parseFloat(receiptDtls[i].netAmount)),
"netAmount_After_Waive": (parseFloat(receiptDtls[i].netAmountAfterWaiver)),
"netPaidAmount": (parseFloat(receiptDtls[i].payableAmount)),
"allBillType": receiptDtls[i].allBillType
}
demArr.push(ptDem);
} else {
let ptDem = {
"asseseeNo": receiptDtls[i].demandNo,
"freshBillNo": receiptDtls[i].billNo,
"fromQtr": receiptDtls[i].fromQtr,
"toQtr": receiptDtls[i].toQtr,
"billType": receiptDtls[i].billType,
"payableAmt": receiptDtls[i].demandAmount,
"rebateAmount": receiptDtls[i].rebateAmount,
"interestAmount": receiptDtls[i].interestAmount,
"penaltyAmount": receiptDtls[i].penaltyAmount,
"netAmount": (parseFloat(receiptDtls[i].netAmount)),
"netAmount_After_Waive": (parseFloat(receiptDtls[i].netAmountAfterWaiver)),
"netPaidAmount": (parseFloat(receiptDtls[i].payableAmount)),
"allBillType": receiptDtls[i].allBillType
}
demArr.push(ptDem);
}
arr.push(object);
}
let arr1 = [];
let i = 0;
var date21 = dDate;
var billArr = [];
let s = Math.floor(Math.random() * 100);
// console.log(s);
let val = parseInt(seqn) + parseInt(s);
// console.log(val);
if (result != null) {
//receiptNo= parseInt(result.receiptSeqNo)+j;
// intstruNo = parseInt(result.instrSlNo);
}
else {
//receiptNo=sequence+j;
instrSlNo = val;
};
for (let k = 0; k < billDetails.length; k++) {
// billDetails.forEach(async billDetails[k] =>{
const seqnce = await ccReceiptService.searchCollSeq(
['coll_sequence_no'],
{
COLL_COLLECTION_CENTER_CODE: office?.toString(),
COLL_COLLECTION_YEAR: billDetails[k].financial_year,
COLL_SEQUENCE_DESC: "TRES_COLL_INSTR_SL_NO"
}
);
// console.log("sequence", seqnce[0].coll_sequence_no);
//receiptNo=sequence+j;
let objt = {
TRES_COLL_RECEIPT_YEAR: billDetails[k].financial_year,
TRES_COLL_RECEIPT_NO: receiptNo,
TRES_COLL_COLLECT_CENTER_CODE: office,
TRES_COLL_INST_SL_NO: intstruNo + k,
TRES_COLL_PAYMENT_MODE: billDetails[k].mode,
TRES_COLL_CHEQUE_DD_NO: billDetails[k].chNumber,
TRES_COLL_CHEQUE_DD_DATE: billDetails[k].chDate ? billDetails[k].chDate : date21,
TRES_COLL_BANK_CODE: billDetails[k].bankCode,
TRES_COLL_BRANCH_CODE: billDetails[k].branch_code ? billDetails[k].branch_code : '',
TRES_COLL_AMOUNT: billDetails[k].instruAmt,
TRES_COLL_AMOUNT_ENCR: Enc_num(billDetails[k].instruAmtEncr),
TRES_BANK_SETTLEMENT_FLAG: 'H',
CREATE_UID: receiptDtls[i].empId,
CREATE_DATE: currentTime,
MODIFIED_UID: receiptDtls[i].empId,
MODIFIED_DATE: currentTime,
VERSION_NO: 1,
TRES_COLL_DEPARTMENT_CODE: billDetails[k].department,
COLL_COUNTER_NO: billDetails[k].counter
}
let yy = {
"receiptNo": receiptNo,
"receiptDate": dDate,
"instrumntType": billDetails[k].mode,
"instrumntNo": billDetails[k].chNumber,
"instrumentDate": billDetails[k].chDate,
"bankCode": billDetails[k].bankCode,
"instrumentAmount": billDetails[k].instruAmt
};
if (billDetails[k].mode == 'C') {
objt = {
TRES_COLL_RECEIPT_YEAR: billDetails[k].financial_year,
TRES_COLL_RECEIPT_NO: receiptNo,
TRES_COLL_COLLECT_CENTER_CODE: office,
TRES_COLL_INST_SL_NO: intstruNo + k,
TRES_COLL_PAYMENT_MODE: billDetails[k].mode,
TRES_COLL_CHEQUE_DD_NO: billDetails[k].chNumber,
// TRES_COLL_CHEQUE_DD_DATE: billDetails[k].chDate ? billDetails[k].chDate : date21,
TRES_COLL_BANK_CODE: billDetails[k].bankCode,
TRES_COLL_BRANCH_CODE: billDetails[k].branch_code,
TRES_COLL_AMOUNT: billDetails[k].instruAmt,
TRES_COLL_AMOUNT_ENCR: Enc_num(billDetails[k].instruAmtEncr),
TRES_BANK_SETTLEMENT_FLAG: 'H',
CREATE_UID: receiptDtls[i].empId,
CREATE_DATE: currentTime,
MODIFIED_UID: receiptDtls[i].empId,
MODIFIED_DATE: currentTime,
VERSION_NO: 1,
TRES_COLL_DEPARTMENT_CODE: billDetails[k].department,
COLL_COUNTER_NO: billDetails[k].counter
}
}
if (type == 2) {
// if (billDetails[k].mode == 'C' && (demand[0].receiptDtls[0].demandType === "SUSP" || demand[0].receiptDtls[0].demandType === "MISC")) {
// let instru_query = `INSERT INTO pt_prod.asmt_misc_receipt_pay_mode
// (asmt_receipt_year, asmt_receipt_no, asmt_pay_mode, asmt_pay_amount, asmt_cheque_status, create_uid, create_date)
// VALUES('2021-2022', '${receiptNo}', 'C',${billDetails[k].instruAmt}, 'H','${receiptDtls[i].empId}', '${currentTime}');`;
// const query = await receiptService.updateOrInsertQuery(instru_query);
// } else if (billDetails[k].mode == 'D' && (demand[0].receiptDtls[0].demandType === "SUSP" || demand[0].receiptDtls[0].demandType === "MISC")) {
// let instru_query = `INSERT INTO pt_prod.asmt_misc_receipt_pay_mode
// (asmt_receipt_year, asmt_receipt_no, asmt_pay_mode, asmt_cheque_no, asmt_cheque_date, asmt_bank_code, asmt_pay_amount, asmt_cheque_status, create_uid, create_date)
// VALUES('2021-2022', '${receiptNo}', 'D', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].bankCode},${billDetails[k].instruAmt}, 'H','${receiptDtls[i].empId}', '${currentTime}');`;
// const query = await receiptService.updateOrInsertQuery(instru_query);
// } else if (billDetails[k].mode == 'Q' && (demand[0].receiptDtls[0].demandType === "SUSP" || demand[0].receiptDtls[0].demandType === "MISC")) {
// let instru_query = `INSERT INTO pt_prod.asmt_misc_receipt_pay_mode
// (asmt_receipt_year, asmt_receipt_no, asmt_pay_mode, asmt_cheque_no, asmt_cheque_date, asmt_bank_code, asmt_pay_amount, asmt_cheque_status, create_uid, create_date)
// VALUES('2021-2022', '${receiptNo}', 'Q', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].bankCode},${billDetails[k].instruAmt}, 'H','${receiptDtls[i].empId}', '${currentTime}');`;
// const query = await receiptService.updateOrInsertQuery(instru_query);
// } else if (billDetails[k].mode == 'C' && (demand[0].receiptDtls[0].demandType === "SUSP" || demand[0].receiptDtls[0].demandType !== "MISC")) {
// let instru_query = `INSERT INTO pt_prod.asmt_instrument
// (receipt_no, ward_no, office_code, instrument_type,instrument_amt, intrument_status, create_id, create_date)
// VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'CS',${billDetails[k].instruAmt}, 'A','${receiptDtls[i].empId}', '${currentTime}');`;
// const query = await receiptService.updateOrInsertQuery(instru_query);
// } else if (billDetails[k].mode == 'D' && (demand[0].receiptDtls[0].demandType === "SUSP" || demand[0].receiptDtls[0].demandType !== "MISC")) {
// let instru_query;
// if (billDetails[k].branch_code != null && billDetails[k].branch_code !== "" && !isNaN(billDetails[k].branch_code)) {
// console.log("****", billDetails[k].branch_code + "====");
// instru_query = `INSERT INTO pt_prod.asmt_instrument
// (receipt_no, ward_no, office_code, instrument_type, instrument_no, instrument_date, instrument_amt, intrument_status, bank_code, branch_code,create_id, create_date)
// VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'DD', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].instruAmt}, 'A', '${billDetails[k].bankCode}', ${billDetails[k].branch_code ? billDetails[k].branch_code : ""},'${receiptDtls[i].empId}', '${currentTime}');`;
// } else {
// console.log("****8888", billDetails[k].branch_code);
// instru_query = `INSERT INTO pt_prod.asmt_instrument
// (receipt_no, ward_no, office_code, instrument_type, instrument_no, instrument_date, instrument_amt, intrument_status, bank_code,create_id, create_date)
// VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'DD', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].instruAmt}, 'A', '${billDetails[k].bankCode}','${receiptDtls[i].empId}', '${currentTime}');`;
// }
if (billDetails[k].mode == 'C' && (demand[0].receiptDtls[0].demandType === "SUSP")) {
let instru_query = `INSERT INTO pt_prod.asmt_instrument
(receipt_no, ward_no, office_code, instrument_type,instrument_amt, intrument_status, create_id, create_date)
VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'CS',${billDetails[k].instruAmt}, 'A','${receiptDtls[i].empId}', '${currentTime}');`;
const query = await receiptService.updateOrInsertQuery(instru_query);
} else if (billDetails[k].mode == 'D' && (demand[0].receiptDtls[0].demandType === "SUSP")) {
let instru_query;
if (billDetails[k].branch_code != null && billDetails[k].branch_code !== "" && !isNaN(billDetails[k].branch_code)) {
console.log("****", billDetails[k].branch_code + "====");
instru_query = `INSERT INTO pt_prod.asmt_instrument
(receipt_no, ward_no, office_code, instrument_type, instrument_no, instrument_date, instrument_amt, intrument_status, bank_code, branch_code,create_id, create_date)
VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'DD', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].instruAmt}, 'A', '${billDetails[k].bankCode}', ${billDetails[k].branch_code ? billDetails[k].branch_code : ""},'${receiptDtls[i].empId}', '${currentTime}');`;
} else {
console.log("****8888", billDetails[k].branch_code);
instru_query = `INSERT INTO pt_prod.asmt_instrument
(receipt_no, ward_no, office_code, instrument_type, instrument_no, instrument_date, instrument_amt, intrument_status, bank_code,create_id, create_date)
VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'DD', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].instruAmt}, 'A', '${billDetails[k].bankCode}','${receiptDtls[i].empId}', '${currentTime}');`;
}
const query = await receiptService.updateOrInsertQuery(instru_query);
} else if (billDetails[k].mode == 'Q' && (demand[0].receiptDtls[0].demandType !== "SUSP" || demand[0].receiptDtls[0].demandType !== "MISC")) {
if (billDetails[k].branch_code != null && billDetails[k].branch_code !== "" && !isNaN(billDetails[k].branch_code)) {
instru_query = `INSERT INTO pt_prod.asmt_instrument
(receipt_no, ward_no, office_code, instrument_type, instrument_no, instrument_date, instrument_amt, intrument_status, bank_code, branch_code,create_id, create_date)
VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'CQ', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].instruAmt}, 'A', '${billDetails[k].bankCode}', ${billDetails[k].branch_code ? billDetails[k].branch_code : ""},'${receiptDtls[i].empId}', '${currentTime}');`;
} else {
instru_query = `INSERT INTO pt_prod.asmt_instrument
(receipt_no, ward_no, office_code, instrument_type, instrument_no, instrument_date, instrument_amt, intrument_status, bank_code,create_id, create_date)
VALUES('${receiptNo}', '${demandDetails.wardNo}', '${office}', 'CQ', '${billDetails[k].chNumber}', '${billDetails[k].chDate}', ${billDetails[k].instruAmt}, 'A', '${billDetails[k].bankCode}','${receiptDtls[i].empId}', '${currentTime}');`;
}
const query = await receiptService.updateOrInsertQuery(instru_query);
}
}
if (billDetails[k].mode != 'C') {
bankName = await commonService.searchBankName(billDetails[k].bankCode);
if (billDetails[k].branch_code != null && billDetails[k].branch_code !== "" && !isNaN(billDetails[k].branch_code)) {
bankBranchName = await commonService.searchBranchName(billDetails[k]?.branch_code?.toString(), billDetails[k]?.bankCode?.toString());
// console.log("bankName", bankName);
// console.log("bankName", bankBranchName);
} else {
bankBranchName = '-';
// console.log("bankName", bankName);
// console.log("bankName", bankBranchName);
}
} else {
bankName = '-';
bankBranchName = '-';
}
let billDtls = {
mode: "",
bank: bankName ? bankName : '-',
branch: bankBranchName ? bankBranchName : '-',
chequeNo: billDetails[k].chNumber ? billDetails[k].chNumber : '-',
chequeDate: billDetails[k].chDate ? moment(billDetails[k].chDate).format('DD/MM/YYYY') : '-',
amount: billDetails[k].instruAmt
}
if (billDetails[k].mode == 'D') {
billDtls.mode = 'DRAFT';
yy.instrumntType = "DD";
} else if (billDetails[k].mode == 'Q') {
billDtls.mode = 'CHEQUE';
yy.instrumntType = "CQ";
} else if (billDetails[k].mode == 'C') {
billDtls.mode = 'CASH';
billDtls.chequeDate = '-'
yy.instrumntType = "CS";
}
billArr.push(billDtls);
// console.log("objt===>", objt);
intruArr.push(yy);
intruArr.forEach(ele => {
paymentAmount = paymentAmount + parseFloat(ele.instrumentAmount);
})
arr1.push(objt);
i + 1;
}
// console.log(arr1);
const tokenValidate = await hashBusiness.validateToken(tokenINFO);
let url1 = "https://kmcdev.ddns.net/property-services/assessmentCitizen/_saveAsseseePaymentDetailsCC";
let dat = {
"RequestInfo": {
"apiId": "Rainmaker",
"ver": ".01",
"ts": "",
"action": "",
"did": "1",
"key": "",
"msgId": "20170310130900|en_IN",
"authToken": request.tokenInfo.RequestInfo.authToken
},
"RequestData": {
"departmentCode": "2",
"paymentUpdateDataList": [
{
"asseseeNo": demandDetails.asseseeNo,
"barcode": barcode,
"totalDemandAmount": receiptHdr.receiptAmount,
"useSuspenseAmount": 0,
"netPayableAmount": receiptHdr.payableAmount,
"demandList": demArr,
"miscDemandList": [],
"receiptDetails": {
"receiptNo": receiptNo,
"paidBy": demandDetails.ownerNameDisplay,
"flatNo": demandDetails.premisesType,
"floorNo": demandDetails.premisesNo,
"mobileNo": demandDetails.mobileNo,
"emailId": "hh@gmail.com",
"paymentType": "PD",
"paymentAmount": receiptHdr.receiptAmount,
"suspenseAmount": demandDetails.suspenseBalance,
"totalAmount": receiptHdr.receiptAmount,
"instrumentList": intruArr
}
}
],
//"instrumentList" :intruArr
}
};
let data1;
if (type === "1") {
data1 = {
"RequestInfo": {
"apiId": "Rainmaker",
"ver": ".01",
"ts": "",
"action": "",
"did": "1",
"key": "",
"msgId": "20170310130900|en_IN",
"authToken": request.tokenInfo.RequestInfo.authToken
},
"RequestData": {
"departmentCode": "2",
"paymentUpdateDataList": [
{
"asseseeNo": demandDetails.asseseeNo,
"barcode": barcode, // optional for payment type ALL
"paymentType": "ALL", // null in case of barcoded payment
"useSuspense": "N",
"totalDemandAmount": receiptHdr.receiptAmount,
"useSuspenseAmount": 0,
"netPayableAmount": receiptHdr.payableAmount,
"demandList": demArr,
"receiptDetails": {
"receiptNo": receiptNo,
"paidBy": demandDetails.ownerNameDisplay,
"flatNo": demandDetails.premisesType,
"floorNo": demandDetails.premisesNo,
"mobileNo": demandDetails.mobileNo,
"emailId": "hh@gmail.com",
"paymentType": "PD",
"paymentAmount": paymentAmount,
"suspenseAmount": 0,
"totalAmount": receiptHdr.receiptAmount,
"instrumentList": intruArr
}
}
]
}
}
} else if (type === "3") {
data1 = {
"RequestInfo": {
"apiId": "Rainmaker",
"ver": ".01",
"ts": "",
"action": "",
"did": "1",
"key": "",
"msgId": "20170310130900|en_IN",
"authToken": request.tokenInfo.RequestInfo.authToken
},
"RequestData": {
"departmentCode": "2",
"paymentUpdateDataList": [
{
"asseseeNo": demandDetails.asseseeNo,
"barcode": barcode, // optional for payment type ALL
"paymentType": "ALL", // null in case of barcoded payment
"useSuspense": suspense[0].useSuspense,
"totalDemandAmount": receiptHdr.receiptAmount,
"useSuspenseAmount": suspense[0].ptAmount,
"netPayableAmount": parseFloat(receiptHdr.receiptAmount) - parseFloat(suspense[0].ptAmount),
"demandList": demArr,
// "miscDemandList" :[ //// for departmenal collection (misc /496/suspense collection) only
// {
// "asseseeNo" :"110610300789",
// "demandNo" :"20",
// "demandYear" :"2020-2021",
// "paybleAmount" :500,
// "netAmount" :500
// }
// ],
"receiptDetails": {
"receiptNo": receiptNo,
"paidBy": demandDetails.ownerNameDisplay,
"flatNo": demandDetails.premisesType,
"floorNo": demandDetails.premisesNo,
"mobileNo": demandDetails.mobileNo,
"emailId": "hh@gmail.com",
"paymentType": "PD",
"paymentAmount": paymentAmount + parseFloat(suspense[0].useSuspenseAmount),
"suspenseAmount": parseFloat(suspense[0].amount) + parseFloat(suspense[0].useSuspenseAmount),
"totalAmount": parseFloat(receiptHdr.receiptAmount) + parseFloat(suspense[0].amount),
"instrumentList": intruArr
}
}
]
}
}
} else if (type === "4" || type === "5") {
data1 = {
"RequestInfo": {
"apiId": "Rainmaker",
"ver": ".01",
"ts": "",
"action": "",
"did": "1",
"key": "",
"msgId": "20170310130900|en_IN",
"authToken": request.tokenInfo.RequestInfo.authToken
},
"RequestData": {
"departmentCode": "2",
"paymentUpdateDataList": [
{
"asseseeNo": demandDetails.asseseeNo,
"barcode": barcode, // optional for payment type ALL
"paymentType": "ALL", // null in case of barcoded payment
"useSuspense": 0,
"totalDemandAmount": receiptHdr.receiptAmount,
"useSuspenseAmount": 0,
"netPayableAmount": receiptHdr.payableAmount,
"demandList": [],
"miscDemandList": [ //// for departmenal collection (misc /496/suspense collection) only
{
"asseseeNo": demandDetails.asseseeNo,
"demandNo": receiptDtls[0].demandNo,
"demandYear": receiptHdr.financial_year,
"paybleAmount": receiptDtls[0].payableAmount,
"netAmount": receiptDtls[0].netAmount
}
],
"receiptDetails": {
"receiptNo": receiptNo,
"paidBy": demandDetails.ownerNameDisplay,
"flatNo": demandDetails.premisesType,
"floorNo": demandDetails.premisesNo,
"mobileNo": demandDetails.mobileNo,
"emailId": "hh@gmail.com",
"paymentType": "PD",
"paymentAmount": paymentAmount,
"suspenseAmount": 0,
"totalAmount": parseFloat(receiptHdr.receiptAmount),
"instrumentList": intruArr
}
}
]
}
}
}
if (type != 2) {
try {
// const response1 = await axios.post(url1, data1);
const response1 = {
data: {
"ResponseInfo": {
"status": "successful"
}
}
}
const result1 = response1.data;
console.log("====>", result1.ResponseInfo);
if (result1.ResponseInfo.status === 'successful') {
//recNumber = parseInt(result.receiptSeqNo);
let borough;
if (demandDetails.wardNo === "" || demandDetails.wardNo === null) {
borough = "";
} else {
borough = await ccReceiptService.getBorough(demandDetails.wardNo);
}
// console.log(dat.RequestData.paymentUpdateDataList[0].demandList);
// console.log(dat.RequestData.paymentUpdateDataList[0].receiptDetails.instrumentList);
// console.log("print", arr1);
const addReceiptHdr = await ccReceiptService.addReceiptHeaderData(
obj
);
const addReceiptDtls = await ccReceiptService.addReceiptDtlData(
arr
);
const addReceiptInsDtls = await ccReceiptService.addReceiptInsData(
arr1
);
// const addReceiptColl = await c
// console.log("updated seq===", updateSeq)
let query1 = await receiptService.updateOrSelectQuery(`UPDATE coll_kmc1_data.coll_ip_counter_map
SET coll_counter_wise_receipt_no = '${updateSeq}'
WHERE office_code = '${office}' and coll_counter_no = '${demand[0].receiptHdr.counter}' and financial_year = '2024-2025';`);
// let query2 = await receiptService.updateOrSelectQuery(`UPDATE coll_kmc1_data.tres_coll_receipt_instru_dtls
// SET tres_coll_cheque_dd_date = null
// where tres_coll_payment_mode='C';`);
let amountInWords = price_in_words(obj.TRES_COLL_RECEIPT_AMOUNT);
let query = `SELECT code FROM public.eg_hrms_employee WHERE id :: varchar ='${operatorDetails.userId}' or code ='${operatorDetails.userId}';`
let empId1 = await receiptService.updateOrSelectQuery(query);
let empId = empId1[0].code;
operatorDetails.userId = empId;
// console.log(empId);
if (chequeDetails.length >= 1) {
for (let h = 0; h < chequeDetails.length; h++) {
let query2 = `INSERT INTO public.coll_receipt_cheque_data
(receipt_no, cheque_no, cheque_date, cheque_amount, reason, document_data, type_of_chq, create_uid, create_date)
VALUES('${receiptNo}', '${chequeDetails[h].chequeNo}', '${chequeDetails[h].chequeDate}', '${chequeDetails[h].chequeAmount}', '${chequeDetails[h].reason}', '${chequeDetails[h].document}','${chequeDetails[h].typeOfCheque}', '${empId}', now());
`;
let fileChequeData = await receiptService.updateOrSelectQuery(query2);
}
}
let imgObj = {
receipt: obj,
receiptDtl: recDetlArr,
receiptInstru: billArr,
demandDtls: demandDetails,
module: "PROPERTY TAX",
operator: operatorDetails,
dateTime: receiptDateTime,
boroughId: 'Borough ' + borough,
total: obj.TRES_COLL_RECEIPT_AMOUNT,
amtWord: amountInWords
};
let options = {
format: "A4",
orientation: "portrait",
border: "10mm"
};
// receiptNo=receiptDtls.TRES_COLL_RECEIPT_NO;
// console.log(receiptNo);
// Original parameter value
const originalValue = JSON.stringify(obj.TRES_COLL_DEPARTMENT_CODE);
// Encrypt and URL-encode the parameter value
const encryptedValue = encryptValue(originalValue);
// console.log(encryptedValue);
const encodedValue = encodeURIComponent(encryptedValue.encryptedValue);
// Additional parameters
const receipt = receiptNo;
// Construct the URL with parameters
const base_url = 'https://kmcdev.ddns.net/collection-be/getReceipt';
const queryParameters = {
prn: encodedValue,
receipt,
};
const url12 = `${base_url}?${querystring.stringify(queryParameters)}`;
// console.log(url12);
var footerTemplate1 = `<!DOCTYPE html>` +
`<html>
<head>
<title></title>`+
`<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">`+
` <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<style>
footer {
position: fixed;
bottom: 0;
left: 0;
}
</style>`+
`<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js"></script>
<script src="https://cdn.jsdelivr.net/gh/davidshimjs/qrcodejs/qrcode.min.js"></script>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
</head>`+
` <footer id="pageFooter" style="height:120 px !important">
<table>
<tr>
<td class="col-sm-8" style="width:360px;">
<div style="text-align: left;font-size: 6px !important;font-weight: bold;">
Scan the QR Code to verify the Receipt.
</div>
</td>
</tr>
<tr class="col-sm-12">
<td class="col-sm-8" style="width:360px;">
<div id="qr_code"></div>
</td>
<td class="col-sm-4">
<div style="text-align: right;font-size: 8px !important;font-weight: bold;">
E. and O.E.
<br>
<br>
<br>
<br>
<br>
SIGNATURE OF OPERATOR
</div>
</td>
</tr>
</table>
</footer>`+
` <script>
var apiUrl = "https://kmcdev.ddns.net/collection-be/getReceipt";
var urlWithParam = "${url12}"; ` +
`var qrcode = new QRCode("qr_code", {
text: urlWithParam,
width: 60,
height: 60,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H
});
</script>
</html>`;
var html;
if (demand[0].receiptDtls[0].demandType !== "SUSP" || demand[0].receiptDtls[0].demandType !== "MISC") {
html = `${headerTemplate}${mainContent}${footerTemplate1}`;
} else {
html = `${headerTemplate}${mainContentPT}${footerTemplate1}`;
}
//console.log("html----------", html)
// const image = new Image();
// image.src ="Kolkata-Municipal-Corporation.png";
let document = {
type: 'buffer',
template: html,
// image:image,
context: {
options: imgObj
},
path: "./output.pdf"
};
// document.addImage()
let base64data = "";
const pdf1 = pdf.create(document, {
format: "A4",
orientation: "portrait",
border: "10mm",
paginationOffset: 1,
childProcessOptions: {
env: {
OPENSSL_CONF: '/dev/null',
}
},
}).then(async resp => {
// console.log("The resp is ", resp)
base64data = resp.toString('base64');
let query1 = `INSERT INTO public.coll_receipt_pdf_data
(receipt_no, pdf_base64_data, create_uid, create_date)
VALUES('${receiptNo}', '${base64data}', 'CC', now());`;
const receiptPdfData = await receiptService.updateOrSelectQuery(query1);
let query2 = `select id,receipt_no from public.coll_receipt_pdf_data where receipt_no ='${receiptNo}'`;
const receiptPdfDataId = await receiptService.updateOrSelectQuery(query2);
console.log("The base64data is ", receiptPdfDataId);
baseArr.push(base64data);
return baseArr;
}).
catch(error => {
console.log("error--------------", error)
})
const printReceipt = async () => {
const a = await pdf1;
return a;
}
printReceipt();
const data = await printReceipt();
baseArr = data;
return {
status: 200,
data: baseArr,
result: res
}
} else {
// Response is not successful, return an error message
return {
status: result1.statusCode,
receiptNo:receiptArr || [],
error: "Error: Response was not successful"
};
}
} catch (error) {
// Catch any errors that occur during the axios request
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.error("Error response status:", error.response.status);
console.error("Error response data:", error.response.data);
return {
status: error.response.status,
error: "Request failed",
receiptNo:receiptArr || [],
errorDescription: error.response.data
};
} else if (error.request) {
// The request was made but no response was received
console.error("No response received:", error.request);
return {
status: 500,
error: "No response received",
receiptNo:receiptArr || [],
errorDescription: error.request
};
} else {
// Something happened in setting up the request that triggered an Error
console.error("Error setting up request:", error.message);
return {
status: 500,
error: "Internal Server Error",
receiptNo:receiptArr || [],
errorDescription: error.message
};
}
}
} else {
let borough;
if (demandDetails.wardNo === "" || demandDetails.wardNo === null) {
borough = "";
} else {
borough = await ccReceiptService.getBorough(demandDetails.wardNo);
}
// console.log(dat.RequestData.paymentUpdateDataList[0].demandList);
// console.log(dat.RequestData.paymentUpdateDataList[0].receiptDetails.instrumentList);
// console.log("print", arr1);
const addReceiptHdr = await ccReceiptService.addReceiptHeaderData(
obj
);
const addReceiptDtls = await ccReceiptService.addReceiptDtlData(
arr
);
const addReceiptInsDtls = await ccReceiptService.addReceiptInsData(
arr1
);
// const addReceiptColl = await c
// console.log("updated seq===", updateSeq)
let query1 = await receiptService.updateOrSelectQuery(`UPDATE coll_kmc1_data.coll_ip_counter_map
SET coll_counter_wise_receipt_no = '${updateSeq}'
WHERE office_code = '${office}' and coll_counter_no = '${demand[0].receiptHdr.counter}' and financial_year = '2024-2025';`);
// let query2 = await receiptService.updateOrSelectQuery(`UPDATE coll_kmc1_data.tres_coll_receipt_instru_dtls
// SET tres_coll_cheque_dd_date = null
// where tres_coll_payment_mode='C';`);
let amountInWords = price_in_words(obj.TRES_COLL_RECEIPT_AMOUNT);
let query = `SELECT code FROM public.eg_hrms_employee WHERE id :: varchar ='${operatorDetails.userId}' or code ='${operatorDetails.userId}';`
let empId1 = await receiptService.updateOrSelectQuery(query);
let empId = empId1[0].code;
operatorDetails.userId = empId;
// console.log(empId);
if (chequeDetails.length >= 1) {
for (let h = 0; h < chequeDetails.length; h++) {
let query2 = `INSERT INTO public.coll_receipt_cheque_data
(receipt_no, cheque_no, cheque_date, cheque_amount, reason, document_data, type_of_chq, create_uid, create_date)
VALUES('${receiptNo}', '${chequeDetails[h].chequeNo}', '${chequeDetails[h].chequeDate}', '${chequeDetails[h].chequeAmount}', '${chequeDetails[h].reason}', '${chequeDetails[h].document}','${chequeDetails[h].typeOfCheque}', '${empId}', now());
`;
let fileChequeData = await receiptService.updateOrSelectQuery(query2);
}
}
let imgObj = {
receipt: obj,
receiptDtl: arr,
receiptInstru: billArr,
demandDtls: demandDetails,
paidByName: result1[0].paid_by_name,
module: "PROPERTY TAX",
operator: operatorDetails,
dateTime: receiptDateTime,
boroughId: 'Borough ' + borough,
total: obj.TRES_COLL_RECEIPT_AMOUNT,
amtWord: amountInWords
};
let options = {
format: "A4",
orientation: "portrait",
border: "10mm"
};
// receiptNo=receiptDtls.TRES_COLL_RECEIPT_NO;
// console.log(receiptNo);
// Original parameter value
const originalValue = JSON.stringify(obj.TRES_COLL_DEPARTMENT_CODE);
// Encrypt and URL-encode the parameter value
const encryptedValue = encryptValue(originalValue);
// console.log(encryptedValue);
const encodedValue = encodeURIComponent(encryptedValue.encryptedValue);
// Additional parameters
const receipt = receiptNo;
// Construct the URL with parameters
const base_url = 'https://kmcdev.ddns.net/collection-be/getReceipt';
const queryParameters = {
prn: encodedValue,
receipt,
};
const url12 = `${base_url}?${querystring.stringify(queryParameters)}`;
// console.log(url12);
var footerTemplate1 = `<!DOCTYPE html>` +
`<html>
https://github.com/Arshadtpr/collab_arshad/issues/new