package de.cannamanage.domain.entity;

import de.cannamanage.domain.enums.FeeInterval;
import jakarta.persistence.*;

import java.time.Instant;
import java.util.UUID;

/**
 * Fee schedule (Beitragsordnung) — defines a named fee tier for the club.
 * Never hard-deleted; set isActive=false to deactivate.
 */
@Entity
@Table(name = "fee_schedules")
public class FeeSchedule extends AbstractTenantEntity {

    @Column(name = "club_id", nullable = false)
    private UUID clubId;

    @Column(name = "name", nullable = false, length = 100)
    private String name;

    @Column(name = "amount_cents", nullable = false)
    private Integer amountCents;

    @Enumerated(EnumType.STRING)
    @Column(name = "interval", nullable = false, length = 20)
    private FeeInterval interval;

    @Column(name = "is_default")
    private Boolean isDefault = false;

    @Column(name = "is_active")
    private Boolean isActive = true;

    @Column(name = "updated_at")
    private Instant updatedAt;

    @PrePersist
    void onCreateFee() {
        this.updatedAt = Instant.now();
    }

    @PreUpdate
    void onUpdateFee() {
        this.updatedAt = Instant.now();
    }

    // Getters and setters

    public UUID getClubId() { return clubId; }
    public void setClubId(UUID clubId) { this.clubId = clubId; }

    public String getName() { return name; }
    public void setName(String name) { this.name = name; }

    public Integer getAmountCents() { return amountCents; }
    public void setAmountCents(Integer amountCents) { this.amountCents = amountCents; }

    public FeeInterval getInterval() { return interval; }
    public void setInterval(FeeInterval interval) { this.interval = interval; }

    public Boolean getIsDefault() { return isDefault; }
    public void setIsDefault(Boolean isDefault) { this.isDefault = isDefault; }

    public Boolean getIsActive() { return isActive; }
    public void setIsActive(Boolean isActive) { this.isActive = isActive; }

    public Instant getUpdatedAt() { return updatedAt; }
    public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; }
}
