📄 doc_payment.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.acct;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.compiere.model.*;
import org.compiere.util.*;
/**
* Post Invoice Documents.
* <pre>
* Table: C_Payment (335)
* Document Types ARP, APP
* </pre>
* @author Jorg Janke
* @version $Id: Doc_Payment.java,v 1.7 2005/10/26 00:40:02 jjanke Exp $
*/
public class Doc_Payment extends Doc
{
/**
* Constructor
* @param ass accounting schemata
* @param rs record
* @parem trxName trx
*/
protected Doc_Payment (MAcctSchema[] ass, ResultSet rs, String trxName)
{
super (ass, MPayment.class, rs, null, trxName);
} // Doc_Payment
/** Tender Type */
private String m_TenderType = null;
/** Prepayment */
private boolean m_Prepayment = false;
/** Bank Account */
private int m_C_BankAccount_ID = 0;
/**
* Load Specific Document Details
* @return error message or null
*/
protected String loadDocumentDetails ()
{
MPayment pay = (MPayment)getPO();
setDateDoc(pay.getDateTrx());
m_TenderType = pay.getTenderType();
m_Prepayment = pay.isPrepayment();
m_C_BankAccount_ID = pay.getC_BankAccount_ID();
// Amount
setAmount(Doc.AMTTYPE_Gross, pay.getPayAmt());
return null;
} // loadDocumentDetails
/**************************************************************************
* Get Source Currency Balance - always zero
* @return Zero (always balanced)
*/
public BigDecimal getBalance()
{
BigDecimal retValue = Env.ZERO;
// log.config( toString() + " Balance=" + retValue);
return retValue;
} // getBalance
/**
* Create Facts (the accounting logic) for
* ARP, APP.
* <pre>
* ARP
* BankInTransit DR
* UnallocatedCash CR
* or Charge/C_Prepayment
* APP
* PaymentSelect DR
* or Charge/V_Prepayment
* BankInTransit CR
* CashBankTransfer
* -
* </pre>
* @param as accounting schema
* @return Fact
*/
public ArrayList<Fact> createFacts (MAcctSchema as)
{
// create Fact Header
Fact fact = new Fact(this, as, Fact.POST_Actual);
// Cash Transfer
if ("X".equals(m_TenderType))
{
ArrayList<Fact> facts = new ArrayList<Fact>();
facts.add(fact);
return facts;
}
int AD_Org_ID = getBank_Org_ID(); // Bank Account Org
if (getDocumentType().equals(DOCTYPE_ARReceipt))
{
// Asset
FactLine fl = fact.createLine(null, getAccount(Doc.ACCTTYPE_BankInTransit, as),
getC_Currency_ID(), getAmount(), null);
if (fl != null && AD_Org_ID != 0)
fl.setAD_Org_ID(AD_Org_ID);
//
MAccount acct = null;
if (getC_Charge_ID() != 0)
acct = MCharge.getAccount(getC_Charge_ID(), as, getAmount());
else if (m_Prepayment)
acct = getAccount(Doc.ACCTTYPE_C_Prepayment, as);
else
acct = getAccount(Doc.ACCTTYPE_UnallocatedCash, as);
fl = fact.createLine(null, acct,
getC_Currency_ID(), null, getAmount());
if (fl != null && AD_Org_ID != 0
&& getC_Charge_ID() == 0) // don't overwrite charge
fl.setAD_Org_ID(AD_Org_ID);
}
// APP
else if (getDocumentType().equals(DOCTYPE_APPayment))
{
MAccount acct = null;
if (getC_Charge_ID() != 0)
acct = MCharge.getAccount(getC_Charge_ID(), as, getAmount());
else if (m_Prepayment)
acct = getAccount(Doc.ACCTTYPE_V_Prepayment, as);
else
acct = getAccount(Doc.ACCTTYPE_PaymentSelect, as);
FactLine fl = fact.createLine(null, acct,
getC_Currency_ID(), getAmount(), null);
if (fl != null && AD_Org_ID != 0
&& getC_Charge_ID() == 0) // don't overwrite charge
fl.setAD_Org_ID(AD_Org_ID);
// Asset
fl = fact.createLine(null, getAccount(Doc.ACCTTYPE_BankInTransit, as),
getC_Currency_ID(), null, getAmount());
if (fl != null && AD_Org_ID != 0)
fl.setAD_Org_ID(AD_Org_ID);
}
else
{
p_Error = "DocumentType unknown: " + getDocumentType();
log.log(Level.SEVERE, p_Error);
fact = null;
}
//
ArrayList<Fact> facts = new ArrayList<Fact>();
facts.add(fact);
return facts;
} // createFact
/**
* Get AD_Org_ID from Bank Account
* @return AD_Org_ID or 0
*/
private int getBank_Org_ID ()
{
if (m_C_BankAccount_ID == 0)
return 0;
//
MBankAccount ba = MBankAccount.get(getCtx(), m_C_BankAccount_ID);
return ba.getAD_Org_ID();
} // getBank_Org_ID
} // Doc_Payment
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -