Пример #1
0
        public void BookManualEntry(Booking booking, User currentUser)
        {
            using (SqlConnection conn = _movementSetManagement.GetConnection())
            {
                SqlTransaction sqlTransac = conn.BeginTransaction();
                try
                {
                    if (booking.Amount <= 0)
                        throw new OpenCbsAccountException(OpenCbsAccountExceptionsEnum.IncorrectAmountFormat);

                    if (booking.DebitAccount.Id == booking.CreditAccount.Id)
                    {
                        throw new OpenCbsAccountException(OpenCbsAccountExceptionsEnum.EqualAccounts);
                    }

                    _movementSetManagement.InsertManualMovment(booking, sqlTransac);
                    sqlTransac.Commit();
                }
                catch (Exception ex)
                {
                    sqlTransac.Rollback();
                    throw ex;
                }
            }
        }
Пример #2
0
 public void SetUp()
 {
     movementSet = new AccountingTransaction();
     Bookings = new List<Booking>();
     Booking Booking = new Booking(1, new Account("100000", "first account"), 1000, new Account("200000", "second account"), movementSet.Date, new Branch {Id = 1});
     Bookings.Add(Booking);
 }
 public void TestCreateStandardBooking()
 {
     Assert.Ignore();
     Booking booking = new Booking();
     booking.Name = "Test";
     booking.CreditAccount = new Account("111", "Test");
     booking.DebitAccount = new Account("222", "Test");
     _standardBookingServicesServices = ServicesProvider.GetInstance().GetStandardBookingServices();
     _standardBookingServicesServices.CreateStandardBooking(booking);
     List<Booking> bookings = _standardBookingServicesServices.SelectAllStandardBookings();
     Assert.AreEqual(bookings.Count, 1);
 }
Пример #4
0
 public void CreateStandardBooking(Booking booking)
 {
     const string sqlText = @"INSERT INTO StandardBookings([Name], debit_account_id, credit_account_id)
                              VALUES (@name, @debit_account_id, @credit_account_id)";
     using (SqlConnection conn = GetConnection())
     using (OpenCbsCommand insertIntoTable = new OpenCbsCommand(sqlText, conn))
         {
             insertIntoTable.AddParam("@name", booking.Name);
             insertIntoTable.AddParam("@debit_account_id", booking.DebitAccount.Id);
             insertIntoTable.AddParam("@credit_account_id", booking.CreditAccount.Id);
             insertIntoTable.ExecuteNonQuery();
         }
 }
        public void TestDeleteStandardBooking()
        {
            Assert.Ignore();
            Booking booking = new Booking();
            booking.Name = "Tdfdfest";
            booking.CreditAccount = new Account("1eyyturt", "Tesyutrt");
            booking.DebitAccount = new Account("22ytutyuret", "Tetyuyusrt");
            _standardBookingServicesServices = ServicesProvider.GetInstance().GetStandardBookingServices();
            _standardBookingServicesServices.CreateStandardBooking(booking);

            List<Booking> bookings = _standardBookingServicesServices.SelectAllStandardBookings();
            _standardBookingServicesServices.DeleteStandardBooking(bookings[0].Id);
            booking = _standardBookingServicesServices.SelectStandardBookingById(bookings[0].Id);
            Assert.IsNull(booking.Name);
        }
