1 19 package org.openbravo.erpCommon.ad_callouts; 20 21 import org.openbravo.base.secureApp.HttpSecureAppServlet; 22 import org.openbravo.base.secureApp.VariablesSecureApp; 23 import org.openbravo.xmlEngine.XmlDocument; 24 import org.openbravo.erpCommon.utility.Utility; 25 import java.io.*; 26 import javax.servlet.*; 27 import javax.servlet.http.*; 28 29 import org.openbravo.erpCommon.businessUtility.Tax; 30 31 public class SL_Invoice_Charge_Tax extends HttpSecureAppServlet { 32 33 34 public void init (ServletConfig config) { 35 super.init(config); 36 boolHist = false; 37 } 38 39 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 40 VariablesSecureApp vars = new VariablesSecureApp(request); 41 if (vars.commandIn("DEFAULT")) { 42 String strChanged = vars.getStringParameter("inpLastFieldChanged"); 43 if (log4j.isDebugEnabled()) log4j.debug("CHANGED: " + strChanged); 44 String strMProductID = vars.getStringParameter("inpmProductId"); 45 String strADOrgID = vars.getStringParameter("inpadOrgId"); 46 String strCInvoiceID = vars.getStringParameter("inpcInvoiceId"); 47 String strWindowId = vars.getStringParameter("inpwindowId"); 48 String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 49 String strWharehouse = Utility.getContext(this, vars, "#M_Warehouse_ID", strWindowId); 50 String strCChargeID = vars.getStringParameter("inpcChargeId"); 51 String strTabId = vars.getStringParameter("inpTabId"); 52 53 try { 54 printPage(response, vars, strMProductID, strADOrgID, strCInvoiceID, strIsSOTrx, strWharehouse, strCChargeID, strTabId); 55 } catch (ServletException ex) { 56 pageErrorCallOut(response); 57 } 58 } else pageError(response); 59 } 60 61 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strMProductID, String strADOrgID, String strCInvoiceID, String strIsSOTrx, String strWharehouse, String strCChargeID, String strTabId) throws IOException, ServletException { 62 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 63 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 64 65 String chargeAmt; 66 if (strCChargeID.equals("")) chargeAmt = ""; 67 else chargeAmt = SLChargeData.chargeAmt(this, strCChargeID); 68 69 StringBuffer resultado = new StringBuffer (); 70 resultado.append("var calloutName='SL_Invoice_Charge_Tax';\n\n"); 71 resultado.append("var respuesta = new Array("); 72 73 SLInvoiceTaxData [] data = SLInvoiceTaxData.select(this, strCInvoiceID); 74 75 String strCTaxID = Tax.get(this, strMProductID, data[0].dateinvoiced, strADOrgID, strWharehouse, data[0].cBpartnerLocationId, data[0].cBpartnerLocationId, data[0].cProjectId, strIsSOTrx.equals("Y")); 76 77 resultado.append("new Array(\"inpcTaxId\", \"" + strCTaxID + "\"),"); 78 resultado.append("new Array(\"inpchargeamt\", \"" + chargeAmt + "\")\n"); 79 80 resultado.append(");"); 81 xmlDocument.setParameter("array", resultado.toString()); 82 xmlDocument.setParameter("frameName", "frameAplicacion"); 83 response.setContentType("text/html; charset=UTF-8"); 84 PrintWriter out = response.getWriter(); 85 out.println(xmlDocument.print()); 86 out.close(); 87 } 88 } 89 | Popular Tags |