using EDPlayerJournal.Entries;

namespace EDPlayerJournal.BGS; 

public class Transaction : IComparable<Transaction> {
    public List<Entry> Entries { get; } = new List<Entry>();

    public virtual string CompletedAt {
        get {
            var items = Entries
                .OrderBy(x => x.Timestamp)
                .ToArray()
                ;
            if (items == null || items.Length == 0) {
                return "Unknown";
            }

            Entry last = items.Last();
            return last.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
        }
    }

    /// <summary>
    /// Controlling faction of the station this entry was made/turned into.
    /// </summary>
    public string? ControllingFaction { get; set; }
    public string? Station { get; set; }
    public string? System { get; set; }
    public ulong SystemAddress { get; set; }
    public string? Faction { get; set; }

    /// <summary>
    /// Whether this transaction type only benefits the controlling faction or not, default: no
    /// </summary>
    public virtual bool OnlyControllingFaction {
        get { return false; }
    }

    public virtual int CompareTo(Transaction? other) {
        throw new NotImplementedException("not implemented");
    }

    public string? Name => ToString();
}
