Arshadtpr / collab_arshad

like collab editor
0 stars 0 forks source link

Text #1

Open Arshadtpr opened 6 months ago

Arshadtpr commented 6 months ago

https://github.com/Arshadtpr/collab_arshad/issues/new

Arshadtpr commented 5 months ago

Referral for Junior Accountant/Accounts Payable Position

Arshadtpr commented 5 months ago

100008 100006 12165

Arshadtpr commented 4 months ago

-- 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" =');

Arshadtpr commented 4 months ago

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',

Arshadtpr commented 4 months ago

https://govsharedstorage.blob.core.windows.net/kmc-gov-storage?sp=racwdl&st=2024-05-31T16:57:11Z&se=2025-06-01T00:57:11Z&spr=https&sv=2022-11-02&sr=c&sig=P8GH9qMvaTWoUc6m9qp1e0qUuBFcgg32euUbLZFTxag%3D

Arshadtpr commented 1 month ago

VPN: SDC DB arsusm ArsU#*#120

Arshadtpr commented 3 weeks ago

which eventually gets called with:

onload='javascript:resizeIframe(this);'

Arshadtpr commented 2 weeks ago

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>
`+ ` `+ ` `+ ` `+ `
Scan the QR Code to verify the Receipt.
E. and O.E.




SIGNATURE OF OPERATOR
`+ ` `; var html; // if (demand[0].receiptDtls[0].demandType !== "SUSP" || demand[0].receiptDtls[0].demandType !== "MISC") { // html = `${headerTemplate}${mainContent}${footerTemplate1}`; // } else { html = `${headerTemplate}${mainContentPTSusp}${footerTemplate1}`; //} //console.log("html----------", html) // const image = new Image(); // image.src ="Kolkata-Municipal-Corporation.png"; let query21 = await receiptService.updateOrSelectQuery(`UPDATE public.coll_suspense_data set modify_uid='${empId}', modify_date=now(), demand_status='P' WHERE demand_no='${result1[0].max}' AND reference_no='${demandDetails.asseseeNo}';`); 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(resp => { // console.log("The resp is ", resp) base64data = resp.toString('base64'); 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 } } } // console.log("Arrrrrrrrrrrrrrrrrr",baseArr); } } else { if (demand.length >= 1) { // Single const demandDetails = demand[0].demandDetails; const receiptHdr = demand[0].receiptHdr; const receiptDtls = demand[0].receiptDtls; let seqnc = Math.floor(Math.random() * 1000000); let financial_year = getCurrentFinancialYear(); console.log("ReceiptNo", receiptNo); // let receiptNo = parseInt(result.receiptSeqNo); let seqence = addLeadingZeros(recNumber, 6) console.log("RECEIPT NO", receiptNo_cc2 + seqence); receiptNo = receiptNo_cc2 + seqence; if (dept_code === 16) { receiptHdr.department = 16; } else if (dept_code === 5) { receiptHdr.department = 5; } else if (dept_code === 44) { receiptHdr.department = 44; } else if (dept_code === 75) { receiptHdr.department = 75; } else { receiptHdr.department = 2; } receipt21 = receiptNo; let obj = { TRES_COLL_RECEIPT_YEAR: 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_ISSUING_OFFICE_CODE 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: 0, 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: seqnc, TRES_COLL_STATIONERY_PREFIX: 'ZX', TRES_COLL_BOUNCED_AMOUNT: '0.00', TRES_COLL_STATIONARY_NO_TO: seqnc + 1 } let arrRec = []; let arr = []; 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(); let pdate1; //let console.log(pdate1); arrRec.push(receiptDtls[i]); 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; let demandYear; if (receiptDtls[i].demandType === "FIN" || receiptDtls[i].demandType === "PS" || receiptDtls[i].demandType === "MS" || receiptDtls[i].demandType === "PAR" || receiptDtls[i].demandType === "BUS") { pdate1 = receiptDtls[i].presentationDate; pdate1 = receiptDtls[i].rebateDate; } else { pdate1 = moment(dateObject1).format('YYYY-MM-DD hh:mm:ss.mmm'); rdate1 = moment(dateObject).format('YYYY-MM-DD hh:mm:ss.mmm'); } if (demandDetails.asseseeNo === demandDetails.barcode) { 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 { 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'); } if (receiptDtls[i].demandType === "MAT") { let dateNow = new Date(); pdate1 = moment(dateNow).format('YYYY-MM-DD hh:mm:ss.mmm'); rdate1 = moment(dateNow).format('YYYY-MM-DD hh:mm:ss.mmm'); } console.log(rdate1, pdate1); // let dateStr3 =new Date(element.rebateDate); //moment(receiptDtls[i].rebateDate).format('YYYY-MM-DD hh:mm:ss.mmm') if (receiptDtls[i].demandType === "SUSP" || receiptDtls[i].demandType === "MISC") { con_var = 1; console.log("demandType ", receiptDtls[i].demandType) let object; arr.push(object); } else { console.log("demandType ", receiptDtls[i].demandType) con_var = 0; let object; if (dept_code === 16) { receiptDtls[i].department = 16; } else { receiptDtls[i].department = 2; } if (receiptDtls[0].demandType === 'SWM') { 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: demandDetails.demand_year, TRES_COLL_DEMAND_INFO_2: receiptDtls[i].demandNo, TRES_COLL_DEMAND_INFO_3: demandDetails.lic_ce_no, TRES_COLL_DEMAND_INFO_4: '1', TRES_COLL_DEMAND_INFO_5: '0', TRES_COLL_PRESENTATION_DATE: pdate1, TRES_COLL_REBATE_DATE: rdate1, 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 if (receiptDtls[0].demandType === 'SWM_MISC') { 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: demandDetails.demand_year, TRES_COLL_DEMAND_INFO_2: receiptDtls[i].demandNo, TRES_COLL_DEMAND_INFO_3: i, TRES_COLL_DEMAND_INFO_4: '1', TRES_COLL_DEMAND_INFO_5: '0', TRES_COLL_PRESENTATION_DATE: pdate1, TRES_COLL_REBATE_DATE: rdate1, 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 if (receiptDtls[0].demandType === 'PAR') { object = { TRES_COLL_RECEIPT_YEAR: receiptHdr.financial_year, TRES_COLL_RECEIPT_NO: receiptNo, TRES_COLL_COLLECT_CENTER_CODE: office, TRES_COLL_DEMAND_INFO_1: demandDetails.demandYear, TRES_COLL_DEMAND_INFO_2: demandDetails.demandId, TRES_COLL_DEMAND_INFO_3: demandDetails.areaCode, TRES_COLL_DEMAND_INFO_4: demandDetails.agencyName, TRES_COLL_DEMAND_INFO_5: '0', TRES_COLL_PRESENTATION_DATE: pdate1, TRES_COLL_REBATE_DATE: rdate1, 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 if (receiptDtls[0].demandType === 'MAT') { demandYear = getDemandYear(receiptDtls[i].barcodeData.demandYear); object = { TRES_COLL_RECEIPT_YEAR: financial_year, TRES_COLL_RECEIPT_NO: receiptNo, TRES_COLL_COLLECT_CENTER_CODE: office, TRES_COLL_DEMAND_INFO_1: demandYear, TRES_COLL_DEMAND_INFO_2: receiptDtls[i].barcodeData.demandNo, TRES_COLL_DEMAND_INFO_3: receiptDtls[i].barcodeData.officeCode, TRES_COLL_DEMAND_INFO_4: receiptDtls[i].barcodeData.docType, TRES_COLL_DEMAND_INFO_5: receiptDtls[i].barcodeData.maaNo, TRES_COLL_PRESENTATION_DATE: pdate1, TRES_COLL_REBATE_DATE: rdate1, 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: receiptHdr.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, TRES_COLL_DEMAND_INFO_5: receiptDtls[i].billNo + receiptDtls[i].shareType ? receiptDtls[i].billNo + receiptDtls[i].shareType : '2102340C', TRES_COLL_PRESENTATION_DATE: pdate1, TRES_COLL_REBATE_DATE: rdate1, 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 } } // let arr.push(object); } } let arr1 = []; let i = 0; let bankName = ""; let bankBranchName = ""; let billArr = []; const date12 = new Date(); const date21 = moment(date12).format('YYYY-MM-DD'); 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" } ); let seq = Math.floor(Math.random() * 100); let objt = { TRES_COLL_RECEIPT_YEAR: financial_year, TRES_COLL_RECEIPT_NO: receiptNo, TRES_COLL_COLLECT_CENTER_CODE: billDetails[k].centre_code, TRES_COLL_INST_SL_NO: insNo + 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 } let paymentType = ""; if (billDetails[k].mode != 'C') { console.log("===="); 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, billDetails[k].bankCode); console.log("bankName", bankName); console.log("bankName", bankBranchName); } else { bankBranchName = '-'; console.log("bankName", bankName); console.log("bankName", 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 ? billDetails[k].chDate : '-', amount: billDetails[k].instruAmt } if (billDetails[k].mode == 'D') { billDtls.mode = 'DRAFT' paymentType = "DEMAND DRAFT"; } else if (billDetails[k].mode == 'Q') { billDtls.mode = 'CHEQUE' paymentType = "CHEQUE"; } else if (billDetails[k].mode == 'C') { billDtls.mode = 'CASH' paymentType = "CASH"; } billArr.push(billDtls); arr1.push(objt); i + 1; //}) } const addReceiptHdr = await ccReceiptService.addReceiptHeaderData( obj ); const addReceiptDtls = await ccReceiptService.addReceiptDtlData( arr ); const addReceiptInsDtls = await ccReceiptService.addReceiptInsData( arr1 ); let updatedNo = parseInt(recNumber) + 1; let query1 = await receiptService.updateOrSelectQuery(`UPDATE coll_kmc1_data.coll_ip_counter_map SET coll_counter_wise_receipt_no = '${updatedNo}' WHERE office_code = '${office}' and coll_counter_no = '${demand[0].receiptHdr.counter}' and financial_year = '2024-2025';`); // console.log({ dd: ele.TRES_COLL_DEMAND_INFO_3 }); if (receiptDtls[0].demandType === "PAR") { arr.forEach(async ele => { if (ele.TRES_COLL_DEMAND_INFO_3.startsWith('1')) { ele.type = "CITIZEN"; let paymentUrl = 'https://kmcdev.ddns.net/parking-services/updateCitizenDemandPaymentDetails'; let paymentData = { "demandAcknowledgementNum": receiptDtls[0].demandNo, "paymentMode": 2, "referenceId": receiptNo, "paymentBy": demandDetails.mobileNo, "createdBy": receiptDtls[0].empId, }; const res = await axios.post(paymentUrl, paymentData); const result1 = res.data; console.log("Resssss===>", res?.data); } else if (ele.TRES_COLL_DEMAND_INFO_3.startsWith('2')) { ele.type = "AGENCY"; let paymentUrl = 'https://kmcdev.ddns.net/parking-services/updateAgencyDemandPaymentDetails'; let paymentData = { "demandAcknowledgementNum": receiptDtls[0].demandNo, "paymentMode": 2, "referenceId": receiptNo, "paymentBy": demandDetails.mobileNo, "createdBy": receiptDtls[0].empId, }; const res = await axios.post(paymentUrl, paymentData); const result1 = res.data; console.log("Resssss===>", res?.data); } }); if (receiptDtls[0].demandType === "BUS") { let paymentUrl = 'https://kmcdev.ddns.net/bustee-services/updateLoiDemandPaymentDetails'; let paymentData = { "paymentType": "", // "demandAcknowledgementNum": receiptDtls[0].demandNo, // "paymentMode": 2, // "referenceId": receiptNo, // "paymentBy": demandDetails.mobileNo, // "createdBy": receiptDtls[0].empId, "loiDemandNo": receiptDtls[0].demandNo, "amountPaid": receiptHdr?.receiptAmount, "bankName": bankName, "branchName": bankBranchName, "ddNo": billDetails[0].chNumber, "draftDate": "2024-09-03T00:00:00.000Z", "paymentBy": demandDetails.mobileNo, "paymentDate": "2024-09-03T00:00:00.000Z", "paymentMode": 2, "referenceId": receiptNo, "referenceNo": receiptNo, "authToken": request?.tokenInfo?.RequestInfo?.authToken || "", "timeStamp": moment().toISOString() } const res = await axios.post(paymentUrl, paymentData); const result1 = res.data; console.log("Resssss===>", res?.data); } } if (addReceiptHdr && addReceiptDtls && addReceiptInsDtls) { let borough; let moduleName; let particulars; if (receiptDtls[0].demandType !== "FIN" && receiptDtls[0].demandType !== "PS" && receiptDtls[0].demandType !== "MS" && receiptDtls[0].demandType !== "PAR" && receiptDtls[0].demandType !== "LIC" && receiptDtls[0].demandType !== "SWM" && receiptDtls[0].demandType !== "BUS" && receiptDtls[0].demandType !== "SWM_MISC" && receiptDtls[0].demandType !== "MAT") { borough = await ccReceiptService.getBorough(demandDetails.wardNo); moduleName = "Assessment and Collection" particulars = 'PROPERTY TAX' } else if (receiptDtls[0].demandType === "SWM") { borough = await ccReceiptService.getBorough(demandDetails.lic_ward_no); demandDetails.wardNo = demandDetails.lic_ward_no; moduleName = "SOLID WASTE MANAGEMENT" particulars = 'SOLID WASTE MANAGEMENT' } else if (receiptDtls[0].demandType === "SWM_MISC") { borough = await ccReceiptService.getBorough(demandDetails.lic_ward_no); demandDetails.wardNo = demandDetails.lic_ward_no; moduleName = "SOLID WASTE MANAGEMENT" particulars = 'SOLID WASTE MANAGEMENT' } else { borough = "-"; if (receiptDtls[0].demandType === "FIN") { moduleName = "FINANCE" particulars = 'FINANCE' } else if (receiptDtls[0].demandType === "PS") { moduleName = "PARKS AND SQUARES"; particulars = 'PARK BOOKING FEE'; let query = ` UPDATE "km.kolkata".park_request_header SET park_treasury_receipt_no='${receiptNo}', park_treasury_receipt_date=now(), paymentdate=now(), paymentstatus='1', paymentby='${operatorDetails.userId}', uniquepaymentcode='${receiptNo}',statusdesc='Paid' WHERE park_sl_no='${receiptDtls[0].park_sl_no}' and permissionrequestnumber='${receiptDtls[0].permissionrequestnumber}';` let receiptPaidUpdate = await receiptService.updateOrSelectFinQuery(query); } else if (receiptDtls[0].demandType === "MS") { moduleName = "PARKS AND SQUARES" particulars = 'PARKS AND SQUARES' } else if (receiptDtls[0].demandType === "PAR") { moduleName = "PARKING" particulars = 'PARKING' } else if (receiptDtls[0].demandType === "BUS") { moduleName = "BUSTEE"; particulars = 'Pay and Use Toilet Fee'; } else if (receiptDtls[0].demandType === "LIC") { moduleName = "LICENSE" particulars = 'LICENSE' } else if (receiptDtls[0].demandType === "MAT") { moduleName = "MAT"; if (receiptDtls[i].barcodeData.docType === '2') { particulars = 'Appeal and Process Fees' } else if (receiptDtls[i].barcodeData.docType === '5') { particulars = 'Limitation Fees' } else if (receiptDtls[i].barcodeData.docType === '6') { particulars = 'Miscellaneous Fees' } } } let amountInWords = price_in_words(obj.TRES_COLL_RECEIPT_AMOUNT); let imgObj; if (receiptDtls[0].demandType === "SWM_MISC") { imgObj = { receipt: obj, receiptDtl: receiptDtls, module: moduleName, receiptInstru: billArr, demandDtls: demandDetails, operator: operatorDetails, dateTime: receiptDateTime, boroughId: 'Borough ' + borough, total: obj.TRES_COLL_RECEIPT_AMOUNT, amtWord: amountInWords }; let receiptColl = await ccReceiptService.insertReceiptColl(receiptNo, JSON.stringify(imgObj), demandDetails.mobileNo, receiptHdr.empId); } else if (receiptDtls[0].demandType === "MAT") { imgObj = { receipt: obj, receiptDtl: receiptDtls, module: moduleName, particulars: particulars, receiptInstru: billArr, demandDtls: demandDetails, operator: operatorDetails, dateTime: receiptDateTime, boroughId: 'Borough ' + borough, total: obj.TRES_COLL_RECEIPT_AMOUNT, amtWord: amountInWords }; let receiptColl = await ccReceiptService.insertReceiptColl(receiptNo, JSON.stringify(imgObj), demandDetails.mobileNo, receiptHdr.empId); } else if (receiptDtls[0].demandType === "PS") { imgObj = { receipt: obj, receiptDtl: receiptDtls, module: moduleName, particulars: particulars, receiptInstru: billArr, demandDtls: demandDetails, operator: operatorDetails, dateTime: receiptDateTime, boroughId: 'Borough ' + borough, total: obj.TRES_COLL_RECEIPT_AMOUNT, amtWord: amountInWords }; let receiptColl = await ccReceiptService.insertReceiptColl(receiptNo, JSON.stringify(imgObj), demandDetails.mobileNo, receiptHdr.empId); } else { imgObj = { receipt: obj, receiptDtl: arr, module: moduleName, particulars: particulars, receiptInstru: billArr, demandDtls: demandDetails, operator: operatorDetails, dateTime: receiptDateTime, boroughId: 'Borough ' + borough, total: obj.TRES_COLL_RECEIPT_AMOUNT, amtWord: amountInWords }; let receiptColl = await ccReceiptService.insertReceiptColl(receiptNo, JSON.stringify(imgObj), demandDetails.mobileNo, receiptHdr.empId); } // receiptNo=imgObj.receipt.TRES_COLL_RECEIPT_NO; console.log("Receipt No", receiptNo); let options = { format: "A4", orientation: "portrait", border: "10mm" } // 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 url = `${base_url}?${querystring.stringify(queryParameters)}`; console.log(url); var footerTemplate1 = `` + ` `+ ` `+ ` `+ ` `+ `
E. and O.E.




