/*
 * File: src/main/java/reports/model/sales/PrescriptionItem.java
 * Description: This model represents the PrescriptionItem entity, capturing details
 * related to items associated with prescriptions. It includes a relationship with the
 * Prescriptions entity and tracks metadata such as quantities and timestamps for
 * creation, updates, and deletions.
 */

package com.nebula.erp.reports.model.sales;

import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "prescription_item")
@Getter
@Setter
public class PrescriptionItem {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    @JoinColumn(name = "prescription_id", nullable = false)
    @JsonBackReference
    private Prescriptions prescription;

    private String type;

    private String product_id;

    private String product_name;

    @Column(nullable = false)
    private Integer quantity;

    private Boolean is_sale = false;  // Set default value as false

    private String created_by;

    private String tenant;

    private LocalDateTime created_at = LocalDateTime.now();
    private LocalDateTime updated_at = LocalDateTime.now();
    private LocalDateTime deleted_at = null;

}