/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="custTransaction">Transaction for this view model</param>
        /// <param name="saleLineItem">Sale line item for this view model if applicable</param>
        /// <remarks>If saleLineItem is not null then view model wraps line not transaction</remarks>
        public ShippingInformationViewModel(CustomerOrderTransaction custTransaction, SaleLineItem saleLineItem)
        {
            this.transaction     = custTransaction;
            this.lineItem        = saleLineItem;
            this.ShippingAddress = (saleLineItem == null) ? custTransaction.ShippingAddress : saleLineItem.ShippingAddress;

            // Load delivery date and set DeliveryDate property so validation is checked
            if (saleLineItem == null)
            {
                if (custTransaction.RequestedDeliveryDate > DateTime.MinValue)
                {
                    this.DeliveryDate = custTransaction.RequestedDeliveryDate;
                }
            }
            else
            {
                if (saleLineItem.DeliveryDate.HasValue && saleLineItem.DeliveryDate.Value > DateTime.MinValue)
                {
                    this.DeliveryDate = saleLineItem.DeliveryDate.Value;
                }
            }

            // Load delivery charge
            string shippingChargeCode = LSRetailPosis.Settings.ApplicationSettings.Terminal.ShippingChargeCode;

            Tax.MiscellaneousCharge mc = (saleLineItem == null)
                ? custTransaction.MiscellaneousCharges.SingleOrDefault(m => m.ChargeCode == shippingChargeCode)
                : lineItem.MiscellaneousCharges.SingleOrDefault(m => m.ChargeCode == shippingChargeCode);

            if (mc != null)
            {
                this.shippingCharge = mc.Price;
            }

            // Get list of addresses
            storeDataManager = new DM.StoreDataManager(
                SalesOrder.InternalApplication.Settings.Database.Connection,
                SalesOrder.InternalApplication.Settings.Database.DataAreaID);

            // Create a read-only collection
            deliveryModes = new ReadOnlyCollection <DataEntity.DeliveryMode>(storeDataManager.GetDeliveryModes());

            // Load delivery method and set ShippingMethod property so validation is checked
            this.ShippingMethod = (DeliveryMode)((saleLineItem == null) ? custTransaction.DeliveryMode : saleLineItem.DeliveryMode);
        }
예제 #2
0
        private ReadOnlyCollection <DeliveryModeExploded> DeliveryModesForItem(SaleLineItem item)
        {
            // Set address fields if available
            string country = string.Empty;
            string state   = string.Empty;

            if (this.ShippingAddress != null)
            {
                country = this.ShippingAddress.Country;
                state   = this.ShippingAddress.State;
            }

            return(new ReadOnlyCollection <DataEntity.DeliveryModeExploded>(
                       storeDataManager.GetDeliveryModes(
                           ApplicationSettings.Terminal.StorePrimaryId,
                           country,
                           state,
                           item.ItemId,
                           item.DimensionGroupId)));
        }