} // getJournals /// <summary> /// Copy Journal/Lines from other Journal Batch /// </summary> /// <param name="jb">Journal Batch</param> /// <returns>number of journals + lines copied</returns> public int CopyDetailsFrom(MJournalBatch jb) { if (IsProcessed() || jb == null) { return(0); } int count = 0; int lineCount = 0; MJournal[] fromJournals = jb.GetJournals(false); for (int i = 0; i < fromJournals.Length; i++) { MJournal toJournal = new MJournal(GetCtx(), 0, jb.Get_TrxName()); PO.CopyValues(fromJournals[i], toJournal, GetAD_Client_ID(), GetAD_Org_ID()); toJournal.SetGL_JournalBatch_ID(GetGL_JournalBatch_ID()); toJournal.Set_ValueNoCheck("DocumentNo", null); // create new //Manish 18/7/2016. C_Period_ID was Null.. But column is mandatory in database so value can't be null. toJournal.Set_ValueNoCheck("C_Period_ID", fromJournals[i].GetC_Period_ID()); // end toJournal.SetDateDoc(GetDateDoc()); // dates from this Batch toJournal.SetDateAcct(GetDateAcct()); toJournal.SetDocStatus(MJournal.DOCSTATUS_Drafted); toJournal.SetDocAction(MJournal.DOCACTION_Complete); toJournal.SetTotalCr(Env.ZERO); toJournal.SetTotalDr(Env.ZERO); toJournal.SetIsApproved(false); toJournal.SetIsPrinted(false); toJournal.SetPosted(false); toJournal.SetProcessed(false); if (toJournal.Save()) { count++; lineCount += toJournal.CopyLinesFrom(fromJournals[i], GetDateAcct(), 'x'); } } if (fromJournals.Length != count) { log.Log(Level.SEVERE, "Line difference - Journals=" + fromJournals.Length + " <> Saved=" + count); } return(count + lineCount); } // copyLinesFrom