private synchronized OBError processButton(VariablesSecureApp vars, String strKey, String strOrgId,
String windowId) {
Connection conn = null;
OBError myError = null;
try {
conn = this.getTransactionConnection();
String strRegId = SequenceIdData.getUUID();
String strCloseId = SequenceIdData.getUUID();
String strOpenId = SequenceIdData.getUUID();
String strDivideUpId = SequenceIdData.getUUID();
CreateRegFactAcctData[] data = CreateRegFactAcctData
.treeOrg(this, vars.getClient(), strOrgId);
CreateRegFactAcctData[] acctSchema = CreateRegFactAcctData.treeAcctSchema(this, vars
.getClient());
for (int j = 0; j < acctSchema.length; j++) {
for (int i = 0; i < data.length; i++) {
if (log4j.isDebugEnabled())
log4j.debug("Output: Before buttonReg");
String strRegOut = processButtonReg(conn, vars, strKey, windowId, data[i].org, strRegId,
acctSchema[j].id);
String strCloseOut = processButtonClose(conn, vars, strKey, windowId, data[i].org,
strCloseId, strOpenId, strDivideUpId, acctSchema[j].id);
if (log4j.isDebugEnabled())
log4j.debug("Output: After buttonClose - strRegOut:" + strRegOut);
if (log4j.isDebugEnabled())
log4j.debug("Output: After buttonClose - strCloseOut:" + strCloseOut);
if (!strRegOut.equals("Success")) {
return Utility.translateError(this, vars, vars.getLanguage(), "ProcessRunError");
} else if (!strCloseOut.equals("Success")) {
return Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this,
"ProcessRunError_CreateNextPeriod", vars.getLanguage()));
}
ExpenseAmtDr = new BigDecimal("0");
ExpenseAmtCr = new BigDecimal("0");
RevenueAmtDr = new BigDecimal("0");
RevenueAmtCr = new BigDecimal("0");
String strOrgSchemaId = CreateRegFactAcctData.orgAcctschema(this, data[i].org,
acctSchema[j].id);
if (strOrgSchemaId != null && !strOrgSchemaId.equals("")) {
if (CreateRegFactAcctData.insertOrgClosing(conn, this, vars.getClient(), data[i].org,
vars.getUser(), strKey, strOrgSchemaId, strRegId, strCloseId, strDivideUpId,
strOpenId) == 0
|| CreateRegFactAcctData.updateClose(conn, this, vars.getUser(), strKey,
data[i].org) == 0)
return Utility.translateError(this, vars, vars.getLanguage(), "ProcessRunError");
}
}
}
releaseCommitConnection(conn);
myError = new OBError();
myError.setType("Success");
myError.setTitle("");
myError.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
} catch (Exception e) {
log4j.warn(e);
try {
releaseRollbackConnection(conn);
} catch (Exception ignored) {