Пример #6
0
 public void TestBook()
 {
     Account cashCredit = new Account();
     cashCredit.DebitPlus = true;
     cashCredit.Number = "1031";
     cashCredit.TypeCode = "CASH_CREDIT";
     cashCredit.Balance = 0;
     cashCredit.CurrencyId = 1;
     chartOfAccounts.AddAccount(cash);
     chartOfAccounts.AddAccount(cashCredit);
     // OMFS-200
     AccountingTransaction movementSet = new AccountingTransaction();
     Booking mvt = new Booking(2, cashCredit, 100, cash, movementSet.Date, new Branch{Id = 1});
     movementSet.AddBooking(mvt);
     chartOfAccounts.Book(movementSet);
     Assert.AreEqual(1100m,chartOfAccounts.GetAccountByTypeCode("CASH",1).Balance.Value);
     Assert.AreEqual(-100m,chartOfAccounts.GetAccountByTypeCode("CASH_CREDIT",1).Balance.Value);
 }
        public void TestSelectAllStandardBookings()
        {
            Assert.Ignore();
            Booking booking = new Booking();
            booking.Name = "Tefdfst";
            booking.CreditAccount = new Account("1ert", "Testrt");
            booking.DebitAccount = new Account("22ret", "Tesrbgt");
            _standardBookingServicesServices = ServicesProvider.GetInstance().GetStandardBookingServices();
            _standardBookingServicesServices.CreateStandardBooking(booking);

            booking.Name = "Tesfdft1";
            booking.CreditAccount = new Account("111f1", "Test1");
            booking.DebitAccount = new Account("2221", "Test1");
            _standardBookingServicesServices = ServicesProvider.GetInstance().GetStandardBookingServices();
            _standardBookingServicesServices.CreateStandardBooking(booking);

            List<Booking> bookings = _standardBookingServicesServices.SelectAllStandardBookings();
            Assert.IsNotEmpty(bookings);
        }
        public void InsertSavingMovment(Booking booking, SqlTransaction sqlTransaction)
        {
            const string sqlText =
                @"INSERT INTO dbo.SavingsAccountingMovements
                               ( debit_account_number_id,
                                  credit_account_number_id,
                                  amount,
                                  transaction_date,
                                  currency_id,
                                  exchange_rate,
                                  is_exported,
                                  event_id,
                                  contract_id,
                                  rule_id,
                                  branch_id,
                                  closure_id,
                                  fiscal_year_id)
                               VALUES
                               ( @debit_account_number_id,
                                 @credit_account_number_id,
                                 @amount,
                                 @transaction_date,
                                 @currency_id,
                                 @exchange_rate,
                                 0,
                                 @event_id,
                                 @contract_id,
                                 @rule_id,
                                 @branch_id,
                                 @closure_id,
                                 @fiscal_year_id)";
            using (OpenCbsCommand command = new OpenCbsCommand(sqlText, sqlTransaction.Connection, sqlTransaction))
            {
                command.AddParam("@debit_account_number_id", booking.DebitAccount.Id);
                command.AddParam("@credit_account_number_id", booking.CreditAccount.Id);
                command.AddParam("@amount", booking.Amount.Value);
                command.AddParam("@transaction_date", booking.Date);
                command.AddParam("@currency_id", booking.Currency.Id);
                command.AddParam("@exchange_rate", booking.ExchangeRate);
                command.AddParam("@event_id", booking.EventId);
                command.AddParam("@contract_id", booking.ContractId);
                command.AddParam("@branch_id", booking.Branch.Id);
                command.AddParam("@closure_id", booking.ClosureId);
                command.AddParam("@fiscal_year_id", booking.FiscalYear.Id);

                if (booking.RuleId != 0)
                {
                    command.AddParam("@rule_id", booking.RuleId);
                }
                else
                {
                    command.AddParam("@rule_id", null);
                }

                command.ExecuteNonQuery();
            }
        }
        public void InsertManualMovment(Booking booking, SqlTransaction sqlTransaction)
        {
            const string sqlText =
                @"INSERT INTO dbo.ManualAccountingMovements
                               ( debit_account_number_id,
                                  credit_account_number_id,
                                  amount,
                                  transaction_date,
                                  currency_id,
                                  exchange_rate,
                                  description,
                                  user_id,
                                  is_exported,
                                  event_id,
                                  branch_id,
                                  closure_id)
                               VALUES
                               ( @debit_account_number_id,
                                 @credit_account_number_id,
                                 @amount,
                                 @transaction_date,
                                 @currency_id,
                                 @exchange_rate,
                                 @description,
                                 @user_id,
                                 0,
                                 @event_id,
                                 @branch_id,
                                 @closure_id)";

            using (OpenCbsCommand command = new OpenCbsCommand(sqlText, sqlTransaction.Connection, sqlTransaction))
            {
                command.AddParam("@debit_account_number_id", booking.DebitAccount.Id);
                command.AddParam("@credit_account_number_id", booking.CreditAccount.Id);
                command.AddParam("@amount", booking.Amount.Value);
                command.AddParam("@transaction_date", booking.Date);
                command.AddParam("@currency_id", booking.Currency.Id);
                command.AddParam("@exchange_rate", booking.ExchangeRate);
                command.AddParam("@description", booking.Description);
                command.AddParam("@user_id", booking.User.Id);
                command.AddParam("@event_id", booking.EventId);
                command.AddParam("@branch_id", booking.Branch.Id);
                command.AddParam("@closure_id", booking.ClosureId);

                command.ExecuteNonQuery();
            }
        }
        public void UpdateManualMovment(Booking booking, SqlTransaction sqlTransaction)
        {
            const string sqlText =
                @"UPDATE dbo.ManualAccountingMovements
                    SET closure_id = @closure_id,
                       fiscal_year_id = @fiscal_year_id
                    WHERE id = @id";

            using (OpenCbsCommand command = new OpenCbsCommand(sqlText, sqlTransaction.Connection, sqlTransaction))
            {
                command.AddParam("@id", booking.Id);
                command.AddParam("@closure_id", booking.ClosureId);
                command.AddParam("@fiscal_year_id", booking.FiscalYear.Id);
                command.ExecuteNonQuery();
            }
        }
