Fixed an incorrect calulation
The calculations used in the reports were calulating based off the owed column which mathematically did not make sense since we are looking for the daily.
This commit is contained in:
@@ -190,7 +190,7 @@ namespace Ophelias.Managers
|
|||||||
{
|
{
|
||||||
using (SQLiteCommand cmd = Manager.con.CreateCommand()) // Create a new command to execute
|
using (SQLiteCommand cmd = Manager.con.CreateCommand()) // Create a new command to execute
|
||||||
{
|
{
|
||||||
cmd.CommandText = "SELECT sum(((julianday(EndDate) - julianday(StartDate)) * transactions.Rate) - transactions.Owed) AS Loss " +
|
cmd.CommandText = "SELECT sum(transactions.Rate - (transactions.Rate * transactions.Multiplier)) AS Loss " +
|
||||||
"FROM reservations " +
|
"FROM reservations " +
|
||||||
"INNER JOIN transactions ON reservations.TransactionID = transactions.ID " +
|
"INNER JOIN transactions ON reservations.TransactionID = transactions.ID " +
|
||||||
"WHERE (DATE(@Date) BETWEEN StartDate AND EndDate) AND STATUS IN (@Status1,@Status2) AND Type = @Type";
|
"WHERE (DATE(@Date) BETWEEN StartDate AND EndDate) AND STATUS IN (@Status1,@Status2) AND Type = @Type";
|
||||||
@@ -234,7 +234,7 @@ namespace Ophelias.Managers
|
|||||||
{
|
{
|
||||||
using (SQLiteCommand cmd = Manager.con.CreateCommand()) // Create a new command to execute
|
using (SQLiteCommand cmd = Manager.con.CreateCommand()) // Create a new command to execute
|
||||||
{
|
{
|
||||||
cmd.CommandText = "SELECT sum(transactions.Owed) FROM reservations " +
|
cmd.CommandText = "SELECT sum(transactions.Rate * Multiplier) FROM reservations " +
|
||||||
"INNER JOIN transactions ON reservations.TransactionID = transactions.ID " +
|
"INNER JOIN transactions ON reservations.TransactionID = transactions.ID " +
|
||||||
"WHERE (DATE(@Date) BETWEEN StartDate AND EndDate) AND Status IN (@Status1,@Status2);";
|
"WHERE (DATE(@Date) BETWEEN StartDate AND EndDate) AND Status IN (@Status1,@Status2);";
|
||||||
cmd.Parameters.AddWithValue("@Date", dt.AddDays(i).Date.ToString("yyyy-MM-dd"));
|
cmd.Parameters.AddWithValue("@Date", dt.AddDays(i).Date.ToString("yyyy-MM-dd"));
|
||||||
|
|||||||
@@ -182,8 +182,16 @@ internal class Program
|
|||||||
* has been split into other functions. See those functions for details on how
|
* has been split into other functions. See those functions for details on how
|
||||||
* they work.
|
* they work.
|
||||||
*/
|
*/
|
||||||
|
activeReservation = null;
|
||||||
|
activeGuest = null;
|
||||||
(string FirstName, string LastName) = GetGuestName();
|
(string FirstName, string LastName) = GetGuestName();
|
||||||
string Email = GetGuestEmail();
|
string Email = GetGuestEmail();
|
||||||
|
activeGuest = Hotel.GetGuestByEmail(Email);
|
||||||
|
if (activeGuest != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"\nThere is already a guest with the email {Email}.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Console.Write("Would you like to enter your credit card details? (Y/n): ");
|
Console.Write("Would you like to enter your credit card details? (Y/n): ");
|
||||||
string? CreditCard = null;
|
string? CreditCard = null;
|
||||||
string? CardExpiration = null;
|
string? CardExpiration = null;
|
||||||
@@ -347,6 +355,7 @@ internal class Program
|
|||||||
if ((int)(Date - DateTime.Now).TotalDays < 90)
|
if ((int)(Date - DateTime.Now).TotalDays < 90)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Prepaid reservations must be made 90 days in advance.");
|
Console.WriteLine("Prepaid reservations must be made 90 days in advance.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -358,13 +367,14 @@ internal class Program
|
|||||||
if ((int)(Date - DateTime.Now).TotalDays < 60)
|
if ((int)(Date - DateTime.Now).TotalDays < 60)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Sixty-days-in-advance reservations must be made 60 days in advance.");
|
Console.WriteLine("Sixty-days-in-advance reservations must be made 60 days in advance.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
(DateTime?, DateTime?) SelectDate(ReservationType Type)
|
(DateTime?, DateTime?) SelectDate(ReservationType Type)
|
||||||
{
|
{
|
||||||
@@ -497,7 +507,7 @@ internal class Program
|
|||||||
Console.WriteLine("Aborting reservation creation.");
|
Console.WriteLine("Aborting reservation creation.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
string? cc, exp, ccv;
|
||||||
while ((Type != ReservationType.SixtyDayAdvance &&
|
while ((Type != ReservationType.SixtyDayAdvance &&
|
||||||
(activeGuest.CreditCard == null || activeGuest.Expiration == null || activeGuest.CCV == null)))
|
(activeGuest.CreditCard == null || activeGuest.Expiration == null || activeGuest.CCV == null)))
|
||||||
{
|
{
|
||||||
@@ -509,8 +519,9 @@ internal class Program
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
(cc,exp,ccv) = GetCreditCardInformation();
|
||||||
GetCreditCardInformation();
|
if (cc != null && exp != null && ccv != null)
|
||||||
|
activeGuest.UpdateGuest(activeGuest.Id, CreditCard: cc, Expiration: exp, CCV: ccv);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.Write($"Thank you for filling out your reservation details. Currently you have made a {Type} " +
|
Console.Write($"Thank you for filling out your reservation details. Currently you have made a {Type} " +
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Ophelias.Expressions
|
|||||||
* Basic check to make sure money is in US format. 300.20/ 0.00 etc.
|
* Basic check to make sure money is in US format. 300.20/ 0.00 etc.
|
||||||
*/
|
*/
|
||||||
internal static Regex CardRx = new(@"^[0-9]{16}$", RegexOptions.Compiled);
|
internal static Regex CardRx = new(@"^[0-9]{16}$", RegexOptions.Compiled);
|
||||||
internal static Regex ExpriationRx = new(@"^(0?[1-9]|1[012])/[2-9][0-9]{1}$", RegexOptions.Compiled);
|
internal static Regex ExpriationRx = new(@"^(0?[1-9]|1[012])/2[0-9]{1}$", RegexOptions.Compiled);
|
||||||
internal static Regex CCVRx = new(@"^[0-9]{3}$", RegexOptions.Compiled);
|
internal static Regex CCVRx = new(@"^[0-9]{3}$", RegexOptions.Compiled);
|
||||||
internal static Regex MoneyRx = new(@"^(\d+\.\d{2}|\d+)$", RegexOptions.Compiled);
|
internal static Regex MoneyRx = new(@"^(\d+\.\d{2}|\d+)$", RegexOptions.Compiled);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user