private void HmrcBank(MarketPlaceDataModel oModel) { /*if (oModel.HmrcData == null) { * Log.Debug("There is no VAT return data for customer {0}.", m_nCustomerID); * return; * } // if * * var oVat = oModel.HmrcData; * * if (oVat == null) { * Log.Debug("There is no VAT return data for customer {0}.", m_nCustomerID); * return; * } // if * * if ((oVat.VatReturnSummary != null) && (oVat.VatReturnSummary.Length > 0)) { * var oHmrc = oVat.VatReturnSummary[0]; * * DateTime? oFrom = null; * DateTime? oTo = null; * * if ((oHmrc.Quarters != null) && (oHmrc.Quarters.Count > 0)) { * int nIdx = oHmrc.Quarters.Count - 1; * * oTo = oHmrc.Quarters[nIdx].DateTo; * * nIdx -= 3; * if (nIdx < 0) * nIdx = 0; * * oFrom = oHmrc.Quarters[nIdx].DateFrom; * } // if * * * } // if*///todo var ad = new AffordabilityData { Type = AffordabilityType.Hmrc, DateFrom = oModel.OriginationDate, DateTo = oModel.LastTransactionDate, Opex = oModel.TotalNetOutPayments, Revenues = oModel.TotalNetInPayments, ValueAdded = oModel.TotalNetInPayments - oModel.TotalNetOutPayments, Ebitda = oModel.TotalNetInPayments - oModel.TotalNetOutPayments, //todo FreeCashFlow = oModel.TotalNetInPayments - oModel.TotalNetOutPayments, //todo LoanRepayment = LoadLoanRepaymentsForHmrc(), Salaries = 0, //todo Tax = 0, //todo TurnoverTrend = oModel.TurnoverTrend }; ad.FreeCashFlow -= ad.LoanRepayment; MpModel.Affordability.Add(ad); } // HmrcBank
public LocalMp(MarketPlaceDataModel oModel, MP_CustomerMarketPlace mp) { Model = oModel; Marketplace = mp; } // constructor
} // Name public override void Execute() { MpModel = new MpModel { Affordability = new List <AffordabilityData>(), MarketPlaces = new List <MarketPlaceDataModel>(), }; using (this.m_oTimeCounter.AddStep("Total mp and affordability strategy execute time")) { try { using (this.m_oTimeCounter.AddStep("All marketplaces build time")) GetAllModels(); var oPaypal = new List <LocalMp>(); var oEcomm = new List <LocalMp>(); var oAccounting = new List <LocalMp>(); MarketPlaceDataModel oHmrc = null; var oYodlee = new List <LocalMp>(); foreach (LocalMp mm in this.m_oMundMs) { if (mm.Marketplace.Disabled) { continue; } if (mm.Marketplace.Marketplace.InternalId == ms_oCompanyFilesID) { continue; } if (mm.Marketplace.Marketplace.InternalId == ms_oYodleeID) { oYodlee.Add(mm); continue; } // if if (mm.Marketplace.Marketplace.InternalId == ms_oHmrcID) { if (oHmrc == null) { oHmrc = mm.Model; } continue; } // if if (mm.Marketplace.Marketplace.InternalId == ms_oPaypalID) { oPaypal.Add(mm); continue; } // if if (mm.Marketplace.Marketplace.IsPaymentAccount) { oAccounting.Add(mm); } else { oEcomm.Add(mm); } } // for each marketplace if (oHmrc != null) { using (this.m_oTimeCounter.AddStep("HMRC affordability build time")) HmrcBank(oHmrc); } // if if (oYodlee.Any()) { using (this.m_oTimeCounter.AddStep("Yodlee affordability build time")) SaveBankStatement(oYodlee); } // if using (this.m_oTimeCounter.AddStep("PayPal affordability build time")) Psp(oPaypal); using (this.m_oTimeCounter.AddStep("Ecomm affordability build time")) EcommAccounting(oEcomm, AffordabilityType.Ecomm); using (this.m_oTimeCounter.AddStep("Accounting affordability build time")) EcommAccounting(oAccounting, AffordabilityType.Accounting); using (this.m_oTimeCounter.AddStep("Logging affordability time")) { Log.Debug("**************************************************************************"); Log.Debug("*"); Log.Debug("* Affordability data for customer {0} - begin:", this.m_nCustomerID); Log.Debug("*"); Log.Debug("**************************************************************************"); foreach (var a in MpModel.Affordability) { Log.Debug(a); } Log.Debug("**************************************************************************"); Log.Debug("*"); Log.Debug("* Affordability data for customer {0} - end.", this.m_nCustomerID); Log.Debug("*"); Log.Debug("**************************************************************************"); } // using } catch (Exception ex) { Log.Error(ex, "Failed calculation models and affordability for customer {0}", this.m_nCustomerID); } //try } // using total timer Log.Info(this.m_oTimeCounter.ToString()); } // Execute
} // Create public MarketPlaceDataModel CreateLightModel(MP_CustomerMarketPlace mp, DateTime?history) { var lastChecked = mp.UpdatingEnd.HasValue ? FormattingUtils.FormatDateToString(mp.UpdatingEnd.Value) : "never/in progress"; var updatingStatus = mp.GetUpdatingStatus(history); var updatingError = mp.GetUpdatingError(history); DateTime?originationDate; var age = GetAccountAge(mp, out originationDate); var url = GetUrl(mp, mp.GetRetrieveDataHelper().RetrieveCustomerSecurityInfo(mp.Id)); var lastTransactionDate = GetLastTransactionDate(mp); var model = new MarketPlaceDataModel { Id = mp.Id, Type = mp.DisplayName, Name = mp.Marketplace.Name, LastChecked = lastChecked, UpdatingStatus = updatingStatus, UpdateError = updatingError, AccountAge = age, RaitingPercent = 0, SellerInfoStoreURL = url, IsPaymentAccount = mp.Marketplace.IsPaymentAccount, UWPriority = mp.Marketplace.UWPriority, Disabled = mp.Disabled, IsNew = mp.IsNew, IsHistory = history.HasValue, History = history, LastTransactionDate = lastTransactionDate, OriginationDate = originationDate }; var aggregations = mp.Marketplace.GetAggregations(mp, history).ToList(); model.TurnoverTrend = ThisLibrary.Instance.DB.Fill <TurnoverTrend>( "LoadActiveMarketplaceTurnovers", CommandSpecies.StoredProcedure, new QueryParameter("MpID", mp.Id) ) .OrderByDescending(x => x.TheMonth) .Take(12) .ToList(); var monthSales = aggregations.FirstOrDefault(x => x.TimePeriod.TimePeriodType == TimePeriodEnum.Month && x.ParameterName == AggregationFunction.Turnover.ToString() ); model.MonthSales = monthSales == null ? 0 : (decimal)monthSales.Value; var yearSales = aggregations.FirstOrDefault(x => x.TimePeriod.TimePeriodType == TimePeriodEnum.Year && x.ParameterName == AggregationFunction.Turnover.ToString() ); model.AnnualSales = yearSales == null ? 0 : (decimal)yearSales.Value; var feedbacks = GetFeedbackData(aggregations); model.RaitingPercent = feedbacks.RaitingPercent; if (model.IsPaymentAccount) { var paymentModel = GetPaymentAccountModel(mp, history, aggregations); model.TotalNetInPayments = paymentModel.TotalNetInPayments; model.TotalNetOutPayments = paymentModel.TotalNetOutPayments; model.MonthInPayments = paymentModel.MonthInPayments; model.TransactionsNumber = paymentModel.TransactionsNumber; } // if return(model); } // CreateLightModel