package com.pressing.domain.pickup;

import com.pressing.common.entity.SiteScopedEntity;
import com.pressing.domain.invoice.Invoice;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "pickups")
public class Pickup extends SiteScopedEntity {

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

    @Column(nullable = false)
    private LocalDateTime pickupDateTime;

    @Column(nullable = false, length = 80)
    private String operatorName;

    @Column(length = 255)
    private String notes;

    @OneToMany(mappedBy = "pickup", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<PickupLine> lines = new ArrayList<>();
}
