Beispiel #1
0
        public void UpdateIVLocationCache(DataRow pdrowReturnedGoodsDetail, bool blnNewReturnedGood, int pintCCNID)
        {
            if (blnNewReturnedGood && pdrowReturnedGoodsDetail.RowState == DataRowState.Deleted)
            {
                //in case of adding a new returned goods
                //we don't care the deleted record
                //we only care the other states : Modified and AddNew
                return;
            }

            /*
             *              MasterLocCache (CCN, MasLoc, CODE(PRODUCTID), AVG Cost, On Hand Qty)
             *                      AVG Cost = SO_CommitInventoryDetail.CostOfGoodsSold (SO -> SO Detail -> CommitInventoryDetail)
             */
            IV_LocationCacheDS objIV_LocationCacheDS = new IV_LocationCacheDS();
            bool blnHasProductID = objIV_LocationCacheDS.HasProductID(int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.PRODUCTID_FLD].ToString()),
                                                                      pintCCNID,
                                                                      int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.MASTERLOCATIONID_FLD].ToString()),
                                                                      int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.LOCATIONID_FLD].ToString()));

            //Initialize the VO for the MasLocCache object
            IV_LocationCacheVO objIV_LocationCacheVO = new IV_LocationCacheVO();

            objIV_LocationCacheVO.ProductID        = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.PRODUCTID_FLD].ToString());
            objIV_LocationCacheVO.MasterLocationID = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.MASTERLOCATIONID_FLD].ToString());
            objIV_LocationCacheVO.CCNID            = pintCCNID;
            objIV_LocationCacheVO.LocationID       = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.LOCATIONID_FLD].ToString());


            //first we implement the case of totally adding new returned goods record
            //incase of updating an existing returned goods record
            //according to Mr.Nguyen Manh Cuong ==> Implement later ==> because it is very very complicated
            if (blnNewReturnedGood)
            {
                objIV_LocationCacheVO.OHQuantity = Decimal.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.RECEIVEQUANTITY_FLD].ToString());
            }
            else
            {
                //this one is implemented later
            }
            if (blnHasProductID)
            {
                //update an existing product
                objIV_LocationCacheDS.UpdateReturnedGoods(objIV_LocationCacheVO);
            }
            else
            {
                //Insert a new product into inventory
                objIV_LocationCacheDS.AddReturnedGoods(objIV_LocationCacheVO);
            }
        }
Beispiel #2
0
        private void UpdateIVLocationCache(DataRow pdrowReturnedGoodsDetail, bool blnNewReturnedGood, PO_ReturnToVendorMasterVO pobjPO_ReturnToVendorMasterVO)
        {
            if (blnNewReturnedGood && pdrowReturnedGoodsDetail.RowState == DataRowState.Deleted)
            {
                return;
            }

            IV_LocationCacheDS objIV_LocationCacheDS = new IV_LocationCacheDS();
            bool blnHasProductID = objIV_LocationCacheDS.HasProductID(int.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString()),
                                                                      pobjPO_ReturnToVendorMasterVO.CCNID,
                                                                      pobjPO_ReturnToVendorMasterVO.MasterLocationID,
                                                                      int.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString()));

            //Initialize the VO for the MasLocCache object
            IV_LocationCacheVO objIV_LocationCacheVO = new IV_LocationCacheVO();

            objIV_LocationCacheVO.ProductID        = int.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString());
            objIV_LocationCacheVO.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
            objIV_LocationCacheVO.CCNID            = pobjPO_ReturnToVendorMasterVO.CCNID;
            objIV_LocationCacheVO.LocationID       = int.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString());


            //first we implement the case of totally adding new returned goods record
            //incase of updating an existing returned goods record
            //according to Mr.Nguyen Manh Cuong ==> Implement later ==> because it is very very complicated
            if (blnNewReturnedGood)
            {
                objIV_LocationCacheVO.OHQuantity = Decimal.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.QUANTITY_FLD].ToString()) * (-1);
            }

            if (blnHasProductID)
            {
                objIV_LocationCacheDS.UpdateReturnedGoods(objIV_LocationCacheVO);
            }
            else
            {
                objIV_LocationCacheDS.AddReturnedGoods(objIV_LocationCacheVO);
            }
        }