Пример #11
0
        public void SpecialOperation(ISavingsContract saving, DateTime pDate, OCurrency amount,
              string description, User pUser, OSavingsMethods savingsMethod, bool isCredit, Booking booking)
        {
            if (booking == null)
               throw new OpenCbsBookingException(OpenCbsBookingExceptionsEnum.BookingIsEmpty);

               booking.Amount = amount;
               booking.Description = description;
               booking.ExchangeRate = 1;
               booking.Date = TimeProvider.Now;
               booking.Currency = saving.Product.Currency;
               booking.User = User.CurrentUser;

               SavingEvent e;

               if (isCredit)
               {
               e = SpecialOperationCredit(saving, pDate, amount, description,
                                   User.CurrentUser, savingsMethod);
               }
               else
               {
               e = SpecialOperationDebit(saving, pDate, amount, description,
                                   User.CurrentUser, savingsMethod);
               }

               booking.EventId = e.Id;
               ServicesProvider.GetInstance().GetAccountingServices().BookManualEntry(booking, User.CurrentUser);
        }
Пример #12
0
        public Booking SelectStandardBookingById(int id)
        {
            const string sqlText = @"SELECT Id, [Name], debit_account_id, credit_account_id
                                    FROM StandardBookings
                                    WHERE Id = @Id";
            Booking standardBooking = new Booking();
            using (SqlConnection conn = GetConnection())
            {
                using (OpenCbsCommand select = new OpenCbsCommand(sqlText, conn))
                {
                    select.AddParam("@Id", id);

                    using (OpenCbsReader reader = select.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            standardBooking.Id = reader.GetInt("Id");
                            standardBooking.Name = reader.GetString("Name");

                            Account account =
                                _chartOfAccounts.GetAccountById(reader.GetInt("debit_account_id"));
                            standardBooking.DebitAccount = account;

                            account =
                                _chartOfAccounts.GetAccountById(reader.GetInt("credit_account_id"));
                            standardBooking.CreditAccount = account;
                        }
                    }
                }
            }
            return standardBooking;
        }
Пример #13
0
 private void _checkStandardBooking(Booking pBooking)
 {
     if (string.IsNullOrEmpty(pBooking.Name))
         throw new OpenCbsBookingException(OpenCbsBookingExceptionsEnum.NameIsEmpty);
     if (pBooking.CreditAccount == null)
         throw new OpenCbsBookingException(OpenCbsBookingExceptionsEnum.CreditAccountIsEmpty);
     if (pBooking.DebitAccount == null)
         throw new OpenCbsBookingException(OpenCbsBookingExceptionsEnum.DebitAccountIsEmpty);
     if (pBooking.CreditAccount.Number == pBooking.DebitAccount.Number)
         throw new OpenCbsBookingException(OpenCbsBookingExceptionsEnum.DebitAndCreditAccountAreIdentical);
 }
