示例#1
0
        }         // ExtractValue

        private void EcommAccounting(List <LocalMp> oModels, AffordabilityType nType)
        {
            if ((oModels == null) || (oModels.Count < 1))
            {
                return;
            }

            bool bWasAnnualized = false;
            var  oErrorMsgs     = new List <string>();

            decimal nRevenue = 0;
            int     nCount   = 0;

            foreach (var mm in oModels)
            {
                nCount++;
                var mp     = mm.Marketplace;
                var oModel = mm.Model;

                if (!string.IsNullOrWhiteSpace(mp.UpdateError))
                {
                    oErrorMsgs.Add(mp.UpdateError.Trim());
                }

                nRevenue += oModel.AnnualSales;
            }             // for each account

            var trend = oModels
                        .SelectMany(x => x.Model.TurnoverTrend)
                        .GroupBy(x => x.TheMonth)
                        .Select(t => new TurnoverTrend {
                TheMonth = t.Key,
                Turnover = t.Sum(s => s.Turnover)
            })
                        .ToList();

            if (nCount > 0)
            {
                var oRes = new AffordabilityData {
                    Type          = nType,
                    Revenues      = nRevenue,
                    IsAnnualized  = bWasAnnualized,
                    ErrorMsgs     = string.Join(" ", oErrorMsgs).Trim(),
                    TurnoverTrend = trend
                };

                oRes.Fill();
                oRes.DateFrom = oModels.Any(x => x.Model.OriginationDate.HasValue)
                                        ? oModels.Min(x => x.Model.OriginationDate)
                                        : null;
                oRes.DateTo = oModels.Any(x => x.Model.LastTransactionDate.HasValue)
                                        ? oModels.Max(x => x.Model.LastTransactionDate)
                                        : null;
                MpModel.Affordability.Add(oRes);
            }     // if
        }         // EcommAccounting
示例#2
0
        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
示例#3
0
        }         // HmrcBank

        private void Psp(List <LocalMp> oPayPals)
        {
            if ((oPayPals == null) || (oPayPals.Count < 1))
            {
                return;
            }

            bool bWasAnnualized = false;
            var  oErrorMsgs     = new List <string>();

            decimal nRevenue = 0;
            decimal nOpex    = 0;

            foreach (var mm in oPayPals)
            {
                var mp     = mm.Marketplace;
                var oModel = mm.Model;

                if (!string.IsNullOrWhiteSpace(mp.UpdateError))
                {
                    oErrorMsgs.Add(mp.UpdateError.Trim());
                }

                nRevenue += oModel.TotalNetInPayments;
                nOpex    += Math.Abs(oModel.TotalNetOutPayments);
            }             // for each account

            var trend = oPayPals
                        .SelectMany(x => x.Model.TurnoverTrend)
                        .GroupBy(x => x.TheMonth)
                        .Select(t => new TurnoverTrend {
                TheMonth = t.Key,
                Turnover = t.Sum(s => s.Turnover)
            }).ToList();

            var oRes = new AffordabilityData {
                Type          = AffordabilityType.Psp,
                Revenues      = nRevenue,
                Opex          = nOpex,
                IsAnnualized  = bWasAnnualized,
                ErrorMsgs     = string.Join(" ", oErrorMsgs).Trim(),
                TurnoverTrend = trend
            };

            oRes.Fill();
            oRes.DateFrom = oPayPals.Any(x => x.Model.OriginationDate.HasValue)
                                ? oPayPals.Min(x => x.Model.OriginationDate)
                                : null;
            oRes.DateTo = oPayPals.Any(x => x.Model.LastTransactionDate.HasValue)
                                ? oPayPals.Max(x => x.Model.LastTransactionDate)
                                : null;
            MpModel.Affordability.Add(oRes);
        }         // Psp
示例#4
0
        }         // EcommAccounting

        private void SaveBankStatement(List <LocalMp> yodlees)
        {
            var affordability = new AffordabilityData {
                Type          = AffordabilityType.Bank,
                Ebitda        = 0,
                FreeCashFlow  = 0,
                LoanRepayment = 0,
                Opex          = 0,
                Revenues      = 0,
                Salaries      = 0,
                Tax           = 0,
                ValueAdded    = 0,
            };

            foreach (var yodlee in yodlees)
            {
                if (yodlee.Model != null)
                {
                    affordability.DateFrom       = affordability.DateFrom ?? yodlee.Model.OriginationDate;
                    affordability.DateTo         = affordability.DateTo ?? yodlee.Model.LastTransactionDate;
                    affordability.Opex          += yodlee.Model.TotalNetOutPayments;
                    affordability.Revenues      += yodlee.Model.TotalNetInPayments;
                    affordability.ValueAdded    += (yodlee.Model.TotalNetInPayments - yodlee.Model.TotalNetOutPayments); //todo fix
                    affordability.FreeCashFlow  += (yodlee.Model.TotalNetInPayments - yodlee.Model.TotalNetOutPayments); //todo fix
                    affordability.Ebitda        += (yodlee.Model.TotalNetInPayments - yodlee.Model.TotalNetOutPayments); //todo fix
                    affordability.IsAnnualized   = false;
                    affordability.LoanRepayment += 0;                                                                    // todo fix
                    affordability.Salaries      += 0;                                                                    //todo fix
                    affordability.Tax           += 0;                                                                    //todo fix
                }                                                                                                        // if
            }                                                                                                            // for each

            affordability.TurnoverTrend = yodlees
                                          .SelectMany(x => x.Model.TurnoverTrend)
                                          .GroupBy(x => x.TheMonth)
                                          .Select(t => new TurnoverTrend {
                TheMonth = t.Key,
                Turnover = t.Sum(s => s.Turnover)
            })
                                          .ToList();

            if (yodlees.Count() > 1)
            {
                affordability.ErrorMsgs = "More than one bank data";
            }

            MpModel.Affordability.Add(affordability);
        }         // SaveBankStatement