//
//  Vehicle.swift
//  Gas Man
//
//  Created by Kameron Kenny on 3/18/25.
//

import Foundation
import CoreData

@objc(Vehicle)
public class Vehicle: NSManagedObject {
    public override func awakeFromInsert() {
        super.awakeFromInsert()
        self.id = UUID()
        print("Assigned new UUID: \(self.id)")
    }
}

extension Vehicle: Identifiable {
    @NSManaged public var id: UUID?
    
    // Computed property to always get a non-optional UUID.
    public var nonOptionalID: UUID {
        id ?? UUID()
    }
    
    @NSManaged public var year: String?
    @NSManaged public var make: String?
    @NSManaged public var model: String?
    @NSManaged public var color: String?
    @NSManaged public var purchaseDate: Date?
    @NSManaged public var purchasePrice: NSNumber?
    @NSManaged public var soldDate: Date?
    @NSManaged public var odometerAtPurchase: NSNumber?
    @NSManaged public var odometerAtSale: NSNumber?
    @NSManaged public var notes: String?
    
    // Existing additional fields
    @NSManaged public var engineName: String?
    @NSManaged public var engineDisplacement: NSNumber?
    @NSManaged public var transmission: String?
    @NSManaged public var vehicleType: String?
    @NSManaged public var wheelSizeWidth: NSNumber?
    @NSManaged public var wheelSizeDiameter: NSNumber?
    @NSManaged public var tireSizeWidth: NSNumber?
    @NSManaged public var tireSizeHeight: NSNumber?
    @NSManaged public var tireSizeRadius: NSNumber?
    
    // New fields for tire and wheel brands/models
    @NSManaged public var tireBrand: String?
    @NSManaged public var tireModel: String?
    @NSManaged public var wheelBrand: String?
    @NSManaged public var wheelModel: String?
}

