Skip to content

Commit 89f1707

Browse files
committed
Fix balance column in transactino view.
Fix model based automation test.
1 parent 33fb284 commit 89f1707

File tree

13 files changed

+256
-217
lines changed

13 files changed

+256
-217
lines changed

Source/WPF/MoneyPackage/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap rescap">
3-
<Identity Name="43906ChrisLovett.MyMoney.Net" Publisher="CN=Chris Lovett, O=Chris Lovett, S=Washington, C=US" Version="2.1.0.56" />
3+
<Identity Name="43906ChrisLovett.MyMoney.Net" Publisher="CN=Chris Lovett, O=Chris Lovett, S=Washington, C=US" Version="2.1.0.57" />
44
<Properties>
55
<DisplayName>MyMoney.Net</DisplayName>
66
<PublisherDisplayName>Chris Lovett</PublisherDisplayName>

Source/WPF/MyMoney/Controls/PasswordControl.xaml.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Windows;
2+
using System.Windows.Automation.Peers;
23
using System.Windows.Controls;
3-
using System.Windows.Input;
44

55
namespace Walkabout.Controls
66
{
@@ -55,5 +55,24 @@ private void OnTextChanged(object sender, TextChangedEventArgs e)
5555
{
5656
this.PasswordField.Password = this.PasswordTextBox.Text;
5757
}
58+
59+
protected override AutomationPeer OnCreateAutomationPeer()
60+
{
61+
// Make sure we can use ValuePattern on this control for automation.
62+
var id = this.Name;
63+
if (this.PasswordTextBox.Visibility == System.Windows.Visibility.Visible)
64+
{
65+
this.PasswordTextBox.SetValue(System.Windows.Automation.AutomationProperties.AutomationIdProperty, id);
66+
return new TextBoxAutomationPeer(this.PasswordTextBox);
67+
}
68+
else
69+
{
70+
this.PasswordField.SetValue(System.Windows.Automation.AutomationProperties.AutomationIdProperty, id);
71+
return new PasswordBoxAutomationPeer(this.PasswordField);
72+
}
73+
}
74+
75+
5876
}
77+
5978
}

