/// <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); }
/// <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); }