Beispiel #1
0
        public void VoidGRVUnitCostlog(int Userid)
        {
            foreach (DataRowView drv in GRVSoundDetail.DefaultView)
            {
                AverageCostCalculator averageCostCalculator = new AverageCostCalculator();
                averageCostCalculator.LoadbyParameter(ReceiptID, Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["AccountID"]), Convert.ToInt32(drv["ActivityID"]));
                DataRowView drvPrevious = GetPreviousStockDataRowView(averageCostCalculator.ItemID, averageCostCalculator.ManufacturerID
                                                                      , averageCostCalculator.ItemUnitID, averageCostCalculator.AccountID);

                double NewUnitCost, NewSellingPrice;
                double PreviousQuantity, PreviousUnitCost;

                if (drvPrevious != null)
                {
                    PreviousQuantity = Convert.ToDouble(drvPrevious["PreviousQty"]) + Convert.ToDouble(drv["ReceivedQty"]);
                    PreviousUnitCost = Convert.ToDouble(drvPrevious["UnitCost"]);
                    NewUnitCost      = averageCostCalculator.CalculateMovingAverage(PreviousQuantity, PreviousUnitCost, -Convert.ToDouble(drv["ReceivedQty"]), Convert.ToDouble(drv["UnitCost"]));
                }
                else
                {
                    NewUnitCost = averageCostCalculator.CalculateMovingAverage(Convert.ToDouble(drv["ReceivedQty"]), Convert.ToDouble(drv["UnitCost"]), Convert.ToDouble(drv["ReceivedQty"]), Convert.ToDouble(drv["UnitCost"]));
                }

                if (drv["Margin"] != DBNull.Value)
                {
                    NewSellingPrice = averageCostCalculator.GetSellingPrice(Convert.ToDouble(drv["Margin"]));
                    averageCostCalculator.SaveWeightedAverageLog(Userid, ReceiptID, Convert.ToDouble(drv["Margin"]), NewSellingPrice);
                }
                else
                {
                    NewSellingPrice = averageCostCalculator.GetSellingPrice(0);
                    averageCostCalculator.SaveWeightedAverageLog(Userid, ReceiptID, 0, NewSellingPrice);
                }
            }
        }
