Ejemplo n.º 1
0
        public Stock GetStockDetails(string code)
        {
            var offSet = _policyManager.LoadStoreInfo().OffSet;
            var none   = _resourceManager.GetResString(offSet, 347);
            var plu    = _stockService.GetPluMast(code);

            if (plu == null)
            {
                return(new Stock());
            }
            var stock = CacheManager.GetStockInformation(code);

            stock = new Stock
            {
                PLUPrim = plu.PLUPrim,
                PLUType = plu.PLUType
            };
            var stockItem = _stockService.GetStockByStockCode(code);

            if (stockItem != null)
            {
                stock.StockCode          = stockItem.StockCode;
                stock.Description        = stockItem.Description ?? "";
                stock.Department         = stockItem.Department;
                stock.SubDepartment      = stockItem.SubDepartment;
                stock.SubDetail          = stockItem.SubDetail;
                stock.StockType          = stockItem.StockType == '\0' ? 'V' : stockItem.StockType;
                stock.Vendor             = stockItem.Vendor;
                stock.PRType             = stockItem.PRType == '\0' ? 'R' : stockItem.PRType;
                stock.PRUnit             = stockItem.PRUnit == '\0' ? '$' : stockItem.PRUnit;
                stock.Vendor             = stockItem.Vendor ?? "";
                stock.LoyaltySave        = 0;
                stock.ProductDescription = stockItem.ProductDescription;
                stock.SByWeight          = stockItem.SByWeight;
                stock.UM                   = stockItem.UM ?? "";
                stock.StandardCost         = stockItem.StandardCost;
                stock.AverageCost          = stockItem.AverageCost;
                stock.EligibleLoyalty      = stockItem.EligibleLoyalty;
                stock.EligibleFuelRebate   = _policyManager.FuelRebate && stockItem.EligibleFuelRebate;
                stock.FuelRebate           = stockItem.FuelRebate;
                stock.EligibletaxRebate    = stockItem.EligibletaxRebate;
                stock.QualtaxRebate        = stockItem.QualtaxRebate;
                stock.EligibleTaxExemption = stockItem.EligibleTaxExemption;
            }
            else
            {
                stock.StockType = 'V';
            }
            // Set the rebate for the product, if any,
            if (stockItem != null && !string.IsNullOrEmpty(stockItem.Vendor))
            {
                stock.Rebate = _stockService.GetStockRebate(stockItem.Vendor, stockItem.StockCode);
            }


            if (_policyManager.TAX_EXEMPT)
            //  -made the same for all taxexempt- after talking to Nicolette 'And Policy.TE_Type = "SITE" Then
            {
                if (stockItem != null)
                {
                    var productTe = _stockService.GetProductTaxExempt(stockItem.StockCode);
                    if (productTe != null)
                    {
                        stock.TECategory =
                            Convert.ToInt16(productTe.CategoryFK ?? 0);
                        stock.TEVendor = Convert.ToString(productTe.TEVendor ?? "");
                        //shiny added the TE vendor
                    }
                }
            }

            stock.Charges   = GetCharges(stock.StockCode, stock.StockType);
            stock.LineKits  = GetLineKits(stock.StockCode, stock.StockType, stock.Description, stock.Vendor);
            stock.LineTaxes = GetLineTaxes(stock.StockCode, stock.StockType);

            CacheManager.AddStockInformation(stock, stock.StockCode);
            return(stock);
        }