private void _TestDocument() { for (int i = 0; i < 25; i++) { clsDocument document = new clsDocument(i); Console.WriteLine(document.Name() + "," + document.PropertyAddress() + "," + document.DocumentType().ToString() + "," + ((int)document.DocumentType()).ToString()); } clsCSVTable testTable = new clsCSVTable(clsDocument.strDocumentPath); testTable.SaveAs("/Users/" + Environment.UserName + "/Documents/Professional/Resilience/tblDocumentTest.csv"); clsDocument newDoc = new clsDocument("test", 1, clsDocument.Type.ClosingProtectionLetter); Console.WriteLine(newDoc.Save("/Users/" + Environment.UserName + "/Documents/Professional/Resilience/tblDocumentTest.csv")); }
public string Filename(string znr = "10-13-525480-00-d") { try { pADMS = new clsAPI(); pADMS.SuppressLoginDialog = true; pADMSCatchWords = new clsCatchwords(); pADMSDocuments = new clsDocuments(); pADMSDocument = new clsDocument(); pADMSArchives = new clsArchives(); plSuccess = pADMS.Login("", "", "\\\\PAFS1\\proalpha\\startup\\client\\pastart.xml", "production-rmc", "xDMS", "xmdepass", ""); pADMSCatchWords.AppSrv = pADMS.AppSrv; pADMSDocuments.AppSrv = pADMS.AppSrv; pADMSDocument.AppSrv = pADMS.AppSrv; pADMSArchives.AppSrv = pADMS.AppSrv; pADMSCatchWords.AddCatchword(40, 1006, znr, "", 1); plSuccess = pADMSDocuments.Research(pADMSCatchWords); if (plSuccess) { var result = from clsDocument document in pADMSDocuments from clsArchive archive in document.Archives select new DmsInfo(archive.ArchiveID.ToString(), archive.ArchiveID); return(result.Last().Filename); } } catch (System.Exception) { throw; } return(""); }
private void ScheduleNewSale() { DateTime scheduledSale = (DateTime)this.SaleDatePicker.DateValue; if (scheduledSale <= System.DateTime.Today.Date) { this.StatusMessageTextField.StringValue = "Can't schedule a new sale in the past."; } else { // check to make sure scheduled date is after all rehabs if (scheduledSale < this.loan.FindDate(clsCashflow.Type.RehabDraw, false, true)) { scheduledSale = this.loan.FindDate(clsCashflow.Type.RehabDraw, false, true).AddDays(1); this.StatusMessageTextField.StringValue = "Proposed Sale Date is before last Rehab Date. \nChanging Sale Date to " + scheduledSale.ToString("MM/dd/yyyy"); } double dImpliedAdditional = this.loan.ImpliedAdditionalInterest(); // expire Projected Disposition foreach (clsCashflow cf in this.loan.Cashflows()) { if ((cf.TypeID() == clsCashflow.Type.NetDispositionProj) && (cf.DeleteDate() > System.DateTime.Today.AddYears(50))) { this.StatusMessageTextField.StringValue += "\nProjected Disposition Deleted as of Today."; cf.Delete(System.DateTime.Today); } } // schedule principal repay double dPrincipalRepay = this.loan.LoanAsOf(scheduledSale).Balance(scheduledSale); this.loan.AddCashflow(new clsCashflow(scheduledSale, System.DateTime.Today, System.DateTime.MaxValue, this.loan.ID(), dPrincipalRepay, false, clsCashflow.Type.Principal)); this.StatusMessageTextField.StringValue += "\nPrincipal Added: " + dPrincipalRepay.ToString("000,000.00"); this.StatusMessageTextField.StringValue += "," + scheduledSale.ToString("MM/dd/yyyy"); // schedule hard interest double dHardInterest = this.loan.LoanAsOf(scheduledSale).AccruedInterest(scheduledSale); double perdiem = dHardInterest - this.loan.LoanAsOf(scheduledSale.AddDays(-1)).AccruedInterest(scheduledSale.AddDays(-1)); this.loan.AddCashflow(new clsCashflow(scheduledSale, System.DateTime.Today, System.DateTime.MaxValue, this.loan.ID(), dHardInterest, false, clsCashflow.Type.InterestHard)); this.StatusMessageTextField.StringValue += "\nInterest Added: " + dHardInterest.ToString("000,000.00"); this.StatusMessageTextField.StringValue += "," + scheduledSale.ToString("MM/dd/yyyy"); // schedule additional interest double dAdditionalInterest = this.ExpectedAdditionalInterestTextField.DoubleValue; this.loan.AddCashflow(new clsCashflow(scheduledSale.AddDays(7), System.DateTime.Today, System.DateTime.MaxValue, this.loan.ID(), dAdditionalInterest, false, clsCashflow.Type.InterestAdditional)); this.StatusMessageTextField.StringValue += "\nAddlInt Added: " + dAdditionalInterest.ToString("000,000.00"); this.StatusMessageTextField.StringValue += "," + scheduledSale.AddDays(7).ToString("MM/dd/yyyy"); this.StatusMessageTextField.StringValue += "\nPrev AddlInt: " + dImpliedAdditional.ToString("000,000.00"); this.StatusMessageTextField.StringValue += "\nSave = " + this.loan.Save().ToString(); this.ShowLoanPayoffLetterInfo(dPrincipalRepay, dHardInterest, perdiem); // Record Sale Contract if (this.bRecordSaleContract) { clsDocument saleContract = new clsDocument(clsDocument.DocumentID(this.loan.PropertyID(), clsDocument.Type.SaleContract)); clsDocumentRecord saleContractRecord = new clsDocumentRecord(saleContract.ID(), System.DateTime.Now, (DateTime)this.RecordDatePicker.DateValue, this.loan.CoBorrowerID(), this.loan.LenderID(), clsDocumentRecord.Status.Preliminary, clsDocumentRecord.Transmission.Electronic); if (saleContractRecord.Save()) { this.StatusMessageTextField.StringValue += "\nSale Contract Recorded"; } else { this.StatusMessageTextField.StringValue += "\nSale Contract FAILED TO RECORD"; } } else { this.StatusMessageTextField.StringValue += "\nSale Contract NOT RECORDED"; } } }
partial void propertyMenuChosen(AppKit.NSPopUpButton sender) { documentRecordHistory.StringValue = " "; documentRecordHistory.StringValue += "\t" + "\t" + "\t" + "Sender " + "Reciever " + " Action Date " + "Record Date " + "\n"; clsCSVTable tbl = new clsCSVTable(clsDocument.strDocumentPath); int chosenID = clsLoan.LoanID(propertyMenu.TitleOfSelectedItem); Console.WriteLine(chosenID.ToString()); System.Collections.Generic.List <clsDocument> documentList = new System.Collections.Generic.List <clsDocument>(); System.Collections.Generic.List <int> documentlistIDs = new System.Collections.Generic.List <int>(); for (int i = 0; i < tbl.Length(); i++) { if (chosenID.ToString() == tbl.Value(i, clsDocument.PropertyColumn)) { clsDocument document = new clsDocument(i); documentList.Add(document); Console.Write(tbl.Value(i, clsDocument.PropertyColumn)); documentlistIDs.Add(i); } } clsCSVTable documentRecordTable = new clsCSVTable(clsDocumentRecord.strDocumentRecordPath); clsCSVTable tblEntities = new clsCSVTable(clsEntity.strEntityPath); for (int iDocIndex = 0; iDocIndex < documentlistIDs.Count; iDocIndex++) { int docID = documentlistIDs[iDocIndex]; documentRecordHistory.StringValue += documentList[iDocIndex].Name() + "\n"; for (int i = 0; i < documentRecordTable.Length(); i++) { if (documentRecordTable.Value(i, clsDocumentRecord.DocumentColumn) == docID.ToString()) { int senderID = Int32.Parse(documentRecordTable.Value(i, clsDocumentRecord.SenderColumn)); int receiverID = Int32.Parse(documentRecordTable.Value(i, clsDocumentRecord.ReceiverColumn)); int status = Int32.Parse(documentRecordTable.Value(i, clsDocumentRecord.StatusColumn)); int transmission = Int32.Parse(documentRecordTable.Value(i, clsDocumentRecord.TransmissionColumn)); Console.WriteLine(documentRecordTable.Value(i, clsDocumentRecord.DocumentColumn)); //documentRecordHistory.StringValue += "Doc record ID: " + i + ", Action date: " + (documentRecordTable.Value(i, clsDocumentRecord.ActionDateColumn)) + ", Record date: "+ (documentRecordTable.Value(i, clsDocumentRecord.RecordDateColumn)) + ", Sender ID: " + (documentRecordTable.Value(i, clsDocumentRecord.SenderColumn)) + ", Reciever ID: " + (documentRecordTable.Value(i, clsDocumentRecord.ReceiverColumn)) + ", Status: " + (documentRecordTable.Value(i, clsDocumentRecord.StatusColumn)) + ", Transmission method: " + (documentRecordTable.Value(i, clsDocumentRecord.TransmissionColumn)) + "\n"; string Sender = tblEntities.Value(senderID, clsEntity.NameColumn); string Reciever = tblEntities.Value(receiverID, clsEntity.NameColumn); clsDocumentRecord.Status Status = (clsDocumentRecord.Status)(status); string StatusString = Status.ToString(); //Titles if (Sender.Length > 15) { Sender = Sender.Substring(0, 15); } else { while (Sender.Length < 15) { Sender = Sender + " "; } } documentRecordHistory.StringValue += "\t" + "\t" + "\t" + Sender; // Now it is the reciever length if (Reciever.Length > 15) { Reciever = Reciever.Substring(0, 15); } else { while (Reciever.Length < 15) { Reciever = Reciever + " "; } } documentRecordHistory.StringValue += ", " + Reciever; documentRecordHistory.StringValue += ", " + DateTime.Parse(documentRecordTable.Value(i, clsDocumentRecord.ActionDateColumn)).ToString("MM/dd/yy hh:mm"); documentRecordHistory.StringValue += ", " + DateTime.Parse(documentRecordTable.Value(i, clsDocumentRecord.RecordDateColumn)).ToString("MM/dd/yy hh:mm"); while (StatusString.Length < 12) { StatusString = StatusString + " "; } documentRecordHistory.StringValue += ", " + StatusString; documentRecordHistory.StringValue += ", " + (clsDocumentRecord.Transmission)(transmission) + "\n"; } } } }
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()); } }
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()); } }