public override void ViewDidLoad() { base.ViewDidLoad(); // load Loans By Address clsCSVTable tbl = new clsCSVTable(clsLoan.strLoanPath); for (int i = 0; i < tbl.Length(); i++) { clsLoan l = new clsLoan(i); loansByAddress.Add(l.Property().Address(), l); } // Do any additional setup after loading the view. this.UpdateAddressList(); this.SaleDatePicker.DateValue = (NSDate)System.DateTime.Today.Date; this.ChooseActionPopUp.RemoveAllItems(); this.RecordDatePicker.DateValue = (NSDate)System.DateTime.Today.Date; this.LenderComboBox.RemoveAll(); clsCSVTable tblEntities = new clsCSVTable(clsEntity.strEntityPath); for (int i = 0; i < tblEntities.Length(); i++) { if (tbl.Matches(clsLoan.LenderColumn, i.ToString()).Count > 0) { this.LenderComboBox.Add((NSString)(new clsEntity(i)).Name()); } } this.StatusComboBox.RemoveAll(); foreach (clsLoan.State c in Enum.GetValues(typeof(clsLoan.State))) { this.StatusComboBox.Add((NSString)c.ToString()); } }
private void loadRehabInfo() { chosenID = clsLoan.LoanID(propertyMenu.TitleOfSelectedItem); clsLoan l = new clsLoan(chosenID); if ((l.Status() == clsLoan.State.PendingSale) || (l.Status() == clsLoan.State.Sold)) { this.LoanStatusTextField.TextColor = NSColor.Red; this.LoanStatusTextField.StringValue = l.Status().ToString().ToUpper(); if (l.Status() == clsLoan.State.PendingSale) { this.LoanStatusTextField.StringValue += " *** CHECK PAYOFF LETTER"; } } else { this.LoanStatusTextField.TextColor = NSColor.Black; this.LoanStatusTextField.StringValue = l.Status().ToString(); } rehabDrawDisplayTrue.StringValue = "Payed draws:" + "\n"; rehabDrawDisplayFalse.StringValue = "Not payed draws:" + "\n"; // Repopulate Cashflow ID Pop Up this.CashflowIDPopUp.RemoveAllItems(); this.CashflowIDPopUp.AddItem("Select Cashflow"); double trueTotal = 0; double falseTotal = 0; foreach (clsCashflow cashFlow in l.Cashflows()) { if (cashFlow.TypeID() == clsCashflow.Type.RehabDraw && cashFlow.DeleteDate() > System.DateTime.Today) { if (cashFlow.Actual() == true) { trueTotal += cashFlow.Amount(); rehabDrawDisplayTrue.StringValue += "Date: " + cashFlow.PayDate().ToString("MM/dd/yyyy hh:mm") + ", "; rehabDrawDisplayTrue.StringValue += "Amount: " + "$" + (-cashFlow.Amount()).ToString("00,000.00") + ", "; rehabDrawDisplayTrue.StringValue += "Payed: " + cashFlow.Actual() + "\n"; } else { falseTotal += cashFlow.Amount(); rehabDrawDisplayFalse.StringValue += "Date: " + cashFlow.PayDate().ToString("MM/dd/yyyy hh:mm") + ", "; rehabDrawDisplayFalse.StringValue += "Amount: " + "$" + (-cashFlow.Amount()).ToString("00,000.00") + ", "; rehabDrawDisplayFalse.StringValue += "Payed: " + cashFlow.Actual() + ", "; rehabDrawDisplayFalse.StringValue += "Cashflow ID: " + cashFlow.ID() + "\n"; this.CashflowIDPopUp.AddItem(cashFlow.ID().ToString()); } } } //After each cashflows are filtered, display the total trueTotal = -trueTotal; falseTotal = -falseTotal; rehabDrawDisplayTrue.StringValue += "Total amount: " + "$" + trueTotal.ToString("00,000.00"); rehabDrawDisplayFalse.StringValue += "Total amount: " + "$" + falseTotal.ToString("00,000.00"); }
partial void PropertyChosen(NSComboBox sender) { this.addressSelected = this.PropertyChooser.StringValue; if (this.addressSelected.Length > 1) { this.loan = new clsLoan(this.loanList[this.addressSelected]); } this.Update(); }
private void WriteLoanAuditHTML(int loanID, DateTime dtStart, DateTime dtEnd, System.IO.StreamWriter sw, List <double> totals, string rowIDName) { clsEntity titleHolder; clsEntity coBorrower; int totalsIndex = 0; double value; clsLoan loanStart = new clsLoan(loanID).LoanAsOf(dtStart); clsLoan loanEnd = new clsLoan(loanID).LoanAsOf(dtEnd); titleHolder = new clsEntity(loanEnd.TitleHolderID()); coBorrower = new clsEntity(loanEnd.CoBorrowerID()); if ((loanEnd.Status() != clsLoan.State.Cancelled) && (loanStart.Status() != clsLoan.State.Sold)) { sw.WriteLine("<tr ID=" + rowIDName + ">"); sw.Write("<td align=\"left\">" + loanEnd.Property().Address() + "</td>"); // write values value = loanStart.Balance(dtStart); totals[totalsIndex] += value; totalsIndex++; sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>"); value = loanEnd.Balance(dtEnd) - loanStart.Balance(dtStart) + loanEnd.PrincipalPaid(dtEnd); totals[totalsIndex] += value; totalsIndex++; sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>"); value = loanEnd.PrincipalPaid(dtEnd); totals[totalsIndex] += value; totalsIndex++; sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>"); value = loanEnd.Balance(dtEnd); totals[totalsIndex] += value; totalsIndex++; sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>"); value = loanEnd.AccruedInterest(dtEnd); totals[totalsIndex] += value; totalsIndex++; sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>"); value = loanEnd.InterestPaid(dtEnd); totals[totalsIndex] += value; totalsIndex++; sw.Write("<td align=\"right\">" + value.ToString("#,##0.00") + "</td>"); value = loanEnd.Rate(); sw.Write("<td align=\"right\">" + value.ToString("0.00%") + "</td>"); sw.Write("<td>" + titleHolder.Name() + "</td>"); sw.Write("<td>" + coBorrower.Name() + "</td>"); sw.WriteLine(); sw.WriteLine("</tr>"); sw.Flush(); } }
private void WriteLoanAudit(int loanID, DateTime dtStart, DateTime dtEnd, System.IO.StreamWriter streamWriter) { clsLoan loanEnd = new clsLoan(loanID).LoanAsOf(dtEnd); clsLoan loanStart = new clsLoan(loanID).LoanAsOf(dtStart); if ((loanEnd.Status() != clsLoan.State.Cancelled) && (loanStart.Status() != clsLoan.State.Sold)) { streamWriter.Write(loanEnd.Property().Address() + ","); streamWriter.Write(loanStart.Balance(dtStart).ToString() + ","); double dAdditions = loanEnd.Balance(dtEnd) - loanStart.Balance(dtStart) + loanEnd.PrincipalPaid(dtEnd); streamWriter.Write(dAdditions.ToString() + ","); streamWriter.Write(loanEnd.PrincipalPaid(dtEnd).ToString() + ","); streamWriter.Write(loanEnd.Balance(dtEnd).ToString() + ","); streamWriter.Write(loanEnd.AccruedInterest(dtEnd).ToString() + ","); streamWriter.WriteLine(loanEnd.InterestPaid(dtEnd).ToString()); streamWriter.Flush(); } }
private void RedrawTable() { // instantiate loan that matches address chosen if (this.PropertyChooser.SelectedIndex != 0) { clsLoan loan = new clsLoan(dictLoanIDsByAddress[this.PropertyChooser.StringValue]); // load all documents pertaining to that property, and all document records pertaining to each document List <int> documentIDs = tblDocuments.Matches(clsDocument.PropertyColumn, loan.PropertyID().ToString()); List <clsDocument> documents = new List <clsDocument>(); Dictionary <int, List <clsDocumentRecord> > documentRecords = new Dictionary <int, List <clsDocumentRecord> >(); foreach (int id in documentIDs) { documents.Add(new clsDocument(id)); documentRecords.Add(id, new List <clsDocumentRecord>()); foreach (int docrecid in tblDocumentRecords.Matches(clsDocumentRecord.DocumentColumn, id.ToString())) { documentRecords[id].Add(new clsDocumentRecord(docrecid)); } } // apply filters (date range, type, status, transmission, sender, receiver) to construct datasource // construct datasource this.dataSource.data = new List <clsDocumentRecord>(); foreach (int id in documentIDs) { foreach (clsDocumentRecord rec in documentRecords[id]) { bool ok = true; ok = (ok) && (((int)rec.StatusType() == this.StatusFilter.SelectedIndex - 1) || (this.StatusFilter.SelectedIndex == 0)); ok = (ok) && (((int)rec.SenderID() == this.SenderFilter.SelectedIndex - 1) || (this.SenderFilter.SelectedIndex == 0)); ok = (ok) && (((int)rec.ReceiverID() == this.ReceiverFilter.SelectedIndex - 1) || (this.ReceiverFilter.SelectedIndex == 0)); // ok = (ok) && (((int)rec.DocumentID() == this.TypeFilter.SelectedIndex - 1) || (this.TypeFilter.SelectedIndex == 0)); if (ok) { this.dataSource.data.Add(rec); } } } // ALLOW SORTING this.DocRecTableView.ReloadData(); } }
partial void dateChangeClicked(AppKit.NSButton sender) { if (Int32.TryParse(CashflowIDPopUp.SelectedItem.Title, out int i)) { clsLoan loan = new clsLoan(chosenID); DateTime newDate = (DateTime)(dateChanger.DateValue); // Delete existing (old) cashflow clsCashflow cf = new clsCashflow(Int32.Parse(CashflowIDPopUp.SelectedItem.Title)); cf.Delete(System.DateTime.Today); cf.Save(); // Create new cashflow with new date clsCashflow updatedCF = new clsCashflow(newDate, System.DateTime.Today, System.DateTime.MaxValue, cf.LoanID(), cf.Amount(), false, cf.TypeID()); loan.AddCashflow(updatedCF); updatedCF.Save(); loadRehabInfo(); } }
partial void dateChangeClicked(AppKit.NSButton sender) { clsLoan loan = new clsLoan(chosenID); int cfID = 0; cfID = Int32.Parse(cashflowID.StringValue); DateTime newDate = (DateTime)(dateChanger.DateValue); clsCashflow cf = new clsCashflow(cfID); cf.Delete(System.DateTime.Today); cf.Save(); clsCashflow updatedCF = new clsCashflow(newDate, System.DateTime.Today, System.DateTime.MaxValue, cf.LoanID(), cf.Amount(), false, cf.TypeID()); loan.AddCashflow(updatedCF); updatedCF.Save(); loadRehabInfo(); }
partial void addNewConstruction(AppKit.NSButton sender) { clsLoan loan = new clsLoan(chosenID); DateTime payDate = (DateTime)(constructionDateNew.DateValue); DateTime recordDate = System.DateTime.Today; DateTime deleteDate = System.DateTime.MaxValue; int loanID = chosenID; double amount = constructionAmountNew.DoubleValue; if (amount > 0) { amount = -amount; } bool payed = false; if (payDate > System.DateTime.Today) { payed = false; } else { payed = true; } clsCashflow.Type typeID = new clsCashflow.Type(); typeID = clsCashflow.Type.RehabDraw; clsCashflow newCashflow = new clsCashflow(payDate, recordDate, deleteDate, loanID, amount, payed, typeID); loan.Cashflows().Add(newCashflow); newCashflow.Save(); loadRehabInfo(); // if (loan.Save()) // loadRehabInfo(); // else // rehabDrawDisplayTrue.StringValue += "\nSave Failed, New Cashflow not Saved."; }
/// <summary> /// Private Mehod for Save Loan ApplicationRecord /// </summary> public void SaveLoanDetails() { ObjLoan = new clsLoan(); int intYear, intMonth; try { //Loan Detials ObjLoan.LoanId = !string.IsNullOrEmpty(hdnLoanId.Value) ? Convert.ToInt32(hdnLoanId.Value) : 0; ObjLoan.CustomerId = !string.IsNullOrEmpty(hdnCustomerId.Value) ? Convert.ToInt32(hdnCustomerId.Value) : 0; ObjLoan.LoanDate = !string.IsNullOrEmpty(txtLoanDate.Text.Trim()) ? Convert.ToString(txtLoanDate.Text.Trim()) : String.Empty; ObjLoan.LoanTypeID = !string.IsNullOrEmpty(ddlLoanType.SelectedValue) ? Convert.ToInt32(ddlLoanType.SelectedValue) : 0; ObjLoan.LoanAmount = !string.IsNullOrEmpty(txtLoanAmt.Text.Trim()) ? Convert.ToDouble(txtLoanAmt.Text.Trim()) : 0; ObjLoan.InstallmentAmt = !string.IsNullOrEmpty(txtEmiAmt.Text.Trim()) ? Convert.ToDouble(txtEmiAmt.Text.Trim()) : 0; //Calculate Loan Period intYear = !string.IsNullOrEmpty(ddlLoanYear.SelectedValue) ? Convert.ToInt32(ddlLoanYear.SelectedValue) : 0; intMonth = !string.IsNullOrEmpty(ddlLoanMonth.SelectedValue) ? Convert.ToInt32(ddlLoanMonth.SelectedValue) : 0; intMonth = ((intYear * 12) + intMonth); ObjLoan.LoanPeriod = intMonth; ObjLoan.LoanReason = !string.IsNullOrEmpty(txtCustomerLoanPurpose.Text.Trim()) ? Convert.ToString(txtCustomerLoanPurpose.Text.Trim()) : string.Empty; ObjLoan.LoanPaidUpTypeID = !string.IsNullOrEmpty(ddlCustomerPastLoanEMI.SelectedValue) ? Convert.ToInt32(ddlCustomerPastLoanEMI.SelectedValue) : 0; ObjLoan.TotalInstallment = !string.IsNullOrEmpty(txtTotalLoanInstallmentAmt.Text.Trim()) ? Convert.ToDouble(txtTotalLoanInstallmentAmt.Text.Trim()) : 0; ObjLoan.WitnessNo1 = !string.IsNullOrEmpty(hdnWitnessID1.Value) ? Convert.ToInt32(hdnWitnessID1.Value) : 0; ObjLoan.WitnessNo2 = !string.IsNullOrEmpty(hdnWitnessID2.Value) ? Convert.ToInt32(hdnWitnessID2.Value) : 0; ObjLoan.WitnessNo3 = !string.IsNullOrEmpty(hdnWitnessID3.Value) ? Convert.ToInt32(hdnWitnessID3.Value) : 0; ObjLoan.WitnessNo4 = !string.IsNullOrEmpty(hdnWitnessID4.Value) ? Convert.ToInt32(hdnWitnessID4.Value) : 0; ObjLoan.CreatedBy = Convert.ToInt32(AppSessions.GetSession(AppSessions.UDFSessionName._user_id.ToString())); ObjLoan.CreatedDate = Convert.ToDateTime(txtLoanDate.Text); ObjLoan.UpdatedBy = Convert.ToInt32(AppSessions.GetSession(AppSessions.UDFSessionName._user_id.ToString())); ObjLoan.UpdatedDate = Convert.ToDateTime(txtLoanDate.Text); ObjLoan.IsActive = true; if (ObjLoan.Insert()) { lblMessage.CssClass = "SuccessfulMessage"; lblMessage.Text = (String)GetGlobalResourceObject("SharedResource", "RecordSavedSuccessfully"); } else { lblMessage.CssClass = "FailureMessage"; lblMessage.Text = (String)GetGlobalResourceObject("SharedResource", "RecordSavingFailure"); } ShowHideLoanGrid(true); EnableDisabledControls(false); BindLoanGrid(); } catch { lblMessage.CssClass = "FailureMessage"; lblMessage.Text = (String)GetGlobalResourceObject("SharedResource", "RecordSavingFailure"); } finally { ObjLoan = null; } }
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(); }
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(); } }
private void WriteLoan(int loanID, DateTime dtAsOf, System.IO.StreamWriter sw) { clsEntity titleHolder; clsEntity coBorrower; clsEntity titleCompany; 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.Write(loan.Property().Address() + ","); sw.Write(eStatus.ToString().ToUpper() + ","); if (eStatus == clsLoan.State.Cancelled) { sw.Write(",,,,,,,,,,,,,,,,"); } else { if (loan.Status() == clsLoan.State.Sold) { sw.Write(",,,"); if (loan.AccruedAdditionalInterest(dtAsOf) > 0D) { sw.Write(loan.AccruedAdditionalInterest(dtAsOf)); } sw.Write(",,,"); sw.Write(loan.PrincipalPaid(dtAsOf).ToString() + ","); sw.Write(loan.InterestPaid(dtAsOf).ToString() + ","); sw.Write(loan.AdditionalInterestPaid(dtAsOf).ToString() + ","); sw.Write(loan.Return(false).ToString() + ","); sw.Write(loan.IRR(false).ToString() + ","); } else if (loan.Status() == clsLoan.State.PartiallySold) { sw.Write(loan.Balance(dtAsOf).ToString() + ","); sw.Write(loan.AccruedInterest(dtAsOf).ToString() + ","); sw.Write(loan.ProjectedHardInterest().ToString() + ","); if (loan.AccruedAdditionalInterest(dtAsOf) > 0D) { sw.Write(loan.AccruedAdditionalInterest(dtAsOf)); } sw.Write(","); sw.Write(loan.Return(false).ToString() + ","); sw.Write(loan.IRR(false).ToString() + ","); sw.Write(loan.PrincipalPaid(dtAsOf).ToString() + ","); sw.Write(loan.InterestPaid(dtAsOf).ToString() + ","); sw.Write(loan.AdditionalInterestPaid(dtAsOf).ToString() + ","); sw.Write(loan.Return(false).ToString() + ","); sw.Write(loan.IRR(false).ToString() + ","); } else { sw.Write(loan.Balance(dtAsOf).ToString() + ","); sw.Write(loan.AccruedInterest(dtAsOf).ToString() + ","); sw.Write(loan.ProjectedHardInterest().ToString() + ","); sw.Write(loan.ProjectedAdditionalInterest(dtAsOf).ToString() + ","); sw.Write(loan.Return(false).ToString() + ","); sw.Write(loan.IRR(false).ToString() + ","); sw.Write(",,,,,"); } sw.Write(loan.RehabRemain(dtAsOf).ToString() + ","); sw.Write(loan.RehabSpent(dtAsOf).ToString() + ","); sw.Write(loan.SaleDate().ToShortDateString() + ","); sw.Write(loan.OriginationDate().ToShortDateString() + ","); sw.Write((loan.SaleDate() - loan.OriginationDate()).TotalDays.ToString() + ","); } sw.Write(titleHolder.Name() + ","); sw.Write(coBorrower.Name() + ","); sw.Write(titleCompany.Name() + ","); sw.Write(loan.Rate().ToString() + ","); sw.Write(loan.PenaltyRate().ToString() + ","); sw.Write(loan.OriginationDate().ToShortDateString() + ","); sw.Write(loan.MaturityDate().ToShortDateString() + ","); sw.Write(loan.GrossReturn(false).ToString() + ","); sw.Write(loan.GrossReturn(true).ToString() + ","); sw.Write(loan.Return(true).ToString() + ","); sw.Write(loan.IRR(true).ToString() + ","); sw.Write(loan.FirstRehabEstimate().ToString() + ","); sw.WriteLine(); sw.Flush(); }
private void CalculateAggregates(DateTime startDate, DateTime endDate) { // Balances: Total made, less each quarters repayment, adding to Net Balance double dTotalLent = 0D; double dRepaidPeriod = 0D; double dRepaidPreviously = 0D; double dNetBalance = 0D; double dTotalCommitted = 0D; double dTotalRehabRemain = 0D; double dSaleContracts = 0D; double dSaleListings = 0D; double dPendingAcq = 0D; double dPartialBalance = 0D; // Accrued: Total accrued FTD, less this period payments, less prior payments, (=accrued end of period), // less accrued end of prev period, adding to net accrued this period // (+) paid this period (+) additional interest paid this period (+) add'l accrued this period = Net Income Period double dHardInterestPaidThisPeriod = 0D; double dHardInterestPaidPreviously = 0D; double dAccruedThisPeriod = 0D; double dAdditionalInterestPaidThisPeriod = 0D; double dAdditionalInterestAccruedThisPeriod = 0D; double dAdditionalInterestAccruedPreviousPeriod = 0D; double dPointsPaidThisPeriod = 0D; double dAccruedFTD = 0D; double dAccruedNetAtStartDate = 0D; // Loan-by-loan: // (+) Total Accrual FTD (+) interest paid this period (-) interest paid previous periods // (+) Additional Paid this period (+) additional accrued this period (-) additional accrued last period int iStateCount = Enum.GetNames(typeof(clsLoan.State)).Length; int[,] iLoansByStatus = new int[iStateCount, 2]; int[] iUncancelledCount = new int[2]; for (int i = 0; i < iStateCount; i++) { iLoansByStatus[i, 0] = iLoansByStatus[i, 1] = 0; } // loop through loans clsCSVTable tbl = new clsCSVTable(clsLoan.strLoanPath); for (int i = 0; i < tbl.Length(); i++) { if (this.lenderLoanIDs.Contains(i)) { clsLoan loan = new clsLoan(i); clsLoan loanAsOfEndDate = loan.LoanAsOf(endDate); if (loan.FindDate(clsCashflow.Type.AcquisitionPrice, true, false) <= endDate) { iLoansByStatus[(int)loan.LoanAsOf(startDate).Status(), 0]++; iLoansByStatus[(int)loanAsOfEndDate.Status(), 1]++; dTotalLent += loan.Balance(endDate) + loan.PrincipalPaid(endDate); dTotalRehabRemain += loanAsOfEndDate.RehabRemain(endDate); dRepaidPeriod += loan.PrincipalPaid(endDate) - loan.PrincipalPaid(startDate); dRepaidPreviously += loan.PrincipalPaid(startDate); dHardInterestPaidPreviously += loan.HardInterestPaid(startDate); dHardInterestPaidThisPeriod += loan.HardInterestPaid(endDate) - loan.HardInterestPaid(startDate); dPointsPaidThisPeriod += loan.PointsPaid(endDate) - loan.PointsPaid(startDate); dAccruedThisPeriod += loan.AccruedInterest(endDate) - loan.AccruedInterest(startDate); dAdditionalInterestPaidThisPeriod += loan.AdditionalInterestPaid(endDate) - loan.AdditionalInterestPaid(startDate); dAdditionalInterestAccruedThisPeriod += loan.AccruedAdditionalInterest(endDate); // needs fixing dAdditionalInterestAccruedPreviousPeriod += loan.AccruedAdditionalInterest(startDate); // needs fixing dAccruedFTD += loan.AccruedInterest(endDate) + loan.HardInterestPaid(endDate); dAccruedNetAtStartDate += loan.AccruedInterest(startDate); if (loanAsOfEndDate.Status() == clsLoan.State.Listed) { dSaleListings += loan.Balance(endDate); } if (loanAsOfEndDate.Status() == clsLoan.State.PendingSale) { dSaleContracts += loan.Balance(endDate); } if (loanAsOfEndDate.Status() == clsLoan.State.PendingAcquisition) { dPendingAcq += loan.AcquisitionCost(false); } if (loanAsOfEndDate.Status() == clsLoan.State.PartiallySold) { dPartialBalance += loan.Balance(endDate); } } } } dTotalCommitted = dTotalLent + dTotalRehabRemain + dPendingAcq; dNetBalance = dTotalLent - dRepaidPeriod - dRepaidPreviously; for (int i = 0; i < 2; i++) { iUncancelledCount[i] = iLoansByStatus[(int)clsLoan.State.Listed, i]; iUncancelledCount[i] += iLoansByStatus[(int)clsLoan.State.PendingAcquisition, i]; iUncancelledCount[i] += iLoansByStatus[(int)clsLoan.State.PendingSale, i]; iUncancelledCount[i] += iLoansByStatus[(int)clsLoan.State.Rehab, i]; iUncancelledCount[i] += iLoansByStatus[(int)clsLoan.State.Sold, i]; iUncancelledCount[i] += iLoansByStatus[(int)clsLoan.State.PartiallySold, i]; } int iRepaidCount = iLoansByStatus[(int)clsLoan.State.Sold, 1] - iLoansByStatus[(int)clsLoan.State.Sold, 0]; int iOutstandingCount = iUncancelledCount[1] - iLoansByStatus[(int)clsLoan.State.Sold, 1]; // Display Results this.ReportSummaryTextLabel.StringValue = ""; this.ReportSummaryTextLabel.StringValue += " Total Committed: \t" + dTotalCommitted.ToString("00,000,000.00"); this.ReportSummaryTextLabel.StringValue += "(" + iUncancelledCount[1].ToString("000") + ")" + "\t"; this.ReportSummaryTextLabel.StringValue += "\n Total Loan Given: \t" + dTotalLent.ToString("00,000,000.00"); this.ReportSummaryTextLabel.StringValue += "(" + (iUncancelledCount[1] - iLoansByStatus[(int)clsLoan.State.PendingAcquisition, 1]).ToString("000") + ")" + "\t"; this.ReportSummaryTextLabel.StringValue += "FTD Accrual: \t" + dAccruedFTD.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n Repaid Period: \t" + dRepaidPeriod.ToString("00,000,000.00"); this.ReportSummaryTextLabel.StringValue += "(" + iRepaidCount.ToString("000") + ")" + "\t"; this.ReportSummaryTextLabel.StringValue += "(-)Paid Period: \t" + dHardInterestPaidThisPeriod.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n Repaid Previously: \t" + dRepaidPreviously.ToString("00,000,000.00"); this.ReportSummaryTextLabel.StringValue += "(" + iLoansByStatus[(int)clsLoan.State.Sold, 0].ToString("000") + ")" + "\t"; this.ReportSummaryTextLabel.StringValue += "(-)Paid Prev: \t" + dHardInterestPaidPreviously.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n Loans Outstanding: \t" + dNetBalance.ToString("00,000,000.00"); this.ReportSummaryTextLabel.StringValue += "(" + iOutstandingCount.ToString("000") + ")" + "\t"; this.ReportSummaryTextLabel.StringValue += "Net Accrued: \t" + (dAccruedFTD - dHardInterestPaidThisPeriod - dHardInterestPaidPreviously).ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n \t \t"; this.ReportSummaryTextLabel.StringValue += "(-)Start Accr: \t" + dAccruedNetAtStartDate.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n Sale Contracts \t" + dSaleContracts.ToString("00,000,000.00"); this.ReportSummaryTextLabel.StringValue += "(" + iLoansByStatus[(int)clsLoan.State.PendingSale, 1].ToString("000") + ")" + "\t"; this.ReportSummaryTextLabel.StringValue += "Period Accr: \t" + (dAccruedFTD - dHardInterestPaidThisPeriod - dHardInterestPaidPreviously - dAccruedNetAtStartDate).ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n Sale Listings \t" + dSaleListings.ToString("00,000,000.00"); this.ReportSummaryTextLabel.StringValue += "(" + iLoansByStatus[(int)clsLoan.State.Listed, 1].ToString("000") + ")" + "\t"; this.ReportSummaryTextLabel.StringValue += " \t"; this.ReportSummaryTextLabel.StringValue += "(+) Addl Paid : \t" + dAdditionalInterestPaidThisPeriod.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n \t \t \t"; this.ReportSummaryTextLabel.StringValue += "(+) Addl Accrue: \t" + dAdditionalInterestAccruedThisPeriod.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n \t \t \t"; this.ReportSummaryTextLabel.StringValue += "(-) Prior Accru: \t" + dAdditionalInterestAccruedPreviousPeriod.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n \t \t"; this.ReportSummaryTextLabel.StringValue += "(+) Additional: \t" + (dAdditionalInterestPaidThisPeriod + dAdditionalInterestAccruedThisPeriod - dAdditionalInterestAccruedPreviousPeriod).ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n \t \t"; this.ReportSummaryTextLabel.StringValue += "(+) Hard Paid : \t" + dHardInterestPaidThisPeriod.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n \t \t"; this.ReportSummaryTextLabel.StringValue += "(+) Points Paid :\t" + dPointsPaidThisPeriod.ToString("000,000.00"); this.ReportSummaryTextLabel.StringValue += "\n \t \t"; this.ReportSummaryTextLabel.StringValue += "Net Income Per: \t" + (dAccruedFTD - dHardInterestPaidPreviously - dAccruedNetAtStartDate + dAdditionalInterestPaidThisPeriod + dAdditionalInterestAccruedThisPeriod - dAdditionalInterestAccruedPreviousPeriod + dPointsPaidThisPeriod).ToString("000,000.00"); }
private void UpdateChosenAddress(bool clearMessageText = true) { this.ChooseActionPopUp.RemoveAllItems(); if (clsLoan.LoanID(this.AddressComboBox.StringValue) >= 0) { this.loan = new clsLoan(clsLoan.LoanID(this.AddressComboBox.StringValue)); if (clearMessageText) { this.StatusMessageTextField.StringValue = ""; } this.StatusTextField.StringValue = this.loan.Status().ToString(); this.RepaymentAmountTextField.DoubleValue = 0D; this.SetDefaultLabels(); switch (this.loan.Status()) { case clsLoan.State.PendingSale: this.ChooseActionPopUp.AddItem("Cancel"); this.ChooseActionPopUp.AddItem("Update"); if (this.loan.SaleDate() <= System.DateTime.Today) { this.ChooseActionPopUp.AddItem("Mark Loan Repaid"); } this.SaleDatePicker.DateValue = (NSDate)this.loan.SaleDate().Date.ToUniversalTime(); this.ExpectedSalePriceTextField.DoubleValue = 0D; this.ExpectedAdditionalInterestTextField.DoubleValue = this.loan.ScheduledAdditionalInterest(System.DateTime.Today.Date); DateTime scheduledSale = this.loan.SaleDate().Date; double dPrincipalRepay = this.loan.LoanAsOf(scheduledSale.AddDays(-1)).Balance(scheduledSale.AddDays(-1)); double dHardInterest = this.loan.LoanAsOf(scheduledSale).AccruedInterest(scheduledSale); double perdiem = dHardInterest - this.loan.LoanAsOf(scheduledSale.AddDays(-1)).AccruedInterest(scheduledSale.AddDays(-1)); double dAdditionalInterest = this.ExpectedAdditionalInterestTextField.DoubleValue; this.ShowLoanPayoffLetterInfo(dPrincipalRepay, dHardInterest, perdiem); break; case clsLoan.State.Listed: case clsLoan.State.Rehab: this.ChooseActionPopUp.AddItem("Schedule"); this.ChooseActionPopUp.AddItem("Update"); this.SaleDatePicker.DateValue = (NSDate)this.loan.SaleDate().Date.ToUniversalTime(); this.ExpectedSalePriceTextField.DoubleValue = 0D; this.ExpectedAdditionalInterestTextField.DoubleValue = this.loan.ProjectedAdditionalInterest(System.DateTime.Today.Date); break; case clsLoan.State.PendingAcquisition: this.ChooseActionPopUp.AddItem("Update"); this.SaleDatePicker.DateValue = (NSDate)this.loan.SaleDate().Date.ToUniversalTime(); this.ExpectedSalePriceTextField.DoubleValue = 0D; this.ExpectedAdditionalInterestTextField.DoubleValue = this.loan.ProjectedAdditionalInterest(System.DateTime.Today.Date); break; case clsLoan.State.Unknown: case clsLoan.State.Cancelled: case clsLoan.State.Sold: default: this.SetSoldLabels(); this.ChooseActionPopUp.AddItem("Update/Add"); this.ChooseActionPopUp.AddItem("Mark Addl Int Actual"); this.ExpectedSalePriceTextField.DoubleValue = 0D; this.ExpectedAdditionalInterestTextField.DoubleValue = this.loan.ScheduledAdditionalInterest() + this.loan.PastDueAdditionalInterest(); this.SaleDatePicker.DateValue = (NSDate)this.loan.FindDate(clsCashflow.Type.InterestAdditional, false, true).ToUniversalTime(); break; } } }
partial void PropertyChosen(AppKit.NSComboBox sender) { if (this.AddressComboBox.StringValue != "") { this.loanToUpdate = new clsLoan(clsLoan.LoanID(this.AddressComboBox.StringValue)); DateTime OGDate = loanToUpdate.OriginationDate(); this.ClosingDatePicker.DateValue = (NSDate)OGDate.ToUniversalTime(); //clear labels this.ConcessionLabel.StringValue = ""; this.HOILabel.StringValue = ""; this.PriceLabel.StringValue = ""; this.AcqTaxLabel.StringValue = ""; this.RecordingLabel.StringValue = ""; this.ProcessingLabel.StringValue = ""; this.ClosingDateLabel.StringValue = ""; this.InitialDrawLabel.StringValue = ""; this.PropertyTaxLabel.StringValue = ""; this.TitlePolicyLabel.StringValue = ""; this.PointsLabel.StringValue = ""; //reload labels foreach (clsCashflow cf in this.loanToUpdate.Cashflows()) { if (cf.DeleteDate() > System.DateTime.Today.AddYears(100)) { string amount = (Math.Abs(cf.Amount())).ToString("#,##0.00"); switch (cf.TypeID()) { case clsCashflow.Type.AcquisitionConcession: this.ConcessionLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionPrice: this.PriceLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionProcessing: this.ProcessingLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionRecording: this.RecordingLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionTaxes: this.AcqTaxLabel.StringValue = amount; break; case clsCashflow.Type.TitlePolicy: this.TitlePolicyLabel.StringValue = amount; break; case clsCashflow.Type.HomeownersInsurance: this.HOILabel.StringValue = amount; break; case clsCashflow.Type.InitialExpenseDraw: this.InitialDrawLabel.StringValue = amount; break; case clsCashflow.Type.PropertyTax: // amount = (-cf.Amount()).ToString("#,##0.00"); this.PropertyTaxLabel.StringValue = amount; break; case clsCashflow.Type.Points: this.PointsLabel.StringValue = amount; break; default: break; } } } this.HOIField.StringValue = this.HOILabel.StringValue; this.PriceField.StringValue = this.PriceLabel.StringValue; this.AcqTaxField.StringValue = this.AcqTaxLabel.StringValue; this.RecordingField.StringValue = this.RecordingLabel.StringValue; this.ConcessionField.StringValue = this.ConcessionLabel.StringValue; this.ProcessingField.StringValue = this.ProcessingLabel.StringValue; this.ClosingDatePicker.DateValue = (NSDate)this.loanToUpdate.OriginationDate().ToUniversalTime(); this.InitialDrawField.StringValue = this.InitialDrawLabel.StringValue; this.PropertyTaxField.StringValue = this.PropertyTaxLabel.StringValue; this.TitlePolicyField.StringValue = this.TitlePolicyLabel.StringValue; clsEntity lender = new clsEntity(this.loanToUpdate.LenderID); this.LenderComboBox.Select((NSString)lender.Name()); clsEntity borrower = new clsEntity(this.loanToUpdate.BorrowerID); this.BorrowerComboBox.Select((NSString)borrower.Name()); this.LenderLabel.StringValue = (NSString)this.LenderComboBox.SelectedValue; this.BorrowerLabel.StringValue = (NSString)this.BorrowerComboBox.SelectedValue; this.UpdatedPointsLabel.StringValue = this.PointsLabel.StringValue; this.UpdateTotalCostLabel(); } }
partial void RunReportPressed(NSButton sender) { // open file string fileName = "/Volumes/GoogleDrive/Shared Drives/Resilience/Reports/DocumentStatus"; fileName += System.DateTime.Today.ToString("yyyyMMdd"); fileName += "." + this.LenderPopUpButton.TitleOfSelectedItem; fileName += ".htm"; System.IO.StreamWriter sw = new System.IO.StreamWriter(fileName); // write beginning tags and header sw.WriteLine("<!DOCTYPE html><html>"); sw.WriteLine("<head>"); sw.WriteLine("<style>"); sw.WriteLine("th {text-decoration:underline;}"); sw.WriteLine("tr {background-color:WhiteSmoke;}"); sw.WriteLine("td#MUSTHAVE {background-color:Red;}"); sw.WriteLine("td#MIGHTHAVE {background-color:Orange;}"); sw.WriteLine("td#SHOULDHAVE {background-color:Yellow;}"); sw.WriteLine("td#TODO {background-color:Green;}"); sw.WriteLine("td#COMPLETE {background-color:White;}"); sw.WriteLine("tr#HEADER {background-color:White;}"); sw.WriteLine("</style>"); sw.WriteLine("</head>"); // html body sw.WriteLine("<body>"); sw.WriteLine("<h1>Document Status Report " + System.DateTime.Today.ToString("MM/dd/yyyy") + "</h1>"); sw.WriteLine("<table style=\"width:auto\">"); WriteHTMLHeaderRow(sw); // loop through loans clsCSVTable tbl = new clsCSVTable(clsLoan.strLoanPath); clsCSVTable tblDocuments = new clsCSVTable(clsDocument.strDocumentPath); clsCSVTable tblDocumentRecords = new clsCSVTable(clsDocumentRecord.strDocumentRecordPath); for (int i = 0; i < tbl.Length(); i++) { if (this.lenderLoanIDs.Contains(i)) { // load document list clsLoan loan = new clsLoan(i); Dictionary <int, clsDocument> documentList = new Dictionary <int, clsDocument>(); List <int> documentListIDs = new List <int>(); documentListIDs = tblDocuments.Matches(clsDocument.PropertyColumn, loan.PropertyID().ToString()); // load document records List <clsDocumentRecord> documentRecordList = new List <clsDocumentRecord>(); List <int> documentRecordIDs = new List <int>(); List <clsDocument.Type> documentTypes = new List <clsDocument.Type>(); foreach (int id in documentListIDs) { documentList.Add(id, new clsDocument(id)); foreach (int recID in tblDocumentRecords.Matches(clsDocumentRecord.DocumentColumn, id.ToString())) { documentRecordIDs.Add(recID); documentRecordList.Add(new clsDocumentRecord(recID)); documentTypes.Add(documentList[id].DocumentType()); } } // write loan to report this.WriteLoanHTML(loan.Property().Address(), loan.Status(), sw, documentRecordList, documentTypes); } } // end of doc tags this.WriteHTMLFooter(sw); sw.WriteLine("</table></body></html>"); sw.Flush(); }
/// <summary> /// /// </summary> private void BindLoanGrid() { ObjLoan = new clsLoan(); dtLoan = new DataTable(); try { if (!string.IsNullOrEmpty(txtSearchCustomer.Text) && !string.IsNullOrEmpty(ddlLoanSearch.SelectedValue)) { string strsearch = ddlLoanSearch.SelectedValue.ToString(); switch (strsearch) { case "CustomerNo": ObjLoan.CustomerCode = txtSearchCustomer.Text.ToString(); break; case "CusotmerName": ObjLoan.CoustmerName = txtSearchCustomer.Text.ToString(); break; case "CusotmerDistrict": ObjLoan.DistrictName = txtSearchCustomer.Text.ToString(); break; default: break; } } else { ObjLoan.CustomerCode = string.Empty; ObjLoan.CoustmerName = string.Empty; ObjLoan.DistrictName = string.Empty; } dtLoan = ObjLoan.LoanWithSearchFilters(); if (dtLoan.Rows.Count > 0) { gvCustomerLoan.DataSource = dtLoan; } else { gvCustomerLoan.DataSource = null; } gvCustomerLoan.PageSize = Convert.ToInt32(ddlPager.SelectedValue.ToString()); gvCustomerLoan.DataBind(); } catch { } finally { ObjLoan = null; ObjLoan = null; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvCustomerLoan_RowEditing(object sender, GridViewEditEventArgs e) { ObjLoan = new clsLoan(); dtLoan = new DataTable(); clsComFun = new CommonFunctions(); int iLoanId; string strValue = string.Empty; int intMonth = 0, intYear = 0; try { //BindLoanTypes(); iLoanId = Convert.ToInt32(((Label)gvCustomerLoan.Rows[e.NewEditIndex].FindControl("lblLoanId")).Text); if (iLoanId > 0) { ObjLoan.LoanId = iLoanId; dtLoan = ObjLoan.LoanWithSearchFilters(); if (dtLoan.Rows.Count > 0) { //Fill Loan Details hdnCustomerId.Value = dtLoan.Rows[0]["CustomerId"].ToString(); hdnLoanId.Value = dtLoan.Rows[0]["LoanID"].ToString(); //Loan Details txtLoanDate.Text = dtLoan.Rows[0]["LoanDate"].ToString(); ddlLoanType.SelectedValue = dtLoan.Rows[0]["LoanTypeID"].ToString(); txtLoanAmt.Text = CommonFunctions.FormatMoneyString(Convert.ToDecimal(dtLoan.Rows[0]["LoanAmount"])); txtEmiAmt.Text = CommonFunctions.FormatMoneyString(Convert.ToDecimal(dtLoan.Rows[0]["InstallmentAmount"])); strValue = dtLoan.Rows[0]["LoanPeriod"].ToString(); intYear = (System.Convert.ToInt32(strValue) / 12); ddlLoanYear.SelectedValue = intYear.ToString(); intMonth = (System.Convert.ToInt32(strValue) - (intYear * 12)); ddlLoanMonth.SelectedValue = intMonth.ToString(); ddlCustomerPastLoanEMI.SelectedValue = dtLoan.Rows[0]["LoanPaidTypeID"].ToString(); txtCustomerLoanPurpose.Text = dtLoan.Rows[0]["LoanReason"].ToString(); txtTotalLoanInstallmentAmt.Text = CommonFunctions.FormatMoneyString(Convert.ToDecimal(dtLoan.Rows[0]["TotalInstallment"])); BindCustomerDetails(Convert.ToInt64(dtLoan.Rows[0]["CustomerId"].ToString())); BindWitnessDetails(Convert.ToInt64(dtLoan.Rows[0]["WitnessID1"]), "1"); BindWitnessDetails(Convert.ToInt64(dtLoan.Rows[0]["WitnessID2"]), "2"); BindWitnessDetails(Convert.ToInt64(dtLoan.Rows[0]["WitnessID3"]), "3"); BindWitnessDetails(Convert.ToInt64(dtLoan.Rows[0]["WitnessID4"]), "4"); EnableDisabledControls(false); ShowHideLoanGrid(false); ShowHideLoanWitnessFields(false); } } } catch (Exception) { } finally { ObjLoan = null; ObjCust = null; dtLoan = null; } ShowHideLoanGrid(false); EnableDisabledControls(false); }
partial void AddButtonPushed(AppKit.NSButton sender) { // store values string address = this.AddressBox.StringValue; string town = this.TownBox.StringValue; string county = this.CountyBox.StringValue; string state = this.StateBox.StringValue; int titleHolderID = clsEntity.EntityID(this.TitleHolderPopUp.TitleOfSelectedItem); int coID = clsEntity.EntityID(this.CoBorrowerPopUp.TitleOfSelectedItem); int lenderID = clsEntity.EntityID(this.LenderPopUp.TitleOfSelectedItem); int titleID = clsEntity.EntityID(this.TitlePopUp.TitleOfSelectedItem); DateTime acquisitionDate = (DateTime)this.PurchaseDatePicker.DateValue; double price = this.PurchasePriceBox.DoubleValue; double bpo = this.BPOBox.DoubleValue; double rehabCost = this.RehabCostBox.DoubleValue; double pnl = this.PnLBox.DoubleValue; double months = this.MonthsToCompletionBox.DoubleValue; double loanRate = this.LoanRateBox.DoubleValue; double penaltyRate = this.DefaultRateBox.DoubleValue; double points = this.PointsBox.DoubleValue; double profitSplit = this.ProfitSplitBox.DoubleValue; bool acqOnly = (this.AcquisitionOnlyCheckBox.State == NSCellStateValue.On); bool bfullAcqCostFunded = (this.FullAcquisitionCostCheckBox.State == NSCellStateValue.On); double initialFundingMult = this.InitialLoanPercentBox.DoubleValue; // acquisition cost estimates CostEstimate costEstimateForState; double initialDraw = -4500D; double programFee = -2000D; double otherBudgetedCosts = initialDraw - programFee; // accounting, travel, utilities, inspections, etc. double concessionPercentage = 0.02; double commissionPercentage = 0.06; double totalBackEndCosts; // other stuff double dispostion; double totalCommitment; double upfrontCommitment; double hardInterestGuess; double pnlGuess; int streetNumber; string streetName; this.UpdateMessage.StringValue = ""; // check State.length == 2 if (state.Length != 2) { this.UpdateMessage.StringValue = "Invalid State ID (Length must be 2)"; } // check date > today else if (acquisitionDate < System.DateTime.Today) { this.UpdateMessage.StringValue = "Acquisition Date can not be in the past."; } // check no duplicates in entities else if ((titleHolderID == lenderID) || (titleHolderID == titleID) || (coID == lenderID) || (coID == titleID) || (lenderID == titleID)) { this.UpdateMessage.StringValue = "Duplicate Entities - please check TitleHolder, CoBorrower, Lender and Title Company"; } // check address has numbers and letters else if ((!Int32.TryParse(System.Text.RegularExpressions.Regex.Match(address, @"\d+").Value, out streetNumber)) || (streetName = System.Text.RegularExpressions.Regex.Replace(address, streetNumber.ToString(), "").Trim()) == "") { this.UpdateMessage.StringValue = "Invalid Street Address, must be {streetnumber} {streetname}"; } // check all values are positive else if (price * months * bpo < 0.001) { this.UpdateMessage.StringValue = "Missing Values in price, BPO, or Months"; } else if ((rehabCost <= 0) && (!acqOnly)) { this.UpdateMessage.StringValue = "Rehab cost missing for non-acquisition-only loan"; } else if ((pnl <= 0) && (profitSplit > 0)) { this.UpdateMessage.StringValue = "Esimtated PnL Missing or Negative for loan with profit split"; } // check things like lender elgible, borrower eligible, title company state eligible // Check valid address?? // Check county?? else { // Create new Property, Loan and Documents in tables if (coID == -1) { coID = titleHolderID; } clsProperty newProperty = new clsProperty(address, town, county, state, bpo, streetName); newProperty.Save(); clsLoan newLoan = new clsLoan(newProperty.ID(), titleHolderID, coID, titleID, lenderID, acquisitionDate, acquisitionDate.AddMonths(9), loanRate, penaltyRate, points, profitSplit, acqOnly); int newLoanID = newLoan.ID(); for (int i = 0; i < Enum.GetValues(typeof(clsDocument.Type)).Length; i++) { clsDocument newDoc = new clsDocument(((clsDocument.Type)i).ToString(), newProperty.ID(), (clsDocument.Type)i); newDoc.Save(); } #region Create Cashflows, contingent on Loan Parameters costEstimateForState = new CostEstimate(state, price, bpo, months); if (bfullAcqCostFunded) { totalCommitment = (price + rehabCost - initialDraw - costEstimateForState.AcquisitionClosingCosts) / (1D - points * 0.01); upfrontCommitment = (totalCommitment - rehabCost / (1D - points * 0.01)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, -price, false, clsCashflow.Type.AcquisitionPrice)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, 0D, false, clsCashflow.Type.AcquisitionConcession)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, costEstimateForState.ProcessingCost, false, clsCashflow.Type.AcquisitionProcessing)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, costEstimateForState.RecordingCost, false, clsCashflow.Type.AcquisitionRecording)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, costEstimateForState.AcquisitionTaxes, false, clsCashflow.Type.AcquisitionTaxes)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, costEstimateForState.HOICost, false, clsCashflow.Type.HomeownersInsurance)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, initialDraw, false, clsCashflow.Type.InitialExpenseDraw)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, costEstimateForState.TitlePolicyCost, false, clsCashflow.Type.TitlePolicy)); if (points > 0) { // upfront points newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, 0.01 * points * upfrontCommitment, false, clsCashflow.Type.Points)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, -0.01 * points * upfrontCommitment, false, clsCashflow.Type.Points)); } if (!acqOnly) { // assume entire rehab draw comes halfway through the rehab process, and that there is a two month lag from rehab completion to sale closing newLoan.AddCashflow(new clsCashflow(acquisitionDate.AddMonths((int)(0.5 * (months - 2D))), System.DateTime.Today, System.DateTime.MaxValue, newLoanID, -rehabCost, false, clsCashflow.Type.RehabDraw)); if (points > 0) { // points on construction draws newLoan.AddCashflow(new clsCashflow(acquisitionDate.AddMonths((int)(0.5 * (months - 2D))), System.DateTime.Today, System.DateTime.MaxValue, newLoanID, 0.01 * points * rehabCost / (1D - points * 0.01), false, clsCashflow.Type.Points)); newLoan.AddCashflow(new clsCashflow(acquisitionDate.AddMonths((int)(0.5 * (months - 2D))), System.DateTime.Today, System.DateTime.MaxValue, newLoanID, -0.01 * points * rehabCost / (1D - points * 0.01), false, clsCashflow.Type.Points)); } } } else { totalCommitment = price * initialFundingMult; newLoan.AddCashflow(new clsCashflow(acquisitionDate, DateTime.Today, DateTime.MaxValue, newLoanID, -price, false, clsCashflow.Type.AcquisitionPrice)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, DateTime.Today, DateTime.MaxValue, newLoanID, -price * (initialFundingMult - 1D), false, clsCashflow.Type.InitialExpenseDraw)); if (points > 0) { newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, 0.01 * points * totalCommitment, false, clsCashflow.Type.Points)); } } // disposition cashflow hardInterestGuess = (totalCommitment - 0.5 * rehabCost) * (months / 12D) * loanRate; if (profitSplit > 0) { totalBackEndCosts = costEstimateForState.SaleTaxes + hardInterestGuess + bpo * (concessionPercentage + commissionPercentage); pnlGuess = bpo - (totalCommitment + totalBackEndCosts); if (!bfullAcqCostFunded) { pnlGuess += -totalCommitment * points * 0.01; } // if points were payed upfront, subtract from PnL UpdateMessage.StringValue += "\n Estimated vs Quoted PnL: \t"; UpdateMessage.StringValue += pnlGuess.ToString("000,000.00") + " vs " + pnl.ToString("000,000.00"); } else { pnlGuess = 0D; } dispostion = totalCommitment + hardInterestGuess + profitSplit * pnl; // user-given pnl rather than system estimate newLoan.AddCashflow(new clsCashflow(acquisitionDate.AddMonths((int)months), System.DateTime.Today, System.DateTime.MaxValue, newLoanID, dispostion, false, clsCashflow.Type.NetDispositionProj)); #endregion newLoan.SetNewOriginationDate(acquisitionDate); newLoan.Save(); // write summary to text label (this.UpdateMessage.StringValue) this.UpdateMessage.StringValue += String.Format("\n\nCompleted adding new loan ({0}), new cashflows, new property ({1}), and new docs ", newLoan.ID().ToString(), newProperty.ID().ToString()); } }
partial void PropertyChosen(AppKit.NSComboBox sender) { if (this.AddressComboBox.StringValue != "") { this.loanToUpdate = new clsLoan(clsLoan.LoanID(this.AddressComboBox.StringValue)); DateTime OGDate = loanToUpdate.OriginationDate(); this.ClosingDatePicker.DateValue = (NSDate)DateTime.SpecifyKind(OGDate, DateTimeKind.Utc); foreach (clsCashflow cf in this.loanToUpdate.Cashflows()) { if (cf.DeleteDate() > System.DateTime.Today.AddYears(100)) { string amount = (Math.Abs(cf.Amount())).ToString("#,##0.00"); switch (cf.TypeID()) { case clsCashflow.Type.AcquisitionConcession: this.ConcessionLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionPrice: this.PriceLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionProcessing: this.ProcessingLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionRecording: this.RecordingLabel.StringValue = amount; break; case clsCashflow.Type.AcquisitionTaxes: this.AcqTaxLabel.StringValue = amount; break; case clsCashflow.Type.TitlePolicy: this.TitlePolicyLabel.StringValue = amount; break; case clsCashflow.Type.HomeownersInsurance: this.HOILabel.StringValue = amount; break; case clsCashflow.Type.InitialExpenseDraw: this.InitialDrawLabel.StringValue = amount; break; case clsCashflow.Type.PropertyTax: this.PropertyTaxLabel.StringValue = amount; break; default: break; } } } this.HOIField.StringValue = this.HOILabel.StringValue; this.PriceField.StringValue = this.PriceLabel.StringValue; this.AcqTaxField.StringValue = this.AcqTaxLabel.StringValue; this.RecordingField.StringValue = this.RecordingLabel.StringValue; this.ConcessionField.StringValue = this.ConcessionLabel.StringValue; this.ProcessingField.StringValue = this.ProcessingLabel.StringValue; this.ClosingDatePicker.DateValue = (NSDate)DateTime.SpecifyKind(this.loanToUpdate.OriginationDate(), DateTimeKind.Utc); this.InitialDrawField.StringValue = this.InitialDrawLabel.StringValue; this.PropertyTaxField.StringValue = this.PropertyTaxLabel.StringValue; this.TitlePolicyField.StringValue = this.TitlePolicyLabel.StringValue; } }
partial void AddButtonPushed(AppKit.NSButton sender) { // store values string address = this.AddressBox.StringValue; string town = this.TownBox.StringValue; string county = this.CountyBox.StringValue; string state = this.StateBox.StringValue; int titleHolderID = (int)this.TitleHolderPopUp.IndexOfSelectedItem - 3; int coID = (int)this.CoBorrowerPopUp.IndexOfSelectedItem - 3; int lenderID = (int)this.LenderPopUp.IndexOfSelectedItem - 3; int titleID = (int)this.TitlePopUp.IndexOfSelectedItem - 3; DateTime acquisitionDate = (DateTime)this.PurchaseDatePicker.DateValue; double price = this.PurchasePriceBox.DoubleValue; double bpo = this.BPOBox.DoubleValue; double rehabCost = this.RehabCostBox.DoubleValue; double pnl = this.PnLBox.DoubleValue; double months = this.MonthsToCompletionBox.DoubleValue; double loanRate = 0.09; double penaltyRate = 0.05; // acquisition cost estimates double processingCost; double recordingCost; double acquisitionTaxes; double titlePolicyCost; double HOICost; double propertyTaxes; double initialDraw = -4500D; double programFee = -2000D; double commissions; double transferTax; double proRatedPropertyTax; double otherBudgetedCosts = initialDraw - programFee; // accounting, travel, utilities, inspections, etc. double concessionPercentage = 0.02; double commissionPercentage = 0.06; double totalBackEndCosts; // other stuff double dispostion; double totalCommitment; double hardInterestGuess; double pnlGuess; int streetNumber; string streetName; this.UpdateMessage.StringValue = ""; // check State.length == 2 if (state.Length != 2) { this.UpdateMessage.StringValue = "Invalid State ID (Length must be 2)"; } // check date > today else if (acquisitionDate < System.DateTime.Today) { this.UpdateMessage.StringValue = "Acquisition Date can not be in the past."; } // check no duplicates in entities else if ((titleHolderID == coID) || (titleHolderID == lenderID) || (titleHolderID == titleID) || (coID == lenderID) || (coID == titleID) || (lenderID == titleID)) { this.UpdateMessage.StringValue = "Duplicate Entities - please check TitleHolder, CoBorrower, Lender and Title Company"; } // check address has numbers and letters else if ((!Int32.TryParse(System.Text.RegularExpressions.Regex.Match(address, @"\d+").Value, out streetNumber)) || (streetName = System.Text.RegularExpressions.Regex.Replace(address, streetNumber.ToString(), "").Trim()) == "") { this.UpdateMessage.StringValue = "Invalid Street Address, must be {streetnumber} {streetname}"; } // check all values are positive else if (price * rehabCost * months * pnl * bpo < 0.001) { this.UpdateMessage.StringValue = "Missing Values in price, rehab, PnL, BPO, or Months"; } // check things like lender elgible, borrower eligible, title company state eligible // Check valid address?? // Check county?? else { // calculate estimated acquisition costs switch (state) { case "NJ": processingCost = -1150D; recordingCost = -415D; acquisitionTaxes = 0D; titlePolicyCost = -620 - 0.0044 * price; HOICost = -450 - 0.0054 * price; propertyTaxes = -0.015 * price; proRatedPropertyTax = bpo * 0.002 * months; // roughly 2.4% per year in NJ transferTax = bpo * 0.01; break; case "MD": processingCost = -875D; recordingCost = -1090D - 0.0025 * price; acquisitionTaxes = -190D - 0.0066 * price; titlePolicyCost = -463D - 0.0042 * price; HOICost = -1017D - 0.0025 * price; propertyTaxes = -0.009 * price; proRatedPropertyTax = bpo * 0.0009 * months; // roughly 1.1% per year in MD transferTax = bpo * 0.01; break; case "PA": processingCost = -250D; recordingCost = -425D - 0.0025 * price; acquisitionTaxes = -450D - 0.02 * price; titlePolicyCost = -1330D - 0.005 * price; HOICost = -417D - 0.0144 * price; propertyTaxes = -0.017 * price; proRatedPropertyTax = bpo * 0.00125 * months; // roughly 1.5% per year in PA transferTax = bpo * 0.01; break; default: processingCost = -250D; recordingCost = -425D - 0.0025 * price; acquisitionTaxes = -450D - 0.02 * price; titlePolicyCost = -1330D - 0.005 * price; HOICost = -417D - 0.0144 * price; propertyTaxes = -0.017 * price; proRatedPropertyTax = bpo * 0.00125 * months; // roughly 1.5% per year in PA transferTax = bpo * 0.01; break; } // calculate rough estimated other costs totalCommitment = price + rehabCost - (initialDraw + processingCost + recordingCost + acquisitionTaxes + titlePolicyCost + HOICost + propertyTaxes); commissions = bpo * commissionPercentage; // total back end costs are Accrued Property Tax, Sale Transfer Tax (typically split with buyer), Sale Commissons, // seller concession / assistance, and Hard Interest hardInterestGuess = (totalCommitment - 0.5 * rehabCost) * (months / 12D) * loanRate; totalBackEndCosts = proRatedPropertyTax + transferTax + commissions + hardInterestGuess + bpo * concessionPercentage; pnlGuess = bpo - (totalCommitment + totalBackEndCosts); // Check estimated PnL based on State, Purchase, Rehab - Message Box variance, reject if outside $X UpdateMessage.StringValue += "\n Estimated vs Quoted PnL: \t"; UpdateMessage.StringValue += pnlGuess.ToString("000,000.00") + " vs " + pnl.ToString("000,000.00"); dispostion = totalCommitment + hardInterestGuess + 0.5 * pnlGuess; // if valid, then create new property, new loan, new cashflows, new documents clsProperty newProperty = new clsProperty(address, town, county, state, bpo, streetName); newProperty.Save(); clsLoan newLoan = new clsLoan(newProperty.ID(), titleHolderID, coID, titleID, lenderID, acquisitionDate, acquisitionDate.AddMonths(9), loanRate, penaltyRate); int newLoanID = newLoan.ID(); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, -price, false, clsCashflow.Type.AcquisitionPrice)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, 0D, false, clsCashflow.Type.AcquisitionConcession)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, processingCost, false, clsCashflow.Type.AcquisitionProcessing)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, recordingCost, false, clsCashflow.Type.AcquisitionRecording)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, acquisitionTaxes, false, clsCashflow.Type.AcquisitionTaxes)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, HOICost, false, clsCashflow.Type.HomeownersInsurance)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, initialDraw, false, clsCashflow.Type.InitialExpenseDraw)); newLoan.AddCashflow(new clsCashflow(acquisitionDate, System.DateTime.Today, System.DateTime.MaxValue, newLoanID, titlePolicyCost, false, clsCashflow.Type.TitlePolicy)); // assume entire rehab draw comes halfway through the rehab process, and that there is a two month lag from rehab completion to sale closing newLoan.AddCashflow(new clsCashflow(acquisitionDate.AddMonths((int)(0.5 * (months - 2D))), System.DateTime.Today, System.DateTime.MaxValue, newLoanID, -rehabCost, false, clsCashflow.Type.RehabDraw)); // disposition cashflow newLoan.AddCashflow(new clsCashflow(acquisitionDate.AddMonths((int)months), System.DateTime.Today, System.DateTime.MaxValue, newLoanID, dispostion, false, clsCashflow.Type.NetDispositionProj)); newLoan.SetNewOriginationDate(acquisitionDate); newLoan.Save(); // Create Documents for (int i = 0; i < Enum.GetValues(typeof(clsDocument.Type)).Length; i++) { clsDocument newDoc = new clsDocument(((clsDocument.Type)i).ToString(), newProperty.ID(), (clsDocument.Type)i); newDoc.Save(); } // write summary to text label (this.UpdateMessage.StringValue) this.UpdateMessage.StringValue += String.Format("\n\nCompleted adding new loan ({0}), new cashflows, new property ({1}), and new docs ", newLoan.ID().ToString(), newProperty.ID().ToString()); } }