Example #1
0
        /// <summary>
        /// Adds a ledger entry to the category.
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <exception cref="System.ArgumetNullException">. Entry must be provided.</exception>
        public void AddEntry(ILedgerEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("Entry must be provided");
            }

            entry.Category = this;
            this.Entries.Add(entry);
        }
Example #2
0
 public static void DeleteLedgerEntry(ILedgerEntry ledger)
 {
     foreach (ISubledgerEntry subLedger in ledger.SubledgerEntries)
     {
         foreach (IJournalEntryLine line in subLedger.JournalEntryLines)
         {
             line.SubledgerEntry = null;
         }
     }
 }
Example #3
0
 public static bool Update(IDalSession session, ILedgerEntry obj)
 {
     return session.InsertOrUpdate(obj);
 }
Example #4
0
 private void WriteCreditEntry(ILedgerEntry creditEntry)
 {
 }
Example #5
0
 private void WriteDebitEntry(ILedgerEntry debitEntry)
 {
 }
Example #6
0
 private void LogUnknownLedgerEntryType(ILedgerEntry obj)
 {
 }
Example #7
0
 private void WriteDebitEntry(ILedgerEntry obj)
 {
 }
Example #8
0
 private void WriteCreditEntry(ILedgerEntry obj)
 {
 }
Example #9
0
        private static string formatLedgerEntry(BatchExecutionResults results, ILedgerEntry ledgerEntry)
        {
            try
            {
                string formatted = "";

                formatted += ledgerEntry.FormatLine() + Environment.NewLine;
                foreach (var subledgerEntry in ledgerEntry.SubledgerEntries
                        .Where(x => ((x.LineNumber > 0) && (x.Amount != 0m)))
                        .OrderBy(y => y.LineNumber))
                {
                    formatted += subledgerEntry.FormatLine() + Environment.NewLine;
                }

                return formatted;
            }
            catch (Exception ex)
            {
                results.MarkError(
                    new ApplicationException(string.Format("Error exporting ledger entry {0} or one of its sub-ledger entries.",
                                                           ledgerEntry.Key), ex));
                return "";
            }
        }
Example #10
0
        private static void CreateSubLedgerEntries(IDalSession session, ILedgerEntry newEntry, IList<IJournalEntryLine> groupOfLines)
        {
            var summary = from s in groupOfLines                //.Where(n => n.GLAccount.ExactAccount != null)
                          group s by
                          new
                          {
                              account = s.GLAccount.ExactAccount,
                              currency = s.Balance.UnderlyingShortName
                          } into accountGroups
                          select new
                          {
                              exactAccount = accountGroups.Key.account,
                              currency = accountGroups.Key.currency,
                              records = accountGroups,
                              total = (from l in accountGroups select (l.Debit - l.Credit)).Sum()
                          };

            //bool bankFlag = newEntry.LedgerType.JournalType == JournalTypes.BankStatement;
            int lineNumer = 1;
            foreach (var d in summary.OrderBy(a => a.exactAccount).ThenBy(b => b.currency))
            {
                Decimal quantity =  d.total.Quantity;
                ISubledgerEntry newSubEntry = new SubledgerEntry("", d.exactAccount, quantity, d.currency, false, d.total.XRate);
                if (newSubEntry.Amount != 0m) newSubEntry.LineNumber = lineNumer++;
                foreach (var f in d.records)
                {
                    f.SubledgerEntry = newSubEntry;
                }
                newEntry.SubledgerEntries.AddSubLedgerEntry(newSubEntry);
            }
        }