/**
         * verifyQuantity - checks that the warehouse specified in the work order transaction
         * has sufficient quantity of the product
         * @param product
         * @param wot
         * @param qty
         * @param asiID
         * @return error message if any, else Quantity Available
         */
        private String VerifyQuantity(VAdvantage.Model.MProduct product, ViennaAdvantage.Model.MVAMFGMWrkOdrTransaction wot, Decimal qty, int asiID)
        {
            if (product.IsStocked())
            {
                ViennaAdvantage.Model.MVAMFGMWorkOrder wo = new ViennaAdvantage.Model.MVAMFGMWorkOrder(wot.GetCtx(), wot.GetVAMFG_M_WorkOrder_ID(), wot.Get_TrxName());
                int M_Warehouse_ID = wo.GetM_Warehouse_ID();

                //logic change by Raghu
                //Decimal available = ViennaAdvantage.Model.Storage.GetQtyAvailable
                //(M_Warehouse_ID, product.GetM_Product_ID(), asiID, null);

                // during creation of production execution line, reserverd qty to be checked or not
                Decimal?available = 0.0M;
                if (VAdvantage.Utility.Util.GetValueOfString(wot.GetConsiderReservedQty()) == "N")
                {
                    try
                    {
                        available = MStorage.GetQtyAvailableWithoutReserved
                                        (M_Warehouse_ID, product.GetM_Product_ID(), asiID, null);
                    }
                    catch
                    {
                        return(Msg.GetMsg(wot.GetCtx(), "PleaseUpdateVAFramework"));
                    }
                }
                else
                {
                    available = MStorage.GetQtyAvailable
                                    (M_Warehouse_ID, product.GetM_Product_ID(), asiID, null);
                }

                if (available == null)
                {
                    available = Env.ZERO;
                }
                if (Env.Signum(available.Value) == 0)
                {
                    return(Msg.GetMsg(wot.GetCtx(), "NoQtyAvailable", "0"));
                }
                else if (available.Value.CompareTo(qty) < 0)
                {
                    return(Msg.GetMsg(wot.GetCtx(), "InsufficientQtyAvailable", available.ToString()));
                }
            }
            return(Msg.GetMsg(wot.GetCtx(), "QtyAvailable"));
        } // verifyQuantity
예제 #2
0
        /*	Is Product Stocked
         *  @param ctx context
         *	@param M_Product_ID id
         *	@return true if found and stocked - false otherwise
         */
        public static bool IsProductStocked(Ctx ctx, int M_Product_ID)
        {
            MProduct product = Get(ctx, M_Product_ID);

            return(product.IsStocked());
        }
예제 #3
0
        /// <summary>
        /// Process Issue
        /// </summary>
        /// <returns>true if processed</returns>
        public bool Process()
        {
            if (!Save())
            {
                return(false);
            }
            if (GetM_Product_ID() == 0)
            {
                log.Log(Level.SEVERE, "No Product");
                return(false);
            }

            MProduct product = MProduct.Get(GetCtx(), GetM_Product_ID());

            //	If not a stocked Item nothing to do
            if (!product.IsStocked())
            {
                SetProcessed(true);
                return(Save());
            }

            /** @todo Transaction */

            //	**	Create Material Transactions **
            MTransaction mTrx = new MTransaction(GetCtx(), GetAD_Org_ID(),
                                                 MTransaction.MOVEMENTTYPE_WorkOrderPlus,
                                                 GetM_Locator_ID(), GetM_Product_ID(), GetM_AttributeSetInstance_ID(),
                                                 Decimal.Negate(GetMovementQty()), GetMovementDate(), Get_TrxName());

            mTrx.SetC_ProjectIssue_ID(GetC_ProjectIssue_ID());
            //
            MLocator loc = MLocator.Get(GetCtx(), GetM_Locator_ID());

            if (MStorage.Add(GetCtx(), loc.GetM_Warehouse_ID(), GetM_Locator_ID(),
                             GetM_Product_ID(), GetM_AttributeSetInstance_ID(), GetM_AttributeSetInstance_ID(),
                             Decimal.Negate(GetMovementQty()), null, null, Get_TrxName()))
            {
                if (mTrx.Save(Get_TrxName()))
                {
                    SetProcessed(true);
                    if (Save())
                    {
                        return(true);
                    }
                    else
                    {
                        log.Log(Level.SEVERE, "Issue not saved");               //	requires trx !!
                    }
                }
                else
                {
                    log.Log(Level.SEVERE, "Transaction not saved");     //	requires trx !!
                }
            }
            else
            {
                log.Log(Level.SEVERE, "Storage not updated");                   //	OK
            }
            //
            return(false);
        }