/*
 * File: src/main/java/purchase/model/Supplier.java
 * Description: This model class represents a Supplier entity, storing detailed information about suppliers
 * involved in the purchase and inventory management processes. Each Supplier record includes key contact details,
 * location information, and metadata fields for tracking the entity's lifecycle.
 * The Supplier entity is linked to Purchase Orders and Goods Received Notes (GRN) in the system,
 * supporting traceability and compliance.
*/

package com.nebula.erp.purchase.model;

import jakarta.persistence.*;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.time.Instant;

@Data
@Entity
@Table(name = "supplier")
@Getter
@Setter
public class Supplier {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false)
    private String supplier_id;

    @Column(nullable = false)
    private String supplier_name;

    @Column(nullable = false)
    private String contact_person;

    @Column(nullable = false)
    private String phone_number;

    @Column(nullable = false)
    private String email_address;

    @Column(nullable = false)
    private String address;

    @Column(nullable = false)
    private String city;

    @Column(nullable = false)
    private String state_province;

    @Column(nullable = false)
    private String zip_postal_code;

    @Column(nullable = false)
    private String country;

    @Column(nullable = false)
    private String website;

    @Column(nullable = false)
    private String supplier_type;

    @Column(nullable = false)
    private String notes;

    @Column(nullable = false)
    private String created_by;

    @Column(nullable = false)
    private String tenant;

    @Column(nullable = false, updatable = false)
    private Instant created_at;

    @Column(nullable = false)
    private Instant updated_at;

    private Instant deleted_at;

    @PrePersist
    protected void onCreate() {
        Instant now = Instant.now();
        created_at = now;
        updated_at = now;
    }

    @PreUpdate
    protected void onUpdate() {
        updated_at = Instant.now();
    }
}