Skip to content

Commit

Permalink
Tech dept (#20)
Browse files Browse the repository at this point in the history
* Upgrade .net to version 8
* Add PayeeId to import wizard
* Add DefaultBackupDirectory
* Change colors on the menu
  • Loading branch information
vov4uk authored Jan 18, 2024
1 parent 1c5f9a7 commit cf970a9
Show file tree
Hide file tree
Showing 41 changed files with 425 additions and 226 deletions.
Binary file modified Financier.Desktop.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
| What | Badge|
| ---- | ---- |
| Build | [![Build Status](https://dev.azure.com/khmelovskyi/Financier.Desktop/_apis/build/status/vov4uk.Financier.Desktop?branchName=master)](https://dev.azure.com/khmelovskyi/Financier.Desktop/_build/latest?definitionId=2&branchName=master)|
| Latest | [![GitHub (pre-)release](https://img.shields.io/github/v/release/vov4uk/financier.desktop?include_prereleases)](https://github.com/vov4uk/Financier.Desktop/releases)|
| Total| [![Github Releases](https://img.shields.io/github/downloads/vov4uk/Financier.Desktop/total)](https://github.com/vov4uk/Financier.Desktop/releases)|
| Sonar | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vov4uk_Financier.Desktop&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vov4uk_Financier.Desktop)|

# Financier Desktop
[**Install the .NET Desktop Runtime.**](https://dotnet.microsoft.com/en-us/download/dotnet/6.0/runtime)

MVP (minimum viable product) application, with enough functions to work with Financier .backup on Windows.
More info on [Github pages](https://vov4uk.github.io/Financier.Desktop/)
<h1 align="center">Financier Desktop</h1>
<p align="center">
<a href="https://dev.azure.com/khmelovskyi/Financier.Desktop/_build/latest?definitionId=2&branchName=master">
<img alt="Build" src="https://dev.azure.com/khmelovskyi/Financier.Desktop/_apis/build/status/vov4uk.Financier.Desktop?branchName=master"/>
</a>
<a href="https://github.com/vov4uk/Financier.Desktop/releases">
<img alt="GitHub release" src="https://img.shields.io/github/v/release/vov4uk/financier.desktop?include_prereleases"/>
</a>
<a href="https://github.com/vov4uk/Financier.Desktop/releases">
<img alt="GitHub Latest" src="https://img.shields.io/github/downloads/vov4uk/Financier.Desktop/latest/total"/>
</a>
<a href="https://github.com/vov4uk/Financier.Desktop/releases">
<img alt="Github Releases" src="https://img.shields.io/github/downloads/vov4uk/Financier.Desktop/total"/>
</a>
<a href="https://sonarcloud.io/summary/new_code?id=vov4uk_Financier.Desktops">
<img alt="Quality Gate Status" src="https://sonarcloud.io/api/project_badges/measure?project=vov4uk_Financier.Desktop&metric=alert_status"/>
</a>

</p>

[**Install the .NET Desktop Runtime.**](https://dotnet.microsoft.com/en-us/download/dotnet/8.0/runtime)

MVP (minimum viable product) application, with enough functions to work with Financisto .backup on Windows.
More info on [Github pages](https://vov4uk.github.io/Financier.Desktop)

## About
Desktop version of [Financier](https://github.com/handydevcom/financier "Financier") which is a fork of the great [Financisto](https://github.com/dsolonenko/financisto) app. Financisto is an open-source personal finance tracker for Android platform.

## Supported features

- Open/save Financier (Financisto) .backup files
- Open/save Financisto .backup files
- View transactions list
- Transactions search and filtering
- Edit transactions/transfers
- Duplicate transactions/transfers
- Edit entities (projects, locations, payees...)
- Import CSV report from Monobank
- Import PDF report from A-Bank
- Import PDF report from PUMB
- Parse recipiet text to SPLIT transaction
- Save .backup as SQLite database (.db file)
- Reporting (kudos to [@2ruslan](https://github.com/2ruslan))
Expand Down
2 changes: 1 addition & 1 deletion src/Financier.Adapter/BackupReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void ReadHeader()
break;

case Backup.VERSION_NAME:
BackupVersion.Version = Version.Parse(line.Value);
BackupVersion.Version = line.Value;
break;

case Backup.DATABASE_VERSION:
Expand Down
2 changes: 1 addition & 1 deletion src/Financier.Adapter/BackupVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class BackupVersion
{
public string Package { get; set; }
public int VersionCode { get; set; }
public Version Version { get; set; }
public string Version { get; set; }
public int DatabaseVersion { get; set; }
}
}
8 changes: 4 additions & 4 deletions src/Financier.Common/Assets/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
</emoji:TextBlock>
</DataTemplate>
<Path x:Key="IconRefresh"
Fill="DarkBlue"
Stroke="DarkBlue"
Fill="#858585"
Stroke="#858585"
Stretch="Uniform"
Data="M111.9,61.57a5.36,5.36,0,0,1,10.71,0A61.3,61.3,0,0,1,17.54,104.48v12.35a5.36,5.36,0,0,1-10.72,0V89.31A5.36,5.36,0,0,1,12.18,84H40a5.36,5.36,0,1,1,0,10.71H23a50.6,50.6,0,0,0,88.87-33.1ZM106.6,5.36a5.36,5.36,0,1,1,10.71,0V33.14A5.36,5.36,0,0,1,112,38.49H84.44a5.36,5.36,0,1,1,0-10.71H99A50.6,50.6,0,0,0,10.71,61.57,5.36,5.36,0,1,1,0,61.57,61.31,61.31,0,0,1,91.07,8,61.83,61.83,0,0,1,106.6,20.27V5.36Z" />
<Path x:Key="IconClearFilters"
Fill="DarkBlue"
Stroke="DarkBlue"
Fill="#858585"
Stroke="#858585"
Stretch="Uniform"
Data="M91.124,15.645c12.928,0,23.406,10.479,23.406,23.406 c0,12.927-10.479,23.406-23.406,23.406c-12.927,0-23.406-10.479-23.406-23.406C67.718,26.125,78.197,15.645,91.124,15.645 L91.124,15.645z M2.756,0h117.322c1.548,0,2.802,1.254,2.802,2.802c0,0.848-0.368,1.622-0.996,2.139l-10.667,13.556 c-1.405-1.375-2.95-2.607-4.614-3.672l6.628-9.22H9.43l37.975,46.171c0.59,0.516,0.958,1.254,0.958,2.102v49.148l21.056-9.623 V57.896c1.651,1.9,3.548,3.582,5.642,4.996v32.133c0,1.105-0.627,2.064-1.586,2.506l-26.476,12.758 c-1.327,0.773-3.023,0.332-3.798-1.033c-0.258-0.441-0.368-0.92-0.368-1.4V55.02L0.803,4.756c-1.07-1.106-1.07-2.839,0-3.945 C1.355,0.258,2.056,0,2.756,0L2.756,0z M96.93,28.282c1.328-1.349,3.489-1.355,4.825-0.013c1.335,1.342,1.341,3.524,0.013,4.872 l-5.829,5.914l5.836,5.919c1.317,1.338,1.299,3.506-0.04,4.843c-1.34,1.336-3.493,1.333-4.81-0.006l-5.797-5.878l-5.807,5.889 c-1.329,1.349-3.489,1.355-4.826,0.013c-1.335-1.342-1.341-3.523-0.013-4.872l5.83-5.913l-5.836-5.919 c-1.317-1.338-1.3-3.507,0.04-4.843c1.339-1.336,3.492-1.333,4.81,0.006l5.796,5.878L96.93,28.282L96.93,28.282z" />
</ResourceDictionary>
12 changes: 6 additions & 6 deletions src/Financier.Common/Filters/PeriodFilter.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ private static (DateTime? from, DateTime? to) UpdatePeriod(PeriodType type, Date
{
var today = DateTime.Today;

from = new DateTime(today.AddMonths(-1).Year, today.AddMonths(-1).Month, 1);
to = new DateTime(today.Year, today.Month, 1).AddMilliseconds(-1);
from = new DateTime(today.AddMonths(-1).Year, today.AddMonths(-1).Month, 1,0,0,0, DateTimeKind.Local);
to = new DateTime(today.Year, today.Month, 1,0,0,0, DateTimeKind.Local).AddMilliseconds(-1);
}
break;
case PeriodType.CurrentWeek:
Expand All @@ -108,8 +108,8 @@ private static (DateTime? from, DateTime? to) UpdatePeriod(PeriodType type, Date
{
var today = DateTime.Today;

from = new DateTime(today.Year, today.Month, 1);
to = new DateTime(today.AddMonths(1).Year, today.AddMonths(1).Month, 1).AddMilliseconds(-1);
from = new DateTime(today.Year, today.Month, 1, 0, 0, 0, DateTimeKind.Local);
to = new DateTime(today.AddMonths(1).Year, today.AddMonths(1).Month, 1, 0, 0, 0, DateTimeKind.Local).AddMilliseconds(-1);
}
break;
case PeriodType.PreviousAndCurrentWeek:
Expand All @@ -128,8 +128,8 @@ private static (DateTime? from, DateTime? to) UpdatePeriod(PeriodType type, Date
{
var today = DateTime.Today;

from = new DateTime(today.AddMonths(-1).Year, today.AddMonths(-1).Month, 1);
to = new DateTime(today.AddMonths(1).Year, today.AddMonths(1).Month, 1).AddMilliseconds(-1);
from = new DateTime(today.AddMonths(-1).Year, today.AddMonths(-1).Month, 1, 0, 0, 0, DateTimeKind.Local);
to = new DateTime(today.AddMonths(1).Year, today.AddMonths(1).Month, 1, 0, 0, 0, DateTimeKind.Local).AddMilliseconds(-1);
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/Financier.Common/Financier.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Financier.DataAccess/Abstractions/IBaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface IBaseRepository<T> where T : class

Task<List<T>> FindManyAsync(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes);

Task<List<TResult>> FindManyAsync<TResult>(
Task<List<TResult>> FindManyAndProjectAsync<TResult>(
Expression<Func<T, bool>> predicate,
Expression<Func<T, TResult>> projection,
params Expression<Func<T, object>>[] includes);
Expand Down
2 changes: 1 addition & 1 deletion src/Financier.DataAccess/BaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public virtual async Task<List<T>> FindManyAsync(Expression<Func<T, bool>> predi
return await result?.ToListAsync();
}

public virtual async Task<List<TResult>> FindManyAsync<TResult>(
public virtual async Task<List<TResult>> FindManyAndProjectAsync<TResult>(
Expression<Func<T, bool>> predicate,
Expression<Func<T, TResult>> projection,
params Expression<Func<T, object>>[] includes)
Expand Down
27 changes: 19 additions & 8 deletions src/Financier.DataAccess/FinancierDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,14 @@ public async Task RebuildAccountBalanceAsync(int accountId)
}

var acc = context.Accounts.FirstOrDefault(x => x.Id == accountId);
acc.TotalAmount = balance;
var lastTransaction = transactions.LastOrDefault();
acc.LastTransactionDate = lastTransaction?.DateTime ?? 0;
acc.LastTransactionId = lastTransaction?.Id ?? 0;
context.Accounts.Update(acc);
if (acc != null)
{
acc.TotalAmount = balance;
acc.LastTransactionDate = lastTransaction?.DateTime ?? 0;
acc.LastTransactionId = lastTransaction?.Id ?? 0;
context.Accounts.Update(acc);
}
await context.SaveChangesAsync();
}
}
Expand Down Expand Up @@ -197,9 +200,17 @@ public async Task<IEnumerable<Transaction>> GetSubTransactionsAsync(int id)
if (id != 0)
{
using var uow = CreateUnitOfWork();
return (await uow.GetRepository<Transaction>().FindManyAsync(
predicate: x => x.ParentId == id,
includes: new Expression<Func<Transaction, object>>[]{ o => o.OriginalCurrency, c => c.Category})) ?? Array.Empty<Transaction>().ToList();
var subTransactions = await uow.GetRepository<Transaction>().
FindManyAsync(
x => x.ParentId == id,
o => o.OriginalCurrency,
c => c.Category);

if (subTransactions == null)
{
return Array.Empty<Transaction>();
}
return subTransactions;
}

return Array.Empty<Transaction>();
Expand Down Expand Up @@ -250,7 +261,7 @@ public async Task InsertOrUpdateAsync<T>(IEnumerable<T> entities)
int ordinal = reader.GetOrdinal(customAttribute.Name);
object obj = ordinal != -1 ?
reader.GetValue(ordinal) :
throw new Exception(string.Format("Class [{0}] have attribute of field [{1}] which not exist in reader", this.GetType(), customAttribute.Name));
throw new InvalidCastException(string.Format("Class [{0}] have attribute of field [{1}] which not exist in reader", this.GetType(), customAttribute.Name));

if (obj != DBNull.Value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Financier.Desktop/Data/BaseTransactionDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public DateTime Time

public DateTime DateTime
{
get { return new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second); }
get { return new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second, DateTimeKind.Local); }
}

public int Id
Expand Down
21 changes: 15 additions & 6 deletions src/Financier.Desktop/Data/TransactionDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ public TransactionDto(Transaction transaction, IEnumerable<Transaction> subTrans
}
else
{
list.Add(new TransactionDto(t));
var tr = new TransactionDto(t);

// if transaction not in home currency, replace FromAmount with OriginalFromAmount to show correct values
if (IsOriginalFromAmountVisible)
{
tr.FromAmount = tr.OriginalFromAmount ?? 0;
}
list.Add(tr);
}
}

Expand All @@ -83,7 +90,7 @@ public TransactionDto(Transaction transaction)

public AccountFilterModel FromAccount
{
get => fromAccount ??= DbManual.Account?.FirstOrDefault(x => x.Id == FromAccountId);
get => fromAccount ??= DbManual.Account?.Find(x => x.Id == FromAccountId);
set
{
if (SetProperty(ref fromAccount, value))
Expand All @@ -110,12 +117,12 @@ public int FromAccountId

public CurrencyModel FromAccountCurrency
{
get => DbManual.Currencies?.FirstOrDefault(x => x.Id == (FromAccount != null ? FromAccount.CurrencyId : 0));
get => DbManual.Currencies?.Find(x => x.Id == (FromAccount != null ? FromAccount.CurrencyId : 0));
}

public CategoryModel Category
{
get => category ??= DbManual.Category?.FirstOrDefault(x => x.Id == CategoryId);
get => category ??= DbManual.Category?.Find(x => x.Id == CategoryId);
set
{
if (SetProperty(ref category, value))
Expand Down Expand Up @@ -187,7 +194,7 @@ public int? LocationId

public CurrencyModel OriginalCurrency
{
get => currency ??= DbManual.Currencies?.FirstOrDefault(x => x.Id == OriginalCurrencyId);
get => currency ??= DbManual.Currencies?.Find(x => x.Id == OriginalCurrencyId);
set
{
if (SetProperty(ref currency, value))
Expand Down Expand Up @@ -268,7 +275,7 @@ public string RateString
if (Rate != 0)
{
var d = 1.0 / Rate;
var localCurrency = DbManual.Currencies?.FirstOrDefault(x => x.Id == fromAccount?.Id);
var localCurrency = DbManual.Currencies?.Find(x => x.Id == fromAccount?.Id);
return $"1{currency?.Name}={Rate:F5}{localCurrency?.Name}, 1{localCurrency?.Name}={d:F5}{currency?.Name}";
}

Expand Down Expand Up @@ -322,7 +329,9 @@ public void RecalculateUnSplitAmount()
internal void RecalculateRate()
{
if (originalFromAmount != null && originalFromAmount != 0)
{
Rate = Math.Abs(fromAmount / 100.0 / (originalFromAmount.Value / 100.0));
}
}
}
}
8 changes: 4 additions & 4 deletions src/Financier.Desktop/Data/TransferDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public TransferDto(Transaction transaction)
toAmount = transaction.ToAmount;
date = UnixTimeConverter.Convert(transaction.DateTime).Date;
time = UnixTimeConverter.Convert(transaction.DateTime);
fromAccount = DbManual.Account.FirstOrDefault(x => x.Id == fromAccountId);
toAccount = DbManual.Account.FirstOrDefault(x => x.Id == toAccountId);
fromAccount = DbManual.Account.Find(x => x.Id == fromAccountId);
toAccount = DbManual.Account.Find(x => x.Id == toAccountId);
}

public AccountFilterModel FromAccount
Expand All @@ -50,7 +50,7 @@ public AccountFilterModel FromAccount

public CurrencyModel FromAccountCurrency
{
get => DbManual.Currencies?.FirstOrDefault(x => x.Id == (FromAccount != null ? FromAccount.CurrencyId : 0));
get => DbManual.Currencies?.Find(x => x.Id == (FromAccount != null ? FromAccount.CurrencyId : 0));
}

public int FromAccountId
Expand Down Expand Up @@ -126,7 +126,7 @@ public int ToAccountId

public CurrencyModel ToAccountCurrency
{
get => DbManual.Currencies?.FirstOrDefault(x => x.Id == (ToAccount != null ? ToAccount.CurrencyId : 0));
get => DbManual.Currencies?.Find(x => x.Id == (ToAccount != null ? ToAccount.CurrencyId : 0));
}

public long ToAmount
Expand Down
19 changes: 8 additions & 11 deletions src/Financier.Desktop/Financier.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>Images\ic_launcher.ico</ApplicationIcon>
Expand All @@ -14,10 +14,7 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Images\pumb.png" />
</ItemGroup>

<ItemGroup>
<Resource Include="Images\folder.png" />
<Resource Include="Images\ic_launcher.ico" />
<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -92,16 +89,16 @@

<ItemGroup>
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="DataGridExtensions" Version="2.6.0-beta1" />
<PackageReference Include="Docnet.Core" Version="2.4.0-alpha.2" />
<PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.103" />
<PackageReference Include="DataGridExtensions" Version="2.6.0" />
<PackageReference Include="Docnet.Core" Version="2.6.0" />
<PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.113" />
<PackageReference Include="Emoji.Wpf" Version="0.3.4" />
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.1.3" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="Prism.Core" Version="8.1.97" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.0.0.68202">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.16.0.82469">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Binary file added src/Financier.Desktop/Images/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cf970a9

Please sign in to comment.