/// <summary> /// Create new Journal Batch by copying /// </summary> /// <param name="ctx">context</param> /// <param name="GL_JournalBatch_ID">journal batch</param> /// <param name="dateDoc">date of the document date</param> /// <param name="trxName">transaction</param> /// <returns>Journal Batch</returns> public static MJournalBatch CopyFrom(Ctx ctx, int GL_JournalBatch_ID, DateTime?dateDoc, Trx trxName) { MJournalBatch from = new MJournalBatch(ctx, GL_JournalBatch_ID, trxName); if (from.GetGL_JournalBatch_ID() == 0) { throw new ArgumentException("From Journal Batch not found GL_JournalBatch_ID=" + GL_JournalBatch_ID); } // MJournalBatch to = new MJournalBatch(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); // if (!to.Save()) { throw new Exception("Could not create Journal Batch"); } if (to.CopyDetailsFrom(from) == 0) { throw new Exception("Could not create Journal Batch Details"); } return(to); } // copyFrom