KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > acct > Doc_Payment


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

14 package org.compiere.acct;
15
16 import java.math.*;
17 import java.util.*;
18 import java.sql.*;
19
20 import org.compiere.util.*;
21 import org.compiere.model.*;
22
23 /**
24  * Post Invoice Documents.
25  * <pre>
26  * Table: C_Payment (335)
27  * Document Types ARP, APP
28  * </pre>
29  * @author Jorg Janke
30  * @version $Id: Doc_Payment.java,v 1.8 2003/03/19 06:47:32 jjanke Exp $
31  */

32 public class Doc_Payment extends Doc
33 {
34     /**
35      * Constructor
36      * @param AD_Client_ID clent
37      */

38     protected Doc_Payment(int AD_Client_ID)
39     {
40         super(AD_Client_ID);
41     }
42
43     /**
44      * Return TableName of Document
45      * @return C_Payment
46      */

47     public String JavaDoc getTableName()
48     {
49         return "C_Payment";
50     } // getTableName
51

52     /**
53      * Get Table ID
54      * @return 335
55      */

56     public int getAD_Table_ID()
57     {
58         return 335;
59     } // getAD_Table_ID
60

61     /**
62      * Load Specific Document Details
63      * @param rs result set
64      * @return true if loadDocumentType was set
65      */

66     protected boolean loadDocumentDetails (ResultSet rs)
67     {
68         try
69         {
70             p_vo.DateDoc = rs.getTimestamp("DateTrx");
71
72             // Amount
73
p_vo.Amounts[Doc.AMTTYPE_Gross] = rs.getBigDecimal("PayAmt");
74             if (p_vo.Amounts[Doc.AMTTYPE_Gross] == null)
75                 p_vo.Amounts[Doc.AMTTYPE_Gross] = Env.ZERO;
76         }
77         catch (SQLException e)
78         {
79             log.error("loadDocumentDetails", e);
80         }
81         return false;
82     } // loadDocumentDetails
83

84     /*************************************************************************/
85
86     /**
87      * Get Source Currency Balance - always zero
88      * @return Zero (always balanced)
89      */

90     public BigDecimal getBalance()
91     {
92         BigDecimal retValue = Env.ZERO;
93     // Log.trace(Log.l4_Data, toString() + " Balance=" + retValue);
94
return retValue;
95     } // getBalance
96

97     /**
98      * Create Facts (the accounting logic) for
99      * ARP, APP.
100      * <pre>
101      * ARP
102      * BankInTransit DR
103      * UnallocatedCash CR
104      * APP
105      * PaymentSelect DR
106      * BankInTransit CR
107      * CashBankTransfer
108      * -
109      * </pre>
110      * @param as accounting schema
111      * @return Fact
112      */

113     public Fact createFact (AcctSchema as)
114     {
115         // create Fact Header
116
Fact fact = new Fact(this, as, Fact.POST_Actual);
117
118         if (p_vo.DocumentType.equals(DocVO.DOCTYPE_ARReceipt))
119         {
120             fact.createLine(null, getAccount(Doc.ACCTTYPE_BankInTransit, as),
121                 p_vo.C_Currency_ID, getAmount(), null);
122             fact.createLine(null, getAccount(Doc.ACCTTYPE_UnallocatedCash, as),
123                 p_vo.C_Currency_ID, null, getAmount());
124         }
125         // APP
126
else if (p_vo.DocumentType.equals(DocVO.DOCTYPE_APPayment))
127         {
128             fact.createLine(null, getAccount(Doc.ACCTTYPE_PaymentSelect, as),
129                 p_vo.C_Currency_ID, getAmount(), null);
130             fact.createLine(null, getAccount(Doc.ACCTTYPE_BankInTransit, as),
131                 p_vo.C_Currency_ID, null, getAmount());
132         }
133         else
134         {
135             p_vo.Error = "DocumentType unknown: " + p_vo.DocumentType;
136             log.error("createFact - " + p_vo.Error);
137             fact = null;
138         }
139         return fact;
140     } // createFact
141

142 } // Doc_Payment
143
Popular Tags