Example #1
0
 private void InitInternational(Lineitem item, Data.Entities.EbayOrderItem entity)
 {
     Id                = item.lineItemId;
     Name              = item.title;
     UnitPrice         = GetUnitCost(item.lineItemCost, item.quantity);
     Discount          = "£0.00";
     Quantity          = item.quantity;
     SubTotal          = item.lineItemCost.ToString();
     LegacyVariationId = item.legacyVariationId ?? "0";
     LegacyItemId      = item.legacyItemId;
     Variant           = entity.CharacterName;
     Image             = entity.Image;
 }
Example #2
0
            public EbayOrderModelItem(Lineitem item, Data.Entities.EbayOrder orderEntity, bool international)
            {
                var entity = orderEntity.OrderItems.Cast <Data.Entities.EbayOrderItem>().FirstOrDefault(x =>
                                                                                                        x.LegacyItemId == item.legacyItemId &&
                                                                                                        x.LegacyVariationId == (item.legacyVariationId ?? "0") &&
                                                                                                        x.LineItemId == item.lineItemId);

                if (international)
                {
                    InitInternational(item, entity);
                }
                else
                {
                    Init(item, entity);
                }
            }
Example #3
0
        // GET: Invoices/SelectItems
        public ActionResult SelectItems(int?id, int?Quantity)
        {
            var invoiceItems = new List <Lineitem>();

            // load items from session
            if (Session["InvoiceItems"] != null)
            {
                invoiceItems = (List <Lineitem>)Session["InvoiceItems"];
            }

            if (id != null)
            {
                if (invoiceItems.SingleOrDefault(ii => ii.product_inventory_id == id) == null)
                {
                    if (Quantity > db.Product_Inventory.Find(id).unit_quantity)
                    {
                        return(RedirectToAction("Index", "SelectProductInventory", new { actionName = "SelectItems", controllerName = "Invoices", message = "Quantity requested is not available." }));
                    }
                    var li = new Lineitem();
                    li.lineitem_unit_quantity = Convert.ToInt32(Quantity);
                    li.CalculateTotal(Convert.ToInt32(id));                                         // assign product id and calculate total
                    li.ProductInventory.Product = db.Products.Find(li.ProductInventory.product_id); // assign product
                    invoiceItems.Add(li);
                }
                else
                {
                    var li = invoiceItems.SingleOrDefault(ii => ii.product_inventory_id == id);
                    if (li != null)
                    {
                        if ((Quantity + li.lineitem_unit_quantity) > db.Product_Inventory.Find(id).unit_quantity)
                        {
                            return(RedirectToAction("Index", "SelectProductInventory", new { actionName = "SelectItems", controllerName = "Invoices", message = "Quantity requested is not available." }));
                        }
                        li.lineitem_unit_quantity += Convert.ToInt32(Quantity);
                        li.CalculateTotal(Convert.ToInt32(id));
                        li.ProductInventory.Product = db.Products.Find(li.ProductInventory.product_id);
                    }
                }
            }

            Session["InvoiceItems"] = invoiceItems;

            ViewBag.ActionTitle = "Select Items for  ";
            return(View(invoiceItems));
        }
Example #4
0
 private void Init(Lineitem item, Data.Entities.EbayOrderItem entity)
 {
     Id        = item.lineItemId;
     Name      = item.title;
     UnitPrice = item.lineItemCost.ToString();
     if (item.appliedPromotions.Any() && item.appliedPromotions[0].discountAmount != null)
     {
         Discount = item.appliedPromotions[0].discountAmount.ToString();
     }
     else
     {
         Discount = "£0.00";
     }
     Quantity          = item.quantity;
     SubTotal          = item.total.ToString();
     LegacyVariationId = item.legacyVariationId ?? "0";
     LegacyItemId      = item.legacyItemId;
     Variant           = entity.CharacterName;
     Image             = entity.Image;
 }
Example #5
0
 // POST: api/Line
 //点餐。
 public int Post([FromBody] Lineitem value)
 {
     return(dal.LineitemAdd(value));
 }
Example #6
0
 //点餐
 public int LineitemAdd(Lineitem lineitem)
 {
     return(DBHelper.ExecuteNonQuery(string.Format("insert into Lineitem values ('{0}','{1}','{2}','{3}',0)", lineitem.Ltmid, lineitem.Lttid, lineitem.Ltnum, lineitem.Ltmoney)));
 }
