Beispiel #1
0
        /// <summary>
        /// Returns the qunatity in lot size.
        /// </summary>
        /// <param name="NetWeight">Weight after Tare is deducted</param>
        /// <param name="CommodityGrade">To Get the one lot size</param>
        /// <returns></returns>
        public static float CalculateGRNQuantity(float NetWeight, int NoBags, Guid CommodityGradeId)
        {
            float            tolerance = -1;
            Nullable <float> lotSizeKg = null;
            int   OneLotNumberBags     = -1;
            float GRNQty = 0;
            // get Lot size for the qty.
            Guid   CoffeeId    = new Guid(Utility.GetCommodityId("Coffee").ToString());
            Guid   CommodityID = CommodityGradeBLL.GetCommodityGrade(CommodityGradeId).CommodityId;
            string t           = CommodityGradeBLL.GetCommodityGrade(CommodityGradeId).Commodity;

            if (CoffeeId != CommodityID)
            {
                NetWeight = NetWeight * 100;
            }


            lotSizeKg        = CommodityGradeBLL.GetCommodityGradeLotSizeById(CommodityGradeId);
            OneLotNumberBags = CommodityGradeBLL.GetCommodityGradeLotSizeInBagsById(CommodityGradeId);
            tolerance        = Utility.WeightTolerance();
            if (lotSizeKg == null)
            {
                throw new InvalidLotSizeException("Invalid lot Size.");
            }
            else
            {
                GRNQty = (float)ECXLotCalclulate((float)NetWeight, NoBags, OneLotNumberBags, (float)lotSizeKg, tolerance);
                GRNQty = (float)(Math.Round(GRNQty * 10000) / 10000);
            }

            return(GRNQty);
        }
Beispiel #2
0
        public Nullable <float> CalculateNetWeight(float GrossWeight, Guid BagTypeId, int NoBags, Guid CommodityGradeId)
        {
            //Get Commodity Id
            Guid CommodityID = CommodityGradeBLL.GetCommodityGrade(CommodityGradeId).CommodityId;
            Guid CoffeeId    = new Guid(Utility.GetCommodityId("Coffee").ToString());


            float      Tare, netWeight;
            BagTypeBLL objbagType = new BagTypeBLL();

            objbagType.GetBagTypeById(BagTypeId);

            if (objbagType != null)
            {
                Tare = objbagType.Tare;
                if (Tare == -1)
                {
                    throw new InvalidTareException("Tare for the bag type is not provided");
                }
                // Utility.LogException(new Exception("CC : CoffeeId=" + CoffeeId.ToString() + ", CommodityID=" + CommodityID.ToString()));
                if (CoffeeId != CommodityID)
                {
                    Tare = Tare / 100; // change to quintals
                }
                netWeight = GrossWeight - (Tare * NoBags);
                // Utility.LogException(new Exception("Tare:" + Tare.ToString() + ", NoBags=" + NoBags + ", GrossWeight=" + GrossWeight.ToString() + ", netWeight=" + netWeight.ToString()));

                if (netWeight <= 0)
                {
                    throw new Exception("Net weight can not be below 0.");
                }
                netWeight = (float)(Math.Round(netWeight * 100) / 100);
                return((float)(Math.Round(netWeight * 100, 0)) / 100);
            }
            else
            {
                throw new InvalidTareException("Tare for the bag type is not provided.");
            }
        }