Exemple #1
0
        public InvoiceItem(InvoiceItem copy, Invoice parent)
        {
            this.BuyingPrice = copy.BuyingPrice;
            this.Datetime = copy.Datetime;
            //this.FromDB = copy.FromDB;
            this.invSKU = copy.invSKU;
            this.ItemDiscount = copy.ItemDiscount;
            this.ItemName = copy.ItemName;
            this.ItemOptions = copy.ItemOptions;
            this.ItemOrigPrice = copy.ItemOrigPrice;
            this.ItemPrice = copy.ItemPrice;
            this.ItemQtyCanceled = copy.ItemQtyCanceled;
            this.ItemQtyInvoiced = copy.ItemQtyInvoiced;
            this.ItemQtyOrdered = copy.ItemQtyOrdered;
            this.ItemQtyRefunded = copy.ItemQtyRefunded;
            this.ItemQtyShipped = copy.ItemQtyShipped;
            this.ItemStatus = copy.ItemStatus;
            this.ItemTax = copy.ItemTax;
            this.ItemTotal = copy.ItemTotal;

            this.MSG_SKU = copy.MSG_SKU;
            this.OrderItemIncrement = copy.OrderItemIncrement;
            // dopravu parujeme
            if (copy.PairCode != null && copy.PairCode == Properties.Settings.Default.ShippingCode)
            {
                //this.PairCode = copy.PairCode;
                this.PairProduct = copy.PairProduct.Clone() as StockItem;

            }
            this.PairProductStack = copy.PairProductStack;
            this.itemStorage = copy.itemStorage;

            this.Parent = parent;
            this.PredajnaCena = copy.PredajnaCena;
        }
Exemple #2
0
        internal static void InsertWaitingInvoice(InvoiceItem inv)
        {
            string strMaxCode = string.Empty;

            var maxCodeSel = "select * from WAITING_PRODS where Id = (select max(id) from WAITING_PRODS)";
            var maxCode = ExecuteQuery(maxCodeSel);
            if (maxCode != null && maxCode.Tables != null && maxCode.Tables.Count > 0)
                strMaxCode = maxCode.Tables[0].Rows[0]["ID"].ToString();
            if (string.IsNullOrEmpty(strMaxCode))
                return;

            var insert = string.Format("insert into WAITING_INV_ITEMS values ({0},{1},{2},\"{3}\",\"{4}\",{5},\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\",{13},{14})",
                "null", int.Parse(strMaxCode), DBPrice(inv.BuyingPrice), inv.Datetime, inv.ItemName, DBPrice(inv.PredajnaCena), inv.ItemOptions, inv.ItemOrigPrice, inv.ItemPrice, inv.ItemTax, inv.ItemDiscount, inv.ItemTotal, inv.ItemStatus, inv.ItemQtyOrdered, 1);

            ExecuteNonQuery(insert);
        }
Exemple #3
0
 public static bool IsItemPaired(InvoiceItem i)
 {
     return i != null && i.PairProduct != null;
 }
