package com.example.ops_android.data.model

import com.google.gson.annotations.SerializedName

data class PurchaseOrder(
    @SerializedName("ID") val id: Int = 0,
    @SerializedName("Title") val title: String? = null,
    @SerializedName("OrderStatus") val status: String? = null,
    @SerializedName("Remark") val remark: String? = null,
    @SerializedName("Link") val link: String? = null,
    @SerializedName("Styles") val style_tags: String? = null,
    @SerializedName("CreatedAt") val created_at: String? = null,
    @SerializedName("UpdatedAt") val updated_at: String? = null,
    @SerializedName("UserID") val user_id: Int? = null,
    // Filled from detail API (not in list API)
    @kotlin.jvm.Transient val costs: List<Cost>? = null,
    @kotlin.jvm.Transient val status_logs: List<StatusLog>? = null
)

data class Cost(
    @SerializedName("Price") val price: Double = 0.0,
    @SerializedName("Quantity") val quantity: Int = 0,
    @SerializedName("CurrencyType") val currencyType: Int = 1,
    @SerializedName("CostType") val costType: Int = 1
) {
    // backward-compat for UI
    val amount: Double get() = price
    val currency: String get() = when (currencyType) { 1 -> "CNY"; 2 -> "MOP"; 3 -> "HKD"; 4 -> "USD"; else -> "CNY" }
    val remark: String? get() = null
}

data class PurchasePhoto(
    @SerializedName("Sha256") val sha256: String? = null,
    @SerializedName("Name") val name: String? = null,
    @SerializedName("Path") val path: String? = null
)

data class PurchaseCommit(
    @SerializedName("id") val id: Int = 0,
    @SerializedName("orderId") val orderId: Int = 0,
    @SerializedName("userId") val userId: Int = 0,
    @SerializedName("action") val action: String? = null,
    @SerializedName("status") val status: String? = null,
    @SerializedName("oldStatus") val oldStatus: String? = null,
    @SerializedName("comment") val comment: String? = null,
    @SerializedName("photos") val photos: List<String>? = null,
    @SerializedName("createdAt") val created_at: String? = null
)

// Keep backward compatibility with existing UI code
typealias StatusLog = PurchaseCommit
