} // 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()); // Get Period MPeriod period = MPeriod.Get(GetCtx(), GetDateAcct()); if (period == null) { log.Warning("No Period for " + GetDateAcct()); m_processMsg = "@PeriodNotFound@"; return(DocActionVariables.STATUS_INVALID); } // Standard Period if (period.GetC_Period_ID() != GetC_Period_ID() && period.IsStandardPeriod()) { m_processMsg = "@PeriodNotValid@"; return(DocActionVariables.STATUS_INVALID); } Boolean open = period.IsOpen(dt.GetDocBaseType()); if (!open) { log.Warning(period.GetName() + ": Not open for " + dt.GetDocBaseType() + " (" + GetDateAcct() + ")"); m_processMsg = "@PeriodClosed@"; return(DocActionVariables.STATUS_INVALID); } // Lines MJournalLine[] lines = GetLines(true); if (lines.Length == 0) { m_processMsg = "@NoLines@"; return(DocActionVariables.STATUS_INVALID); } // Add up Amounts Decimal AmtSourceDr = Env.ZERO; Decimal AmtSourceCr = Env.ZERO; for (int i = 0; i < lines.Length; i++) { MJournalLine line = lines[i]; if (!IsActive()) { continue; } // if (line.IsDocControlled()) { m_processMsg = "@DocControlledError@ - @Line@=" + line.GetLine() + " - " + line.GetAccountElementValue(); return(DocActionVariables.STATUS_INVALID); } // AmtSourceDr = Decimal.Add(AmtSourceDr, line.GetAmtSourceDr()); AmtSourceCr = Decimal.Add(AmtSourceCr, line.GetAmtSourceCr()); } SetTotalDr(AmtSourceDr); SetTotalCr(AmtSourceCr); // Control Amount if (Env.ZERO.CompareTo(GetControlAmt()) != 0 && GetControlAmt().CompareTo(GetTotalDr()) != 0) { m_processMsg = "@ControlAmtError@"; return(DocActionVariables.STATUS_INVALID); } // Unbalanced Jornal & Not Suspense if (AmtSourceDr.CompareTo(AmtSourceCr) != 0) { MAcctSchemaGL gl = MAcctSchemaGL.Get(GetCtx(), GetC_AcctSchema_ID()); if (gl == null || !gl.IsUseSuspenseBalancing()) { m_processMsg = "@UnbalancedJornal@"; return(DocActionVariables.STATUS_INVALID); } } if (!DOCACTION_Complete.Equals(GetDocAction())) { SetDocAction(DOCACTION_Complete); } m_justPrepared = true; return(DocActionVariables.STATUS_INPROGRESS); } // prepareIt