WIP: Adds several core models needed for functionality #24
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ophelias.Guest.Models
|
namespace Ophelias.Models
|
||||||
{
|
{
|
||||||
internal class Guest
|
internal class Guest
|
||||||
{
|
{
|
||||||
@@ -31,4 +31,13 @@ namespace Ophelias.Guest.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
internal class GuestList
|
||||||
|
{
|
||||||
|
internal List<Guest> Guests;
|
||||||
|
|
||||||
|
internal GuestList()
|
||||||
|
{
|
||||||
|
Guests = new List<Guest>();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
OpheliasOasis/Models/Rate.cs
Normal file
33
OpheliasOasis/Models/Rate.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Ophelias.Models;
|
||||||
|
|
||||||
|
namespace Ophelias.Models
|
||||||
|
{
|
||||||
|
internal class BaseRate
|
||||||
|
{
|
||||||
|
internal int Id;
|
||||||
|
internal double Rate;
|
||||||
|
internal DateTime DateSet;
|
||||||
|
|
||||||
|
internal BaseRate(int id, double rate)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Rate = rate;
|
||||||
|
DateSet = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class Rates
|
||||||
|
{
|
||||||
|
internal List<BaseRate> BaseRates;
|
||||||
|
|
||||||
|
internal Rates()
|
||||||
|
{
|
||||||
|
BaseRates = new List<BaseRate>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,9 @@ 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 Oasis.Reservation.Models
|
namespace Ophelias.Models
|
||||||
{
|
{
|
||||||
internal class Reservation
|
internal class Reservation
|
||||||
{
|
{
|
||||||
@@ -47,13 +48,22 @@ namespace Oasis.Reservation.Models
|
|||||||
CheckOut = null;
|
CheckOut = null;
|
||||||
DateChanged = null;
|
DateChanged = null;
|
||||||
}
|
}
|
||||||
|
internal void ChangeReservation(ReservationType type)
|
||||||
|
{
|
||||||
|
Status = ReservationStatus.Changed;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
internal void CancelReservation()
|
||||||
|
{
|
||||||
|
Status = ReservationStatus.Cancelled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum ReservationStatus
|
internal enum ReservationStatus
|
||||||
{
|
{
|
||||||
Active,
|
Active,
|
||||||
Changed,
|
Changed,
|
||||||
Cancelled,
|
Cancelled,
|
||||||
|
Ended,
|
||||||
}
|
}
|
||||||
internal enum ReservationType
|
internal enum ReservationType
|
||||||
{
|
{
|
||||||
@@ -62,4 +72,13 @@ namespace Oasis.Reservation.Models
|
|||||||
Incentive,
|
Incentive,
|
||||||
SixtyDayAdvance,
|
SixtyDayAdvance,
|
||||||
}
|
}
|
||||||
|
internal class ReservationList
|
||||||
|
{
|
||||||
|
internal List<Reservation> Reservations;
|
||||||
|
|
||||||
|
internal ReservationList()
|
||||||
|
{
|
||||||
|
Reservations = new List<Reservation>();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,25 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace OpheliasOasis.Models
|
namespace OpheliasOasis.Models
|
||||||
{
|
{
|
||||||
internal class Class1
|
internal class Room
|
||||||
{
|
{
|
||||||
|
internal int Id;
|
||||||
|
internal bool Occupied;
|
||||||
|
|
||||||
|
internal Room(int id)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Occupied = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class RoomList
|
||||||
|
{
|
||||||
|
internal List<Room> Rooms;
|
||||||
|
|
||||||
|
internal RoomList()
|
||||||
|
{
|
||||||
|
Rooms = new List<Room>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,143 @@ 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 OpheliasOasis
|
namespace Ophelias.Models
|
||||||
{
|
{
|
||||||
internal class Class1
|
internal class Transaction
|
||||||
{
|
{
|
||||||
|
private double PenaltyMultipler = 1.1;
|
||||||
|
|
||||||
|
internal int Id;
|
||||||
|
|
||||||
|
internal double Rate;
|
||||||
|
internal double Paid;
|
||||||
|
internal double Owed;
|
||||||
|
internal double? Penalty;
|
||||||
|
internal double? Multiplier;
|
||||||
|
internal double RefundAmount;
|
||||||
|
|
||||||
|
internal bool? Late;
|
||||||
|
internal bool PaidOff;
|
||||||
|
|
||||||
|
internal DateTime PayBy;
|
||||||
|
internal DateTime PaidOn;
|
||||||
|
|
||||||
|
internal Transaction(int id, ReservationType type, DateTime payby)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Paid = 0;
|
||||||
|
Owed = 0;
|
||||||
|
RefundAmount = 0;
|
||||||
|
PaidOff = false;
|
||||||
|
PayBy = payby;
|
||||||
|
Multiplier = Fee(type);
|
||||||
|
}
|
||||||
|
private bool IsOverdue()
|
||||||
|
{
|
||||||
|
if (DateTime.Now > PayBy)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetChangeFees(ReservationType type, double rate)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ReservationType.Conventional: return;
|
||||||
|
case ReservationType.Prepaid: SetFee(PenaltyMultipler); SetRate(rate); return;
|
||||||
|
case ReservationType.Incentive: return;
|
||||||
|
case ReservationType.SixtyDayAdvance: SetFee(PenaltyMultipler); SetRate(rate); return;
|
||||||
|
default: throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CancellationHandler(ReservationType type)
|
||||||
|
{
|
||||||
|
void SetRefund()
|
||||||
|
{
|
||||||
|
if (DateTime.Now.AddDays(+3).Day <= PayBy.Day)
|
||||||
|
{
|
||||||
|
RefundAmount = Paid;
|
||||||
|
Paid = 0;
|
||||||
|
Owed = 0;
|
||||||
|
PaidOff = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ReservationType.Conventional: SetRefund(); return;
|
||||||
|
case ReservationType.Prepaid: return;
|
||||||
|
case ReservationType.Incentive: SetRefund(); return;
|
||||||
|
case ReservationType.SixtyDayAdvance: return;
|
||||||
|
default: throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Penalize(ReservationStatus status, ReservationType type, double rate)
|
||||||
|
{
|
||||||
|
switch(status)
|
||||||
|
{
|
||||||
|
case ReservationStatus.Active: IsOverdue(); return;
|
||||||
|
case ReservationStatus.Cancelled: CancellationHandler(type); return;
|
||||||
|
case ReservationStatus.Changed: SetChangeFees(type, rate); return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal 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.SixtyDayAdvance: return 0.85;
|
||||||
|
default: throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal void SetFee(double mult)
|
||||||
|
{
|
||||||
|
Multiplier = mult;
|
||||||
|
}
|
||||||
|
internal void SetRate(double rate)
|
||||||
|
{
|
||||||
|
Rate = rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Pay(double amount)
|
||||||
|
{
|
||||||
|
if (RefundAmount > -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Paid += amount;
|
||||||
|
if (Paid == Owed)
|
||||||
|
{
|
||||||
|
Owed -= Paid;
|
||||||
|
PaidOn = DateTime.Now;
|
||||||
|
PaidOff = true;
|
||||||
|
} else if (Paid > Owed)
|
||||||
|
{
|
||||||
|
RefundAmount = Paid - Owed;
|
||||||
|
Owed = Owed - Paid + RefundAmount;
|
||||||
|
PaidOn = DateTime.Now;
|
||||||
|
PaidOff = true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Owed -= Paid;
|
||||||
|
PaidOn = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal class TransactionList
|
||||||
|
{
|
||||||
|
internal List<Transaction> Transactions;
|
||||||
|
|
||||||
|
internal TransactionList()
|
||||||
|
{
|
||||||
|
Transactions = new List<Transaction>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user