1 19 package org.openbravo.erpCommon.ad_actionButton; 20 21 import org.openbravo.erpCommon.utility.*; 22 import org.openbravo.erpCommon.businessUtility.Tax; 23 import org.openbravo.erpCommon.businessUtility.Tree; 24 import org.openbravo.erpCommon.utility.OBError; 25 import org.openbravo.erpCommon.ad_reports.ReportTrialBalanceData; 26 import org.openbravo.base.secureApp.*; 27 import org.openbravo.xmlEngine.XmlDocument; 28 import java.io.*; 29 import java.util.*; 30 import javax.servlet.*; 31 import javax.servlet.http.*; 32 import org.openbravo.utils.Replace; 33 import java.math.BigDecimal ; 34 35 import java.sql.Connection ; 37 38 39 public class CreateFrom extends HttpSecureAppServlet { 40 static final BigDecimal ZERO = new BigDecimal (0.0); 41 42 43 public void init (ServletConfig config) { 44 super.init(config); 45 boolHist = false; 46 } 47 48 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 49 VariablesSecureApp vars = new VariablesSecureApp(request); 50 if (vars.commandIn("DEFAULT")) { 51 String strKey = vars.getGlobalVariable("inpKey", "CreateFrom|key"); 52 String strTableId = vars.getGlobalVariable("inpTableId", "CreateFrom|tableId"); 53 String strProcessId = vars.getGlobalVariable("inpProcessId", "CreateFrom|processId", ""); 54 String strPath = vars.getGlobalVariable("inpPath", "CreateFrom|path", strDireccion + request.getServletPath()); 55 String strWindowId = vars.getGlobalVariable("inpWindowId", "CreateFrom|windowId", ""); 56 String strTabName = vars.getGlobalVariable("inpTabName", "CreateFrom|tabName", ""); 57 String strDateInvoiced = vars.getGlobalVariable("inpDateInvoiced", "CreateFrom|dateInvoiced", ""); 58 String strBPartnerLocation = vars.getGlobalVariable("inpcBpartnerLocationId", "CreateFrom|bpartnerLocation", ""); 59 String strMPriceList = vars.getGlobalVariable("inpMPricelist", "CreateFrom|pricelist", ""); 60 String strBPartner = vars.getGlobalVariable("inpcBpartnerId", "CreateFrom|bpartner", ""); 61 String strStatementDate = vars.getGlobalVariable("inpstatementdate", "CreateFrom|statementDate", ""); 62 String strBankAccount = vars.getGlobalVariable("inpcBankaccountId", "CreateFrom|bankAccount", ""); 63 String strOrg = vars.getGlobalVariable("inpadOrgId", "CreateFrom|adOrgId", ""); 64 String strIsreceipt = vars.getGlobalVariable("inpisreceipt", "CreateFrom|isreceipt", ""); 65 66 if (log4j.isDebugEnabled()) log4j.debug("doPost - inpadOrgId = " + strOrg); 67 if (log4j.isDebugEnabled()) log4j.debug("doPost - inpisreceipt = " + strIsreceipt); 68 69 vars.removeSessionValue("CreateFrom|key"); 70 vars.removeSessionValue("CreateFrom|processId"); 71 vars.removeSessionValue("CreateFrom|path"); 72 vars.removeSessionValue("CreateFrom|windowId"); 73 vars.removeSessionValue("CreateFrom|tabName"); 74 vars.removeSessionValue("CreateFrom|dateInvoiced"); 75 vars.removeSessionValue("CreateFrom|bpartnerLocation"); 76 vars.removeSessionValue("CreateFrom|pricelist"); 77 vars.removeSessionValue("CreateFrom|bpartner"); 78 vars.removeSessionValue("CreateFrom|statementDate"); 79 vars.removeSessionValue("CreateFrom|bankAccount"); 80 vars.removeSessionValue("CreateFrom|adOrgId"); 81 vars.removeSessionValue("CreateFrom|isreceipt"); 82 83 vars.setSessionValue("CreateFrom|default","1"); 85 86 printPage_FS(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strDateInvoiced, strBPartnerLocation, strMPriceList, strBPartner, strStatementDate, strBankAccount, strOrg, strIsreceipt); 87 } else if (vars.commandIn("FRAME2")) { 88 printPage_F2(response, vars); 89 } else if (vars.commandIn("FRAME1")) { 90 String strTableId = vars.getGlobalVariable("inpTableId", "CreateFrom|tableId"); 91 String strType = pageType(strTableId); 92 String strKey = vars.getGlobalVariable("inpKey", "CreateFrom" + strType + "|key"); 93 String strProcessId = vars.getGlobalVariable("inpProcessId", "CreateFrom" + strType + "|processId", ""); 94 String strPath = vars.getGlobalVariable("inpPath", "CreateFrom" + strType + "|path", strDireccion + request.getServletPath()); 95 String strWindowId = vars.getGlobalVariable("inpWindowId", "CreateFrom" + strType + "|windowId"); 96 String strTabName = vars.getGlobalVariable("inpTabName", "CreateFrom" + strType + "|tabName"); 97 String strDateInvoiced = vars.getGlobalVariable("inpDateInvoiced", "CreateFrom" + strType + "|dateInvoiced", ""); 98 String strBPartnerLocation = vars.getGlobalVariable("inpcBpartnerLocationId", "CreateFrom" + strType + "|bpartnerLocation", ""); 99 String strPriceList = vars.getGlobalVariable("inpMPricelist", "CreateFrom" + strType + "|pricelist", ""); 100 String strBPartner = vars.getGlobalVariable("inpcBpartnerId", "CreateFrom" + strType + "|bpartner", ""); 101 String strStatementDate = vars.getGlobalVariable("inpstatementdate", "CreateFrom" + strType + "|statementDate", ""); 102 String strBankAccount = vars.getGlobalVariable("inpcBankaccountId", "CreateFrom" + strType + "|bankAccount", ""); 103 String strOrg = vars.getGlobalVariable("inpadOrgId", "CreateFrom" + strType + "|adOrgId", ""); 104 String strIsreceipt = vars.getGlobalVariable("inpisreceipt", "CreateFrom" + strType + "|isreceipt", ""); 105 106 if (log4j.isDebugEnabled()) log4j.debug("doPost - inpadOrgId = " + strOrg); 107 if (log4j.isDebugEnabled()) log4j.debug("doPost - inpisreceipt = " + strIsreceipt); 108 109 vars.removeSessionValue("CreateFrom" + strType + "|key"); 110 vars.removeSessionValue("CreateFrom|tableId"); 111 vars.removeSessionValue("CreateFrom" + strType + "|processId"); 112 vars.removeSessionValue("CreateFrom" + strType + "|path"); 113 vars.removeSessionValue("CreateFrom" + strType + "|windowId"); 114 vars.removeSessionValue("CreateFrom" + strType + "|tabName"); 115 vars.removeSessionValue("CreateFrom" + strType + "|dateInvoiced"); 116 vars.removeSessionValue("CreateFrom" + strType + "|bpartnerLocation"); 117 vars.removeSessionValue("CreateFrom" + strType + "|pricelist"); 118 vars.removeSessionValue("CreateFrom" + strType + "|bpartner"); 119 vars.removeSessionValue("CreateFrom" + strType + "|statementDate"); 120 vars.removeSessionValue("CreateFrom" + strType + "|bankAccount"); 121 vars.removeSessionValue("CreateFrom" + strType + "|adOrgId"); 122 vars.removeSessionValue("CreateFrom" + strType + "|isreceipt"); 123 124 callPrintPage(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strDateInvoiced, strBPartnerLocation, strPriceList, strBPartner, strStatementDate, strBankAccount, strOrg, strIsreceipt); 125 } else if (vars.commandIn("FIND_PO", "FIND_INVOICE", "FIND_SHIPMENT", "FIND_BANK", "FIND_SETTLEMENT")) { 126 String strKey = vars.getRequiredStringParameter("inpKey"); 127 String strTableId = vars.getStringParameter("inpTableId"); 128 String strProcessId = vars.getStringParameter("inpProcessId"); 129 String strPath = vars.getStringParameter("inpPath", strDireccion + request.getServletPath()); 130 String strWindowId = vars.getStringParameter("inpWindowId"); 131 String strTabName = vars.getStringParameter("inpTabName"); 132 String strDateInvoiced = vars.getStringParameter("inpDateInvoiced"); 133 String strBPartnerLocation = vars.getStringParameter("inpcBpartnerLocationId"); 134 String strPriceList = vars.getStringParameter("inpMPricelist"); 135 String strBPartner = vars.getStringParameter("inpcBpartnerId"); 136 String strStatementDate = vars.getStringParameter("inpstatementdate"); 137 String strBankAccount = vars.getStringParameter("inpcBankaccountId"); 138 String strOrg = vars.getStringParameter("inpadOrgId"); 139 String strIsreceipt = vars.getStringParameter("inpisreceipt"); 140 if (log4j.isDebugEnabled()) log4j.debug("doPost - inpadOrgId = " + strOrg); 141 if (log4j.isDebugEnabled()) log4j.debug("doPost - inpisreceipt = " + strIsreceipt); 142 143 callPrintPage(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strDateInvoiced, strBPartnerLocation, strPriceList, strBPartner, strStatementDate, strBankAccount, strOrg, strIsreceipt); 144 } else if (vars.commandIn("REFRESH_INVOICES", "REFRESH_SHIPMENTS")) { 145 String strBPartner = vars.getStringParameter("inpcBpartnerId"); 146 String strWindowId = vars.getStringParameter("inpWindowId"); 147 printPageInvoiceCombo(response, vars, strBPartner, strWindowId); 148 } else if (vars.commandIn("SAVE")) { 149 String strProcessId = vars.getStringParameter("inpProcessId"); 150 String strKey = vars.getRequiredStringParameter("inpKey"); 151 String strTableId = vars.getStringParameter("inpTableId"); 152 String strWindowId = vars.getStringParameter("inpWindowId"); 153 String strTabName = vars.getStringParameter("inpTabName"); 154 String strPath = vars.getStringParameter("inpPath", strDireccion + request.getServletPath()); 155 String strMessage = saveMethod(vars, strKey, strTableId, strProcessId, strWindowId); 156 if (!strMessage.equals("")) vars.setSessionValue(strWindowId + "|" + strTabName + ".message", strMessage); 157 printPageClosePopUp(response, vars); 158 } else pageErrorPopUp(response); 160 } 161 162 163 void printPage_FS(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strDateInvoiced, String strBPartnerLocation, String strPriceList, String strBPartner, String strStatementDate, String strBankAccount, String strOrg, String strIsreceipt) throws IOException, ServletException { 164 if (log4j.isDebugEnabled()) log4j.debug("Output: FrameSet"); 165 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_FS").createXmlDocument(); 166 String strType = pageType(strTableId); 167 vars.setSessionValue("CreateFrom" + strType + "|path", strPath); 168 vars.setSessionValue("CreateFrom" + strType + "|key", strKey); 169 vars.setSessionValue("CreateFrom" + strType + "|processId", strProcessId); 170 vars.setSessionValue("CreateFrom" + strType + "|windowId", strWindowId); 171 vars.setSessionValue("CreateFrom" + strType + "|tabName", strTabName); 172 vars.setSessionValue("CreateFrom" + strType + "|dateInvoiced", strDateInvoiced); 173 vars.setSessionValue("CreateFrom" + strType + "|bpartnerLocation", strBPartnerLocation); 174 vars.setSessionValue("CreateFrom" + strType + "|pricelist", strPriceList); 175 vars.setSessionValue("CreateFrom" + strType + "|bpartner", strBPartner); 176 vars.setSessionValue("CreateFrom" + strType + "|statementDate", strStatementDate); 177 vars.setSessionValue("CreateFrom" + strType + "|bankAccount", strBankAccount); 178 vars.setSessionValue("CreateFrom" + strType + "|adOrgId", strOrg); 179 vars.setSessionValue("CreateFrom" + strType + "|isreceipt", strIsreceipt); 180 response.setContentType("text/html; charset=UTF-8"); 181 PrintWriter out = response.getWriter(); 182 out.println(xmlDocument.print()); 183 out.close(); 184 } 185 186 void printPage_F2(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException { 187 if (log4j.isDebugEnabled()) log4j.debug("Output: Frame2"); 188 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_F2").createXmlDocument(); 189 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 190 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 191 response.setContentType("text/html; charset=UTF-8"); 192 PrintWriter out = response.getWriter(); 193 out.println(xmlDocument.print()); 194 out.close(); 195 } 196 197 String pageType(String strTableId) { 198 if (strTableId.equals("392")) return "Bank"; 199 else if (strTableId.equals("318")) return "Invoice"; 200 else if (strTableId.equals("319")) return "Shipment"; 201 else if (strTableId.equals("426")) return "Pay"; 202 else if (strTableId.equals("800019")) return "Settlement"; 203 else return ""; 204 } 205 206 void callPrintPage(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strDateInvoiced, String strBPartnerLocation, String strPriceList, String strBPartner, String strStatementDate, String strBankAccount, String strOrg, String strIsreceipt) throws IOException, ServletException { 207 if (strTableId.equals("392")) { printPageBank(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strStatementDate, strBankAccount); 209 } else if (strTableId.equals("318")) { printPageInvoice(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strDateInvoiced, strBPartnerLocation, strPriceList, strBPartner); 211 } else if (strTableId.equals("319")) { printPageShipment(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strBPartner); 213 } else if (strTableId.equals("426")) { printPagePay(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strBPartner); 215 } else if (strTableId.equals("800019")) { printPageSettlement(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strBPartner); 217 } else if (strTableId.equals("800176")) { printPageDPManagement(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strBPartner); 219 } else if (strTableId.equals("800179")) { printPageCRemittance(response, vars, strPath, strKey, strTableId, strProcessId, strWindowId, strTabName, strBPartner, strOrg, strIsreceipt); 221 }else { 222 pageError(response); 223 } 224 } 225 226 void printPageBank(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strStatementDate, String strBank) throws IOException, ServletException { 227 if (log4j.isDebugEnabled()) log4j.debug("Output: Bank"); 228 String strcBPartner = vars.getStringParameter("inpcBpartnerId"); 229 String strPaymentRule = vars.getStringParameter("inppaymentrule"); 230 String strPlannedDateFrom = vars.getStringParameter("inpplanneddateFrom"); 231 String strPlannedDateTo = vars.getStringParameter("inpplanneddateTo"); 232 String strAmountFrom = vars.getStringParameter("inpamountFrom"); 233 String strAmountTo = vars.getStringParameter("inpamountTo"); 234 String strIsReceipt = vars.getStringParameter("inpisreceipt"); 235 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 236 String strBankAccount = vars.getStringParameter("inpcBankaccountId"); 237 String strOrg = vars.getStringParameter("inpadOrgId"); 238 String strCharge = vars.getStringParameter("inpCharge"); 239 String strPlannedDate = vars.getStringParameter("inpplanneddate", strStatementDate); 240 String strCost = vars.getStringParameter("inpcost", "0.00"); 241 String strDocumentNo = vars.getStringParameter("inpDocumentNo"); 242 CreateFromBankData[] data = null; 243 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_Bank").createXmlDocument(); 244 if (strcBPartner.equals("") && strPaymentRule.equals("") && strPlannedDateFrom.equals("") && strPlannedDateTo.equals("") && strIsReceipt.equals("") && strBankAccount.equals("") && strOrg.equals("")) { 245 data = new CreateFromBankData[0]; 246 } else { 247 if (vars.commandIn("FRAME1") && strIsReceipt.equals("")) strIsReceipt = isSOTrx; 248 data = CreateFromBankData.select(this, vars.getLanguage(), strStatementDate, Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strcBPartner, strPaymentRule, strPlannedDateFrom, strPlannedDateTo, strAmountFrom, strAmountTo, strIsReceipt, strBank, strOrg, strCharge, strDocumentNo); 249 } 250 if (vars.commandIn("FRAME1") && strIsReceipt.equals("")) strIsReceipt = isSOTrx; 251 252 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 253 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 254 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 255 xmlDocument.setParameter("path", strPath); 256 xmlDocument.setParameter("key", strKey); 257 xmlDocument.setParameter("tableId", strTableId); 258 xmlDocument.setParameter("processId", strProcessId); 259 xmlDocument.setParameter("windowId", strWindowId); 260 xmlDocument.setParameter("tabName", strTabName); 261 xmlDocument.setParameter("statementDate", strStatementDate); 262 xmlDocument.setParameter("paramCBankaccountID", strBank); 263 xmlDocument.setParameter("paramPlannedDate", strPlannedDate); 264 xmlDocument.setParameter("paramplanneddate", strPlannedDate); 265 xmlDocument.setParameter("paramcost", strCost); 266 xmlDocument.setParameter("documentNo", strDocumentNo); 267 268 xmlDocument.setParameter("paymentRule", strPaymentRule); 269 270 try { 271 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "All_Payment Rule", "", Utility.getContext(this, vars, "#User_Org", "CreateFrom"), Utility.getContext(this, vars, "#User_Client", "CreateFrom"), 0); 272 Utility.fillSQLParameters(this, vars, null, comboTableData, "CreateFrom", strPaymentRule); 273 xmlDocument.setData("reportPaymentRule","liststructure", comboTableData.select(false)); 274 comboTableData = null; 275 } catch (Exception ex) { 276 throw new ServletException(ex); 277 } 278 xmlDocument.setParameter("cbpartnerId", strcBPartner); 279 280 xmlDocument.setParameter("cbpartnerId_DES", CreateFromBankData.bpartner(this, strcBPartner)); 281 xmlDocument.setParameter("plannedDateFrom", strPlannedDateFrom); 282 xmlDocument.setParameter("plannedDateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 283 xmlDocument.setParameter("plannedDateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 284 xmlDocument.setParameter("plannedDateTo", strPlannedDateTo); 285 xmlDocument.setParameter("plannedDateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 286 xmlDocument.setParameter("plannedDateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 287 xmlDocument.setParameter("amountFrom", strAmountFrom); 288 { 289 OBError myMessage = vars.getMessage("CreateFrom"); 290 vars.removeMessage("CreateFrom"); 291 if (myMessage!=null) { 292 xmlDocument.setParameter("messageType", myMessage.getType()); 293 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 294 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 295 } 296 } 297 xmlDocument.setParameter("amountTo", strAmountTo); 298 xmlDocument.setParameter("isreceiptPago", strIsReceipt); 299 xmlDocument.setParameter("isreceiptCobro", strIsReceipt); 300 xmlDocument.setParameter("adOrgId", strOrg); 301 xmlDocument.setParameter("charge", strCharge); 302 303 304 try { 305 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_BankAccount_ID", "", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 306 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strBank); 307 xmlDocument.setData("reportC_BankAccount_ID","liststructure", comboTableData.select(false)); 308 comboTableData = null; 309 } catch (Exception ex) { 310 throw new ServletException(ex); 311 } 312 313 314 try { 315 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "AD_Org_ID", "", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 316 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strOrg); 317 xmlDocument.setData("reportAD_Org_ID","liststructure", comboTableData.select(false)); 318 comboTableData = null; 319 } catch (Exception ex) { 320 throw new ServletException(ex); 321 } 322 323 xmlDocument.setData("structure1", data); 324 response.setContentType("text/html; charset=UTF-8"); 325 PrintWriter out = response.getWriter(); 326 out.println(xmlDocument.print()); 327 out.close(); 328 } 329 330 void printPageInvoice(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strDateInvoiced, String strBPartnerLocation, String strPriceList, String strBPartner) throws IOException, ServletException { 331 if (log4j.isDebugEnabled()) log4j.debug("Output: Invoice"); 332 CreateFromInvoiceData[] data = null; 333 XmlDocument xmlDocument; 334 String strPO = vars.getStringParameter("inpPurchaseOrder"); 335 String strShipment = vars.getStringParameter("inpShipmentReciept"); 336 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 337 if (vars.commandIn("FIND_PO")) strShipment=""; 338 else if (vars.commandIn("FIND_SHIPMENT")) strPO=""; 339 if (strPO.equals("") && strShipment.equals("")) { 340 String [] discard = {"sectionDetail"}; 341 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice", discard).createXmlDocument(); 342 data=CreateFromInvoiceData.set(); 343 } else { 344 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice").createXmlDocument(); 345 if (strShipment.equals("")) { 346 if (vars.getLanguage().equals("en_US")) { 347 if (isSOTrx.equals("Y")) data=CreateFromInvoiceData.selectFromPOSOTrx(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 348 else data=CreateFromInvoiceData.selectFromPO(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 349 } else { 350 if (isSOTrx.equals("Y")) data=CreateFromInvoiceData.selectFromPOTrlSOTrx(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 351 else data=CreateFromInvoiceData.selectFromPOTrl(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 352 } 353 } else { 354 if (vars.getLanguage().equals("en_US")) { 355 if (isSOTrx.equals("Y")) data=CreateFromInvoiceData.selectFromShipmentSOTrx(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strShipment); 356 else data=CreateFromInvoiceData.selectFromShipment(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strShipment); 357 } else { 358 if (isSOTrx.equals("Y")) data=CreateFromInvoiceData.selectFromShipmentTrlSOTrx(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strShipment); 359 else data=CreateFromInvoiceData.selectFromShipmentTrl(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strShipment); 360 } 361 } 362 } 363 364 365 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 366 xmlDocument.setParameter("path", strPath); 367 xmlDocument.setParameter("key", strKey); 368 xmlDocument.setParameter("tableId", strTableId); 369 xmlDocument.setParameter("processId", strProcessId); 370 xmlDocument.setParameter("dateInvoiced", strDateInvoiced); 371 xmlDocument.setParameter("bpartnerLocation", strBPartnerLocation); 372 xmlDocument.setParameter("pricelist", strPriceList); 373 xmlDocument.setParameter("cBpartnerId", strBPartner); 374 xmlDocument.setParameter("BPartnerDescription", CreateFromShipmentData.selectBPartner(this, strBPartner)); 375 xmlDocument.setParameter("PurchaseOrder", strPO); 376 xmlDocument.setParameter("Shipment", strShipment); 377 xmlDocument.setParameter("pType", (!strShipment.equals("")?"SHIPMENT":(!strPO.equals(""))?"PO":"")); 378 xmlDocument.setParameter("windowId", strWindowId); 379 xmlDocument.setParameter("tabName", strTabName); 380 381 382 if (strBPartner.equals("")) { 383 xmlDocument.setData("reportShipmentReciept", "liststructure", new CreateFromInvoiceData[0]); 384 xmlDocument.setData("reportPurchaseOrder", "liststructure", new CreateFromInvoiceData[0]); 385 } else { 386 if (isSOTrx.equals("Y")) { 387 xmlDocument.setData("reportShipmentReciept", "liststructure", CreateFromInvoiceData.selectFromShipmentSOTrxCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 388 xmlDocument.setData("reportPurchaseOrder", "liststructure", CreateFromInvoiceData.selectFromPOSOTrxCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 389 } else { 390 xmlDocument.setData("reportShipmentReciept", "liststructure", CreateFromInvoiceData.selectFromShipmentCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 391 xmlDocument.setData("reportPurchaseOrder", "liststructure", CreateFromInvoiceData.selectFromPOCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 392 } 393 } 394 { 395 OBError myMessage = vars.getMessage("CreateFrom"); 396 vars.removeMessage("CreateFrom"); 397 if (myMessage!=null) { 398 xmlDocument.setParameter("messageType", myMessage.getType()); 399 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 400 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 401 } 402 } 403 xmlDocument.setData("structure1", data); 404 response.setContentType("text/html; charset=UTF-8"); 405 PrintWriter out = response.getWriter(); 406 out.println(xmlDocument.print()); 407 out.close(); 408 } 409 410 void printPageShipment(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strBPartner) throws IOException, ServletException { 411 if (log4j.isDebugEnabled()) log4j.debug("Output: Shipment"); 412 CreateFromShipmentData[] data = null; 413 XmlDocument xmlDocument; 414 String strPO = vars.getStringParameter("inpPurchaseOrder"); 415 String strInvoice = vars.getStringParameter("inpInvoice"); 416 String strLocator = vars.getStringParameter("inpmLocatorId"); 417 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 418 if (vars.commandIn("FIND_PO")) strInvoice=""; 419 else if (vars.commandIn("FIND_INVOICE")) strPO=""; 420 if (strPO.equals("") && strInvoice.equals("")) { 421 String [] discard = {"sectionDetail"}; 422 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_Shipment", discard).createXmlDocument(); 423 data=CreateFromShipmentData.set(); 424 } else { 425 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_Shipment").createXmlDocument(); 426 if (strInvoice.equals("")) { 427 if (vars.getLanguage().equals("en_US")) { 428 if (isSOTrx.equals("Y")) data=CreateFromShipmentData.selectFromPOSOTrx(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 429 else data=CreateFromShipmentData.selectFromPO(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 430 } else { 431 if (isSOTrx.equals("Y")) data=CreateFromShipmentData.selectFromPOTrlSOTrx(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 432 else data=CreateFromShipmentData.selectFromPOTrl(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strPO); 433 } 434 } else { 435 if (vars.getLanguage().equals("en_US")) { 436 if (isSOTrx.equals("Y")) data = new CreateFromShipmentData[0]; 437 else data=CreateFromShipmentData.selectFromInvoice(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strInvoice); 438 } else { 439 if (isSOTrx.equals("Y")) data = new CreateFromShipmentData[0]; 440 else data=CreateFromShipmentData.selectFromInvoiceTrl(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strInvoice); 441 } 442 } 443 } 444 445 446 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 447 xmlDocument.setParameter("path", strPath); 448 xmlDocument.setParameter("key", strKey); 449 xmlDocument.setParameter("tableId", strTableId); 450 xmlDocument.setParameter("processId", strProcessId); 451 xmlDocument.setParameter("cBpartnerId", strBPartner); 452 xmlDocument.setParameter("BPartnerDescription", CreateFromShipmentData.selectBPartner(this, strBPartner)); 453 xmlDocument.setParameter("PurchaseOrder", strPO); 454 xmlDocument.setParameter("M_Locator_ID", strLocator); 455 xmlDocument.setParameter("M_Locator_ID_DES", CreateFromShipmentData.selectLocator(this, strLocator)); 456 xmlDocument.setParameter("Invoice", strInvoice); 457 xmlDocument.setParameter("pType", (!strInvoice.equals("")?"INVOICE":(!strPO.equals(""))?"PO":"")); 458 xmlDocument.setParameter("windowId", strWindowId); 459 xmlDocument.setParameter("tabName", strTabName); 460 461 if (strBPartner.equals("")) { 462 xmlDocument.setData("reportInvoice", "liststructure", new CreateFromShipmentData[0]); 463 xmlDocument.setData("reportPurchaseOrder", "liststructure", new CreateFromShipmentData[0]); 464 } else { 465 if (isSOTrx.equals("Y")) { 466 xmlDocument.setData("reportInvoice", "liststructure", new CreateFromShipmentData[0]); 467 xmlDocument.setData("reportPurchaseOrder", "liststructure", CreateFromShipmentData.selectFromPOSOTrxCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 468 } else { 469 xmlDocument.setData("reportInvoice", "liststructure", CreateFromShipmentData.selectFromInvoiceCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 470 xmlDocument.setData("reportPurchaseOrder", "liststructure", CreateFromShipmentData.selectFromPOCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 471 } 472 } 473 474 xmlDocument.setData("structure1", data); 475 response.setContentType("text/html; charset=UTF-8"); 476 PrintWriter out = response.getWriter(); 477 out.println(xmlDocument.print()); 478 out.close(); 479 } 480 481 void printPageInvoiceCombo(HttpServletResponse response, VariablesSecureApp vars, String strBPartner, String strWindowId) throws IOException, ServletException { 482 if (log4j.isDebugEnabled()) log4j.debug("Output: Refresh Invoices"); 483 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_F0").createXmlDocument(); 484 String strArray=""; 485 String strArray2 = ""; 486 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 487 488 if (strBPartner.equals("")) { 489 strArray = arrayEntradaSimple("arrDatos", new CreateFromShipmentData[0]); 490 strArray2 = arrayEntradaSimple("arrDatos2", new CreateFromShipmentData[0]); 491 } else { 492 if (vars.commandIn("REFRESH_INVOICES")) { if (isSOTrx.equals("Y")) { 494 strArray = arrayEntradaSimple("arrDatos", new CreateFromShipmentData[0]); 495 strArray2 = arrayEntradaSimple("arrDatos2", CreateFromShipmentData.selectFromPOSOTrxCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 496 } else { 497 strArray = arrayEntradaSimple("arrDatos", CreateFromShipmentData.selectFromInvoiceCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 498 strArray2 = arrayEntradaSimple("arrDatos2", CreateFromShipmentData.selectFromPOCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 499 } 500 } else { if (isSOTrx.equals("Y")) { 502 strArray = arrayEntradaSimple("arrDatos", CreateFromInvoiceData.selectFromShipmentSOTrxCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 503 strArray2 = arrayEntradaSimple("arrDatos2", CreateFromInvoiceData.selectFromPOSOTrxCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 504 } else { 505 strArray = arrayEntradaSimple("arrDatos", CreateFromInvoiceData.selectFromShipmentCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 506 strArray2 = arrayEntradaSimple("arrDatos2", CreateFromInvoiceData.selectFromPOCombo(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strBPartner)); 507 } 508 } 509 } 510 511 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 512 xmlDocument.setParameter("array", strArray + "\n" + strArray2); 513 response.setContentType("text/html; charset=UTF-8"); 514 PrintWriter out = response.getWriter(); 515 out.println(xmlDocument.print()); 516 out.close(); 517 } 518 519 void printPagePay(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strBPartner) throws IOException, ServletException { 520 if (log4j.isDebugEnabled()) log4j.debug("Output: Pay"); 521 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_Pay").createXmlDocument(); 522 523 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 524 response.setContentType("text/html; charset=UTF-8"); 525 PrintWriter out = response.getWriter(); 526 out.println(xmlDocument.print()); 527 out.close(); 528 } 529 530 void printPageSettlement(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strBPartner) throws IOException, ServletException { 531 532 if (log4j.isDebugEnabled()) log4j.debug("Output: Settlement"); 533 if (log4j.isDebugEnabled()) log4j.debug(vars.commandIn("DEFAULT")); 534 535 String strcBPartner = vars.getStringParameter("inpcBpartnerId"); 536 String strPaymentRule = vars.getStringParameter("inppaymentrule"); 537 String strPlannedDateFrom = vars.getStringParameter("inpplanneddateFrom"); 538 String strPlannedDateTo = vars.getStringParameter("inpplanneddateTo"); 539 String strAmountFrom = vars.getStringParameter("inpamountFrom"); 540 String strAmountTo = vars.getStringParameter("inpamountTo"); 541 String strTotalAmount = vars.getStringParameter("inpamount"); 542 String strIsReceipt = vars.getStringParameter("inpisreceipt"); 543 if (log4j.isDebugEnabled()) log4j.debug("IsReceipt: "+strIsReceipt); 544 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 545 String strAutoCalc = vars.getStringParameter("inpAutoClaculated"); 546 String strAutoCalcSelect = "AMOUNT"; 547 548 if (strAutoCalc.equals("")) strAutoCalcSelect = "WRITEOFFAMT"; 549 550 String strOrg = vars.getStringParameter("inpadOrgId"); 551 String strMarcarTodos = vars.getStringParameter("inpTodos", "N"); 552 553 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_Settlement").createXmlDocument(); 554 CreateFromSettlementData[] data = null; 555 556 if(vars.getSessionValue("CreateFrom|default").equals("1")) { 557 558 vars.removeSessionValue("CreateFrom|default"); 559 560 563 564 if (log4j.isDebugEnabled()) log4j.debug("strIsReceipt: \"\""); 566 567 data = new CreateFromSettlementData[0]; 568 569 if (vars.commandIn("FRAME1")) { 570 strcBPartner = strBPartner; 571 strIsReceipt = isSOTrx; 572 } 573 } 574 else { 575 576 if (log4j.isDebugEnabled()) log4j.debug("strIsReceipt: "+ strIsReceipt); 578 579 data = CreateFromSettlementData.select(this, vars.getLanguage(), strMarcarTodos, strAutoCalcSelect, Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strcBPartner, strPaymentRule, strPlannedDateFrom, strPlannedDateTo, strIsReceipt, strAmountFrom, strAmountTo, strTotalAmount, strOrg); 580 } 581 582 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 583 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 584 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 585 xmlDocument.setParameter("path", strPath); 586 xmlDocument.setParameter("key", strKey); 587 xmlDocument.setParameter("tableId", strTableId); 588 xmlDocument.setParameter("processId", strProcessId); 589 xmlDocument.setParameter("windowId", strWindowId); 590 xmlDocument.setParameter("tabName", strTabName); 591 xmlDocument.setParameter("autoCalculated", strAutoCalc); 592 xmlDocument.setParameter("amountFrom", strAmountFrom); 593 xmlDocument.setParameter("amountTo", strAmountTo); 594 xmlDocument.setParameter("totalAmount", strTotalAmount); 595 xmlDocument.setParameter("adOrgId", strOrg); 596 xmlDocument.setParameter("marcarTodos", strMarcarTodos); 597 598 xmlDocument.setParameter("paymentRule", strPaymentRule); 599 600 try { 601 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "All_Payment Rule", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 602 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strPaymentRule); 603 xmlDocument.setData("reportPaymentRule","liststructure", comboTableData.select(false)); 604 comboTableData = null; 605 } catch (Exception ex) { 606 throw new ServletException(ex); 607 } 608 609 try { 610 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "AD_Org_ID", "", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 611 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strOrg); 612 xmlDocument.setData("reportAD_Org_ID","liststructure", comboTableData.select(false)); 613 comboTableData = null; 614 } catch (Exception ex) { 615 throw new ServletException(ex); 616 } 617 618 xmlDocument.setParameter("cbpartnerId", strcBPartner); 619 xmlDocument.setParameter("cbpartnerId_DES", CreateFromSettlementData.bpartner(this, strcBPartner)); 620 xmlDocument.setParameter("plannedDateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 621 xmlDocument.setParameter("plannedDateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 622 xmlDocument.setParameter("plannedDateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 623 xmlDocument.setParameter("plannedDateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 624 xmlDocument.setParameter("isreceiptPago", strIsReceipt); 625 xmlDocument.setParameter("isreceiptCobro", strIsReceipt); 626 { 627 OBError myMessage = vars.getMessage("CreateFrom"); 628 vars.removeMessage("CreateFrom"); 629 if (myMessage!=null) { 630 xmlDocument.setParameter("messageType", myMessage.getType()); 631 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 632 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 633 } 634 } 635 636 xmlDocument.setData("structure1", data); 637 638 response.setContentType("text/html; charset=UTF-8"); 639 PrintWriter out = response.getWriter(); 640 out.println(xmlDocument.print()); 641 out.close(); 642 } 643 644 void printPageDPManagement(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strBPartner) throws IOException, ServletException { 645 if (log4j.isDebugEnabled()) log4j.debug("Output: DPManagement"); 646 String strcBPartner = vars.getStringParameter("inpcBpartnerId"); 647 String strPaymentRule = vars.getStringParameter("inppaymentrule"); 648 String strPlannedDateFrom = vars.getStringParameter("inpplanneddateFrom"); 649 String strPlannedDateTo = vars.getStringParameter("inpplanneddateTo"); 650 String strAmountFrom = vars.getStringParameter("inpamountFrom"); 651 String strAmountTo = vars.getStringParameter("inpamountTo"); 652 String strTotalAmount = vars.getStringParameter("inpamount"); 653 String strIsReceipt = vars.getStringParameter("inpisreceipt"); 654 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 655 String strAutoCalcSelect = "AMOUNT"; 657 659 String strOrg = vars.getStringParameter("inpadOrgId"); 660 String strStatusFrom = vars.getStringParameter("inpStatusFrom"); 661 String strStatusTo = vars.getStringParameter("inpStatusTo"); 662 663 String strMarcarTodos = vars.getStringParameter("inpTodos", "N"); 664 665 666 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_DPManagement").createXmlDocument(); 667 CreateFromDPManagementData[] data = null; 668 if (strcBPartner.equals("") && strPaymentRule.equals("") && strPlannedDateFrom.equals("") && strPlannedDateTo.equals("") && strIsReceipt.equals("") && strTotalAmount.equals("") && strOrg.equals("")) { 669 data = new CreateFromDPManagementData[0]; 670 if (vars.commandIn("FRAME1")) { 671 strcBPartner = strBPartner; 672 strIsReceipt = isSOTrx; 673 } 674 } else { 675 data = CreateFromDPManagementData.select(this, vars.getLanguage(), strMarcarTodos, Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strcBPartner, strPaymentRule, strPlannedDateFrom, strPlannedDateTo, strIsReceipt, strAmountFrom, strAmountTo, strTotalAmount, strStatusFrom, strOrg); 676 677 if (log4j.isDebugEnabled()) log4j.debug("DPSelect: lineas"+data.length+"client "+Utility.getContext(this, vars, "#User_Client", strWindowId)+ "userOrg "+Utility.getContext(this, vars, "#User_Org", strWindowId)+ " partner:"+strcBPartner+" rule:"+strPaymentRule+ "df"+strPlannedDateFrom+" dt:"+strPlannedDateTo+" rec:"+strIsReceipt+"amtF:"+strAmountFrom+"amt T:"+strAmountTo+"ttlamt:"+strTotalAmount+"org "+strOrg); 678 } 679 680 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 681 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 682 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 683 xmlDocument.setParameter("path", strPath); 684 xmlDocument.setParameter("key", strKey); 685 xmlDocument.setParameter("tableId", strTableId); 686 xmlDocument.setParameter("processId", strProcessId); 687 xmlDocument.setParameter("windowId", strWindowId); 688 xmlDocument.setParameter("tabName", strTabName); 689 xmlDocument.setParameter("amountFrom", strAmountFrom); 691 xmlDocument.setParameter("amountTo", strAmountTo); 692 xmlDocument.setParameter("totalAmount", strTotalAmount); 693 xmlDocument.setParameter("adOrgId", strOrg); 694 xmlDocument.setParameter("statusTo", strStatusTo); 695 xmlDocument.setParameter("statusFrom", strStatusFrom); 696 697 xmlDocument.setParameter("marcarTodos", strMarcarTodos); 698 699 xmlDocument.setParameter("paymentRule", strPaymentRule); 700 701 try { 702 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "All_Payment Rule", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 703 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strPaymentRule); 704 xmlDocument.setData("reportPaymentRule","liststructure", comboTableData.select(false)); 705 comboTableData = null; 706 } catch (Exception ex) { 707 throw new ServletException(ex); 708 } 709 710 try { 711 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "AD_Org_ID", "", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 712 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strOrg); 713 xmlDocument.setData("reportAD_Org_ID","liststructure", comboTableData.select(false)); 714 comboTableData = null; 715 } catch (Exception ex) { 716 throw new ServletException(ex); 717 } 718 719 try { 720 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "C_DP_Management_Status", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 721 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strStatusFrom); 722 xmlDocument.setData("reportStatusFrom","liststructure", comboTableData.select(false)); 723 comboTableData = null; 724 } catch (Exception ex) { 725 throw new ServletException(ex); 726 } 727 728 try { 729 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "C_DP_Management_Status", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 730 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strStatusFrom); 731 xmlDocument.setData("reportStatusTo","liststructure", comboTableData.select(false)); 732 comboTableData = null; 733 } catch (Exception ex) { 734 throw new ServletException(ex); 735 } 736 737 xmlDocument.setParameter("cbpartnerId", strcBPartner); 738 xmlDocument.setParameter("cbpartnerId_DES", CreateFromDPManagementData.bpartner(this, strcBPartner)); 739 xmlDocument.setParameter("plannedDateFrom", strPlannedDateFrom); 740 xmlDocument.setParameter("plannedDateTo", strPlannedDateTo); 741 xmlDocument.setParameter("isreceiptPago", strIsReceipt); 742 xmlDocument.setParameter("isreceiptCobro", strIsReceipt); 743 744 745 xmlDocument.setData("structure1", data); 746 747 response.setContentType("text/html; charset=UTF-8"); 748 PrintWriter out = response.getWriter(); 749 out.println(xmlDocument.print()); 750 out.close(); 751 } 752 753 void printPageCRemittance(HttpServletResponse response, VariablesSecureApp vars, String strPath, String strKey, String strTableId, String strProcessId, String strWindowId, String strTabName, String strBPartner, String stradOrgId, String isReceipt) throws IOException, ServletException { 754 if (log4j.isDebugEnabled()) log4j.debug("Output: CRemittance"); 755 String strcBPartner = vars.getStringParameter("inpcBpartnerId"); 756 String strPaymentRule = vars.getStringParameter("inppaymentrule"); 757 String strPlannedDateFrom = vars.getStringParameter("inpplanneddateFrom"); 758 String strPlannedDateTo = vars.getStringParameter("inpplanneddateTo"); 759 String strAmountFrom = vars.getStringParameter("inpamountFrom"); 760 String strAmountTo = vars.getStringParameter("inpamountTo"); 761 String strTotalAmount = vars.getStringParameter("inpamount"); 762 String strIsReceipt = vars.getStringParameter("inpisreceipt", isReceipt); 763 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 764 String strAutoCalcSelect = "AMOUNT"; 766 768 String strOrg = vars.getStringParameter("inpadOrgId", stradOrgId); 769 String strStatusFrom = vars.getStringParameter("inpStatusFrom"); 770 772 String strMarcarTodos = vars.getStringParameter("inpTodos", "N"); 773 String strTreeOrg = ReportTrialBalanceData.treeOrg(this, vars.getClient()); 774 String strOrgFamily = Tree.getMembers(this, strTreeOrg, strOrg); 775 776 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFrom_CRemittance").createXmlDocument(); 777 CreateFromCRemittanceData[] data = null; 779 if (vars.commandIn("FRAME1")) { 780 data = new CreateFromCRemittanceData[0]; 781 strcBPartner = strBPartner; 782 strIsReceipt = isSOTrx; 783 } else { 784 data = CreateFromCRemittanceData.select(this, vars.getLanguage(), strMarcarTodos, Utility.getContext(this, vars, "#User_Client", strWindowId), Utility.getContext(this, vars, "#User_Org", strWindowId), strOrgFamily, strcBPartner, strPaymentRule, strPlannedDateFrom, strPlannedDateTo, strIsReceipt, strAmountFrom, strAmountTo, strTotalAmount,strStatusFrom); 785 } 786 787 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 788 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 789 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 790 xmlDocument.setParameter("path", strPath); 791 xmlDocument.setParameter("key", strKey); 792 xmlDocument.setParameter("tableId", strTableId); 793 xmlDocument.setParameter("processId", strProcessId); 794 xmlDocument.setParameter("windowId", strWindowId); 795 xmlDocument.setParameter("tabName", strTabName); 796 xmlDocument.setParameter("amountFrom", strAmountFrom); 798 xmlDocument.setParameter("amountTo", strAmountTo); 799 xmlDocument.setParameter("totalAmount", strTotalAmount); 800 xmlDocument.setParameter("statusFrom", strStatusFrom); 802 803 xmlDocument.setParameter("marcarTodos", strMarcarTodos); 804 805 xmlDocument.setParameter("paymentRule", strPaymentRule); 806 807 xmlDocument.setParameter("plannedDateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 808 xmlDocument.setParameter("plannedDateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 809 810 xmlDocument.setParameter("plannedDateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 811 xmlDocument.setParameter("plannedDateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 812 813 try { 814 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "All_Payment Rule", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 815 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strPaymentRule); 816 xmlDocument.setData("reportPaymentRule","liststructure", comboTableData.select(false)); 817 comboTableData = null; 818 } catch (Exception ex) { 819 throw new ServletException(ex); 820 } 821 822 try { 823 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "AD_Org_ID", "", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 824 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strOrg); 825 xmlDocument.setData("reportAD_Org_ID","liststructure", comboTableData.select(false)); 826 comboTableData = null; 827 } catch (Exception ex) { 828 throw new ServletException(ex); 829 } 830 831 try { 832 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "C_DP_Management_Status", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 833 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, strStatusFrom); 834 xmlDocument.setData("reportStatusFrom","liststructure", comboTableData.select(false)); 835 comboTableData = null; 836 } catch (Exception ex) { 837 throw new ServletException(ex); 838 } 839 840 xmlDocument.setParameter("cbpartnerId", strcBPartner); 841 xmlDocument.setParameter("cbpartnerId_DES", CreateFromDPManagementData.bpartner(this, strcBPartner)); 842 xmlDocument.setParameter("plannedDateFrom", strPlannedDateFrom); 843 xmlDocument.setParameter("plannedDateTo", strPlannedDateTo); 844 xmlDocument.setParameter("isreceiptPago", strIsReceipt); 845 xmlDocument.setParameter("isreceiptCobro", strIsReceipt); 846 xmlDocument.setParameter("adOrgId", strOrg); 847 848 xmlDocument.setData("structure1", data); 849 850 response.setContentType("text/html; charset=UTF-8"); 851 PrintWriter out = response.getWriter(); 852 out.println(xmlDocument.print()); 853 out.close(); 854 } 855 856 String saveMethod(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId, String strWindowId) throws IOException, ServletException { 857 if (strTableId.equals("392")) return saveBank(vars, strKey, strTableId, strProcessId); 858 else if (strTableId.equals("318")) return saveInvoice(vars, strKey, strTableId, strProcessId, strWindowId); 859 else if (strTableId.equals("319")) return saveShipment(vars, strKey, strTableId, strProcessId, strWindowId); 860 else if (strTableId.equals("426")) return savePay(vars, strKey, strTableId, strProcessId); 861 else if (strTableId.equals("800019")) return saveSettlement(vars, strKey, strTableId, strProcessId); 862 else if (strTableId.equals("800176")) return saveDPManagement(vars, strKey, strTableId, strProcessId); 863 else if (strTableId.equals("800179")) return saveCRemittance(vars, strKey, strTableId, strProcessId); 864 else return ""; 865 } 866 867 String saveBank(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId) throws IOException, ServletException { 868 if (log4j.isDebugEnabled()) log4j.debug("Save: Bank"); 869 String strPayment = vars.getInStringParameter("inpcPaymentId"); 870 String strStatementDate = vars.getStringParameter("inpstatementdate"); 871 String strDateplanned = ""; 872 String strChargeamt = ""; 873 if (strPayment.equals("")) return ""; 874 Connection conn = null; 875 try { 876 conn = this.getTransactionConnection(); 877 if (strPayment.startsWith("(")) strPayment = strPayment.substring(1, strPayment.length()-1); 878 if (!strPayment.equals("")) { 879 strPayment = Replace.replace(strPayment, "'", ""); 880 StringTokenizer st = new StringTokenizer(strPayment, ",", false); 881 while (st.hasMoreTokens()) { 882 String strDebtPaymentId = st.nextToken(); 883 if (!CreateFromBankData.NotIsReconcilied(conn, this, strDebtPaymentId)) { 884 releaseRollbackConnection(conn); 885 log4j.warn("CreateFrom.saveBank - debt_payment " + strDebtPaymentId + " is reconcilied"); 886 return Utility.messageBD(this, "DebtPaymentReconcilied", vars.getLanguage()); 887 } 888 strDateplanned = vars.getStringParameter("inpplanneddate" + strDebtPaymentId.trim()); 889 strChargeamt = vars.getStringParameter("inpcost" + strDebtPaymentId.trim()); 890 String strSequence = SequenceIdData.getSequence(this, "C_BankStatementLine", vars.getClient()); 891 CreateFromBankData.insert(conn, this, strSequence, vars.getClient(), vars.getUser(), strKey, strDateplanned.equals("")?strStatementDate:strDateplanned, strChargeamt, strDebtPaymentId); 892 } 893 } 894 releaseCommitConnection(conn); 895 } catch (Exception e) { 896 try { 897 releaseRollbackConnection(conn); 898 } catch (Exception ignored) {} 899 e.printStackTrace(); 900 log4j.warn("Rollback in transaction"); 901 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 902 } 903 return Utility.messageBD(this, "Success", vars.getLanguage()); 904 } 905 906 String saveInvoice(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId, String strWindowId) throws IOException, ServletException { 907 if (log4j.isDebugEnabled()) log4j.debug("Save: Invoice"); 908 String strDateInvoiced = vars.getRequiredStringParameter("inpDateInvoiced"); 909 String strMWarehouse = vars.getWarehouse(); 910 String strBPartnerLocation = vars.getRequiredStringParameter("inpcBpartnerLocationId"); 911 String strBPartner = vars.getRequiredStringParameter("inpcBpartnerId"); 912 String strPriceList = vars.getRequiredStringParameter("inpMPricelist"); 913 String strType = vars.getRequiredStringParameter("inpType"); 914 String strClaves = vars.getRequiredInParameter("inpcOrderId"); 915 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 916 String strShipment="", strPO="", priceActual="0", priceLimit="0", priceList="0", strPriceListVersion="", priceStd="0", offerId=""; 917 CreateFromInvoiceData[] data=null; 918 919 Connection conn = null; 920 try { 921 conn = this.getTransactionConnection(); 922 if (strType.equals("SHIPMENT")) { 923 strShipment = vars.getStringParameter("inpShipmentReciept"); 924 if (isSOTrx.equals("Y")) data = CreateFromInvoiceData.selectFromShipmentUpdateSOTrx(conn, this, strClaves); 925 else data = CreateFromInvoiceData.selectFromShipmentUpdate(conn, this, strClaves); 926 CreateFromInvoiceData[] dataAux = CreateFromInvoiceData.selectPriceList(conn, this, strDateInvoiced, strPriceList); 927 if (dataAux==null || dataAux.length==0) return Utility.messageBD(this, "PriceListVersionNotFound", vars.getLanguage()); 928 strPriceListVersion = dataAux[0].id; 929 } else { 930 strPO = vars.getStringParameter("inpPurchaseOrder"); 931 if (isSOTrx.equals("Y")) data = CreateFromInvoiceData.selectFromPOUpdateSOTrx(conn, this, strClaves); 932 else data = CreateFromInvoiceData.selectFromPOUpdate(conn, this, strClaves); 933 } 934 if (data!=null) { 935 for (int i=0;i<data.length;i++) { 936 String strSequence = SequenceIdData.getSequence(this, "C_InvoiceLine", vars.getClient()); 937 CreateFromInvoiceData[] price = null; 938 String C_Tax_ID=""; 939 if (data[i].cOrderlineId.equals("")) C_Tax_ID = Tax.get (this, data[i].mProductId, strDateInvoiced, data[i].adOrgId, vars.getWarehouse(), strBPartnerLocation, strBPartnerLocation, CreateFromInvoiceData.selectProject(this, strKey), isSOTrx.equals("Y")?true:false); 940 else C_Tax_ID = CreateFromInvoiceData.getTax(this, data[i].cOrderlineId); 941 942 int stdPrecision = Integer.valueOf(data[i].stdprecision).intValue(); 943 if (!data[i].cOrderlineId.equals("")) { 944 price = CreateFromInvoiceData.selectPrices(conn, this, data[i].cOrderlineId); 945 if (price!=null && price.length>0) { 946 priceList = price[0].pricelist; 947 priceActual = price[0].priceactual; 948 priceLimit = price[0].pricelimit; 949 priceStd = price[0].pricestd; 950 offerId = price[0].mOfferId; 951 } 952 price=null; 953 } else { 954 price = CreateFromInvoiceData.selectBOM(conn, this, strDateInvoiced, strBPartner, data[i].mProductId, strPriceListVersion); 955 if (price!=null && price.length>0) { 956 priceList = price[0].pricelist; 957 priceActual = price[0].priceactual; 958 priceLimit = price[0].pricelimit; 959 priceStd = price[0].pricestd; 960 offerId = price[0].mOfferId; 961 } 962 price=null; 963 } 964 BigDecimal LineNetAmt = (new BigDecimal (priceActual)).multiply(new BigDecimal (data[i].id)); 965 LineNetAmt.setScale(stdPrecision, BigDecimal.ROUND_HALF_UP); 966 CreateFromInvoiceData.insert(conn, this, strSequence, strKey, vars.getClient(), data[i].adOrgId, vars.getUser(), data[i].cOrderlineId, data[i].mInoutlineId, data[i].description, data[i].mProductId, data[i].cUomId, data[i].id, priceList, priceActual, priceLimit, LineNetAmt.toString(), C_Tax_ID, data[i].quantityorder, data[i].mProductUomId, data[i].mAttributesetinstanceId, priceStd); 967 } 968 } 969 970 if (!strPO.equals("")) { 971 int total = CreateFromInvoiceData.deleteC_Order_ID(conn, this, strKey, strPO); 972 if (total==0) CreateFromInvoiceData.updateC_Order_ID(conn, this, strPO, strKey); 973 } 974 975 releaseCommitConnection(conn); 976 if (log4j.isDebugEnabled()) log4j.debug("Save commit"); 977 } catch(Exception e){ 978 try { 979 releaseRollbackConnection(conn); 980 } catch (Exception ignored) {} 981 e.printStackTrace(); 982 log4j.warn("Rollback in transaction"); 983 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 984 } 985 return Utility.messageBD(this, "Success", vars.getLanguage()); 986 } 987 988 String saveShipment(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId, String strWindowId) throws IOException, ServletException { 989 if (log4j.isDebugEnabled()) log4j.debug("Save: Shipment"); 990 String strLocator = vars.getRequiredStringParameter("inpmLocatorId"); 991 String strType = vars.getRequiredStringParameter("inpType"); 992 String strClaves = vars.getRequiredInParameter("inpId"); 993 String isSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 994 String strInvoice="", strPO=""; 995 CreateFromShipmentData[] data=null; 996 997 Connection conn = null; 998 try { 999 conn = this.getTransactionConnection(); 1000 if (strType.equals("INVOICE")) { 1001 strInvoice = vars.getStringParameter("inpInvoice"); 1002 if (!isSOTrx.equals("Y")) data = CreateFromShipmentData.selectFromInvoiceUpdate(conn, this, strClaves); 1003 } else { 1004 strPO = vars.getStringParameter("inpPurchaseOrder"); 1005 if (isSOTrx.equals("Y")) data = CreateFromShipmentData.selectFromPOUpdateSOTrx(conn, this, strClaves); 1006 else data = CreateFromShipmentData.selectFromPOUpdate(conn, this, strClaves); 1007 } 1008 if (data!=null) { 1009 for (int i=0;i<data.length;i++) { 1010 String strMultiplyRate=""; 1011 int stdPrecision =0; 1012 if (data[i].breakdown.equals("Y")) { 1013 if (data[i].cUomIdConversion.equals("")) { 1014 releaseRollbackConnection(conn); 1015 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 1016 } 1017 String strInitUOM = data[i].cUomIdConversion; 1018 String strUOM = data[i].cUomId; 1019 if (strInitUOM.equals(strUOM)) strMultiplyRate = "1"; 1020 else strMultiplyRate = CreateFromShipmentData.multiplyRate (this, strInitUOM, strUOM); 1021 if (strMultiplyRate.equals("")) strMultiplyRate = CreateFromShipmentData.divideRate (this, strUOM, strInitUOM); 1022 if (strMultiplyRate.equals("")) { 1023 strMultiplyRate = "1"; 1024 releaseRollbackConnection(conn); 1025 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 1026 } 1027 stdPrecision = Integer.valueOf(data[i].stdprecision).intValue(); 1028 BigDecimal quantity, qty, multiplyRate; 1029 1030 multiplyRate = new BigDecimal (strMultiplyRate); 1031 qty = new BigDecimal (data[i].id); 1032 boolean qtyIsNegative = false; 1033 if (qty.doubleValue() < ZERO.doubleValue()) { 1034 qtyIsNegative = true; 1035 qty = new BigDecimal (-1.0 * qty.doubleValue()); 1036 } 1037 quantity = new BigDecimal (multiplyRate.doubleValue() * qty.doubleValue()); 1038 if (quantity.scale() > stdPrecision) quantity = quantity.setScale(stdPrecision, BigDecimal.ROUND_HALF_UP); 1039 while (qty.doubleValue()>ZERO.doubleValue()) { 1040 String total = "1"; 1041 BigDecimal conversion; 1042 if (quantity.doubleValue()<1.0) { 1043 total=quantity.toString(); 1044 conversion = qty; 1045 quantity=ZERO; 1046 qty=ZERO; 1047 } else { 1048 conversion = new BigDecimal (1.0 * multiplyRate.doubleValue()); 1049 if (conversion.doubleValue()>qty.doubleValue()) { 1050 conversion=qty; 1051 qty=ZERO; 1052 } else qty = new BigDecimal (qty.doubleValue() - conversion.doubleValue()); 1053 quantity = new BigDecimal (quantity.doubleValue() - 1.0); 1054 } 1055 String strConversion = conversion.toString(); 1056 String strSequence = SequenceIdData.getSequence(this, "M_InOutLine", vars.getClient()); 1057 CreateFromShipmentData.insert(conn, this, strSequence, strKey, vars.getClient(), data[i].adOrgId, vars.getUser(), data[i].mProductId, data[i].cUomId, (qtyIsNegative?"-"+strConversion:strConversion), data[i].cOrderlineId, strLocator, CreateFromShipmentData.isInvoiced(conn, this, data[i].cInvoicelineId), (qtyIsNegative?"-"+total:total), data[i].mProductUomId, data[i].mAttributesetinstanceId); 1058 if (!strInvoice.equals("")) CreateFromShipmentData.updateInvoice(conn, this, strSequence, data[i].cInvoicelineId); 1059 else CreateFromShipmentData.updateInvoiceOrder(conn, this, strSequence, data[i].cOrderlineId); 1060 } 1061 } else { 1062 String strSequence = SequenceIdData.getSequence(this, "M_InOutLine", vars.getClient()); 1063 CreateFromShipmentData.insert(conn, this, strSequence, strKey, vars.getClient(), data[i].adOrgId, vars.getUser(), data[i].mProductId, data[i].cUomId, data[i].id, data[i].cOrderlineId, strLocator, CreateFromShipmentData.isInvoiced(conn, this, data[i].cInvoicelineId), data[i].quantityorder, data[i].mProductUomId, data[i].mAttributesetinstanceId); 1064 if (!strInvoice.equals("")) CreateFromShipmentData.updateInvoice(conn, this, strSequence, data[i].cInvoicelineId); 1065 else CreateFromShipmentData.updateInvoiceOrder(conn, this, strSequence, data[i].cOrderlineId); 1066 } 1067 } 1068 } 1069 1070 if (!strPO.equals("")) { 1071 int total = CreateFromShipmentData.deleteC_Order_ID(conn, this, strKey, strPO); 1072 if (total==0) CreateFromShipmentData.updateC_Order_ID(conn, this, strPO, strKey); 1073 } 1074 if (!strInvoice.equals("")) { 1075 int total = CreateFromShipmentData.deleteC_Invoice_ID(conn, this, strKey, strInvoice); 1076 if (total==0) CreateFromShipmentData.updateC_Invoice_ID(conn, this, strInvoice, strKey); 1077 } 1078 1079 releaseCommitConnection(conn); 1080 if (log4j.isDebugEnabled()) log4j.debug("Save commit"); 1081 } catch(Exception e){ 1082 try { 1083 releaseRollbackConnection(conn); 1084 } catch (Exception ignored) {} 1085 e.printStackTrace(); 1086 log4j.warn("Rollback in transaction"); 1087 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 1088 } 1089 return Utility.messageBD(this, "Success", vars.getLanguage()); 1090 } 1091 1092 String savePay(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId) throws IOException, ServletException { 1093 if (log4j.isDebugEnabled()) log4j.debug("Save: Pay"); 1094 return ""; 1095 } 1096 1097 String saveSettlement(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId) throws IOException, ServletException { 1098 if (log4j.isDebugEnabled()) log4j.debug("Save: Settlement"); 1099 String strDebtPayment = vars.getInStringParameter("inpcDebtPaymentId"); 1100 if (strDebtPayment.equals("")) return ""; 1101 Connection conn = null; 1102 try { 1103 conn = this.getTransactionConnection(); 1104 if (strDebtPayment.startsWith("(")) strDebtPayment = strDebtPayment.substring(1, strDebtPayment.length()-1); 1105 if (!strDebtPayment.equals("")) { 1106 strDebtPayment = Replace.replace(strDebtPayment, "'", ""); 1107 StringTokenizer st = new StringTokenizer(strDebtPayment, ",", false); 1108 while (st.hasMoreTokens()) { 1109 String strDebtPaymentId = st.nextToken().trim(); 1110 String strWriteOff = vars.getStringParameter("inpwriteoff" + strDebtPaymentId); 1111 String strIsPaid = vars.getStringParameter("inpispaid" + strDebtPaymentId, "N"); 1112 if (!CreateFromSettlementData.NotIsCancelled(conn, this, strDebtPaymentId)) { 1113 releaseRollbackConnection(conn); 1114 log4j.warn("CreateFrom.saveSettlement - debt_payment " + strDebtPaymentId + " is cancelled"); 1115 return Utility.messageBD(this, "DebtPaymentCancelled", vars.getLanguage()); 1116 } 1117 CreateFromSettlementData.update(conn, this, vars.getUser(), strKey, strWriteOff, strIsPaid, strDebtPaymentId); 1118 } 1119 } 1120 releaseCommitConnection(conn); 1121 } catch (Exception e) { 1122 try { 1123 releaseRollbackConnection(conn); 1124 } catch (Exception ignored) {} 1125 e.printStackTrace(); 1126 log4j.warn("Rollback in transaction"); 1127 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 1128 } 1129 return Utility.messageBD(this, "Success", vars.getLanguage()); 1130 } 1131 1132 String saveDPManagement(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId) throws IOException, ServletException { 1133 if (log4j.isDebugEnabled()) log4j.debug("Save: DPManagement"); 1134 String strDebtPayment = vars.getInStringParameter("inpcDebtPaymentId"); 1135 if (strDebtPayment.equals("")) return ""; 1136 Connection conn = null; 1137 try { 1138 conn = this.getTransactionConnection(); 1139 String strStatusTo = vars.getStringParameter("inpStatusTo"); 1140 if (strDebtPayment.startsWith("(")) strDebtPayment = strDebtPayment.substring(1, strDebtPayment.length()-1); 1141 if (!strDebtPayment.equals("")) { 1142 strDebtPayment = Replace.replace(strDebtPayment, "'", ""); 1143 Integer line = new Integer (CreateFromDPManagementData.getLine(this, strKey)); 1144 StringTokenizer st = new StringTokenizer(strDebtPayment, ",", false); 1145 while (st.hasMoreTokens()) { 1146 String strDebtPaymentId = st.nextToken().trim(); 1147 if (!CreateFromDPManagementData.NotIsCancelled(conn, this, strDebtPaymentId)) { 1148 releaseRollbackConnection(conn); 1149 log4j.warn("CreateFrom.saveSettlement - debt_payment " + strDebtPaymentId + " is cancelled"); 1150 return Utility.messageBD(this, "DebtPaymentCancelled", vars.getLanguage()); 1151 } 1152 String strDPManagementLineID = SequenceIdData.getSequence(this, "C_DP_ManagementLine", vars.getClient()); 1153 1154 line += 10; 1155 CreateFromDPManagementData.insert(conn, this, strDPManagementLineID, vars.getClient(), vars.getUser(), strKey, strStatusTo, line.toString(), strDebtPaymentId); 1156 1157 } 1158 } 1159 releaseCommitConnection(conn); 1160 } catch (Exception e) { 1161 try { 1162 releaseRollbackConnection(conn); 1163 } catch (Exception ignored) {} 1164 e.printStackTrace(); 1165 log4j.warn("Rollback in transaction"); 1166 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 1167 } 1168 return Utility.messageBD(this, "Success", vars.getLanguage()); 1169 } 1170 1171 1172 String saveCRemittance(VariablesSecureApp vars, String strKey, String strTableId, String strProcessId) throws IOException, ServletException { 1173 if (log4j.isDebugEnabled()) log4j.debug("Save: Cremittance"); 1174 String strDebtPayment = vars.getInStringParameter("inpcDebtPaymentId"); 1175 if (strDebtPayment.equals("")) return ""; 1176 Connection conn = null; 1177 try { 1178 conn = this.getTransactionConnection(); 1179 Integer lineNo = Integer.valueOf(CreateFromCRemittanceData.selectLineNo(this, strKey)).intValue(); 1180 if (strDebtPayment.startsWith("(")) strDebtPayment = strDebtPayment.substring(1, strDebtPayment.length()-1); 1182 if (!strDebtPayment.equals("")) { 1183 strDebtPayment = Replace.replace(strDebtPayment, "'", ""); 1184 StringTokenizer st = new StringTokenizer(strDebtPayment, ",", false); 1185 while (st.hasMoreTokens()) { 1186 String strDebtPaymentId = st.nextToken().trim(); 1187 1188 if (!CreateFromDPManagementData.NotIsCancelled(conn, this, strDebtPaymentId)) { 1189 releaseRollbackConnection(conn); 1190 log4j.warn("CreateFrom.saveSettlement - debt_payment " + strDebtPaymentId + " is cancelled"); 1191 return Utility.messageBD(this, "DebtPaymentCancelled", vars.getLanguage()); 1192 } 1193 String strCRemittanceLineID = SequenceIdData.getSequence(this, "C_RemittanceLine", vars.getClient()); 1194 lineNo += 10; 1195 CreateFromCRemittanceData.insert(conn, this, strCRemittanceLineID, vars.getClient(), vars.getUser(), strKey, lineNo.toString(),strDebtPaymentId); 1196 1197 } 1198 } 1199 releaseCommitConnection(conn); 1200 } catch (Exception e) { 1201 try { 1202 releaseRollbackConnection(conn); 1203 } catch (Exception ignored) {} 1204 e.printStackTrace(); 1205 log4j.warn("Rollback in transaction"); 1206 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 1207 } 1208 return Utility.messageBD(this, "Success", vars.getLanguage()); 1209 } 1210 1211 1212 1213 public String getServletInfo() { 1214 return "Servlet that presents the button of CreateFrom"; 1215 } } 1217 | Popular Tags |