package de.effigenix.infrastructure.masterdata.persistence.entity;

import jakarta.persistence.*;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "suppliers")
public class SupplierEntity {

    @Id
    @Column(name = "id", nullable = false, length = 36)
    private String id;

    @Column(name = "name", nullable = false, unique = true, length = 200)
    private String name;

    @Column(name = "phone", length = 50)
    private String phone;

    @Column(name = "email", length = 255)
    private String email;

    @Column(name = "contact_person", length = 200)
    private String contactPerson;

    @Column(name = "street", length = 200)
    private String street;

    @Column(name = "house_number", length = 20)
    private String houseNumber;

    @Column(name = "postal_code", length = 20)
    private String postalCode;

    @Column(name = "city", length = 100)
    private String city;

    @Column(name = "country", length = 2)
    private String country;

    @Column(name = "payment_due_days")
    private Integer paymentDueDays;

    @Column(name = "payment_description", length = 500)
    private String paymentDescription;

    @Column(name = "quality_score")
    private Integer qualityScore;

    @Column(name = "delivery_score")
    private Integer deliveryScore;

    @Column(name = "price_score")
    private Integer priceScore;

    @Column(name = "status", nullable = false, length = 20)
    private String status;

    @Column(name = "created_at", nullable = false, updatable = false)
    private OffsetDateTime createdAt;

    @Column(name = "updated_at", nullable = false)
    private OffsetDateTime updatedAt;

    @ElementCollection(fetch = FetchType.EAGER)
    @CollectionTable(name = "quality_certificates", joinColumns = @JoinColumn(name = "supplier_id"))
    private List<QualityCertificateEmbeddable> certificates = new ArrayList<>();

    public SupplierEntity() {}

    public String getId() { return id; }
    public String getName() { return name; }
    public String getPhone() { return phone; }
    public String getEmail() { return email; }
    public String getContactPerson() { return contactPerson; }
    public String getStreet() { return street; }
    public String getHouseNumber() { return houseNumber; }
    public String getPostalCode() { return postalCode; }
    public String getCity() { return city; }
    public String getCountry() { return country; }
    public Integer getPaymentDueDays() { return paymentDueDays; }
    public String getPaymentDescription() { return paymentDescription; }
    public Integer getQualityScore() { return qualityScore; }
    public Integer getDeliveryScore() { return deliveryScore; }
    public Integer getPriceScore() { return priceScore; }
    public String getStatus() { return status; }
    public OffsetDateTime getCreatedAt() { return createdAt; }
    public OffsetDateTime getUpdatedAt() { return updatedAt; }
    public List<QualityCertificateEmbeddable> getCertificates() { return certificates; }

    public void setId(String id) { this.id = id; }
    public void setName(String name) { this.name = name; }
    public void setPhone(String phone) { this.phone = phone; }
    public void setEmail(String email) { this.email = email; }
    public void setContactPerson(String contactPerson) { this.contactPerson = contactPerson; }
    public void setStreet(String street) { this.street = street; }
    public void setHouseNumber(String houseNumber) { this.houseNumber = houseNumber; }
    public void setPostalCode(String postalCode) { this.postalCode = postalCode; }
    public void setCity(String city) { this.city = city; }
    public void setCountry(String country) { this.country = country; }
    public void setPaymentDueDays(Integer paymentDueDays) { this.paymentDueDays = paymentDueDays; }
    public void setPaymentDescription(String paymentDescription) { this.paymentDescription = paymentDescription; }
    public void setQualityScore(Integer qualityScore) { this.qualityScore = qualityScore; }
    public void setDeliveryScore(Integer deliveryScore) { this.deliveryScore = deliveryScore; }
    public void setPriceScore(Integer priceScore) { this.priceScore = priceScore; }
    public void setStatus(String status) { this.status = status; }
    public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; }
    public void setUpdatedAt(OffsetDateTime updatedAt) { this.updatedAt = updatedAt; }
    public void setCertificates(List<QualityCertificateEmbeddable> certificates) { this.certificates = certificates; }
}
