public override Money CalculateTax(EntitiesV2.Product product, EntitiesV2.PriceGroup priceGroup, Money unitPrice) { var productProperty = product.GetProperties() .FirstOrDefault(x => x.GetDefinitionField().DataType.DefinitionName == "PriceGroup"); if (productProperty == null && product.ParentProduct != null) { // check variant productProperty = product.ParentProduct .GetProperties() .FirstOrDefault(x => x.GetDefinitionField().DataType.DefinitionName == "PriceGroup"); } if (productProperty == null) { return base.CalculateTax(product, priceGroup, unitPrice); } int priceGroupId = -1; if (int.TryParse(productProperty.GetValue().ToString(), out priceGroupId)) { var overridenPriceGroup = _priceGroupRepository.SingleOrDefault(x => x.PriceGroupId == priceGroupId); if (priceGroup != null) { return CalculateTax(overridenPriceGroup, unitPrice); } } return base.CalculateTax(product, priceGroup, unitPrice); }
public System.Web.UI.Control GetControl(EntitiesV2.Definitions.IProperty property) { var priceGroups = _priceGroupRepository.Select().ToList(); var dropDownList = new SafeDropDownList(); foreach (var priceGroup in priceGroups) { var listItem = new ListItem(); listItem.Text = priceGroup.Name; listItem.Value = priceGroup.PriceGroupId.ToString(); listItem.Selected = property.GetValue().ToString() == priceGroup.PriceGroupId.ToString(); dropDownList.Items.Add(listItem); } return dropDownList; }
public bool Supports(EntitiesV2.DataType dataType) { return dataType.DefinitionName == "PriceGroup"; }
public bool ValidateForShipping(EntitiesV2.Shipment shipment) { return true; }
public Money CalculateShippingPrice(EntitiesV2.Shipment shipment) { ValidateForShipping(shipment); var quantity = shipment.OrderLines.Sum(orderLine => orderLine.Quantity); return new Money(quantity * _multiplier, shipment.PurchaseOrder.BillingCurrency); }