private static decimal AdjustPrice(ShippingMethodDto shippingMethod, IEstimateSettings settings, decimal price) { if (settings.PriceAdjustmentPercent > 0) { var pricePart = price * (settings.PriceAdjustmentPercent / 100.0m); price += settings.PriceAdjustmentIsAddition ? pricePart : -pricePart; } var shippingMethodRow = shippingMethod.ShippingMethod[0]; var amount = shippingMethodRow.BasePrice + price; if (settings.PriceRounding) { return(Math.Round(amount, MidpointRounding.AwayFromZero)); } return(amount); }
public AppSettings(IRegionNames regionNames, IEstimateSettings estimateSettings) { _regionNames = regionNames; _estimateSettings = estimateSettings; }
public EstimateService(IEstimateSettings estimateSettings) { _estimateCalculator = new EstimateCalculator(estimateSettings); }
public EstimateCalculator(IEstimateSettings estimateSettings) { _estimateSettings = estimateSettings; }
protected virtual IEnumerable <IShippingQueryParameter> CreateAdditionalParameters(ShippingMethodDto shippingMethod, IEstimateSettings settings) { yield return(new Edi(settings.Edi)); yield return(new ShippedFromPostOffice(settings.PostingAtPostOffice)); var productCode = settings.BringProductId ?? Product.Servicepakke.Code; var product = Product.GetByCode(productCode); if (!string.IsNullOrWhiteSpace(settings.BringCustomerNumber)) { product.CustomerNumber = settings.BringCustomerNumber; } yield return(new Products(product)); yield return(new AdditionalServices(settings.AdditionalServices.ToArray())); }
protected virtual ShipmentLeg CreateShipmentLeg(IShipment shipment, ShippingMethodDto shippingMethod, IEstimateSettings settings) { var postalCodeFrom = settings.PostalCodeFrom; var countryCodeFrom = settings.CountryCodeFrom; if (string.IsNullOrEmpty(shipment.WarehouseCode) == false) { var warehouse = _warehouseRepository.Get(shipment.WarehouseCode); var warehousePostalCode = warehouse.ContactInformation?.PostalCode; var warehouseCountryCode = warehouse.ContactInformation?.CountryCode; if (string.IsNullOrEmpty(warehousePostalCode) == false && warehouse.IsPickupLocation) { postalCodeFrom = warehousePostalCode; countryCodeFrom = warehouseCountryCode.ToIso2CountryCode(); } } var countryCodeTo = shipment.ShippingAddress.CountryCode.ToIso2CountryCode(); return(new ShipmentLeg(postalCodeFrom, shipment.ShippingAddress.PostalCode, countryCodeFrom, countryCodeTo)); }