namespace MoneyMap.Models.Import
{
///
/// Result of an import operation, showing counts of processed transactions.
///
public record ImportResult(int Total, int Inserted, int Skipped, string? Last4FromFile);
///
/// Wrapper for import operation result with success/failure state.
///
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 };
}
///
/// Wrapper for preview operation result with success/failure state.
///
public class PreviewOperationResult
{
public bool IsSuccess { get; init; }
public List? Data { get; init; }
public string? ErrorMessage { get; init; }
public static PreviewOperationResult Success(List data) =>
new() { IsSuccess = true, Data = data };
public static PreviewOperationResult Failure(string error) =>
new() { IsSuccess = false, ErrorMessage = error };
}
///
/// Preview of a transaction before import, with duplicate detection info.
///
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; }
}
///
/// User's selection for payment method during import confirmation.
///
public class PaymentSelection
{
public int? AccountId { get; set; }
public int? CardId { get; set; }
public string? Category { get; set; }
}
///
/// Key for detecting duplicate transactions.
///
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) { }
}
}