Stammdaten -> Texte bereinigen shows the bookings of one account in the selected year and edits only their Text: inline, search and replace (plain or regex with $1 groups) over the listed rows, tidying spaces, or setting one text for selected rows. A group panel shows the first-word groups the Analyse page will use, updated live. Saving goes through RawDataRepository.SaveTransactionTextsAsync: refused if the file changed since loading or a text is empty, previous version backed up, atomic save. Opened from the menu, a button per account on Konten, and a link on the Analyse page at account level. Also: the content area fills the window between header and footer, so dropdowns on short pages are no longer cut off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2 KiB
C#
49 lines
2 KiB
C#
#nullable enable
|
|
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Schaad.Accounting.Models;
|
|
|
|
namespace Schaad.Accounting.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// The data files of the selected year and mandator as plain JSON text, for the JSON editor.
|
|
/// </summary>
|
|
public interface IRawDataRepository
|
|
{
|
|
/// <summary>Data file names, e.g. "Transactions.json".</summary>
|
|
IReadOnlyList<string> FileNames { get; }
|
|
|
|
Task<RawDataFile> LoadAsync(string fileName);
|
|
|
|
/// <summary>
|
|
/// Validates the text and, if it is valid and the file is still as loaded
|
|
/// (<paramref name="loadedHash"/>), backs up the current file and saves the text.
|
|
/// </summary>
|
|
Task<RawDataSaveResult> SaveAsync(string fileName, string text, string loadedHash);
|
|
|
|
/// <summary>
|
|
/// The transactions of the selected year as they are on disk, with the file's fingerprint
|
|
/// for <see cref="SaveTransactionTextsAsync"/>.
|
|
/// </summary>
|
|
Task<TransactionSnapshot> LoadTransactionsAsync();
|
|
|
|
/// <summary>
|
|
/// Changes only the Text of the given transactions (by Id), with the same safeguards as
|
|
/// <see cref="SaveAsync"/>: refused if the file changed since <paramref name="loadedHash"/>,
|
|
/// previous version backed up.
|
|
/// </summary>
|
|
Task<RawDataSaveResult> SaveTransactionTextsAsync(IReadOnlyDictionary<string, string> textById, string loadedHash);
|
|
}
|
|
|
|
public record TransactionSnapshot(IReadOnlyList<Transaction> Transactions, string Hash);
|
|
|
|
/// <param name="Hash">Fingerprint of the file content, to detect changes made elsewhere.</param>
|
|
public record RawDataFile(string FileName, string Path, string Text, string Hash);
|
|
|
|
/// <param name="File">The saved file as now on disk (re-formatted); null if not saved.</param>
|
|
public record RawDataSaveResult(IReadOnlyList<string> Errors, RawDataFile? File, string? BackupPath)
|
|
{
|
|
public bool Saved => File != null;
|
|
}
|
|
}
|