/// <summary> /// This is the Accounting name for making a purchase (<see cref="MakePurchase"/> /// </summary> public IAccount <Identifier> Credit(Pecuniam amt, IVoca note = null, DateTime?atTime = null, ITransactionId trace = null) { var dt = atTime ?? Balance.LastTransaction.AtTime; AddPositiveValue(dt, amt, note, trace); return(this); }
public void TestEquals() { var test01 = new Pecuniam(138.0M); var test02 = new Pecuniam(138.0M); Assert.IsTrue(test01.Equals(test02)); }
/// <summary> /// Public API method to allow the <see cref="Max"/> to /// be increased and only increased. /// </summary> /// <param name="val"></param> public void IncreaseMaxTo(Pecuniam val) { if (Max != null && Max > val) { return; } Max = val; }
public CreditCardAccount(ICreditCard cc, float minPaymentRate, Pecuniam ccMax = null) : base(cc.CardHolderSince, minPaymentRate <= 0 ? DF_MIN_PMT_RATE : minPaymentRate) { Cc = cc; Max = ccMax ?? new Pecuniam(1000); FormOfCredit = Rand.Sp.Enums.FormOfCredit.Revolving; DueFrequency = new TimeSpan(30, 0, 0, 0); }
/// <summary> /// Applies a payment to the credit card account /// </summary> /// <returns> /// when <see cref="dt"/> is after the expiration date /// </returns> public override Guid AddNegativeValue(DateTime dt, Pecuniam amount, IVoca note = null, ITransactionId trace = null) { if (dt > Cc.ExpDate) { return(Guid.Empty); } return(base.AddNegativeValue(dt, amount, note, trace)); }
public virtual void AddItem(string name, string groupName, double expectedValue, CurrencyAbbrev c = CurrencyAbbrev.USD, DateTime?atTime = null, TimeSpan?dueFrequency = null) { var amt = new Pecuniam(Convert.ToDecimal(expectedValue), c); AddItem(name, groupName, amt, atTime, dueFrequency); }
/// <summary> /// Src https://www.fns.usda.gov/snap/how-much-could-i-receive /// </summary> /// <returns></returns> protected internal virtual Pecuniam GetFoodStampsMonthlyAmount(Pecuniam netAnnualIncome) { if (netAnnualIncome == null) { return(Pecuniam.Zero); } var thirtyPercentAdjIncome = netAnnualIncome.ToDouble() / 12 * 0.3; return(thirtyPercentAdjIncome.ToPecuniam().GetAbs()); }
/// <summary> /// Src https://www.hud.gov/sites/documents/DOC_11750.PDF /// </summary> /// <returns></returns> protected internal virtual Pecuniam GetHudMonthlyAmount(Pecuniam grossAnnualIncome, Pecuniam netAnnualIncome) { if (grossAnnualIncome == null || netAnnualIncome == null) { return(Pecuniam.Zero); } var thirtyPercentAdjIncome = grossAnnualIncome.ToDouble() / 12 * 0.3; var tenPercentGrossIncome = netAnnualIncome.ToDouble() / 12 * 0.1; var sum = thirtyPercentAdjIncome + tenPercentGrossIncome + 25.0D; return(sum.ToPecuniam().GetAbs()); }
/// <summary> /// Applies a purchase transaction to this credit card. /// </summary> /// <returns> /// True when the card is not expired and /// the purchase amount <see cref="amount"/> /// will not cause the total balance to exceed <see cref="Max"/>. /// </returns> public override Guid AddPositiveValue(DateTime dt, Pecuniam amount, IVoca note = null, ITransactionId trace = null) { if (dt > Cc.ExpDate) { return(Guid.Empty); } var cBal = GetValueAt(dt); if (cBal >= Max || cBal + amount >= Max) { return(Guid.Empty); } return(base.AddPositiveValue(dt, amount, note)); }
public void TestDifferentCurrencyIsException() { var usd = new Pecuniam(10M); var yen = new Pecuniam(10M, CurrencyAbbrev.JPY); try { var shouldBlow = usd + yen; Assert.False(false); } catch { Assert.True(true); } }
public void TestOps() { var test00 = Pecuniam.Zero; var test01 = new Pecuniam(1.0M); var testResult = test00 + test01; Assert.AreEqual(1.0M, testResult.Amount); Assert.AreEqual(new Pecuniam(2.0M), new Pecuniam(1.0M) + new Pecuniam(1.0M)); Assert.AreEqual(new Pecuniam(2.0M), new Pecuniam(4.0M) - new Pecuniam(2.0M)); Assert.AreEqual(new Pecuniam(4.0M), new Pecuniam(4.0M) * new Pecuniam(1.0M)); Assert.AreEqual(new Pecuniam(4.0M), new Pecuniam(4.0M) / new Pecuniam(1.0M)); Assert.IsTrue(new Pecuniam(4.0M) > new Pecuniam(3.0M)); Assert.IsTrue(new Pecuniam(1.0M) < new Pecuniam(3.0M)); Assert.IsTrue(new Pecuniam(1.0M) == new Pecuniam(1.0M)); Assert.IsTrue(new Pecuniam(2.0M) != new Pecuniam(1.0M)); }
public void TestGetRandPecuniam() { var testResult = Pecuniam.RandomPecuniam(); Assert.IsNotNull(testResult); Assert.IsFalse(testResult.Equals(Pecuniam.Zero)); testResult = Pecuniam.RandomPecuniam(10000, 99999); Assert.IsNotNull(testResult); var testResultValue = testResult.Amount; Assert.IsTrue(testResultValue >= 10000M && testResultValue <= 99999M); testResult = Pecuniam.RandomPecuniam(10000, 99999, 100); Assert.IsNotNull(testResult); testResultValue = testResult.Amount; Assert.IsTrue(testResultValue >= 10000M && testResultValue <= 99999M); Assert.IsTrue(testResult.Amount % 100M == 0); }
public virtual void AddItem(string name, string groupName, Pecuniam expectedValue, DateTime?atTime = null, TimeSpan?dueFrequency = null) { var amt = expectedValue ?? Pecuniam.Zero; var dt = atTime.GetValueOrDefault(DateTime.UtcNow); var tss = dueFrequency ?? Constants.TropicalYear; var p = new NamedTradeline(new VocaBase(name, DivisionName)) { DueFrequency = tss }; if (amt.Amount < 0M) { p.AddNegativeValue(dt, amt); } else { p.AddPositiveValue(dt, amt); } AddItem(p); }
/// <summary> /// Helper method to put functionality in common vernacular /// - is the exact same as <see cref="AddPositiveValue"/> and <see cref="Debit"/> /// </summary> public virtual Guid MakePayment(DateTime dt, Pecuniam val, IVoca note = null) { return(AddNegativeValue(dt, val, note)); }
protected virtual Pecuniam CalcValue(Pecuniam pecuniam, double d) { pecuniam = pecuniam ?? Pecuniam.Zero; return(Math.Round(pecuniam.ToDouble() * d, 2).ToPecuniam()); }
/// <summary> /// Helper method to put functionality in common vernacular /// - is the exact same as <see cref="AddPositiveValue"/> and <see cref="Credit"/> /// </summary> public Guid MakePurchase(DateTime dt, Pecuniam val, IVoca note = null) { return(AddPositiveValue(dt, val, note)); }
protected override Pecuniam CalcValue(Pecuniam pecuniam, double d) { return(base.CalcValue(pecuniam, d).GetNeg()); }