package com.pressing.domain.invoice;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.pressing.common.entity.BaseEntity;
import com.pressing.domain.catalog.Article;
import com.pressing.domain.catalog.ArticleColor;
import com.pressing.domain.catalog.ArticleType;
import com.pressing.domain.catalog.StorageLocation;
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;

@Getter
@Setter
@Entity
@Table(name = "invoice_lines")
public class InvoiceLine extends BaseEntity {

    @JsonIgnore 
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "invoice_id")
    private Invoice invoice;

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

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "color_id")
    private ArticleColor color;

    @Column(nullable = false, length = 200)
    private String designation;

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

    @Column(length = 80)
    private String brand;

    @Column(length = 255)
    private String observation;

    @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(nullable = false)
    private int quantityPickedUp = 0;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "storage_location_id")
    private StorageLocation storageLocation;


}