Пример #14
0
 public void CreateStandardBooking(Booking booking)
 {
     _checkStandardBooking(booking);
     _StandardBookingManager.CreateStandardBooking(booking);
 }
Пример #15
0
        public void TestBookAndUnBook()
        {
            // Actors
            Account _cash = null, _cashCredit = null;
            OCurrency cashBalance1 = 0, cashBalance2 = 0;
            OCurrency cashBalance3 = 0, cashBalance4 = 0;
            Booking mvt = null;
            AccountingTransaction movementSet = null;

            // Activites
            chartOfAccounts.Accounts = new List<Account>();
            _cash = new Account();
            _cash.DebitPlus = true;
            _cash.Number = "1011";
            _cash.Balance = 1000;
            _cash.TypeCode = "CASH";
            _cash.CurrencyId = 1;

            _cashCredit = new Account();
            _cashCredit.DebitPlus = true;
            _cashCredit.Number = "1031";
            _cashCredit.TypeCode = "CASH_CREDIT";
            _cashCredit.Balance = 0;
            _cashCredit.CurrencyId = 1;
            chartOfAccounts.AddAccount(_cash);
            chartOfAccounts.AddAccount(_cashCredit);
            movementSet = new AccountingTransaction();

            // Asertions
            mvt = new Booking(2, _cashCredit, 100, cash, movementSet.Date, new Branch{Id = 1});
            movementSet.AddBooking(mvt);
            chartOfAccounts.Book(movementSet);
            cashBalance1 = chartOfAccounts.GetAccountByTypeCode("CASH",1).Balance;
            cashBalance2 = chartOfAccounts.GetAccountByTypeCode("CASH_CREDIT", 1).Balance;
            chartOfAccounts.UnBook(movementSet);
            cashBalance3 = chartOfAccounts.GetAccountByTypeCode("CASH", 1).Balance;
            cashBalance4 = chartOfAccounts.GetAccountByTypeCode("CASH_CREDIT",1).Balance;

            // Asertions
            Assert.AreEqual (1100m,   cashBalance1.Value);
            Assert.AreEqual (-100m,   cashBalance2.Value);
            Assert.AreEqual (1000m,   cashBalance3.Value);
            Assert.AreEqual (0m,      cashBalance4.Value);
        }
Пример #16
0
	    public void AddBooking(Booking pBooking)
		{
            _bookings.Add(pBooking);
		}
Пример #17
0
 private static Booking GetBooking(ContractAccountingRule rule, Event eventItem)
 {
     if (eventItem.Code == rule.EventType.EventCode)
     {
         if ((rule.LoanProduct == null
              || (eventItem.LoanProduct != null && eventItem.LoanProduct.Id == rule.LoanProduct.Id))
             && (rule.SavingProduct == null
                 || (eventItem.SavingProduct != null && eventItem.SavingProduct.Id == rule.SavingProduct.Id))
             && (rule.Currency == null
                 || (eventItem.Currency != null && eventItem.Currency.Id == rule.Currency.Id))
             && (rule.ClientType == OClientTypes.All
                 || eventItem.ClientType == rule.ClientType)
             && (rule.EconomicActivity == null
                 ||
                 (eventItem.EconomicActivity != null && eventItem.EconomicActivity.Id == rule.EconomicActivity.Id)))
         {
             var booking = new Booking
                               {
                                   Amount = GetValue(rule, eventItem),
                                   CreditAccount = rule.CreditAccount,
                                   DebitAccount = rule.DebitAccount,
                                   ContractId = eventItem.ContracId,
                                   Date = eventItem.Date,
                                   EventId = eventItem.Id,
                                   RuleId = rule.Id,
                                   ExchangeRate = 1,
                                   Currency = eventItem.Currency,
                                   Branch = eventItem.Branch,
                                   EventType = eventItem.Code,
                                   Name = eventItem.Description + " [" + eventItem.Date + "]",
                                   Type = eventItem is SavingEvent
                                              ? OMovementType.Saving
                                              : eventItem is TellerEvent
                                                    ? OMovementType.Teller
                                                    : OMovementType.Loan
                               };
             return booking;
         }
     }
     return null;
 }
