//public int GetC_Currency_ID() //{ // return GetCtx().GetContextAsInt("$C_Currency_ID "); //} public bool IsComplete() { String ds = GetDocStatus(); return(DOCSTATUS_Completed.Equals(ds) || DOCSTATUS_Closed.Equals(ds) || DOCSTATUS_Reversed.Equals(ds)); }
public virtual bool VoidIt() { log.Info(ToString()); bool res = true; if (DOCSTATUS_Closed.Equals(GetDocStatus()) || DOCSTATUS_Reversed.Equals(GetDocStatus()) || DOCSTATUS_Voided.Equals(GetDocStatus())) { _processMsg = "Document Closed: " + GetDocStatus(); return(false); } //Processed- Documnent canot be voided if payment reference exist if (DOCSTATUS_Completed.Equals(GetDocStatus())) { if (IsVA027_PaymentGenerated()) { _processMsg = Msg.GetMsg(GetCtx(), "VA027_PaymentAvailable"); return(false); } } // Not Processed if (DOCSTATUS_Drafted.Equals(GetDocStatus()) || DOCSTATUS_Invalid.Equals(GetDocStatus()) || DOCSTATUS_InProgress.Equals(GetDocStatus()) || DOCSTATUS_Approved.Equals(GetDocStatus()) || DOCSTATUS_NotApproved.Equals(GetDocStatus())) { AddDescription(Msg.GetMsg(GetCtx(), "Voided") + " (" + GetVA027_PayAmt() + ")"); SetVA027_PayAmt(Env.ZERO); SetVA027_DiscountAmt(Env.ZERO); SetVA027_WriteoffAmt(Env.ZERO); } //*****************code //***********************end here else { res = ReverseCorrectIt(); } if (res == true) { SetProcessed(true); SetDocAction(DOCACTION_None); return(true); } else { return(false); } }
} // voidIt /// <summary> /// Close Document.Cancel not delivered Qunatities /// </summary> /// <returns>true if success </returns> public Boolean CloseIt() { log.Info(ToString()); if (DOCSTATUS_Completed.Equals(GetDocStatus())) { SetProcessed(true); SetDocAction(DOCACTION_None); return(true); } return(false); } // closeIt
} // 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
} // rejectIt /// <summary> /// Complete Document /// </summary> /// <returns>new status (Complete, In Progress, Invalid, Waiting ..)</returns> public String CompleteIt() { log.Info("completeIt - " + ToString()); // Re-Check if (!m_justPrepared) { String status = PrepareIt(); if (!DocActionVariables.STATUS_INPROGRESS.Equals(status)) { return(status); } } // JID_1290: Set the document number from completed document sequence after completed (if needed) SetCompletedDocumentNo(); // Implicit Approval ApproveIt(); // Add up Amounts & complete them MJournal[] journals = GetJournals(true); Decimal? TotalDr = Env.ZERO; Decimal? TotalCr = Env.ZERO; for (int i = 0; i < journals.Length; i++) { MJournal journal = journals[i]; if (!journal.IsActive()) { journal.SetProcessed(true); journal.SetDocStatus(DOCSTATUS_Voided); journal.SetDocAction(DOCACTION_None); journal.Save(); continue; } // Complete if not closed if (DOCSTATUS_Closed.Equals(journal.GetDocStatus()) || DOCSTATUS_Voided.Equals(journal.GetDocStatus()) || DOCSTATUS_Reversed.Equals(journal.GetDocStatus()) || DOCSTATUS_Completed.Equals(journal.GetDocStatus())) { ; } else { String status = journal.CompleteIt(); if (!DocActionVariables.STATUS_COMPLETED.Equals(status)) { journal.SetDocStatus(status); journal.Save(); m_processMsg = journal.GetProcessMsg(); return(status); } journal.SetDocStatus(DOCSTATUS_Completed); journal.Save(); } // //TotalDr = TotalDr.add(journal.getTotalDr()); TotalDr = Decimal.Add(TotalDr.Value, journal.GetTotalDr()); TotalCr = Decimal.Add(TotalCr.Value, journal.GetTotalCr()); } SetTotalDr(TotalDr.Value); SetTotalCr(TotalCr.Value); // User Validation String valid = ModelValidationEngine.Get().FireDocValidate(this, ModalValidatorVariables.DOCTIMING_AFTER_COMPLETE); if (valid != null) { m_processMsg = valid; return(DocActionVariables.STATUS_INVALID); } // SetProcessed(true); SetDocAction(DOCACTION_Close); return(DocActionVariables.STATUS_COMPLETED); } // completeIt
} // invalidateIt /// <summary> /// Prepare Document /// </summary> /// <returns>new status (In Progress or Invalid) </returns> public String PrepareIt() { log.Info(ToString()); m_processMsg = ModelValidationEngine.Get().FireDocValidate(this, ModalValidatorVariables.DOCTIMING_BEFORE_PREPARE); if (m_processMsg != null) { return(DocActionVariables.STATUS_INVALID); } MDocType dt = MDocType.Get(GetCtx(), GetC_DocType_ID()); // Std Period open? if (!MPeriod.IsOpen(GetCtx(), GetDateAcct(), dt.GetDocBaseType())) { m_processMsg = "@PeriodClosed@"; return(DocActionVariables.STATUS_INVALID); } // is Non Business Day? // JID_1205: At the trx, need to check any non business day in that org. if not fund then check * org. if (MNonBusinessDay.IsNonBusinessDay(GetCtx(), GetDateAcct(), GetAD_Org_ID())) { m_processMsg = Common.Common.NONBUSINESSDAY; return(DocActionVariables.STATUS_INVALID); } // JID_0521 - Restrict if debit and credit amount is not equal.-Mohit-12-jun-2019. if (GetTotalCr() != GetTotalDr()) { m_processMsg = Msg.GetMsg(GetCtx(), "DBAndCRAmtNotEqual"); return(DocActionVariables.STATUS_INVALID); } // Add up Amounts & prepare them MJournal[] journals = GetJournals(false); if (journals.Length == 0) { m_processMsg = "@NoLines@"; return(DocActionVariables.STATUS_INVALID); } Decimal TotalDr = Env.ZERO; Decimal TotalCr = Env.ZERO; for (int i = 0; i < journals.Length; i++) { MJournal journal = journals[i]; if (!journal.IsActive()) { continue; } // Prepare if not closed if (DOCSTATUS_Closed.Equals(journal.GetDocStatus()) || DOCSTATUS_Voided.Equals(journal.GetDocStatus()) || DOCSTATUS_Reversed.Equals(journal.GetDocStatus()) || DOCSTATUS_Completed.Equals(journal.GetDocStatus())) { ; } else { String status = journal.PrepareIt(); if (!DocActionVariables.STATUS_INPROGRESS.Equals(status)) { journal.SetDocStatus(status); journal.Save(); m_processMsg = journal.GetProcessMsg(); return(status); } journal.SetDocStatus(DOCSTATUS_InProgress); journal.Save(); } // //TotalDr = TotalDr.add(journal.getTotalDr()); TotalDr = Decimal.Add(TotalDr, journal.GetTotalDr()); TotalCr = Decimal.Add(TotalCr, journal.GetTotalCr()); } SetTotalDr(TotalDr); SetTotalCr(TotalCr); // Control Amount if (Env.ZERO.CompareTo(GetControlAmt()) != 0 && GetControlAmt().CompareTo(GetTotalDr()) != 0) { m_processMsg = "@ControlAmtError@"; return(DocActionVariables.STATUS_INVALID); } // Add up Amounts m_justPrepared = true; return(DocActionVariables.STATUS_INPROGRESS); } // prepareIt