public AccountSelectorViewModel(IAccountService accountService, ICacheService cacheService, IApplicationState applicationState, IEntityService entityService, IReportServiceClient reportServiceClient) { _accounts = new ObservableCollection<AccountScreenRow>(); _accountService = accountService; _cacheService = cacheService; _applicationState = applicationState; _entityService = entityService; _reportServiceClient = reportServiceClient; ShowAccountDetailsCommand = new CaptionCommand<string>(Resources.AccountDetails.Replace(' ', '\r'), OnShowAccountDetails, CanShowAccountDetails); PrintCommand = new CaptionCommand<string>(Resources.Print, OnPrint); AccountButtonSelectedCommand = new CaptionCommand<AccountScreen>("", OnAccountScreenSelected); AutomationCommandSelectedCommand = new CaptionCommand<AccountScreenAutmationCommandMap>("", OnAutomationCommandSelected); EventServiceFactory.EventService.GetEvent<GenericEvent<EventAggregator>>().Subscribe( x => { if (x.Topic == EventTopicNames.ResetCache) { _accountButtons = null; _batchDocumentButtons = null; _selectedAccountScreen = null; } }); }
public AccountButtonViewModel(AccountButton model, AccountScreen screen, ICommand actionCommand) { _isEnabled = true; _actionCommand = actionCommand; _screen = screen; Model = model; }
public IEnumerable<AccountScreenRow> GetAccountScreenRows(AccountScreen accountScreen, WorkPeriod currentWorkPeriod) { var rows = new List<AccountScreenRow>(); var detailedTemplateNames = accountScreen.AccountScreenValues.Where(x => x.DisplayDetails).Select(x => x.AccountTypeId); _accountDao.GetAccountBalances(detailedTemplateNames.ToList(), GetFilter(accountScreen, currentWorkPeriod)).ToList().ForEach(x => rows.Add(AccountScreenRow.Create(x, _cacheService.GetCurrencySymbol(x.Key.ForeignCurrencyId), GetGroupKey(accountScreen, x.Key.AccountTypeId)))); var templateTotals = accountScreen.AccountScreenValues.Where(x => !x.DisplayDetails).Select(x => x.AccountTypeId); _accountDao.GetAccountTypeBalances(templateTotals.ToList(), GetFilter(accountScreen, currentWorkPeriod)).ToList().ForEach(x => rows.Add(AccountScreenRow.Create(x, GetGroupKey(accountScreen, x.Key.Id)))); var hideIfZeroBalanceTypeIds = accountScreen.AccountScreenValues.Where(x => x.HideZeroBalanceAccounts).Select(x => x.AccountTypeId).ToList(); var accounts = rows.Where(x => ShouldKeepAccount(x, hideIfZeroBalanceTypeIds)) .OrderBy(x => GetSortOrder(accountScreen.AccountScreenValues, x.AccountTypeId)) .ThenBy(x => x.Name) .ToList(); return accounts; }
public void PrintAccountScreen(AccountScreen accountScreen, WorkPeriod workperiod, Printer printer) { var accounts = _accountService.GetAccountScreenRows(accountScreen, workperiod); var report = new SimpleReport(""); report.AddParagraph("Header"); report.AddParagraphLine("Header", _settingService.ProgramSettings.UserInfo); report.AddParagraphLine("Header", string.Format(accountScreen.Name), true); report.AddParagraphLine("Header", ""); report.AddColumnLength("Transactions", "60*", "40*"); report.AddColumTextAlignment("Transactions", TextAlignment.Left, TextAlignment.Right); report.AddTable("Transactions", string.Format(Resources.Name_f, Resources.Account), Resources.Balance); foreach (var ad in accounts) { report.AddRow("Transactions", ad.Name, ad.BalanceStr); } _printerService.PrintReport(report.Document, printer); }
private Expression<Func<AccountTransactionValue, bool>> GetFilter(AccountScreen selectedAccountScreen, WorkPeriod currentWorkPeriod) { if (selectedAccountScreen == null || selectedAccountScreen.Filter == 0) return null; //Resources.All, Resources.Month, Resources.Week, Resources.WorkPeriod if (selectedAccountScreen.Filter == 1) { var date = DateTime.Now.MonthStart(); return x => x.Date >= date; } if (selectedAccountScreen.Filter == 2) { var date = DateTime.Now.StartOfWeek(); return x => x.Date >= date; } if (selectedAccountScreen.Filter == 3) { var date = currentWorkPeriod.StartDate; return x => x.Date >= date; } return null; }
public void Refresh() { UpdateAccountScreen(_selectedAccountScreen ?? (_selectedAccountScreen = AccountScreens.FirstOrDefault())); }
public void PrintAccountScreen(AccountScreen accountScreen) { _reportService.PrintAccountScreen(accountScreen, _applicationState.CurrentWorkPeriod, _applicationState.GetReportPrinter()); }
private void UpdateAccountScreen(AccountScreen accountScreen) { _accounts = _accountService.GetAccounts( _cacheService.GetAccountTemplatesByName(accountScreen.AccountTemplateNamesList).ToArray()); RaisePropertyChanged(() => Accounts); }
public AccountButton(AccountScreen accountScreen, ICacheService cacheService) { _accountScreen = accountScreen; _cacheService = cacheService; }
private void UpdateLocations(AccountScreen locationScreen) { var locationData = _locationService.GetCurrentLocations(locationScreen, CurrentPageNo).OrderBy(x => x.Order); if (Locations != null && (Locations.Count() == 0 || Locations.Count != locationData.Count() || Locations.First().Caption != locationData.First().Name)) Locations = null; if (Locations == null) { Locations = new ObservableCollection<IDiagram>(); Locations.AddRange(locationData.Select(x => new AccountButtonViewModel(x, SelectedLocationScreen, LocationSelectionCommand))); } else { for (var i = 0; i < locationData.Count(); i++) { ((AccountButtonViewModel)Locations[i]).Model = locationData.ElementAt(i); } } RaisePropertyChanged(() => Locations); RaisePropertyChanged(() => LocationScreens); RaisePropertyChanged(() => SelectedLocationScreen); RaisePropertyChanged(() => IsPageNavigatorVisible); RaisePropertyChanged(() => LocationsVerticalAlignment); }
public IEnumerable<AccountScreenRow> GetAccountScreenRows(AccountScreen accountScreen, WorkPeriod currentWorkPeriod) { return _accountRowBuilder.GetAccountScreenRows(accountScreen, currentWorkPeriod); }
private void UpdateAccountScreen(AccountScreen accountScreen) { if (accountScreen == null) return; _batchDocumentButtons = null; _selectedAccountScreen = accountScreen; _automationCommands = null; _accounts.Clear(); _accounts.AddRange(_accountService.GetAccountScreenRows(accountScreen, _applicationState.CurrentWorkPeriod)); RaisePropertyChanged(() => BatchDocumentButtons); RaisePropertyChanged(() => AccountButtons); RaisePropertyChanged(() => AutomationCommands); OnRefreshed(); }
public AccountButtonViewModel(AccountButton model, AccountScreen screen) : this(model, screen, null) { }
private void OnAccountScreenSelected(AccountScreen accountScreen) { UpdateAccountScreen(accountScreen); }
private static string GetGroupKey(AccountScreen accountScreen, int accountTypeId) { if (!accountScreen.DisplayAsTree) return null; return accountScreen.AccountScreenValues.Single(x => x.AccountTypeId == accountTypeId).AccountTypeName; }
private void UpdateAccountScreen(AccountScreen accountScreen) { if (accountScreen == null) return; _batchDocumentButtons = null; _selectedAccountScreen = accountScreen; _accounts.Clear(); var detailedTemplateNames = accountScreen.AccountScreenValues.Where(x => x.DisplayDetails).Select(x => x.AccountTypeId); _accountService.GetAccountBalances(detailedTemplateNames.ToList(), GetFilter()).ToList().ForEach(x => _accounts.Add(new AccountRowData(x.Key.Name, x.Value.Balance, x.Value.Exchange, x.Key.Id, GetCurrencyFormat(x.Key.ForeignCurrencyId)))); var templateTotals = accountScreen.AccountScreenValues.Where(x => !x.DisplayDetails).Select(x => x.AccountTypeId); _accountService.GetAccountTypeBalances(templateTotals.ToList(), GetFilter()).ToList().ForEach(x => _accounts.Add(new AccountRowData(x.Key.Name, x.Value.Balance, x.Value.Exchange, 0, ""))); RaisePropertyChanged(() => BatchDocumentButtons); RaisePropertyChanged(() => AccountButtons); }
private void OnSelectLocationCategoryExecuted(AccountScreen obj) { UpdateLocations(obj); }