public void SetUp()
        {
            Account _account = new Account();

            _account.Balance = 300;

            BookingToView _booking1 = new BookingToView(OBookingDirections.Debit, 1000, new DateTime(2008, 1, 1),
                                                        3.45, "S/01/2008-1", "LDRE34");

            BookingToView _booking2 = new BookingToView(OBookingDirections.Credit, 1333, new DateTime(2008, 1, 2),
                                                        4, "S/01/2008-1", "LDRE35");

            BookingToView _booking3 = new BookingToView(OBookingDirections.Debit, 10, new DateTime(2008, 1, 5),
                                                        5.45, "S/01/2008-3", "LDRE36");

            _bookingToViewStock = new BookingToViewStock(_account);
            _bookingToViewStock.Add(_booking1);
            _bookingToViewStock.Add(_booking2);
            _bookingToViewStock.Add(_booking3);
        }
Example #2
0
        private void _InitializeListViewBookings(Account pAccount, DateTime pBeginDate, DateTime pEndDate, OBookingTypes pBookingType)
        {
            lvBooking.Items.Clear();
            lblAccountBalance.Text = String.Empty;
            if (pAccount != null)
            {
                _bookingsStock = ServicesProvider.GetInstance().GetAccountingServices().FindAllBookings(pAccount, pBeginDate, pEndDate, ((Currency) (cmbCurrencies.SelectedItem)).Id , pBookingType, ((Branch) cmbBranches.SelectedItem).Id);
                if (_bookingsStock.Count != 0)
                {
                    foreach (BookingToView bookingToView in _bookingsStock)
                    {
                        ListViewItem listViewItem = new ListViewItem(bookingToView.Date.ToShortDateString());
                        if (bookingToView.Direction == OBookingDirections.Debit)
                        {
                            listViewItem.SubItems.Add(bookingToView.AmountInternal.GetFormatedValue(true));
                            listViewItem.SubItems.Add("");
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add(bookingToView.AmountInternal.GetFormatedValue(true));
                        }

                        if (cmbCurrencies.Items.Count > 0)
                        {
                            listViewItem.SubItems.Add(bookingToView.ExchangeRate.ToString());
                            if (!bookingToView.ExchangeRate.HasValue)
                                listViewItem.BackColor = Color.Red;
                            listViewItem.SubItems.Add(bookingToView.ExternalAmount.GetFormatedValue(true));
                        }

                        if (bookingToView.IsExported)
                            listViewItem.ForeColor = Color.Gray;
                            
                        string purpose = string.Format("{0} {1} {2}", 
                            MultiLanguageStrings.GetString(Ressource.AccountView, bookingToView.EventCode + @".Text"), 
                            bookingToView.ContractCode, 
                            MultiLanguageStrings.GetString(Ressource.AccountView, bookingToView.AccountingLabel + @".Text"));

                        listViewItem.SubItems.Add(purpose);
                        lvBooking.Items.Add(listViewItem);
                    }
                }

                if (((Currency) cmbCurrencies.SelectedItem).Id != 0)
                {
                    Currency selectedcur = cmbCurrencies.SelectedItem as Currency;
                    OCurrency balance = ServicesProvider.GetInstance().GetAccountingServices().
                        GetAccountBalance(pAccount.Id, selectedcur.Id, 0, null, 0, (cmbBranches.SelectedItem as Branch).Id);
                    lblAccountBalance.Text = string.Format("{0}  {1}", balance.GetFormatedValue(selectedcur.UseCents), selectedcur);
                    
                }
                else
                {
                    Currency selectedcur = new Currency();
                    foreach (var item in cmbCurrencies.Items)
                    {
                        if(((Currency) item).IsPivot)
                        {
                            selectedcur = (Currency) item;
                        }
                    }
                    OCurrency balance = ServicesProvider.GetInstance().GetAccountingServices().
                        GetAccountBalance(pAccount.Id, 0, 0, null, 0, (cmbBranches.SelectedItem as Branch).Id);
                    lblAccountBalance.Text = string.Format("{0} {1}", balance.GetFormatedValue(selectedcur.UseCents), selectedcur.Name);
                }
            }
            else _bookingsStock = null;
        }
 public void GetSelectedBookingBalanceInExternalCurrency_NoBooking()
 {
     _bookingToViewStock = new BookingToViewStock(new Account());
     Assert.AreEqual(0m, _bookingToViewStock.GetSelectedBookingBalanceInExternalCurrency.Value);
 }
 public void GetSelectedBookingBalanceInInternalCurrency_NoBooking()
 {
     _bookingToViewStock = new BookingToViewStock(new Account());
     Assert.AreEqual(0m,_bookingToViewStock.GetSelectedBookingBalanceInInternalCurrency.Value);
 }
        public void SetUp()
        {
            Account _account = new Account();
            _account.Balance = 300;

            BookingToView _booking1 = new BookingToView(OBookingDirections.Debit,1000,new DateTime(2008,1,1),
                                                        3.45,"S/01/2008-1","LDRE34");

            BookingToView _booking2 = new BookingToView(OBookingDirections.Credit, 1333, new DateTime(2008, 1, 2),
                                                        4,"S/01/2008-1","LDRE35");

            BookingToView _booking3 = new BookingToView(OBookingDirections.Debit, 10, new DateTime(2008, 1, 5),
                                                        5.45,"S/01/2008-3","LDRE36");

            _bookingToViewStock = new BookingToViewStock(_account);
            _bookingToViewStock.Add(_booking1);
            _bookingToViewStock.Add(_booking2);
            _bookingToViewStock.Add(_booking3);
        }
        public BookingToViewStock SelectBookings(Account pAccount, DateTime pBeginDate, DateTime pEndDate,
                                                 int currencyId, OBookingTypes pBookingType, int pBranchId)
        {
            const string sqlQuery = "GetAccountBookings";

            bool? isExported = null;
            switch (pBookingType)
            {
                case OBookingTypes.Exported:
                    isExported = true;
                    break;
                case OBookingTypes.NotExported:
                    isExported = false;
                    break;
            }

            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand cmd = new OpenCbsCommand(sqlQuery, conn).AsStoredProcedure())
                {
                    cmd.AddParam("@beginDate",pBeginDate);
                    cmd.AddParam("@endDate", pEndDate);
                    cmd.AddParam("@account_id",  pAccount.Id);
                    cmd.AddParam("@currency_id", currencyId);
                    cmd.AddParam("@is_exported",  isExported);
                    cmd.AddParam("@branch_id",  pBranchId);

                    using (OpenCbsReader reader = cmd.ExecuteReader())
                    {
                        if (reader == null || reader.Empty) return new BookingToViewStock(pAccount);

                        BookingToViewStock stock = new BookingToViewStock(pAccount);
                        while (reader.Read())
                        {
                            stock.Add(GetBooking(pAccount, reader));
                        }
                        return stock;
                    }
                }
        }