Пример #18
0
 private void SetStandardBooking(Booking pBooking)
 {
     textBoxName.Text = pBooking.Name;
     comboBoxCredit.SelectedItem = comboBoxCredit.Items.OfType<Account>().FirstOrDefault(item => item.Number == pBooking.CreditAccount.Number);
     comboBoxDebit.SelectedItem = comboBoxDebit.Items.OfType<Account>().FirstOrDefault(item => item.Number == pBooking.DebitAccount.Number);
 }
Пример #19
0
        public List<Booking> SelectAllStandardBookings()
        {
            const string sqlText = @"SELECT Id, [Name], debit_account_id, credit_account_id FROM StandardBookings";
            List<Booking> list = new List<Booking>();
            using (SqlConnection conn = GetConnection())
            {
                using (OpenCbsCommand select = new OpenCbsCommand(sqlText, conn))
                {
                    using (OpenCbsReader reader = select.ExecuteReader())
                    {
                        if (reader.Empty) return list;
                        while (reader.Read())
                        {
                            Booking standardBooking = new Booking();
                            standardBooking.Id = reader.GetInt("Id");
                            standardBooking.Name = reader.GetString("Name");

                            Account account =
                                _chartOfAccounts.GetAccountById(reader.GetInt("debit_account_id"));
                            standardBooking.DebitAccount = account;

                            account =
                                _chartOfAccounts.GetAccountById(reader.GetInt("credit_account_id"));
                            standardBooking.CreditAccount = account;

                            list.Add(standardBooking);
                        }
                    }
                }
                return list;
            }
        }
Пример #20
0
 public void UpdateStandardBooking(Booking booking)
 {
     const string sqlText = @"UPDATE StandardBookings
                                SET [Name] = @name,
                                    debit_account_id = @debit_account_id,
                                    credit_account_id = @credit_account_id
                             WHERE Id = @Id";
     using (SqlConnection conn = GetConnection())
     {
         using (OpenCbsCommand insertIntoTable = new OpenCbsCommand(sqlText, conn))
         {
             insertIntoTable.AddParam("@name", booking.Name);
             insertIntoTable.AddParam("@debit_account_id", booking.DebitAccount.Id);
             insertIntoTable.AddParam("@credit_account_id", booking.CreditAccount.Id);
             insertIntoTable.AddParam("@Id", booking.Id);
             insertIntoTable.ExecuteNonQuery();
         }
     }
 }
        public Booking SelectBookingByEventId(int eventId)
        {
            const string sqlText = @"SELECT
                                      ManualAccountingMovements.id,
                                      debit_account_number_id,
                                      credit_account_number_id,
                                      amount,
                                      transaction_date,
                                      export_date,
                                      is_exported,
                                      currency_id,
                                      exchange_rate,
                                      [description],
                                      event_id,
                                      0 AS contract_id,
                                      Users.id AS user_id,
                                      Users.deleted AS user_deleted,
                                      Users.user_name AS user_username,
                                      Users.user_pass AS user_password,
                                      Users.role_code AS user_role,
                                      Users.first_name AS user_firstname,
                                      Users.last_name AS user_lastname,
                                      branch_id
                                    FROM dbo.ManualAccountingMovements
                                    INNER JOIN Users ON [Users].id = ManualAccountingMovements.[user_id]
                                    WHERE event_id = @event_id";

            Booking booking = new Booking();
            using (SqlConnection conn = GetConnection())
            {
                using (OpenCbsCommand select = new OpenCbsCommand(sqlText, conn))
                {
                    select.AddParam("@event_id", eventId);
                    using (OpenCbsReader reader = select.ExecuteReader())
                    {
                        if (reader.Empty) return null;
                        while (reader.Read())
                        {
                            booking = GetBooking(reader);
                            booking.User = new User
                                               {
                                                   Id = reader.GetInt("user_id"),
                                                   IsDeleted = reader.GetBool("user_deleted"),
                                                   Password = reader.GetString("user_password"),
                                                   UserName = reader.GetString("user_username"),
                                                   FirstName = reader.GetString("user_firstname"),
                                                   LastName = reader.GetString("user_lastname")
                                               };

                            booking.User.SetRole(reader.GetString("user_role"));
                        }
                    }

                    booking.CreditAccount = _accountManagement.Select(booking.CreditAccount.Id);
                    booking.DebitAccount = _accountManagement.Select(booking.DebitAccount.Id);
                    booking.Currency = _currencyManager.SelectCurrencyById(booking.Currency.Id);
                    booking.Branch = _branchManager.Select(booking.Branch.Id);
                    return booking;
                }
            }
        }
