using LINQtoCSV;

namespace StockFin.Models;

/// <summary>
/// Représente une ligne du fichier "Exportation de transactions.csv" (format Trade Republic).
/// Le séparateur est la virgule, les décimales utilisent le point, les valeurs sont entre guillemets.
/// </summary>
public class TransactionCsvRow
{
    /// <summary>Horodatage UTC de la transaction (ex : "2024-09-13T11:15:55.989679Z").</summary>
    [CsvColumn(Name = "datetime", FieldIndex = 1)]
    public DateTime? DateTimeUtc { get; set; }

    /// <summary>Date de la transaction (ex : "2024-09-13").</summary>
    [CsvColumn(Name = "date", FieldIndex = 2)]
    public DateTime? Date { get; set; }

    /// <summary>Type de compte (ex : "DEFAULT").</summary>
    [CsvColumn(Name = "account_type", FieldIndex = 3)]
    public string? AccountType { get; set; }

    /// <summary>Catégorie de la transaction (ex : "CASH", "ORDER").</summary>
    [CsvColumn(Name = "category", FieldIndex = 4)]
    public string? Category { get; set; }

    /// <summary>Type d'opération (ex : "CUSTOMER_INBOUND", "BUY", "SELL", "DIVIDEND").</summary>
    [CsvColumn(Name = "type", FieldIndex = 5)]
    public string? Type { get; set; }

    /// <summary>Classe d'actif (ex : "EQUITY", "ETF" — vide pour les opérations en cash).</summary>
    [CsvColumn(Name = "asset_class", FieldIndex = 6)]
    public string? AssetClass { get; set; }

    /// <summary>Nom du titre ou de la contrepartie.</summary>
    [CsvColumn(Name = "name", FieldIndex = 7)]
    public string? Name { get; set; }

    /// <summary>Symbole boursier / ticker (vide pour les opérations en cash).</summary>
    [CsvColumn(Name = "symbol", FieldIndex = 8)]
    public string? Symbol { get; set; }

    /// <summary>Nombre de parts (vide pour les opérations en cash).</summary>
    [CsvColumn(Name = "shares", FieldIndex = 9)]
    public double? Shares { get; set; }

    /// <summary>Prix unitaire (vide pour les opérations en cash).</summary>
    [CsvColumn(Name = "price", FieldIndex = 10)]
    public double? Price { get; set; }

    /// <summary>Montant de la transaction dans la devise du compte.</summary>
    [CsvColumn(Name = "amount", FieldIndex = 11)]
    public decimal? Amount { get; set; }

    /// <summary>Frais de courtage.</summary>
    [CsvColumn(Name = "fee", FieldIndex = 12)]
    public decimal? Fee { get; set; }

    /// <summary>Taxe (ex : TOB en Belgique).</summary>
    [CsvColumn(Name = "tax", FieldIndex = 13)]
    public decimal? Tax { get; set; }

    /// <summary>Devise du compte (ex : "EUR").</summary>
    [CsvColumn(Name = "currency", FieldIndex = 14)]
    public string? Currency { get; set; }

    /// <summary>Montant dans la devise d'origine (pour les transactions en devise étrangère).</summary>
    [CsvColumn(Name = "original_amount", FieldIndex = 15)]
    public decimal? OriginalAmount { get; set; }

    /// <summary>Devise d'origine (ex : "USD").</summary>
    [CsvColumn(Name = "original_currency", FieldIndex = 16)]
    public string? OriginalCurrency { get; set; }

    /// <summary>Taux de change appliqué.</summary>
    [CsvColumn(Name = "fx_rate", FieldIndex = 17)]
    public decimal? FxRate { get; set; }

    /// <summary>Description libre de la transaction.</summary>
    [CsvColumn(Name = "description", FieldIndex = 18)]
    public string? Description { get; set; }

    /// <summary>Identifiant unique de la transaction (GUID).</summary>
    [CsvColumn(Name = "transaction_id", FieldIndex = 19)]
    public string? TransactionId { get; set; }

    /// <summary>Nom de la contrepartie (virement entrant/sortant).</summary>
    [CsvColumn(Name = "counterparty_name", FieldIndex = 20)]
    public string? CounterpartyName { get; set; }

    /// <summary>IBAN de la contrepartie.</summary>
    [CsvColumn(Name = "counterparty_iban", FieldIndex = 21)]
    public string? CounterpartyIban { get; set; }

    /// <summary>Référence du paiement (communication).</summary>
    [CsvColumn(Name = "payment_reference", FieldIndex = 22)]
    public string? PaymentReference { get; set; }

    /// <summary>Code MCC (Merchant Category Code) — uniquement pour les paiements par carte.</summary>
    [CsvColumn(Name = "mcc_code", FieldIndex = 23)]
    public string? MccCode { get; set; }
}
