//Added by Arpit on 15th Dec,2016 public static MJournal CopyFrom(Ctx ctx, int GL_Journal_ID, DateTime?dateDoc, Trx trxName) { MJournal from = new MJournal(ctx, GL_Journal_ID, trxName); if (from.GetGL_Journal_ID() == 0) { throw new ArgumentException("From Journal Batch not found GL_JournalBatch_ID=" + GL_Journal_ID); } // MJournal to = new MJournal(ctx, 0, trxName); PO.CopyValues(from, to, from.GetAD_Client_ID(), from.GetAD_Org_ID()); to.Set_ValueNoCheck("DocumentNo", null); // to.Set_ValueNoCheck("C_Period_ID", null); to.SetDateAcct(dateDoc); to.SetDateDoc(dateDoc); to.SetDocStatus(DOCSTATUS_Drafted); to.SetDocAction(DOCACTION_Complete); to.SetIsApproved(false); to.SetProcessed(false); from.GetType(); // if (!to.Save()) { throw new Exception("Could not create GL Journal "); } if (to.CopyJLines(from, dateDoc) == 0) { throw new Exception("Could not create GL Journal Details"); } return(to); } // copyFrom
} // reverseAccrualIt /// <summary> /// Reverse Accrual. Flip Dr/Cr - Use Today's date /// </summary> /// <param name="GL_JournalBatch_ID">reversal batch</param> /// <returns> journal or null </returns> public MJournal ReverseAccrualIt(int GL_JournalBatch_ID) { log.Info(ToString()); // Journal MJournal reverse = new MJournal(this); reverse.SetGL_JournalBatch_ID(GL_JournalBatch_ID); reverse.SetDateDoc(DateTime.Now); reverse.Set_ValueNoCheck("C_Period_ID", null); // reset reverse.SetDateAcct(reverse.GetDateDoc()); // Reverse indicator String description = reverse.GetDescription(); if (description == null) { description = "** " + GetDocumentNo() + " **"; } else { description += " ** " + GetDocumentNo() + " **"; } reverse.SetDescription(description); if (!reverse.Save()) { return(null); } // Lines reverse.CopyLinesFrom(this, reverse.GetDateAcct(), 'R'); // SetProcessed(true); SetDocAction(DOCACTION_None); return(reverse); } // reverseAccrualIt