Пример #1
0
        /// <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);
        }
Пример #2
0
        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();
        }
Пример #3
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));
 }
Пример #4
0
 public TransactionNote(IVoca copyFrom)
 {
     if (copyFrom == null)
     {
         return;
     }
     CopyNamesFrom(copyFrom);
 }
Пример #5
0
        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
            });
        }
Пример #6
0
        /// <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));
        }
Пример #7
0
 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;
 }
Пример #8
0
        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
            });
        }
Пример #9
0
        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);
        }
Пример #10
0
        /// <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));
        }
Пример #11
0
        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;
        }
Пример #12
0
        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);
        }
Пример #13
0
 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);
 }
Пример #14
0
 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));
 }
Пример #15
0
        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);
            }
        }
Пример #16
0
        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);
            }
        }
Пример #17
0
        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);
            }
        }
Пример #18
0
        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);
        }
Пример #19
0
        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)));
            }
        }
Пример #20
0
 /// <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));
 }
Пример #21
0
 public AmexCc(IVoca cardholder, DateTime?openedDate, DateTime?expiryDate)
     : base(cardholder, openedDate, expiryDate)
 {
 }
Пример #22
0
 public AmexCc(string cardNumber, IVoca cardholder, DateTime?openedDate, DateTime?expiryDate) : base(
         cardNumber, cardholder, openedDate, expiryDate)
 {
 }
Пример #23
0
 public MasterCardCc(string cardNumber, string cvv, IVoca cardholder, DateTime?openedDate,
                     DateTime?expiryDate) : base(cardNumber, cvv, cardholder, openedDate, expiryDate)
 {
 }
Пример #24
0
 public MasterCardCc(IVoca cardholder, DateTime?openedDate, DateTime?expiryDate)
     : base(cardholder, openedDate, expiryDate)
 {
 }
Пример #25
0
 /// <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));
 }
Пример #26
0
 /// <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);
 }
Пример #27
0
 public BirthCert(IVoca personName) : base(personName)
 {
 }
Пример #28
0
 public DiscoverCc(IVoca cardholder, DateTime?openedDate, DateTime?expiryDate)
     : base(cardholder, openedDate, expiryDate)
 {
 }
Пример #29
0
        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;
        }
Пример #30
0
 private Transaction(DateTime atTime, Pecuniam amt, IVoca description = null) : base(atTime, description)
 {
     Cash = amt ?? Pecuniam.Zero;
 }