Esempio n. 1
0
        public void UpdateCostHistory(DataRow pdrowReturnedGoodsDetail, bool blnNewReturnedGood, SO_ReturnedGoodsMasterVO pobjSO_ReturnedGoodsMasterVO, decimal pdcmAvgCost)
        {
            const string RETURNED_GOODS_TRANSACTION_NAME = "SOReturnGoodsReceive";

            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;
            }
            IV_CostHistoryVO objIV_CostHistoryVO = new IV_CostHistoryVO();

            if (pdcmAvgCost < 0)
            {
                pdcmAvgCost = 0;
            }
            objIV_CostHistoryVO.ICDHItemCost21 = pdcmAvgCost;
            objIV_CostHistoryVO.ReceiveDate    = pobjSO_ReturnedGoodsMasterVO.TransDate;
            objIV_CostHistoryVO.ReceiveRef     = pobjSO_ReturnedGoodsMasterVO.ReturnedGoodsMasterID;
            objIV_CostHistoryVO.ReceiveRefLine = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.RETURNEDGOODSDETAILID_FLD].ToString());
            //QA Status
            if (pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.QASTATUS_FLD].ToString().Trim() != String.Empty)
            {
                objIV_CostHistoryVO.QAStatus = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.QASTATUS_FLD].ToString());
            }
            else
            {
                objIV_CostHistoryVO.QAStatus = 0;
            }
            //Party ID
            objIV_CostHistoryVO.PartyID = pobjSO_ReturnedGoodsMasterVO.PartyID;
            //Party Location
            objIV_CostHistoryVO.PartyLocationID = pobjSO_ReturnedGoodsMasterVO.PartyLocationID;
            //Master Location
            objIV_CostHistoryVO.MasterLocationID = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.MASTERLOCATIONID_FLD].ToString());
            //Product ID
            objIV_CostHistoryVO.ProductID = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.PRODUCTID_FLD].ToString());
            //CCN ID
            objIV_CostHistoryVO.CCNID = pobjSO_ReturnedGoodsMasterVO.CCNID;
            //Unit of measure
            if (pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.UNITID_FLD].ToString().Trim() != String.Empty)
            {
                objIV_CostHistoryVO.StockUMID = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.UNITID_FLD].ToString());
            }
            //get the TransType ID
            MST_TranTypeDS objMST_TranTypeDS = new MST_TranTypeDS();

            objIV_CostHistoryVO.TranTypeID = objMST_TranTypeDS.GetIDFromCode(RETURNED_GOODS_TRANSACTION_NAME);

            //Insert this record into the IV_CostHistory
            IV_CostHistoryDS objIV_CostHistoryDS = new IV_CostHistoryDS();

            objIV_CostHistoryDS.AddReturnedGoods(objIV_CostHistoryVO);
        }