Пример #22
0
 public void DoSavingMovement(Booking booking)
 {
     using (SqlConnection conn = _movementSetManagement.GetConnection())
     {
         SqlTransaction sqlTransac = conn.BeginTransaction();
         try
         {
             _movementSetManagement.InsertSavingMovment(booking, sqlTransac);
             sqlTransac.Commit();
         }
         catch (Exception)
         {
             sqlTransac.Rollback();
             throw;
         }
     }
 }
 private static void _AssertSelectedBooking(Booking pBooking, int pNumber, string pDebitAccount,
     string pCreditAccount, OCurrency pAmount, OAccountingLabels pLabel)
 {
     Assert.AreEqual(pNumber, pBooking.Number);
     Assert.AreEqual(pDebitAccount, pBooking.DebitAccount.Number);
     Assert.AreEqual(pCreditAccount, pBooking.CreditAccount.Number);
     Assert.AreEqual(pAmount.Value, pBooking.Amount.Value);
     Assert.AreEqual(pLabel, pBooking.Label);
 }
Пример #24
0
        public void TestUpdateStandardBooking()
        {
            Booking booking = new Booking();
            booking.Name = "Tdfdfest";
            booking.CreditAccount = new Account("1eyyturt", "Tesyutrt");
            booking.DebitAccount = new Account("22ytutyuret", "Tetyuyusrt");
            _standardBookingServicesServices = ServicesProvider.GetInstance().GetStandardBookingServices();
            _standardBookingServicesServices.CreateStandardBooking(booking);

            List<Booking> bookings = _standardBookingServicesServices.SelectAllStandardBookings();
            int id = bookings[0].Id;
            booking = _standardBookingServicesServices.SelectStandardBookingById(id);
            booking.Name = "Shoulbe";
            _standardBookingServicesServices.UpdateStandardBookings(booking);
            booking = _standardBookingServicesServices.SelectStandardBookingById(id);
            Assert.AreNotEqual(booking.Name, "Shoulbe");
        }
Пример #25
0
 public void UpdateStandardBookings(Booking booking)
 {
     _checkStandardBooking(booking);
     _StandardBookingManager.UpdateStandardBooking(booking);
 }
