} // MJournalBatch /// <summary> /// Copy Constructor.Dos not copy: Dates/Period /// </summary> /// <param name="original">original</param> public MJournalBatch(MJournalBatch original) : this(original.GetCtx(), 0, original.Get_TrxName()) { //this (original.getCtx(), 0, original.Get_TrxName()); SetClientOrg(original); SetGL_JournalBatch_ID(original.GetGL_JournalBatch_ID()); // // setC_AcctSchema_ID(original.getC_AcctSchema_ID()); // setGL_Budget_ID(original.getGL_Budget_ID()); SetGL_Category_ID(original.GetGL_Category_ID()); SetPostingType(original.GetPostingType()); SetDescription(original.GetDescription()); SetC_DocType_ID(original.GetC_DocType_ID()); SetControlAmt(original.GetControlAmt()); // SetC_Currency_ID(original.GetC_Currency_ID()); // setC_ConversionType_ID(original.getC_ConversionType_ID()); // setCurrencyRate(original.getCurrencyRate()); // SetDateDoc(original.getDateDoc()); // setDateAcct(original.getDateAcct()); // setC_Period_ID(original.getC_Period_ID()); } // MJournal
} // reverseCorrectionIt /// <summary> /// Reverse Accrual. Flip Dr/Cr - Use Today's date /// </summary> /// <returns>true if success </returns> public Boolean ReverseAccrualIt() { log.Info("ReverseCorrectIt - " + ToString()); MJournal[] journals = GetJournals(true); // check prerequisites for (int i = 0; i < journals.Length; i++) { MJournal journal = journals[i]; if (!journal.IsActive()) { continue; } // All need to be closed/Completed if (DOCSTATUS_Completed.Equals(journal.GetDocStatus())) { ; } else { m_processMsg = "All Journals need to be Compleded: " + journal.GetSummary(); return(false); } } // Reverse it MJournalBatch reverse = new MJournalBatch(this); reverse.SetC_Period_ID(0); //reverse.SetDateDoc(new Timestamp(System.currentTimeMillis())); reverse.SetDateDoc(DateTime.Now); reverse.SetDateAcct(reverse.GetDateDoc()); // Reverse indicator String description = reverse.GetDescription(); if (description == null) { description = "** " + GetDocumentNo() + " **"; } else { description += " ** " + GetDocumentNo() + " **"; } reverse.SetDescription(description); reverse.Save(); // Reverse Journals for (int i = 0; i < journals.Length; i++) { MJournal journal = journals[i]; if (!journal.IsActive()) { continue; } if (journal.ReverseCorrectIt(reverse.GetGL_JournalBatch_ID()) == null) { m_processMsg = "Could not reverse " + journal; return(false); } journal.Save(); } return(true); } // ReverseCorrectIt
} // closeIt /// <summary> /// Reverse Correction.As if nothing happened - same date /// </summary> /// <returns>true if success </returns> public Boolean ReverseCorrectIt() { log.Info("reverseCorrectIt - " + ToString()); MJournal[] journals = GetJournals(true); // check prerequisites for (int i = 0; i < journals.Length; i++) { MJournal journal = journals[i]; if (!journal.IsActive()) { continue; } // All need to be closed/Completed if (DOCSTATUS_Completed.Equals(journal.GetDocStatus())) { ; } else { m_processMsg = "All Journals need to be Compleded: " + journal.GetSummary(); return(false); } } // Reverse it MJournalBatch reverse = new MJournalBatch(this); reverse.SetDateDoc(GetDateDoc()); reverse.SetC_Period_ID(GetC_Period_ID()); reverse.SetDateAcct(GetDateAcct()); reverse.SetC_Year_ID(GetC_Year_ID()); // Reverse indicator if (reverse.Get_ColumnIndex("ReversalDoc_ID") > 0 && reverse.Get_ColumnIndex("IsReversal") > 0) { // set Reversal property for identifying, record is reversal or not during saving or for other actions reverse.SetIsReversal(true); // Set Orignal Document Reference reverse.SetReversalDoc_ID(GetGL_JournalBatch_ID()); } // for reversal document set Temp Document No to empty if (reverse.Get_ColumnIndex("TempDocumentNo") > 0) { reverse.SetTempDocumentNo(""); } String description = reverse.GetDescription(); if (description == null) { description = "** " + GetDocumentNo() + " **"; } else { description += " ** " + GetDocumentNo() + " **"; reverse.SetDescription(description); } if (!reverse.Save()) { ValueNamePair pp = VLogger.RetrieveError(); if (pp != null && !String.IsNullOrEmpty(pp.GetName())) { m_processMsg = pp.GetName() + " - " + "Could not reverse " + this; } else { m_processMsg = "Could not reverse " + this; } return(false); } // // Reverse Journals for (int i = 0; i < journals.Length; i++) { MJournal journal = journals[i]; if (!journal.IsActive()) { continue; } if (journal.ReverseCorrectIt(reverse.GetGL_JournalBatch_ID()) == null) { m_processMsg = "Could not reverse " + journal; return(false); } journal.Save(); } return(true); } // reverseCorrectionIt