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;
        }
 public void LoadAverageCostCalculator()
 {
     AverageCostCalculator = new AverageCostCalculator(this);
 }
        private void LoadAndCalculate()
        {
            var ledgerService = new LedgerService();
            var ledgerObject = ledgerService.GetLedger(costElement.ItemID, costElement.ItemUnitID, costElement.ManufacturerID,
                                                       costElement.MovingAverageID);

            previousQty = ReceiveDoc.GetSoundStock(costElement);

            previousUnitCost = Math.Round(ledgerObject.UnitCost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint,
                                          MidpointRounding.AwayFromZero);

            AverageCostCalculator averageCostCalculator = new AverageCostCalculator(costElement);

            costElement.AverageCost = averageCostCalculator.CalculateMovingAverage(Convert.ToDouble(previousQty),
                                                                                   Convert.ToDouble(previousUnitCost),
                                                                                   costElement.Qty, costElement.UnitCost);
            costElement.SellingPrice = averageCostCalculator.GetSellingPrice(BLL.Settings.IsCenter?0:costElement.Margin);

            txtItemName.Text = costElement.ItemName;
            txtManufacturer.Text = costElement.ManufacturerName;
            txtUnit.Text = costElement.ItemUnitName;
        }
Beispiel #7
0
 public void LoadAverageCostCalculator()
 {
     AverageCostCalculator = new AverageCostCalculator(this);
 }