KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_actionButton > CreateRegFactAcct


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19 package org.openbravo.erpCommon.ad_actionButton;
20
21 import org.openbravo.erpCommon.utility.*;
22 import org.openbravo.exception.*;
23 import org.openbravo.utils.FormatUtilities;
24 import org.openbravo.base.secureApp.HttpSecureAppServlet;
25 import org.openbravo.base.secureApp.VariablesSecureApp;
26 import org.openbravo.xmlEngine.XmlDocument;
27 import java.io.*;
28 import java.math.*;
29 import javax.servlet.*;
30 import javax.servlet.http.*;
31 import java.sql.*;
32
33
34 // imports for transactions
35
import java.sql.Connection JavaDoc;
36
37 public class CreateRegFactAcct extends HttpSecureAppServlet {
38   
39
40   BigDecimal ExpenseAmtDr = new BigDecimal("0");
41   BigDecimal ExpenseAmtCr = new BigDecimal("0");
42   BigDecimal RevenueAmtDr = new BigDecimal("0");
43   BigDecimal RevenueAmtCr = new BigDecimal("0");
44
45   public void init (ServletConfig config) {
46     super.init(config);
47     boolHist = false;
48   }
49
50   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
51     VariablesSecureApp vars = new VariablesSecureApp(request);
52
53     if (vars.commandIn("DEFAULT")) {
54       String JavaDoc strProcessId = vars.getStringParameter("inpProcessId");
55       String JavaDoc strWindow = vars.getStringParameter("inpwindowId");
56       String JavaDoc strTab = vars.getStringParameter("inpTabId");
57       String JavaDoc strPediodId = vars.getStringParameter("inpcPeriodId", "");
58       String JavaDoc strKey = vars.getRequiredGlobalVariable("inpcYearId", strWindow + "|C_Year_ID");
59       String JavaDoc strClose = vars.getGlobalVariable("inpClose", "CreateRegFactAcct|Close", "N");
60       printPage(response, vars, strKey, strPediodId, strWindow, strTab, strProcessId, strClose);
61     } else if (vars.commandIn("SAVE")) {
62       String JavaDoc strWindow = vars.getStringParameter("inpwindowId");
63       String JavaDoc strPediodId = vars.getStringParameter("inpcPeriodId", "");
64       String JavaDoc strKey = vars.getRequiredGlobalVariable("inpcYearId", strWindow + "|C_Year_ID");
65       String JavaDoc strTab = vars.getStringParameter("inpTabId");
66       String JavaDoc strClose = vars.getRequestGlobalVariable("inpClose", "CreateRegFactAcct|Close");
67       ActionButtonDefaultData[] tab = ActionButtonDefaultData.windowName(this, strTab);
68       String JavaDoc strWindowPath="", strTabName="";
69       if (tab!=null && tab.length!=0) {
70         strTabName = FormatUtilities.replace(tab[0].name);
71         if (tab[0].help.equals("Y")) strWindowPath="../utility/WindowTree_FS.html?inpTabId=" + strTab;
72         else strWindowPath = "../" + FormatUtilities.replace(tab[0].description) + "/" + strTabName + "_Relation.html";
73       } else strWindowPath = strDefaultServlet;
74       try {
75         Connection JavaDoc conn = this.getTransactionConnection();
76         String JavaDoc messageResult = processButton(conn, vars, strKey, strPediodId, strWindow, strClose);
77         if (messageResult.equals("ProcessOK")) releaseCommitConnection(conn);
78         else releaseRollbackConnection(conn);
79         messageResult = Utility.messageBD(this, messageResult, vars.getLanguage());
80         vars.setSessionValue(strWindow + "|" + strTabName + ".message", messageResult);
81       } catch (NoConnectionAvailableException ex) {
82         bdErrorConnection(response);
83         return;
84       } catch (SQLException ex2) {
85         OBError myError = Utility.translateError(this, vars, vars.getLanguage(), ex2.toString());
86         if (!myError.isConnectionAvailable()) {
87           bdErrorConnection(response);
88           return;
89         } else vars.setMessage(strTab, myError);
90       }
91       printPageClosePopUp(response, vars, strWindowPath);
92     } else pageErrorPopUp(response);
93   }
94
95   String JavaDoc processButton(Connection JavaDoc conn, VariablesSecureApp vars, String JavaDoc strKey, String JavaDoc strPediodId, String JavaDoc windowId, String JavaDoc strClose) throws ServletException{
96     String JavaDoc strRegId = SequenceIdData.getSequence(this, "Fact_Acct_Group", vars.getClient());
97     String JavaDoc strCloseId = strClose.equals("Y")?SequenceIdData.getSequence(this, "Fact_Acct_Group", vars.getClient()):"";
98     String JavaDoc strOpenId = strClose.equals("Y")?SequenceIdData.getSequence(this, "Fact_Acct_Group", vars.getClient()):"";
99     CreateRegFactAcctData [] data = CreateRegFactAcctData.treeOrg(this, vars.getClient(), "0");
100     String JavaDoc strMessage="";
101     for (int i=0;i<data.length;i++){
102       if (!strClose.equals("Y")){
103         if(!(strMessage=processButtonReg(conn, vars, strKey, strPediodId, windowId, data[i].org, strRegId)).equals("ProcessOK")) {
104           return "";
105         }
106       } else {
107         String JavaDoc strRegOut = processButtonReg(conn, vars, strKey, strPediodId, windowId, data[i].org, strRegId);
108         String JavaDoc strCloseOut = processButtonClose(conn, vars, strKey, strPediodId, windowId, data[i].org, strCloseId, strOpenId);
109         if (!strRegOut.equals("ProcessOK") || !strCloseOut.equals("ProcessOK")) return "";
110       }
111       ExpenseAmtDr = new BigDecimal("0");
112       ExpenseAmtCr = new BigDecimal("0");
113       RevenueAmtDr = new BigDecimal("0");
114       RevenueAmtCr = new BigDecimal("0");
115     }
116     if(CreateRegFactAcctData.updatePeriods(conn, this, strRegId, vars.getUser(), strKey, strPediodId)==0) return "";
117     else if (strClose.equals("Y") && (CreateRegFactAcctData.updatePeriodsClose(conn, this, strCloseId, vars.getUser(), strKey, strPediodId)==0 || CreateRegFactAcctData.updateClose(conn, this, vars.getUser(), strCloseId)==0)) return "";
118     return "ProcessOK";
119   }
120
121   String JavaDoc processButtonReg(Connection JavaDoc conn, VariablesSecureApp vars, String JavaDoc strKey, String JavaDoc strPediodId, String JavaDoc windowId, String JavaDoc stradOrgId, String JavaDoc strID) {
122     try {
123       CreateRegFactAcctData[] expense = CreateRegFactAcctData.getAmounts(this, strKey, strPediodId, "E", stradOrgId);
124       CreateRegFactAcctData[] revenue = CreateRegFactAcctData.getAmounts(this, strKey, strPediodId, "R", stradOrgId);
125       BigDecimal AmtCr, AmtDr;
126       String JavaDoc strAcctSchema = Utility.getContext(this, vars, "$C_ACCTSCHEMA_ID", windowId);;
127       String JavaDoc Fact_Acct_ID = "";
128       String JavaDoc Fact_Acct_Group_ID = strID;
129       if(CreateRegFactAcctData.getNextPeriod(this, strPediodId).equals("")) return "ProcessRunError1";
130       //Fact_Acct_Group_ID = SequenceIdData.getSequence(this, "Fact_Acct_Group", vars.getClient());
131
int i;
132       for (i=0;i<expense.length;i++){
133         ExpenseAmtDr = ExpenseAmtDr.add(new BigDecimal(expense[i].totalamtdr));
134         ExpenseAmtCr = ExpenseAmtCr.add(new BigDecimal(expense[i].totalamtcr));
135         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
136         if(!expense[i].totalamtdr.equals("0") || !expense[i].totalamtcr.equals("0")) CreateRegFactAcctData.insert(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, expense[i].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),expense[i].totalamtdr,expense[i].totalamtcr,expense[i].totalamtdr,expense[i].totalamtcr , Fact_Acct_Group_ID, Integer.toString((i+3)*10),expense[i].acctdescription,expense[i].acctvalue, expense[i].cBpartnerId, expense[i].recordId2, expense[i].mProductId, expense[i].aAssetId);
137       }
138       for (int j=0;j<revenue.length;j++){
139         RevenueAmtDr = RevenueAmtDr.add(new BigDecimal(revenue[j].totalamtdr));
140         RevenueAmtCr = RevenueAmtCr.add(new BigDecimal(revenue[j].totalamtcr));
141         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
142         if(!revenue[j].totalamtdr.equals("0") || !revenue[j].totalamtcr.equals("0"))CreateRegFactAcctData.insert(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, revenue[j].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),revenue[j].totalamtdr,revenue[j].totalamtcr,revenue[j].totalamtdr,revenue[j].totalamtcr , Fact_Acct_Group_ID, Integer.toString((i+j+3)*10),revenue[j].acctdescription,revenue[j].acctvalue, revenue[j].cBpartnerId, revenue[j].recordId2, revenue[j].mProductId, revenue[j].aAssetId);
143       }
144       CreateRegFactAcctData [] account = CreateRegFactAcctData.incomesummary(this, strAcctSchema);
145       if (ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).signum()>0){
146         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
147         CreateRegFactAcctData.insert(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, account[0].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),"0",ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).toString(),"0",ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).toString(), Fact_Acct_Group_ID, "10", account[0].name, account[0].value, account[0].cBpartnerId, account[0].recordId2, account[0].mProductId, account[0].aAssetId);
148       }else if (ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).signum()<0){
149         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
150         CreateRegFactAcctData.insert(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, account[0].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),ExpenseAmtCr.add(RevenueAmtCr).subtract(RevenueAmtDr).subtract(ExpenseAmtDr).toString(),"0",ExpenseAmtCr.add(RevenueAmtCr).subtract(RevenueAmtDr).subtract(ExpenseAmtDr).toString(),"0", Fact_Acct_Group_ID, "10", account[0].name, account[0].value, account[0].cBpartnerId, account[0].recordId2, account[0].mProductId, account[0].aAssetId);
151       }
152       return "ProcessOK";
153     } catch (ServletException e) {
154       log4j.warn(e);
155       return "ProcessRunError4";
156     }
157   }
158
159   String JavaDoc processButtonClose(Connection JavaDoc conn, VariablesSecureApp vars, String JavaDoc strKey, String JavaDoc strPediodId, String JavaDoc windowId, String JavaDoc stradOrgId, String JavaDoc strCloseID, String JavaDoc strOpenID) {
160     try {
161       CreateRegFactAcctData[] asset = CreateRegFactAcctData.getAmountsClose(this, strKey, strPediodId, "A", stradOrgId);
162       CreateRegFactAcctData[] liability = CreateRegFactAcctData.getAmountsClose(this, strKey, strPediodId, "L", stradOrgId);
163       BigDecimal AmtCr, AmtDr;
164       BigDecimal assetAmtDr = new BigDecimal("0");
165       BigDecimal assetAmtCr = new BigDecimal("0");
166       BigDecimal liabilityAmtDr = new BigDecimal("0");
167       BigDecimal liabilityAmtCr = new BigDecimal("0");
168       String JavaDoc strAcctSchema = Utility.getContext(this, vars, "$C_ACCTSCHEMA_ID", windowId);;
169       String JavaDoc Fact_Acct_ID = "";
170       String JavaDoc Fact_Acct_Group_ID = strCloseID;
171       String JavaDoc newPeriod = CreateRegFactAcctData.getNextPeriod(this, strPediodId);
172       if(newPeriod.equals("")) return "ProcessRunError";
173       //Fact_Acct_Group_ID = SequenceIdData.getSequence(this, "Fact_Acct_Group", vars.getClient());
174
int i;
175       for (i=0;i<asset.length;i++){
176         assetAmtDr = assetAmtDr.add(new BigDecimal(asset[i].totalamtdr));
177         assetAmtCr = assetAmtCr.add(new BigDecimal(asset[i].totalamtcr));
178         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
179         if(!asset[i].totalamtdr.equals("0") || !asset[i].totalamtcr.equals("0"))CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, asset[i].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),asset[i].totalamtdr,asset[i].totalamtcr,asset[i].totalamtdr,asset[i].totalamtcr , Fact_Acct_Group_ID, Integer.toString((i+3)*10), "C", asset[i].acctdescription, asset[i].acctvalue, asset[i].cBpartnerId, asset[i].recordId2, asset[i].mProductId, asset[i].aAssetId);
180       }
181       for (int j=0;j<liability.length;j++){
182         liabilityAmtDr = liabilityAmtDr.add(new BigDecimal(liability[j].totalamtdr));
183         liabilityAmtCr = liabilityAmtCr.add(new BigDecimal(liability[j].totalamtcr));
184         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
185         if(!liability[j].totalamtdr.equals("0") || !liability[j].totalamtcr.equals("0"))CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, liability[j].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),liability[j].totalamtdr,liability[j].totalamtcr,liability[j].totalamtdr,liability[j].totalamtcr , Fact_Acct_Group_ID, Integer.toString((i+j+3)*10), "C", liability[j].acctdescription, liability[j].acctvalue, liability[j].cBpartnerId, liability[j].recordId2, liability[j].mProductId, liability[j].aAssetId);
186       }
187       CreateRegFactAcctData [] account = CreateRegFactAcctData.incomesummary(this, strAcctSchema);
188       if (ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).signum()<0){
189         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
190         CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, account[0].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).toString(),"0",ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).toString(),"0", Fact_Acct_Group_ID, "10","C", account[0].name, account[0].value, account[0].cBpartnerId, account[0].recordId2, account[0].mProductId, account[0].aAssetId);
191       }else if (ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).signum()>0){
192         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
193         CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, account[0].accountId, CreateRegFactAcctData.getEndDate(this, strPediodId), strPediodId, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),"0",ExpenseAmtCr.add(RevenueAmtCr).subtract(RevenueAmtDr).subtract(ExpenseAmtDr).toString(),"0",ExpenseAmtCr.add(RevenueAmtCr).subtract(RevenueAmtDr).subtract(ExpenseAmtDr).toString(), Fact_Acct_Group_ID, "10", "C", account[0].name, account[0].value, account[0].cBpartnerId, account[0].recordId2, account[0].mProductId, account[0].aAssetId);
194       }
195
196       String JavaDoc Fact_Acct_Group_ID2 = strOpenID;
197       i = 0;
198       for (i=0;i<asset.length;i++){
199         assetAmtDr = assetAmtDr.add(new BigDecimal(asset[i].totalamtdr));
200         assetAmtCr = assetAmtCr.add(new BigDecimal(asset[i].totalamtcr));
201         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
202         if(!asset[i].totalamtdr.equals("0") || !asset[i].totalamtcr.equals("0"))CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, asset[i].accountId, CreateRegFactAcctData.getStartDate(this, newPeriod), newPeriod, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),asset[i].totalamtcr,asset[i].totalamtdr,asset[i].totalamtcr,asset[i].totalamtdr , Fact_Acct_Group_ID2, Integer.toString((i+3)*10), "O", asset[i].acctdescription, asset[i].acctvalue, asset[i].cBpartnerId, asset[i].recordId2, asset[i].mProductId, asset[i].aAssetId);
203       }
204       for (int j=0;j<liability.length;j++){
205         liabilityAmtDr = liabilityAmtDr.add(new BigDecimal(liability[j].totalamtdr));
206         liabilityAmtCr = liabilityAmtCr.add(new BigDecimal(liability[j].totalamtcr));
207         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
208         if(!liability[j].totalamtdr.equals("0") || !liability[j].totalamtcr.equals("0"))CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, liability[j].accountId, CreateRegFactAcctData.getStartDate(this, newPeriod), newPeriod, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),liability[j].totalamtcr,liability[j].totalamtdr,liability[j].totalamtcr,liability[j].totalamtdr, Fact_Acct_Group_ID2, Integer.toString((i+j+3)*10), "O", liability[j].acctdescription, liability[j].acctvalue, liability[j].cBpartnerId, liability[j].recordId2, liability[j].mProductId, liability[j].aAssetId);
209       }
210       account = CreateRegFactAcctData.incomesummary(this, strAcctSchema);
211       if (ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).signum()<0){
212         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
213         CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, account[0].accountId, CreateRegFactAcctData.getStartDate(this, newPeriod), newPeriod, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),"0",ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).toString(),"0",ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).toString(), Fact_Acct_Group_ID2, "10","O", account[0].name, account[0].value, account[0].cBpartnerId, account[0].recordId2, account[0].mProductId, account[0].aAssetId);
214       }else if (ExpenseAmtDr.add(RevenueAmtDr).subtract(RevenueAmtCr).subtract(ExpenseAmtCr).signum()>0){
215         Fact_Acct_ID = SequenceIdData.getSequence(this, "Fact_Acct", vars.getClient());
216         CreateRegFactAcctData.insertClose(conn, this, Fact_Acct_ID, vars.getClient(), stradOrgId, vars.getUser(), strAcctSchema, account[0].accountId, CreateRegFactAcctData.getStartDate(this, newPeriod), newPeriod, CreateRegFactAcctData.adTableId(this), "A", CreateRegFactAcctData.cCurrencyId(this, strAcctSchema),ExpenseAmtCr.add(RevenueAmtCr).subtract(RevenueAmtDr).subtract(ExpenseAmtDr).toString(),"0",ExpenseAmtCr.add(RevenueAmtCr).subtract(RevenueAmtDr).subtract(ExpenseAmtDr).toString(),"0", Fact_Acct_Group_ID2, "10","O", account[0].name, account[0].value, account[0].cBpartnerId, account[0].recordId2, account[0].mProductId, account[0].aAssetId);
217       }
218
219       return "ProcessOK";
220     } catch (ServletException e) {
221       log4j.warn(e);
222       return "ProcessRunError";
223     }
224   }
225
226   void printPage(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strKey, String JavaDoc strPediodId, String JavaDoc windowId, String JavaDoc strTab, String JavaDoc strProcessId, String JavaDoc strClose) throws IOException, ServletException {
227       if (log4j.isDebugEnabled()) log4j.debug("Output: Button process Create Close Fact Acct");
228
229       ActionButtonDefaultData[] data = null;
230       String JavaDoc strHelp="", strDescription="";
231       if (vars.getLanguage().equals("es_ES")) data = ActionButtonDefaultData.select(this, strProcessId);
232       else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId);
233
234       if (data!=null && data.length!=0) {
235         strDescription = data[0].description;
236         strHelp = data[0].help;
237       }
238       String JavaDoc[] discard = {""};
239       if (strHelp.equals("")) discard[0] = new String JavaDoc("helpDiscard");
240       XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateRegFactAcct", discard).createXmlDocument();
241       xmlDocument.setParameter("key", strKey);
242       xmlDocument.setParameter("window", windowId);
243       xmlDocument.setParameter("tab", strTab);
244       xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
245       xmlDocument.setParameter("question", Utility.messageBD(this, "StartProcess?", vars.getLanguage()));
246       xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
247       xmlDocument.setParameter("description", strDescription);
248       xmlDocument.setParameter("help", strHelp);
249       xmlDocument.setParameter("Close", strClose);
250
251       xmlDocument.setData("reportcPeriodId", "liststructure", CreateRegFactAcctData.select(this,strKey));
252
253       xmlDocument.setParameter("cPeriodId", strPediodId);
254
255
256       response.setContentType("text/html; charset=UTF-8");
257       PrintWriter out = response.getWriter();
258       out.println(xmlDocument.print());
259       out.close();
260     }
261
262   public String JavaDoc getServletInfo() {
263     return "Servlet Project close fact acct";
264   } // end of getServletInfo() method
265
}
266
267
Popular Tags