Esempio n. 2
0
        public void UpdateCostHistory(DataRow pdrowReturnedGoodsDetail, bool blnNewReturnedGood, PO_ReturnToVendorMasterVO pobjPO_ReturnToVendorMasterVO)
        {
            const string RETURNED_GOODS_TRANSACTION_NAME = "POReturnToVendor";

            try
            {
                IV_CostHistoryVO objIV_CostHistoryVO = new IV_CostHistoryVO();

                objIV_CostHistoryVO.ReceiveDate    = pobjPO_ReturnToVendorMasterVO.PostDate;
                objIV_CostHistoryVO.ReceiveRef     = pobjPO_ReturnToVendorMasterVO.ReturnToVendorMasterID;
                objIV_CostHistoryVO.ReceiveRefLine = int.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.RETURNTOVENDORDETAILID_FLD].ToString());
                //QA Status
                objIV_CostHistoryVO.QAStatus = 0;
                //Party ID
                objIV_CostHistoryVO.PartyID = pobjPO_ReturnToVendorMasterVO.PartyID;
                //Master Location
                objIV_CostHistoryVO.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
                //Product ID
                objIV_CostHistoryVO.ProductID = int.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString());
                //CCN ID
                objIV_CostHistoryVO.CCNID = pobjPO_ReturnToVendorMasterVO.CCNID;
                //Unit of measure
                if (pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.BUYINGUMID_FLD].ToString().Trim() != String.Empty)
                {
                    objIV_CostHistoryVO.StockUMID = int.Parse(pdrowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.BUYINGUMID_FLD].ToString());
                }
                //get the TransType ID
                MST_TranTypeDS objMST_TranTypeDS = new MST_TranTypeDS();
                objIV_CostHistoryVO.TranTypeID = objMST_TranTypeDS.GetIDFromCode(RETURNED_GOODS_TRANSACTION_NAME);

                //Insert this record into the IV_CostHistory
                IV_CostHistoryDS objIV_CostHistoryDS = new IV_CostHistoryDS();
                objIV_CostHistoryDS.AddReturnedGoods(objIV_CostHistoryVO);
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public void UpdateTransactionHistory(DataRow pdrowReturnedGoodsDetail, bool blnNewReturnedGood, SO_ReturnedGoodsMasterVO pobjSO_ReturnedGoodsMasterVO, decimal pdcmAvgCost, decimal pdecUMRate)
        {
            const string RETURNED_GOODS_TRANSACTION_NAME = "SOReturnGoodsReceive";
            const string QASTATUS_STATUS_1 = "1";
            const string QASTATUS_STATUS_3 = "3";

            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;
            }
            MST_TransactionHistoryVO objMST_TransactionHistoryVO = new MST_TransactionHistoryVO();

            objMST_TransactionHistoryVO.MasterLocationID = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.MASTERLOCATIONID_FLD].ToString().Trim());
            if (pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.BINID_FLD].ToString().Trim() != String.Empty)
            {
                objMST_TransactionHistoryVO.BinID = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.BINID_FLD].ToString().Trim());
            }
            objMST_TransactionHistoryVO.TransDate   = new UtilsBO().GetDBDate();
            objMST_TransactionHistoryVO.PostDate    = pobjSO_ReturnedGoodsMasterVO.TransDate;
            objMST_TransactionHistoryVO.RefMasterID = pobjSO_ReturnedGoodsMasterVO.ReturnedGoodsMasterID;
            objMST_TransactionHistoryVO.RefDetailID = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.RETURNEDGOODSDETAILID_FLD].ToString().Trim());
            objMST_TransactionHistoryVO.Lot         = pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.LOT_FLD].ToString().Trim();
            objMST_TransactionHistoryVO.Serial      = pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.SERIAL_FLD].ToString().Trim();

            //try to get the inspection status
            if (pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.QASTATUS_FLD].ToString().Trim() == String.Empty)
            {
                objMST_TransactionHistoryVO.InspStatus = 0;
            }
            else
            {
                if (pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.QASTATUS_FLD].ToString().Trim() == QASTATUS_STATUS_1)
                {
                    objMST_TransactionHistoryVO.InspStatus = int.Parse(QASTATUS_STATUS_1);
                }
                else
                {
                    objMST_TransactionHistoryVO.InspStatus = int.Parse(QASTATUS_STATUS_3);
                }
            }

            objMST_TransactionHistoryVO.CCNID = pobjSO_ReturnedGoodsMasterVO.CCNID;

            //get the TransType ID
            MST_TranTypeDS objMST_TranTypeDS = new MST_TranTypeDS();

            objMST_TransactionHistoryVO.TranTypeID = objMST_TranTypeDS.GetIDFromCode(RETURNED_GOODS_TRANSACTION_NAME);


            objMST_TransactionHistoryVO.PartyID         = pobjSO_ReturnedGoodsMasterVO.PartyID;
            objMST_TransactionHistoryVO.PartyLocationID = pobjSO_ReturnedGoodsMasterVO.PartyLocationID;
            objMST_TransactionHistoryVO.LocationID      = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.LOCATIONID_FLD].ToString().Trim());
            objMST_TransactionHistoryVO.ProductID       = int.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.PRODUCTID_FLD].ToString().Trim());
            if (pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.UNITID_FLD].ToString().Trim() != String.Empty)
            {
                objMST_TransactionHistoryVO.StockUMID = int.Parse(pdrowReturnedGoodsDetail[ITM_ProductTable.STOCKUMID_FLD].ToString().Trim());
            }

            //calculate the NewAvg Cost
            //1.Get the OnHand Quantity from Master Location Cache
            //2.Calculate the Average Cost
            //3.Then NewAvgCost = (ReceiveQty + OnHanQty)/ ((ReceiveQty * AvgCost) + (OnHanQty * AvgCost))
            IV_MasLocCacheDS objIV_MasLocCacheDS = new IV_MasLocCacheDS();
            decimal          dcmOnHanQty         = objIV_MasLocCacheDS.GetOnHanQty(objMST_TransactionHistoryVO.ProductID, objMST_TransactionHistoryVO.CCNID, objMST_TransactionHistoryVO.MasterLocationID);

            if (pdcmAvgCost < 0)
            {
                pdcmAvgCost = 0;
            }
            decimal dcmReceiveQty = decimal.Parse(pdrowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.RECEIVEQUANTITY_FLD].ToString());

            try
            {
                objMST_TransactionHistoryVO.NewAvgCost = (dcmReceiveQty + dcmOnHanQty) / ((dcmReceiveQty * pdcmAvgCost) + (dcmOnHanQty * pdcmAvgCost));
            }
            catch
            {
                objMST_TransactionHistoryVO.NewAvgCost = 0;
            }

            objMST_TransactionHistoryVO.Quantity = dcmReceiveQty * pdecUMRate;

            new InventoryUtilsBO().SaveTransactionHistory(TransactionTypeEnum.SOReturnGoodsReceive.ToString(), (int)PurposeEnum.ReturnGoodReceipt, objMST_TransactionHistoryVO);
        }