Esempio n. 1
0
        private void WriteLoanStatusHTML(int loanID, DateTime dtAsOf, System.IO.StreamWriter sw, List <double> totals, string rowIDName)
        {
            clsEntity titleHolder;
            clsEntity coBorrower;
            clsEntity titleCompany;
            int       totalsIndex = 0;
            double    value;

            clsLoan loan = new clsLoan(loanID).LoanAsOf(dtAsOf);

            titleHolder  = new clsEntity(loan.TitleHolderID());
            titleCompany = new clsEntity(loan.TitleCompanyID());
            coBorrower   = new clsEntity(loan.CoBorrowerID());
            clsLoan.State eStatus = loan.Status();

            sw.WriteLine("<tr ID=" + rowIDName + ">");

            sw.Write("<td align=\"left\">" + loan.Property().Address() + "</td>");
            if (eStatus.ToString().Length > 10)
            {
                sw.Write("<td align=\"left\">" + eStatus.ToString().ToUpper().Substring(0, 10) + "</td>");
            }
            else
            {
                sw.Write("<td align=\"left\">" + eStatus.ToString().ToUpper() + "</td>");
            }

            if (eStatus == clsLoan.State.Cancelled)
            {
                for (int i = 0; i < 16; i++)
                {
                    sw.Write("<td></td>");
                    totalsIndex++;
                }
            }
            else
            {
                if (loan.Status() == clsLoan.State.Sold)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        sw.Write("<td></td>");
                        totalsIndex++;
                    }
                    if (loan.AccruedAdditionalInterest(dtAsOf) > 0D)
                    {
                        value = loan.AccruedAdditionalInterest(dtAsOf);
                        totals[totalsIndex] += value;
                        sw.Write("<td align=\"right\">" + value + "</td>");
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        sw.Write("<td></td>");
                        totalsIndex++;
                    }
                    value = loan.PrincipalPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.InterestPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.PointsPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.AdditionalInterestPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.Return(false);
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.IRR(false);
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                }
                else if (loan.Status() == clsLoan.State.PartiallySold)
                {
                    value = loan.Balance(dtAsOf);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    value = loan.AccruedInterest(dtAsOf);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    value = loan.ProjectedHardInterest();
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    value = loan.AccruedAdditionalInterest(dtAsOf);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value + "</td>");
                    value = loan.Return(false);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    value = loan.IRR(false);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    value = loan.PrincipalPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.InterestPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.PointsPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.AdditionalInterestPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.Return(false);
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    value = loan.IRR(false);
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                }
                else
                {
                    value = loan.Balance(dtAsOf);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    value = loan.AccruedInterest(dtAsOf);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    value = loan.ProjectedHardInterest();
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    value = loan.ProjectedAdditionalInterest(dtAsOf);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    value = loan.Return(false);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    value = loan.IRR(false);
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    sw.Write("<td align=\"right\">" + value.ToString("#0.00%") + "</td>");
                    for (int i = 0; i < 2; i++)
                    {
                        sw.Write("<td></td>");
                        totalsIndex++;
                    }
                    value = loan.PointsPaid(dtAsOf);
                    sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                    totals[totalsIndex] += value;
                    totalsIndex++;
                    for (int i = 0; i < 3; i++)
                    {
                        sw.Write("<td></td>");
                        totalsIndex++;
                    }
                }
                value = loan.RehabRemain(dtAsOf);
                totals[totalsIndex] += value;
                totalsIndex++;
                sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                value = loan.RehabSpent(dtAsOf);
                totals[totalsIndex] += value;
                totalsIndex++;
                sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>");
                sw.Write("<td align=\"right\">" + loan.SaleDate().ToShortDateString() + "</td>");
                sw.Write("<td align=\"right\">" + loan.OriginationDate().ToShortDateString() + "</td>");
                sw.Write("<td align=\"right\">" + (loan.SaleDate() - loan.OriginationDate()).TotalDays.ToString() + "</td>");
            }

            sw.Write("<td>" + titleHolder.Name() + "</td>");
            sw.Write("<td>" + coBorrower.Name() + "</td>");
            sw.Write("<td>" + titleCompany.Name() + "</td>");
            sw.Write("<td>" + loan.Rate().ToString("#0.00%") + "</td>");
            sw.Write("<td>" + loan.PenaltyRate().ToString("#0.00%") + "</td>");
            sw.Write("<td>" + (loan.Points() * 0.01).ToString("#0.00%") + "</td>");
            sw.Write("<td>" + loan.ProfitSplit().ToString("#0.00%") + "</td>");
            sw.Write("<td>" + loan.OriginationDate().ToShortDateString() + "</td>");
            sw.Write("<td>" + loan.MaturityDate().ToShortDateString() + "</td>");
            sw.Write("<td>" + loan.GrossReturn(false).ToString("#0.00%") + "</td>");
            sw.Write("<td>" + loan.GrossReturn(true).ToString("#0.00%") + "</td>");
            sw.Write("<td>" + loan.Return(true).ToString("#0.00%") + "</td>");
            sw.Write("<td>" + loan.IRR(true).ToString("#0.00%") + "</td>");
            sw.Write("<td>" + loan.FirstRehabEstimate().ToString("#,##0.00") + "</td>");
            sw.WriteLine();

            sw.WriteLine("</tr>");
            sw.Flush();
        }
