using CsvHelper.Configuration.Attributes;

namespace PowderCoating.Application.DTOs.Import;

/// <summary>
/// DTO for importing invoice headers from CSV files.
/// Column names match the native CSV export (ExportInvoicesCsv) for round-trip compatibility.
/// CustomerEmail is an additional optional column for more reliable customer matching when
/// the file did not originate from the native export.
/// </summary>
public class InvoiceImportDto
{
    [Name("InvoiceNumber")]
    public string? InvoiceNumber { get; set; }

    // Customer resolution: email takes priority, name is the fallback
    [Name("CustomerEmail")]
    public string? CustomerEmail { get; set; }

    // "Customer" matches the column written by ExportInvoicesCsv
    [Name("Customer")]
    public string? CustomerName { get; set; }

    [Name("JobNumber")]
    public string? JobNumber { get; set; }

    [Name("Status")]
    public string Status { get; set; } = "Draft";

    [Name("InvoiceDate")]
    public DateTime InvoiceDate { get; set; }

    [Name("DueDate")]
    public DateTime? DueDate { get; set; }

    [Name("Project Name", "ProjectName")]
    public string? ProjectName { get; set; }

    [Name("SubTotal")]
    public decimal SubTotal { get; set; }

    [Name("TaxPercent")]
    public decimal TaxPercent { get; set; }

    [Name("TaxAmount")]
    public decimal TaxAmount { get; set; }

    [Name("DiscountAmount")]
    public decimal DiscountAmount { get; set; }

    [Name("Total")]
    public decimal Total { get; set; }

    [Name("AmountPaid")]
    public decimal AmountPaid { get; set; }

    // BalanceDue is computed (Total - AmountPaid); ignored on import
    [Ignore]
    public decimal BalanceDue { get; set; }

    [Name("CustomerPO")]
    public string? CustomerPO { get; set; }

    [Name("Terms")]
    public string? Terms { get; set; }

    [Name("Notes")]
    public string? Notes { get; set; }
}
