diff --git a/Schaad.Accounting.Common/Interfaces/Extensions/DecimalExtension.cs b/Schaad.Accounting.Common/Interfaces/Extensions/DecimalExtension.cs deleted file mode 100644 index 1113baf..0000000 --- a/Schaad.Accounting.Common/Interfaces/Extensions/DecimalExtension.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Globalization; -using System.Text; - -namespace Schaad.Accounting.Common.Extensions -{ - public static class DecimalExtension - { - public static string ToFormattedString(this decimal value) - { - var culture = new CultureInfo("de-CH"); - culture.NumberFormat.NumberGroupSeparator = "'"; - return value.ToString("#,0.00", culture); - } - } -} \ No newline at end of file diff --git a/Schaad.Accounting.Common/Schaad.Accounting.Common.csproj b/Schaad.Accounting.Common/Schaad.Accounting.Common.csproj index 0924dc5..47844fe 100644 --- a/Schaad.Accounting.Common/Schaad.Accounting.Common.csproj +++ b/Schaad.Accounting.Common/Schaad.Accounting.Common.csproj @@ -14,4 +14,7 @@ ..\dlls\Schaad.Finance.Api.dll + + + \ No newline at end of file diff --git a/Schaad.Accounting.Services/FileService.cs b/Schaad.Accounting.Services/FileService.cs index c89b6f3..00f63d8 100644 --- a/Schaad.Accounting.Services/FileService.cs +++ b/Schaad.Accounting.Services/FileService.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; +using System.Globalization; using System.IO.Compression; using System.Linq; using System.Text; -using Schaad.Accounting.Common.Extensions; using Schaad.Accounting.Datasets; using Schaad.Accounting.Interfaces; using Schaad.Finance.Api; @@ -133,18 +133,25 @@ namespace Schaad.Accounting.Services if (trx.OriginAccountId == accountId) { - debit = trx.Value.ToFormattedString(); + debit = ToFormattedString(trx.Value); trx.Value *= -1; } else { - credit = trx.Value.ToFormattedString(); + credit = ToFormattedString(trx.Value); } balance += trx.Value; - sb.AppendLine($"{trx.BookingDate:dd.MM.yyyy};{trx.ValueDate:dd.MM.yyyy};{trx.Text};{debit};{credit};{balance.ToFormattedString()}"); + sb.AppendLine($"{trx.BookingDate:dd.MM.yyyy};{trx.ValueDate:dd.MM.yyyy};{trx.Text};{debit};{credit};{ToFormattedString(balance)}"); } var fileBytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(sb.ToString()); return fileBytes; } + + private string ToFormattedString(decimal value) + { + var culture = new CultureInfo("de-CH"); + culture.NumberFormat.NumberGroupSeparator = "'"; + return value.ToString("#,0.00", culture); + } } } \ No newline at end of file diff --git a/Schaad.Accounting.UI/Components/Pages/Home.razor b/Schaad.Accounting.UI/Components/Pages/Home.razor index 427e282..c721fda 100644 --- a/Schaad.Accounting.UI/Components/Pages/Home.razor +++ b/Schaad.Accounting.UI/Components/Pages/Home.razor @@ -1,4 +1,5 @@ @page "/" + @rendermode InteractiveServer Home @@ -26,19 +27,53 @@ Cancel -
- - - - - - - - - - -
Keine Daten vorhanden!
-
-
-
-
\ No newline at end of file + + + + + + + + + + + + + + + @foreach (var transaction in matchingBankTransactions) + { + + + + + + + + + + + } + +
BuchungsdatumValutadatumTextBetragKontoZusatzinfo
@transaction.BookingDate.ToString("dd.MM.yyyy")
@transaction.ValueDate.ToString("dd.MM.yyyy")
+
+ + + @foreach (var text in bookingTexts.OrderBy(t => t)) + { + + } + +
+
+
@transaction.Value.ToFormattedString()
+
+ + +
@transaction.BankTransactionText
+
diff --git a/Schaad.Accounting.UI/Components/Pages/Home.razor.cs b/Schaad.Accounting.UI/Components/Pages/Home.razor.cs index 77a9564..65b0ab4 100644 --- a/Schaad.Accounting.UI/Components/Pages/Home.razor.cs +++ b/Schaad.Accounting.UI/Components/Pages/Home.razor.cs @@ -1,4 +1,5 @@ -using System.IO.Compression; +using System.Diagnostics; +using System.IO.Compression; using Microsoft.AspNetCore.Components; using Microsoft.FluentUI.AspNetCore.Components; using Schaad.Accounting.Datasets; @@ -24,17 +25,33 @@ public partial class Home : ComponentBase [Inject] private IFileService fileService { get; set; } = null!; - private IQueryable? bankTransactionsQueryable; + [Inject] + private IBookingTextRepository bookingTextRepository { get; set; } = null!; + + [Inject] + private ITransactionRepository transactionRepository { get; set; } = null!; + + private List? matchingBankTransactions; + private IReadOnlyList accounts = []; + private IReadOnlyList bookingTexts = []; FluentInputFile? myFileByBuffer; int? progressPercent; string? progressTitle; bool IsCanceled; Dictionary Files = new(); - + + private bool loaded; + protected override Task OnInitializedAsync() { - bankTransactionsQueryable = viewService.GetOpenBankTransactionList().AsQueryable(); + if (loaded == false) { + matchingBankTransactions = viewService.MatchOpenBankTransactions(); + accounts = viewService.GetAccountViewList(); + bookingTexts = bookingTextRepository.GetBookingTextList().Select(b => b.Text).ToArray(); + loaded = true; + } + return base.OnInitializedAsync(); } @@ -82,7 +99,7 @@ public partial class Home : ComponentBase File.Delete(file.Value); } - bankTransactionsQueryable = viewService.GetOpenBankTransactionList().AsQueryable(); + matchingBankTransactions = viewService.MatchOpenBankTransactions(); } private async Task ImportXmlAndShowResultAsync(string fileName) @@ -134,4 +151,22 @@ public partial class Home : ComponentBase { toastService.ShowToast(intent, message, 3000); } + + private async Task BookBankTransactionAsync(Transaction transaction) + { + if (string.IsNullOrEmpty(transaction.Text) || string.IsNullOrEmpty(transaction.TargetAccountId)) + { + ShowToast("Transaktion kann wegen fehlenden Daten nicht gespeichert werden!", ToastIntent.Error); + return; + } + transactionRepository.SaveTransaction(transaction); + matchingBankTransactions!.RemoveAll(q => q == transaction); + await Task.CompletedTask; + } + + private async Task SplitBankTransactionAsync(Transaction transaction) + { + ShowToast("Split noch nicht implementiert!", ToastIntent.Warning); + await Task.CompletedTask; + } } diff --git a/Schaad.Accounting.UI/Components/Pages/Home.razor.css b/Schaad.Accounting.UI/Components/Pages/Home.razor.css new file mode 100644 index 0000000..f98d341 --- /dev/null +++ b/Schaad.Accounting.UI/Components/Pages/Home.razor.css @@ -0,0 +1,42 @@ +table { + width: 100%; + table-layout: fixed; + border-collapse: collapse; + padding-right: 10px; +} + +th, td { + padding: 4px 4px; + vertical-align: middle; + overflow: hidden; + border: 1px solid #ccc; +} + +th { + background-color: #f8f8f8; +} + +th:nth-child(1), td:nth-child(1) { width: 120px; } /* Buchungsdatum */ +th:nth-child(2), td:nth-child(2) { width: 120px; } /* Valutadatum */ +th:nth-child(3), td:nth-child(3) { width: 240px; } /* Text */ +th:nth-child(4), td:nth-child(4) { width: 100px; text-align: right; } /* Betrag */ +th:nth-child(5), td:nth-child(5) { width: 300px; } /* Konto */ +th:nth-child(7), td:nth-child(7), +th:nth-child(8), td:nth-child(8) { width: 40px; text-align: center; } /* Buttons */ + +.text-column input { + width: 100%; + box-sizing: border-box; /* Ensures padding/border doesn't overflow */ +} + +.zusatzinfo-column div { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; +} + +.betrag-column { + text-align: right; + white-space: nowrap; +} diff --git a/Schaad.Accounting.UI/Components/_Imports.razor b/Schaad.Accounting.UI/Components/_Imports.razor index 792f27f..1c85a1a 100644 --- a/Schaad.Accounting.UI/Components/_Imports.razor +++ b/Schaad.Accounting.UI/Components/_Imports.razor @@ -13,5 +13,6 @@ @using Plotly.Blazor @using Schaad.Accounting.UI @using Schaad.Accounting.UI.Components +@using Schaad.Accounting.Models @using Schaad.Accounting.Interfaces