Esempio n. 2
0
 partial void UpdateButtonPushed(AppKit.NSButton sender)
 {
     this.SummaryMessageField.StringValue = "";
     if (this.loanToUpdate == null)
     {
         this.SummaryMessageField.StringValue = "No loan selected.  No updates made.";
     }
     else if (this.loanToUpdate.Status() != clsLoan.State.Cancelled)
     {
         // only validaton is:  are any cashflows ACTUAL
         bool   bAnyActuals = false;
         double oldAcqCost  = this.loanToUpdate.AcquisitionCost(false);
         foreach (clsCashflow cf in this.loanToUpdate.Cashflows())
         {
             if (cf.Actual())
             {
                 bAnyActuals = true;
             }
         }
         if (bAnyActuals)
         {
             this.SummaryMessageField.StringValue = "Can't update - some cashflows are marked Actual";
         }
         else
         {
             int delayDays = ((DateTime)this.ClosingDatePicker.DateValue - this.loanToUpdate.OriginationDate()).Days;
             List <clsCashflow> newCashflows = new List <clsCashflow>();
             // delete all existing scheduled cashflows
             foreach (clsCashflow cf in this.loanToUpdate.Cashflows())
             {
                 if (cf.DeleteDate() > System.DateTime.Today.AddYears(50))
                 {
                     if ((cf.TypeID() == clsCashflow.Type.NetDispositionProj) ||
                         (cf.TypeID() == clsCashflow.Type.RehabDraw))
                     {
                         newCashflows.Add(new clsCashflow(cf.PayDate().AddDays(delayDays),
                                                          System.DateTime.Today, System.DateTime.MaxValue,
                                                          this.loanToUpdate.ID(), cf.Amount(), false, cf.TypeID()));
                     }
                     cf.Delete(System.DateTime.Today);
                 }
             }
             // create all the new cashflows
             this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                           System.DateTime.Now, System.DateTime.MaxValue,
                                                           this.loanToUpdate.ID(), -this.PriceField.DoubleValue,
                                                           false, clsCashflow.Type.AcquisitionPrice));
             if (this.ConcessionField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), this.ConcessionField.DoubleValue,
                                                               false, clsCashflow.Type.AcquisitionConcession));
             }
             if (this.HOIField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), -this.HOIField.DoubleValue,
                                                               false, clsCashflow.Type.HomeownersInsurance));
             }
             if (this.AcqTaxField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), -this.AcqTaxField.DoubleValue,
                                                               false, clsCashflow.Type.AcquisitionTaxes));
             }
             if (this.RecordingField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), -this.RecordingField.DoubleValue,
                                                               false, clsCashflow.Type.AcquisitionRecording));
             }
             if (this.ProcessingField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), -this.ProcessingField.DoubleValue,
                                                               false, clsCashflow.Type.AcquisitionProcessing));
             }
             if (this.TitlePolicyField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), -this.TitlePolicyField.DoubleValue,
                                                               false, clsCashflow.Type.TitlePolicy));
             }
             if (this.InitialDrawField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), -this.InitialDrawField.DoubleValue,
                                                               false, clsCashflow.Type.InitialExpenseDraw));
             }
             if (this.PropertyTaxField.DoubleValue > 0)
             {
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               System.DateTime.Now, System.DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), -this.PropertyTaxField.DoubleValue,
                                                               false, clsCashflow.Type.PropertyTax));
             }
             if (loanToUpdate.Points() > 0)
             {
                 if (this.loanToUpdate.PointsCapitalized()) // if points were capitalized, capitalize them on update
                 {
                     this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                                   DateTime.Now, DateTime.MaxValue,
                                                                   this.loanToUpdate.ID(), -this.UpdatedPointsLabel.DoubleValue,
                                                                   false, clsCashflow.Type.Points));
                 }
                 // either way, add points paid at closing (to lender)
                 this.loanToUpdate.AddCashflow(new clsCashflow((DateTime)this.ClosingDatePicker.DateValue,
                                                               DateTime.Now, DateTime.MaxValue,
                                                               this.loanToUpdate.ID(), this.UpdatedPointsLabel.DoubleValue,
                                                               false, clsCashflow.Type.Points));
             }
             foreach (clsCashflow cf in newCashflows)
             {
                 if (cf.TypeID() == clsCashflow.Type.NetDispositionProj)
                 {
                     DateTime newDate = (DateTime)this.ClosingDatePicker.DateValue;
                     clsLoan  l       = loanToUpdate.LoanAsOf(newDate.AddDays(1), true);
                     this.loanToUpdate.AddCashflow(new clsCashflow(cf.PayDate(), cf.RecordDate(), cf.DeleteDate(), cf.LoanID(),
                                                                   cf.Amount() + loanToUpdate.LoanAsOf(newDate.AddDays(1), true).Balance(newDate.AddDays(1)) - oldAcqCost,
                                                                   false, clsCashflow.Type.NetDispositionProj));
                     //                                cf.Amount() + loanToUpdate.AcquisitionCost(false) - oldAcqCost, false, clsCashflow.Type.NetDispositionProj));
                 }
                 else
                 {
                     this.loanToUpdate.AddCashflow(cf);
                 }
             }
             // Update origination Date and Save
             this.loanToUpdate.SetNewOriginationDate((DateTime)this.ClosingDatePicker.DateValue);
             this.loanToUpdate.LenderID   = clsEntity.EntityID((String)(NSString)this.LenderComboBox.SelectedValue);
             this.loanToUpdate.BorrowerID = clsEntity.EntityID((String)(NSString)this.BorrowerComboBox.SelectedValue);
             if (this.loanToUpdate.Save())
             {
                 this.SummaryMessageField.StringValue += "\nSave successful.  " + this.loanToUpdate.Property().Address();
                 this.SummaryMessageField.StringValue += "\nOld / New Acquisition Cost = ";
                 this.SummaryMessageField.StringValue += oldAcqCost.ToString("#,##0.00") + " / ";
                 this.SummaryMessageField.StringValue += this.loanToUpdate.AcquisitionCost(false).ToString("#,##0.00");
                 this.UpdateTotalCostLabel();
             }
             else
             {
                 this.SummaryMessageField.StringValue += "\nSave Failed.";
             }
         }
     }
     else
     {
         this.SummaryMessageField.StringValue = "Update failed.  Loan has already been cancelled.  " + this.loanToUpdate.Property().Address();
     }
 }