Esempio n. 1
0
        /// <summary>
        /// Reverse Correction
        /// </summary>
        /// <returns>false</returns>
        public Boolean ReverseCorrectIt()
        {
            log.Info("ReverseCorrectIt - " + ToString());
            //Move Confirm Reversal Arpit
            MMovementConfirm reversal = new MMovementConfirm(GetCtx(), 0, Get_TrxName());

            CopyValues(this, reversal, GetAD_Client_ID(), GetAD_Org_ID());
            reversal.SetDocStatus(DOCSTATUS_Drafted);
            reversal.SetDocAction(DOCACTION_Complete);
            reversal.SetIsApproved(false);
            reversal.SetProcessed(false);
            reversal.AddDescription("{->" + GetDocumentNo() + ")");
            if (reversal.Save())
            {
                // Move Confirm Line
                DataSet ds = DB.ExecuteDataset("Select M_MovementLineConfirm_ID from M_MovementLineConfirm Where M_MovementConfirm_ID =" + GetM_MovementConfirm_ID());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    for (Int32 i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        MMovementLineConfirm linesfrom = new MMovementLineConfirm(GetCtx(), Util.GetValueOfInt(ds.Tables[0].Rows[i]["M_MovementLineConfirm_ID"]), Get_TrxName());
                        MMovementLineConfirm linesTo   = new MMovementLineConfirm(GetCtx(), 0, Get_TrxName());
                        CopyValues(linesfrom, linesTo, GetAD_Client_ID(), GetAD_Org_ID());
                        linesTo.SetM_MovementConfirm_ID(reversal.GetM_MovementConfirm_ID());
                        linesTo.SetConfirmedQty(Decimal.Negate(linesfrom.GetConfirmedQty()));
                        linesTo.SetDifferenceQty(Decimal.Negate(linesfrom.GetDifferenceQty()));
                        linesTo.SetScrappedQty(Decimal.Negate(linesfrom.GetScrappedQty()));
                        linesTo.SetTargetQty(Decimal.Negate(linesfrom.GetTargetQty()));
                        linesTo.SetProcessed(true);
                        if (!linesTo.Save(Get_Trx()))
                        {
                            Get_Trx().Rollback();
                            _processMsg = "Reversal ERROR: " + reversal.GetProcessMsg();
                            return(false);
                        }
                    }
                }
                if (reversal.CompleteIt() == DOCSTATUS_Completed)
                {
                    reversal.SetDocStatus("RE"); // set
                    reversal.SetDocAction(DOCACTION_Void);
                    reversal.SetProcessed(true);
                    reversal.Save(Get_Trx());
                }
            }
            else
            {
                _processMsg = "Could not create Movement Confirm Reversal";
                return(false);
            }
            SetDocStatus(DOCSTATUS_Voided);
            SetDocAction(DOCACTION_Void);
            Save(Get_Trx());
            //End
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Create Confirmation or return existing one
        /// </summary>
        /// <param name="move">movement</param>
        /// <param name="checkExisting">if false, new confirmation is created</param>
        /// <returns>Confirmation</returns>
        public static MMovementConfirm Create(MMovement move, Boolean checkExisting)
        {
            if (checkExisting)
            {
                MMovementConfirm[] confirmations = move.GetConfirmations(false);
                for (int i = 0; i < confirmations.Length; i++)
                {
                    MMovementConfirm confirm1 = confirmations[i];
                    if (confirm1 != null)
                    {
                        return(confirm1);
                    }
                }
            }

            MMovementConfirm confirm = new MMovementConfirm(move);

            confirm.Save(move.Get_TrxName());
            MMovementLine[] moveLines = move.GetLines(false);
            for (int i = 0; i < moveLines.Length; i++)
            {
                MMovementLine        mLine = moveLines[i];
                MMovementLineConfirm cLine = new MMovementLineConfirm(confirm);
                cLine.SetMovementLine(mLine);
                // setting QtyEntered in Target Qty on Confirmation Line
                cLine.SetTargetQty(mLine.GetQtyEntered());
                cLine.SetConfirmedQty(mLine.GetQtyEntered());
                cLine.Save(move.Get_TrxName());
            }
            // Change By Arpit Rai on 24th August,2017 To Check if VA Material Quality Control Module exists or not
            if (Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(*) FROM AD_ModuleInfo WHERE Prefix='VA010_'", null, null)) > 0)
            {
                CreateConfirmParameters(move, confirm.GetM_MovementConfirm_ID(), confirm.GetCtx());
            }
            return(confirm);
        }
Esempio n. 3
0
        /// <summary>
        /// Void Document.
        /// </summary>
        /// <returns>false</returns>
        public Boolean VoidIt()
        {
            //Added BY arpit on 12th Dec,2016
            if (GetDocStatus() == "CO")
            {
                this.SetDocAction(DOCACTION_Void);
                this.SetDocStatus(DOCACTION_Void);
                if (!this.Save(Get_Trx()))
                {
                    _processMsg = "Could not void the document";
                    return(false);
                }

                MMovementConfirm RevMoveConf = new MMovementConfirm(GetCtx(), 0, Get_Trx());
                CopyValues(this, RevMoveConf, GetAD_Client_ID(), GetAD_Org_ID());
                RevMoveConf.SetDocumentNo(GetDocumentNo());
                // RevMoveConf.SetDocStatus("RE");
                //  RevMoveConf.SetDocAction(DOCACTION_Void);
                // RevMoveConf.SetProcessed(true);
                RevMoveConf.AddDescription("{->" + GetDocumentNo() + ")");
                if (RevMoveConf.Save(Get_Trx()))
                {
                    MMovementLineConfirm[] Lines = GetLines(true);
                    for (int i = 0; i < Lines.Length; i++)
                    {
                        MMovementLineConfirm oLines   = Lines[i];
                        MMovementLineConfirm revLines = new MMovementLineConfirm(GetCtx(), 0, Get_TrxName());
                        CopyValues(oLines, revLines, oLines.GetAD_Client_ID(), oLines.GetAD_Org_ID());
                        revLines.SetM_MovementConfirm_ID(RevMoveConf.GetM_MovementConfirm_ID());
                        revLines.SetConfirmedQty(Decimal.Negate(revLines.GetConfirmedQty()));
                        revLines.SetDifferenceQty(Decimal.Negate(revLines.GetDifferenceQty()));
                        revLines.SetScrappedQty(Decimal.Negate(revLines.GetScrappedQty()));
                        revLines.SetTargetQty(Decimal.Negate(revLines.GetTargetQty()));
                        revLines.SetProcessed(true);
                        if (!revLines.Save(Get_Trx()))
                        {
                            Get_Trx().Rollback();
                            _processMsg = "Could not create Movement Comfirmation Reversal Line";
                            return(false);
                        }
                    }
                }
                else
                {
                    Get_Trx().Rollback();
                    _processMsg = "Could not create Move Confirmation Reversal";
                    return(false);
                }
                if (RevMoveConf.CompleteIt() == DocActionVariables.ACTION_COMPLETE)
                {
                    RevMoveConf.SetDocStatus("RE");
                    RevMoveConf.SetDocAction(DOCACTION_Void);
                    RevMoveConf.SetProcessed(true);
                    RevMoveConf.Save(Get_Trx());
                }
                else
                {
                    _processMsg = "Reversal ERROR: ";
                    return(false);
                }
            }
            //End Here
            log.Info("VoidIt - " + ToString());
            return(true);
        }