Module Lunchify
Package jku.se

Class Statistics

java.lang.Object
jku.se.Statistics

public class Statistics extends Object
The Statistics class provides various statistical evaluations based on invoices and reimbursements stored in the system.

It is primarily used by administrators to:

  • Analyze invoice submission trends over time
  • Track reimbursements by month and user
  • Calculate averages and category-specific counts
  • Generate reports for user-specific and monthly reimbursements

The data is retrieved from the InvoiceRepository and UserRepository.

  • Constructor Details

    • Statistics

      public Statistics()
  • Method Details

    • getInvoicesPerMonth

      public Map<String,Integer> getInvoicesPerMonth()
      Calculates the number of invoices submitted per calendar month.
      Returns:
      Map with month names as keys and number of invoices as values.
    • getInvoicesPerUserAndMonth

      public Map<String,Map<String,UserInvoiceData>> getInvoicesPerUserAndMonth()
      Groups invoice counts per user for each month.
      Returns:
      Map with month names as keys and maps of user data as values.
    • getReimbursementPerMonth

      public Map<String,Double> getReimbursementPerMonth()
      Calculates the total reimbursement amount per month.
      Returns:
      Map with month names as keys and reimbursement sums as values.
    • getReimbursementForAYear

      public double getReimbursementForAYear()
      Calculates the total reimbursement over the last 12 months.
      Returns:
      Sum of reimbursements from the last year.
    • getAverageOfInvoicesPerUserPerMonth

      public double getAverageOfInvoicesPerUserPerMonth()
      Computes the average number of invoices submitted per user per month.
      Returns:
      Average invoices per user per month.
    • getInvoicesPerSupermarket

      public int getInvoicesPerSupermarket()
      Counts all supermarket invoices from all users.
      Returns:
      Total number of supermarket invoices.
    • getInvoicesPerRestaurant

      public int getInvoicesPerRestaurant()
      Counts all restaurant invoices from all users.
      Returns:
      Total number of restaurant invoices.
    • getInvoicesPerSupermarketUser

      public int getInvoicesPerSupermarketUser(String currentUser)
      Counts all supermarket invoices for a specific user.
      Parameters:
      currentUser - The user's email.
      Returns:
      Number of supermarket invoices for the user.
    • getInvoicesPerRestaurantUser

      public int getInvoicesPerRestaurantUser(String currentUser)
      Counts all restaurant invoices for a specific user.
      Parameters:
      currentUser - The user's email.
      Returns:
      Number of restaurant invoices for the user.
    • getUserReimbursementDetails

      public Map<String,Object> getUserReimbursementDetails() throws SQLException
      Retrieves invoice count and total reimbursement for all active users in the current month.
      Returns:
      Map of user emails to their invoice/reimbursement stats and a total.
      Throws:
      SQLException - if a database error occurs.
    • getUserReimbursementDetailsPerMonth

      public Map<String,Map<String,Map<String,Object>>> getUserReimbursementDetailsPerMonth() throws SQLException
      Delivers user reimbursement data grouped by month and user. Each user map contains, for example, "name", "email", "total_reimbursement".
      Throws:
      SQLException