public ActionResult RefreshYodlee(string displayName = null) { var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id); var yodleeMain = new YodleeMain(); var oEsi = new YodleeServiceInfo(); var yodlees = this.customer.CustomerMarketPlaces .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId) .ToList(); if (yodlees.Count == 0) { return(View(new { error = "Error loading bank accounts" })); } var lu = yodleeMain.LoginUser(yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); if (lu == null) { return(View(new { error = "Error logging to yodlee account" })); } MP_CustomerMarketPlace umi = displayName == null ? yodlees[0] : yodlees.FirstOrDefault(y => y.DisplayName == displayName); //TODO Currently refreshes the first one if (umi == null) { return(View(new { error = "Account not found" })); } var callback = Url.Action("RecheckYodleeCallback", "YodleeMarketPlaces", new { Area = "Customer" }, "https") + "/" + umi.Id; string finalUrl = yodleeMain.GetEditAccountUrl(Serialized.Deserialize <YodleeSecurityInfo>(umi.SecurityData).ItemId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); return(Redirect(finalUrl)); }
} // CategorizeTransaction private void CategorizeTransaction( MP_YodleeOrderItemBankTransaction oTransaction, List <MP_YodleeGroup> yodleeGroupRepository, List <MP_YodleeGroupRuleMap> yodleeGroupRuleMapRepository, MP_CustomerMarketPlace mp, List <string> directors ) { if (oTransaction.ezbobCategory != null) { return; } try { oTransaction.ezbobCategory = CategorizeTransaction( yodleeGroupRepository, yodleeGroupRuleMapRepository, oTransaction.description, oTransaction.transactionBaseType, (int)(oTransaction.transactionAmount.HasValue ? oTransaction.transactionAmount.Value : 0), mp.Customer.Id, mp.Customer.PersonalInfo.Surname, directors); } catch (Exception e) { _Log.Debug("Yodlee Categorize transaction failed.", e); } // try } // CategorizeTransaction
} // Name public override void Execute() { Log.Debug("Getting a bank model for customer {0}...", m_nCustomerID); Result = null; try { Customer customer = DbHelper.GetCustomerInfo(m_nCustomerID); if (customer == null) { Log.Warn("Could not find a customer by id {0}.", m_nCustomerID); return; } // if MP_CustomerMarketPlace oYodleeMp = customer.CustomerMarketPlaces .FirstOrDefault(mp => mp.Marketplace.InternalId == ms_oYodleeID); if (oYodleeMp == null) { Log.Debug("Customer {0} has no bank accounts.", customer.Stringify()); return; } // if var builder = GetMpModelBuilder(oYodleeMp); var model = builder.Create(oYodleeMp, null); Result = model; Log.Debug("Getting a bank model for customer {0} complete.", customer.Stringify()); } catch (Exception e) { Log.Warn(e, "Something went wrong while building a bank model for customer with id {0}.", m_nCustomerID); } // try } // Execute
public override DateTime?GetSeniority(MP_CustomerMarketPlace mp) { var invoices = _session.Query <MP_FreeAgentInvoice>() .Where(oi => oi.Request.CustomerMarketPlace.Id == mp.Id) .Where(oi => oi.dated_on != null) .Select(oi => oi.dated_on); var expenses = _session.Query <MP_FreeAgentInvoice>() .Where(oi => oi.Request.CustomerMarketPlace.Id == mp.Id) .Where(oi => oi.dated_on != null) .Select(oi => oi.dated_on); DateTime?earliest = null; if (invoices.Any()) { earliest = invoices.Min(); } if (expenses.Any() && expenses.Min() < earliest) { earliest = expenses.Min(); } return(earliest); }
protected override PaymentAccountsModel GetPaymentAccountModel(MP_CustomerMarketPlace mp, DateTime?history, List <IAnalysisDataParameterInfo> av) { var paymentAccountModel = new FreeAgentPaymentAccountsModel(mp, history); paymentAccountModel.Load(av); return(paymentAccountModel); }
public override DateTime?GetLastTransaction(MP_CustomerMarketPlace mp) { DateTime?invoices = null; DateTime?expenses = null; var tmpInvoices = _session.Query <MP_FreeAgentInvoice>() .Where(oi => oi.Request.CustomerMarketPlace.Id == mp.Id) .Where(oi => oi.dated_on != null); if (tmpInvoices.Count() != 0) { invoices = tmpInvoices.Max(oi => oi.dated_on); } var tmpExpenses = _session.Query <MP_FreeAgentInvoice>() .Where(oi => oi.Request.CustomerMarketPlace.Id == mp.Id) .Where(oi => oi.dated_on != null); if (tmpExpenses.Count() != 0) { expenses = tmpExpenses.Max(oi => oi.dated_on); } DateTime?latest = null; if (invoices.HasValue) { latest = invoices; } if ((expenses.HasValue && !latest.HasValue) || (expenses.HasValue && expenses.Value > latest)) { latest = expenses; } return(latest); }
} // SelectOne private DateTime?GetDateFromList(MP_CustomerMarketPlace mp, WhichDateToTake nWhich) { if (null == Configuration.Instance.GetVendorInfo(mp.Marketplace.Name)) { return(null); } DateTime?oResult = null; IQueryable <DateTime> oListOfPaymentDates = _session .Query <MP_ChannelGrabberOrderItem>() .Where(oi => (oi.Order.CustomerMarketPlace.Id == mp.Id) && (oi.PaymentDate != null) ) .Select(oi => oi.PaymentDate); foreach (DateTime oDate in oListOfPaymentDates) { oResult = SelectOne(oResult, oDate, nWhich); } IQueryable <MP_VatReturnRecord> oVatPeriods = _session .Query <MP_VatReturnRecord>() .Where(r => r.CustomerMarketPlace.Id == mp.Id && (r.IsDeleted == null || !r.IsDeleted.Value)); foreach (MP_VatReturnRecord oPeriod in oVatPeriods) { oResult = SelectOne(oResult, oPeriod.DateFrom, nWhich); oResult = SelectOne(oResult, oPeriod.DateTo, nWhich); } // for each return(oResult); } // GetDateFromList
public AskvilleStatus Askville(int?customerMarketPlaceId, string merchantId, string marketplaceId, string askvilleGuid = "") { MP_CustomerMarketPlace marketplace = _customerMarketPlaceRepository.GetAll().FirstOrDefault(x => x.Id == customerMarketPlaceId); if (marketplace == null) { throw new Exception(string.Format("Marketplace {0} does not found", customerMarketPlaceId)); } var securityInfo = (AmazonSecurityInfo)marketplace.GetRetrieveDataHelper().RetrieveCustomerSecurityInfo(marketplace.Id); merchantId = merchantId ?? securityInfo.MerchantId; marketplaceId = marketplaceId ?? securityInfo.MarketplaceId[0]; var guid = askvilleGuid == "" ? Guid.NewGuid().ToString() : askvilleGuid; var acceptUrl = Url.Action("ActivateStore", "Home", new { Area = "", id = guid, approve = true.ToString().ToLower() }, "https"); var disAcceptUrl = Url.Action("ActivateStore", "Home", new { Area = "", id = guid, approve = false.ToString().ToLower() }, "https"); string origin = marketplace.Customer.CustomerOrigin.Name; string phone = marketplace.Customer.CustomerOrigin.PhoneNumber; var message = @" Confirm your store on Amazon. Your Amazon shop has been added on" + origin + @". To confirm store please <a href=""" + acceptUrl + @""">click here</a>" + Environment.NewLine + @"If you have not added the store on " + origin + @" please <a href=""" + disAcceptUrl + @""">click here </a>" + Environment.NewLine + @" Thank you! Kindest regards," + Environment.NewLine + origin + @"team, www." + origin + @".com customercare@" + origin + @".com" + Environment.NewLine + phone; var sendingStatus = _askvilleService.AskQuestion(merchantId, marketplaceId, 31, message); var askville = askvilleGuid == "" ? (new Askville { Guid = guid, IsPassed = false, MarketPlace = marketplace, SendStatus = sendingStatus, MessageBody = message, CreationDate = DateTime.UtcNow }) : _askvilleRepository.GetAskvilleByGuid(askvilleGuid); askville.Status = askvilleGuid == "" ? AskvilleStatus.NotPerformed : AskvilleStatus.ReCheck; _askvilleRepository.SaveOrUpdate(askville); Utils.WriteLog("Send askville message", sendingStatus.ToString(), ExperianServiceType.Askville, marketplace.Customer.Id); return(askville.Status); }
} // GetFeedbackDAta private List <string> GetAmazonCategories(MP_CustomerMarketPlace marketplace) { return(_session.Query <MP_AmazonOrderItemDetailCatgory>() .Where(x => x.OrderItemDetail.OrderItem.Order.CustomerMarketPlace.Id == marketplace.Id) .Select(x => x.Category.Name) .Distinct() .ToList()); } // GetAmazonCategories
public static FreeAgentAccountModel ToModel(MP_CustomerMarketPlace account) { return(new FreeAgentAccountModel { id = account.Id, displayName = account.DisplayName }); } // ToModel
} // GetSeniority public virtual string GetUrl(MP_CustomerMarketPlace mp, IMarketPlaceSecurityInfo securityInfo) { return(string.Format( "https://www.google.com/search?q={0}+{1}", HttpUtility.UrlEncode(mp.Marketplace.Name), mp.DisplayName )); } // GetUrl
} // GetLastTransactionDate protected virtual PaymentAccountsModel GetPaymentAccountModel( MP_CustomerMarketPlace mp, DateTime?history, List <IAnalysisDataParameterInfo> av ) { return(null); } // GetPaymentAccountModel
} // GetUrl public override DateTime? GetSeniority(MP_CustomerMarketPlace mp) { List<DateTime> filesDate = this.companyFilesRepo.GetByCustomerId(mp.Customer.Id).Select(x => x.Created).ToList(); if (filesDate.Any()) return filesDate.Min(); return null; } // GetSeniority
public override DateTime?GetSeniority(MP_CustomerMarketPlace mp) { var s = _session.Query <MP_YodleeOrderItemBankTransaction>() .Where(t => t.YodleeOrderItem.Order.CustomerMarketPlace == mp) .Where(t => t.postDate.HasValue || t.transactionDate.HasValue) .Select(oi => oi.postDate ?? oi.transactionDate); return(!s.Any() ? null : s.Min()); }
public override DateTime?GetSeniority(MP_CustomerMarketPlace mp) { var s = _session.Query <MP_EkmOrderItem>() .Where(oi => oi.Order.CustomerMarketPlace.Id == mp.Id) .Where(oi => oi.OrderDate != null) .Select(oi => oi.OrderDate); return(s.Any() ? s.Min() : (DateTime?)null); }
public override DateTime?GetSeniority(MP_CustomerMarketPlace mp) { var s = _session.Query <MP_PayPointOrderItem>() .Where(oi => oi.Order.CustomerMarketPlace.Id == mp.Id) .Where(oi => oi.date != null) .Select(oi => oi.date); return(!s.Any() ? null : s.Min()); }
public MP_PayPalTransaction SavePayPalTransactionInfo(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, List <PayPalTransactionItem> data, MP_CustomerMarketplaceUpdatingHistory historyRecord, MP_PayPalTransaction mpTransaction) { MP_CustomerMarketPlace customerMarketPlace = GetCustomerMarketPlace(databaseCustomerMarketPlace.Id); if (data == null) { return(mpTransaction); } if (mpTransaction == null) { mpTransaction = new MP_PayPalTransaction { CustomerMarketPlace = customerMarketPlace, Created = DateTime.UtcNow, HistoryRecord = historyRecord }; } if (data.Count != 0) { foreach (var dataItem in data) { var mpTransactionItem = new MP_PayPalTransactionItem2 { Transaction = mpTransaction, Created = dataItem.Created, Currency = _CurrencyRateRepository.GetCurrencyOrCreate("GBP"), FeeAmount = _CurrencyConvertor.ConvertToBaseCurrency( dataItem.FeeAmount ?? new AmountInfo { CurrencyCode = "GBP", Value = 0 }, dataItem.Created).Value, GrossAmount = _CurrencyConvertor.ConvertToBaseCurrency( dataItem.GrossAmount ?? new AmountInfo { CurrencyCode = "GBP", Value = 0 }, dataItem.Created).Value, NetAmount = _CurrencyConvertor.ConvertToBaseCurrency( dataItem.NetAmount ?? new AmountInfo { CurrencyCode = "GBP", Value = 0 }, dataItem.Created).Value, TimeZone = dataItem.Timezone, Status = dataItem.Status, Type = dataItem.Type, PayPalTransactionId = dataItem.TransactionId }; mpTransaction.TransactionItems.Add(mpTransactionItem); } } customerMarketPlace.PayPalTransactions.Add(mpTransaction); _CustomerMarketplaceRepository.Update(customerMarketPlace); return(mpTransaction); }
public PaymentAccountsModel(MP_CustomerMarketPlace mp, DateTime?history) { if (mp != null) { displayName = mp.DisplayName; id = mp.Id; IsNew = mp.IsNew; Status = mp.GetUpdatingStatus(history); } } // constructor
public static PayPointAccountModel ToModel(MP_CustomerMarketPlace account) { var payPointSecurityInfo = Serialized.Deserialize<PayPointSecurityInfo>(account.SecurityData); return new PayPointAccountModel { id = payPointSecurityInfo.MarketplaceId, mid = payPointSecurityInfo.Mid, vpnPassword = payPointSecurityInfo.VpnPassword, remotePassword = payPointSecurityInfo.RemotePassword }; } // ToModel
protected override PaymentAccountsModel GetPaymentAccountModel(MP_CustomerMarketPlace mp, DateTime?history, List <IAnalysisDataParameterInfo> av) { var status = mp.GetUpdatingStatus(history); var yodleeModel = new YodleePaymentAccountsModel(mp, history); yodleeModel.Load(av); return(yodleeModel); }
public override DateTime?GetLastTransaction(MP_CustomerMarketPlace mp) { var s = _session.Query <MP_EkmOrderItem>().Where(oi => oi.Order.CustomerMarketPlace.Id == mp.Id).Where(oi => oi.OrderDate != null); if (s.Count() != 0) { return(s.Max(oi => oi.OrderDate)); } return(null); }
protected override void InitializeSpecificData( MP_CustomerMarketPlace mp, MarketPlaceModel model, DateTime? history ) { var ebayFeedBack = mp.EbayFeedback.LastOrDefault(); model.Categories = GetEbayCategories(mp); model.EBay = BuildEBay(mp.EbayUserData.LastOrDefault(), mp.EbayUserAccountData.LastOrDefault(), ebayFeedBack); } // InitializeSpecificData
public override DateTime?GetLastTransaction(MP_CustomerMarketPlace mp) { var transactionItems = _session.Query <MP_PayPalTransaction>().Where(t => t.CustomerMarketPlace.Id == mp.Id).SelectMany(x => x.TransactionItems); if (transactionItems.Count() != 0) { return(transactionItems.Max(x => x.Created)); } return(null); }
public override DateTime?GetSeniority(MP_CustomerMarketPlace mp) { var payPalTransactions = _session.Query <MP_PayPalTransaction>() .Where(t => t.CustomerMarketPlace.Id == mp.Id) .SelectMany(x => x.TransactionItems); var transactionsMinDate = payPalTransactions.Any() ? payPalTransactions.Min(f => f.Created) : (DateTime?)null; return(transactionsMinDate); }
} // ToModel public static YodleeAccountModel ToModel(MP_CustomerMarketPlace marketplace, YodleeBanksRepository yodleeBanksRepository = null) { var securityInfo = Serialized.Deserialize <YodleeSecurityInfo>(marketplace.SecurityData); var yodleeBank = yodleeBanksRepository != null?yodleeBanksRepository.Search(securityInfo.CsId) : null; return(new YodleeAccountModel { bankId = yodleeBank != null ? yodleeBank.Id : 0, displayName = yodleeBank != null ? yodleeBank.Name : "Uploaded bank" }); } // ToModel
public void StoreEbayUserAccountData(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, IDatabaseEbayAccountInfo data, MP_CustomerMarketplaceUpdatingHistory historyRecord) { if (data == null) { WriteToLog("StoreEbayUserData: invalid data to store", WriteLogType.Error); return; } MP_CustomerMarketPlace customerMarketPlace = GetCustomerMarketPlace(databaseCustomerMarketPlace.Id); try { var accountData = new MP_EbayUserAccountData { CustomerMarketPlace = customerMarketPlace, Created = data.SubmittedDate.ToUniversalTime(), Currency = data.Currency, Id = 0, PaymentMethod = data.PaymentMethod, AccountId = data.AccountId, AccountState = data.AccountState, AmountPastDueValue = data.AmountPastDueValue, BankAccountInfo = data.BankAccountInfo, BankModifyDate = data.BankModifyDate, CreditCardExpiration = data.CreditCardExpiration, CreditCardInfo = data.CreditCardInfo, CreditCardModifyDate = data.CreditCardModifyDate, CurrentBalance = data.CurrentBalance, PastDue = data.PastDue, HistoryRecord = historyRecord }; if (data.AdditionalAccount != null && data.AdditionalAccount.Length > 0) { data.AdditionalAccount.ForEach( a => accountData.EbayUserAdditionalAccountData.Add( new MP_EbayUserAdditionalAccountData { Currency = a.Currency, AccountCode = a.AccountCode, Balance = a.Balance.Value, EbayUserAccountData = accountData })); } customerMarketPlace.EbayUserAccountData.Add(accountData); _CustomerMarketplaceRepository.Update(customerMarketPlace); } catch (Exception ex) { WriteToLog("StoreEbayUserData: failed to store data", WriteLogType.Error, ex); } }
} // GetAllModels private MarketPlaceDataModel GetDefaultModel(MP_CustomerMarketPlace mp) { return(new MarketPlaceDataModel { Id = mp.Id, Type = mp.DisplayName, Name = mp.Marketplace.Name, IsPaymentAccount = mp.Marketplace.IsPaymentAccount, Disabled = mp.Disabled, History = null, }); } // GetDefaultModel
} // GetFeedbackData public string GetAccountAge(MP_CustomerMarketPlace mp, out DateTime?originationDate) { originationDate = UpdateOriginationDate(mp); return (originationDate == null ? "-" : Convert.ToString( Math.Round((DateTime.UtcNow - originationDate).Value.TotalDays / 30.0, 1), CultureInfo.InvariantCulture )); } // GetAccountAge
protected override void InitializeSpecificData(MP_CustomerMarketPlace mp, MarketPlaceModel model, DateTime?history) { if (_yodleeModel == null) { try { _yodleeModel = BuildYodlee(mp, history); } catch (Exception ex) { Log.Warn(ex, "Build Yodlee Model Failed."); } } model.Yodlee = _yodleeModel; }
public void StoreEbayFeedbackData(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, DatabaseEbayFeedbackData data, MP_CustomerMarketplaceUpdatingHistory historyRecord) { if (data == null) { WriteToLog("StoreEbayUserData: invalid data to store", WriteLogType.Error); return; } MP_CustomerMarketPlace customerMarketPlace = GetCustomerMarketPlace(databaseCustomerMarketPlace.Id); var feedBack = new MP_EbayFeedback { CustomerMarketPlace = customerMarketPlace, Created = data.Submitted, RepeatBuyerCount = data.RepeatBuyerCount, RepeatBuyerPercent = data.RepeatBuyerPercent, TransactionPercent = data.TransactionPercent, UniqueBuyerCount = data.UniqueBuyerCount, UniqueNegativeCount = data.UniqueNegativeCount, UniqueNeutralCount = data.UniqueNeutralCount, UniquePositiveCount = data.UniquePositiveCount, HistoryRecord = historyRecord }; if (data.FeedbackByPeriod != null && data.FeedbackByPeriod.Count > 0) { feedBack.FeedbackByPeriodItems.AddAll(data.FeedbackByPeriod.Values.Select(f => new MP_EbayFeedbackItem { EbayFeedback = feedBack, Negative = f.Negative, Positive = f.Positive, Neutral = f.Neutral, TimePeriod = GetTimePeriod(TimePeriodFactory.Create(f.TimePeriod)) }).ToList()); } if (data.RaitingByPeriod != null && data.RaitingByPeriod.Count > 0) { feedBack.RaitingByPeriodItems.AddAll(data.RaitingByPeriod.Values.Select(r => new MP_EbayRaitingItem { EbayFeedback = feedBack, Communication = r.Communication, ItemAsDescribed = r.ItemAsDescribed, ShippingAndHandlingCharges = r.ShippingAndHandlingCharges, ShippingTime = r.ShippingTime, TimePeriod = GetTimePeriod(TimePeriodFactory.Create(r.TimePeriod)) }).ToList()); } customerMarketPlace.EbayFeedback.Add(feedBack); _CustomerMarketplaceRepository.Update(customerMarketPlace); }