KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_forms > DocInvoice


1 /*
2  ******************************************************************************
3  * The contents of this file are subject to the Compiere License Version 1.1
4  * ("License"); You may not use this file except in compliance with the License
5  * You may obtain a copy of the License at http://www.compiere.org/license.html
6  * Software distributed under the License is distributed on an "AS IS" basis,
7  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
8  * the specific language governing rights and limitations under the License.
9  * The Original Code is Compiere ERP & CRM Business Solution
10  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
11  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
12  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
13  * Contributor(s): Openbravo SL
14  * Contributions are Copyright (C) 2001-2006 Openbravo S.L.
15  ******************************************************************************
16 */

17 package org.openbravo.erpCommon.ad_forms;
18
19 import org.openbravo.erpCommon.utility.SequenceIdData;
20 import org.openbravo.base.secureApp.VariablesSecureApp;
21 import java.math.*;
22 import java.util.*;
23 import javax.servlet.*;
24 import org.apache.log4j.Logger ;
25 // imports for transactions
26
import org.openbravo.database.ConnectionProvider;
27 import java.sql.Connection JavaDoc;
28 import org.openbravo.data.FieldProvider;
29
30
31
32 public class DocInvoice extends AcctServer {
33     static Logger log4jDocInvoice = Logger.getLogger(DocInvoice.class);
34
35     private DocTax[] m_taxes = null;
36     private String JavaDoc SeqNo = "0";
37
38 /**
39  * Constructor
40  * @param AD_Client_ID AD_Client_ID
41  */

42 public DocInvoice(String JavaDoc AD_Client_ID){
43     super(AD_Client_ID);
44 }
45
46 public void loadObjectFieldProvider(ConnectionProvider conn, String JavaDoc AD_Client_ID, String JavaDoc Id) throws ServletException{
47     setObjectFieldProvider(DocInvoiceData.selectRegistro(conn, AD_Client_ID, Id));
48 }
49
50 public boolean loadDocumentDetails(FieldProvider [] data,ConnectionProvider conn){
51     DateDoc = data[0].getField("DateInvoiced");
52     TaxIncluded = data[0].getField("IsTaxIncluded");
53     C_BPartner_Location_ID = data[0].getField("C_BPartner_Location_ID");
54     // Amounts
55
Amounts[AMTTYPE_Gross] = data[0].getField("GrandTotal");
56     if (Amounts[AMTTYPE_Gross] == null)
57         Amounts[AMTTYPE_Gross] = "0";
58     Amounts[AMTTYPE_Net] = data[0].getField("TotalLines");
59     if (Amounts[AMTTYPE_Net] == null)
60         Amounts[AMTTYPE_Net] = "0";
61     Amounts[AMTTYPE_Charge] = data[0].getField("ChargeAmt");
62     if (Amounts[AMTTYPE_Charge] == null)
63         Amounts[AMTTYPE_Charge] = "0";
64
65     loadDocumentType(); // lines require doc type
66
// Contained Objects
67
p_lines = loadLines();
68     m_taxes = loadTaxes();
69     m_debt_payments = loadDebtPayments();
70     return true;
71
72 }
73
74 private DocLine[] loadLines(){
75     ArrayList<Object JavaDoc> list = new ArrayList<Object JavaDoc>();
76     DocLineInvoiceData[] data = null;
77     try{
78         log4jDocInvoice.debug("############### groupLines = " + groupLines);
79         if (groupLines.equals("Y")) data = DocLineInvoiceData.selectTotal(this, Record_ID);
80         else data = DocLineInvoiceData.select(this, Record_ID);
81     }catch(ServletException e){
82         log4jDocInvoice.warn(e);
83     }
84     if (data==null || data.length==0) return null;
85     for (int i=0;i<data.length;i++){
86             String JavaDoc Line_ID = data[i].cInvoicelineId;
87             DocLine_Invoice docLine = new DocLine_Invoice (DocumentType, Record_ID, Line_ID);
88             docLine.loadAttributes(data[i], this);
89             String JavaDoc Qty = data[i].qtyinvoiced;
90             docLine.setQty(Qty);
91             String JavaDoc LineNetAmt = data[i].linenetamt;
92             String JavaDoc PriceList = data[i].pricelist;
93             docLine.setAmount (LineNetAmt, PriceList, Qty);
94
95             list.add (docLine);
96     }
97     // Return Array
98
DocLine[] dl = new DocLine[list.size()];
99     list.toArray(dl);
100     return dl;
101 } // loadLines
102

103 private DocTax[] loadTaxes(){
104     ArrayList<Object JavaDoc> list = new ArrayList<Object JavaDoc>();
105     DocInvoiceData [] data = null;
106     try{
107         data = DocInvoiceData.select(this, Record_ID);
108     }catch(ServletException e){
109         log4jDocInvoice.warn(e);
110     }
111     log4jDocInvoice.debug("############### Taxes.length = " + data.length);
112         //
113
for (int i=0;i<data.length;i++){
114             String JavaDoc C_Tax_ID = data[i].cTaxId;
115             String JavaDoc name = data[i].name;
116             String JavaDoc rate = data[i].rate;
117             String JavaDoc taxBaseAmt = data[i].taxbaseamt;
118             String JavaDoc amount = data[i].taxamt;
119             //
120
DocTax taxLine = new DocTax(C_Tax_ID, name, rate, taxBaseAmt, amount);
121             list.add(taxLine);
122     }
123     // Return Array
124
DocTax[] tl = new DocTax[list.size()];
125     list.toArray(tl);
126     return tl;
127 } // loadTaxes
128

129
130 private DocLine_Payment[] loadDebtPayments(){
131     ArrayList<Object JavaDoc> list = new ArrayList<Object JavaDoc>();
132     DocInvoiceData [] data = null;
133     try{
134         data = DocInvoiceData.selectDebtPayments(this, Record_ID);
135     }catch(ServletException e){
136         log4jDocInvoice.warn(e);
137     }
138     log4jDocInvoice.debug("############### DebtPayments.length = " + data.length);
139         //
140
for (int i=0;i<data.length;i++){
141             //
142
String JavaDoc Line_ID = data[i].cDebtPaymentId;
143             DocLine_Payment dpLine = new DocLine_Payment(DocumentType, Record_ID, Line_ID);
144             log4jDocInvoice.debug(" dpLine.m_Record_Id2 = " + data[i].cDebtPaymentId);
145             dpLine.m_Record_Id2 = data[i].cDebtPaymentId;
146             dpLine.C_Currency_ID_From = data[i].cCurrencyId;
147             dpLine.dpStatus = data[i].status;
148             dpLine.isReceipt = data[i].isreceipt;
149             dpLine.isPaid = data[i].ispaid;
150             dpLine.isManual = data[i].ismanual;
151             dpLine.WriteOffAmt = data[i].writeoffamt;
152             dpLine.Amount = data[i].amount;
153             list.add(dpLine);
154     }
155     // Return Array
156
DocLine_Payment[] tl = new DocLine_Payment[list.size()];
157     list.toArray(tl);
158     return tl;
159 } // loadTaxes
160

161 /**
162  * Create Facts (the accounting logic) for
163  * ARI, ARC, ARF, API, APC.
164  * <pre>
165  * ARI, ARF
166  * Receivables DR
167  * Charge CR
168  * TaxDue CR
169  * Revenue CR
170  *
171  * ARC
172  * Receivables CR
173  * Charge DR
174  * TaxDue DR
175  * Revenue RR
176  *
177  * API
178  * Payables CR
179  * Charge DR
180  * TaxCredit DR
181  * Expense DR
182  *
183  * APC
184  * Payables DR
185  * Charge CR
186  * TaxCredit CR
187  * Expense CR
188  * </pre>
189  * @param as accounting schema
190  * @return Fact
191  */

192 public Fact createFact (AcctSchema as,ConnectionProvider conn,Connection JavaDoc con,VariablesSecureApp vars) throws ServletException{
193     log4jDocInvoice.debug("Starting create fact");
194     // create Fact Header
195
Fact fact = new Fact(this, as, Fact.POST_Actual);
196     String JavaDoc Fact_Acct_Group_ID = SequenceIdData.getSequence(conn, "Fact_Acct_Group", vars.getClient());
197     // Cash based accounting
198
if (!as.isAccrual())
199         return null;
200
201     /** @todo Assumes TaxIncluded = N */
202
203     // ARI, ARF
204
if (DocumentType.equals(AcctServer.DOCTYPE_ARInvoice) || DocumentType.equals(AcctServer.DOCTYPE_ARProForma)){
205       log4jDocInvoice.debug("Point 1");
206         // Receivables DR
207
for (int i = 0;m_debt_payments!=null && i < m_debt_payments.length; i++){
208           if(m_debt_payments[i].isReceipt.equals("Y")) fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, true, m_debt_payments[i].dpStatus, conn), this.C_Currency_ID, getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
209           else fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, false, m_debt_payments[i].dpStatus, conn),this.C_Currency_ID, "", getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
210         }
211         // Charge CR
212
log4jDocInvoice.debug("The first create line");
213         fact.createLine(null, getAccount(AcctServer.ACCTTYPE_Charge, as, conn),C_Currency_ID, "", getAmount(AcctServer.AMTTYPE_Charge), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
214         // TaxDue CR
215
log4jDocInvoice.debug("m_taxes.length: " + m_taxes);
216         for (int i = 0;m_taxes!=null && i < m_taxes.length; i++){
217             fact.createLine(null, m_taxes[i].getAccount(DocTax.ACCTTYPE_TaxDue, as, conn),C_Currency_ID, "", m_taxes[i].m_amount, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
218         }
219         // Revenue CR
220
if (p_lines!=null && p_lines.length>0) {
221             for (int i = 0; i < p_lines.length; i++)
222                 fact.createLine(p_lines[i],((DocLine_Invoice)p_lines[i]).getAccount(ProductInfo.ACCTTYPE_P_Revenue, as, conn),this.C_Currency_ID, "", p_lines[i].getAmount(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
223         }
224         // Set Locations
225
FactLine[] fLines = fact.getLines();
226         for (int i = 0; i < fLines.length; i++){
227             if (fLines[i] != null){
228                 fLines[i].setLocationFromOrg(fLines[i].getAD_Org_ID(conn), true,conn); // from Loc
229
fLines[i].setLocationFromBPartner(C_BPartner_Location_ID, false,conn); // to Loc
230
}
231         }
232     }
233     // ARC
234
else if (this.DocumentType.equals(AcctServer.DOCTYPE_ARCredit)){
235       log4jDocInvoice.debug("Point 2");
236         // Receivables CR
237
for (int i = 0;m_debt_payments!=null && i < m_debt_payments.length; i++){
238           if(m_debt_payments[i].isReceipt.equals("Y")) fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, true, m_debt_payments[i].dpStatus, conn), this.C_Currency_ID, "", getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
239           else fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, false, m_debt_payments[i].dpStatus, conn), this.C_Currency_ID, getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
240         }
241
242         //fact.createLine(null, getAccount(AcctServer.ACCTTYPE_C_Receivable, as, conn),this.C_Currency_ID, "", getAmount(AcctServer.AMTTYPE_Gross), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
243
// Charge DR
244
fact.createLine(null, getAccount(AcctServer.ACCTTYPE_Charge, as, conn),this.C_Currency_ID, getAmount(AcctServer.AMTTYPE_Charge), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
245         // TaxDue DR
246
for (int i = 0;m_taxes!=null && i < m_taxes.length; i++)
247             fact.createLine(null, m_taxes[i].getAccount(DocTax.ACCTTYPE_TaxDue, as, conn),this.C_Currency_ID, m_taxes[i].getAmount(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
248         // Revenue CR
249
for (int i = 0;p_lines!=null && i < p_lines.length; i++)
250             fact.createLine(p_lines[i],((DocLine_Invoice)p_lines[i]).getAccount(ProductInfo.ACCTTYPE_P_Revenue, as, conn),this.C_Currency_ID, p_lines[i].getAmount(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
251         // Set Locations
252
FactLine[] fLines = fact.getLines();
253         for (int i = 0;fLines!=null && i < fLines.length; i++){
254             if (fLines[i] != null){
255                 fLines[i].setLocationFromOrg(fLines[i].getAD_Org_ID(conn), true,conn); // from Loc
256
fLines[i].setLocationFromBPartner(C_BPartner_Location_ID, false,conn); // to Loc
257
}
258         }
259     }
260     // API
261
else if (this.DocumentType.equals(AcctServer.DOCTYPE_APInvoice)){
262       log4jDocInvoice.debug("Point 3");
263         // Liability CR
264
for (int i = 0;m_debt_payments!=null && i < m_debt_payments.length; i++){
265           if(m_debt_payments[i].isReceipt.equals("Y")) fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, true, m_debt_payments[i].dpStatus, conn), this.C_Currency_ID, getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
266           else fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, false, m_debt_payments[i].dpStatus, conn), this.C_Currency_ID, "", getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
267         }
268
269         //fact.createLine(null, getAccount(AcctServer.ACCTTYPE_V_Liability, as, conn),this.C_Currency_ID, "", getAmount(AcctServer.AMTTYPE_Gross), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
270
// Charge DR
271
fact.createLine(null, getAccount(AcctServer.ACCTTYPE_Charge, as, conn),this.C_Currency_ID, getAmount(AcctServer.AMTTYPE_Charge), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
272         // TaxCredit DR
273
for (int i = 0;m_taxes!=null && i < m_taxes.length; i++)
274             fact.createLine(null, m_taxes[i].getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn),this.C_Currency_ID, m_taxes[i].getAmount(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
275         // Expense DR
276
for (int i = 0;p_lines!=null && i < p_lines.length; i++)
277             fact.createLine(p_lines[i],((DocLine_Invoice)p_lines[i]).getAccount(ProductInfo.ACCTTYPE_P_Expense,as, conn),this.C_Currency_ID, p_lines[i].getAmount(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
278         // Set Locations
279
FactLine[] fLines = fact.getLines();
280         for (int i = 0;fLines !=null && i < fLines.length; i++){
281             if (fLines[i] != null){
282                 fLines[i].setLocationFromBPartner(C_BPartner_Location_ID, true,conn); // from Loc
283
fLines[i].setLocationFromOrg(fLines[i].getAD_Org_ID(conn), false,conn); // to Loc
284
}
285         }
286         updateProductInfo(as.getC_AcctSchema_ID(), conn,con); // only API
287
}
288     // APC
289
else if (this.DocumentType.equals(AcctServer.DOCTYPE_APCredit)){
290       log4jDocInvoice.debug("Point 4");
291         // Liability DR
292
for (int i = 0;m_debt_payments!=null && i < m_debt_payments.length; i++){
293           if(m_debt_payments[i].isReceipt.equals("Y")) fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, true, m_debt_payments[i].dpStatus, conn), this.C_Currency_ID, getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
294           else fact.createLine(m_debt_payments[i], getAccountBPartner(C_BPartner_ID, as, false, m_debt_payments[i].dpStatus, conn), this.C_Currency_ID, "", getConvertedAmt(m_debt_payments[i].Amount,m_debt_payments[i].C_Currency_ID_From, this.C_Currency_ID,DateAcct,"",conn), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
295         }
296
297
298         //fact.createLine (null, getAccount(AcctServer.ACCTTYPE_V_Liability, as, conn),this.C_Currency_ID,"", getAmount(AcctServer.AMTTYPE_Gross), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
299
// Charge CR
300
fact.createLine (null, getAccount(AcctServer.ACCTTYPE_Charge, as, conn),this.C_Currency_ID, getAmount(AcctServer.AMTTYPE_Charge),"", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
301         // TaxCredit CR
302
for (int i = 0;m_taxes!=null && i < m_taxes.length; i++)
303             fact.createLine (null, m_taxes[i].getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn),this.C_Currency_ID, m_taxes[i].getAmount(),"", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
304         // Expense CR
305
for (int i = 0;p_lines!=null && i < p_lines.length; i++)
306             fact.createLine (p_lines[i],((DocLine_Invoice)p_lines[i]).getAccount(ProductInfo.ACCTTYPE_P_Expense,as, conn),this.C_Currency_ID,p_lines[i].getAmount(),"", Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,conn);
307         // Set Locations
308
FactLine[] fLines = fact.getLines();
309         for (int i = 0;fLines !=null && i < fLines.length; i++){
310             if (fLines[i] != null){
311                 fLines[i].setLocationFromBPartner(C_BPartner_Location_ID, true,conn); // from Loc
312
fLines[i].setLocationFromOrg(fLines[i].getAD_Org_ID(conn), false,conn); // to Loc
313
}
314         }
315     }
316     else{
317         log4jDocInvoice.warn("Doc_Invoice - DocumentType unknown: " + this.DocumentType);
318         fact = null;
319     }
320     SeqNo = "0";
321     return fact;
322 } // createFact
323

324     
325     /**
326      * Update Product Info.
327      * - Costing (PriceLastInv)
328      * - PO (PriceLastInv)
329      * @param C_AcctSchema_ID accounting schema
330      */

331     private void updateProductInfo (String JavaDoc C_AcctSchema_ID,ConnectionProvider conn,Connection JavaDoc con){
332         log4jDocInvoice.debug("updateProductInfo - C_Invoice_ID=" + this.Record_ID);
333
334         /** @todo Last.. would need to compare document/last updated date
335          * would need to maintain LastPriceUpdateDate on _PO and _Costing */

336
337         // update Product PO info
338
// should only be once, but here for every AcctSchema
339
// ignores multiple lines with same product - just uses first
340

341         int no = 0;
342         try{
343             no = DocInvoiceData.updateProductPO(con,conn,Record_ID);
344             log4jDocInvoice.debug("M_Product_PO - Updated=" + no);
345
346             // update Product Costing
347
// requires existence of currency conversion !!
348
// if there are multiple lines of the same product last price uses first
349
no = DocInvoiceData.updateProductCosting(con,conn,C_AcctSchema_ID,Record_ID);
350             log4jDocInvoice.debug("M_Product_Costing - Updated=" + no);
351         }catch(ServletException e){
352             log4jDocInvoice.warn(e);
353         }
354     } // updateProductInfo
355

356     /**
357      * Get Source Currency Balance - subtracts line and tax amounts from total - no rounding
358      * @return positive amount, if total invoice is bigger than lines
359      */

360     public BigDecimal getBalance(){
361         BigDecimal ZERO = new BigDecimal("0");
362         BigDecimal retValue = ZERO;
363         StringBuffer JavaDoc sb = new StringBuffer JavaDoc (" [");
364         // Total
365
retValue = retValue.add(new BigDecimal(getAmount(AcctServer.AMTTYPE_Gross)));
366         sb.append(getAmount(AcctServer.AMTTYPE_Gross));
367         // - Charge
368
retValue = retValue.subtract(new BigDecimal(getAmount(AcctServer.AMTTYPE_Charge)));
369         sb.append("-").append(getAmount(AcctServer.AMTTYPE_Charge));
370         // - Tax
371
for (int i = 0; i < m_taxes.length; i++){
372             retValue = retValue.subtract(new BigDecimal(m_taxes[i].getAmount()));
373             sb.append("-").append(m_taxes[i].getAmount());
374         }
375         // - Lines
376
for (int i = 0; i < p_lines.length; i++){
377             retValue = retValue.subtract(new BigDecimal(p_lines[i].getAmount()));
378             sb.append("-").append(p_lines[i].getAmount());
379         }
380         sb.append("]");
381         //
382
log4jDocInvoice.debug("Balance=" + retValue + sb.toString());
383         return retValue;
384     } // getBalance
385

386     public String JavaDoc nextSeqNo(String JavaDoc oldSeqNo){
387       log4jDocInvoice.debug("DocInvoice - oldSeqNo = " + oldSeqNo);
388       BigDecimal seqNo = new BigDecimal(oldSeqNo);
389       SeqNo = (seqNo.add(new BigDecimal("10"))).toString();
390       log4jDocInvoice.debug("DocInvoice - nextSeqNo = " + SeqNo);
391       return SeqNo;
392     }
393
394     /**
395      * Get the account for Accounting Schema
396      * @param AcctType see ACCTTYPE_*
397      * @param as accounting schema
398      * @return Account
399      */

400     public final Account getAccountBPartner(String JavaDoc cBPartnerId, AcctSchema as,boolean isReceipt, String JavaDoc dpStatus, ConnectionProvider conn){
401         DocPaymentData [] data=null;
402         try{
403             if (log4j.isDebugEnabled()) log4j.debug("DocInvoice - getAccountBPartner - DocumentType = " + DocumentType);
404             if (isReceipt){
405                 data = DocPaymentData.selectBPartnerCustomerAcct(conn, cBPartnerId, as.getC_AcctSchema_ID(), dpStatus);
406             }else{
407                 data = DocPaymentData.selectBPartnerVendorAcct(conn, cBPartnerId, as.getC_AcctSchema_ID(), dpStatus);
408             }
409         }catch(ServletException e){
410             log4j.warn(e);
411         }
412         // Get Acct
413
String JavaDoc Account_ID = "";
414         if (data != null && data.length!=0){
415             Account_ID = data[0].accountId;
416         }else return null;
417         // No account
418
if (Account_ID.equals("")){
419             log4j.warn("DocInvoice - getAccountBPartner - NO account BPartner="
420                 + cBPartnerId + ", Record=" + Record_ID+", status "+dpStatus);
421             return null;
422         }
423         // Return Account
424
Account acct = null;
425         try{
426             acct = Account.getAccount(conn, Account_ID);
427         }catch(ServletException e){
428             log4j.warn(e);
429         }
430         return acct;
431     } // getAccount
432

433
434   /**
435    * Get Document Confirmation
436    * @not used
437    */

438   public boolean getDocumentConfirmation(ConnectionProvider conn, String JavaDoc strRecordId) {
439     return true;
440   }
441
442     public String JavaDoc getServletInfo() {
443     return "Servlet for the accounting";
444   } // end of getServletInfo() method
445
}
446
Popular Tags