public ToolLineCostParameters(IToolBilling item, string resourceName) { Period = item.Period; ResourceID = item.ResourceID; ResourceName = resourceName; RatePeriod = item.RatePeriod; RoomID = item.RoomID; BillingTypeID = item.BillingTypeID; IsStarted = item.IsStarted; ResourceRate = item.ResourceRate; ReservationRate = item.ReservationRate; PerUseRate = item.PerUseRate; Uses = item.Uses; UsageFeeCharged = item.UsageFeeCharged; OverTimePenaltyPercentage = item.OverTimePenaltyPercentage; OverTimePenaltyFee = item.OverTimePenaltyFee; UncancelledPenaltyPercentage = item.UncancelledPenaltyPercentage; UncancelledPenaltyFee = item.UncancelledPenaltyFee; BookingFee = item.BookingFee; ReservationFee2 = item.ReservationFee2; SchedDuration = item.SchedDuration; ChargeDuration = item.ChargeDuration; OverTime = item.OverTime; TransferredDuration = item.TransferredDuration; ChargeMultiplier = item.ChargeMultiplier; IsCancelledBeforeAllowedTime = item.IsCancelledBeforeAllowedTime; }
public static void CalculateUsageFeeCharged(IToolBilling item) { //before April 2011 if (item.Period < April2011) { item.UsageFeeCharged = ((item.ChargeMultiplier * ((item.ActDuration - item.OverTime) / 60)) * item.ResourceRate) * (item.IsStarted ? 1 : 0); } //as of April 2011 and before June 2013 else if (item.Period >= April2011 && item.Period < June2013) { item.UsageFeeCharged = ((item.ChargeMultiplier * (((item.ChargeDuration - item.OverTime) - item.TransferredDuration) / 60)) * item.ResourceRate) * (1 - (item.IsCancelledBeforeAllowedTime ? 1 : 0)); } //as of October 2015 ["as of June 2013" is no longer true because we continued to use UsageFee20110401 for billing after this date until 2015-10-01. The UsageFeeCharged column should always have the value of *what we actually billed* so I have to overwrite the UsageFeeCharged column with the values in UsageFee20110401 for the date range 2013-06-01 to 2015-10-01] else { decimal amount = 0; //first start with AddVal amount += item.Uses * item.PerUseRate; // next add any charges based on AcctPer and MulVal // item.ResourceRate is the MulVal (i.e. per period charge) and item.RatePeriod is AcctPer // uses is already baked in to ChargeDuration, OverTime, and TrnasferredDuration var baseDuration = item.ChargeDuration - item.OverTime - item.TransferredDuration; decimal rpc = RatePeriodCharge(item, baseDuration); amount += rpc; item.UsageFeeCharged = amount * item.ChargeMultiplier * (1 - (item.IsCancelledBeforeAllowedTime ? 1 : 0)); } }
private static string GetResourceName(IToolBilling tb, IEnumerable <ResourceInfo> resources) { var res = resources.FirstOrDefault(x => x.ResourceID == tb.ResourceID); if (res == null) { throw new Exception($"Cannot find record with ResourceID: {tb.ResourceID}"); } return(res.ResourceName); }
public static string GetResourceName(IToolBilling item) { DataTable dt = GetResourceTable(); var rows = dt.Select($"ResourceID = {item.ResourceID}"); if (rows.Length == 0) { throw new Exception($"Cannot find record with ResourceID: {item.ResourceID}"); } return(rows[0].Field <string>("ResourceName")); }
private string GetResourceName(IToolBilling tb) { if (resources == null) { resources = Provider.Scheduler.Resource.GetResources(); } var res = resources.FirstOrDefault(x => x.ResourceID == tb.ResourceID); if (res == null) { throw new Exception($"Cannot find record with ResourceID: {tb.ResourceID}"); } return(res.ResourceName); }
public static void CalculateReservationFee(IToolBilling item) { if (item.Period < April2011) { //2010-11 ReservationFee needs to be caluclated here [not sure why, the formula is exactly the same as the computed column ReservationFeeOld] if (item.IsStarted && item.ResourceRate > 0) { item.ReservationFee2 = item.ReservationRate * item.Uses * item.ChargeMultiplier; } else { item.ReservationFee2 = 0; } } else { //we stopped charging a reservation fee as of 2011-04-01 item.ReservationFee2 = 0; } }
public void CalculateBookingFee(IToolBilling item) { throw new NotImplementedException(); }
public decimal RatePeriodCharge(IToolBilling item, decimal duration) { throw new NotImplementedException(); }
public decimal RatePeriodCharge(IToolBilling item, decimal duration) => ToolBillingUtility.RatePeriodCharge(item, duration);
public void CalculateBookingFee(IToolBilling item) => ToolBillingUtility.CalculateBookingFee(item);
public void CalculateUsageFeeCharged(IToolBilling item) => ToolBillingUtility.CalculateUsageFeeCharged(item);
public void CalculateReservationFee(IToolBilling item) => ToolBillingUtility.CalculateReservationFee(item);
public static void CalculateBookingFee(IToolBilling item) { //before April 2011 there was no booking fee concept if (item.Period < April2011) { item.BookingFee = GetBookingFeePercentage(item.Period); } //as of April 2011 and before June 2013 else if (item.Period >= April2011 && item.Period < June2013) { if (item.IsCancelledBeforeAllowedTime) { item.BookingFee = item.ResourceRate * (item.MaxReservedDuration / 60) * GetBookingFeePercentage(item.Period) * item.ChargeMultiplier; } else { //if user made smaller reservation and used it, we still charge those old booking fee if (item.MaxReservedDuration > item.ChargeDuration) { item.BookingFee = item.ResourceRate * ((item.MaxReservedDuration - item.ChargeDuration) / 60) * GetBookingFeePercentage(item.Period) * item.ChargeMultiplier; } else { item.BookingFee = 0; } } } //as of June 2013 else { decimal amount = 0; //next add any charges based on AcctPer and MulVal (item.ResourceRate is the MulVal i.e. per period charge) if (item.IsCancelledBeforeAllowedTime) { // [2018-08-01 jg] Commenting out the line below because we should not charge a booking // fee on the per use charge. This is because if someone modifies a reservation // they will receive the booking fee on each canceled-for-modification reservation, // plus they will be charged the full booking fee on the final reservation. Transferred // duration is not a factor here becuase that only affects the hourly charge. // only charge a booking fee on the PerUseRate when the reservation was canceled //amount += item.Uses * item.PerUseRate; // [2018-08-01 jg] We should subtract the transferred duration. Otherwise we risk // charging the booking fee on used time, which is ok unless the time is used // by a reservation created for modification. Since we don't know at this point // where the transferred duration is coming from (was it from another user's // reservation, the same user not for modification, the same user for modification, // who knows?) we can't determine what amount of transferred duration should be // removed. Therefore it must always be removed to err on the side of caution. // Also need to use SchedDuration now because at this time MaxReservedDuration // is still determined based on prior modifications. Use SchedDuration instead // of ChargeDuration because the reservation was never started if we are here. amount += RatePeriodCharge(item, item.SchedDuration - item.TransferredDuration); } else { // [2018-08-01 jg] Skipping this part as of 2018-07-01. // Reason: we now handle reservation modification by cancelling the existing // reservation and creating a new one. Therefore the booking fee will be applied to // the original reservation and we no longer have to track MaxReservedDuration. // Otherwise we are double dipping - charging a booking fee on the original // "cancelled for modification" reservation and also the unused portion of // MaxReservedDuration of the new modification reservation (which is included in the // reservation that was canceled for modification by definition). } // As of May 2020 the percentage is zero because booking fees are being waived due to COVID-19. item.BookingFee = amount * GetBookingFeePercentage(item.Period) * item.ChargeMultiplier; } }
private decimal GetLineCost(IToolBilling tb) { return(ToolBilling.GetLineCost(new ToolLineCostParameters(tb, GetResourceName(tb)))); }
public static decimal GetLineCost(IToolBilling item) => GetLineCost(new ToolLineCostParameters(item, GetResourceName(item)));
public static void CalculateToolBillingCharges(IToolBilling tb) { CalculateReservationFee(tb); CalculateUsageFeeCharged(tb); CalculateBookingFee(tb); }
public static decimal RatePeriodCharge(IToolBilling item, decimal duration) => RatePeriodCharge(item.Period, item.RatePeriod, item.ResourceRate, duration);
public void CalculateReservationFee(IToolBilling item) { throw new NotImplementedException(); }
public void CalculateUsageFeeCharged(IToolBilling item) { throw new NotImplementedException(); }
public decimal GetLineCost(IToolBilling item) { throw new NotImplementedException(); }