package com.pressing.modules.statistics.dto;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class StatisticsDtos {

    // --- ÉTAT RÉCAPITULATIF DES ACTIVITÉS ---
    public record SummaryReportResponse(
            int year,
            int quarter,
            List<MonthlyStat> newCustomersPerMonth,
            List<TopCustomer> top10Customers,
            List<MonthlyStat> depositOperationsPerMonth,
            List<MonthlyArticlesStat> articlesDepositedAndPickedUpPerMonth,
            List<ServiceDistribution> depositsByService,
            List<ServiceDistribution> pickupsByService,
            List<CategoryDistribution> depositsByCategory,
            List<TopArticle> top10Articles,
            long readyNotPickedUpCount,
            List<MonthlyRevenue> revenuePerMonth,
            // Encaissements réels par mois (règlements effectivement perçus, lavage + repassage confondus,
            // basés sur la date de paiement — distinct de revenuePerMonth.collected qui reflète le cumul
            // payé des factures groupées par mois de dépôt).
            List<MonthlyCollectionStat> collectionsPerMonth
    ) {}

    public record MonthlyStat(String monthName, long count) {}
    public record MonthlyArticlesStat(String monthName, long depositedCount, long pickedUpCount) {}
    public record MonthlyRevenue(String monthName, BigDecimal turnover, BigDecimal collected) {}
    public record MonthlyCollectionStat(String monthName, BigDecimal totalCollected) {}
    public record TopCustomer(Long customerId, String name, String phone, long invoiceCount, BigDecimal totalSpent) {}
    public record TopArticle(String articleName, long quantity) {}
    public record ServiceDistribution(String serviceName, long count) {}
    public record CategoryDistribution(String categoryName, long count) {}

    // --- BILAN TRIMESTRIEL (MATRICE CLIENTS / SERVICES) ---
    public record ServiceColumnDto(Long serviceId, String serviceName) {}
    public record ClientServiceStatDto(int deposits, int pickups) {}

    public record ClientMatrixRowDto(
            Long customerId,
            String customerNumber,
            String customerName,
            Map<Long, ClientServiceStatDto> serviceStats,
            int totalDeposits,
            int totalPickups,
            int totalInStock
    ) {}

    public record MonthlyMatrixResponse(
            int monthIndex,
            String monthName,
            List<ServiceColumnDto> services,
            List<ClientMatrixRowDto> rows
    ) {}

    public record QuarterlyMatrixResponse(
            int year,
            int quarter,
            List<MonthlyMatrixResponse> months
    ) {}
}