public bool AddSku(string sku, int quantity)
        {
            try
            {
                var catalogItem = OrderProvider.GetInvoiceSkuDetails(sku);
                if (catalogItem == null)
                {
                    return(false);
                }
                quantity = (quantity <= 0) ? 1 : quantity;
                var skus    = GetSkus();
                var skuItem = new InvoiceSKU
                {
                    //shan - mar 07, 2012 - set temp id for sku as it will help in identifying which row
                    //has been modified to update the qty or total price in case of having multiple rows of same sku
                    ID       = GetSkus().Count + 1,
                    SKU      = sku,
                    Quantity = quantity,
                    //begin - shan - mar 14, 2012 - get the full description of the product
                    //Description = catalogItem.Description,
                    //the catalogItem object didnt have the full description
                    //get the ProductInfo object from allSKUs list and get the full name
                    //allSKUs should be available in the cache already..
                    Description = OrderProvider.GetProductDescription(sku),
                    //end
                    UnitTotalPrice    = catalogItem.ListPrice,
                    UnitVolumePoints  = catalogItem.VolumePoints,
                    TotalVolumePoints = catalogItem.VolumePoints * quantity,
                    TotalPrice        = quantity * catalogItem.ListPrice
                };
                //TODO: some process here to fill in the rest of data for SKU

                skus.Add(skuItem);
                SaveSkus(skus);
                return(true);
            }
            catch (Exception ex)
            {
                MyHLWebUtil.LogExceptionWithContext(ex);
                return(false);
            }
        }
예제 #2
0
        private static Invoice CreateInvoiceFromCustomerOrder(ServiceProvider.CustomerOrderSvc.CustomerOrder_V01 customerOrderV01)
        {
            var invoice = new Invoice();

            try
            {
                invoice.ID            = 0;
                invoice.Type          = InvoiceType.customer;
                invoice.CreatedDate   = DateTime.Now;
                invoice.DistributorID = customerOrderV01.DistributorID;
                if (null != customerOrderV01.Shipping)
                {
                    var shippingInfo = (ServiceProvider.CustomerOrderSvc.CustomerShippingInfo_V01)customerOrderV01.Shipping;
                    if (null != shippingInfo)
                    {
                        if (null != shippingInfo.Address)
                        {
                            invoice.Address1   = shippingInfo.Address.Line1;
                            invoice.Address2   = shippingInfo.Address.Line2;
                            invoice.City       = shippingInfo.Address.City;
                            invoice.State      = shippingInfo.Address.StateProvinceTerritory;
                            invoice.PostalCode = shippingInfo.Address.PostalCode;
                        }
                        if (null != shippingInfo.Recipient)
                        {
                            invoice.FirstName = shippingInfo.Recipient.First;
                            invoice.LastName  = shippingInfo.Recipient.Last;
                        }
                        invoice.PhoneNumber = shippingInfo.Phone;
                    }

                    if (null != customerOrderV01.OrderItems && customerOrderV01.OrderItems.Count > 0)
                    {
                        invoice.InvoiceSkus = new List <InvoiceSKU>();
                        foreach (var orderItem in customerOrderV01.OrderItems)
                        {
                            var catalogItem = OrderProvider.GetInvoiceSkuDetails(orderItem.SKU);
                            if (null != catalogItem)
                            {
                                var skuItem = new InvoiceSKU
                                {
                                    SKU               = orderItem.SKU,
                                    Quantity          = orderItem.Quantity,
                                    Description       = catalogItem.Description,
                                    UnitTotalPrice    = catalogItem.ListPrice,
                                    UnitVolumePoints  = catalogItem.VolumePoints,
                                    TotalVolumePoints = catalogItem.VolumePoints * orderItem.Quantity,
                                    TotalPrice        = orderItem.Quantity * catalogItem.ListPrice
                                };
                                invoice.InvoiceSkus.Add(skuItem);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // TODO: Proper logging
                //MyHLWebUtil.LogExceptionWithContext(ex);
            }
            return(invoice);
        }
예제 #3
0
 public CatalogItem_V01 GetInvoiceSkuDetails(string skuValue)
 {
     return(OrderProvider.GetInvoiceSkuDetails(skuValue));
 }