Exemplo n.º 1
0
        /// <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);
                }
            }
        }
Exemplo n.º 2
0
 private static void MapServiceItemCharge(RaServiceItem item, RaServiceItem serviceItem)
 {
     item.ServiceCharge = serviceItem.ServiceCharge;
     item.TariffType    = serviceItem.TariffType;
     item.ChargedDay    = serviceItem.ChargedDay;
     item.ChargedHour   = serviceItem.ChargedHour;
     item.ChargedMinute = serviceItem.ChargedMinute;
     item.ServiceRate   = serviceItem.ServiceRate;
 }
Exemplo n.º 3
0
 /// <summary>
 ///  Create web model from entity
 /// </summary>
 public static DomainModels.RaServiceItem CreateFrom(this RaServiceItem source)
 {
     return(new DomainModels.RaServiceItem
     {
         RaServiceItemId = source.RaServiceItemId,
         RaMainId = source.RaMainId,
         ChargedDay = source.ChargedDay,
         ChargedHour = source.ChargedHour,
         ChargedMinute = source.ChargedMinute,
         EndDtTime = source.EndDtTime,
         StartDtTime = source.StartDtTime,
         TariffType = source.TariffType,
         Quantity = source.Quantity,
         ServiceCharge = source.ServiceCharge,
         ServiceItemId = source.ServiceItemId,
         ServiceRate = source.ServiceRate
     });
 }
Exemplo n.º 4
0
        public override RaServiceItem CalculateRAServiceItemCharge(DateTime StartDate, DateTime EndDate, Int32 ItemQuantity, ServiceRt ServiceItemRate)
        {
            RaServiceItem oRASICharge = null;
            //calculate total rental duration as a time span object
            TimeSpan dtSpan = EndDate - StartDate;

            //convert rental duration to minutes for standardization
            float SIDurationInMinutes = 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
            oRASICharge            = new RaServiceItem();
            oRASICharge.TariffType = this.TariffType.TariffTypeCode;
            if (SIDurationInMinutes >= TariffDurationFrom && SIDurationInMinutes <= TariffDurationTo)
            {
                oRASICharge.ServiceRate   = ServiceItemRate.ServiceRate;
                oRASICharge.ServiceCharge = ServiceItemRate.ServiceRate * ItemQuantity;
                oRASICharge.ChargedDay    = dtSpan.Days;
                oRASICharge.ChargedHour   = dtSpan.Hours;
                oRASICharge.ChargedMinute = dtSpan.Minutes;
            }
            else
            {
                float ChargeDuration = GetDurationInMinutes(dtSpan, Convert.ToInt32(TariffType.MeasurementUnitId));
                oRASICharge.ServiceCharge = (float)Math.Round((ChargeDuration / TariffDurationTo) * ServiceItemRate.ServiceRate * ItemQuantity, base.DecimalRounding, MidpointRounding.AwayFromZero);

                oRASICharge.ServiceRate = ServiceItemRate.ServiceRate;
                //excess milage charge for edit case
                oRASICharge.ChargedDay    = dtSpan.Days;
                oRASICharge.ChargedHour   = dtSpan.Hours;
                oRASICharge.ChargedMinute = dtSpan.Minutes;
            }
            return(oRASICharge);
        }