package com.pressing.domain.ironing;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.pressing.common.entity.BaseEntity;
import com.pressing.domain.catalog.Article;
import com.pressing.domain.catalog.ArticleType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.math.BigDecimal;
import lombok.Getter;
import lombok.Setter;

// Ligne de détail d'une facture de repassage (IroningInvoice = en-tête / reçu,
// IroningInvoiceLine = un article repassé sur ce reçu). Miroir de InvoiceLine.
@Getter
@Setter
@Entity
@Table(name = "ironing_invoice_lines")
public class IroningInvoiceLine extends BaseEntity {

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "ironing_invoice_id")
    private IroningInvoice ironingInvoice;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "article_type_id")
    private ArticleType articleType;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "article_id")
    private Article article;

    @Column(nullable = false)
    private int quantity = 1;

    @Column(nullable = false, precision = 12, scale = 2)
    private BigDecimal unitPrice = BigDecimal.ZERO;

    @Column(nullable = false, precision = 12, scale = 2)
    private BigDecimal lineTotal = BigDecimal.ZERO;

    @Column(length = 255)
    private String observation;
}
