public VariableRateLoan(DateTime openedDate, Pecuniam amount) : base(openedDate, amount) { if (amount != null && amount.Amount != 0) { Balance.AddPositiveValue(openedDate, amount.GetAbs(), new TransactionNote("Initial Transaction")); } }
public static Rent RandomRent(Identifier property = null, double?totalYearlyRent = null) { var avgRent = totalYearlyRent ?? 0D; var randRent = Pecuniam.Zero; if (avgRent == 0D) { avgRent = (double)GetAvgAmericanRentByYear(null).Amount; var stdOfAvgRent = avgRent * 0.43759; var lower = (int)Math.Round(avgRent - (stdOfAvgRent * 3)); var upper = (int)Math.Round(avgRent + (stdOfAvgRent * 3)); randRent = Pecuniam.RandomPecuniam(lower, upper, 100); } else { randRent = avgRent.ToPecuniam(); } var randTerm = Etx.RandomPickOne(new[] { 24, 18, 12, 6 }); var randDate = Etx.RandomDate(0, DateTime.Today.AddDays(-2), true); var randDepositAmt = (int)Math.Round((randRent.Amount - randRent.Amount % 250) / 2); var randDeposit = new Pecuniam(randDepositAmt); var rent = new Rent(property, randDate, randTerm, randRent, randDeposit); return(rent); }
public Pecuniam GetRandomMax(DateTime?dt) { if (!int.TryParse(Value, out var ccScore)) { return(new Pecuniam(1000)); } if (ccScore >= 800) { return(Pecuniam.RandomPecuniam(10000, 20000, 100)); } if (ccScore >= 750) { return(Pecuniam.RandomPecuniam(5000, 10000, 100)); } if (ccScore >= 700) { return(Pecuniam.RandomPecuniam(3000, 5000, 100)); } if (ccScore >= 600) { return(Pecuniam.RandomPecuniam(1000, 2000, 100)); } return(new Pecuniam(1000)); }
public Rent(Identifier property, DateTime signing, int forMonths, Pecuniam monthlyRent, Pecuniam deposit) : base(signing) { //calc number of days till the first day of the next month if (signing.Day != 1) { _dtOfFirstFullRentDue = signing.Month == 12 ? new DateTime(signing.Year + 1, 1, _dayOfMonthRentDue) : new DateTime(signing.Year, signing.Month + 1, _dayOfMonthRentDue); var tsTillNextMonth = _dtOfFirstFullRentDue - signing; _proRatedAmt = new Pecuniam(Math.Round(monthlyRent.Amount / 30 * (tsTillNextMonth.Days - 1), 2)); } else { _proRatedAmt = Pecuniam.Zero; _dtOfFirstFullRentDue = signing; } Terminus = _dtOfFirstFullRentDue.AddMonths(forMonths); var fullTermAmt = _proRatedAmt + new Pecuniam(monthlyRent.Amount * forMonths); Balance.AddPositiveValue(signing, fullTermAmt, new TransactionNote("Lease Signing")); LeaseTermInMonths = forMonths; Deposit = deposit; MonthlyPmt = monthlyRent; Id = property; DueFrequency = DefaultDueFrequency; FormOfCredit = Enums.FormOfCredit.None; }
public SecuredFixedRateLoan(Identifier property, DateTime openedDate, Pecuniam totalCost, float rate, int termInYears) : base( openedDate, CreditCardAccount.DF_MIN_PMT_RATE, totalCost) { PropertyId = property; if (totalCost == null || totalCost == Pecuniam.Zero) { throw new ArgumentException("You must pass in a valid amount."); } //interest rate must be a positive number _rate = Math.Abs(rate); //handle if caller passes in rate like 5.5 meaning they wanted 0.055 if (_rate > 1) { _rate = Convert.ToSingle(Math.Round(_rate / 100, 4)); } //calc the monthly payment var fv = totalCost.Amount.PerDiemInterest(rate, DaysPerYear * termInYears, DaysPerYear); _monthlyPayment = new Pecuniam(Math.Round(fv / (termInYears * 12), 2)); _minPaymentRate = fv == 0 ? CreditCardAccount.DF_MIN_PMT_RATE : (float)Math.Round(_monthlyPayment.Amount / fv, 6); _termInYears = termInYears; }
public Pecuniam GetCurrent(DateTime dt, Dictionary <DateTime, float> variableRate) { if (variableRate == null || variableRate.Keys.Count <= 0) { throw new ArgumentNullException(nameof(variableRate)); } //get very first recorded transaction var oldestTransaction = FirstTransaction; if (oldestTransaction == null) { return(Pecuniam.Zero); } var bal = Pecuniam.Zero; //set first transaction as the lower bounds of the current time-frame var prevVdt = oldestTransaction.AtTime; foreach (var vdt in variableRate.Keys) { //the dictionary is the date the rate ended, not began if (DateTime.Compare(prevVdt, dt) > 0) { continue; } var currVdt = vdt; //this rate was only applicable to this many days var daysAtRate = (currVdt - prevVdt).TotalDays; //this iteration's rate-ending-date is actually beyond our query date if (DateTime.Compare(currVdt, dt) > 0) { daysAtRate = (dt - prevVdt).TotalDays; currVdt = dt; } //get those transactions which occured between var betwixtTs = GetTransactions(prevVdt, currVdt); betwixtTs.Sort(Comparer); //add in this date-ranges transactions to the running balance bal = betwixtTs.Aggregate(bal, (current, bts) => current + bts.Cash); //get the balance plus interest for the number of days this rate was in effect bal = new Pecuniam(bal.Amount.PerDiemInterest(variableRate[vdt], daysAtRate, DaysPerYear)); //save where we ended this time for next iteration prevVdt = currVdt; } return(bal); }
protected LoanBase(DateTime openedDate, Pecuniam amount) : base(openedDate) { if (amount != null && amount.Amount != 0) { Balance.AddPositiveValue(openedDate, amount.GetAbs(), new TransactionNote("Initial Transaction")); } FormOfCredit = Enums.FormOfCredit.Installment; DueFrequency = DefaultDueFrequency; _minPaymentRate = DF_MIN_PMT_RATE; }
/// <summary> /// Helper method to put functionality in common vernacular /// - is the exact same as AddPositiveValue /// </summary> public virtual void Deposit(DateTime dt, Pecuniam amount, string note = null) { if (string.IsNullOrWhiteSpace(note)) { AddPositiveValue(dt, amount); } else { AddPositiveValue(dt, amount, new TransactionNote(note)); } }
public virtual IAccount <Identifier> Credit(Pecuniam amt, IVoca note = null, DateTime?atTime = null, ITransactionId trace = null) { var dt = atTime ?? Balance.LastTransaction.AtTime; if (IsOppositeForm) { AddPositiveValue(dt, amt, note, trace); } else { AddNegativeValue(dt, amt, note, trace); } return(this); }
/// <summary> /// Gets the difference of the current /// market value to the remaining balance on the note. /// </summary> /// <param name="dt"> /// The date of query. /// </param> /// <param name="marketValue"> /// </param> /// <returns></returns> public virtual Pecuniam GetEquityAt(DateTime?dt, Pecuniam marketValue = null) { var qDt = dt ?? DateTime.Today; if (qDt < Inception) { return(Pecuniam.Zero); } var qRemaining = GetValueAt(qDt).GetAbs(); var mv = (marketValue ?? GetEstimatedMarketValueAt(qDt)).GetAbs(); return(mv - qRemaining); }
internal static Guid AddTransaction(ISet <ITransaction> items, DateTime dt, Pecuniam amount, IVoca note = null, ITransactionId trace = null) { if (items == null) { throw new ArgumentNullException(nameof(items)); } var t = new Transaction(dt, amount, note) { Trace = trace }; items.Add(t); return(t.UniqueId); }
public virtual Guid AddNegativeValue(DateTime dt, Pecuniam amount, IVoca note = null, ITransactionId trace = null) { if (amount == null) { return(Guid.Empty); } if (amount == Pecuniam.Zero) { return(Guid.Empty); } while (DataSet.Any(x => DateTime.Compare(x.AtTime, dt) == 0)) { dt = dt.AddTicks(1L); } return(Transaction.AddTransaction(DataSet, dt, amount.GetNeg(), note, trace)); }
public SecuredFixedRateLoan(Identifier property, DateTime openedDate, float minPaymentRate, Pecuniam amount = null) : base(openedDate, minPaymentRate, amount) { PropertyId = property; }
/// <summary> /// Helper method to put functionality in common vernacular /// - is the exact same as <see cref="ITransactionable.AddNegativeValue(DateTime, Pecuniam, IVoca, ITransactionId)"/> /// </summary> public void PayRent(DateTime dt, Pecuniam amount, IVoca note = null) { AddNegativeValue(dt, amount, note); }
protected LoanBase(DateTime openedDate, float minPaymentRate, Pecuniam amount = null) : this(openedDate, amount) { _minPaymentRate = minPaymentRate; }
public FixedRateLoan(DateTime openedDate, float minPaymentRate, Pecuniam amount = null) : base(openedDate, minPaymentRate, amount) { }
/// <summary> /// Creates a new mortgage with the given data /// </summary> /// <param name="property"></param> /// <param name="openedDate"></param> /// <param name="rate"></param> /// <param name="purchasePrice"></param> /// <param name="termInYears"></param> public Mortgage(Identifier property, DateTime openedDate, float rate, Pecuniam purchasePrice, int termInYears = 30) : base(property, openedDate, purchasePrice, rate, termInYears) { FormOfCredit = Enums.FormOfCredit.Mortgage; }
public VariableRateLoan(DateTime openedDate, float minPaymentRate, Pecuniam amt = null) : this(openedDate, amt) { _minPaymentRate = minPaymentRate; }
public FixedRateLoan(DateTime openedDate, Pecuniam amount) : base(openedDate, amount) { }
private Transaction(DateTime atTime, Pecuniam amt, IVoca description = null) : base(atTime, description) { Cash = amt ?? Pecuniam.Zero; }