Update models with more functionality

This is a small commit that aims to add some more descriptive
functionality to the models.

Guest now has more creditcard information
such as CCV and an expiration date to bring it in-line with what would
be expected.

Reservation implemented a very loose cancellation function,
this may be moved out.

Transaction has a few more tweaks that follows the same goal as guest,
however this functionality may be migrated as well.
This commit is contained in:
雲華
2022-04-09 04:45:42 -04:00
parent c1526a123f
commit f1a1b5d067
3 changed files with 54 additions and 18 deletions

View File

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