pageErrorPopUp(response);
}
private OBError processSave(VariablesSecureApp vars, String strOrder, String strNewOrg,
String strTax) {
OBError myMessage = null;
if (log4j.isDebugEnabled())
log4j.debug("Save: ChangeOrderOrg ");
if (strOrder.equals(""))
return Utility.translateError(this, vars, vars.getLanguage(), "ProcessRunError");
Connection conn = null;
try {
conn = this.getTransactionConnection();
if (strOrder.startsWith("("))
strOrder = strOrder.substring(1, strOrder.length() - 1);
if (!strOrder.equals("")) {
strOrder = Replace.replace(strOrder, "'", "");
StringTokenizer st = new StringTokenizer(strOrder, ",", false);
while (st.hasMoreTokens()) {
String strOrderId = st.nextToken();
String StrDocBaseType = ChangeOrderOrgData.selectDocbasetype(this, strOrderId);
String StrDocSubTypeSo = ChangeOrderOrgData.selectDocsubtypeso(this, strOrderId);
String StrDocTypeID = ChangeOrderOrgData.selectDoctypeneworg(this, StrDocBaseType,
StrDocSubTypeSo, strNewOrg);
String StrExistsShipment = ChangeOrderOrgData.selectExistsShipment(this, strOrderId);
if (ChangeOrderOrgData.checkRestrictions(conn, this, strOrderId)) {
releaseRollbackConnection(conn);
log4j.warn("The order is incorrect");
myMessage = new OBError();
myMessage.setType("Error");
myMessage.setMessage(Utility.messageBD(this, "ProcessRunError", vars.getLanguage()));
return myMessage;
}
boolean shouldDelete = ChangeOrderOrgData.shouldDeleteCashLine(conn, this, strOrderId);
ChangeOrderOrgData.resetOrder(conn, this, strOrderId);
try {
ChangeOrderOrgData.updateDocAction(conn, this, vars.getUser(), strOrderId);
} catch (ServletException ex) {
myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
releaseRollbackConnection(conn);
return myMessage;
}
String pinstance = SequenceIdData.getUUID();
try {
ChangeOrderOrgData.insertPInstance(conn, this, pinstance, "104", strOrderId, vars
.getUser(), vars.getClient(), vars.getOrg());
} catch (ServletException ex) {
myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
releaseRollbackConnection(conn);
return myMessage;
}
ChangeOrderOrgData.processOrder(conn, this, pinstance);
try {
ChangeOrderOrgData.updateLines(conn, this, strTax, vars.getUser(), strNewOrg,
strOrderId);
ChangeOrderOrgData.update(conn, this, vars.getUser(), strNewOrg, StrDocTypeID,
StrDocTypeID, strOrderId);
} catch (ServletException ex) {
myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
releaseRollbackConnection(conn);
return myMessage;
}
if (!StrExistsShipment.equals("0")) {
int i = 0;
ChangeOrderOrgData[] shipmentsData = ChangeOrderOrgData
.selectShipment(this, strOrderId);
for (i = 0; i < shipmentsData.length; i++) {
ChangeOrderOrgData.updateProcessed(conn, this, vars.getUser(),
shipmentsData[i].mInoutId);
String StrDocTypeIDShipment = ChangeOrderOrgData
.cDocttypeshipment(this, StrDocTypeID);
String DocumentnoShipment = Utility.getDocumentNo(this, vars, "169", "M_Inout",
StrDocTypeIDShipment, StrDocTypeIDShipment, false, true);
try {
ChangeOrderOrgData.updateShipment(conn, this, vars.getUser(), DocumentnoShipment,
StrDocTypeIDShipment, strNewOrg, shipmentsData[i].mInoutId);
ChangeOrderOrgData.updateShipmentlines(conn, this, vars.getUser(), strNewOrg,
shipmentsData[i].mInoutId);
ChangeOrderOrgData.updateMtransaction(conn, this, strNewOrg, vars.getUser(),
shipmentsData[i].mInoutId);
} catch (ServletException ex) {
myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
releaseRollbackConnection(conn);
return myMessage;
}
}
}
/* Pending change org for the invoices related */
pinstance = SequenceIdData.getUUID();
try {
ChangeOrderOrgData.insertPInstance(conn, this, pinstance, "104", strOrderId, vars
.getUser(), vars.getClient(), vars.getOrg());
} catch (ServletException ex) {
myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
releaseRollbackConnection(conn);
return myMessage;
}
ChangeOrderOrgData.processOrder(conn, this, pinstance);
try {
if (shouldDelete)
ChangeOrderOrgData.deleteCashLine(conn, this, strOrderId);
} catch (ServletException ex) {
myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
releaseRollbackConnection(conn);
return myMessage;
}
}
}
releaseCommitConnection(conn);
myMessage = new OBError();
myMessage.setType("Success");
myMessage.setTitle("");
myMessage.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
} catch (Exception e) {
try {
releaseRollbackConnection(conn);
} catch (Exception ignored) {
}