/// <summary> /// Create a pricing summary detail for a given service professional service, copying /// the needed data and performing the calculations that apply to that service/pricing-type /// to fill the detail fields. /// /// TODO: Adapt and add special pricing calculations, with variables, hourlyPrice*serviceDurationMinutes/60 and hourlySurcharge, /// needed for Housekeepr and Babysitter/hourly-pricings. There was previous code at LcPricingModel, needs some refactor for the new way /// common interfaces for LcRest classes, calculations and save data. Some comments added to guide the process. /// </summary> /// <param name="service"></param> /// <returns></returns> public static PricingSummaryDetail FromServiceProfessionalService(ServiceProfessionalService service) { var allSessionsMinutes = service.numberOfSessions > 0 ? service.serviceDurationMinutes * service.numberOfSessions : service.serviceDurationMinutes; // Complex calculations based on pricing type //var config = LcPricingModel.PackageBasePricingTypeConfigs[service.pricingTypeID]; //config.PriceCalculation == LcEnum.PriceCalculationType.FixedPrice/HourlyPrice // Calculate time and price required for selected package /*if (config.Mod != null) * { * // Applying calculation from the PackageMod * // TODO: needs refactor, on interface and implementations because: there is no more 'fees' and subtotals per detail, that's done in the summary only. * config.Mod.CalculateCustomerData(customerID, thePackage, fee, modelData, ModelState); * } * if (config.PriceCalculation == LcEnum.PriceCalculationType.HourlyPrice) * { * // Discard value of priceRateUnit, is forced to be HOUR for this pricing-type * hourlyPrice = service.priceRate ?? 0 * } */ return(new PricingSummaryDetail { serviceDurationMinutes = allSessionsMinutes, firstSessionDurationMinutes = service.serviceDurationMinutes, price = service.price, serviceProfessionalServiceID = service.serviceProfessionalServiceID, serviceName = service.name, serviceDescription = service.description, numberOfSessions = service.numberOfSessions, hourlyPrice = !String.IsNullOrEmpty(service.priceRateUnit) && service.priceRateUnit.ToUpper() == "HOUR" ? service.priceRate : null, isRemoteService = service.isPhone }); }
/// <summary> /// Generates the pricing details list (List of PricingSummaryDetail) /// for a given list service professional services, fetching from database /// the data for each service and computing it as a PricingSummaryDetail. /// It replaces any previous details list. /// Its recommended a manual call of Calculate* methods to update the summary after this /// /// TODO Add possibility to include serviceProfessional defined price per service (it allows for /// serviceProfessional bookings to set a different price than the default one for the service) /// /// TODO Add calculation delegation for ProviderPackageMods and support /// for fields clientDataInput/serviceProfessionalDataInput (special pricings like housekeeper) /// </summary> /// <param name="serviceProfessionalUserID"></param> /// <param name="services"></param> /// <returns>Returns the jobTitleID shared by the given services. 0 if no services. /// An exceptions happens if services from different jobTitles are provided</returns> public int SetDetailServices(int serviceProfessionalUserID, IEnumerable <int> services) { var details = new List <PricingSummaryDetail>(); var jobTitleID = 0; foreach (var service in ServiceProfessionalService.GetListByIds(serviceProfessionalUserID, services)) { if (jobTitleID == 0) { jobTitleID = service.jobTitleID; } details.Add(PricingSummaryDetail.FromServiceProfessionalService(service)); } this.details = details; return(jobTitleID); }