Skip to content

Commit

Permalink
#12 Moved internal transactions to their own list
Browse files Browse the repository at this point in the history
Still to do:
Mark as seen marks all as seen, should just be the visible ones.
Don't show a live tile update for internal transfers (maybe make it an
option).
  • Loading branch information
cpmcgrath committed Nov 20, 2012
1 parent a339be8 commit 520a348
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
28 changes: 23 additions & 5 deletions CommonwealthBank/ViewModels/TransactionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using CMcG.CommonwealthBank.Agent;
using CMcG.CommonwealthBank.Data;
using CMcG.CommonwealthBank.Logic;
using System.Text.RegularExpressions;

namespace CMcG.CommonwealthBank.ViewModels
{
Expand Down Expand Up @@ -30,13 +31,13 @@ void Load()
Account = store.CurrentOptions.GetSelectedAccount(store);
AutoRefresh = store.CurrentOptions.AutoRefresh;

Transactions = store.Transactions.OrderByDescending(x => x.Id).ToArray();
var replacements = store.Replacements.ToArray();
m_allTransactions = store.Transactions.OrderByDescending(x => x.Id).ToArray();
var replacements = store.Replacements.ToArray();

foreach (var transaction in Transactions)
foreach (var transaction in m_allTransactions)
transaction.Replacements = replacements;
}
NotifyPropertyChanged("Transactions", "ReceivedTransactions", "SentTransactions", "AccountAmount");
NotifyPropertyChanged("Transactions", "ReceivedTransactions", "SentTransactions", "InternalTransactions", "AccountAmount");
new Updater().UpdateLiveTile();
}

Expand All @@ -51,7 +52,13 @@ public void Refresh()

public bool AutoRefresh { get; set; }
public Account Account { get; set; }
public Transaction[] Transactions { get; set; }

Transaction[] m_allTransactions;

public Transaction[] Transactions
{
get { return m_allTransactions.Except(InternalTransactions).ToArray(); }
}

public Transaction[] ReceivedTransactions
{
Expand All @@ -63,6 +70,17 @@ public Transaction[] SentTransactions
get { return Transactions.Where(x => x.Amount < 0).ToArray(); }
}

public Transaction[] InternalTransactions
{
get { return m_allTransactions.Where(IsInternal).ToArray(); }
}

bool IsInternal(Transaction trans)
{
var match = Regex.Match(trans.Description, @"Transfer (from|to) xx(?<digits>\d+) NetBank");
return match.Success;
}

public string AccountAmount
{
get { return Account != null ? Account.AccountAmount.ToString("$0.00") : ""; }
Expand Down
6 changes: 6 additions & 0 deletions CommonwealthBank/Views/ScreenTransactions.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
HorizontalContentAlignment = "Stretch"
ItemsSource = "{Binding SentTransactions}" />
</controls:PivotItem>

<controls:PivotItem Header="internal">
<ListBox ItemTemplate = "{StaticResource TransactionTemplate}"
HorizontalContentAlignment = "Stretch"
ItemsSource = "{Binding InternalTransactions}" />
</controls:PivotItem>
</controls:Pivot>
</Grid>

Expand Down

0 comments on commit 520a348

Please sign in to comment.