WIP: Adds several core models needed for functionality #24

Merged
yan-wah merged 10 commits from models into main 2022-04-16 04:48:19 -04:00
3 changed files with 54 additions and 18 deletions
Showing only changes of commit f1a1b5d067 - Show all commits

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ophelias.Models;
namespace Ophelias.Models namespace Ophelias.Models
{ {
@@ -12,24 +13,35 @@ namespace Ophelias.Models
internal string FirstName; internal string FirstName;
internal string LastName; internal string LastName;
internal string Email; internal string Email;
internal string PhoneNumber;
internal string? CreditCard; internal string? CreditCard;
internal string? CCV;
internal DateTime CreditCardExpiration;
internal Guest(int id, string fname, string lname, string email) internal Guest(int id, string fname, string lname, string email, string phone)
{ {
Id = id; Id = id;
FirstName = fname; FirstName = fname;
LastName = lname; LastName = lname;
Email = email; Email = email;
PhoneNumber = phone;
} }
internal Guest(int id, string fname, string lname, string email, string cc) internal Guest(int id, string fname, string lname, string email, string phone, string cc, DateTime expiration, string ccv)
{ {
Id = id; Id = id;
FirstName = fname; FirstName = fname;
LastName = lname; LastName = lname;
Email = email; Email = email;
PhoneNumber = phone;
CreditCard = cc; CreditCard = cc;
CreditCardExpiration = expiration;
}
internal void SetCreditCardInformation(string cc, DateTime expiration, string ccv)
{
CreditCard = cc;
CreditCardExpiration = expiration;
CCV = ccv;
} }
} }
internal class GuestList internal class GuestList
{ {

View File

@@ -48,14 +48,16 @@ namespace Ophelias.Models
CheckOut = null; CheckOut = null;
DateChanged = null; DateChanged = null;
} }
internal void ChangeReservation(ReservationType type) internal void ChangeReservation(ReservationType type, Transaction t, BaseRate b)
{ {
Status = ReservationStatus.Changed; Status = ReservationStatus.Changed;
Type = type; Type = type;
t.Penalize(this, b.Rate);
} }
internal void CancelReservation() internal void CancelReservation(Transaction t)
{ {
Status = ReservationStatus.Cancelled; Status = ReservationStatus.Cancelled;
t.Penalize(this);
} }
} }
internal enum ReservationStatus internal enum ReservationStatus

View File

@@ -26,15 +26,15 @@ namespace Ophelias.Models
internal DateTime PayBy; internal DateTime PayBy;
internal DateTime PaidOn; internal DateTime PaidOn;
internal Transaction(int id, ReservationType type, DateTime payby) internal Transaction(int id, Reservation r, DateTime payby)
{ {
Id = id; Id = id;
Paid = 0; Paid = 0;
Owed = 0; Owed = 0;
RefundAmount = 0; RefundAmount = 0;
PaidOff = false; PaidOff = false;
PayBy = payby; PayBy = SetPayByDate(r);
Multiplier = Fee(type); Multiplier = Fee(r.Type);
} }
private bool IsOverdue() private bool IsOverdue()
{ {
@@ -44,7 +44,17 @@ namespace Ophelias.Models
} }
return false; return false;
} }
private DateTime SetPayByDate(Reservation r)
{
switch(r.Type)
{
case ReservationType.Conventional: return r.EndDate;
case ReservationType.Prepaid: return r.StartDate;
case ReservationType.Incentive: return r.EndDate;
case ReservationType.SixtyDayAdvance: return r.StartDate.AddDays(-30);
default: throw new NotImplementedException();
}
}
private void SetChangeFees(ReservationType type, double rate) private void SetChangeFees(ReservationType type, double rate)
{ {
switch (type) switch (type)
@@ -78,32 +88,44 @@ namespace Ophelias.Models
default: throw new NotImplementedException(); default: throw new NotImplementedException();
} }
} }
internal void Penalize(Reservation r)
internal void Penalize(ReservationStatus status, ReservationType type, double rate)
{ {
switch(status) switch (r.Status)
{ {
case ReservationStatus.Active: IsOverdue(); return; case ReservationStatus.Active: IsOverdue(); return;
case ReservationStatus.Cancelled: CancellationHandler(type); return; case ReservationStatus.Ended: IsOverdue(); return;
case ReservationStatus.Changed: SetChangeFees(type, rate); return; case ReservationStatus.Cancelled: CancellationHandler(r.Type); return;
default: throw new NotImplementedException();
} }
} }
internal double Fee(ReservationType type) internal void Penalize(Reservation r, double rate)
{
switch(r.Status)
{
case ReservationStatus.Changed: SetChangeFees(r.Type, rate); return;
default: throw new NotImplementedException();
}
}
private double Fee(ReservationType type)
{ {
switch (type) switch (type)
{ {
case ReservationType.Conventional: return 1.0; case ReservationType.Conventional: return 1.0;
case ReservationType.Prepaid: return 0.75; case ReservationType.Prepaid: return 0.75;
case ReservationType.Incentive: return 1.0; case ReservationType.Incentive: return GetIncentiveRate();
case ReservationType.SixtyDayAdvance: return 0.85; case ReservationType.SixtyDayAdvance: return 0.85;
default: throw new NotImplementedException(); default: throw new NotImplementedException();
} }
} }
internal void SetFee(double mult) private double GetIncentiveRate()
{
return 0.80;
}
private void SetFee(double mult)
{ {
Multiplier = mult; Multiplier = mult;
} }
internal void SetRate(double rate) private void SetRate(double rate)
{ {
Rate = rate; Rate = rate;
} }