Beispiel #3
0
        private void CheckOnHandQty(DataSet dstData, PO_ReturnToVendorMasterVO pobjPO_ReturnToVendorMasterVO)
        {
            const string METHOD_NAME = THIS + ".GetOnhandQty()";

            new IV_BinCacheDS();
            IV_LocationCacheDS objIV_LocationCacheDS = new IV_LocationCacheDS();
            InventoryUtilsBO   boIVUtils             = new InventoryUtilsBO();

            new MST_UMRateDS();
            decimal dcmOnHandQty, decOnHandCurrent = 0;

            try {
                for (int i = 0; i < dstData.Tables[0].Rows.Count; i++)
                {
                    if (dstData.Tables[0].Rows[i].RowState != DataRowState.Deleted)
                    {
                        //dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.RETURNTOVENDORMASTERID_FLD] = intReturnToVendorMasterID;
                        //get Quantity, location, bin, umrate
                        string strBINID = dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.BINID_FLD].ToString().Trim();
                        dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString().Trim();
                        if (strBINID != String.Empty)
                        {
                            IV_BinCacheVO objIV_BinCacheVO = new IV_BinCacheVO();
                            objIV_BinCacheVO.ProductID        = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString());
                            objIV_BinCacheVO.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
                            objIV_BinCacheVO.CCNID            = pobjPO_ReturnToVendorMasterVO.CCNID;
                            objIV_BinCacheVO.LocationID       = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString());
                            objIV_BinCacheVO.BinID            = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.BINID_FLD].ToString());
                            //get onhand qty from Bin Cache
                            if (dstData.Tables[0].Rows[i][ITM_ProductTable.LOTCONTROL_FLD].ToString() != true.ToString())
                            {
//								dcmOnHandQty = boIVUtils.GetAvailableQtyByPostDate(pobjPO_ReturnToVendorMasterVO.PostDate, objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
//									objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
//								decOnHandCurrent = boIVUtils.GetAvailableQtyByPostDate(new UtilsBO().GetDBDate(), objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
//									objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
                                dcmOnHandQty = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
                                                                                   objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
                                decOnHandCurrent = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
                                                                                       objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
                            }
                            else
                            {
                                objIV_BinCacheVO.Lot = dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOT_FLD].ToString();
