angular.module('kalgudiApp.basicApp').factory('basicAppfullblownFactory', ["$q", "$rootScope", "basicAppMessageService", "myconnectsdataFactory", "mybusinessdataFactory", "mycontentService", function ($q, $rootScope, basicAppMessageService, myconnectsdataFactory, mybusinessdataFactory, mycontentService) { var basicAppfullblownFactoryObject = {}; basicAppfullblownFactoryObject.processingfullblown = function (message_to_process) { // to get names and business names if (message_to_process.brokerBizId != "" && message_to_process.brokerBizId != undefined) { if (message_to_process.isBrokerThirdPartyUser == 0) { //message_to_process.brokerBusinessName = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.brokerBizId); message_to_process.brokerBusinessName = { firstName: message_to_process.brokerFirstName || '', businessName: message_to_process.brokerBusinessName || '', businessId: message_to_process.brokerBizId || '' } } else { message_to_process.brokerBusinessName = { firstName: message_to_process.brokerFirstName || '', businessName: message_to_process.brokerBusinessName || '', businessId: message_to_process.brokerBizId || '' } /*message_to_process.brokerBusinessName = mybusinessdataFactory.getAllconnectsListWithBizId(message_to_process.brokerBizId); if(message_to_process.brokerBusinessName == undefined){ message_to_process.brokerBusinessName = {}; message_to_process.brokerBusinessName.firstName = message_to_process.brokerName; message_to_process.brokerBusinessName.businessName = message_to_process.brokerBusinessName; }*/ } } if (message_to_process.transactionType.toLowerCase() == "sale") { if (message_to_process.isBuyerThirdPartyUser == 0) { //message_to_process.buyerBusinessName = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.buyerBizId); message_to_process.buyerBusinessName = { firstName: message_to_process.buyerFirstName || '', businessName: message_to_process.buyerBusinessName || '', businessId: message_to_process.buyerBizId } } else { var buyerBusinessName = mybusinessdataFactory.getAllconnectsListWithBizId(message_to_process.buyerBizId); if (buyerBusinessName == undefined) { message_to_process.buyerBusinessName = {}; message_to_process.buyerBusinessName.firstName = message_to_process.partnerName; message_to_process.buyerBusinessName.businessName = message_to_process.partnerBusinessName; } else { message_to_process.buyerBusinessName = angular.copy(buyerBusinessName); } if (message_to_process.buyerBusinessName.firstName == "Cash") { message_to_process.buyerBusinessName.firstName = message_to_process.cashFirstName; } } message_to_process.sellerBusinessName = $rootScope.loggedInUserCurrentBussinessInfo; message_to_process.sellerBusinessName.firstName = $rootScope.loggedInUserBusinessProfile.firstName; } else if (message_to_process.transactionType.toLowerCase() == "purchase") { if (message_to_process.isSellerThirdPartyUser == 0) { //message_to_process.sellerBusinessName = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.sellerBizId); message_to_process.sellerBusinessName = { firstName: message_to_process.sellerFirstName || '', businessName: message_to_process.businessName || '', businessId: message_to_process.sellerBizId || '' } } else { var sellerBusinessName = mybusinessdataFactory.getAllconnectsListWithBizId(message_to_process.sellerBizId); if (sellerBusinessName == undefined) { message_to_process.sellerBusinessName = {}; message_to_process.sellerBusinessName.firstName = message_to_process.partnerName; message_to_process.sellerBusinessName.businessName = message_to_process.partnerBusinessName; } else { message_to_process.sellerBusinessName = angular.copy(sellerBusinessName); } if (message_to_process.sellerBusinessName.firstName == "Cash") { message_to_process.sellerBusinessName.firstName = message_to_process.cashFirstName; } } message_to_process.buyerBusinessName = $rootScope.loggedInUserCurrentBussinessInfo; message_to_process.buyerBusinessName.firstName = $rootScope.loggedInUserBusinessProfile.firstName; } else if (message_to_process.transactionType.toLowerCase() == "farmerpurchase") { if (message_to_process.isFarmerThirdPartyUser == 0) { //message_to_process.sellerBusinessName = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.farmerBizId); message_to_process.sellerBusinessName = { firstName: message_to_process.farmerFirstName, businessName: message_to_process.farmerBusinessName || '', businessId: message_to_process.farmerBizId } } else { message_to_process.sellerBusinessName = mybusinessdataFactory.getAllconnectsListWithBizId(message_to_process.farmerBizId); if (message_to_process.sellerBusinessName == undefined) { message_to_process.sellerBusinessName = {}; message_to_process.sellerBusinessName.firstName = message_to_process.partnerName; message_to_process.sellerBusinessName.businessName = message_to_process.partnerBusinessName; } } message_to_process.buyerBusinessName = $rootScope.loggedInUserCurrentBussinessInfo; message_to_process.buyerBusinessName.firstName = $rootScope.loggedInUserBusinessProfile.firstName; } if (message_to_process.isIncoming == 1) { //message_to_process.BusinessCreatedBy = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.createdBy); message_to_process.BusinessCreatedBy = { firstName: message_to_process.createdByFirstName || '', businessName: message_to_process.createdByBizName || '', businessId: message_to_process.createdBy || '', profilePicURL: message_to_process.profilePicURL || '' } } else { message_to_process.BusinessCreatedBy = $rootScope.loggedInUserCurrentBussinessInfo; message_to_process.BusinessCreatedBy.firstName = $rootScope.loggedInUserBusinessProfile.firstName; if ($rootScope.loggedInUserBusinessProfile.profilePicUrl != undefined) { message_to_process.BusinessCreatedBy.profilePicURL = $rootScope.loggedInUserBusinessProfile.profilePicUrl; } } for (var index in message_to_process.commentList) { var commentedName = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.commentList[index].modifiedBy); if (commentedName == undefined) { commentedName = mybusinessdataFactory.getAllconnectsListWithBizId(message_to_process.commentList[index].modifiedBy); } if (commentedName.profilePicUrl != undefined) { message_to_process.commentList[index].profilePicUrl = commentedName.profilePicUrl; } } //litearls processing var literal_template = ''; if (message_to_process.transactionType.toLowerCase() == 'sale') { if (message_to_process.isIncoming == 0) { //created by us if (message_to_process.brokerBizId != '') { //sale with broker if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0609; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0610; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: message_to_process.buyerBusinessName.firstName, biz_dyn: message_to_process.buyerBusinessName.businessName, caname_dyn: message_to_process.brokerBusinessName.firstName, caibzname_dyn: message_to_process.brokerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn|caname_dyn|caibzname_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { //sale without broker if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0605; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0606; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: message_to_process.buyerBusinessName.firstName, biz_dyn: message_to_process.buyerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } else if (message_to_process.isIncoming == 1) { if (message_to_process.partnerBusinessTypeId == "BT000009") { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0684; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0685; } var literalstr = literal_template; var mapObj = { product_dyn: message_to_process.productList[0].productName, biz_dyn: message_to_process.sellerFirstName, biztype_dyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|biz_dyn|biztype_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { if (message_to_process.brokerBizId == message_to_process.createdBy) { if (message_to_process.hasOwnProperty('partnerBusinessTypeId') && message_to_process.partnerBusinessTypeId == "BT000013") { if (message_to_process.hasOwnProperty('type') && message_to_process.type == 'SERVICES') { if (message_to_process.totalTxAmount != '' && message_to_process.totalTxAmount != 0) { var literalstr = $rootScope.loginpinliteral.KL_TR_0686; var mapObj = { currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), buyer_dyn: message_to_process.buyerBusinessName.firstName, buyer_biznamedyn: message_to_process.buyerBusinessName.businessName, seller_dyn: message_to_process.sellerBusinessName.firstName, seller_biznamedyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/currency_dyn|amt_dyn|buyer_dyn|buyer_biznamedyn|seller_dyn|seller_biznamedyn/gi, function (matched) { return mapObj[matched]; }); } else { var literalstr = $rootScope.loginpinliteral.KL_TR_0687; var mapObj = { buyer_dyn: message_to_process.buyerBusinessName.firstName, buyer_biznamedyn: message_to_process.buyerBusinessName.businessName, seller_dyn: message_to_process.sellerBusinessName.firstName, seller_biznamedyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/buyer_dyn|buyer_biznamedyn|seller_dyn|seller_biznamedyn/gi, function (matched) { return mapObj[matched]; }); } } else if (message_to_process.hasOwnProperty('type') && message_to_process.type == 'DIGITAL') { var literalstr = $rootScope.loginpinliteral.KL_TR_0688; var mapObj = { currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), buyer_dyn: message_to_process.buyerBusinessName.firstName, buyer_biznamedyn: message_to_process.buyerBusinessName.businessName }; literalstr = literalstr.replace(/currency_dyn|amt_dyn|buyer_dyn|buyer_biznamedyn/gi, function (matched) { return mapObj[matched]; }); } else { if (message_to_process.totalTxAmount != '' && message_to_process.totalTxAmount != 0) { var literalstr = $rootScope.loginpinliteral.KL_TR_0689; var mapObj = { currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), buyer_dyn: message_to_process.buyerBusinessName.firstName, buyer_biznamedyn: message_to_process.buyerBusinessName.businessName, seller_dyn: message_to_process.sellerBusinessName.firstName, seller_biznamedyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/currency_dyn|amt_dyn|buyer_dyn|buyer_biznamedyn|seller_dyn|seller_biznamedyn/gi, function (matched) { return mapObj[matched]; }); } else { var literalstr = $rootScope.loginpinliteral.KL_TR_0690; var mapObj = { buyer_dyn: message_to_process.buyerBusinessName.firstName, buyer_biznamedyn: message_to_process.buyerBusinessName.businessName, seller_dyn: message_to_process.sellerBusinessName.firstName, seller_biznamedyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/buyer_dyn|buyer_biznamedyn|seller_dyn|seller_biznamedyn/gi, function (matched) { return mapObj[matched]; }); } } message_to_process.Businesstemplates = literalstr; } else { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0613; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0614; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: $rootScope.loggedInUserBusinessProfile.firstName, biz_dyn: $rootScope.loggedInUserBusinessProfile.lstOfUserBusinessDetailsInfo[0].businessName, buyer_dyn: message_to_process.buyerBusinessName.firstName, buyer_biznamedyn: message_to_process.buyerBusinessName.businessName, seller_dyn: message_to_process.sellerBusinessName.firstName, seller_biznamedyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn|buyer_dyn|buyer_biznamedyn|seller_dyn|seller_biznamedyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } else { //created by opposition if (message_to_process.brokerBizId != '') { //sale with broker internally it is purchase if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0611; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0612; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: $rootScope.loggedInUserBusinessProfile.firstName, biz_dyn: $rootScope.loggedInUserBusinessProfile.lstOfUserBusinessDetailsInfo[0].businessName, caname_dyn: message_to_process.brokerBusinessName.firstName, caibzname_dyn: message_to_process.brokerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn|caname_dyn|caibzname_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { //sale without broker if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0607; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0608; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: $rootScope.loggedInUserBusinessProfile.firstName, biz_dyn: $rootScope.loggedInUserBusinessProfile.lstOfUserBusinessDetailsInfo[0].businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } } } } else if (message_to_process.transactionType.toLowerCase() == 'purchase' || message_to_process.transactionType.toLowerCase() == 'farmerpurchase') { if (message_to_process.isIncoming == 0) { //created by us if (message_to_process.brokerBizId != undefined && message_to_process.brokerBizId != '') { //purchase with broker if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0611; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0612; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: message_to_process.sellerBusinessName.firstName, biz_dyn: message_to_process.sellerBusinessName.businessName, caname_dyn: message_to_process.brokerBusinessName.firstName, caibzname_dyn: message_to_process.brokerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn|caname_dyn|caibzname_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { //purchase without broker if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0607; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0608; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: message_to_process.sellerBusinessName.firstName, biz_dyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } else if (message_to_process.isIncoming == 1) { if (message_to_process.partnerBusinessTypeId == "BT000009") { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0682; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0683; } var literalstr = literal_template; var mapObj = { product_dyn: message_to_process.productList[0].productName, biz_dyn: message_to_process.buyerFirstName, biztype_dyn: message_to_process.buyerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|biz_dyn|biztype_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { if (message_to_process.brokerBizId == message_to_process.createdBy) { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0613; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0614; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: $rootScope.loggedInUserBusinessProfile.firstName, biz_dyn: $rootScope.loggedInUserBusinessProfile.lstOfUserBusinessDetailsInfo[0].businessName, buyer_dyn: message_to_process.buyerBusinessName.firstName, buyer_biznamedyn: message_to_process.buyerBusinessName.businessName, seller_dyn: message_to_process.sellerBusinessName.firstName, seller_biznamedyn: message_to_process.sellerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn|buyer_dyn|buyer_biznamedyn|seller_dyn|seller_biznamedyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { //created by opposition if (message_to_process.brokerBizId != '') { //purchase with broker if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0609; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0610; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: $rootScope.loggedInUserBusinessProfile.firstName, biz_dyn: $rootScope.loggedInUserBusinessProfile.lstOfUserBusinessDetailsInfo[0].businessName, caname_dyn: message_to_process.brokerBusinessName.firstName, caibzname_dyn: message_to_process.brokerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn|caname_dyn|caibzname_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { //purchase without broker if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0605; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0606; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: $rootScope.loggedInUserBusinessProfile.firstName, biz_dyn: $rootScope.loggedInUserBusinessProfile.lstOfUserBusinessDetailsInfo[0].businessName, }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } } } } else if (message_to_process.transactionType.toLowerCase() == 'inward' || message_to_process.transactionType.toLowerCase() == 'outward') { var customerBusinessData = ""; customerBusinessData = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.customerBizId); message_to_process.customerBusinessName = { firstName: customerBusinessData.firstName, businessName: customerBusinessData.businessName, businessId: customerBusinessData.businessId }; if (message_to_process.partnerBusinessTypeId == "BT000007") { if (message_to_process.transactionType.toLowerCase() == 'inward') { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0676; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0677; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: message_to_process.customerBusinessName.firstName, biz_dyn: message_to_process.customerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else if (message_to_process.transactionType.toLowerCase() == 'outward') { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0674; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0675; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, name_dyn: message_to_process.customerBusinessName.firstName, biz_dyn: message_to_process.customerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } else { if (message_to_process.transactionType.toLowerCase() == 'inward') { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0654; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0655; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: message_to_process.customerBusinessName.firstName, biz_dyn: message_to_process.customerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else if (message_to_process.transactionType.toLowerCase() == 'outward') { if (message_to_process.godowncharges.godownCharges != 0) { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0650; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0651; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), name_dyn: message_to_process.customerBusinessName.firstName, biz_dyn: message_to_process.customerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|currency_dyn|amt_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else if (message_to_process.godowncharges.godownCharges == 0) { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0652; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0653; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, name_dyn: message_to_process.customerBusinessName.firstName, biz_dyn: message_to_process.customerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } } } else if (message_to_process.transactionType.toLowerCase() == "transportation") { var consigneeBusinessName = {}; consignerBusinessName = {}; if (message_to_process.consigneeBizId != "") { if (message_to_process.isConsigneeThirdPartyUser == 0) { consigneeBusinessName = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.consigneeBizId); message_to_process.consigneeBusinessName = { firstName: consigneeBusinessName.firstName, businessName: consigneeBusinessName.businessName, businessId: consigneeBusinessName.businessId }; } else { consigneeBusinessName = mybusinessdataFactory.getAllconnectsListWithBizId(message_to_process.consigneeBizId); message_to_process.consigneeBusinessName = { firstName: consigneeBusinessName.firstName, businessName: consigneeBusinessName.businessName, businessId: consigneeBusinessName.businessId }; } } if (message_to_process.consignerBizId != "") { if (message_to_process.isConsignerThirdPartyUser == 0) { //consignerBusinessName = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.consignerBizId); message_to_process.consignerBusinessName = { firstName: message_to_process.consignerFirstName || '', businessName: message_to_process.consignerbusinessName || '', businessId: message_to_process.consignerBizId || '' }; } else { //consignerBusinessName = mybusinessdataFactory.getAllconnectsListWithBizId(message_to_process.consignerBizId); message_to_process.consignerBusinessName = { firstName: message_to_process.consignerFirstName || '', businessName: message_to_process.consignerbusinessName || '', businessId: message_to_process.consignerBizId || '' }; } } var literal_template = $rootScope.loginpinliteral.KL_TR_0636; var literalstr = literal_template; var mapObj = { //product_dyn:Object.keys(message_to_process.productList).length, currency_dyn: message_to_process.currencyList[0].currencyCode, amt_dyn: message_to_process.totalTxAmount.toFixed(2), consignee_dyn: consigneeBusinessName.firstName, consigneebiz_dyn: consigneeBusinessName.businessName, consigner_dyn: consignerBusinessName.firstName, consignerbiz_dyn: consignerBusinessName.businessName }; literalstr = literalstr.replace(/currency_dyn|amt_dyn|consignee_dyn|consigneebiz_dyn|consigner_dyn|consignerbiz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else if (message_to_process.transactionType.toLowerCase() == 'processing') { var customerBusinessData = ""; customerBusinessData = myconnectsdataFactory.getConnetcs_VisitorsProfile(message_to_process.customerBizId); message_to_process.customerBusinessName = { firstName: customerBusinessData.firstName, businessName: customerBusinessData.businessName, businessId: customerBusinessData.businessId }; if (message_to_process.serviceType != undefined && message_to_process.serviceType.toLowerCase() == 'own') { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0680; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0681; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, }; literalstr = literalstr.replace(/product_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } else { if (Object.keys(message_to_process.productList).length == 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0678; } else if (Object.keys(message_to_process.productList).length > 1) { literal_template = $rootScope.loginpinliteral.KL_TR_0679; } var literalstr = literal_template; var mapObj = { product_dyn: Object.keys(message_to_process.productList).length, name_dyn: message_to_process.customerBusinessName.firstName, biz_dyn: message_to_process.customerBusinessName.businessName }; literalstr = literalstr.replace(/product_dyn|name_dyn|biz_dyn/gi, function (matched) { return mapObj[matched]; }); message_to_process.Businesstemplates = literalstr; } } //end if (message_to_process.isPostBuy === 1) { message_to_process.Businesstemplates = message_to_process.Businesstemplates.replace("product", "service") } return message_to_process; } basicAppfullblownFactoryObject.getFullViewMessages = function (request) { var deferred = $q.defer(); var fullviewids = []; fullviewids.push(request.keypattern_id); var fullviewrequest = { "module": "traderapp", "keys": fullviewids } mycontentService.getSYNC_fullBatchcall(fullviewrequest).then(function (resultfullblow) { var tempBusinessFullViews = {}; for (index in resultfullblow) { var parsedobject = JSON.parse(resultfullblow[index]); tempBusinessFullViews[index] = parsedobject; } deferred.resolve(basicAppfullblownFactoryObject.processingfullblown(tempBusinessFullViews[request.keypattern_id])); }); return deferred.promise; } return basicAppfullblownFactoryObject; }]);