package natch_package;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

public class NatchPlanDetail implements Serializable{
	
	 
	 
		 /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

		public NatchPlanDetail() {
		        generateUniquePlanId(); // auto-assigns a unique planId
		    }
	 
	    // Unique ID to identify the plan (Allowed: alphanumeric, dot, hyphen, underscore)
	    // Required | Length: 1 - 40
	    private String planId;

	    // Name of the plan
	    // Required | Length: 1 - 40
	    private String planName;

	    // Type of the plan: PERIODIC or ON_DEMAND
	    // Required
	    private String planType="PERIODIC";

	    // Maximum amount for the plan
	    // Required
	    private Double planMaxAmount;

	    // Currency code (e.g., INR, USD)
	    private String planCurrency="INR";

	    // Recurring amount (Required for PERIODIC type)
	    private Double planRecurringAmount;

	    // Maximum number of payment cycles
	    private Integer planMaxCycles;

	    // Number of billing cycles between charges (Required for PERIODIC type)
	    private Integer planIntervals;

	    // Interval type: DAY, WEEK, MONTH, YEAR
	    private String planIntervalType;

	    // Optional note for the plan
	    private String planNote;
	    
	    private String planStatus;
	    
	    

	    // Getters and Setters
	    public String getPlanId() {
	        return planId;
	    }	
	    
	    public void setPlanId(String planId) {
	        this.planId = planId;
	    }
	    
	    public void generateUniquePlanId() {
	        String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
	        String randomPart = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 8);
	        this.planId = "plan_" + timestamp + "_" + randomPart; // Example: plan_20251027_142315_ab12cd34

	        // Ensure max 40 characters (trim if needed)
	        if (this.planId.length() > 40) {
	            this.planId = this.planId.substring(0, 40);
	        }
	    }

	    public String getPlanName() {
	        return planName;
	    }

	    public void setPlanName(String planName) {
	        this.planName = planName;
	    }

	    public String getPlanType() {
	        return planType;
	    }

	    public void setPlanType(String planType) {
	        this.planType = planType;
	    }

	    public Double getPlanMaxAmount() {
	        return planMaxAmount;
	    }

	    public void setPlanMaxAmount(Double planMaxAmount) {
	        this.planMaxAmount = planMaxAmount;
	    }

	    public String getPlanCurrency() {
	        return planCurrency;
	    }

	    public void setPlanCurrency(String planCurrency) {
	        this.planCurrency = planCurrency;
	    }

	    public Double getPlanRecurringAmount() {
	        return planRecurringAmount;
	    }

	    public void setPlanRecurringAmount(Double planRecurringAmount) {
	        this.planRecurringAmount = planRecurringAmount;
	    }

	    public Integer getPlanMaxCycles() {
	        return planMaxCycles;
	    }

	    public void setPlanMaxCycles(Integer planMaxCycles) {
	        this.planMaxCycles = planMaxCycles;
	    }

	    public Integer getPlanIntervals() {
	        return planIntervals;
	    }

	    public void setPlanIntervals(Integer planIntervals) {
	        this.planIntervals = planIntervals;
	    }

	    public String getPlanIntervalType() {
	        return planIntervalType;
	    }

	    public void setPlanIntervalType(String planIntervalType) {
	        this.planIntervalType = planIntervalType;
	    }

	    public String getPlanNote() {
	        return planNote;
	    }

	    public void setPlanNote(String planNote) {
	        this.planNote = planNote;
	    }

		public String getPlanStatus() {
			return planStatus;
		}

		public void setPlanStatus(String planStatus) {
			this.planStatus = planStatus;
		}
	

}
