public IntacctGeneralLedgerTransaction(string targetJournalId, string description, IntacctGeneralLedgerEntry[] entries, DateTime dateCreated)
 {
     JournalId	= targetJournalId;
     Description = description;
     DateCreated = new IntacctDate(dateCreated);
     GlTransactionEntries = entries;
 }
        /// <summary>
        /// Adds a debit/credit pair of GL entries.
        /// </summary>
        /// <remarks>
        /// The pair should balance to zero. However, since transactions may come with different exchange rates and currencies,
        /// this is not explicitly validated.
        /// </remarks>
        public void AddEntryPair(IntacctGeneralLedgerEntry credit, IntacctGeneralLedgerEntry debit)
        {
            if (credit == null) throw new ArgumentNullException(nameof(credit));
            if (debit == null) throw new ArgumentNullException(nameof(debit));

            if (credit.Type != IntacctGeneralLedgerEntryType.Credit) throw new ArgumentException("Credit entry must be of type Credit", nameof(credit));
            if (debit.Type != IntacctGeneralLedgerEntryType.Debit) throw new ArgumentException("Debit entry must be of type Credit", nameof(debit));

            var entries = new List<IntacctGeneralLedgerEntry>();
            if (GlTransactionEntries != null && GlTransactionEntries.Length > 0)
            {
                entries.AddRange(GlTransactionEntries);
            }

            entries.Add(credit);
            entries.Add(debit);

            GlTransactionEntries = entries.ToArray();
        }
 public IntacctGeneralLedgerTransaction(string targetJournalId, string description, IntacctGeneralLedgerEntry[] entries)
     : this(targetJournalId, description, entries, DateTime.Now)
 {
 }