Example #7
0
        public static Invoice poplateInvoice(List <row> pageItem, string fileName)
        {
            int whereTotal = 0;

            var total = new List <string> {
                "Total", "Total dues"
            };
            Invoice currentInvoice = new Invoice();

            for (int i = pageItem.Count - 1; i >= 0; i--)
            {
                if (pageItem[i].word != null)

                {
                    if (pageItem[i].word.ToUpper() == "TOTAL".ToUpper() || pageItem[i].word.ToUpper() == "T0TAL:".ToUpper() || pageItem[i].word.ToUpper() == "T0ta1".ToUpper() || pageItem[i].word.ToUpper() == "TOTA1".ToUpper() || pageItem[i].word.ToUpper() == "payment".ToUpper())
                    {
                        whereTotal = i;
                        for (int j = whereTotal; j <= pageItem.Count - 1; j++)
                        {
                            if (pageItem[whereTotal].line != pageItem[j].line)
                            {
                                break;
                            }

                            if (pageItem[j].type == 3)
                            {
                                currentInvoice.TotalAmount = pageItem[j].word;
                                int    whereLineItem = 0;
                                double itemAmount    = 0;

                                string iteamName = "";
                                double itemQty   = 0;

                                for (int k = whereTotal; k >= 0; k--)
                                {
                                    if (whereLineItem != 0 && whereLineItem != pageItem[k].line)
                                    {
                                        whereLineItem = 0;
                                        Lineitem lineIteam = new Lineitem();
                                        lineIteam.ItemAmount = itemAmount;
                                        lineIteam.ItemQty    = itemQty;
                                        lineIteam.ItemName   = iteamName;
                                        currentInvoice.Lineitems.Add(lineIteam);
                                        iteamName = "";
                                    }

                                    if (pageItem[whereTotal].line != pageItem[k].line)
                                    {
                                        if (pageItem[k].type == 3 && whereLineItem == 0)
                                        {
                                            whereLineItem = pageItem[k].line;

                                            Regex  rgx = new Regex("\\$");
                                            string str = rgx.Replace(pageItem[k].word, "");
                                            itemAmount = Convert.ToDouble(str);
                                        }

                                        if (whereLineItem == pageItem[k].line)
                                        {
                                            if (pageItem[k].type == 1 || pageItem[k].type == 2)
                                            {
                                                itemQty = Convert.ToDouble(pageItem[k].word);
                                            }
                                            else if (pageItem[k].type == 5 && pageItem[k].word != "$")
                                            {
                                                iteamName = pageItem[k].word + " " + iteamName;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (pageItem[i].type == 4)
                    {
                        //IFormatProvider monthFirst = IFormatProvider("MM/dd/yyyy");
                        currentInvoice.InvoiceDate = Convert.ToDateTime(pageItem[i].word);
                    }
                }
            }
            int    currentLine = 0;
            string vName       = "";

            for (int i = 0; i <= pageItem.Count - 1; i++)
            {
                if (vName != "")
                {
                    if (currentLine != pageItem[i].line && currentLine != 0)
                    {
                        currentInvoice.VendorName = vName;
                        break;
                    }
                }
                if (pageItem[i].type == 5 && pageItem[i].word != null)
                {
                    if (pageItem[i].word.Trim() != "")
                    {
                        vName = vName + " " + pageItem[i].word;
                    }
                    if (currentLine == 0)
                    {
                        currentLine = pageItem[i].line;
                    }
                }
            }
            currentInvoice.InvoiceID = fileName;
            if (currentInvoice.TotalAmount == null)
            {
                //advanced Total finder
                for (int i = pageItem.Count - 1; i >= 0; i--)
                {
                    if (pageItem[i].type == 3 && currentInvoice.TotalAmount == null)
                    {
                        currentInvoice.TotalAmount = pageItem[i].word;
                        int    whereLineItem = 0;
                        double itemAmount    = 0;

                        string iteamName = "";
                        double itemQty   = 0;
                        whereTotal = i;
                        for (int k = whereTotal; k >= 0; k--)
                        {
                            if (whereLineItem != 0 && whereLineItem != pageItem[k].line)
                            {
                                whereLineItem = 0;
                                Lineitem lineIteam = new Lineitem();
                                lineIteam.ItemAmount = itemAmount;
                                lineIteam.ItemQty    = itemQty;
                                lineIteam.ItemName   = iteamName;
                                currentInvoice.Lineitems.Add(lineIteam);
                                iteamName = "";
                            }

                            if (pageItem[whereTotal].line != pageItem[k].line)
                            {
                                if (pageItem[k].type == 3 && whereLineItem == 0)
                                {
                                    whereLineItem = pageItem[k].line;

                                    Regex  rgx = new Regex("\\$");
                                    string str = rgx.Replace(pageItem[k].word, "");
                                    itemAmount = Convert.ToDouble(str);
                                }

                                if (whereLineItem == pageItem[k].line)
                                {
                                    if (pageItem[k].type == 1 || pageItem[k].type == 2)
                                    {
                                        itemQty = Convert.ToDouble(pageItem[k].word);
                                    }
                                    else if (pageItem[k].type == 5 && pageItem[k].word != "$")
                                    {
                                        iteamName = pageItem[k].word + " " + iteamName;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(currentInvoice);
        }