package com.gestoreasy.database.entities

import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.ForeignKey

@Entity(
    tableName = "orders",
    foreignKeys = [
        ForeignKey(
            entity = Client::class,
            parentColumns = ["id"],
            childColumns = ["client_id"],
            onDelete = ForeignKey.SET_NULL
        )
    ]
)
data class Order(
    @PrimaryKey
    val id: Long = 0,
    val client_id: Long?,
    val numero: String,
    val data: Long,
    val status: String, // "rascunho", "pendente", "confirmado", "cancelado"
    val subtotal: Double,
    val desconto: Double = 0.0,
    val total: Double,
    val observacoes: String?,
    val vendedor_id: Long?,
    val synced: Boolean = false,
    val created_at: Long = System.currentTimeMillis(),
    val updated_at: Long = System.currentTimeMillis()
)

