Skip to content

Commit

Permalink
Merge pull request #70 from TheAxelander/pre-release
Browse files Browse the repository at this point in the history
Merge changes for version 1.5
  • Loading branch information
TheAxelander authored Feb 19, 2022
2 parents a163326 + 90eaf0e commit 8cf696a
Show file tree
Hide file tree
Showing 26 changed files with 1,937 additions and 81 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### 1.5 (2022-02-19)

* [Add] Option to set Localization [#52](https://github.com/TheAxelander/OpenBudgeteer/issues/52)
* [Add] Enable mapping of seperated columns for Debit and Credit Amount on Import Page [#53](https://github.com/TheAxelander/OpenBudgeteer/issues/53)
* [Add] Duplicate Check before importing data with an option to exclude certain records [#49](https://github.com/TheAxelander/OpenBudgeteer/issues/49)
* [Fixed] Moved Sqlite database path back to `/app/database` [#63](https://github.com/TheAxelander/OpenBudgeteer/issues/63)
* [Fixed] Crash on Rules Page in case a Bucket has been deleted with an existing RuleSet [#65](https://github.com/TheAxelander/OpenBudgeteer/issues/65)
* [Fixed] Include Transactions which are in modification in all filters to prevent immediate disappearance [#67](https://github.com/TheAxelander/OpenBudgeteer/issues/67)

### 1.4.1 (2021-11-28)

* [Changed] Handling of Bucket Group creation (fixes also crashes during creation cancellation [#56](https://github.com/TheAxelander/OpenBudgeteer/issues/56))
Expand Down
2 changes: 1 addition & 1 deletion OpenBudgeteer.Blazor/OpenBudgeteer.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="ChartJs.Blazor" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" />
<PackageReference Include="Tewr.Blazor.FileReader" Version="3.2.0.21211" />
</ItemGroup>
Expand Down
93 changes: 80 additions & 13 deletions OpenBudgeteer.Blazor/Pages/Import.razor
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
</select>
</div>
<div class="col">
<label>Amount:</label>
<label>Amount / Debit:</label>
<select class="form-control form-control-sm" @onchange=@AmountColumn_SelectionChanged>
<option value="@_placeholderItemValue">---Select Column---</option>
@foreach (var column in _dataContext.IdentifiedColumns)
Expand All @@ -193,6 +193,24 @@
}
</select>
</div>
<div class="col">
<label>Credit (optional):</label>
<select class="form-control form-control-sm" @onchange=@CreditColumn_SelectionChanged>
<option value="@_placeholderItemValue">---Select Column---</option>
@foreach (var column in _dataContext.IdentifiedColumns)
{
if (column == _dataContext.SelectedImportProfile.CreditColumnName)
{
<option selected value="@column">@column</option>
}
else
{
<option value="@column">@column</option>
}
}
</select>
<p><small>Only required if Debit and Credit values are in separate columns</small></p>
</div>
</div>
</div>
}
Expand All @@ -201,15 +219,16 @@
{
<div class="div-margin-top">
<h5>Step 4: Validate and Import Data</h5>
<button class="btn btn-sm btn-primary header-action-button" @onclick=ValidateData>Validate Data</button>
<button class="btn btn-sm btn-primary header-action-button" @onclick=ValidateDataAsync>Validate Data</button>
@if (_dataContext.ValidRecords > 0)
{
<button class="btn btn-sm btn-primary header-action-button" @onclick=ImportData>Import Data</button>
<button class="btn btn-sm btn-primary header-action-button" @onclick=ImportDataAsync>Import Data</button>
}
<div>
<span>Total Records: @_dataContext.TotalRecords</span><br/>
<span>Valid Records: @_dataContext.ValidRecords</span><br/>
<span>Records with errors: @_dataContext.RecordsWithErrors</span>
<span>Records with errors: @_dataContext.RecordsWithErrors</span><br/>
<span>Potential Duplicates: @_dataContext.PotentialDuplicates</span><br/>
@if (_validationErrorMessage != string.Empty)
{
<span style="color: red">Error message: @_validationErrorMessage</span>
Expand Down Expand Up @@ -271,6 +290,48 @@
</table>
</div>
}

@if (_dataContext.Duplicates.Any())
{
<div class="div-margin-top">
<h5>Potential Duplicates:</h5>
<table class="table table-sm table-hover">
<thead>
<tr class="header-row">
<th style="text-align: right; width:100px">Date</th>
<th style="width:150px">Account</th>
<th style="width:250px">Payee</th>
<th>Memo</th>
<th style="text-align: right; width: 90px">Amount</th>
<th style="width: 90px"></th>
</tr>
</thead>
<tbody>
@foreach (var duplicate in _dataContext.Duplicates)
{
<tr>
<td class="col-numbers">@duplicate.Item1.Result.TransactionDate.ToShortDateString()</td>
<td>@_dataContext.SelectedAccount.Name</td>
<td>@duplicate.Item1.Result.Payee</td>
<td>@duplicate.Item1.Result.Memo</td>
<td class="col-numbers">@duplicate.Item1.Result.Amount</td>
<td class="col-buttons"><button class="btn btn-sm btn-danger" @onclick="() => _dataContext.ExcludeDuplicateRecord(duplicate)">Exclude</button></td>
</tr>
foreach (var bankTransaction in duplicate.Item2)
{
<tr class="table-warning">
<td class="col-numbers">@bankTransaction.TransactionDate.ToShortDateString()</td>
<td>@_dataContext.SelectedAccount.Name</td>
<td>@bankTransaction.Payee</td>
<td>@bankTransaction.Memo</td>
<td class="col-numbers">@bankTransaction.Amount</td>
</tr>
}
}
</tbody>
</table>
</div>
}
}

<div class="div-margin-top">
Expand Down Expand Up @@ -359,14 +420,14 @@
_step2Enabled = true;
}

void LoadProfile()
async Task LoadProfile()
{
// Workaround for setting the SelectedImportProfile as the first item is always selected but doesn't trigger OnChange
if (_dataContext.SelectedImportProfile == null && _dataContext.AvailableImportProfiles.Count > 0)
{
_dataContext.SelectedImportProfile = _dataContext.AvailableImportProfiles.First();
}
var result = _dataContext.LoadProfile();
var result = await _dataContext.LoadProfileAsync();
if (result.IsSuccessful)
{
_step3Enabled = _dataContext.SelectedImportProfile.ImportProfileId != 0;
Expand Down Expand Up @@ -404,17 +465,16 @@
if (string.IsNullOrEmpty(_dataContext.SelectedImportProfile.AmountColumnName) ||
_dataContext.SelectedImportProfile.AmountColumnName == _placeholderItemValue) return;
_step4Enabled = true;
ValidateData();
}

void ValidateData()
async Task ValidateDataAsync()
{
_validationErrorMessage = _dataContext.ValidateData().Message;
_validationErrorMessage = (await _dataContext.ValidateDataAsync()).Message;
}

void ImportData()
async Task ImportDataAsync()
{
var result = _dataContext.ImportData();
var result = await _dataContext.ImportDataAsync();
_importConfirmationMessage = result.Message;
_isConfirmationModalDialogVisible = true;
}
Expand All @@ -431,13 +491,13 @@
HandleResult((_dataContext.LoadData()));
}

void ImportProfile_SelectionChanged(ChangeEventArgs e)
async void ImportProfile_SelectionChanged(ChangeEventArgs e)
{
_step3Enabled = false;
_step4Enabled = false;
var value = Convert.ToInt32(e.Value);
_dataContext.SelectedImportProfile = value == _placeholderItemId ? new ImportProfile() : _dataContext.AvailableImportProfiles.First(i => i.ImportProfileId == value);
if (_dataContext.SelectedImportProfile != null) LoadProfile();
if (_dataContext.SelectedImportProfile != null) await LoadProfile();
}

void TargetAccount_SelectionChanged(ChangeEventArgs e)
Expand Down Expand Up @@ -475,6 +535,13 @@
CheckColumnMapping();
}

void CreditColumn_SelectionChanged(ChangeEventArgs e)
{
var value = Convert.ToString(e.Value);
_dataContext.SelectedImportProfile.CreditColumnName = value == _placeholderItemValue ? null : _dataContext.IdentifiedColumns.First(i => i == value);
CheckColumnMapping();
}

void HandleResult(ViewModelOperationResult result)
{
if (!result.IsSuccessful)
Expand Down
2 changes: 1 addition & 1 deletion OpenBudgeteer.Blazor/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</div>
<div class="navbar-text">
<span>
Version: 1.4.1 (<a href="https://github.com/TheAxelander/OpenBudgeteer/blob/master/CHANGELOG.md" target="_blank">Change Log</a>)
Version: 1.5 (<a href="https://github.com/TheAxelander/OpenBudgeteer/blob/master/CHANGELOG.md" target="_blank">Change Log</a>)
</span>
</div>
</div>
Expand Down
31 changes: 18 additions & 13 deletions OpenBudgeteer.Blazor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@ public Startup(IConfiguration configuration)
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization();
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddFileReaderService();
services.AddScoped<YearMonthSelectorViewModel>();
var configurationSection = Configuration.GetSection("Connection");
var provider = configurationSection?["Provider"];

var configurationConnectionSection = Configuration.GetSection("Connection");
var provider = configurationConnectionSection?["Provider"];
string connectionString;
switch (provider)
{
case "mysql":
connectionString = $"Server={configurationSection?["Server"]};" +
$"Port={configurationSection?["Port"]};" +
$"Database={configurationSection?["Database"]};" +
$"User={configurationSection?["User"]};" +
$"Password={configurationSection?["Password"]}";
connectionString = $"Server={configurationConnectionSection?["Server"]};" +
$"Port={configurationConnectionSection?["Port"]};" +
$"Database={configurationConnectionSection?["Database"]};" +
$"User={configurationConnectionSection?["User"]};" +
$"Password={configurationConnectionSection?["Password"]}";

services.AddDbContext<DatabaseContext>(options => options.UseMySql(
connectionString,
Expand All @@ -55,7 +57,7 @@ public void ConfigureServices(IServiceCollection services)

break;
case "sqlite":
connectionString = "Data Source=openbudgeteer.db";
connectionString = "Data Source=database/openbudgeteer.db";
services.AddDbContext<DatabaseContext>(options => options.UseSqlite(
connectionString,
b => b.MigrationsAssembly("OpenBudgeteer.Core")),
Expand All @@ -70,6 +72,11 @@ public void ConfigureServices(IServiceCollection services)
throw new ArgumentOutOfRangeException($"Database provider {provider} not supported");
}

// var configurationAppSettingSection = Configuration.GetSection("AppSettings");
// var cultureInfo = new CultureInfo(configurationAppSettingSection["Culture"]);
// CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
// CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // Required to read ANSI Text files
}

Expand All @@ -89,6 +96,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseHttpsRedirection();
app.UseStaticFiles();

var configurationAppSettingSection = Configuration.GetSection("AppSettings");
app.UseRequestLocalization(configurationAppSettingSection["Culture"]);

app.UseRouting();

Expand All @@ -97,10 +107,5 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});

// TODO Get Culture from Settings
var cultureInfo = new CultureInfo("de-DE");
CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
}
}
7 changes: 5 additions & 2 deletions OpenBudgeteer.Blazor/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
"Connection": {
"Provider" : "mysql",
"Database": "openbudgeteer-dev",
"Server": "127.0.0.1",
"Server": "192.168.178.86",
"Port": "3306",
"User": "openbudgeteer-dev",
"Password": "openbudgeteer-dev"
},
},
"AppSettings": {
"Culture": "en-US"
},
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down
24 changes: 23 additions & 1 deletion OpenBudgeteer.Core.Test/OpenBudgeteer.Core.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,29 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<None Remove="Resources\TestImportFile1.txt" />
<None Remove="Resources\TestImportFile2.txt" />
<None Remove="Resources\TestImportFile3.txt" />
<None Remove="Resources\TestImportFile4.txt" />
</ItemGroup>

<ItemGroup>
<Content Include="Resources\TestImportFile4.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TestImportFile3.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TestImportFile2.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TestImportFile1.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
15 changes: 15 additions & 0 deletions OpenBudgeteer.Core.Test/Resources/TestImportFile1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"Account:";"DE0123456789 / My Bank Account";

"This file contains the following details:";
"Valid Records:";"4";
"Invalid Records:";"0";
"Delimiter:";";";
"Text Qualifier:";""";
"Date Format:";"dd.MM.yyyy";
"Number Format:";"de-DE";

"Accounting Date";"Date";"Type";"Payee";"Memo";"IBAN";"Amount (EUR)";
"14.02.2022";"14.02.2022";"Online Payment";"Lorem ipsum";"dolor sit amet";"DE987654321";"-2,95";
"15.02.2022";"15.02.2022";"Credit Card";"Foobar Company";"";"DE987654321";"-27,50";
"16.02.2022";"16.02.2022";"Bank Transfer";"EMPLOYER";"Income Feb/2022";"DE987654321";"43,00";
"17.02.2022";"17.02.2022";"Bank Transfer";"The Webshop.com";"Billing";"DE987654321";"-6,34";
15 changes: 15 additions & 0 deletions OpenBudgeteer.Core.Test/Resources/TestImportFile2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"Account:";"DE0123456789 / My Bank Account";

"This file contains the following details:";
"Valid Records:";"4";
"Invalid Records:";"0";
"Delimiter:";";";
"Text Qualifier:";""";
"Date Format:";"dd.MM.yyyy";
"Number Format:";"de-DE";

"Accounting Date";"Date";"Type";"Payee";"Memo";"IBAN";"Debit (EUR)";"Credit (EUR)";
"14.02.2022";"14.02.2022";"Online Payment";"Lorem ipsum";"dolor sit amet";"DE987654321";"";"-2,95";
"15.02.2022";"15.02.2022";"Credit Card";"Foobar Company";"";"DE987654321";"";"-27,50";
"16.02.2022";"16.02.2022";"Bank Transfer";"EMPLOYER";"Income Feb/2022";"DE987654321";"43,00";"";
"17.02.2022";"17.02.2022";"Bank Transfer";"The Webshop.com";"Billing";"DE987654321";"";"6,34";
15 changes: 15 additions & 0 deletions OpenBudgeteer.Core.Test/Resources/TestImportFile3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"Account:";"DE0123456789 / My Bank Account";

"This file contains the following details:";
"Valid Records:";"2";
"Invalid Records:";"2";
"Delimiter:";";";
"Text Qualifier:";""";
"Date Format:";"dd.MM.yyyy";
"Number Format:";"de-DE";

"Accounting Date";"Date";"Type";"Payee";"Memo";"IBAN";"Amount (EUR)";
"14.02.2022";"14.02.2022";"Online Payment";"Lorem ipsum";"dolor sit amet";"DE987654321";"-2,95";
"15.02.2022";"15.02.2022";"Credit Card";"Foobar Company";"";"DE987654321";"abc";
"16.02.2022";"16.02.2022";"Bank Transfer";"EMPLOYER";"Income Feb/2022";"DE987654321";"43,00";
"17.02.2022";"17.02.2022";"Bank Transfer";"The Webshop.com";"Billing";"DE987654321";"","-6,34";
15 changes: 15 additions & 0 deletions OpenBudgeteer.Core.Test/Resources/TestImportFile4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'Account:','DE0123456789 / My Bank Account',

'This file contains the following details:',
'Valid Records:','4',
'Invalid Records:','0',
'Delimiter:',',',
'Text Qualifier:',''',
'Date Format:','yyyy-MM-dd',
'Number Format:','en-US',

'Accounting Date','Date','Type','Payee','Memo','IBAN','Amount (USD)',
'2022-02-14','2022-02-14','Online Payment','Lorem ipsum','dolor sit amet','DE987654321','-2.95',
'2022-02-15','2022-02-15','Credit Card','Foobar Company','','DE987654321','-27.50',
'2022-02-16','2022-02-16','Bank Transfer','EMPLOYER','Income Feb/2022','DE987654321','43.00',
'2022-02-17','2022-02-17','Bank Transfer','The Webshop.com','Billing','DE987654321','-6.34',
Loading

0 comments on commit 8cf696a

Please sign in to comment.