Example #1
0
 public void Save(ICashFlow cashFlow)
 {
     if (!this._cashFlowDb.ContainsKey(cashFlow.GenerateId()))
     {
         this._cashFlowDb.Add(cashFlow.GenerateId(), cashFlow);
     }
     this._cashFlowDb[cashFlow.GenerateId()] = cashFlow;
 }
Example #2
0
        public Activity(decimal cash, decimal debt, ICashFlow cashFlow, DateTime initiatedAt)
        {
            InitiatedAt = initiatedAt;
            InitialCash = cash;
            InitialDebt = debt;

            CashFlow = cashFlow;
        }
Example #3
0
        // private static Activity GetActivity(ICashFlow cashFlow, DateTime startAt)
        // {
        //     var result = new Activity(cashFlow, startAt);
        //
        //     return result;
        // }

        private static Activity BuyAndSellOneHouse(ICashFlow cashFlow, DateTime startAt, DateTime soldAt, decimal downPaymentRate)
        {
            var condoAppreciation = new CompoundYearlyInflation(0.05M);
            var soldPrice         = new Money(500000, startAt)
                                    .GetValueAt(condoAppreciation, soldAt);

            return(new MagicEstateBuilder(cashFlow, startAt)
                   .SetInitialCash(50000.00M)
                   .AddCondoWithFixedRateMortgageAtDownPaymentPercentage("first", 500000, downPaymentRate)
                   .SellHome("first", soldAt, soldPrice)
                   .Build());
        }
Example #4
0
        private static decimal PrintCashFlow(decimal downPaymentRate, ICashFlow cashFlow, DateTime startedAt, DateTime soldAt, decimal previousCash)
        {
            var activity           = BuyAndSellOneHouse(cashFlow, startedAt, soldAt, downPaymentRate);
            var consumerPriceIndex = new CompoundYearlyInflation(0.02M);

            // var netWorth = activity.GetNetWorth(consumerPriceIndex, atTwentyYears.AddDays(1));
            var cash = activity.GetCashAt(Inflations.NoopInflation, soldAt.AddDays(1));

            var condoPurchase = activity.GetHistories()
                                .Where(action => action.Type == Types.Purchase)
                                .Where(action => action.Product.GetType() == typeof(Home))
                                .First();

            Console.WriteLine($"\tPurchased with {downPaymentRate * 100} per cent down at {condoPurchase.At} after 20 years");
            Console.WriteLine($"\t- Cash:\t\t{cash}");
            if (previousCash != 0.00M)
            {
                Console.WriteLine($"\t- %+- Change:\t{((cash / previousCash) - 1).ToString("#0.00 %")}");
            }

            return(cash);
        }
Example #5
0
 public CashFinder(ICashFlow cashFlow, DateTime initiatedAt)
 {
     CashFlow    = cashFlow;
     InitiatedAt = initiatedAt;
 }
Example #6
0
 public RealEstateBuilder(ICashFlow cashFlow, DateTime at)
 {
     Result = new Activity(cashFlow, at);
 }
Example #7
0
 public Activity(ICashFlow cashFlow, DateTime initiatedAt)
 {
     CashFlow    = cashFlow;
     InitiatedAt = initiatedAt;
 }
Example #8
0
 public MagicEstateBuilder(ICashFlow cashFlow, DateTime initiatedAt)
 {
     Result      = new Activity(cashFlow, initiatedAt);
     InitiatedAt = At = initiatedAt;
 }
 public void Save(ICashFlow cashFlow)
 {
     if (!this._cashFlowDb.ContainsKey(cashFlow.GenerateId()))
         this._cashFlowDb.Add(cashFlow.GenerateId(), cashFlow);
     this._cashFlowDb[cashFlow.GenerateId()] = cashFlow;
 }