/// <summary> /// Check to see if the appropriate periods are open for this document /// </summary> /// <param name="doc">Doc</param> /// <returns>null if all periods open; otherwise the error message</returns> public static String IsPeriodOpen(DocAction doc) { List <int> docOrgs = new List <int>(); String errorMsg = null; if (errorMsg == null) { // check if lines exist // get all the orgs stamped on the document lines VAdvantage.Utility.Env.QueryParams qParams = doc.GetLineOrgsQueryInfo(); if (qParams != null) { //Object[][] result = QueryUtil.ExecuteQuery(doc.Get_Trx(), qParams.sql, // qParams.parameters.ToList()); Object[][] result = VAdvantage.Utility.QueryUtil.ExecuteQuery(doc.Get_Trx(), qParams.sql, qParams.parameters.ToList()); foreach (Object[] row in result) { docOrgs.Add(Utility.Util.GetValueOfInt(Utility.Util.GetValueOfDecimal(row[0]))); } // check if lines are missing if (result.Length == 0) { errorMsg = "@NoLines@"; } } } if (errorMsg == null) { DateTime?docDate = doc.GetDocumentDate(); String docBaseType = doc.GetDocBaseType(); if (docDate != null && docBaseType != null) { // check if period is open // add doc header org to the list of orgs if (!docOrgs.Contains(doc.GetAD_Org_ID())) { docOrgs.Add(doc.GetAD_Org_ID()); } // Std Period open? errorMsg = MPeriod.IsOpen(doc.GetCtx(), doc.GetAD_Client_ID(), docOrgs, docDate, docBaseType); } } return(errorMsg); }