Пример #1
0
 private void OnCloseScreen(string obj)
 {
     if (AppServices.MainDataContext.SelectedDepartment != null && AppServices.MainDataContext.IsCurrentWorkPeriodOpen)
     {
         EventServiceFactory.EventService.PublishEvent(EventTopicNames.DisplayTicketView);
     }
     else
     {
         EventServiceFactory.EventService.PublishEvent(EventTopicNames.ActivateNavigation);
     }
     SelectedView = 0;
     ActiveView   = 0;
     SelectedCustomerTransactions.Clear();
 }
Пример #2
0
        public void RefreshSelectedCustomer()
        {
            ClearSearchValues();

            if (AppServices.MainDataContext.SelectedTicket != null && AppServices.MainDataContext.SelectedTicket.CustomerId > 0)
            {
                var customer = Dao.SingleWithCache <Customer>(x => x.Id == AppServices.MainDataContext.SelectedTicket.CustomerId);
                if (customer != null)
                {
                    FoundCustomers.Add(new CustomerViewModel(customer));
                }
                if (SelectedCustomer != null)
                {
                    SelectedView = 1;
                    SelectedCustomer.UpdateDetailedInfo();
                }
            }
            RaisePropertyChanged("SelectedCustomer");
            RaisePropertyChanged("IsClearVisible");
            RaisePropertyChanged("IsResetCustomerVisible");
            RaisePropertyChanged("IsMakePaymentVisible");
            ActiveView = 0;
            SelectedCustomerTransactions.Clear();
        }
Пример #3
0
        private void OnDisplayCustomerAccount(string obj)
        {
            SaveSelectedCustomer();
            SelectedCustomerTransactions.Clear();
            if (SelectedCustomer != null)
            {
                var tickets             = Dao.Query <Ticket>(x => x.CustomerId == SelectedCustomer.Id && x.LastPaymentDate > SelectedCustomer.AccountOpeningDate, x => x.Payments);
                var cashTransactions    = Dao.Query <CashTransaction>(x => x.Date > SelectedCustomer.AccountOpeningDate && x.CustomerId == SelectedCustomer.Id);
                var accountTransactions = Dao.Query <AccountTransaction>(x => x.Date > SelectedCustomer.AccountOpeningDate && x.CustomerId == SelectedCustomer.Id);

                var transactions = new List <CustomerTransactionViewModel>();
                transactions.AddRange(tickets.Select(x => new CustomerTransactionViewModel
                {
                    Description = string.Format(Resources.TicketNumber_f, x.TicketNumber),
                    Date        = x.LastPaymentDate,
                    Receivable  = x.GetAccountPaymentAmount() + x.GetAccountRemainingAmount(),
                    Liability   = x.GetAccountPaymentAmount()
                }));

                transactions.AddRange(cashTransactions.Where(x => x.TransactionType == (int)TransactionType.Income)
                                      .Select(x => new CustomerTransactionViewModel
                {
                    Description = x.Name,
                    Date        = x.Date,
                    Liability   = x.Amount
                }));

                transactions.AddRange(cashTransactions.Where(x => x.TransactionType == (int)TransactionType.Expense)
                                      .Select(x => new CustomerTransactionViewModel
                {
                    Description = x.Name,
                    Date        = x.Date,
                    Receivable  = x.Amount
                }));

                transactions.AddRange(accountTransactions.Where(x => x.TransactionType == (int)TransactionType.Liability)
                                      .Select(x => new CustomerTransactionViewModel
                {
                    Description = x.Name,
                    Date        = x.Date,
                    Liability   = x.Amount
                }));

                transactions.AddRange(accountTransactions.Where(x => x.TransactionType == (int)TransactionType.Receivable)
                                      .Select(x => new CustomerTransactionViewModel
                {
                    Description = x.Name,
                    Date        = x.Date,
                    Receivable  = x.Amount
                }));

                transactions = transactions.OrderBy(x => x.Date).ToList();

                for (var i = 0; i < transactions.Count; i++)
                {
                    transactions[i].Balance = (transactions[i].Receivable - transactions[i].Liability);
                    if (i > 0)
                    {
                        (transactions[i].Balance) += (transactions[i - 1].Balance);
                    }
                }

                SelectedCustomerTransactions.AddRange(transactions);
                RaisePropertyChanged("TotalReceivable");
                RaisePropertyChanged("TotalLiability");
                RaisePropertyChanged("TotalBalance");
            }
            ActiveView = 1;
        }