-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrade.js
1 lines (1 loc) · 53.8 KB
/
trade.js
1
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=7)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});class r extends Error{constructor(t,e="errCommon"){if(super(),this.isError=!1,Error.captureStackTrace(this,this.constructor),"errServer"==e&&(e="errCommon",console.log(`\n${(new Date).toUTCString()} :-`),console.log(t)),"object"==typeof t){if(void 0!==t.errCommon&&(this.errCommon=t.errCommon),void 0!==t.errModuleWise&&(this.errModuleWise=t.errModuleWise),void 0!==t.HTTP_R_S_Code&&(this.HTTP_R_S_Code=t.HTTP_R_S_Code),void 0!==t.isError&&(this.isError=t.isError),t.errCommon||t.errModuleWise||t.HTTP_R_S_Code)return this;this[e]=[],t instanceof Error?(console.log(`\n${(new Date).toUTCString()} :-`),console.log(t),this[e].push({strMessage:"SOMETHING_WENT_WRONG"})):this[e].push({strMessage:t.strMessage,objDetails:t.objDetails}),this.isError=!0}else t&&(this[e]=[],this[e].push({strMessage:t}),this.isError=!0)}add(t,e="errCommon"){if("errServer"==e&&(e="errCommon",console.log(`\n${(new Date).toUTCString()} :-`),console.log(t)),"object"==typeof t){if(void 0!==t.errCommon&&(this.errCommon=t.errCommon),void 0!==t.errModuleWise&&(this.errModuleWise=t.errModuleWise),void 0!==t.HTTP_R_S_Code&&(this.HTTP_R_S_Code=t.HTTP_R_S_Code),t.errCommon||t.errModuleWise||t.HTTP_R_S_Code)return this;void 0===this[e]&&(this[e]=[]),t instanceof Error?(console.log(`\n${(new Date).toUTCString()} :-`),console.log(t),this[e].push({strMessage:"SOMETHING_WENT_WRONG"})):this[e].push({strMessage:t.strMessage,objDetails:t.objDetails}),this.isError=!0}else void 0===this[e]&&(this[e]=[]),this[e].push({strMessage:t}),this.isError=!0}setStatus(t){return this.HTTP_R_S_Code=t,this}send({statusCode:t=400}={}){let e={errCommon:this.errCommon,errModuleWise:this.errModuleWise};return Object.keys(e).forEach(t=>void 0===e[t]?delete e[t]:""),this.HTTP_R_S_Code&&(t=this.HTTP_R_S_Code),{body:e,statusCode:t}}}e.default=r},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(13)),r(n(15)),r(n(21)),r(n(23)),r(n(26)),r(n(28)),r(n(29)),r(n(32))},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(33)),r(n(38)),r(n(56)),r(n(63)),r(n(65)),r(n(73)),r(n(77)),r(n(81))},function(t,e){t.exports=require("express")},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(17)),r(n(18)),r(n(19)),r(n(20))},function(t,e){t.exports=require("crypto-js")},function(t,e){t.exports=require("aws-sdk")},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(3)),u=n(8),s=r(n(9)),i=r(n(10)),a=r(n(0)),c=r(n(11)),l=n(103),d=o.default();try{d.use(i.default()),d.use(l.jwtTokenChecking),d.use(s.default.json()),d.use(s.default.urlencoded({limit:"50mb",extended:!0})),d.use((function(t,e,n,r){t instanceof SyntaxError&&"body"in t?n.status(400).send({errCommon:[{strMessage:"INVALID_JSON"}]}):r()})),d.use("/",c.default),d.listen(u.intPort,(function(){console.log("App is listening on port "+u.intPort)}))}catch(t){console.log(new a.default(t).send().body)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.intPort=3002},function(t,e){t.exports=require("body-parser")},function(t,e){t.exports=require("cors")},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});let o=r(n(3)).default.Router();o.use("/wallet",n(12)),o.use("/trade",n(92)),o.use("/returns",n(98)),e.default=o},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(3)),u=n(1),s=n(86);let i=o.default.Router();i.post("/create_wallet",u.makeController(s.createWalletController)),i.post("/get_wallet",u.makeController(s.getWalletController)),i.post("/get_acc_balance",u.makeController(s.getUserWiseAccBalanceController)),i.post("/update_retruns",u.makeController(s.updateWalletStatusController)),t.exports=i},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=r(n(14));e.makeController=function(t){return(e,n)=>{try{const r={body:e.body,query:e.query,params:e.params,ip:e.ip,strEncryptedToken:e.strEncryptedToken,intUserId:e.intUserId,fkPackageId:e.fkPackageId,strUserType:e.strUserType,method:e.method,timReceived:u.default().format("M/D/YYYY hh:m:s a"),path:e.originalUrl,strAudience:(e.get("str-audience")||"").toUpperCase(),headers:{"Content-Type":e.get("Content-Type"),Referer:e.get("referer"),"User-Agent":e.get("User-Agent")}};t(r).then(({headers:t={"Content-Type":"application/json","Last-Modified":(new Date).toUTCString()},type:e="json",statusCode:r=200,body:o})=>{if(!o)throw new Error("EMPTY_RESPONSE");n.set(t),n.type(e),n.status(r).send(o)}).catch(t=>{let e=new o.default(t).send();n.status(e.statusCode).set({"Content-Type":"application/json","Last-Modified":(new Date).toUTCString()}).send(e.body)})}catch(t){let e=new o.default(t).send();n.status(e.statusCode).set({"Content-Type":"application/json","Last-Modified":(new Date).toUTCString()}).send(e.body)}}}},function(t,e){t.exports=require("moment")},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(16),u=r(n(0)),s=n(4);e.getPgConnection=async function(){try{if(s.OBJ_DB_CONFIG){let t=await new o.Client(s.OBJ_DB_CONFIG);return await t.connect(),t}throw new u.default({strMessage:"CONFIGURATION_MISSING",objDetails:"DATABASE"},"errCommon")}catch(t){throw new u.default(t,"errServer")}}},function(t,e){t.exports=require("pg")},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.USER_MODULE="mdl_user"},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.STR_COMMON_DB_TENANT_ID="postgres",e.STR_COMMON_DB="postgres",e.STR_COMMON_DB_USER_NAME="postgres",e.STR_COMMON_DB_PASSWORD="root123",e.STR_BUCKET_URL="",e.INT_ESTIMATE_DELIVERY_DAYS=10,e.INT_MAX_MASTER_IMAGE_SIZE=100,e.INT_MAX_PRODUCT_IMAGE_SIZE=512,e.INT_MAX_PROFILE_IMAGE_SIZE=50,e.AWS_ACCESS_KEY_ID="AKIA444CFGVCJ7VJ5T4E",e.AWS_SECRET_ACCESS_KEY="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",e.AWS_S3_LOCATION="ap-south-1",e.AWS_S3_MASTER_BUCKET="swizbay",e.AWS_BUCKET_URL="https://swizbay.s3.ap-south-1.amazonaws.com/",e.OBJ_DB_CONFIG={user:"ubuntu",host:"localhost",database:"TRD",password:"ubuntu",port:5432},e.OBJ_MASTER_TYPE={expense:!0,vendor:!0,purchase:!0,material:!0,rental_items:!0},e.OBJ_OPEN_TABLE={tbl_materia:!0,tbl_rental:!0},e.OBJ_Account_TYPE={SUPPLIER:!0,PARTY:!0,CASH:!0,BANK:!0,VENDOR:!0,SALARY:!0,PURCHASE_COMMISION:!0,OTHER_EXPENSE:!0,OTHER_INCOME:!0}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TBL_USER="tbl_user",e.TBL_ACCOUNT="tbl_account",e.TBL_Master="tbl_master"},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.objOpenAPI={"/user/login_user":!0,"/login_user":!0,"/get_drop_down":!0,"/common/get_drop_down":!0,"/create_user":!0,"/user/create_user":!0}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(22)),u=r(n(5)),s=r(n(0));e.hashString=function(t){return new Promise((function(e,n){try{t.length>0?o.default.genSalt(10,(function(n,r){o.default.hash(t,r,(function(t,n){e(n)}))})):n("NULL_INPUT_RECVD")}catch(t){throw new s.default(t)}}))},e.compareHashAndText=function(t,e){return new Promise((async function(n,r){try{if(t&&e){n(await o.default.compareSync(t,e))}else r("NULL_INPUT_RECVD")}catch(t){throw new s.default(t)}}))},e.encryptString=async function(t){return t?(await u.default.AES.encrypt(t,"ABDR")).toString():t},e.decryptString=async function(t,e){return e?(await u.default.AES.decrypt(e,"ABDR")).toString(u.default.enc.Utf8):e}},function(t,e){t.exports=require("bcryptjs")},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(24)),u=r(n(0)),s=r(n(25));e.jwtSignIn=async function(t,e){try{let n=await s.default.readFileSync("./config/private.key","utf-8"),r=await({issuer:e.issuer,subject:e.subject,audience:e.audience,algorithm:"RS256"});return await o.default.sign(t,n,r)}catch(t){throw new u.default(t)}},e.jwtVerify=async function(t,e){try{let n=await s.default.readFileSync("./config/public.key","utf-8"),r={issuer:e.issuer,subject:e.subject,audience:e.audience,algorithm:"RS256"};return o.default.verify(t,n,r)}catch(t){throw new u.default(t)}},e.jwtDecode=async function(t){try{return o.default.decode(t,{complete:!0})}catch(t){throw new u.default(t)}}},function(t,e){t.exports=require("jsonwebtoken")},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(27)),u=r(n(0));async function s(){try{let t=await o.default.createClient();return console.log("redis connected"),t}catch(t){throw new u.default(t)}}e.initializeRedisConn=s,e.setRedisData=async function(t,e){let n=await s();try{return await n.on("error",(function(t){console.error(t)})),n.set(t,e,o.default.print)}catch(t){throw new u.default(t)}finally{await n.quit()}},e.getRedisData=async function(t){let e=await s();return new Promise((function(n,r){try{e.get(t,(function(t,e){e&&n(e),n(null)}))}catch(t){r(new u.default(t))}finally{e.quit()}}))},e.removeRedisKey=async function(t){let e=await s();return new Promise((function(n,r){try{e.del(t,(function(t,e){e&&n(e),n(null)}))}catch(t){r(new u.default(t))}finally{e.quit()}}))},e.checkPartialKeyExist=async function(t){let e=await s();return new Promise((function(n,r){try{return e.keys(t+"*",(function(t,e){e&&n(e),n(null)}))}catch(t){r(new u.default(t))}finally{e.quit()}}))}},function(t,e){t.exports=require("redis")},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.makeFileController=function(t){return(e,n)=>{try{const r={body:e.body,file:e.file,files:e.files,query:e.query,params:e.params,ip:e.ip,intUserId:e.intUserId,fkPackageId:e.fkPackageId,strUserType:e.strUserType,authorization:e.get("x-access-token"),method:e.method,timReceived:(new Date).toUTCString(),path:e.originalUrl,strAudience:(e.get("str-audience")||"").toUpperCase(),headers:{"Content-Type":e.get("Content-Type"),Referer:e.get("referer"),"User-Agent":e.get("User-Agent")}};t(r).then(({headers:t={"Content-Type":"text/plain","Last-Modified":(new Date).toUTCString()},type:e="json",statusCode:r=200,body:o})=>{if(!o)throw new Error("EMPTY_RESPONSE");n.set(t),n.type(e),n.status(r).send(o)}).catch(t=>{let e=new o.default(t).send();n.status(e.statusCode).set({"Content-Type":"application/json","Last-Modified":(new Date).toUTCString()}).send(e.body)})}catch(t){let e=new o.default(t).send();n.status(e.statusCode).set({"Content-Type":"application/json","Last-Modified":(new Date).toUTCString()}).send(e.body)}}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(4),u=r(n(30)),s=r(n(31)),i=r(n(6));let a=`mdlmaster${Date.now()}.jpg`;i.default.config.update({accessKeyId:o.AWS_ACCESS_KEY_ID,secretAccessKey:o.AWS_SECRET_ACCESS_KEY,region:o.AWS_S3_LOCATION});let c=new i.default.S3,l=u.default({storage:s.default({s3:c,bucket:o.AWS_S3_MASTER_BUCKET,metadata:function(t,e,n){n(null,{fieldName:a})},key:function(t,e,n){n(null,a),t.body[a]="https://masteraxef.s3.ap-south-1.amazonaws.com/"+a}})});e.fileUploadToS3=l},function(t,e){t.exports=require("multer")},function(t,e){t.exports=require("multer-s3")},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(2),u=r(n(6)),s=r(n(0));e.multiFilesToS3=async function({arrFiles:t}){try{const e=await o.findOne({strTableName:"tbl_config",strWhere:" WHERE type = 'aws' "});console.log("objConfig"),console.log(e.jsnDetails),await u.default.config.update({accessKeyId:e.jsnDetails.AWS_ACCESS_KEY_ID,secretAccessKey:e.jsnDetails.AWS_SECRET_ACCESS_KEY,region:e.jsnDetails.AWS_S3_LOCATION});let n=await new u.default.S3,r={},s="mdlmaster"+Date.now(),i=".jpg";return{arrUrls:await Promise.all(t.map(async(t,o)=>{console.log(t.name);let u=await t.name.split(".");return console.log("arrFilename"),console.log(u),i=await u[u.length-1],r["strImgUrl_"+o]=`${e.jsnDetails.AWS_BUCKET_URL}${o}${s}.${i}`,await n.putObject({Bucket:e.jsnDetails.AWS_S3_MASTER_BUCKET,Body:t.data,Key:`${o}${s}.${i}`,ACL:"public-read"},(function(t,e){t&&console.log("Error uploading data: ",t)})),{status:!0,url:`${e.jsnDetails.AWS_BUCKET_URL}${o}${s}.${i}`}})),...r}}catch(t){throw new s.default(t)}}},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(34)),r(n(35)),r(n(36)),r(n(37))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getIsoDate=function(t=new Date){return(t=new Date(t)).toISOString().replace(/T/," ").replace(/\..+/,"")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getFormatedDate=function(t){return t?("0"+(t=new Date(t)).getDate()).slice(-2)+"/"+("0"+(t.getMonth()+1)).slice(-2)+"/"+t.getFullYear():null}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getDbDate=function(t,e="dd/MM/yyyy"){if(!t)return null;let n=t.split("/"),r="";return"dd/MM/yyyy"==e||"yyyy/MM/dd"==e?r=`${n[2]}/${n[1]}/${n[0]}`:"MM/dd/yyyy"==e&&(r=`${n[2]}/${n[0]}/${n[1]}`),r}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getDateFormatChanger=function(t,e){if(!t||!e)return null;let n,r,o;return n=(t=t.replace(/\-/g,"/")).split("/"),o=(e=e.replace(/\-/g,"/")).split("/"),0==o.indexOf("dd")&&(r=`${n[2]}/${n[1]}/${n[0]}`),1==o.indexOf("dd")&&(r=`${n[2]}/${n[0]}/${n[1]}`),r}},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(39)),r(n(42)),r(n(44)),r(n(47)),r(n(50)),r(n(53))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(40))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0)),s=r(n(41)),i={"-1":null,1:"mdl_chart_of_account",2:"mdl_chart_of_account",3:"mdl_chart_of_account",4:"mdl_bank_account",5:"mdl_credit_card",6:"mdl_corporate_card",7:"mdl_cash_account",8:"mdl_cheque_account",9:"mdl_cheque_account",10:"mdl_cheque_account",11:"",12:"",13:"",14:"mdl_customer",15:"mdl_supplier",16:"",17:"mdl_airline",18:"",19:"",20:"",21:""};e.accountIsExists=async function({intAccountPk:t=-1,strAccountCode:e="",strAccountName:n="",arrAccountType:r=[]}){let a=await o.getPgConnection();try{n=n.toUpperCase(),t=t||-1;let o,c=await a.query(s.default.strQueryAccountInfo,[t,e,n]),l=new u.default;for(let t of c.rows)o=r.includes(t.int_account_type)?"-1":t.int_account_type,t.strCode==e&&l.add({strMessage:"CODE_DUPLICATE",objDetails:i[o]},"errCommon"),t.strName==n&&l.add({strMessage:"NAME_DUPLICATE",objDetails:i[o]},"errCommon");return l}catch(t){throw new u.default(t)}finally{a.end()}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r={strQueryAccountInfo:'SELECT \n vchr_third_party_mapping_code AS "strThirdPartyCode",\n vchr_account_code AS "strCode",\n UPPER(vchr_account_name) AS "strName",\n vchr_display_name AS "strDisplayName",\n int_account_type \nFROM tbl_account \nWHERE (chr_document_status = \'N\' \n AND pk_bint_account_id != $1)\n AND ( vchr_third_party_mapping_code=$2\t\n OR vchr_account_code=$3 \n OR UPPER(vchr_account_name)=$4 \n OR vchr_display_name=$5 )',strGetSystemMappingAccount:"SELECT \t\n fk_bint_account_id AS \"intAccountPk\" \n FROM tbl_system_mapping_accounts \n WHERE vchr_system_mapping_code=$1 AND chr_document_status='N' ",strGetBankChargesAccount:'SELECT \n b.fk_bint_bank_charge_account_id AS "intAccountPk",\n a.vchr_account_code AS "strCode",\n a.vchr_account_name AS "strName"\n FROM tbl_bank AS b\n LEFT JOIN tbl_account AS a \n ON b.fk_bint_bank_account_id = a.pk_bint_account_id\n WHERE a.pk_bint_account_id = $1 AND b.chr_document_status=\'N\' ',strGetCreditCardChargesAccount:'\n SELECT \n pos.fk_bint_expense_acc_id AS "intAccountPk",\n a.vchr_account_code AS "strCode",\n a.vchr_account_name AS "strName"\n FROM tbl_credit_card_pos AS pos\n JOIN tbl_account AS a \n ON pos.fk_bint_expense_acc_id = a.pk_bint_account_id\n WHERE pos.pk_bint_credit_card_pos_id = $1 AND pos.chr_document_status=\'N\' '};e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(43))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.transactionIsExists=async function({strConnection:t,intTransactionPk:e}){}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(45))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=r(n(46));e.createDataLogsDb=async function({objMainDbConnection:t,strModuleName:e,arrJsonItems:n=[],intUserId:r,timCurrent:s,strReason:i=""}){try{let o=" ",a=" ";n.forEach(t=>{o+=`('${e}','${JSON.stringify(t).replace(/'/g,"''")}','${s}',${r}),`,i&&(a+=`(${t.intPk},\n '${e}',\n '${i.replace(/'/g,"''")}',\n '${s}',\n ${r}),`)}),o=o.slice(0,-1),a=a.slice(0,-1),await t.query(u.default.strQueryInsertIntoLogTbl+o),i&&await t.query(u.default.strQueryInsertDeleteResonTbl+a)}catch(t){throw new o.default(t)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});let r={strQueryInsertIntoLogTbl:"INSERT INTO tbl_logs( vchr_module_name,\n json_log_item,\n time_created,\n fk_bint_created_user_id) VALUES ",strQueryInsertDeleteResonTbl:"INSERT INTO tbl_masters_delete_log( \n fk_bint_table_pk_id, \n vchr_table_name, \n txt_reason , \n tim_created, \n fk_bint_created_user_id) VALUES "};e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(48))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0)),s=r(n(49));e.getPermission=async function({source:t,strModule:e}){let n=await o.getPgConnection();try{return(await n.query(s.default.strGetPermission,[t.intUserID,e])).rows[0]}catch(t){throw new u.default(t)}finally{n.end()}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r={strGetPermission:'SELECT ugp.int_view AS "intView",\n ugp.int_add AS "intAdd",\n ugp.int_update AS "intUpdate",\n ugp.int_delete AS "intDelete",\n ugp.int_posting AS "intPosting",\n ugp.int_print AS "intPrint",\n ugp.int_reprint AS "intRePrint"\n FROM tbl_user_group_menu_permission AS ugp\n LEFT JOIN tbl_menu AS m \n ON ugp.fk_bint_menu_id=m.pk_bint_menu_id\n LEFT JOIN tbl_user_group AS ug\n ON ug.pk_bint_user_group_id=ugp.fk_bint_user_group_id\n LEFT JOIN tbl_user AS u\n ON u.fk_bint_user_group_id=ug.pk_bint_user_group_id\n WHERE u.pk_bint_user_id =$1\n AND m.vchr_menu_name =$2\n '};e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(51))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=r(n(52));e.getFinancialYearDb=async function(t,e){try{if(!e)return null;return(await t.query(u.default.strQueryGetFinancialYearSettingsTbl,[e])).rows[0]}catch(t){throw new o.default(t)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});let r={strQueryGetFinancialYearSettingsTbl:'\n SELECT \n pk_bint_financial_year_id AS "intPk",\n dat_financial_year_start AS "datStartDate",\n dat_financial_year_end AS "datEndDate",\n chr_financial_year_status AS "chrStatus"\n FROM tbl_financial_year\n WHERE (dat_financial_year_start, dat_financial_year_end) OVERLAPS ($1::DATE,$1::DATE) AND chr_document_status = \'N\' '};e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(54))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=r(n(55)),s=n(2);e.getPkBasedNameDb=async function(t,e,n,r){try{let o={"{WANTED_FIELD_NAME}":""+e,"{TBL_NAME}":""+n,"{WHERE}":r+" AND chr_document_status = 'N' "};return e||n||r?(await t.query(s.multiReplace(u.default.strQueryGetPkOfTblAttribute,o))).rows:null}catch(t){throw new o.default(t)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});let r={strQueryGetPkOfTblAttribute:"\n SELECT \n {WANTED_FIELD_NAME}\n FROM {TBL_NAME}\n WHERE {WHERE}"};e.default=r},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(57)),r(n(58)),r(n(59)),r(n(60)),r(n(61)),r(n(62))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0));e.insertQueryRunner=async function({strTableName:t,objValues:e,arrReturnItems:n=[]}){let r="",s="",i="",a=[],c=await o.getPgConnection();try{if(t){if(e&&Object.keys(e).length){await Object.keys(e).forEach((t,n)=>{s+=` ${t},`,i+=`$${n+1},`,a.push(e[t])}),r=`INSERT INTO ${t} (${s.slice(0,-1)}) VALUES (${i.slice(0,-1)}) ${n.length?"RETURNING "+n:" "} ;`,console.log("strQuery"),console.log(r);const o=await c.query(r,a);return console.log(o.rows[0]),o.rows}return null}return null}catch(t){throw t&&23505==t.code?new u.default("DUPLICATE ENTRY"):new u.default(t)}finally{c.end()}},e.insertTransQueryRunner=async function({strTableName:t,objValues:e,arrReturnItems:n=[],objDbConnection:r}){let o="",s="",i="",a=[];try{if(t){if(e&&Object.keys(e).length){await Object.keys(e).forEach((t,n)=>{s+=` ${t},`,i+=`$${n+1},`,a.push(e[t])}),o=`INSERT INTO ${t} (${s.slice(0,-1)}) VALUES (${i.slice(0,-1)}) ${n.length?"RETURNING "+n:" "} ;`,console.log("strQuery"),console.log(o);const u=await r.query(o,a);return console.log(u.rows[0]),u.rows}return null}return null}catch(t){throw await r.query("ROLLBACK"),t&&23505==t.code?new u.default("DUPLICATE ENTRY"):new u.default(t)}},e.insertWithAccQueryRunner=async function({strTableName:t,objValues:e,arrAccValues:n,arrReturnItems:r=[]}){let s="",i="",a="",c=[],l=await o.getPgConnection();try{if(t){if(e&&Object.keys(e).length){await l.query("BEGIN");const o=await l.query(" INSERT INTO tbl_account\n (str_account_name,\n str_account_type,\n fk_created_user_id,\n tim_created) VALUES ($1,$2,$3,$4) \n RETURNING pk_account_id",n);if(o&&o.rows&&o.rows[0]&&o.rows[0].pk_account_id){let n={fk_account_id:o.rows[0].pk_account_id,...e};await Object.keys(n).forEach((t,e)=>{i+=` ${t},`,a+=`$${e+1},`,c.push(n[t])}),s=`INSERT INTO ${t} (${i.slice(0,-1)}) VALUES (${a.slice(0,-1)}) ${r.length?"RETURNING "+r:" "} ;`;const u=await l.query(s,c);return console.log(u.rows[0]),await l.query("COMMIT"),u.rows}throw await l.query("ROLLBACK"),new u.default("FAILED")}return null}return null}catch(t){throw await l.query("ROLLBACK"),t&&23505==t.code?new u.default("ACCOUNT NAME DUPLICATE"):new u.default(t)}finally{l.end()}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0));e.commonQueryRunner=async function({strQuery:t,arrData:e=[]}){const n=await o.getPgConnection();try{let r;return r=e.length?await n.query(t,e):await n.query(t),r}catch(t){throw new u.default(t)}finally{n.end()}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0));e.findAll=async function({strTableName:t,strWhere:e="",strColounm:n=" * "}){const r=await o.getPgConnection();try{if(t&&e){const o=`SELECT ${n} FROM ${t} ${e} ;`;console.log("strQuery"),console.log(o);const u=await r.query(o);return console.log(u.rows[0]),u.rows}return null}catch(t){throw new u.default(t)}finally{r.end()}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0));e.findOne=async function({strTableName:t,strWhere:e="",strColounm:n=" * "}){const r=await o.getPgConnection();try{if(t&&e){const o=`SELECT ${n} FROM ${t} ${e} ;`;console.log("strQuery"),console.log(o);const u=await r.query(o);return u&&u.rows?u.rows[0]:null}return null}catch(t){throw new u.default(t)}finally{r.end()}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.transQueryRunner=async function({strQuery:t,objDbConnection:e}){try{const n=await e.query(t);return n&&n.rows&&n.rows.length?n.rows:!!n.rowCount}catch(t){throw await e.query("ROLLBACK"),t&&23505==t.code?new o.default("DUPLICATE ENTRY"):new o.default(t)}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.getQueryRunner=async function({strQuery:t,objDbConnection:e}){try{return await e.query(t)}catch(t){throw new o.default(t)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(64))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.escape=function(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(66)),r(n(67)),r(n(68)),r(n(69)),r(n(70)),r(n(71)),r(n(72))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(2);e.ltrim=function(t,e="\\s"){return t?("\\s"!==e&&(e=r.escape(e)),t.replace(new RegExp("^["+e+"]+","gm"),"")):t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(2);e.multiReplace=function(t,e){let n=[];for(let t in e)n.push(r.escape(t));return t.replace(new RegExp(n.join("|"),"g"),(function(t){return e[t]}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(2);e.rtrim=function(t,e="\\s"){return t?("\\s"!==e&&(e=r.escape(e)),t.replace(new RegExp("["+e+"]+$","gm"),"")):t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.slugify=function(t,e="U",n="_"){return t?"L"==e?t.replace(/[^a-z0-9]/gi,n).toLowerCase():"U"==e?t.replace(/[^a-z0-9]/gi,n).toLocaleUpperCase():t.replace(/[^a-z0-9]/gi,n):t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(2);e.trim=function(t,e="\\s"){return t?("\\s"!==e&&(e=r.escape(e)),t.replace(new RegExp("^["+e+"]+|["+e+"]+$","gm"),"")):t}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(5));e.encryptString=function(t,e){return e?o.default.AES.encrypt(e,"ABDU").toString():e}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(5));e.decryptString=function(t,e){return e?o.default.AES.decrypt(e,"ABDU").toString(o.default.enc.Utf8):e}},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(74)),r(n(75))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.getJSONToCSV=async function({arrItemList:t,objColumns:e=null,strMainTittle:n,intUserID:r}){try{let r=[],o=[],u=[],s=0;e&&e[Object.keys(e)[0]].forEach(t=>{1==t.blnShow&&(s++,o.push(t.strKey),u.push(t.strHeader))}),t.forEach(t=>{let e=[];o.forEach(n=>{e.push(t[n])}),r.push(e)});let i='"',a=",",c="",l=new Array(s);l[(u.length/2-1).toFixed(0)]=n,c=l+"\n",c+=u+"\n";let d=[];return r.forEach(t=>{let e="";d=t,d.forEach(t=>{e+=`${i}${t.toString()}${i},`}),c+=e+"\n"}),a+=a.replace(/,/g,a),c}catch(t){return new o.default(t)}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(76)),u=r(n(0));e.getJSONToExcel=async function({arrItemList:t,objColumns:e=null,strMainTittle:n,intUserID:r}){try{let r=[],u=[],s=[];e&&e[Object.keys(e)[0]].forEach(t=>{t.blnShow,u.push(t.strKey),s.push(t.strHeader)});let i={"!cols":[]};s.forEach(t=>{i["!cols"].push({wch:t.length+3})});let a=new Array;return a[(s.length/2-1).toFixed(0)]=n,r.push(a),r.push(s),t.forEach(t=>{let e=[];u.forEach(n=>{e.push(t[n])}),r.push(e)}),o.default.build([{data:r}],i)}catch(t){return new u.default(t)}}},function(t,e){t.exports=require("node-xlsx")},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(78)),r(n(79)),r(n(80))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createDataLog=async function({objSession:t,arrOldItem:e,intUserId:n,strCreatedTime:r}){return!0}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0));e.findRoe=async function(){const t=await o.getPgConnection();try{const e="SELECT * FROM tbl_roe ORDER BY id DESC LIMIT 1 ;",n=await t.query(e);return console.log(n.rows[0]),n.rows[0]}catch(t){throw new u.default(t)}finally{t.end()}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=r(n(0));e.findUserById=async function(t){const e=await o.getPgConnection();try{const n=`SELECT * FROM tbl_user WHERE id = ${t} ;`,r=await e.query(n);return console.log(r.rows[0]),r.rows[0]}catch(t){throw new u.default(t)}finally{e.end()}}},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(82)),r(n(83)),r(n(84)),r(n(85))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createDocId=function(t){return`SP/${t.strModule}/${(new Date).getTime()}`}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.updateWalletAmount=async function({userId:t,strDocId:e,intAmount:n,intBaseAmount:r,roe:u,timReceived:s,createdBy:i,objDbConnection:a}){try{const c=`SELECT id,"intAmount" FROM tbl_wallet_amount WHERE "userId" = ${t} AND "chrStatus"='N' ORDER BY DESC LIMIT 1`,{rows:l}=await a.query(c),d=l&&l[0]&&l[0].id?l[0].id:0,_=l&&l[0]&&l[0].intAmount?Number(l[0].intAmount)+n:0;if(_<0)throw new o.default("YOUR ACCOUNT HAVE NO PROPER BALANCE");const f=`UPDATE tbl_wallet_amount SET "chrStatus"='E'\n "updatedBy" = ${i},\n "updatedTime"='${s}'\n WHERE ${d?"id ="+d:'"chrStatus"=\'N\' AND "userId"='+t}`,y=`INSERT INTO ("intAmount","intTotalAmount","intBaseAmount","roe", "userId", "strDocId", "createdBy", "createdTime" ) \n VALUES (${n},${_},${r},${u},${t},'${e}',${i},'${s}');`;await a.query(f);return await a.query(y)}catch(t){throw new o.default(t)}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.getWalletAmount=async function({userId:t,objDbConnection:e}){try{const n=`${u} AND "userId" = ${t}`,{rows:r}=await e.query(n),o=r&&r[0]&&r[0]?r[0]:{intDebitAmount:0,intCreditAmount:0};return{intTotalAmont:Number(o.intCreditAmount)-Number(o.intDebitAmount),...o}}catch(t){throw new o.default(t)}};const u=' SELECT SUM("intDebitAmount") AS "intDebitAmount",\n SUM("intCreditAmount") AS "intCreditAmount"\n FROM tbl_wallet_amount\n WHERE "chrStatus"=\'N\' AND "strStatus"=\'COMPLETED\''},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.getTradeAmount=async function({userId:t,objDbConnection:e}){try{const n=`${u} AND "userId" = ${t}`,{rows:r}=await e.query(n),o=r&&r[0]&&r[0]?r[0]:{intDebitAmount:0,intCreditAmount:0};return{intTotalAmont:Number(o.intCreditAmount)-Number(o.intDebitAmount),...o}}catch(t){throw new o.default(t)}};const u=' SELECT SUM("intDebitAmount") AS "intDebitAmount",\nSUM("intCreditAmount") AS "intCreditAmount",\nCOUNT(*) FROM tbl_trade_amount\nWHERE "chrStatus"=\'N\''},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(87),o=n(91),u=o.createWalletControllerFactory({createWalletUsecase:r.createWalletUsecase});e.createWalletController=u;const s=o.getWalletControllerFactory({getWalletUsecase:r.getWalletUsecase});e.getWalletController=s;const i=o.updateWalletStatusControllerFactory();e.updateWalletStatusController=i;const a=o.getUserWiseAccBalanceControllerFactory({getUserWiseAccBalanceUsecase:r.getUserWiseAccBalanceUsecase});e.getUserWiseAccBalanceController=a},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(88)),u=r(n(89)),s=r(n(90)),i=o.default();e.createWalletUsecase=i;const a=u.default();e.getWalletUsecase=a;const c=s.default();e.getUserWiseAccBalanceUsecase=c},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2),s=n(1);e.default=function(){return async function({source:t,body:e}){const n=await s.getPgConnection();try{const r=await u.createDocId({strModule:"WALLET"}),o=await u.findRoe(),s=Number(o.roe)*Number(e.intCreditAmount),i=`$${e.intCreditAmount}(₹${s}) is added to account balance by ${e.strPayMethode}`,a="CASH_IN_HAND"!==e.strPayMethode?"COMPLETED":"REQUESTED",c=`INSERT INTO tbl_wallet_amount ("intCreditAmount","intBaseCreditAmount","roe","strText","userId",\n "strPayMode", "strStatus","strDocId","createdBy","createdTime") VALUES \n (${e.intCreditAmount},${s},${o.roe},'${i}',${t.intUserId},\n '${e.strPayMethode}','${a}','${r}',${t.intUserId},'${t.timReceived}') RETURNING * ;`;return await n.query("BEGIN"),await u.transQueryRunner({strQuery:c,objDbConnection:n}),await n.query("COMMIT"),{strMessage:i,strDocId:r}}catch(t){throw await n.query("ROLLBACK"),new o.default(t)}finally{n.end()}}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2),s=n(1);e.default=function(){return async function({source:t,body:e}){const n=await s.getPgConnection();try{let r='WHERE w."chrStatus" =\'N\' AND w."strStatus"=\'COMPLETED\' AND w."userId"= ',o={};const s=e.intLimit||100;let a;return"CUSTOMER"==t.strUserType?(a=await u.getQueryRunner({strQuery:`${i} ${r}${t.intUserId} ORDER BY w."createdTime" DESC LIMIT ${s} ;`,objDbConnection:n}),o=await u.getWalletAmount({objDbConnection:n,userId:t.intUserId})):a=await u.getQueryRunner({strQuery:`${i} ${r}${e.intUserId} ORDER BY w."createdTime" DESC LIMIT ${s} ;`,objDbConnection:n}),a.rows&&a.rows[0]&&a.rows[0].count&&"0"==a.rows[0].count?{arrList:[]}:{...o,arrList:a.rows||[]}}catch(t){throw new o.default(t)}finally{n.end()}}};const i=' \nSELECT \nw.id ,\nw."intDebitAmount",\nw."intCreditAmount",\nw."intBaseDebitAmount",\nw."intBaseCreditAmount",\nw."roe",\nw."strText",\nw."strDocId",\nw."strPayMode",\nw."strStatus",\nu."strFirstName" AS "strUser",\nw."userId",\nto_char(w."createdTime", \'DD MON YYYY at HH12:MI:SS PM\') as "createdTime" \nFROM tbl_wallet_amount AS w\nLEFT JOIN tbl_user AS u \nON u.id = w."userId" '},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2),s=n(1);e.default=function(){return async function({source:t,body:e}){const n=await s.getPgConnection();try{let t,r=[];if("WALLET"===e.type){let r=" ";const o=e.intLimit||100;t=await u.getQueryRunner({strQuery:` ${i.replace("{WHERE}",r)} LIMIT ${o} ;`,objDbConnection:n})}else{let r=" ";const o=e.intLimit||100;t=await u.getQueryRunner({strQuery:` ${a.replace("{WHERE}",r)} LIMIT ${o} ;`,objDbConnection:n})}return t&&t.rows?(r=await t.rows.map(t=>({intTotalAmont:Number(t.intCreditAmount)-Number(t.intDebitAmount),...t})),{arrList:r}):{strText:"No Data!!"}}catch(t){throw new o.default(t)}finally{n.end()}}};const i=' SELECT SUM(w."intDebitAmount") AS "intDebitAmount",\n SUM(w."intCreditAmount") AS "intCreditAmount",\n u."strFirstName" AS "strUser",\n w."userId"\n FROM tbl_wallet_amount AS w\n LEFT JOIN tbl_user AS u \n ON u.id = w."userId" \n WHERE w."chrStatus"=\'N\' AND w."strStatus"=\'COMPLETED\' {WHERE}\n GROUP BY w."userId",\n u."strFirstName" ',a=' SELECT SUM(w."intDebitAmount") AS "intDebitAmount",\nSUM(w."intCreditAmount") AS "intCreditAmount",\nu."strFirstName" AS "strUser",\nw."userId"\nFROM tbl_trade_amount AS w\nLEFT JOIN tbl_user AS u \nON u.id = w."userId" \nWHERE w."chrStatus"=\'N\' {WHERE}\nGROUP BY w."userId",\nu."strFirstName" '},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2),s=n(1);e.createWalletControllerFactory=function({createWalletUsecase:t}){return async function({body:e,...n}){try{return{body:await t({source:n,body:e})}}catch(t){return new o.default(t).send()}}},e.getWalletControllerFactory=function({getWalletUsecase:t}){return async function({body:e,...n}){try{return{body:await t({source:n,body:e})}}catch(t){return new o.default(t).send()}}},e.getUserWiseAccBalanceControllerFactory=function({getUserWiseAccBalanceUsecase:t}){return async function({body:e,...n}){try{return{body:await t({source:n,body:e})}}catch(t){return new o.default(t).send()}}},e.updateWalletStatusControllerFactory=function(){return async function({body:t,...e}){const n=await s.getPgConnection();try{if("ADMIN"!==e.strUserType)throw new o.default("YOU HAVE NO PERMISSION TO UPDATE");{const r=await u.getQueryRunner({strQuery:`SELECT * FROM tbl_wallet_amount WHERE id = ${t.id} AND "intIsReturn"=1 ;`,objDbConnection:n});let s;if(!(r&&r.rows&&r.rows[0]&&r.rows[0].userId))throw new o.default("RETURNS FAILED!!");s=r.rows[0].userId;const i=await u.getWalletAmount({objDbConnection:n,userId:s}),a=t.type||"COMPLETED";if(!(i&&r.rows&&r.rows[0]&&Number(i.intTotalAmont)>Number(r.rows[0].intDebitAmount)))throw new o.default("RETURNS FAILED!!");await u.getQueryRunner({strQuery:`UPDATE tbl_wallet_amount SET "strStatus" = '${a}',\n "strReturnStatus" = '${a}',\n "updatedBy" = ${e.intUserId},\n "updatedTime" = '${e.timReceived}' WHERE id = ${t.id} ;`,objDbConnection:n})}return{body:{strMessage:"PAYMENT COMPLETED"}}}catch(t){return new o.default(t).send()}finally{n.end()}}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(3)),u=n(1),s=n(93);let i=o.default.Router();i.post("/create_trade",u.makeController(s.createTradeController)),i.post("/get_trade",u.makeController(s.getTradeController)),t.exports=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(94),o=n(97),u=o.createTradeControllerFactory({createTradeUsecase:r.createTradeUsecase});e.createTradeController=u;const s=o.getTradeControllerFactory({getTradeUsecase:r.getTradeUsecase});e.getTradeController=s},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(95)),u=r(n(96)),s=o.default();e.createTradeUsecase=s;const i=u.default();e.getTradeUsecase=i},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2),s=n(1);e.default=function(){return async function({source:t,body:e}){const n=await s.getPgConnection();try{const r=await u.getWalletAmount({objDbConnection:n,userId:t.intUserId});if(e.intCreditAmount&&Number(e.intCreditAmount)>Number(r.intTotalAmont))throw new o.default("TRADE AMOUNT IS GRAITER THAN YOUR ACCOUNT BALANCE");const s=await u.createDocId({strModule:"TRADE"}),i=await u.findRoe(),a=Number(i.roe)*Number(e.intCreditAmount),c=`$${e.intCreditAmount} is added to Trade balance `,l=`$${e.intCreditAmount} is Debited from your Account,For Credits to Trade Account `,d=`INSERT INTO tbl_wallet_amount ("intDebitAmount","intBaseDebitAmount","roe","strText","userId",\n "strPayMode", "strStatus","strDocId","createdBy","createdTime") VALUES \n (${e.intCreditAmount},${a},${i.roe},'${l}',${t.intUserId},\n 'TRANSACTION','COMPLETED','${s}',${t.intUserId},'${t.timReceived}') RETURNING * ;`,_=`INSERT INTO tbl_trade_amount ("intCreditAmount","roe","strText","userId","strDocId","createdBy","createdTime") VALUES \n (${e.intCreditAmount},${i.roe},'${c}',${t.intUserId},\n '${s}',${t.intUserId},'${t.timReceived}') RETURNING * ;`;return await n.query("BEGIN"),await u.transQueryRunner({strQuery:_,objDbConnection:n}),await u.transQueryRunner({strQuery:d,objDbConnection:n}),await n.query("COMMIT"),{strMessage:c,strDocId:s}}catch(t){throw await n.query("ROLLBACK"),new o.default(t)}finally{n.end()}}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2),s=n(1);e.default=function(){return async function({source:t,body:e}){const n=await s.getPgConnection();try{let r='WHERE w."chrStatus" =\'N\' AND w."userId"=';const o=e.intLimit||100;let s;const a=await u.findRoe();if("CUSTOMER"==t.strUserType){if(s=await u.getQueryRunner({strQuery:`${i} ${r}${t.intUserId} ORDER BY w."createdTime" DESC LIMIT ${o} ;`,objDbConnection:n}),s.rows&&s.rows[0]&&s.rows[0].count&&"0"==s.rows[0].count)return{arrList:[]};return{...await u.getTradeAmount({objDbConnection:n,userId:t.intUserId}),...a,arrList:s.rows||[]}}return s=await u.getQueryRunner({strQuery:`${i} ${r}${e.intUserId} ORDER BY w."createdTime" DESC LIMIT ${o} ;`,objDbConnection:n}),s.rows&&s.rows[0]&&s.rows[0].count&&"0"==s.rows[0].count?{arrList:[],...a}:{arrList:s.rows||[],...a}}catch(t){throw new o.default(t)}finally{n.end()}}};const i=' \nSELECT \nw.id ,\nw."intDebitAmount",\nw."intCreditAmount",\nw."roe",\nw."strText",\nw."strDocId",\nu."strFirstName" AS "strUser",\nw."userId",\nto_char(w."createdTime", \'DD MON YYYY at HH12:MI:SS PM\') as "createdTime" \nFROM tbl_trade_amount AS w\nLEFT JOIN tbl_user AS u \nON u.id = w."userId" '},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0));e.createTradeControllerFactory=function({createTradeUsecase:t}){return async function({body:e,...n}){try{return{body:await t({source:n,body:e})}}catch(t){return new o.default(t).send()}}},e.getTradeControllerFactory=function({getTradeUsecase:t}){return async function({body:e,...n}){try{return{body:await t({source:n,body:e})}}catch(t){return new o.default(t).send()}}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(3)),u=n(1),s=n(99);let i=o.default.Router();i.post("/create_return",u.makeController(s.createReturnsController)),i.post("/get_return",u.makeController(s.getReturnsController)),t.exports=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(100),o=n(102),u=o.createReturnsControllerFactory({createRetunsUsecase:r.createRetunsUsecase});e.createReturnsController=u;const s=o.getReturnsControllerFactory();e.getReturnsController=s},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(101)).default();e.createRetunsUsecase=o},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2),s=n(1);e.default=function(){return async function({source:t,body:e}){const n=await s.getPgConnection();try{if("WALLET"==e.type){const r=await u.getWalletAmount({objDbConnection:n,userId:t.intUserId});if(e.intDebitAmount&&!(Number(e.intDebitAmount)<Number(r.intTotalAmont)))throw new o.default("RETURN AMOUNT IS GRAITER THAN YOUR ACCOUNT BALANCE");const s=await u.createDocId({strModule:"RETURN"}),i=await u.findRoe(),a=Number(i.roe)*Number(e.intDebitAmount),c=`$${e.intDebitAmount}(₹${a}) is returnted`,l="RETURN_REQUESTED",d=`INSERT INTO tbl_wallet_amount ("intDebitAmount","intBaseDebitAmount","roe","strText","userId",\n "strPayMode", "strStatus","strReturnStatus","intIsReturn","strDocId","createdBy","createdTime") VALUES \n (${e.intDebitAmount},${a},${i.roe},'${c}',${t.intUserId},\n 'CASH_IN_HAND','${l}','${l}',1,'${s}',${t.intUserId},'${t.timReceived}') RETURNING * ;`;return await n.query("BEGIN"),await u.transQueryRunner({strQuery:d,objDbConnection:n}),await n.query("COMMIT"),{strMessage:c,strDocId:s}}{const r=await u.getTradeAmount({objDbConnection:n,userId:t.intUserId});if(e.intDebitAmount&&Number(e.intDebitAmount)>Number(r.intTotalAmont))throw new o.default("RETURN TRADE AMOUNT IS GRAITER THAN YOUR TRADE BALANCE");const s=await u.createDocId({strModule:"TRADE_RETURN"}),i=await u.findRoe(),a=Number(i.roe)*Number(e.intDebitAmount),c=`$${e.intDebitAmount} is Debits from your Trade balance `,l=`$${e.intDebitAmount} is Credits from your Trade Account `,d=`INSERT INTO tbl_wallet_amount ("intCreditAmount","intBaseCreditAmount","roe","strText","userId",\n "strPayMode", "strStatus","strDocId","createdBy","createdTime") VALUES \n (${e.intDebitAmount},${a},${i.roe},'${l}',${t.intUserId},\n 'TRANSACTION','COMPLETED','${s}',${t.intUserId},'${t.timReceived}') RETURNING * ;`,_=`INSERT INTO tbl_trade_amount ("intDebitAmount","roe","strText","userId","strReturnStatus",\n "intIsReturn","strDocId","createdBy","createdTime") VALUES \n (${e.intDebitAmount},${i.roe},'${c}',${t.intUserId},'RETURN',1,\n '${s}',${t.intUserId},'${t.timReceived}') RETURNING * ;`;return await n.query("BEGIN"),console.log("strTradeQuery"),console.log(_),console.log("strWalletQuery"),console.log(d),await u.transQueryRunner({strQuery:_,objDbConnection:n}),await u.transQueryRunner({strQuery:d,objDbConnection:n}),await n.query("COMMIT"),{strMessage:c,strDocId:s}}}catch(t){throw await n.query("ROLLBACK"),new o.default(t)}finally{n.end()}}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(0)),u=n(2);e.createReturnsControllerFactory=function({createRetunsUsecase:t}){return async function({body:e,...n}){try{return{body:await t({source:n,body:e})}}catch(t){return new o.default(t).send()}}},e.getReturnsControllerFactory=function(){return async function({body:t,...e}){try{let n='WHERE w."intIsReturn"=1 ';"CUSTOMER"==e.strUserType&&(console.log(e.intUserId),n+=' AND w."userId"='+e.intUserId);const r=t.intLimit||100;return{body:{arrList:(await u.commonQueryRunner({strQuery:`${s} ${n} ORDER BY w."createdTime" DESC LIMIT ${r} ;`})).rows||[]}}}catch(t){return new o.default(t).send()}}};const s=' \nSELECT \nw.id ,\nw."intDebitAmount",\nw."intCreditAmount",\nw."intBaseDebitAmount",\nw."intBaseCreditAmount",\nw."roe",\nw."strText",\nw."strDocId",\nw."strPayMode",\nw."strStatus",\nu."strFirstName" AS "strUser",\nw."userId",\nto_char(w."createdTime", \'DD MON YYYY at HH12:MI:SS PM\') as "createdTime" \nFROM tbl_wallet_amount AS w\nLEFT JOIN tbl_user AS u \nON u.id = w."userId" '},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(104))},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),u=n(4),s=r(n(0));e.jwtTokenChecking=async function(t,e,n){let r={"Content-Type":"application/json","Last-Modified":(new Date).toUTCString()};try{const i=await t.headers["x-access-token"]||t.headers.authorization;if(i){console.log("strEncryptedToken"),console.log(i);if(!await o.getRedisData(i))return e.status(401).set(r).send(new s.default("INVALID_TOKEN_PROVIDED").send().body);const a=await o.decryptString(u.STR_COMMON_DB_TENANT_ID,i);if(!a)return e.status(401).set(r).send(new s.default("INVALID_TOKEN_PROVIDED").send().body);{const e={issuer:"issuer",subject:"IP",audience:"ABDU"},r=await o.jwtVerify(a,e);t.intUserId=r.intUserId,t.fkPackageId=r.fkPackageId,t.strUserType=r.strUserType,t.strEncryptedToken=i,n()}}else{if(console.log("test",u.objOpenAPI[t.originalUrl]),console.log("test",t.originalUrl),!u.objOpenAPI[t.originalUrl])return e.status(401).set(r).send(new s.default("AUTHORIZATION_TOKEN_HEADER_IS_MISSING").send().body);n()}}catch(t){return e.status(401).set(r).send(new s.default(t).send().body)}}}]);