/// <summary> /// Creates a <see cref="LineLevelInformationViewModel" object/> /// </summary> /// <param name="saleLineItem">Reference to the line item. It will be modified on Commit.</param> public LineLevelInformationViewModel(SaleLineItem saleLineItem, CustomerOrderTransaction custTransaction) { this.transaction = custTransaction; StoreDataManager storeDataManager = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); this.deliveryStore = storeDataManager.GetStore(saleLineItem.DeliveryStoreNumber); this.saleLineItem = saleLineItem; this.LineItemId = saleLineItem.ItemId; this.Description = saleLineItem.Description; this.Quantity = saleLineItem.Quantity; this.DeliveryDate = saleLineItem.DeliveryDate; this.ShippingAddress = saleLineItem.ShippingAddress; this.ShippingMethodCode = saleLineItem.DeliveryMode != null ? saleLineItem.DeliveryMode.Code : string.Empty; // Since there is a difference between no shipping charge and a shipping charge of zero, we need to see if we have any shipping charges before summing them IEnumerable <Tax.MiscellaneousCharge> shippingCharges = saleLineItem.MiscellaneousCharges.Where(c => c.ChargeCode == ApplicationSettings.Terminal.ShippingChargeCode); if (shippingCharges.Any()) { this.ShippingCharge = shippingCharges.Sum(c => c.Price); } // Check for delivery mode on line first, then header IDeliveryMode deliveryMode = saleLineItem.DeliveryMode ?? custTransaction.DeliveryMode; bool hasPickupCode = deliveryMode != null && string.Equals(deliveryMode.Code, ApplicationSettings.Terminal.PickupDeliveryModeCode, StringComparison.OrdinalIgnoreCase); bool hasDeliveryDate = saleLineItem.DeliveryDate.HasValue; // we have to do this because if hasPickupCode == false, that does not mean that IsShipping will be set to true this.IsPickup = hasPickupCode && hasDeliveryDate; this.IsShipping = !hasPickupCode && hasDeliveryDate; }
/// <summary> /// Creates a <see cref="LineLevelInformationViewModel" object/> /// </summary> /// <param name="saleLineItem">Reference to the line item. It will be modified on Commit.</param> public LineLevelInformationViewModel(SaleLineItem saleLineItem, CustomerOrderTransaction custTransaction) { this.transaction = custTransaction; bool IsPickupaux = false; string DelMode = ""; StoreDataManager storeDataManager = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); DAC odac = new DAC(SalesOrder.InternalApplication.Settings.Database.Connection); DataTable dt = odac.GetLineDataOV(custTransaction.TransactionId, custTransaction.TerminalId, custTransaction.StoreId, saleLineItem.LineId.ToString()); if (dt.Rows.Count > 0) { saleLineItem.DeliveryStoreNumber = dt.Rows[0]["STORENUMBER"].ToString(); IsPickupaux = dt.Rows[0]["ISPICKUP"].ToString() == "1"?true:false; DelMode = dt.Rows[0]["SHIPMODE"].ToString(); if (IsPickupaux) { IList <Microsoft.Dynamics.Retail.Pos.DataEntity.DeliveryMode> delmod = storeDataManager.GetDeliveryModes(); foreach (DeliveryMode mod in delmod) { if (mod.Code == DelMode) { saleLineItem.DeliveryMode = mod; } } } } this.deliveryStore = storeDataManager.GetStore(saleLineItem.DeliveryStoreNumber); this.saleLineItem = saleLineItem; this.LineItemId = saleLineItem.ItemId; this.Description = saleLineItem.Description; this.Quantity = saleLineItem.Quantity; this.DeliveryDate = saleLineItem.DeliveryDate; this.ShippingAddress = saleLineItem.ShippingAddress; this.ShippingMethodCode = saleLineItem.DeliveryMode != null ? saleLineItem.DeliveryMode.Code : string.Empty; // Since there is a difference between no shipping charge and a shipping charge of zero, we need to see if we have any shipping charges before summing them IEnumerable <Tax.MiscellaneousCharge> shippingCharges = saleLineItem.MiscellaneousCharges.Where(c => c.ChargeCode == ApplicationSettings.Terminal.ShippingChargeCode); if (shippingCharges.Any()) { this.ShippingCharge = shippingCharges.Sum(c => c.Price); } // Check for delivery mode on line first, then header IDeliveryMode deliveryMode = saleLineItem.DeliveryMode ?? custTransaction.DeliveryMode; bool hasPickupCode = deliveryMode != null && string.Equals(deliveryMode.Code, ApplicationSettings.Terminal.PickupDeliveryModeCode, StringComparison.OrdinalIgnoreCase); bool hasDeliveryDate = saleLineItem.DeliveryDate.HasValue; // we have to do this because if hasPickupCode == false, that does not mean that IsShipping will be set to true if (IsPickupaux) { this.IsPickup = IsPickupaux; this.IsShipping = !IsPickupaux; } else { this.IsPickup = hasPickupCode && hasDeliveryDate; this.IsShipping = !hasPickupCode && hasDeliveryDate; } }