/*
 * File: src/main/java/reports/model/sales/Payments.java
 * Description: This model represents the Payments entity in the sales domain, capturing
 * details related to payments made for sales. It includes a relationship with the Sales
 * entity and metadata fields for tracking creation, update, and deletion timestamps.
 */

package com.nebula.erp.reports.model.sales;

import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "payments")
public class Payments {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @OneToOne
    @JoinColumn(name = "sale_id", referencedColumnName = "id")
    @JsonBackReference
    private Sales sales;

    @Column(nullable = false)
    private Double amount_paid; // Amount paid for the sale

    @Column(nullable = false)
    private LocalDateTime date; // Date when the payment was made

    @Column(nullable = false)
    private String payment_method; // Method used for the payment (e.g., Credit Card, Cash)

    private String created_by;  // User who created this payment record

    private String tenant;      // Tenant ID (for multi-tenant systems)

    private LocalDateTime created_at = LocalDateTime.now();
    private LocalDateTime updated_at = LocalDateTime.now();
    private LocalDateTime deleted_at = null;

}