package de.cannamanage.service.model.report;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.List;

/**
 * Monthly distribution report data model.
 * Aggregates all distributions for a given month per tenant.
 */
public class MonthlyReport {

    private YearMonth month;
    private int totalDistributions;
    private BigDecimal totalGrams;
    private int uniqueMembers;
    private BigDecimal averagePerMember;
    private List<StrainSummary> topStrains;
    private List<DailyEntry> dailyBreakdown;

    public YearMonth getMonth() { return month; }
    public void setMonth(YearMonth month) { this.month = month; }

    public int getTotalDistributions() { return totalDistributions; }
    public void setTotalDistributions(int totalDistributions) { this.totalDistributions = totalDistributions; }

    public BigDecimal getTotalGrams() { return totalGrams; }
    public void setTotalGrams(BigDecimal totalGrams) { this.totalGrams = totalGrams; }

    public int getUniqueMembers() { return uniqueMembers; }
    public void setUniqueMembers(int uniqueMembers) { this.uniqueMembers = uniqueMembers; }

    public BigDecimal getAveragePerMember() { return averagePerMember; }
    public void setAveragePerMember(BigDecimal averagePerMember) { this.averagePerMember = averagePerMember; }

    public List<StrainSummary> getTopStrains() { return topStrains; }
    public void setTopStrains(List<StrainSummary> topStrains) { this.topStrains = topStrains; }

    public List<DailyEntry> getDailyBreakdown() { return dailyBreakdown; }
    public void setDailyBreakdown(List<DailyEntry> dailyBreakdown) { this.dailyBreakdown = dailyBreakdown; }

    /**
     * Summary of a single strain's distribution totals within the report period.
     */
    public static class StrainSummary {
        private String name;
        private BigDecimal totalGrams;
        private int distributionCount;

        public StrainSummary() {}

        public StrainSummary(String name, BigDecimal totalGrams, int distributionCount) {
            this.name = name;
            this.totalGrams = totalGrams;
            this.distributionCount = distributionCount;
        }

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

        public BigDecimal getTotalGrams() { return totalGrams; }
        public void setTotalGrams(BigDecimal totalGrams) { this.totalGrams = totalGrams; }

        public int getDistributionCount() { return distributionCount; }
        public void setDistributionCount(int distributionCount) { this.distributionCount = distributionCount; }
    }

    /**
     * A single day's aggregate within the monthly breakdown.
     */
    public static class DailyEntry {
        private LocalDate date;
        private BigDecimal grams;
        private int distributions;

        public DailyEntry() {}

        public DailyEntry(LocalDate date, BigDecimal grams, int distributions) {
            this.date = date;
            this.grams = grams;
            this.distributions = distributions;
        }

        public LocalDate getDate() { return date; }
        public void setDate(LocalDate date) { this.date = date; }

        public BigDecimal getGrams() { return grams; }
        public void setGrams(BigDecimal grams) { this.grams = grams; }

        public int getDistributions() { return distributions; }
        public void setDistributions(int distributions) { this.distributions = distributions; }
    }
}
