/// <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); }
protected CreditCard(IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) { CardHolderSince = openedDate.GetValueOrDefault(DateTime.UtcNow); if (expiryDate == null) { ExpDate = Etx.RandomDate(Etx.RandomInteger(4, 6), null); ExpDate = new DateTime(ExpDate.Year, ExpDate.Month, Etx.RandomCoinToss() ? 1 : 15); } else { ExpDate = expiryDate.Value; } if (cardholder != null) { var fname = (cardholder.GetName(KindsOfNames.First) ?? String.Empty).ToUpper(); var lname = (cardholder.GetName(KindsOfNames.Surname) ?? String.Empty).ToUpper(); CardHolderName = string.IsNullOrWhiteSpace(fname) && string.IsNullOrWhiteSpace(lname) ? (cardholder.GetName(KindsOfNames.Legal) ?? String.Empty).ToUpper() : String.Join(" ", fname, lname); } Cvv = $"{Etx.RandomInteger(7, 999),3:D3}"; Number = GetRandomCardNumber(); }
/// <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 TransactionNote(IVoca copyFrom) { if (copyFrom == null) { return; } CopyNamesFrom(copyFrom); }
public static SavingsAccount RandomSavingAccount(IVoca personName = null, DateTime?dt = null) { var dtd = dt.GetValueOrDefault(DateTime.UtcNow); var accountId = new AccountId(Etx.RandomRChars(true)); return(new SavingsAccount(accountId, dtd) { Name = personName?.Name }); }
/// <summary> /// Tries to parse a single item /// from the US Domus Opes data file /// </summary> /// <param name="xmlNode"></param> /// <param name="voca"></param> /// <returns></returns> internal static bool TryParseUsDomusOpesXml(XmlNode xmlNode, out IVoca voca) { voca = null; if (xmlNode == null) { return(false); } if (!(xmlNode is XmlElement xmlElem)) { return(false); } var egs = new List <string>(); var groupName = xmlElem.ParentNode is XmlElement groupElem && groupElem.HasAttributes ? groupElem.GetAttribute("name") : ""; var itemName = xmlElem.GetAttribute("name"); var abbrev = xmlElem.GetAttribute("abbrev"); if (xmlElem.HasChildNodes) { foreach (var cn in xmlElem.ChildNodes) { if (!(cn is XmlElement childElem)) { continue; } if (childElem.LocalName != "eg" || !childElem.HasAttributes) { continue; } var eg = childElem.GetAttribute("name"); if (String.IsNullOrWhiteSpace(eg)) { continue; } egs.Add(eg); } } voca = new VocaBase(itemName); if (!string.IsNullOrWhiteSpace(abbrev)) { voca.AddName(KindsOfNames.Abbrev, abbrev); } if (!string.IsNullOrWhiteSpace(groupName)) { voca.AddName(KindsOfNames.Group, groupName); } return(!string.IsNullOrWhiteSpace(itemName)); }
protected CreditCard(string cardNumber, string cvv, IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : this(cardNumber, cardholder, openedDate, expiryDate) { if (cvv == null) { return; } if (!Regex.IsMatch(cvv, "[0-9]{3}")) { throw new ArgumentException($"The CVV value {cvv} is not valid."); } Cvv = cvv; }
public static CheckingAccount RandomCheckingAccount(IVoca personName = null, DateTime?dt = null, string debitPin = null) { var dtd = dt.GetValueOrDefault(DateTime.UtcNow); var accountId = new AccountId(Etx.RandomRChars(true)); return(CheckingAccount.IsPossiblePin(debitPin) ? new CheckingAccount(accountId, dtd, new Tuple <ICreditCard, string>(CreditCard.RandomCreditCard(personName), debitPin)) : new CheckingAccount(accountId, dtd) { Name = personName?.Name }); }
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> /// 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)); }
protected CreditCard(string cardNumber, IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : this( cardholder, openedDate, expiryDate) { var ccNum = GetRandomCardNumber(); if (string.IsNullOrWhiteSpace(cardNumber)) { return; } if (!ccNum.Validate(cardNumber)) { throw new ArgumentException($"The card number {cardNumber} is not valid."); } ccNum.Value = cardNumber; }
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); }
protected internal IAccount <Identifier> Get(IVoca name) { foreach (var acct in _dataStore) { var acctName = acct as IVoca; if (acctName == null) { continue; } if (VocaBase.Equals(acctName, name)) { return(acct); } } return(null); }
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)); }
protected VitalRecord(IVoca personName) { if (personName == null) { return; } PersonFullName = NfString.DistillSpaces( string.Join(" ", personName.GetName(KindsOfNames.First), personName.GetName(KindsOfNames.Surname))); if (string.IsNullOrWhiteSpace(PersonFullName)) { PersonFullName = personName.GetName(KindsOfNames.Legal); } }
public AmericanDeathCert(MannerOfDeath mannerOfDeath, IVoca personName) : this(mannerOfDeath, (string)null) { if (personName == null) { return; } PersonFullName = NfString.DistillSpaces( string.Join(" ", personName.GetName(KindsOfNames.First), personName.GetName(KindsOfNames.Middle), personName.GetName(KindsOfNames.Surname))); if (string.IsNullOrWhiteSpace(PersonFullName)) { PersonFullName = personName.GetName(KindsOfNames.Legal); } }
public AmericanBirthCert(IVoca personName) : base((IVoca)null) { if (personName == null) { return; } PersonFullName = NfString.DistillSpaces( string.Join(" ", personName.GetName(KindsOfNames.First), personName.GetName(KindsOfNames.Middle), personName.GetName(KindsOfNames.Surname))); if (string.IsNullOrWhiteSpace(PersonFullName)) { PersonFullName = personName.GetName(KindsOfNames.Legal); } }
public TraceTransactionId GetThisAsTraceId(DateTime?atTime = null, IVoca journalName = null) { var dt = atTime ?? AtTime; //get copy of myself as a transaction id var innerTrace = new TraceTransactionId(this, dt); //with this, consider linked-list of trace as journal -> myself -> my-trace if (journalName != null && journalName.AnyNames()) { innerTrace = new TraceTransactionId(this, dt, journalName) { Trace = new TraceTransactionId(this) }; } return(innerTrace); }
public static ICreditCard RandomCreditCard(IVoca cardholder, DateTime?openedDate = null) { var fk = Etx.RandomInteger(0, 3); var dt = openedDate ?? Etx.RandomDate(-3, null); switch (fk) { case 0: return(new MasterCardCc(cardholder, dt, dt.AddYears(3))); case 2: return(new AmexCc(cardholder, dt, dt.AddYears(3))); case 3: return(new DiscoverCc(cardholder, dt, dt.AddYears(3))); default: return(new VisaCc(cardholder, dt, dt.AddYears(3))); } }
/// <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)); }
public AmexCc(IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : base(cardholder, openedDate, expiryDate) { }
public AmexCc(string cardNumber, IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : base( cardNumber, cardholder, openedDate, expiryDate) { }
public MasterCardCc(string cardNumber, string cvv, IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : base(cardNumber, cvv, cardholder, openedDate, expiryDate) { }
public MasterCardCc(IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : base(cardholder, openedDate, expiryDate) { }
/// <summary> /// Allows for class level overrides -default is the static VocaBase.Equals /// </summary> public virtual bool NamesEqual(IVoca voca1, IVoca voca2) { return(VocaBase.Equals(voca1, voca2)); }
/// <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); }
public BirthCert(IVoca personName) : base(personName) { }
public DiscoverCc(IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : base(cardholder, openedDate, expiryDate) { }
public TraceTransactionId(ITransaction transactionId, DateTime?atTime = null, IVoca description = null) { if (transactionId == null) { throw new ArgumentNullException(nameof(transactionId)); } Description = description ?? transactionId.Description; AtTime = atTime ?? transactionId.AtTime; UniqueId = transactionId.UniqueId; Trace = transactionId.Trace; Phase = transactionId.Phase; }
private Transaction(DateTime atTime, Pecuniam amt, IVoca description = null) : base(atTime, description) { Cash = amt ?? Pecuniam.Zero; }