public void GetSalePricingStrategyWithBestForStoreShouldReturnBestForStorePricingStrategy() { var result = new PricingStrategyFactory(SetupFileManagerWithOverallStrategy("BestForStore").Object) .GetSalePricingStrategy(); Assert.That(result, Is.Not.Null, "Should get back a pricing strategy from factory."); Assert.That(result, Is.TypeOf <BestForStorePricingStrategy>(), $"Should get back a strategy of type {typeof(BestForStorePricingStrategy).Name}"); }
/// <summary> /// Calculate Charge For Service Item for RA Billing /// </summary> public RaServiceItem CalculateCharge(DateTime raCreatedDate, DateTime startDtTime, DateTime endDtTime, long serviceItemId, int quantity, Int64 operationId, List <TariffType> oTariffTypeList) { Helpers.PricingStrategy objPs = PricingStrategyFactory.GetPricingStrategy(raCreatedDate, startDtTime, endDtTime, operationId, oTariffTypeList); if (objPs == null) { throw new CaresException(Resources.RentalAgreement.RentalAgreement.TariffTypeNotDefinedForServiceItem, null); } List <ServiceRt> serviceRts = serviceRtRepository.GetForRaBilling(objPs.TariffType.TariffTypeCode, serviceItemId, raCreatedDate).ToList(); if (serviceRts.Count == 0) { throw new CaresException(Resources.RentalAgreement.RentalAgreement.ServiceRateNotDefinedForServiceItem); } ServiceRt oServiceRate = serviceRts[0]; return(objPs.CalculateRAServiceItemCharge(startDtTime, endDtTime, quantity, oServiceRate)); }
/// <summary> /// Calculate Insurance Charge for Ra Billing /// </summary> public RaHireGroupInsurance CalculateCharge(DateTime raRecCreatedDate, DateTime stDate, DateTime eDate, long operationId, long hireGroupDetailId, short insuranceTypeId, List <TariffType> oTariffTypeList) { Helpers.PricingStrategy objPs = PricingStrategyFactory.GetPricingStrategy(raRecCreatedDate, stDate, eDate, operationId, oTariffTypeList); if (objPs == null) { throw new CaresException(Resources.RentalAgreement.RentalAgreement.TariffTypeNotDefinedForHireGroupInsurance, null); } List <InsuranceRt> insuranceRts = insuranceRtRepository. GetForRaBilling(objPs.TariffType.TariffTypeCode, hireGroupDetailId, insuranceTypeId, raRecCreatedDate).ToList(); if (insuranceRts.Count == 0) { throw new CaresException(Resources.RentalAgreement.RentalAgreement.InsuranceRateNotDefinedForHireGroupInsurance); } InsuranceRt oInsRate = insuranceRts[0]; return(objPs.CalculateInsuranceCharge(stDate, eDate, oInsRate)); }
/// <summary> /// Get best offer promotions /// </summary> /// <returns></returns> protected ICollection <AppliedPromotion> ChoosePromotions() { ICollection <AppliedPromotion> appliedPromotions = new HashSet <AppliedPromotion>(); foreach (var saleLineItem in saleLineItems) { IPricingStrategy pricingStrategy = PricingStrategyFactory.NewInstance().CreateStrategy(); IEnumerable <Promotion> promotions = availablePromotions.Where(x => x.Id == saleLineItem.Product.Id); foreach (Promotion promotion in promotions) { pricingStrategy.ApplyPromotion(promotion); } var appliedPromotion = pricingStrategy.GetAppliedPromotion(saleLineItem); if (appliedPromotion != null) { appliedPromotions.Add(appliedPromotion); } } return(appliedPromotions); }