public static void UpdateBankStatement(BankStatementEditView bankStatementEditView) { IDalSession session = NHSessionFactory.CreateSession(); try { IBankStatement bankStatement = getBankStatement(session, bankStatementEditView.JournalEntryId); if (bankStatement.Status != JournalEntryStati.New) throw new ApplicationException("Bank Statement cannot be updated because it has been already booked."); if (bankStatementEditView.CanChangeTransactionDate) bankStatement.TransactionDate = bankStatementEditView.TransactionDate; bankStatement.ClosingBalance = new Money(bankStatementEditView.ClosingBalanceQuantity, bankStatement.Journal.Currency); bankStatement.HasClosingBalance = true; JournalEntryMapper.Update(session, bankStatement); } finally { session.Close(); } }
public static IList GetBankStatementEditView(int journalEntryId) { IDalSession session = NHSessionFactory.CreateSession(); ArrayList editViews = new ArrayList(); try { IBankStatement bankStatement = getBankStatement(session, journalEntryId); if (bankStatement != null) { if (bankStatement.Status != JournalEntryStati.New) throw new ApplicationException("Closing Balance cannot be edited because the Bank Statement has been already booked."); Money closingBalance = (bankStatement.HasClosingBalance ? bankStatement.ClosingBalance : bankStatement.StartingBalance - bankStatement.Balance); bool canChangeTransactionDate = (bankStatement.PrevBankStatement == null && bankStatement.Status == JournalEntryStati.New); BankStatementEditView bankStatementEditView = new BankStatementEditView(journalEntryId, closingBalance, canChangeTransactionDate); if (canChangeTransactionDate) bankStatementEditView.TransactionDate = bankStatement.TransactionDate; editViews.Add(bankStatementEditView); } } finally { session.Close(); } return editViews; }