public static bool StornoBondTransaction(IDalSession session, ITransaction storno, IInternalEmployeeLogin employee) { bool success = false; if (storno.Approved) { IList<IBondCouponPayment> bondPaymentsToStorno = storno.GetBondPaymentsToStorno(); if (bondPaymentsToStorno != null && bondPaymentsToStorno.Count > 0) { IGLLookupRecords lookups = null; int journalID = int.Parse((string)(System.Configuration.ConfigurationManager.AppSettings.Get("DefaultAccruedInterestJournal"))); IJournal journal = JournalMapper.GetJournal(session, journalID); foreach (IBondCouponPayment payment in bondPaymentsToStorno.OrderByDescending(x => x.CouponHistory.StartAccrualDate)) { if (payment.Status == BondCouponPaymentStati.Active || payment.Status == BondCouponPaymentStati.ToBeSettled) { if (lookups == null) lookups = GlLookupRecordMapper.GetGLLookupRecords(session, BookingComponentParentTypes.AccruedInterest); payment.Cancel(); success = true; } else if (payment.Status == BondCouponPaymentStati.Settled) { string nextJournalEntryNumber = JournalEntryMapper.GetNextJournalEntryNumber(session, journal); IMemorialBooking memorialBooking = new MemorialBooking(journal, nextJournalEntryNumber); memorialBooking.TransactionDate = payment.CouponHistory.EndAccrualDate; payment.Storno(employee, storno.StornoReason, memorialBooking); success = true; } } } } return success; }