java.lang.Object
jku.se.Statistics
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
Computes the average number of invoices submitted per user per month.Calculates the number of invoices submitted per calendar month.int
Counts all restaurant invoices from all users.int
getInvoicesPerRestaurantUser
(String currentUser) Counts all restaurant invoices for a specific user.int
Counts all supermarket invoices from all users.int
getInvoicesPerSupermarketUser
(String currentUser) Counts all supermarket invoices for a specific user.Groups invoice counts per user for each month.double
Calculates the total reimbursement over the last 12 months.Calculates the total reimbursement amount per month.Retrieves invoice count and total reimbursement for all active users in the current month.Delivers user reimbursement data grouped by month and user.
-
Constructor Details
-
Statistics
public Statistics()
-
-
Method Details
-
getInvoicesPerMonth
Calculates the number of invoices submitted per calendar month.- Returns:
- Map with month names as keys and number of invoices as values.
-
getInvoicesPerUserAndMonth
Groups invoice counts per user for each month.- Returns:
- Map with month names as keys and maps of user data as values.
-
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
Counts all supermarket invoices for a specific user.- Parameters:
currentUser
- The user's email.- Returns:
- Number of supermarket invoices for the user.
-
getInvoicesPerRestaurantUser
Counts all restaurant invoices for a specific user.- Parameters:
currentUser
- The user's email.- Returns:
- Number of restaurant invoices for the user.
-
getUserReimbursementDetails
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, getUserReimbursementDetailsPerMonth() throws SQLExceptionMap<String, Object>>> Delivers user reimbursement data grouped by month and user. Each user map contains, for example, "name", "email", "total_reimbursement".- Throws:
SQLException
-