Skip to content

Commit

Permalink
Merge pull request #758 from NickvisionApps/consistent-ids
Browse files Browse the repository at this point in the history
Fix inconsistent ids
  • Loading branch information
nlogozzo authored Dec 12, 2023
2 parents f156cdf + e7922dc commit 1e84896
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
10 changes: 3 additions & 7 deletions NickvisionMoney.GNOME/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ public Program(string[] args)
_mainWindow = null;
_mainWindowController = new MainWindowController(args);
_mainWindowController.AppInfo.Changelog =
@"* Disallowed whitespace-only group and account names
* Fixed an issue where exported PDF values were incorrect
* Fixed an issue where some system cultures were not read properly
* Fixed an issue where scrolling the sidebar with the mouse over the calendar would scroll the calendar instead
* Fixed an issue where leading or trailing spaces in group/account names aren't discarded
* Updated to GNOME 45 runtime with latest libadwaita design
* Updated to .NET 8.0
@"* Fixed an issue where the generated ids of new transactions were incorrect.
* Fixed an issue that caused sort to behave inconsistently.
* Fixed calendar not showing marks for transactions after pressing the ""Today"" button.
* Updated and added translations (Thanks to everyone on Weblate)!";
_application.OnActivate += OnActivate;
if (File.Exists(Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) + "/org.nickvision.money.gresource"))
Expand Down
1 change: 1 addition & 0 deletions NickvisionMoney.GNOME/Views/AccountView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@ private void OnSelectCurrentMonth(Gtk.Button sender, EventArgs e)
private void OnResetCalendarFilter(Gtk.Button sender, EventArgs e)
{
gtk_calendar_select_day(_calendar.Handle, ref g_date_time_new_now_local());
OnCalendarMonthYearChanged(null, e);
_rangeExpander.SetEnableExpansion(false);
}

Expand Down
18 changes: 8 additions & 10 deletions NickvisionMoney.Shared/Controllers/AccountViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,18 @@ private int SortTransactions(uint a, uint b)
else if (SortTransactionsBy == SortBy.Date)
{
compareTo = _account.Transactions[a].Date.CompareTo(_account.Transactions[b].Date);
compareTo = compareTo == 0 ? a.CompareTo(b) : compareTo;
}
else if (SortTransactionsBy == SortBy.Amount)
{
var aAmount = _account.Transactions[a].Amount * (_account.Transactions[a].Type == TransactionType.Income ? 1m : -1m);
var bAmount = _account.Transactions[b].Amount * (_account.Transactions[b].Type == TransactionType.Income ? 1m : -1m);
compareTo = aAmount.CompareTo(bAmount);
compareTo = aAmount.CompareTo(bAmount);
if (compareTo == 0)
{
compareTo = _account.Transactions[a].Date.CompareTo(_account.Transactions[b].Date);
compareTo = compareTo == 0 ? a.CompareTo(b) : compareTo;
}
}
if (!SortFirstToLast)
{
Expand Down Expand Up @@ -628,15 +634,7 @@ public async Task AddTransactionAsync(Transaction transaction)
if (res.Successful)
{
var transactions = _account.Transactions.Keys.ToList();
transactions.Sort((a, b) =>
{
var compareTo = SortTransactionsBy == SortBy.Date ? _account.Transactions[a].Date.CompareTo(_account.Transactions[b].Date) : a.CompareTo(b);
if (!SortFirstToLast)
{
compareTo *= -1;
}
return compareTo;
});
transactions.Sort(SortTransactions);
for (var i = 0; i < transactions.Count; i++)
{
if (transactions[i] == transaction.Id)
Expand Down
2 changes: 1 addition & 1 deletion NickvisionMoney.Shared/Controllers/MainWindowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public MainWindowController(string[] args)
Directory.Delete($"{UserDirectories.Config}{Path.DirectorySeparatorChar}Nickvision{Path.DirectorySeparatorChar}{AppInfo.Name}", true);
}
Aura.Active.SetConfig<Configuration>("config");
AppInfo.Version = "2023.11.0";
AppInfo.Version = "2023.12.0-next";
AppInfo.ShortName = _("Denaro");
AppInfo.Description = _("Manage your personal finances");
AppInfo.SourceRepo = new Uri("https://github.com/NickvisionApps/Denaro");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@
<mediatype>application/x-nmoney</mediatype>
</provides>
<releases>
<release version="2023.11.0" date="2023-11-17">
<release version="2023.12.0-next" date="2023-12-01">
<description translatable="no">
<p>- Disallowed whitespace-only group and account names</p>
<p>- Fixed an issue where exported PDF values were incorrect</p>
<p>- Fixed an issue where some system cultures were not read properly</p>
<p>- Fixed an issue where scrolling the sidebar with the mouse over the calendar would scroll the calendar instead</p>
<p>- Fixed an issue where leading or trailing spaces in group/account names aren't discarded</p>
<p>- Updated to GNOME 45 runtime with latest libadwaita design</p>
<p>- Updated to .NET 8.0</p>
<p>- Fixed an issue where the generated ids of new transactions were incorrect.</p>
<p>- Fixed an issue that caused sort to behave inconsistently.</p>
<p>- Fixed calendar not showing marks for transactions after pressing the "Today" button.</p>
<p>- Updated translations (Thanks to everyone on Weblate)!</p>
</description>
</release>
Expand Down
9 changes: 8 additions & 1 deletion NickvisionMoney.Shared/Models/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,14 @@ public async Task<bool> DeleteTransactionAsync(uint id)
Transactions.Remove(id);
if (id + 1 == NextAvailableTransactionId)
{
NextAvailableTransactionId--;
if(Transactions.Count == 0)
{
NextAvailableTransactionId = 1;
}
else
{
NextAvailableTransactionId = Transactions.Max(x => x.Key) + 1;
}
}
BackupAccountToCSV();
return true;
Expand Down

0 comments on commit 1e84896

Please sign in to comment.