This finishes the first iteration of the project. Reports have been tested and are functional in terms of writing out and outputting some form of text. There are still a few bugs here and there that are found but ultimately this commit is so testing can begin. Since the changes are too large to individually summarize, here is the generalization: Reports have been integrated into the admin mode. They write out to text files rather than export to say email or a printer as it was not to be considered for this version. The files are appended too and exist in the debug director of the project. I made this easier to find by outputting where the files were output to after running the report. Other changes included some bug fixes, optimizations, and a few bit of automatic cleanup. This may lead to sylistic inconsistencies. Documentation will come in a later commit.
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using Ophelias.Models;
|
|
|
|
|
|
namespace Ophelias.Reporting
|
|
{
|
|
internal static class Operational
|
|
{
|
|
internal static void FetchDailyArriavals(List<Reservation> reservations)
|
|
{
|
|
List<string> entries = new();
|
|
foreach (Reservation r in reservations)
|
|
{
|
|
string roominfo;
|
|
if (!r.RoomNum.HasValue)
|
|
{
|
|
roominfo = "N/A";
|
|
}
|
|
else
|
|
{
|
|
|
|
roominfo = r.RoomNum.Value.ToString();
|
|
}
|
|
|
|
entries.Add($"{r.Guest.LastName}, {r.Guest.FirstName}\t{r.Type}\t{roominfo}\t{r.EndDate}");
|
|
}
|
|
string report = $"DAILY ARRIVAL REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
|
$"Last, First\tType\tRoom\tDeparture" +
|
|
$"{string.Join("\n", entries)}\n\n";
|
|
|
|
File.AppendAllText(Path.GetFullPath("DailyArrivals.txt"), report);
|
|
}
|
|
internal static void FetchDailyOccupancy(List<(DateTime, int, string, string)> cop, List<int> pop)
|
|
{
|
|
List<string> entries = new();
|
|
foreach (var c in cop)
|
|
{
|
|
string lastOccupied;
|
|
string sameDayLeave = "";
|
|
if (pop.Contains(c.Item2))
|
|
{
|
|
lastOccupied = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
|
|
} else
|
|
{
|
|
lastOccupied = "N/A";
|
|
}
|
|
|
|
if(DateTime.Now.Date == c.Item1.Date)
|
|
{
|
|
sameDayLeave = "*";
|
|
}
|
|
entries.Add($"{c.Item2}\t{lastOccupied}\t{sameDayLeave}{c.Item3}, {c.Item4}");
|
|
}
|
|
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";
|
|
|
|
File.AppendAllText(Path.GetFullPath("DailyOccupancy.txt"), report);
|
|
}
|
|
|
|
}
|
|
}
|