} // 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); } // Std Period open? - AP (Reimbursement) Invoice if (!MPeriod.IsOpen(GetCtx(), GetDateReport(), VAdvantage.Model.MDocBaseType.DOCBASETYPE_APINVOICE)) { 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(), GetDateReport(), GetAD_Org_ID())) { m_processMsg = Common.Common.NONBUSINESSDAY; return(DocActionVariables.STATUS_INVALID); } MTimeExpenseLine[] lines = GetLines(false); if (lines.Length == 0) { m_processMsg = "@NoLines@"; return(DocActionVariables.STATUS_INVALID); } // Add up Amounts Decimal amt = Env.ZERO; for (int i = 0; i < lines.Length; i++) { MTimeExpenseLine line = lines[i]; //amt = amt.add(line.GetApprovalAmt()); amt = Decimal.Add(amt, line.GetApprovalAmt());// amt.add(line.GetApprovalAmt()); } SetApprovalAmt(amt); // Invoiced but no BP for (int i = 0; i < lines.Length; i++) { MTimeExpenseLine line = lines[i]; if (line.IsInvoiced() && line.GetC_BPartner_ID() == 0) { m_processMsg = "@Line@ " + line.GetLine() + ": Invoiced, but no Business Partner"; return(DocActionVariables.STATUS_INVALID); } } m_justPrepared = true; if (!DOCACTION_Complete.Equals(GetDocAction())) { SetDocAction(DOCACTION_Complete); } return(DocActionVariables.STATUS_INPROGRESS); } // prepareIt
/// <summary> /// Get Lines /// </summary> /// <param name="requery">true requeries</param> /// <returns>array of lines</returns> public MTimeExpenseLine[] GetLines(Boolean requery) { if (_lines != null && !requery) { return(_lines); } // int C_Currency_ID = GetC_Currency_ID(); List <MTimeExpenseLine> list = new List <MTimeExpenseLine>(); // String sql = "SELECT * FROM S_TimeExpenseLine WHERE S_TimeExpense_ID=@param ORDER BY Line"; //PreparedStatement pstmt = null; SqlParameter[] param = new SqlParameter[1]; IDataReader idr = null; DataTable dt = null; try { param[0] = new SqlParameter("@param", GetS_TimeExpense_ID()); //pstmt = DataBase.prepareStatement(sql, get_TrxName()); //pstmt.setInt(1, getS_TimeExpense_ID()); idr = DB.ExecuteReader(sql, param, Get_TrxName()); //ResultSet rs = pstmt.executeQuery(); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { MTimeExpenseLine te = new MTimeExpenseLine(GetCtx(), dr, Get_TrxName()); te.SetC_Currency_Report_ID(C_Currency_ID); list.Add(te); } dt = null; } catch (Exception ex) { if (dt != null) { dt = null; } log.Log(Level.SEVERE, "getLines", ex); } finally { if (dt != null) { dt = null; } if (idr != null) { idr.Close(); } } // _lines = new MTimeExpenseLine[list.Count]; _lines = list.ToArray(); return(_lines); } // getLines