3deca29f05
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
2.4 KiB
C#
70 lines
2.4 KiB
C#
namespace MoneyMap.Models.Import
|
|
{
|
|
/// <summary>
|
|
/// Result of an import operation, showing counts of processed transactions.
|
|
/// </summary>
|
|
public record ImportResult(int Total, int Inserted, int Skipped, string? Last4FromFile);
|
|
|
|
/// <summary>
|
|
/// Wrapper for import operation result with success/failure state.
|
|
/// </summary>
|
|
public class ImportOperationResult
|
|
{
|
|
public bool IsSuccess { get; init; }
|
|
public ImportResult? Data { get; init; }
|
|
public string? ErrorMessage { get; init; }
|
|
|
|
public static ImportOperationResult Success(ImportResult data) =>
|
|
new() { IsSuccess = true, Data = data };
|
|
|
|
public static ImportOperationResult Failure(string error) =>
|
|
new() { IsSuccess = false, ErrorMessage = error };
|
|
}
|
|
|
|
/// <summary>
|
|
/// Wrapper for preview operation result with success/failure state.
|
|
/// </summary>
|
|
public class PreviewOperationResult
|
|
{
|
|
public bool IsSuccess { get; init; }
|
|
public List<TransactionPreview>? Data { get; init; }
|
|
public string? ErrorMessage { get; init; }
|
|
|
|
public static PreviewOperationResult Success(List<TransactionPreview> data) =>
|
|
new() { IsSuccess = true, Data = data };
|
|
|
|
public static PreviewOperationResult Failure(string error) =>
|
|
new() { IsSuccess = false, ErrorMessage = error };
|
|
}
|
|
|
|
/// <summary>
|
|
/// Preview of a transaction before import, with duplicate detection info.
|
|
/// </summary>
|
|
public class TransactionPreview
|
|
{
|
|
public required Transaction Transaction { get; init; }
|
|
public bool IsDuplicate { get; init; }
|
|
public required string PaymentMethodLabel { get; init; }
|
|
public string? SuggestedCategory { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// User's selection for payment method during import confirmation.
|
|
/// </summary>
|
|
public class PaymentSelection
|
|
{
|
|
public int? AccountId { get; set; }
|
|
public int? CardId { get; set; }
|
|
public string? Category { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Key for detecting duplicate transactions.
|
|
/// </summary>
|
|
public record TransactionKey(DateTime Date, decimal Amount, string Name, string Memo, int AccountId, int? CardId)
|
|
{
|
|
public TransactionKey(Transaction txn)
|
|
: this(txn.Date, txn.Amount, txn.Name, txn.Memo, txn.AccountId, txn.CardId) { }
|
|
}
|
|
}
|