Example #7
0
        private void _InitializeListViewBookings(Account pAccount, DateTime pBeginDate, DateTime pEndDate, OBookingTypes pBookingType)
        {
            lvBooking.Items.Clear();
            lblAccountBalance.Text = String.Empty;
            if (pAccount != null)
            {
                _bookingsStock = ServicesProvider.GetInstance().GetAccountingServices().FindAllBookings(pAccount, pBeginDate, pEndDate, ((Currency)(cmbCurrencies.SelectedItem)).Id, pBookingType, ((Branch)cmbBranches.SelectedItem).Id);
                if (_bookingsStock.Count != 0)
                {
                    foreach (BookingToView bookingToView in _bookingsStock)
                    {
                        ListViewItem listViewItem = new ListViewItem(bookingToView.Date.ToShortDateString());
                        if (bookingToView.Direction == OBookingDirections.Debit)
                        {
                            listViewItem.SubItems.Add(bookingToView.AmountInternal.GetFormatedValue(true));
                            listViewItem.SubItems.Add("");
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add(bookingToView.AmountInternal.GetFormatedValue(true));
                        }

                        if (cmbCurrencies.Items.Count > 0)
                        {
                            listViewItem.SubItems.Add(bookingToView.ExchangeRate.ToString());
                            if (!bookingToView.ExchangeRate.HasValue)
                            {
                                listViewItem.BackColor = Color.Red;
                            }
                            listViewItem.SubItems.Add(bookingToView.ExternalAmount.GetFormatedValue(true));
                        }

                        if (bookingToView.IsExported)
                        {
                            listViewItem.ForeColor = Color.Gray;
                        }

                        string purpose = string.Format("{0} {1} {2}",
                                                       MultiLanguageStrings.GetString(Ressource.AccountView, bookingToView.EventCode + @".Text"),
                                                       bookingToView.ContractCode,
                                                       MultiLanguageStrings.GetString(Ressource.AccountView, bookingToView.AccountingLabel + @".Text"));

                        listViewItem.SubItems.Add(purpose);
                        lvBooking.Items.Add(listViewItem);
                    }
                }

                if (((Currency)cmbCurrencies.SelectedItem).Id != 0)
                {
                    Currency  selectedcur = cmbCurrencies.SelectedItem as Currency;
                    OCurrency balance     = ServicesProvider.GetInstance().GetAccountingServices().
                                            GetAccountBalance(pAccount.Id, selectedcur.Id, 0, null, 0, (cmbBranches.SelectedItem as Branch).Id);
                    lblAccountBalance.Text = string.Format("{0}  {1}", balance.GetFormatedValue(selectedcur.UseCents), selectedcur);
                }
                else
                {
                    Currency selectedcur = new Currency();
                    foreach (var item in cmbCurrencies.Items)
                    {
                        if (((Currency)item).IsPivot)
                        {
                            selectedcur = (Currency)item;
                        }
                    }
                    OCurrency balance = ServicesProvider.GetInstance().GetAccountingServices().
                                        GetAccountBalance(pAccount.Id, 0, 0, null, 0, (cmbBranches.SelectedItem as Branch).Id);
                    lblAccountBalance.Text = string.Format("{0} {1}", balance.GetFormatedValue(selectedcur.UseCents), selectedcur.Name);
                }
            }
            else
            {
                _bookingsStock = null;
            }
        }