//								dcmOnHandQty = boIVUtils.GetAvailableQtyByPostDate(pobjPO_ReturnToVendorMasterVO.PostDate, objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
//									objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
                                dcmOnHandQty = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
                                                                                   objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
                            }
                        }
                        else
                        {
                            IV_LocationCacheVO objIV_LocationCacheVO = new IV_LocationCacheVO();
                            objIV_LocationCacheVO.ProductID        = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString());
                            objIV_LocationCacheVO.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
                            objIV_LocationCacheVO.CCNID            = pobjPO_ReturnToVendorMasterVO.CCNID;
                            objIV_LocationCacheVO.LocationID       = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString());

                            //get onhand qty from location cache
                            if (dstData.Tables[0].Rows[i][ITM_ProductTable.LOTCONTROL_FLD].ToString() != true.ToString())
                            {
//								dcmOnHandQty =  boIVUtils.GetAvailableQtyByPostDate(pobjPO_ReturnToVendorMasterVO.PostDate, objIV_LocationCacheVO.CCNID, objIV_LocationCacheVO.MasterLocationID,
//									objIV_LocationCacheVO.LocationID, 0, objIV_LocationCacheVO.ProductID);
//								decOnHandCurrent =  boIVUtils.GetAvailableQtyByPostDate(new UtilsBO().GetDBDate(), objIV_LocationCacheVO.CCNID, objIV_LocationCacheVO.MasterLocationID,
//									objIV_LocationCacheVO.LocationID, 0, objIV_LocationCacheVO.ProductID);
                                dcmOnHandQty = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_LocationCacheVO.CCNID, objIV_LocationCacheVO.MasterLocationID,
                                                                                   objIV_LocationCacheVO.LocationID, 0, objIV_LocationCacheVO.ProductID);
                                decOnHandCurrent = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_LocationCacheVO.CCNID, objIV_LocationCacheVO.MasterLocationID,
                                                                                       objIV_LocationCacheVO.LocationID, 0, objIV_LocationCacheVO.ProductID);
                            }
                            else
                            {
                                objIV_LocationCacheVO.Lot = dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOT_FLD].ToString();
                                dcmOnHandQty = objIV_LocationCacheDS.GetAvailableQuantityByLot(objIV_LocationCacheVO.CCNID, objIV_LocationCacheVO.MasterLocationID,
                                                                                               objIV_LocationCacheVO.LocationID, objIV_LocationCacheVO.Lot, objIV_LocationCacheVO.ProductID);
                            }
                        }
                        decimal dcmUMRate = 1;
                        if (pobjPO_ReturnToVendorMasterVO.PurchaseOrderMasterID != 0)
                        {
                            //get the UMRate

                            if (dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.UMRATE_FLD].ToString() != String.Empty)
                            {
                                dcmUMRate = decimal.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.UMRATE_FLD].ToString());
                            }
                            else
                            {
                                dcmUMRate = 1;
                            }
                        }
                        decimal dcmReturnQuantity = decimal.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.QUANTITY_FLD].ToString());
                        if ((dcmOnHandQty - (dcmReturnQuantity * dcmUMRate)) < 0)
                        {
                            throw new PCSBOException(ErrorCode.MESSAGE_RGA_OVERONHANDQTY, i.ToString(), null);
                        }
                        else
                        {
                            if (decOnHandCurrent < (dcmReturnQuantity * dcmUMRate))
                            {
                                throw new PCSBOException(ErrorCode.MESSAGE_AVAILABLE_WAS_USED_AFTER_POSTDATE, i.ToString(), null);
                            }
                        }
                    }
                }
            }
            catch (PCSBOException ex)
            {
                throw ex;
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        private void CheckOnHandQty(DataSet dstData, PO_ReturnToVendorMasterVO pobjPO_ReturnToVendorMasterVO)
        {
            DateTime         dtmCurrentDate = new UtilsBO().GetDBDate().AddDays(1);
            InventoryUtilsBO boIVUtils = new InventoryUtilsBO();
            decimal          dcmOnHandQty, decOnHandCurrent = 0;

            for (int i = 0; i < dstData.Tables[0].Rows.Count; i++)
            {
                if (dstData.Tables[0].Rows[i].RowState != DataRowState.Deleted)
                {
                    //get Quantity, location, bin, umrate
                    string strBINID = dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.BINID_FLD].ToString().Trim();
                    dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString().Trim();
                    if (strBINID != String.Empty)
                    {
                        IV_BinCacheVO objIV_BinCacheVO = new IV_BinCacheVO();
                        objIV_BinCacheVO.ProductID        = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString());
                        objIV_BinCacheVO.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
                        objIV_BinCacheVO.CCNID            = pobjPO_ReturnToVendorMasterVO.CCNID;
                        objIV_BinCacheVO.LocationID       = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString());
                        objIV_BinCacheVO.BinID            = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.BINID_FLD].ToString());
                        dcmOnHandQty = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
                                                                           objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
                        decOnHandCurrent = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_BinCacheVO.CCNID, objIV_BinCacheVO.MasterLocationID,
                                                                               objIV_BinCacheVO.LocationID, objIV_BinCacheVO.BinID, objIV_BinCacheVO.ProductID);
                    }
                    else
                    {
                        IV_LocationCacheVO objIV_LocationCacheVO = new IV_LocationCacheVO();
                        objIV_LocationCacheVO.ProductID        = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString());
                        objIV_LocationCacheVO.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
                        objIV_LocationCacheVO.CCNID            = pobjPO_ReturnToVendorMasterVO.CCNID;
                        objIV_LocationCacheVO.LocationID       = int.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString());

                        dcmOnHandQty = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_LocationCacheVO.CCNID, objIV_LocationCacheVO.MasterLocationID,
                                                                           objIV_LocationCacheVO.LocationID, 0, objIV_LocationCacheVO.ProductID);
                        decOnHandCurrent = boIVUtils.GetAvailableQtyByPostDate(dtmCurrentDate, objIV_LocationCacheVO.CCNID, objIV_LocationCacheVO.MasterLocationID,
                                                                               objIV_LocationCacheVO.LocationID, 0, objIV_LocationCacheVO.ProductID);
                    }
                    decimal dcmUMRate = 1;
                    if (pobjPO_ReturnToVendorMasterVO.PurchaseOrderMasterID != 0)
                    {
                        //get the UMRate

                        if (dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.UMRATE_FLD].ToString() != String.Empty)
                        {
                            dcmUMRate = decimal.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.UMRATE_FLD].ToString());
                        }
                        else
                        {
                            dcmUMRate = 1;
                        }
                    }
                    decimal dcmReturnQuantity = decimal.Parse(dstData.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.QUANTITY_FLD].ToString());
                    if ((dcmOnHandQty - (dcmReturnQuantity * dcmUMRate)) < 0)
                    {
                        throw new PCSBOException(ErrorCode.MESSAGE_RGA_OVERONHANDQTY, i.ToString(), null);
                    }
                    else
                    if (decOnHandCurrent < (dcmReturnQuantity * dcmUMRate))
                    {
                        throw new PCSBOException(ErrorCode.MESSAGE_AVAILABLE_WAS_USED_AFTER_POSTDATE, i.ToString(), null);
                    }
                }
            }
        }