package com.example.kasirapp.data

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

@Entity(
    tableName = "transaction_items",
    foreignKeys = [ForeignKey(
        entity = Transaction::class,
        parentColumns = ["id"],
        childColumns = ["transactionId"],
        onDelete = ForeignKey.CASCADE // Jika transaksi dihapus, itemnya juga terhapus
    )]
)
data class TransactionItem(
    @PrimaryKey(autoGenerate = true)
    val id: Long = 0,
    val transactionId: Long, // Menghubungkan ke Transaction(id)
    val productId: Int,
    val productName: String, // Menyimpan nama produk saat transaksi
    val quantity: Int,
    val price: Int // Menyimpan harga per item saat transaksi
)
