mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-12 16:38:48 +00:00
100 lines
3.5 KiB
Java
100 lines
3.5 KiB
Java
package com.imprimelibros.erp.payments.model;
|
|
|
|
import jakarta.persistence.*;
|
|
import java.time.LocalDateTime;
|
|
|
|
@Entity
|
|
@Table(
|
|
name = "refunds",
|
|
uniqueConstraints = {
|
|
@UniqueConstraint(name = "uq_refund_gateway_id", columnNames = {"gateway_refund_id"})
|
|
},
|
|
indexes = {
|
|
@Index(name = "idx_ref_pay", columnList = "payment_id"),
|
|
@Index(name = "idx_ref_status", columnList = "status")
|
|
}
|
|
)
|
|
public class Refund {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
|
@JoinColumn(name = "payment_id", nullable = false)
|
|
private Payment payment;
|
|
|
|
@OneToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "transaction_id")
|
|
private PaymentTransaction transaction; // el REFUND en payment_transactions
|
|
|
|
@Column(name = "amount_cents", nullable = false)
|
|
private Long amountCents;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "reason", nullable = false, length = 32)
|
|
private RefundReason reason = RefundReason.customer_request;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "status", nullable = false, length = 16)
|
|
private RefundStatus status = RefundStatus.pending;
|
|
|
|
@Column(name = "requested_by_user_id")
|
|
private Long requestedByUserId;
|
|
|
|
@Column(name = "requested_at", nullable = false,
|
|
columnDefinition = "datetime default current_timestamp")
|
|
private LocalDateTime requestedAt;
|
|
|
|
@Column(name = "processed_at")
|
|
private LocalDateTime processedAt;
|
|
|
|
@Column(name = "gateway_refund_id", length = 128)
|
|
private String gatewayRefundId;
|
|
|
|
@Column(name = "notes", length = 500)
|
|
private String notes;
|
|
|
|
@Column(name = "metadata", columnDefinition = "json")
|
|
private String metadata;
|
|
|
|
public Refund() {}
|
|
|
|
// Getters & Setters
|
|
public Long getId() { return id; }
|
|
public void setId(Long id) { this.id = id; }
|
|
|
|
public Payment getPayment() { return payment; }
|
|
public void setPayment(Payment payment) { this.payment = payment; }
|
|
|
|
public PaymentTransaction getTransaction() { return transaction; }
|
|
public void setTransaction(PaymentTransaction transaction) { this.transaction = transaction; }
|
|
|
|
public Long getAmountCents() { return amountCents; }
|
|
public void setAmountCents(Long amountCents) { this.amountCents = amountCents; }
|
|
|
|
public RefundReason getReason() { return reason; }
|
|
public void setReason(RefundReason reason) { this.reason = reason; }
|
|
|
|
public RefundStatus getStatus() { return status; }
|
|
public void setStatus(RefundStatus status) { this.status = status; }
|
|
|
|
public Long getRequestedByUserId() { return requestedByUserId; }
|
|
public void setRequestedByUserId(Long requestedByUserId) { this.requestedByUserId = requestedByUserId; }
|
|
|
|
public LocalDateTime getRequestedAt() { return requestedAt; }
|
|
public void setRequestedAt(LocalDateTime requestedAt) { this.requestedAt = requestedAt; }
|
|
|
|
public LocalDateTime getProcessedAt() { return processedAt; }
|
|
public void setProcessedAt(LocalDateTime processedAt) { this.processedAt = processedAt; }
|
|
|
|
public String getGatewayRefundId() { return gatewayRefundId; }
|
|
public void setGatewayRefundId(String gatewayRefundId) { this.gatewayRefundId = gatewayRefundId; }
|
|
|
|
public String getNotes() { return notes; }
|
|
public void setNotes(String notes) { this.notes = notes; }
|
|
|
|
public String getMetadata() { return metadata; }
|
|
public void setMetadata(String metadata) { this.metadata = metadata; }
|
|
}
|