private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var uie = (FrameworkElement)sender; AccountDefinition ad = (AccountDefinition)uie.DataContext; ViewModel.AddCommand.Execute(ad); }
private async Task TestAccountAsync() { AccountDefinition worker = AccountDefinition.GetByPrefix(ConnectedAccount.Prefix); IsValidating = true; Exception ex = await worker.ValidateInteractiveAsync(ConnectedAccount.Id, ConnectedAccount.StorageConnectionString); ValidationError = ex?.Message; ValidationErrorDetails = ex?.ToString(); IsValidating = false; ValidationPassed = ex == null; CommitCommand?.RaiseCanExecuteChanged(); }
private long GetAccountBalance(AccountDefinition account, bool creditFromDebit) { long creditBalance = this.YearData.Booking .SelectMany(x => x.Credit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); long debitBalance = this.YearData.Booking .SelectMany(x => x.Debit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); if (creditFromDebit) { return(creditBalance - debitBalance); } return(debitBalance - creditBalance); }
public ConnectedAccount(string connectionString) { StorageConnectionString = new StorageConnectionString(connectionString); Definition = AccountDefinition.GetByPrefix(StorageConnectionString.Prefix); }
private XmlNode CreateAccountBalanceNode(AccountDefinition account, long balance) { string accountText = account.ID.ToString(CultureInfo.CurrentCulture).PadLeft(5, '0') + " " + account.Name; return(this.CreateBalanceNode(accountText, balance)); }
private void ProcessAccount(XmlNode dataNode, AccountDefinition account) { if (this.YearData.Booking.All( b => b.Debit.All(x => x.Account != account.ID) && b.Credit.All(x => x.Account != account.ID))) { return; } this.accountsPerGroup++; var lastBookingDate = this.YearData.Booking .Where(x => x.Debit.Any(a => a.Account == account.ID) || x.Credit.Any(a => a.Account == account.ID)) .Select(x => x.Date).DefaultIfEmpty().Max(); long balanceCredit = this.YearData.Booking .SelectMany(x => x.Credit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); long balanceDebit = this.YearData.Booking .SelectMany(x => x.Debit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); long openingCredit = this.YearData.Booking .Where(b => b.Opening) .SelectMany(x => x.Credit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); long openingDebit = this.YearData.Booking .Where(b => b.Opening) .SelectMany(x => x.Debit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); long totalCredit = this.YearData.Booking .Where(b => !b.Opening) .SelectMany(x => x.Credit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); long totalDebit = this.YearData.Booking .Where(b => !b.Opening) .SelectMany(x => x.Debit.Where(y => y.Account == account.ID)) .DefaultIfEmpty().Sum(x => x?.Value ?? 0); if (openingCredit > openingDebit) { openingCredit -= openingDebit; openingDebit = 0; } else { openingDebit -= openingCredit; openingCredit = 0; } if (balanceCredit > balanceDebit) { balanceCredit -= balanceDebit; balanceDebit = 0; } else { balanceDebit -= balanceCredit; balanceCredit = 0; } XmlNode dataLineNode = this.PrintDocument.CreateElement("tr"); dataLineNode.SetAttribute("topLine", true); dataLineNode.AddTableNode(account.ID.ToString(CultureInfo.InvariantCulture)); dataLineNode.AddTableNode(account.Name); dataLineNode.AddTableNode(lastBookingDate.ToDateTime().ToString("d", CultureInfo.CurrentCulture)); dataLineNode.AddTableNode(FormatValue(openingDebit)); dataLineNode.AddTableNode(FormatValue(openingCredit)); dataLineNode.AddTableNode(FormatValue(totalDebit)); dataLineNode.AddTableNode(FormatValue(totalCredit)); dataLineNode.AddTableNode(FormatValue(balanceDebit)); dataLineNode.AddTableNode(FormatValue(balanceCredit)); dataNode.AppendChild(dataLineNode); this.groupOpeningCredit += openingCredit; this.groupOpeningDebit += openingDebit; this.groupTotalCredit += totalCredit; this.groupTotalDebit += totalDebit; this.groupBalanceCredit += balanceCredit; this.groupBalanceDebit += balanceDebit; this.overallOpeningCredit += openingCredit; this.overallOpeningDebit += openingDebit; this.overallTotalCredit += totalCredit; this.overallTotalDebit += totalDebit; this.overallBalanceCredit += balanceCredit; this.overallBalanceDebit += balanceDebit; }