/// <summary> /// Calculae RaCharges /// </summary> public void CalculateRACharges(ref List <RaServiceItem> RAServiceItemList, ref List <RaDriver> RADriverList, DateTime RACreatedDate, Int64 OperationID, List <TariffType> oTariffTypeList) { foreach (RaServiceItem item in RAServiceItemList) { if (item.IsDeleted != true) { RaServiceItem serviceItem = serviceRtService. CalculateCharge(RACreatedDate, item.StartDtTime, item.EndDtTime, item.ServiceItemId, item.Quantity, OperationID, oTariffTypeList); MapServiceItemCharge(item, serviceItem); } } foreach (RaDriver Driver in RADriverList) { if (Driver.IsDeleted != true) { RaDriver raDriver = raDriverHelper. CalculateCharge(RACreatedDate, Driver.StartDtTime, Driver.EndDtTime, Driver.DesigGradeId ?? 0, Driver.IsChauffer, OperationID, oTariffTypeList); MapRaDriverCharge(Driver, raDriver); } } }
/// <summary> /// Map RaDriver Charge /// </summary> private static void MapRaDriverCharge(RaDriver driver, RaDriver raDriver) { driver.TotalCharge = raDriver.TotalCharge; driver.Rate = raDriver.Rate; driver.TariffType = raDriver.TariffType; driver.ChargedDay = raDriver.ChargedDay; driver.ChargedHour = raDriver.ChargedHour; driver.ChargedMinute = raDriver.ChargedMinute; }
public override RaDriver CalculateChaufferCharge(DateTime StartDate, DateTime EndDate, ChaufferCharge ChfRate) { RaDriver oRADriver = null; //calculate total rental duration as a time span object TimeSpan dtSpan = EndDate - StartDate; //convert rental duration to minutes for standardization float ChaufferDurationInMinutes = GetDurationInMinutes(dtSpan, Convert.ToInt32(TariffType.MeasurementUnitId)); //convert tariff type FromDuration to Minute for standardization float TariffDurationFrom = GetDurationInMinutes(TariffType.DurationFrom, Convert.ToInt32(TariffType.MeasurementUnitId)); //convert tariff type ToDuration to Minute for standardization float TariffDurationTo = GetDurationInMinutes(TariffType.DurationTo, Convert.ToInt32(TariffType.MeasurementUnitId)); //convert tariff type GracePeriod to Minute for standardization float TariffGracePeriod = GetDurationInMinutes((float)TariffType.GracePeriod, Convert.ToInt32(TariffType.MeasurementUnitId)); //set rental charge object common parameters oRADriver = new RaDriver(); oRADriver.TariffType = this.TariffType.TariffTypeCode; if (ChaufferDurationInMinutes >= TariffDurationFrom && ChaufferDurationInMinutes <= TariffDurationTo) { oRADriver.Rate = ChfRate.ChaufferChargeRate; oRADriver.TotalCharge = ChfRate.ChaufferChargeRate; oRADriver.ChargedDay = dtSpan.Days; oRADriver.ChargedHour = dtSpan.Hours; oRADriver.ChargedMinute = dtSpan.Minutes; } else { float ChargeDuration = GetDurationInMinutes(dtSpan, Convert.ToInt32(TariffType.MeasurementUnitId)); oRADriver.TotalCharge = (float)Math.Round((ChargeDuration / TariffDurationTo) * ChfRate.ChaufferChargeRate, base.DecimalRounding, MidpointRounding.AwayFromZero); oRADriver.Rate = ChfRate.ChaufferChargeRate; //excess milage charge for edit case oRADriver.ChargedDay = dtSpan.Days; oRADriver.ChargedHour = dtSpan.Hours; oRADriver.ChargedMinute = dtSpan.Minutes; } return(oRADriver); }
/// <summary> /// Create web model from entity /// </summary> public static DomainModels.RaDriver CreateFrom(this RaDriver source) { return(new DomainModels.RaDriver { RaDriverId = source.RaDriverId, RaMainId = source.RaMainId, ChargedDay = source.ChargedDay, ChargedHour = source.ChargedHour, ChargedMinute = source.ChargedMinute, EndDtTime = source.EndDtTime, StartDtTime = source.StartDtTime, TariffType = source.TariffType, ChaufferId = source.ChaufferId, DesigGradeId = source.DesigGradeId, DriverName = source.DriverName, IsChauffer = source.IsChauffer, LicenseExpDt = source.LicenseExpDt, LicenseNo = source.LicenseNo, Rate = source.Rate, TotalCharge = source.TotalCharge }); }