package com.mvrent.carrental.model;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/** A payment collected against a booking (counter cash, UPI, card, gateway, …). */
@Entity
@Table(name = "payments")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Payment {

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

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @JoinColumn(name = "booking_id")
    private Booking booking;

    @NotNull
    private BigDecimal amount;

    @Enumerated(EnumType.STRING)
    @NotNull
    @Builder.Default
    private PaymentMethod method = PaymentMethod.CASH;

    /** Transaction / cheque / UPI reference. */
    private String reference;

    private LocalDate paidAt;

    private String notes;

    /** Username of the staff member who recorded it. */
    private String recordedBy;

    @CreationTimestamp
    private LocalDateTime createdAt;
}
