Exemplo n.º 1
0
        public static FinancialObject Post(ICollection <ActiveInventoryObject> Activity,
                                           string receiptID, decimal cash, decimal credit, decimal check,
                                           PricingModelObject selectedPricingModel, decimal tax, decimal profitLoss, string USStateOfSale, decimal totalSale, decimal discountAmount)
        {
            DateTime transTime    = DateTime.Now;
            decimal  discount     = 0;
            int      productCount = 0;

            if (Activity != null)
            {
                foreach (ActiveInventoryObject aio in Activity)
                {
                    InventoryTransactionObject tran = new InventoryTransactionObject();

                    //aio.TotalDollarChanged -= newItem_TotalDollarChanged;
                    tran.ReceiptID = receiptID;

                    tran.TransactionTime = transTime;
                    decimal amount = aio.GetTotalPrice(selectedPricingModel);

                    tran.TransactionAmount = amount;


                    productCount += aio.Quantity;

                    tran.Quantity = -aio.Quantity;  //Quantity to reflect change in ActiveInventory.  Negative to remove from Inventory.


                    //Part of Pair matching:
                    //tran.CostEach =
                    tran.Discount = aio.Discount;
                    // tran.DiscountRateLevel = aio.DiscountRateLevel;
                    tran.ExportedToWeb = false;
                    tran.IsSale        = true;
                    tran.PairMatched   = false;
                    tran.ProductID     = aio.ProductID;

                    decimal priceEach = aio.GetPriceEach(selectedPricingModel);
                    if (selectedPricingModel != null)
                    {
                        if (selectedPricingModel.IncludesSalesTax)
                        {
                            priceEach = priceEach / (1 + Configuration.Current.CurrentSalesTax);
                        }
                    }
                    tran.SellingPriceEach = priceEach;

                    tran.SKU = aio.SKU;

                    tran.UPC = aio.UPC;


                    Cache.Current.InventoryActivity.Add(tran);

                    discount += aio.Discount;
                }
            }
            Cache.Current.SaveInventoryActivity();

            FinancialObject fin = new FinancialObject();

            fin.ReceiptID      = receiptID;
            fin.DiscountAmount = discount;
            fin.TotalCash      = cash;
            fin.TotalCredit    = credit;
            fin.TotalCheck     = check;

            fin.TotalTax     = tax;
            fin.TotalSale    = fin.TotalCredit + fin.TotalCash + fin.TotalCheck - fin.TotalTax;
            fin.ProductCount = productCount;
            fin.ProfitLoss   = profitLoss;
            fin.Station      = Configuration.Current.StationID;
            fin.User         = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            if (selectedPricingModel != null)
            {
                fin.PricingModelInEffect = selectedPricingModel.Name;
            }
            fin.USStateOfSale = USStateOfSale;

            fin.DiscountAmount += discountAmount;

            Cache.Current.CurrentFinancials.Add(fin);
            Cache.Current.SaveFinancials();
            return(fin);
        }
        public static FinancialObject Post(ICollection<ActiveInventoryObject> Activity, 
            string receiptID, decimal cash, decimal credit, decimal check, 
            PricingModelObject selectedPricingModel, decimal tax, decimal profitLoss, string USStateOfSale, decimal totalSale, decimal discountAmount)
        {

            DateTime transTime = DateTime.Now;
            decimal discount = 0;
            int productCount = 0;
            if (Activity != null)
            {
                foreach (ActiveInventoryObject aio in Activity)
                {
                    InventoryTransactionObject tran = new InventoryTransactionObject();

                    //aio.TotalDollarChanged -= newItem_TotalDollarChanged;
                    tran.ReceiptID = receiptID;

                    tran.TransactionTime = transTime;
                    decimal amount = aio.GetTotalPrice(selectedPricingModel);

                    tran.TransactionAmount = amount;


                    productCount += aio.Quantity;

                    tran.Quantity = -aio.Quantity;  //Quantity to reflect change in ActiveInventory.  Negative to remove from Inventory.


                    //Part of Pair matching:
                    //tran.CostEach =
                    tran.Discount = aio.Discount;
                   // tran.DiscountRateLevel = aio.DiscountRateLevel;
                    tran.ExportedToWeb = false;
                    tran.IsSale = true;
                    tran.PairMatched = false;
                    tran.ProductID = aio.ProductID;

                    decimal priceEach = aio.GetPriceEach(selectedPricingModel);
                    if (selectedPricingModel != null)
                    {

                        if (selectedPricingModel.IncludesSalesTax)
                        {
                            priceEach = priceEach / (1 + Configuration.Current.CurrentSalesTax);
                        }
                    }
                    tran.SellingPriceEach = priceEach;

                    tran.SKU = aio.SKU;

                    tran.UPC = aio.UPC;


                    Cache.Current.InventoryActivity.Add(tran);

                    discount += aio.Discount;
                }
            }
            Cache.Current.SaveInventoryActivity();

            FinancialObject fin = new FinancialObject();
            fin.ReceiptID = receiptID;
            fin.DiscountAmount = discount;
            fin.TotalCash = cash;
            fin.TotalCredit = credit;
            fin.TotalCheck = check;

            fin.TotalTax = tax;
            fin.TotalSale = fin.TotalCredit + fin.TotalCash + fin.TotalCheck - fin.TotalTax;
            fin.ProductCount = productCount;
            fin.ProfitLoss = profitLoss;
            fin.Station = Configuration.Current.StationID;
            fin.User = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            if (selectedPricingModel != null)
            {

                fin.PricingModelInEffect = selectedPricingModel.Name;
            }
            fin.USStateOfSale = USStateOfSale;

            fin.DiscountAmount += discountAmount;

            Cache.Current.CurrentFinancials.Add(fin);
            Cache.Current.SaveFinancials();
            return fin;
        }
