Files
ophelias-oasis/OpheliasOasis/Reporting/Accommodation.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

27 lines
1.3 KiB
C#

using Ophelias.Models;
namespace Ophelias.Reporting
{
internal static class Accommodation
{
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" +
$"Name: {r.Guest.LastName}, {r.Guest.FirstName}\n" +
$"Arrival Date: {r.StartDate.Date.ToString("yyyy-MM-dd")}\n" +
$"Departure Date: {r.EndDate.Date.ToString("yyyy-MM-dd")}\n" +
$"Length of Stay: {(int)(r.EndDate.Date - r.StartDate.Date).TotalDays} days\n" +
$"Charged: ${Math.Round(r.Transaction.Owed, 2)}\n\n";
File.AppendAllText(Path.GetFullPath("AccommodationBills.txt"), report);
}
}
}
}