Files
ophelias-oasis/OpheliasOasis/Reporting/Management.cs
雲華 0a5fa3e402 Updateed some formatting and bug fixes
Fixed inconsistencies in queries that would result in errors because
the parameters were missing. Updating a guest is an example that had
this issue. After checking parameters should all be supplied where
needed.
2022-04-17 18:55:38 -04:00

74 lines
3.9 KiB
C#

using Ophelias.Models;
using Ophelias.Managers;
namespace Ophelias.Reporting
{
internal static class Management
{
/*
* The management class is a collection of functions used in management
* reporting. Specifically, the expected incomes, losses, and occupancy.
* All of these functions share similar functionality with different
* strings.
*/
internal static void CalculateExpectedOccupancy(List<(DateTime, int, int, int, int, int)> items, double average)
{
/*
* This function formats the data provided into a string that details the Date, Rooms Filled, # of Conventional,
* # of Prepaid, # of 60-day, and # of Incentive reservations. These are what the five ints are in the
* List items. The average is the calcualted average expected occupancy.
*/
List<string> entries = new();
foreach (var x in items) // Build a list of entries
{
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{x.Item2}\t{x.Item3}\t{x.Item4}\t{x.Item5}\t{x.Item6}");
}
string report = $"EXPECTED 30 DAY OCCUPANCY REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
$"Date\tRooms Filled\tConventional\tPrepaid\t60-Day\tIncentive\n" +
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
$"Average Occupancy Rate: {Math.Round(average, 2)}\n\n";
File.AppendAllText(Path.GetFullPath("ExpectedOccupancy.txt"), report); // Write to file
}
internal static void CalculateExpectedIncome(List<(DateTime, double)> items, double totalIncome, double average)
{
/*
* This function formats the expected income into a string with the details Date and Income as columns.
* The total income and average are appended after the columns as per the design doc.
*/
List<string> entries = new();
foreach (var x in items) // Build a list of entries
{
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{Math.Round(x.Item2, 2)}");
}
string report = $"EXPECTED 30 DAY INCOME REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
$"Date\tIncome\n" +
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
$"Average Income: {Math.Round(average, 2)}\n" +
$"Total Income: {Math.Round(totalIncome, 2)}\n\n";
File.AppendAllText(Path.GetFullPath("ExpectedIncome.txt"), report); // Write to file
}
internal static void CalculateIncentiveLosses(List<(DateTime, double)> items, double totalLosses, double average)
{
/*
* This function formats the expected income into a string with the details Date and Losses as columns.
* The total losses and average losses are appended after the columns as per the design doc.
*/
List<string> entries = new();
foreach (var x in items) // Build a list of entries
{
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{Math.Round(x.Item2, 2)}");
}
string report = $"EXPECTED 30 DAY LOSSES (TO INCENTIVE) REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
$"Date\tLosses\n" +
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
$"Average Losses (Due to incentive): {Math.Round(average, 2)}\n" +
$"Total Losses (Due to incentive): {Math.Round(totalLosses, 2)}\n\n";
File.AppendAllText(Path.GetFullPath("IncentiveLosses.txt"), report); // Write to file
}
}
}