Removed unused functions and documented reporting

This commit is contained in:
雲華
2022-04-17 13:19:35 -04:00
parent f6f90c76b2
commit 565997b9d7
5 changed files with 99 additions and 34 deletions

View File

@@ -5,6 +5,12 @@ namespace Ophelias.Reporting
{
internal static void GenerateAccommodationBills(List<Reservation> reservations)
{
/*
* This function is used to format and create a new entry in the AccommodationBills.txt
* file. The accommodation bill details the guests Last, First name, the date they arrived,
* the date they depart/ departed, the length of their stay in days, and the amount they
* were charged.
*/
foreach (Reservation? r in reservations)
{
string report = $"ACCOMMODATION BILL - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +

View File

@@ -2,6 +2,10 @@
{
internal class Email
{
/*
* This is a simple email class to mimic what fields
* would exist if we were to send an email.
*/
private readonly string to;
private readonly string subject = "Your payment is due soon!";
private readonly string body = "Hello valued customer, this is a reminder that your payment for your reservation is due soon, please login to the system and pay for your reservation. If you do not it will be canceled.";
@@ -13,6 +17,12 @@
}
internal void Send()
{
/*
* Typically this function would send information or a built email
* to a mail server, however, since that was not in the design doc.
* a mockup was created to write what would go in the email to a
* text document.
*/
File.AppendAllText(Path.GetFullPath("Emails.txt"),
$"TO: {to}\n" +
$"FROM: {from}\n" +

View File

@@ -6,49 +6,68 @@ 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)
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" +
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
$"Average Occupancy Rate: {average}\n\n";
File.AppendAllText(Path.GetFullPath("ExpectedOccupancy.txt"), report);
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)
foreach (var x in items) // Build a list of entries
{
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{x.Item2}");
}
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" +
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
$"Average Income: {average}\n" +
$"Total Income: {totalIncome}\n\n";
File.AppendAllText(Path.GetFullPath("ExpectedIncome.txt"), report);
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)
foreach (var x in items) // Build a list of entries
{
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{x.Item2}");
}
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" +
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
$"Average Losses (Due to incentive): {average}\n" +
$"Total Losses (Due to incentive): {totalLosses}\n\n";
File.AppendAllText(Path.GetFullPath("IncentiveLosses.txt"), report);
File.AppendAllText(Path.GetFullPath("IncentiveLosses.txt"), report); // Write to file
}
}
}

View File

@@ -5,8 +5,23 @@ namespace Ophelias.Reporting
{
internal static class Operational
{
/*
* This class is a collection of operational reporting operations.
* The purpose of it is to write out information regarding the daily
* arrivals and daily occupancy using fstring to print out the reports.
* The output is not fully formatted as there is no way to accurately pad
* the strings. If we knew the longest possible string, which we do not
* because names can be any length, we chose to use tabs for the initial
* spacing.
*/
internal static void FetchDailyArriavals(List<Reservation> reservations)
{
/*
* This class gets writes the daily arrivals in the reservation list.
* If there is a room number that is specified with an individual,
* their room number is listed. Otherwise it is marked as N/A since
* they have not checked in yet to recieve their room.
*/
List<string> entries = new();
foreach (Reservation r in reservations)
{
@@ -25,15 +40,25 @@ namespace Ophelias.Reporting
}
string report = $"DAILY ARRIVAL REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
$"Last, First\tType\tRoom\tDeparture\n" +
$"{string.Join("\n", entries)}\n\n";
$"{string.Join("\n", entries)}\n\n"; // Format the list joined into the string
File.AppendAllText(Path.GetFullPath("DailyArrivals.txt"), report);
File.AppendAllText(Path.GetFullPath("DailyArrivals.txt"), report); // Write to file
}
internal static void FetchDailyOccupancy(List<(DateTime, int, string, string)> cop, List<int> pop)
{
/*
* Fetch Daily Occupancy gets the occupancy for that day. If the guest is leaving
* the same day, an * will preceed their name. If the room they are in was occupied
* the day before, a last occupied date is included.
*/
List<string> entries = new();
foreach (var c in cop)
{
/*
* Iterates over each item to determine whether a date and *
* needs to be set based on the conditions detailed in the
* docstring.
*/
string lastOccupied;
string sameDayLeave = "";
if (pop.Contains(c.Item2))
@@ -53,9 +78,9 @@ namespace Ophelias.Reporting
string report = $"DAILY OCCUPANCY REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
$"An * means that the guest is leaving the same day.\n" +
$"Room #\tPrev. Occupied\tCurrent Occupant\n" +
$"{string.Join("\n", entries)}\n\n";
$"{string.Join("\n", entries)}\n\n"; // Format the list joined into the string
File.AppendAllText(Path.GetFullPath("DailyOccupancy.txt"), report);
File.AppendAllText(Path.GetFullPath("DailyOccupancy.txt"), report); // Write to file
}
}