/** * Prepare Document * @return new status (In Progress or Invalid) */ public String PrepareIt() { try { log.Info(ToString()); _processMsg = ModelValidationEngine.Get().FireDocValidate(this, ModalValidatorVariables.DOCTIMING_BEFORE_PREPARE); if (_processMsg != null) { return(DocActionVariables.STATUS_INVALID); } MRequisitionLine[] lines = GetLines(); // Invalid if (GetAD_User_ID() == 0 || GetM_PriceList_ID() == 0 || GetM_Warehouse_ID() == 0 || lines.Length == 0) { return(DocActionVariables.STATUS_INVALID); } // Std Period open? if (!MPeriod.IsOpen(GetCtx(), GetDateDoc(), MDocBaseType.DOCBASETYPE_PURCHASEREQUISITION)) { _processMsg = "@PeriodClosed@"; return(DocActionVariables.STATUS_INVALID); } // is Non Business Day? if (MNonBusinessDay.IsNonBusinessDay(GetCtx(), GetDateDoc())) { _processMsg = Common.Common.NONBUSINESSDAY; return(DocActionVariables.STATUS_INVALID); } // Add up Amounts int precision = MPriceList.GetStandardPrecision(GetCtx(), GetM_PriceList_ID()); Decimal totalLines = Env.ZERO; for (int i = 0; i < lines.Length; i++) { MRequisitionLine line = lines[i]; Decimal lineNet = Decimal.Multiply(line.GetQty(), line.GetPriceActual()); lineNet = Decimal.Round(lineNet, precision);//, MidpointRounding.AwayFromZero); if (lineNet.CompareTo(line.GetLineNetAmt()) != 0) { line.SetLineNetAmt(lineNet); line.Save(); } totalLines = Decimal.Add(totalLines, line.GetLineNetAmt()); } if (totalLines.CompareTo(GetTotalLines()) != 0) { SetTotalLines(totalLines); Save(); } _justPrepared = true; } catch (Exception ex) { // MessageBox.Show("MRequisition--PrepareIt"); log.Severe(ex.ToString()); } return(DocActionVariables.STATUS_INPROGRESS); }