/// <summary>
 /// Updates the totals for an order form.
 /// </summary>
 /// <param name="orderForm">The order form</param>
 /// <param name="totals">The model containing calculated totals for the order form.</param>
 protected virtual void UpdateOrderFormTotals(OrderForm orderForm, OrderFormTotals totals)
 {
     orderForm.HandlingTotal = totals.HandlingTotal.Amount;
     orderForm.ShippingTotal = totals.ShippingTotal.Amount;
     orderForm.SubTotal = totals.SubTotal.Amount;
     orderForm.TaxTotal = totals.TaxTotal.Amount;
     orderForm.Total = totals.Total.Amount;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the totals for an order form.
        /// </summary>
        /// <param name="orderForm">The order form</param>
        /// <param name="totals">The model containing calculated totals for the order form.</param>
        protected virtual void UpdateOrderFormTotals(OrderForm orderForm, OrderFormTotals totals)
        {
            orderForm.HandlingTotal = totals.HandlingTotal.Amount;
            orderForm.ShippingTotal = totals.ShippingTotal.Amount;
            orderForm.SubTotal      = totals.SubTotal.Amount;
            orderForm.TaxTotal      = totals.TaxTotal.Amount;
            orderForm.Total         = totals.Total.Amount;

            var lineItemDiscountTotal = orderForm.LineItems.Where(x => x.ObjectState != MetaObjectState.Deleted)
                                        .Sum(item => item.LineItemDiscountAmount + item.OrderLevelDiscountAmount);
            var shippingDiscountTotal = orderForm.Shipments.Where(x => x.ObjectState != MetaObjectState.Deleted)
                                        .Sum(shipment => shipment.ShippingDiscountAmount);

            orderForm.DiscountAmount = lineItemDiscountTotal + shippingDiscountTotal;
        }