Exemple #4
0
        internal void CreateInvoice(List<CSVFile> allOrders)
        {
            AllInvoices = new List<Invoice>();
            Invoice inv = null;

            foreach (var order in allOrders)
            {
                string actualOrderNumber = string.Empty;
                foreach (var item in order.Items)
                {
                    // vytvorenie novej objednavky
                    if (item.OrderNumber != actualOrderNumber)
                    {
                        actualOrderNumber = item.OrderNumber;

                        if (inv != null)
                            AllInvoices.Add(inv);

                        inv = new Invoice();

                        inv.OrderPurchasedFrom = item.OrderPurchasedFrom;
                        if (inv.OrderPurchasedFrom.Contains(".sk"))
                            inv.Country = Country.Slovakia;
                        else if (inv.OrderPurchasedFrom.Contains(".hu"))
                            inv.Country = Country.Hungary;
                        else if (inv.OrderPurchasedFrom.Contains(".pl"))
                            inv.Country = Country.Poland;
                        else if (inv.OrderPurchasedFrom.Contains(".cz"))
                            inv.Country = Country.CzechRepublic;
                        else
                            inv.Country = Country.Unknown;

                        inv.fromFile = order.File;
                        inv.TotQtyOrdered = item.TotQtyOrdered;
                        inv.BillingCity = item.BillingCity;
                        inv.BillingCompany = item.BillingCompany;
                        inv.BillingCountry = item.BillingCountry;
                        inv.BillingCountryName = item.BillingCountryName;
                        inv.BillingName = item.BillingName;
                        inv.BillingPhoneNumber = Common.ModifyPhoneNr(item.BillingPhoneNumber, inv.Country);
                        inv.BillingState = item.BillingState;
                        inv.BillingStateName = item.BillingStateName;
                        inv.BillingStreet = item.BillingStreet;
                        inv.BillingZip = item.BillingZip;
                        inv.CustomerEmail = item.CustomerEmail;
                        inv.CustomerName = item.CustomerName;
                        inv.OrderDate = item.OrderDate;
                        inv.OrderDiscount = item.OrderDiscount;
                        inv.OrderDue = item.OrderDue;
                        inv.OrderGrandTotal = item.OrderGrandTotal;
                        inv.OrderNumber = item.OrderNumber;
                        inv.OrderPaid = item.OrderPaid;
                        inv.OrderPaymentMethod = item.OrderPaymentMethod;

                        inv.OrderRefunded = item.OrderRefunded;
                        inv.OrderShipping = item.OrderShipping;
                        inv.OrderShippingMethod = item.OrderShippingMethod;
                        inv.OrderStatus = item.OrderStatus;
                        // ak je stav objednavky zrusena v CSV, nastavime tento stav ak objednavke
                        if (inv.OrderStatus.ToLower().Contains("cancel"))
                            inv.Cancelled = true;
                        inv.OrderSubtotal = item.OrderSubtotal;
                        inv.OrderTax = item.OrderTax;
                        inv.ShippingCity = item.ShippingCity;
                        inv.ShippingCompany = item.ShippingCompany;
                        inv.ShippingCountry = item.ShippingCountry;
                        inv.ShippingCountryName = item.ShippingCountryName;
                        inv.ShippingName = item.ShippingName;
                        inv.ShippingPhoneNumber = Common.ModifyPhoneNr(item.ShippingPhoneNumber, inv.Country);
                        inv.ShippingState = item.ShippingState;
                        inv.ShippingStateName = item.ShippingStateName;
                        inv.ShippingStreet = item.ShippingStreet;
                        inv.ShippingZip = item.ShippingZip;

                        if (inv.CustomerName.Trim().ToUpper() == "GUEST")
                        {
                            inv.CustomerName = item.ShippingName;
                            if (inv.Country == Country.Slovakia)
                                inv.CustomerEmail = "*****@*****.**";
                            if (inv.Country == Country.Hungary)
                                inv.CustomerEmail = "*****@*****.**";
                        }

                        /*IČO,DIČ,Company*/
                       // inv.company = item.
                     //   inv.TestValues = item.TestValues;
                    }

                    if (inv != null)
                    {
                        InvoiceItem newItem = new InvoiceItem(inv);
                        newItem.ItemDiscount = item.ItemDiscount;
                        newItem.ItemName = item.ItemName;
                        newItem.ItemOptions = item.ItemOptions;
                        newItem.ItemOrigPrice = item.ItemOrigPrice;
                        newItem.ItemPrice = item.ItemPrice;
                        newItem.ItemQtyCanceled = item.ItemQtyCanceled;
                        newItem.ItemQtyInvoiced = item.ItemQtyInvoiced;
                        newItem.ItemQtyOrdered = item.ItemQtyOrdered;
                        newItem.ItemQtyRefunded = item.ItemQtyRefunded;
                        newItem.ItemQtyShipped = item.ItemQtyShipped;
                        newItem.invSKU = item.ItemSKU;
                        newItem.ItemStatus = item.ItemStatus;
                        newItem.ItemTax = item.ItemTax;
                        newItem.ItemTotal = item.ItemTotal;
                        newItem.OrderItemIncrement = item.OrderItemIncrement;

                        if (inv.InvoiceItems == null)
                            inv.InvoiceItems = new List<InvoiceItem>();
                        inv.InvoiceItems.Add(newItem);
                    }
                }

                if (inv != null)
                    AllInvoices.Add(inv);
                inv = null;
            }

               CurrentWaitingLoaded = new List<WaitingProductEntity>();
               foreach (var item in AllInvoices)
               {
               var waiting = DBProvider.ReadWaitingInvoices(item.OrderNumber);
               CurrentWaitingLoaded.AddRange(waiting);

               var toAdd = waiting.Select(e => new InvoiceItem(e)).ToList();
               toAdd.ForEach(it => it.Parent = item);
               item.InvoiceItems.AddRange(toAdd);
               }
        }
Exemple #5
0
        internal void btnInvoiceItemNew_Click(object sender, EventArgs e)
        {
            var allInvoices = GetInvoiceDS();
            var ds = GetInvoiceItemsDS();
            if (ds == null)
                return;
            var added = new InvoiceItem();
            added.ItemDiscount = "0.00";
            added.ItemQtyOrdered = "1";

            if (ds.Count > 0)
                ds.Insert(ds.Count-1, added);
            else
                ds.Insert(0, added);

            var selcells = gridInvoices.SelectedCells;
            if (selcells != null && selcells.Count > 0)
            {
                var item = allInvoices[selcells[0].RowIndex];
                added.Parent = item;
                //item.InvoiceItems.Add(added);
            }

            CheckAllEqipped();
            RefreshTab();
        }
Exemple #6
0
 void CompleteOrderItem(InvoiceItem toComplete, StockItem product)
 {
     if (toComplete == null || product == null)
         return;
     // vzajomne prepojenie
     toComplete.PairProduct = product;
     //product.PairProduct = toComplete; // odstranene 3.11.2012 - produkt bude sparovany automaticky v setteri invoiceitemu (predch. riadok)
 }
Exemple #7
0
        /// <summary>
        /// Fake produkt cena za dopravu
        /// </summary>
        /// <param name="allInvoices"></param>
        private void AddShippingItems(List<Invoice> allInvoices)
        {
            foreach (var inv in allInvoices)
            {
                InvoiceItem shipping = new InvoiceItem(inv);
                StockItem shippingStock = new StockItem();

                shipping.PairProduct = shippingStock;   // previazanie poloziek

                var config = new CountrySetting(inv.Country);
                var price = inv.OrderShipping;

                if (Common.GetPrice(price) == 0.0)
                    shipping.ItemPrice = price;
                else
                    shipping.ItemPrice = config.ShipPrice.ToString();

                inv.OrderShipping = shipping.ItemPrice;

                shippingStock.Description = config.ShipText;
                shippingStock.ProductCode = Properties.Settings.Default.ShippingCode;

                shipping.ItemQtyOrdered = "1";
                shippingStock.OrderDate = DateTime.Now;

                inv.InvoiceItems.Add(shipping);
            }
        }