Пример #1
0
        /************************************************************************/

        #region Constructor (internal)
        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionCollection"/> class.
        /// </summary>
        /// <param name="rootNode">The root node from which to find data for this class.</param>
        /// <param name="owner">The statement that owns this collection.</param>
        internal TransactionCollection(XmlNode rootNode, CommonStatementBase owner)
        {
            list = new List <Transaction>();
            if (rootNode != null)
            {
                XmlNode endNode = GetNestedNode(rootNode, GetNodeName(nameof(End)));
                Start = GetDateTimeValue(endNode);
                End   = GetDateTimeValue(GetNestedNode(rootNode, GetNodeName(nameof(End))));
                foreach (XmlNode node in endNode.ChildNodes)
                {
                    if (node.Name == "STMTTRN")
                    {
                        Add(new Transaction(node, owner));
                    }
                }
            }
        }
Пример #2
0
        /************************************************************************/

        #region Constructor (internal)
        /// <summary>
        /// Initializes a new instance of the <see cref="CurrencyAggregate"/> class.
        /// </summary>
        /// <param name="rootNode">The root node from which to find data for this class.</param>
        /// <param name="owner">The statement that owns the currency aggregate.</param>
        internal CurrencyAggregate(XmlNode rootNode, CommonStatementBase owner)
        {
            // Null values here indicate programmer error.
            ValidateNull(rootNode, nameof(rootNode));
            ValidateNull(owner, nameof(owner));

            CurrentRate = 1;
            Symbol      = owner.DefaultCurrency;
            Source      = CurrencySource.DefaultCurrency;

            var currencyNode = GetNestedNode(rootNode, CurrencyNodeName);

            if (currencyNode == null)
            {
                currencyNode = GetNestedNode(rootNode, OrigCurrencyNodeName);
            }

            if (currencyNode != null)
            {
                Source      = currencyNode.Name == CurrencyNodeName ? CurrencySource.Currency : CurrencySource.OriginalCurrency;
                Symbol      = GetNodeValue(currencyNode, nameof(Symbol));
                CurrentRate = GetDecimalValue(currencyNode, nameof(CurrentRate));
            }
        }
Пример #3
0
        /************************************************************************/

        #region Constructor (internal)
        /// <summary>
        /// Initializes a new instance of the <see cref="Transaction"/> class.
        /// </summary>
        /// <param name="rootNode">The root node from which to find data for this class.</param>
        /// <param name="owner">The statement that owns this transaction.</param>
        internal Transaction(XmlNode rootNode, CommonStatementBase owner)
        {
            // Null values here indicate programmer error.
            ValidateNull(rootNode, nameof(rootNode));
            ValidateNull(owner, nameof(owner));

            TransType     = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(TransType)))).ToOfxTransactionType();
            DatePosted    = GetDateTimeValue(rootNode, nameof(DatePosted));
            DateInitiated = GetNullableDateTimeValue(rootNode, nameof(DateInitiated));
            DateAvailable = GetNullableDateTimeValue(rootNode, nameof(DateAvailable));
            Amount        = GetDecimalValue(GetNestedNode(rootNode, GetNodeName(nameof(Amount))));

            TransactionId = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(TransactionId))));
            ValidateOfxParseOperation(String.IsNullOrEmpty(TransactionId), "Cannot retreive transaction id");

            CorrectedTransactionId = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(CorrectedTransactionId))));
            CorrectionAction       = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(CorrectionAction)))).ToTransactionCorrectionAction();
            ServerTransactionId    = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(ServerTransactionId))));

            CheckNumber = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(CheckNumber))));
            // the check number may come in left-padded with zeros. Take out left padding.
            while (CheckNumber.StartsWith("0") && CheckNumber.Length > 0)
            {
                CheckNumber = CheckNumber.Remove(0, 1);
            }

            ReferenceNumber = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(ReferenceNumber))));
            Sic             = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(Sic))));
            PayeeId         = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(PayeeId))));

            Name = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(Name))));
            Memo = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(Memo))));

            // This is not strictly spec. Some ofx responses don't have Name b/c they have a Payee
            if (String.IsNullOrEmpty(Name))
            {
                Name = Memo;
            }

            // Get the payee if it exists.
            XmlNode payeeNode = GetNestedNode(rootNode, GetNodeName(nameof(Payee)));

            if (payeeNode != null)
            {
                Payee = new Payee(payeeNode);
            }

            Currency = new CurrencyAggregate(rootNode, owner);

            //Currency = GetNodeValue(GetNestedNode(rootNode, GetNodeName(nameof(Currency))));
            //if (String.IsNullOrEmpty(Currency))
            //{
            //    Currency = GetNodeValue(GetNestedNode(rootNode, "ORIGCURRENCY"));
            //    if (String.IsNullOrEmpty(Currency))
            //    {
            //        Currency = defaultCurrency;
            //    }
            //}

            XmlNode bankToNode = GetNestedNode(rootNode, "BANKACCTTO");
            XmlNode ccToNode   = GetNestedNode(rootNode, "CCACCTTO");

            if (bankToNode != null)
            {
                ToAccount = new BankAccount(bankToNode);
            }
            else if (ccToNode != null)
            {
                ToAccount = new CreditCardAccount(ccToNode);
            }
        }