Source/WPF/MyMoney/Database/Money.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,13 +1241,16 @@ private async void ApplyPendingBalance()
12411241
{
12421242
bool changed = false;
12431243
List<Account> copy = null;
1244-
lock (this.balancePending)
1244+
if (this.balancePending != null)
12451245
{
1246-
if (this.balancePending != null && this.balancePending.Count > 0)
1246+
lock (this.balancePending)
12471247
{
1248-
copy = new List<Account>(this.balancePending);
1248+
if (this.balancePending != null && this.balancePending.Count > 0)
1249+
{
1250+
copy = new List<Account>(this.balancePending);
1251+
}
1252+
this.balancePending.Clear();
12491253
}
1250-
this.balancePending.Clear();
12511254
}
12521255
if (copy != null && copy.Count > 0)
12531256
{
@@ -9948,7 +9951,7 @@ public async Task<bool> Rebalance(CostBasisCalculator calculator, StockQuoteCach
99489951
this.BeginUpdate(true);
99499952
try
99509953
{
9951-
var result = await this.GetAccountBalance(calculator, cache, a);
9954+
var result = await this.GetBalance(calculator, cache, this.GetTransactionsFrom(a), a, false, false, true);
99529955
// Refresh the Account balance value
99539956
var balance = result.Balance + result.InvestmentValue;
99549957
if (a.Balance != balance)
@@ -9965,12 +9968,7 @@ public async Task<bool> Rebalance(CostBasisCalculator calculator, StockQuoteCach
99659968
return changed;
99669969
}
99679970

9968-
private async Task<AccountBalanceInfo> GetAccountBalance(CostBasisCalculator calculator, StockQuoteCache cache, Account a)
9969-
{
9970-
return await this.GetBalance(calculator, cache, this.GetTransactionsFrom(a), a, false, false);
9971-
}
9972-
9973-
public async Task<AccountBalanceInfo> GetBalance(CostBasisCalculator calculator, StockQuoteCache cache, System.Collections.IEnumerable data, Account account, bool normalize, bool withoutTax)
9971+
public async Task<AccountBalanceInfo> GetBalance(CostBasisCalculator calculator, StockQuoteCache cache, System.Collections.IEnumerable data, Account account, bool normalize, bool withoutTax, bool updateTransactionBalance = false)
99749972
{
99759973
MyMoney money = this.Parent as MyMoney;
99769974
var result = new AccountBalanceInfo();
@@ -10027,6 +10025,10 @@ public async Task<AccountBalanceInfo> GetBalance(CostBasisCalculator calculator,
1002710025

1002810026
balance += amount;
1002910027
result.SalesTax += tax;
10028+
if (updateTransactionBalance)
10029+
{
10030+
t.Balance = balance;
10031+
}
1003010032
}
1003110033
}
1003210034

Source/WPF/MyMoney/Dialogs/PasswordWindow.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Windows;
4+
using System.Windows.Automation.Peers;
45
using System.Windows.Controls;
56
//using Kerr;
67
using Walkabout.Controls;
@@ -42,8 +43,6 @@ private void PasswordWindow_SizeChanged(object sender, SizeChangedEventArgs e)
4243
this.TextBlockIntroMessage.Width = Math.Max(0, e.NewSize.Width - 20);
4344
}
4445

45-
46-
4746
public void AddUserDefinedField(string id, string label)
4847
{
4948
//<TextBlock x:Name="TextBlockUserNamePrompt" Text="User Name: " VerticalAlignment="Center" Margin="0,10,0,2"/>

Source/WPF/MyMoney/Properties/PublishProfiles/ClickOnceProfile.pubxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
44
-->
55
<Project>
66
<PropertyGroup>
7-
<ApplicationRevision>56</ApplicationRevision>
8-
<ApplicationVersion>2.1.0.56</ApplicationVersion>
7+
<ApplicationRevision>57</ApplicationRevision>
8+
<ApplicationVersion>2.1.0.57</ApplicationVersion>
99
<BootstrapperEnabled>True</BootstrapperEnabled>
1010
<Configuration>Release</Configuration>
1111
<CreateWebPageOnPublish>True</CreateWebPageOnPublish>

Source/WPF/MyMoney/Setup/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<changes>
3+
<change version="2.1.0.57" date="12/13/2025">
4+
- Bug: Fix account balance column in Transaction View.
5+
</change>
36
<change version="2.1.0.56" date="12/10/2025">
47
- Feature: Add account summary report with date picker.
58
- Feature: Switch to https://www.fastforex.io/ for exchange rate info.

Source/WPF/ScenarioTest/AutomationExtensions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Windows.Automation;
2+
using Walkabout.Tests.Interop;
23
using Walkabout.Tests.Wrappers;
34

45
namespace Walkabout.Tests
@@ -122,8 +123,15 @@ public static AutomationElement SetTextBox(this AutomationElement parent, string
122123
{
123124
throw new Exception("TextBox '" + name + "' is not enabled");
124125
}
125-
ValuePattern p = (ValuePattern)box.GetCurrentPattern(ValuePattern.Pattern);
126-
p.SetValue(value);
126+
127+
if (box.TryGetCurrentPattern(ValuePattern.Pattern, out object obj) && obj is ValuePattern p)
128+
{
129+
p.SetValue(value);
130+
}
131+
else
132+
{
133+
throw new Exception("TextBox '" + name + "' does not support ValuePattern");
134+
}
127135
return box;
128136
}
129137

Source/WPF/ScenarioTest/ScenarioTest.cs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,11 @@ internal void ConnectToBank()
557557
internal void SignOnToBank()
558558
{
559559
this.WriteLine(" - SignOnToBank");
560-
this.ofxServerWindow.UserName = this.passwordDialog.UserName = "test";
561-
this.ofxServerWindow.Password = this.passwordDialog.Password = "1234";
560+
this.passwordDialog.UserName = "test";
561+
this.passwordDialog.Password = "1234";
562+
// this brings the ofx dialog to the front.
563+
this.ofxServerWindow.UserName = "test";
564+
this.ofxServerWindow.Password = "1234";
562565

563566
bool mfa = false;
564567
if (this.random.Next(0, 2) == 0)
@@ -1070,6 +1073,8 @@ private void SelectAccount()
10701073
}
10711074
this.ClearTransactionViewState();
10721075
this.dataChangedSinceExport = true;
1076+
this.selectedCurrency = null;
1077+
this.editedCurrency = null;
10731078
}
10741079
#endregion
10751080

@@ -1258,6 +1263,7 @@ private void EnsureSelectedTransaction()
12581263
{
12591264
throw new Exception("Cannot find any transaction to select!");
12601265
}
1266+
this.transactions.ScrollSelectionIntoView();
12611267
}
12621268
}
12631269

@@ -1632,12 +1638,15 @@ private bool HasSelectedTransaction
16321638

16331639
private void SearchTransactionView()
16341640
{
1641+
this.transactions = this.window.FindTransactionGrid();
16351642
if (this.transactions != null && this.transactions.CountNoPlaceholder > 5)
16361643
{
16371644
this.EnsureSelectedTransaction();
16381645

16391646
this.WriteLine("- SearchTransactionView");
1640-
var row1 = this.transactions.WaitForSelection();
1647+
var row1 = this.transactions.WaitForSelection();
1648+
Assert.That(row1, Is.Not.Null, "Selection not found after trying to set a selection?");
1649+
16411650
var t = this.transactions.GetSelectedTransactionProxy();
16421651
var search = "\"" + t.Date.ToShortDateString() + "\" and " + t.Amount;
16431652

@@ -1648,35 +1657,30 @@ private void SearchTransactionView()
16481657

16491658
// Make sure selection is preserved on the matching transaction
16501659
var row2 = this.transactions.WaitForSelection();
1651-
Assert.That(row2, Is.Not.Null, "Selection not found after setting search filter");
1660+
if (row2 == null)
1661+
{
1662+
// WTF?
1663+
Assert.That(row2, Is.Not.Null, "Selection not found after setting search filter");
1664+
}
16521665
Assert.That(row2.Id, Is.EqualTo(row1.Id), $"Expected election automation id {row1.Id} doesn't match {row2.Id}");
16531666

16541667
var t2 = this.transactions.GetSelectedTransactionProxy();
1655-
Assert.Multiple(() =>
1656-
{
1657-
Assert.That(t2.Date, Is.EqualTo(t.Date), "Dates don't match");
1658-
Assert.That(t2.Amount, Is.EqualTo(t.Amount), "Amounts don't match");
1659-
});
1660-
1668+
Assert.That(t2.Date, Is.EqualTo(t.Date), "Dates don't match");
1669+
Assert.That(t2.Amount, Is.EqualTo(t.Amount), "Amounts don't match");
1670+
16611671
// don't leave Money with active search filter as it makes the rest of the
16621672
// editing logic very complicated.
16631673
quickFilter.ClearSearch();
16641674
Thread.Sleep(500);
16651675

16661676
// Make sure selection is preserved after search is cleared.
16671677
var row3 = this.transactions.WaitForSelection();
1668-
Assert.Multiple(() =>
1669-
{
1670-
Assert.That(row3, Is.Not.Null, "Selection not restored after clearing search filter");
1671-
Assert.That(row3.Id, Is.EqualTo(row1.Id), $"Expected election automation id {row1.Id} doesn't match {row3.Id}");
1672-
});
1673-
1678+
Assert.That(row3, Is.Not.Null, "Selection not restored after clearing search filter");
1679+
Assert.That(row3.Id, Is.EqualTo(row1.Id), $"Expected election automation id {row1.Id} doesn't match {row3.Id}");
1680+
16741681
var t3 = this.transactions.GetSelectedTransactionProxy();
1675-
Assert.Multiple(() =>
1676-
{
1677-
Assert.That(t3.Date, Is.EqualTo(t.Date), "Dates don't match");
1678-
Assert.That(t3.Amount, Is.EqualTo(t.Amount), "Amounts don't match");
1679-
});
1682+
Assert.That(t3.Date, Is.EqualTo(t.Date), "Dates don't match");
1683+
Assert.That(t3.Amount, Is.EqualTo(t.Amount), "Amounts don't match");
16801684
}
16811685
}
16821686

0 commit comments

Comments
 (0)