Beispiel #2
0
        public bool CalculateFinalCosts()
        {
            _GrandTotalCost  = 0;
            _PriceDifference = 0;
            foreach (DataRowView drv in GRVSoundDetail.DefaultView)
            {
                AverageCostCalculator averageCostCalculator = new AverageCostCalculator();
                averageCostCalculator.LoadbyParameter(ReceiptID, Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["AccountID"]), Convert.ToInt32(drv["ActivityID"]));

                DataRowView drvPrevious = GetPreviousStockDataRowView(averageCostCalculator.ItemID, averageCostCalculator.ManufacturerID
                                                                      , averageCostCalculator.ItemUnitID, averageCostCalculator.AccountID);
                if (!BLL.Settings.UseCostTier && PreviousRowCount > 2)
                {
                    return(false);
                }

                double NewUnitCost, NewSellingPrice;
                var    recQty   = drv["ReceivedQty"];
                var    unitCost = drv["UnitCost"];
                if (drvPrevious != null)
                {
                    var prevQty      = drvPrevious["PreviousQty"];
                    var prevUnitCost = drvPrevious["UnitCost"];

                    NewUnitCost = averageCostCalculator.CalculateMovingAverage(Convert.ToDouble(prevQty),
                                                                               Convert.ToDouble(prevUnitCost),
                                                                               Convert.ToDouble(recQty),
                                                                               Convert.ToDouble(unitCost));
                }

                else
                {
                    NewUnitCost = averageCostCalculator.CalculateMovingAverage(0, 0, Convert.ToDouble(recQty), Convert.ToDouble(unitCost));
                }
                if (BLL.Settings.IsCenter)
                {
                    NewSellingPrice = NewUnitCost;
                }
                else if (drv["Margin"] != DBNull.Value)
                {
                    NewSellingPrice = averageCostCalculator.GetSellingPrice(Convert.ToDouble(drv["Margin"]));
                }
                else
                {
                    NewSellingPrice = averageCostCalculator.GetSellingPrice(0);
                }

                drv["AverageCost"]  = NewUnitCost;
                drv["SellingPrice"] = NewSellingPrice;
                _PriceDifference    = _PriceDifference + averageCostCalculator.PriceDifference;

                _GrandTotalCost = _GrandTotalCost + Convert.ToDouble(drv["TotalCost"]);
            }
            return(true);
        }
        public void VoidGRVUnitCostlog(int Userid)
        {
            foreach (DataRowView drv in GRVSoundDetail.DefaultView)
               {
               AverageCostCalculator averageCostCalculator = new AverageCostCalculator();
               averageCostCalculator.LoadbyParameter(ReceiptID, Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["AccountID"]), Convert.ToInt32(drv["ActivityID"]));
               DataRowView drvPrevious = GetPreviousStockDataRowView(averageCostCalculator.ItemID, averageCostCalculator.ManufacturerID
                                                                    , averageCostCalculator.ItemUnitID, averageCostCalculator.AccountID);

               double NewUnitCost, NewSellingPrice;
               double PreviousQuantity, PreviousUnitCost;

               if (drvPrevious != null)
               {
                   PreviousQuantity = Convert.ToDouble(drvPrevious["PreviousQty"]) + Convert.ToDouble(drv["ReceivedQty"]);
                   PreviousUnitCost = Convert.ToDouble(drvPrevious["UnitCost"]);
                   NewUnitCost = averageCostCalculator.CalculateMovingAverage(PreviousQuantity, PreviousUnitCost, -Convert.ToDouble(drv["ReceivedQty"]), Convert.ToDouble(drv["UnitCost"]));
               }
               else
                   NewUnitCost = averageCostCalculator.CalculateMovingAverage(Convert.ToDouble(drv["ReceivedQty"]), Convert.ToDouble(drv["UnitCost"]), Convert.ToDouble(drv["ReceivedQty"]), Convert.ToDouble(drv["UnitCost"]));

               if (drv["Margin"] != DBNull.Value)
               {
                   NewSellingPrice = averageCostCalculator.GetSellingPrice(Convert.ToDouble(drv["Margin"]));
                   averageCostCalculator.SaveWeightedAverageLog(Userid, ReceiptID, Convert.ToDouble(drv["Margin"]), NewSellingPrice);
               }
               else
               {
                   NewSellingPrice = averageCostCalculator.GetSellingPrice(0);
                   averageCostCalculator.SaveWeightedAverageLog(Userid, ReceiptID, 0, NewSellingPrice);
               }

               }
        }
        public bool CalculateFinalCosts()
        {
            _GrandTotalCost = 0;
               _PriceDifference = 0;
               foreach(DataRowView drv in GRVSoundDetail.DefaultView)
               {
               AverageCostCalculator averageCostCalculator = new AverageCostCalculator();
               averageCostCalculator.LoadbyParameter(ReceiptID,Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["AccountID"]),Convert.ToInt32(drv["ActivityID"]));

               DataRowView drvPrevious = GetPreviousStockDataRowView(averageCostCalculator.ItemID,averageCostCalculator.ManufacturerID
                                                                    ,averageCostCalculator.ItemUnitID,averageCostCalculator.AccountID);
               if(!BLL.Settings.UseCostTier && PreviousRowCount >2)
                    return false;

               double NewUnitCost,NewSellingPrice;
               var recQty = drv["ReceivedQty"];
               var unitCost = drv["UnitCost"];
               if (drvPrevious != null)
               {
                   var prevQty = drvPrevious["PreviousQty"];
                   var prevUnitCost = drvPrevious["UnitCost"];

                   NewUnitCost = averageCostCalculator.CalculateMovingAverage(Convert.ToDouble(prevQty),
                                                                              Convert.ToDouble(prevUnitCost),
                                                                              Convert.ToDouble(recQty),
                                                                              Convert.ToDouble(unitCost));
               }

               else
                   NewUnitCost = averageCostCalculator.CalculateMovingAverage(0,0, Convert.ToDouble(recQty), Convert.ToDouble(unitCost));
               if (BLL.Settings.IsCenter)
                   NewSellingPrice = NewUnitCost;
               else if (drv["Margin"] != DBNull.Value)
                   NewSellingPrice = averageCostCalculator.GetSellingPrice(Convert.ToDouble(drv["Margin"]));
               else
                   NewSellingPrice = averageCostCalculator.GetSellingPrice(0);

               drv["AverageCost"] =  NewUnitCost;
               drv["SellingPrice"] = NewSellingPrice;
               _PriceDifference = _PriceDifference  + averageCostCalculator.PriceDifference;

               _GrandTotalCost = _GrandTotalCost + Convert.ToDouble(drv["TotalCost"]);
               }
               return true;
        }