SIGNATURE OF OPERATOR
`+ ` `; var html; if (con_var == 0) { html = `${headerTemplate}${mainContent}${footerTemplate1}`; } else { html = `${headerTemplate}${mainContent1}${footerTemplate1}`; } console.log(imgObj); if (receiptDtls[0].demandType === "FIN") { html = `${headerTemplate}${mainContent2}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "PS") { html = `${headerTemplate}${mainContent3}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "MS") { html = `${headerTemplate}${mainContent3}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "PAR") { html = `${headerTemplate}${mainContent4}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "LIC") { html = `${headerTemplate}${mainContentLIC}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "SWM") { html = `${headerTemplate}${mainContentSWM}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "SWM_MISC") { html = `${headerTemplate}${mainContentSWMMISC}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "PAR") { html = `${headerTemplate}${mainContentSWM}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "MAT") { if (receiptDtls[i].barcodeData.docType === '2') { html = `${headerTemplate}${mainContentMAT}${footerTemplate1}`; } else if (receiptDtls[i].barcodeData.docType === '5') { html = `${headerTemplate}${mainContentMAT5}${footerTemplate1}`; } else if (receiptDtls[i].barcodeData.docType === '6') { html = `${headerTemplate}${mainContentMAT}${footerTemplate1}`; } } else if (receiptDtls[0].demandType === "BUS") { html = `${headerTemplate}${mainContentBustee}${footerTemplate1}`; } let document = { type: 'buffer', template: html, context: { options: imgObj }, path: "./output.pdf" }; // console.log("===HTML===>",document.template) //let baseData=""; return new Promise((resolve, reject) => { 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) let 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); let arr = []; arr.push(base64data); resolve({ status: 200, data: arr }) }) .catch(error => { console.log("error--------------", error) reject(JSON.stringify(error.Error ? error.Error : 'SOMETHING_WENT_WRONG_MSG')) }); }); } else { return { status: 500, data: "Error occured while updating the DB" } } } } } else { if (demand.length >= 1) { // Single const demandDetails = demand[0].demandDetails; const receiptHdr = demand[0].receiptHdr; const receiptDtls = demand[0].receiptDtls; let seqnc = Math.floor(Math.random() * 1000000); // let receiptNo = parseInt(result.receiptSeqNo); // console.log("RECEIPT NO",receiptNo); receiptNo = dDate1 + seqnc; console.log("ReceiptNo", receiptNo); let obj = { TRES_COLL_RECEIPT_YEAR: receiptHdr.financial_year, TRES_COLL_RECEIPT_NO: receiptNo, TRES_COLL_COLLECT_CENTER_CODE: receiptHdr.centre_code, 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_ISSUING_OFFICE_CODE 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: 0, 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: seqnc, TRES_COLL_STATIONERY_PREFIX: 'ZX', TRES_COLL_BOUNCED_AMOUNT: '0.00', TRES_COLL_STATIONARY_NO_TO: seqnc + 1 } let arrRec = []; let arr = []; 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(); let pdate1; //let console.log("00000", pdate1); arrRec.push(receiptDtls[i]); 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; if (receiptDtls[i].demandType === "FIN" || receiptDtls[i].demandType === "PS" || receiptDtls[i].demandType === "MS" || receiptDtls[i].demandType === "PAR") { pdate1 = receiptDtls[i].presentationDate; pdate1 = receiptDtls[i].rebateDate; } else { pdate1 = moment(dateObject1).format('YYYY-MM-DD hh:mm:ss.mmm'); rdate1 = moment(dateObject).format('YYYY-MM-DD hh:mm:ss.mmm'); } if (demandDetails.asseseeNo === demandDetails.barcode) { 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 { 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(rdate1, pdate1); // let dateStr3 =new Date(element.rebateDate); //moment(receiptDtls[i].rebateDate).format('YYYY-MM-DD hh:mm:ss.mmm') if (receiptDtls[i].demandType === "SUSP" || receiptDtls[i].demandType === "MISC") { con_var = 1; console.log("demandType ", receiptDtls[i].demandType) let object = { TRES_COLL_RECEIPT_YEAR: receiptDtls[i].financial_year, TRES_COLL_RECEIPT_NO: receiptNo, TRES_COLL_COLLECT_CENTER_CODE: receiptDtls[i].centre_code, TRES_COLL_DEMAND_INFO_1: receiptDtls[i].fromQtr ? receiptDtls[i].fromQtr : null, TRES_COLL_DEMAND_INFO_2: receiptDtls[i].fromQtr ? receiptDtls[i].fromQtr : null, TRES_COLL_DEMAND_INFO_3: receiptDtls[i].demandNo, TRES_COLL_DEMAND_INFO_4: receiptDtls[i].demandType ? receiptDtls[i].demandType : 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_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 } arr.push(object); } else { console.log("demandType ", receiptDtls[i].demandType) con_var = 0; console.log(receiptNo); let object = { TRES_COLL_RECEIPT_YEAR: receiptDtls[i].financial_year, TRES_COLL_RECEIPT_NO: receiptNo, TRES_COLL_COLLECT_CENTER_CODE: receiptDtls[i].centre_code, 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, TRES_COLL_DEMAND_INFO_5: receiptDtls[i].billNo + receiptDtls[i].shareType ? receiptDtls[i].billNo + receiptDtls[i].shareType : '2102340C', TRES_COLL_PRESENTATION_DATE: pdate1, TRES_COLL_REBATE_DATE: rdate1, 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 } console.log("object", object); arr.push(object); } } let arr1 = []; let i = 0; let bankName = ""; let bankBranchName = ""; let billArr = []; const date12 = new Date(); const date21 = moment(date12).format('YYYY-MM-DD'); console.log('billdetails', billDetails); for (let k = 0; k < billDetails.length; k++) { console.log(billDetails[k].mode); //billDetails.forEach(async billDetails[k] =>{ billDetails[k].mode = 'O'; let objt = { TRES_COLL_RECEIPT_YEAR: billDetails[k].financial_year, TRES_COLL_RECEIPT_NO: receiptNo, TRES_COLL_COLLECT_CENTER_CODE: billDetails[k].centre_code, TRES_COLL_INST_SL_NO: insNo + 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 ? billDetails[k].bankCode : '1', TRES_COLL_BRANCH_CODE: billDetails[k].branch_code ? billDetails[k].branch_code : '1', 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 (billDetails[k].mode != 'C' && billDetails[k].mode != 'O') { console.log("====33333"); 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, billDetails[k].bankCode); console.log("bankName", bankName); console.log("bankName", bankBranchName); } else { bankBranchName = '-'; console.log("bankName", bankName); console.log("bankName", bankBranchName); } console.log("bankName", bankName); console.log("bankName", bankBranchName); } else { bankName = 'ONLINE'; bankBranchName = 'ONLINE'; } let billDtls = { mode: "ONLINE", bank: bankName ? bankName : '-', branch: bankBranchName ? bankBranchName : '-', chequeNo: billDetails[k].chNumber ? billDetails[k].chNumber : '-', chequeDate: billDetails[k].chDate ? billDetails[k].chDate : '-', amount: billDetails[k].instruAmt } if (billDetails[k].mode == 'D') { billDtls.mode = 'DRAFT' } else if (billDetails[k].mode == 'Q') { billDtls.mode = 'CHEQUE' } else if (billDetails[k].mode == 'C') { billDtls.mode = 'CASH' } billArr.push(billDtls); arr1.push(objt); i + 1; //}) } if (receiptDtls[0].demandType === "PAR") { arr.forEach(async ele => { if (ele.TRES_COLL_DEMAND_INFO_3.startsWith('1')) { ele.type = "CITIZEN"; let paymentUrl = 'https://kmcdev.ddns.net/parking-services/updateCitizenDemandPaymentDetails'; let paymentData = { "demandAcknowledgementNum": receiptDtls[0].demandNo, "paymentMode": 2, "referenceId": receiptNo, "paymentBy": demandDetails.mobileNo, "createdBy": receiptDtls[0].empId, }; const res = await axios.post(paymentUrl, paymentData); const result1 = res.data; console.log("Resssss===>", res?.data); } else if (ele.TRES_COLL_DEMAND_INFO_3.startsWith('2')) { ele.type = "AGENCY"; let paymentUrl = 'https://kmcdev.ddns.net/parking-services/updateAgencyDemandPaymentDetails'; let paymentData = { "demandAcknowledgementNum": receiptDtls[0].demandNo, "paymentMode": 2, "referenceId": receiptNo, "paymentBy": demandDetails.mobileNo, "createdBy": receiptDtls[0].empId, }; const res = await axios.post(paymentUrl, paymentData); const result1 = res.data; console.log("Resssss===>", res?.data); } }); } if (receiptDtls[0].demandType === "BUS") { let paymentUrl = 'https://kmcdev.ddns.net/bustee-services/updateLoiDemandPaymentDetails'; let paymentData = { "paymentType": "ONLINE", // "demandAcknowledgementNum": receiptDtls[0].demandNo, // "paymentMode": 2, // "referenceId": receiptNo, // "paymentBy": demandDetails.mobileNo, // "createdBy": receiptDtls[0].empId, "loiDemandNo": receiptDtls[0].demandNo, "amountPaid": receiptHdr?.receiptAmount, "bankName": "", "branchName": "", "ddNo": "", "draftDate": "", "paymentBy": demandDetails.mobileNo, "paymentDate": moment().format("YYYY-MM-DD"), "paymentMode": 1, "referenceId": receiptNo, "referenceNo": receiptNo, "authToken": request?.tokenInfo?.RequestInfo?.authToken || "", "timeStamp": moment().toISOString() } const res = await axios.post(paymentUrl, paymentData); const result1 = res.data; console.log("Resssss===> BUS", res?.data); } // else if (receiptDtls[0].demandType === "BUS") { // moduleName = "BUSTEE"; // particulars = 'Pay and Use Toilet Fee'; // } if (receiptDtls[0].demandType === "BLD") { let paymentUrl = 'https://kmcdev.ddns.net/bpa-services/demand/_updateBuildingDemandStatus'; if (receiptDtls[i].billType !== 'PERMIT_393A_2' && receiptDtls[i].billType !== 'PERMIT_393A_1') { let paymentData = { "RequestInfo": { "apiId": "Rainmaker", "ver": ".01", "action": "", "did": "1", "key": "", "msgId": "20170310130900|en_IN", "requesterId": "", "authToken": request.tokenInfo.RequestInfo.authToken, "userInfo": { "id": 494, "userName": "Emp839", "name": "Md Reza Khan", "mobileNumber": "7483587839", "emailId": "reza@gmail.com", "locale": null, "type": "EMPLOYEE", "roles": [ { "name": "Super User", "code": "SUPERUSER", "tenantId": "km" } ], "active": true, "actions": null, "tenantId": "km", "uuid": "ea47dd7f-a8c7-4d9f-85e5-d79353c7b63d" } }, "paymentStatusDto": { "module": "OTHER", "bldgDemandStatus": "Paid", "bldgReceiptNumber": receiptNo, "bldgDemandNumber": receiptDtls[i].demandNo, "bldgPlanCaseNumber": "", "paymentDate": date12 } }; try { const response = await axios.post(paymentUrl, paymentData); const result = response.data; console.log("Resssss===>", result); } catch (error) { // Catch any errors that occur during the axios request console.error("Error occurred during axios request:", error); return { status: 500, error: "Internal Server Error:Probably Demand Already Paid", errorDescription: error }; } } else if (receiptDtls[i].billType === 'PERMIT_393A_1') { let paymentData = { "RequestInfo": { "apiId": "Rainmaker", "ver": ".01", "action": "", "did": "1", "key": "", "msgId": "20170310130900|en_IN", "requesterId": "", "authToken": request.tokenInfo.RequestInfo.authToken, "userInfo": { "id": 494, "userName": "Emp839", "name": "Md Reza Khan", "mobileNumber": "7483587839", "emailId": "reza@gmail.com", "locale": null, "type": "EMPLOYEE", "roles": [ { "name": "Super User", "code": "SUPERUSER", "tenantId": "km" } ], "active": true, "actions": null, "tenantId": "km", "uuid": "ea47dd7f-a8c7-4d9f-85e5-d79353c7b63d" } }, "paymentStatusDto": { "module": "PERMIT_393A_1", "bldgDemandStatus": "Paid", "bldgReceiptNumber": receiptNo, "bldgDemandNumber": "", "bldgPlanCaseNumber": receiptDtls[i].demandNo, "paymentDate": date12 } }; try { const response = await axios.post(paymentUrl, paymentData); const result = response.data; console.log("Resssss===>", result); } catch (error) { // Catch any errors that occur during the axios request console.error("Error occurred during axios request:", error); return { status: 500, error: "Internal Server Error:Probably Demand Already Paid", errorDescription: error }; } } else { let paymentData = { "RequestInfo": { "apiId": "Rainmaker", "ver": ".01", "action": "", "did": "1", "key": "", "msgId": "20170310130900|en_IN", "requesterId": "", "authToken": request.tokenInfo.RequestInfo.authToken, "userInfo": { "id": 603, "uuid": "ebd45108-afbb-48dc-ae9e-54f011b4be5f", "userName": "9836070700", "name": "Srijita", "mobileNumber": "9836070700", "emailId": null, "locale": null, "type": "CITIZEN", "roles": [ { "name": "Citizen", "code": "CITIZEN", "tenantId": "km" } ], "active": true, "tenantId": "km", "permanentCity": "km.kolkata" } }, "paymentStatusDto": { "module": "PERMIT_393A_2", "bldgDemandStatus": "Paid", "bldgReceiptNumber": receiptNo, "bldgDemandNumber": "", "bldgPlanCaseNumber": receiptDtls[i].demandNo, "paymentDate": date12 } }; try { const response = await axios.post(paymentUrl, paymentData); const result = response.data; console.log("Resssss===>", result); } catch (error) { // Catch any errors that occur during the axios request console.error("Error occurred during axios request:", error); return { status: 500, error: "Internal Server Error:Probably Demand Already Paid", errorDescription: error }; } } } // if (addReceiptHdr && addReceiptDtls && addReceiptInsDtls) { let borough; let moduleName; let demandDate; let UTR_NO; let UTR_Date; if (receiptDtls[0].demandType !== "BUS" && receiptDtls[0].demandType !== "FIN" && receiptDtls[0].demandType !== "PS" && receiptDtls[0].demandType !== "MS" && receiptDtls[0].demandType !== "PAR" && receiptDtls[0].demandType !== "LIC" && receiptDtls[0].demandType !== "SWM" && receiptDtls[0].demandType !== "BLD" && receiptDtls[0].demandType !== "SWM_MISC") { borough = await ccReceiptService.getBorough(demandDetails.wardNo); moduleName = "PROPERTY TAX" } else if (receiptDtls[0].demandType === "SWM") { borough = await ccReceiptService.getBorough(demandDetails.lic_ward_no); demandDetails.wardNo = demandDetails.lic_ward_no; moduleName = "SOLID WASTE MANAGEMENT" } else if (receiptDtls[0].demandType === "SWM_MISC") { borough = await ccReceiptService.getBorough(demandDetails.lic_ward_no); demandDetails.wardNo = demandDetails.lic_ward_no; moduleName = "SOLID WASTE MANAGEMENT" } else { borough = "-"; if (receiptDtls[0].demandType === "FIN") { moduleName = "FINANCE" } else if (receiptDtls[0].demandType === "PS") { moduleName = "PARKS AND SQUARES"; } else if (receiptDtls[0].demandType === "MS") { moduleName = "PARKS AND SQUARES"; } else if (receiptDtls[0].demandType === "PAR") { moduleName = "PARKING" } else if (receiptDtls[0].demandType === "LIC") { moduleName = "LICENSE" } else if (receiptDtls[0].demandType === "BLD") { console.log("aaa",demand[0].receiptDtls[0].demandNo); let query = `select * from public.portal_transaction_dtls ptd where ptd.demandno='${demand[0]?.receiptDtls[0]?.demandNo}' order by id desc limit 1;` let getUTRNo = await receiptService.getUTRNo(query); console.log(demand[0].demandDetails?.receiptDetails?.demandIssueDate); moduleName = receiptDtls[0].billType demandDate = moment(demand[0].demandDetails?.receiptDetails?.demandIssueDate).format("DD-MM-YYYY") || "-" UTR_NO = getUTRNo[0]?.trxn_no || mihpayid || txnid || "-" UTR_Date = moment(currentDate).format("DD-MM-YYYY") || "-" } } let amountInWords = price_in_words(obj.TRES_COLL_RECEIPT_AMOUNT); let imgObj; if (receiptDtls[0].demandType !== "BLD" && receiptDtls[0].demandType !== "PS") { imgObj = { receipt: obj, receiptDtl: arr, module: moduleName, receiptInstru: billArr, demandDtls: demandDetails, operator: operatorDetails, dateTime: receiptDateTime, boroughId: 'Borough ' + borough, total: obj.TRES_COLL_RECEIPT_AMOUNT, amtWord: amountInWords, demandDate: demandDate || "-", UTR_NO:UTR_NO || "-", UTR_Date:UTR_Date || "-", }; } else if (receiptDtls[0].demandType === "PS") { amountInWords = price_in_words(receiptDtls[0].demandAmount); imgObj = { receipt: obj, receiptDtl: receiptDtls, module: moduleName, receiptInstru: billArr, demandDtls: demandDetails, operator: operatorDetails, dateTime: receiptDateTime, boroughId: 'Borough ' + borough, demandDate: demandDate || "-", total: receiptDtls[0].demandAmount, amtWord: amountInWords, UTR_NO:UTR_NO || "-", UTR_Date:UTR_Date || "-", }; } else { imgObj = { receipt: obj, receiptDtl: receiptDtls, module: moduleName, receiptInstru: billArr, demandDtls: demandDetails, operator: operatorDetails, dateTime: receiptDateTime, boroughId: 'Borough ' + borough, total: obj.TRES_COLL_RECEIPT_AMOUNT, amtWord: amountInWords, demandDate: demandDate || "-", UTR_NO:UTR_NO || "-", UTR_Date:UTR_Date || "-", }; } // receiptNo=imgObj.receipt.TRES_COLL_RECEIPT_NO; console.log("Receipt No", receiptNo); let options = { format: "A4", orientation: "portrait", border: "10mm" } // 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 url = `${base_url}?${querystring.stringify(queryParameters)}`; console.log(url); var footerTemplate1 = `` + ` `+ ` `+ ` `+ ` `+ `
E. and O.E.




SIGNATURE OF OPERATOR
`+ ` `; var html; if (con_var == 0) { html = `${headerTemplate}${mainContent}${footerTemplate1}`; } else { html = `${headerTemplate}${mainContent1}${footerTemplate1}`; } // console.log(imgObj); if (receiptDtls[0].demandType === "FIN") { html = `${headerTemplate}${mainContent2}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "PS") { html = `${mainContentCitizenPS}`; } else if (receiptDtls[0].demandType === "MS") { html = `${headerTemplate}${mainContent3}${footerTemplate1}`; } else if (receiptDtls[0].demandType === "PAR") { //html = `${headerTemplate}${mainContent4}${footerTemplate1}`; html = `${headerTemplate}${mainContent4}`; } else if (receiptDtls[0].demandType === "LIC") { // html = `${headerTemplate}${mainContent}${footerTemplate1}`; html = `${headerTemplate}${mainContentLIC}`; imgObj.receiptDtl = []; imgObj.receiptDtl = receiptDtls; } else if (receiptDtls[0].demandType === "SWM") { // html = `${headerTemplate}${mainContentSWM}${footerTemplate1}`; html = `${headerTemplate}${mainContentSWM}`; } else if (receiptDtls[0].demandType === "SWM_MISC") { // html = `${headerTemplate}${mainContentSWMMISC}${footerTemplate1}`; html = `${headerTemplate}${mainContentSWMMISC}`; } else if (receiptDtls[0].demandType === "BLD") { // html = `${headerTemplate}${mainContentSWMMISC}${footerTemplate1}`; html = `${mainContentBuildingNew}`; } else if (receiptDtls[0].demandType === "BUS") { console.log("=====================BUS===================="); // html = `${headerTemplate}${mainContentSWMMISC}${footerTemplate1}`; html = `${mainCitizenReciept}`; imgObj.module = "BUSTEE"; imgObj.particulars = 'Pay and Use Toilet Fee'; } else if (receiptDtls[0].demandType === "SWM") { console.log("=====================SWM===================="); // html = `${headerTemplate}${mainContentSWMMISC}${footerTemplate1}`; html = `${mainContentSWMCitizen}`; imgObj.module = "SWM"; imgObj.particulars = 'SWM'; } console.log({ imgObj }); let document = { type: 'buffer', template: html, context: { options: imgObj }, path: "./output.pdf" }; // console.log("===HTML===>",document.template) //let baseData=""; return new Promise((resolve, reject) => { 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) let 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}', 'PORTAL', 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); //baseData=base64data; let arr = []; arr.push(base64data); resolve({ status: 200, data: arr, receipt_details: receiptPdfDataId }) }) .catch(error => { console.log("error--------------", error) reject(JSON.stringify(error.Error ? error.Error : 'SOMETHING_WENT_WRONG_MSG')) }); }); // } else { // return { // status: 500, // data: "Error occured while updating the DB" // } // } } } // } // else{ // return { // data: "Error found in the fetching Receipt Number to be used!", // status: 501 // } // } // } else { // return { // data: "Error found in the request parameters within Collection Info!", // status: 501 // } // } } else { return { data: "Error occurred while matching the hashvalues", status: 504 }; } // } else { // return tokenValidate; // } } else { return { data: "Error found in the request parameters!", status: 501 } } } catch (err) { throw err; } }