Exemplo n.º 3
0
        public static void CloseDay(decimal startingCash, decimal CashOnHand, string reportFile)
        {
            decimal cash    = startingCash;
            decimal profit  = 0;
            decimal revenue = 0;

            int     saleCount       = 0;
            int     productQuantity = 0;
            decimal discountAmount  = 0;
            decimal taxAmount       = 0;

            decimal creditAmount = 0;
            decimal checkAmount  = 0;

            List <InventoryTransactionObject> working       = new List <InventoryTransactionObject>();
            List <FinancialObject>            financialList = new List <FinancialObject>();

            foreach (InventoryTransactionObject trans in Cache.Current.InventoryActivity)
            {
                working.Add(trans);
                FinancialObject f = Cache.Current.CurrentFinancials.GetFinancial(trans.ReceiptID);
                if (f != null)
                {
                    if (trans.ProductID != 0)
                    {
                        cash    += f.TotalCash;
                        profit  += f.ProfitLoss;
                        revenue += f.TotalSale;

                        saleCount++;
                        productQuantity += f.ProductCount;
                        discountAmount  += f.DiscountAmount;
                        taxAmount       += f.TotalTax;
                        creditAmount    += f.TotalCredit;
                        checkAmount     += f.TotalCheck;
                        financialList.Add(f);
                    }
                }
            }
            decimal                    overShort = CashOnHand - cash;
            FinancialObject            fin       = null;
            InventoryTransactionObject tran      = null;

            if (overShort != 0)
            {
                fin     = new FinancialObject();
                profit += overShort;

                fin.TotalTax             = 0;
                fin.DiscountAmount       = 0;
                fin.PricingModelInEffect = string.Empty;
                fin.ProductCount         = 0;
                fin.ProfitLoss           = overShort;
                fin.ReceiptID            = DateTime.Today.ToString("yyyyMMdd") + " " + Configuration.Current.StationID + "-" + Configuration.Current.ReceiptIDNumber++;
                Configuration.Current.Save();
                fin.Station   = Configuration.Current.StationID;
                fin.TotalCash = overShort;
                fin.TotalSale = overShort;
                fin.User      = System.Security.Principal.WindowsIdentity.GetCurrent().Name;


                tran                   = new InventoryTransactionObject();
                tran.ReceiptID         = fin.ReceiptID;
                tran.CostEach          = 0;
                tran.Discount          = 0;
                tran.DiscountRateLevel = 0;
                tran.ExportedToWeb     = false;
                tran.IsSale            = true;
                tran.PairMatched       = false;
                tran.ProductID         = 0;
                tran.Quantity          = 0;
                tran.SellingPriceEach  = 0;
                tran.SKU               = string.Empty;
                tran.TransactionAmount = overShort;
                tran.TransactionTime   = DateTime.Now;
                tran.UPC               = string.Empty;
            }

            foreach (InventoryTransactionObject tran1 in working)
            {
                Cache.Current.ReadyForOpenCartUpdate.Add(tran1);
                Cache.Current.InventoryActivity.Remove(tran1);
            }
            if (tran != null)
            {
                Cache.Current.ReadyForOpenCartUpdate.Add(tran);
                working.Add(tran);
            }
            foreach (FinancialObject fin1 in financialList)
            {
                Cache.Current.StagedFinancials.Add(fin1);
                Cache.Current.CurrentFinancials.Remove(fin1);
            }
            if (fin != null)
            {
                Cache.Current.StagedFinancials.Add(fin);
                financialList.Add(fin);
            }

            Cache.Current.SaveReadyForOpenCartUpdate();
            Cache.Current.SaveStagedFinancials();
            Cache.Current.SaveFinancials();
            Cache.Current.SaveInventoryActivity();


            CreatePDFCloseDayReport(startingCash, CashOnHand, cash, creditAmount, checkAmount,
                                    profit, revenue, saleCount, productQuantity, discountAmount, taxAmount, reportFile, financialList, working);
        }
        public static void CloseDay(decimal startingCash, decimal CashOnHand, string reportFile)
        {
            decimal cash = startingCash;
            decimal profit = 0;
            decimal revenue = 0;
            
            int saleCount = 0;
            int productQuantity = 0;
            decimal discountAmount =0;
            decimal taxAmount = 0;

            decimal creditAmount = 0;
            decimal checkAmount = 0;

            List<InventoryTransactionObject> working = new List<InventoryTransactionObject>();
            List<FinancialObject> financialList = new List<FinancialObject>();

            foreach (InventoryTransactionObject trans in Cache.Current.InventoryActivity)
            {
                
                working.Add(trans);
                FinancialObject f = Cache.Current.CurrentFinancials.GetFinancial(trans.ReceiptID);
                if (f != null)
                {
                    if (trans.ProductID != 0)
                    {
                        cash += f.TotalCash;
                        profit += f.ProfitLoss;
                        revenue += f.TotalSale;

                        saleCount++;
                        productQuantity += f.ProductCount;
                        discountAmount += f.DiscountAmount;
                        taxAmount += f.TotalTax;
                        creditAmount += f.TotalCredit;
                        checkAmount += f.TotalCheck;
                        financialList.Add(f);
                    }
                }
              
            }
            decimal overShort = CashOnHand - cash;
            FinancialObject fin = null;
            InventoryTransactionObject tran = null;
            if (overShort != 0)
            {
                fin = new FinancialObject();
                profit += overShort;
                
                fin.TotalTax = 0;
                fin.DiscountAmount = 0;
                fin.PricingModelInEffect = string.Empty;
                fin.ProductCount = 0;
                fin.ProfitLoss = overShort;
                fin.ReceiptID = DateTime.Today.ToString("yyyyMMdd") + " " + Configuration.Current.StationID + "-" + Configuration.Current.ReceiptIDNumber++;
                Configuration.Current.Save();
                fin.Station = Configuration.Current.StationID;
                fin.TotalCash = overShort;
                fin.TotalSale = overShort;
                fin.User = System.Security.Principal.WindowsIdentity.GetCurrent().Name;


                tran = new InventoryTransactionObject();
                tran.ReceiptID = fin.ReceiptID;
                tran.CostEach = 0;
                tran.Discount = 0;
                tran.DiscountRateLevel = 0;
                tran.ExportedToWeb = false;
                tran.IsSale = true;
                tran.PairMatched = false;
                tran.ProductID = 0;
                tran.Quantity = 0;
                tran.SellingPriceEach = 0;
                tran.SKU = string.Empty;
                tran.TransactionAmount = overShort;
                tran.TransactionTime = DateTime.Now;
                tran.UPC = string.Empty;
                
            }

            foreach (InventoryTransactionObject tran1 in working)
            {
                
                Cache.Current.ReadyForOpenCartUpdate.Add(tran1);
                Cache.Current.InventoryActivity.Remove(tran1);
            }
            if (tran != null)
            {
                Cache.Current.ReadyForOpenCartUpdate.Add(tran);
                working.Add(tran);
            }
            foreach (FinancialObject fin1 in financialList)
            {
                Cache.Current.StagedFinancials.Add(fin1);
                Cache.Current.CurrentFinancials.Remove(fin1);
            }
            if (fin != null)
            {
                Cache.Current.StagedFinancials.Add(fin);
                financialList.Add(fin);
            }

            Cache.Current.SaveReadyForOpenCartUpdate();
            Cache.Current.SaveStagedFinancials();
            Cache.Current.SaveFinancials();
            Cache.Current.SaveInventoryActivity();
            

            CreatePDFCloseDayReport(startingCash, CashOnHand, cash, creditAmount, checkAmount,
                profit, revenue, saleCount, productQuantity, discountAmount, taxAmount, reportFile, financialList, working);

        }