Пример #26
0
        public SavingEvent CancelLastEvent(ISavingsContract saving, User user, string pDescription)
        {
            if (string.IsNullOrEmpty(pDescription))
                throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.SavingsEventCommentIsEmpty);

            Debug.Assert(_ePS != null, "Event processor is null");
            SavingEvent lastSavingEvent = saving.GetCancelableEvent();

            if (null == lastSavingEvent) return null;

            // check for compulsory
            if (saving is SavingBookContract)
            {
                if (lastSavingEvent is SavingDepositEvent)
                {
                    if (((SavingBookContract)saving).Loans != null && ((SavingBookContract)saving).Loans.Count > 0)
                    {
                        if (!IsCompulsorySavingBalanceOk(saving, lastSavingEvent.Amount))
                            throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.SavingsEventCannotBeCanceled);
                    }
                }
            }

            //reversal transaction in accounting
            if (lastSavingEvent is SavingCreditOperationEvent || lastSavingEvent is SavingDebitOperationEvent)
            {
                if (((SavingBookContract)saving).Loans != null && ((SavingBookContract)saving).Loans.Count > 0)
                {
                    if (!IsCompulsorySavingBalanceOk(saving, lastSavingEvent.Amount))
                        throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.SavingsEventCannotBeCanceled);
                }

                Booking booking = ServicesProvider.GetInstance().GetAccountingServices().SelectBookingByEventId(lastSavingEvent.Id);
                Booking reversalBooking = new Booking
                                              {
                                                  Currency = booking.Currency,
                                                  User = User.CurrentUser,
                                                  Amount = booking.Amount,
                                                  Description = booking.Description,
                                                  DebitAccount = booking.CreditAccount,
                                                  CreditAccount = booking.DebitAccount,
                                                  Date = TimeProvider.Now,
                                                  EventId = lastSavingEvent.Id,
                                                  ExchangeRate = booking.ExchangeRate,
                                                  Branch = saving.Branch
                                              };
                ServicesProvider.GetInstance().GetAccountingServices().BookManualEntry(reversalBooking, User.CurrentUser);
            }

            // Cancelling event
            lastSavingEvent.Description = pDescription;
            lastSavingEvent = saving.CancelLastEvent();
            _savingEventManager.UpdateEventDescription(lastSavingEvent.Id, pDescription);
            lastSavingEvent.CancelDate = new DateTime(
                                                        TimeProvider.Now.Year,
                                                        TimeProvider.Now.Month,
                                                        TimeProvider.Now.Day,
                                                        TimeProvider.Now.Hour,
                                                        TimeProvider.Now.Minute,
                                                        TimeProvider.Now.Second
                                                      );
            _ePS.CancelFireEvent(lastSavingEvent, saving.Product.Currency.Id);

            SavingEvent savingEvent = lastSavingEvent;
            if (lastSavingEvent.PendingEventId != null)
            {
                savingEvent.Code = "SPDE";
                savingEvent.Id = (int)lastSavingEvent.PendingEventId;
                _ePS.CancelFireEvent(savingEvent, saving.Product.Currency.Id);
            }

            return savingEvent;
        }
Пример #27
0
 private void AddListViewItem(Booking booking)
 {
     ListViewItem listViewItem = new ListViewItem(booking.Name);
     listViewItem.SubItems.Add(booking.DebitAccount.Number + " : " + booking.DebitAccount.Label);
     listViewItem.SubItems.Add(booking.CreditAccount.Number + " : " + booking.CreditAccount.Label);
     listViewItem.Tag = booking;
     listBookings.Items.Add(listViewItem);
 }
Пример #28
0
        public bool Save()
        {
            if (string.IsNullOrEmpty(_txbAmount.Text))
            {
                string caption = MultiLanguageStrings.GetString("SweetBaseForm", "error");
                string message = MultiLanguageStrings.GetString(Ressource.ElemMvtUserControl, "manualEntryInvalidAmount.Text");
                MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            _amount = ServicesHelper.ConvertStringToNullableDecimal(_txbAmount.Text);

            _GetAccounts();
            _CheckExchangeRate();
            _GetBranches();

                Booking booking = new Booking
                                      {
                                          Description = txbDescription.Text,
                                          Amount = _amount.Value,
                                          DebitAccount = _debitAccount,
                                          CreditAccount = _creditAccount,
                                          Date = TimeProvider.Now,
                                          Currency = (Currency)cbCurrencies.SelectedItem,
                                          ExchangeRate = _exchangeRate.Rate,
                                          Branch = _branch,
                                          User = User.CurrentUser
                                      };

                ServicesProvider.GetInstance().GetAccountingServices().BookManualEntry(booking, User.CurrentUser);
                ServicesProvider.GetInstance().GetEventProcessorServices().LogUser(OUserEvents.UserManualEntryEvent, txbDescription.Text, User.CurrentUser.Id);

                _deleteIsPossible = false;

            return true;
        }