IO format fixes and implemented res payment
This is a small commit to include the feature for paying for a reservation, specifically only the 60-day-in-advance reservation type as the others are paid for at specific periods. Other fixes include just some formatting for reports.
This commit is contained in:
@@ -32,11 +32,12 @@ internal class Program
|
||||
"\treservation create - Create a new reservation.\n" +
|
||||
"\treservation update - Update your active reservation.\n" +
|
||||
"\treservation cancel - Cancel a reservation.\n" +
|
||||
"\treservation pay - Pays in full for an active reservation.\n" +
|
||||
"Account Commands:\n" +
|
||||
"\taccount create - Create a new guest account.\n" +
|
||||
"\taccount update - Update your account information.\n" +
|
||||
"\taccount login - Log into your guest account." +
|
||||
"Enter Q to quit.\n"
|
||||
"Enter Q or q to quit.\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -220,6 +221,7 @@ internal class Program
|
||||
|
||||
Console.WriteLine($"The following changes have been made:\n {changes}");
|
||||
activeGuest.UpdateGuest(activeGuest.Id, NewFname, NewLname, NewEmail, NewCard, NewExpiry, NewCCV);
|
||||
activeReservation.Guest = activeGuest;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -491,7 +493,7 @@ internal class Program
|
||||
if (Type == ReservationType.Prepaid)
|
||||
{
|
||||
activeReservation = new(activeGuest, Type, DateTime.Now.Date, StartDate.Value, EndDate.Value);
|
||||
activeReservation.Transaction.Pay(activeReservation.Transaction.Owed);
|
||||
activeReservation.Transaction.Pay(activeReservation.Transaction.Owed, activeGuest.CreditCard);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -586,6 +588,118 @@ internal class Program
|
||||
activeReservation = null;
|
||||
Console.Write("Reservation has been cancelled, you may be charged based on your reservation.");
|
||||
}
|
||||
void PayForReservation()
|
||||
{
|
||||
if (activeGuest == null)
|
||||
{
|
||||
Console.WriteLine("No guest is currently logged in, please login.");
|
||||
return;
|
||||
}
|
||||
if (activeReservation == null)
|
||||
{
|
||||
Console.WriteLine("You currently do not have an active registration.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ReservationType.Incentive == activeReservation.Type)
|
||||
{
|
||||
Console.WriteLine("Incentive reservations are paid for when you check-out.");
|
||||
return;
|
||||
}
|
||||
else if (ReservationType.Conventional == activeReservation.Type)
|
||||
{
|
||||
Console.WriteLine("Conventional reservations are paid for when you check-out.");
|
||||
return;
|
||||
}
|
||||
else if (ReservationType.Prepaid == activeReservation.Type)
|
||||
{
|
||||
Console.WriteLine("Prepaid reservations are paid for when you create them.");
|
||||
return;
|
||||
} else if (ReservationType.SixtyDayAdvance == activeReservation.Type)
|
||||
{
|
||||
if(activeReservation.StartDate.AddDays(-30).Date < DateTime.Now.Date)
|
||||
{
|
||||
if (activeReservation.Transaction.Owed <= activeReservation.Transaction.AmountPaid)
|
||||
{
|
||||
Console.WriteLine("Your reservation has already been paid for.");
|
||||
return;
|
||||
}
|
||||
activeReservation.CancelReservation();
|
||||
Console.WriteLine("Your reservation has been cancelled because you failed to pay within the payment period.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string? cc, exp, ccv;
|
||||
cc = activeGuest.CreditCard;
|
||||
exp = activeGuest.Expiration;
|
||||
ccv = activeGuest.CCV;
|
||||
while (true)
|
||||
{
|
||||
if (cc == null || exp == null || ccv == null)
|
||||
(cc, exp, ccv) = GetCreditCardInformation();
|
||||
|
||||
if (cc == null || exp == null || ccv == null)
|
||||
{
|
||||
Console.Write("Would you like to try again and enter your payment information? (Your reservation will not be canceled)\n" +
|
||||
"YES or NO: ");
|
||||
while (true)
|
||||
{
|
||||
string input = Console.ReadLine();
|
||||
if (input == "YES")
|
||||
{
|
||||
break;
|
||||
} else if (input == "NO")
|
||||
{
|
||||
Console.WriteLine("Payment has been aborted.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Input must be YES or NO.");
|
||||
}
|
||||
}
|
||||
} else if (cc != null && exp != null && ccv != null)
|
||||
{
|
||||
if (ReservationType.SixtyDayAdvance == activeReservation.Type && ((DateTime.Parse(exp).Date < activeReservation.StartDate.AddDays(-30).Date) && (DateTime.Parse(exp).Date < activeReservation.StartDate.AddDays(-45).Date)))
|
||||
{
|
||||
Console.WriteLine("Your card expires too soon. Please enter the correct expiration date if incorrect or a new card.");
|
||||
cc = null;
|
||||
exp = null;
|
||||
ccv = null;
|
||||
}
|
||||
else if (ReservationType.SixtyDayAdvance == activeReservation.Type && ((DateTime.Parse(exp).Date > activeReservation.StartDate.AddDays(-30).Date) && (DateTime.Parse(exp).Date > activeReservation.StartDate.AddDays(-45).Date)))
|
||||
{
|
||||
if (cc != activeGuest.CreditCard && exp != activeGuest.Expiration && ccv != activeGuest.CCV)
|
||||
{
|
||||
activeGuest.UpdateGuest(activeGuest.Id, CreditCard: cc, Expiration: exp, CCV: ccv);
|
||||
activeReservation.Guest = activeGuest;
|
||||
}
|
||||
PaymentStatus ps = activeReservation.Transaction.Pay(activeReservation.Transaction.Owed, activeGuest.CreditCard);
|
||||
if (ps == PaymentStatus.SuccessfulPayment)
|
||||
{
|
||||
Console.WriteLine("Your reservation has been paid for.");
|
||||
return;
|
||||
} else if (ps == PaymentStatus.FailedPayment)
|
||||
{
|
||||
Console.WriteLine("There was an error paying for your resevation. Try again later or contact the Ophelias Oasis team.");
|
||||
return;
|
||||
} else if (ps == PaymentStatus.AmountCannotZero)
|
||||
{
|
||||
Console.WriteLine("You cannot pay $0 or less than $0.");
|
||||
return;
|
||||
} else if (ps == PaymentStatus.MissingCreditCard)
|
||||
{
|
||||
Console.WriteLine("Credit Card information is missing. Payment could not be made.");
|
||||
} else if (ps == PaymentStatus.AlreadyPaid)
|
||||
{
|
||||
Console.WriteLine("Your reservation has already been paid for.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.Write(
|
||||
"\nWelcome to the Ophelias Oasis Hotel Registration System!\n" +
|
||||
"Type help to get a full list of commands or enter a command.\n" +
|
||||
@@ -601,10 +715,12 @@ internal class Program
|
||||
case "reservation create": CreateNewReservation(); break;
|
||||
case "reservation update": UpdateReservation(); break;
|
||||
case "reservation cancel": CancelReservation(); break;
|
||||
case "reservation pay": PayForReservation(); break;
|
||||
case "account create": CreateNewGuestPrompt(); break;
|
||||
case "account update": UpdateGuestInformation(); break;
|
||||
case "account login": GuestLogin(); break;
|
||||
case "q": return;
|
||||
case "Q": return;
|
||||
default: Console.WriteLine("Unknown command, enter help for more inforamtion."); break;
|
||||
}
|
||||
Console.Write("\nCommand: ");
|
||||
@@ -626,7 +742,7 @@ internal class Program
|
||||
"\tcheckin guest - Checks in a guest and assigns them a room.\n" +
|
||||
"\tcheckout guest - Checks out a guest and removes their room assignment.\n" +
|
||||
"\tset rate - Sets a new base rate to begin after a specified date.\n" +
|
||||
"Enter Q to quit.\n"
|
||||
"Enter Q or q to quit.\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -791,7 +907,7 @@ internal class Program
|
||||
Reservation r = Hotel.GetResByGuest(Hotel.GetGuestByEmail(Email));
|
||||
if (r.Type == ReservationType.Incentive || r.Type == ReservationType.Conventional)
|
||||
{
|
||||
r.Transaction.Pay(r.Transaction.Owed);
|
||||
r.Transaction.Pay(r.Transaction.Owed, r.Guest.CreditCard);
|
||||
}
|
||||
|
||||
Hotel.CheckOutGuest(Email, DateTime.Now.Date);
|
||||
@@ -898,6 +1014,7 @@ internal class Program
|
||||
case "checkout guest": CheckOut(); break;
|
||||
case "set rate": SetFutureBaseRate(); break;
|
||||
case "Q": return;
|
||||
case "q": return;
|
||||
default: Console.WriteLine("Unknown command, enter help for more inforamtion."); break;
|
||||
}
|
||||
Console.Write("\nCommand: ");
|
||||
|
||||
Reference in New Issue
Block a user