package com.mvrent.carrental.web;

import com.mvrent.carrental.model.Payment;

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

public record PaymentDto(
        Long id,
        Long bookingId,
        BigDecimal amount,
        String method,
        String reference,
        LocalDate paidAt,
        String notes,
        String recordedBy
) {
    public static PaymentDto from(Payment p) {
        return new PaymentDto(
                p.getId(),
                p.getBooking() != null ? p.getBooking().getId() : null,
                p.getAmount(),
                p.getMethod() != null ? p.getMethod().name() : null,
                p.getReference(),
                p.getPaidAt(),
                p.getNotes(),
                p.getRecordedBy()
        );
    }
}
