Package backend.logic

Klasse StatisticsService

java.lang.Object
backend.logic.StatisticsService

public class StatisticsService extends Object
Service class for generating statistical reports and analytics about reimbursements. Provides various methods to analyze reimbursement data by category, time period, and user metrics.
  • Konstruktordetails

    • StatisticsService

      public StatisticsService()
      Constructs an empty StatisticsService.
    • StatisticsService

      public StatisticsService(List<Reimbursement> reimbursement)
      Constructs a StatisticsService with a predefined list of reimbursements.
      Parameter:
      reimbursement - Initial list of reimbursements to analyze
  • Methodendetails

    • setConnectionProvider

      public static void setConnectionProvider(ConnectionProvider provider)
      Sets the connection provider for database operations.
      Parameter:
      provider - The connection provider implementation
    • setReimbursements

      public void setReimbursements(List<Reimbursement> reimb)
    • getReimbursements

      public List<Reimbursement> getReimbursements()
    • getSumByCategory

      public Map<InvoiceCategory,Double> getSumByCategory()
      Calculates the total approved amount by invoice category.
      Gibt zurück:
      Map with categories as keys and summed amounts as values
    • getCountByCategory

      public Map<InvoiceCategory,Double> getCountByCategory()
      Counts reimbursements by invoice category.
      Gibt zurück:
      Map with categories as keys and count of reimbursements as values
    • getCategoryDistribution

      public Map<String,Integer> getCategoryDistribution(List<Reimbursement> reimbursements)
      Generates a distribution of reimbursements by category.
      Parameter:
      reimbursements - List of reimbursements to analyze
      Gibt zurück:
      Map with category names as keys and counts as values
    • getInvoiceCountLastYear

      public Map<String,Integer> getInvoiceCountLastYear()
      Counts invoices per month for the last 12 months.
      Gibt zurück:
      Map with month labels (e.g., "May 2025") as keys and invoice counts as values
    • getAverageInvoicesPerUserLastYear

      public Map<String,Double> getAverageInvoicesPerUserLastYear()
      Calculates the average number of invoices per user for each of the last 12 months.
      Gibt zurück:
      Map with month labels as keys and average invoice counts as values
    • getReimbursementSumPerMonthLastYear

      public Map<String,Double> getReimbursementSumPerMonthLastYear()
      Calculates the total reimbursement amount per month for the last 12 months.
      Gibt zurück:
      Map with month labels as keys and total amounts as values
    • getReimbursementsFromLast12Months

      public List<Reimbursement> getReimbursementsFromLast12Months()
      Gets all reimbursements from the last 12 months.
      Gibt zurück:
      List of reimbursements from the last year
    • generateLast12MonthsMap

      public Map<String,YearMonth> generateLast12MonthsMap()
      Generates a map of the last 12 months with formatted labels.
      Gibt zurück:
      Map with formatted month labels (e.g., "May 2025") as keys and YearMonth objects as values