⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpayselectioncheck.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 * 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  Business Solution
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.model;

import java.sql.*;
import java.math.*;
import java.util.*;
import java.text.*;
import java.io.*;
import org.apache.log4j.Logger;

import org.compiere.model.*;
import org.compiere.util.*;

/**
 *  Payment Print/Export model.
 *
 * 	@author 	Jorg Janke
 * 	@version 	$Id: MPaySelectionCheck.java,v 1.9 2003/04/22 05:32:19 jjanke Exp $
 */
public final class MPaySelectionCheck extends PO
	implements Serializable
{
	/**
	 *	Constructor
	 *  @param ctx context
	 *  @param C_PaySelectionCheck_ID C_PaySelectionCheck_ID
	 */
	public MPaySelectionCheck (Properties ctx, int C_PaySelectionCheck_ID)
	{
		super(ctx, C_PaySelectionCheck_ID);
	}   //  MPaySelectionCheck

	/**
	 *	Constructor
	 *  @param ctx context
	 *  @param rs result set
	 */
	public MPaySelectionCheck(Properties ctx, ResultSet rs)
	{
		super(ctx, rs);
	}   //  MPaySelectionCheck

	static private Logger		s_log = Logger.getLogger (MPaySelectionCheck.class);

	/**
	 *  Initialize and return PO_Info
	 *  @param ctx context
	 *  @return POInfo
	 */
	protected POInfo initPO (Properties ctx)
	{
		int AD_Table_ID = 525;
		POInfo poi = POInfo.getPOInfo (ctx, AD_Table_ID);
		return poi;
	}	//	initPO


	public static final String	PAYRULE_CASH = "B";
	public static final String	PAYRULE_CREDITCARD = "K";
	public static final String	PAYRULE_CHECK = "S";
	public static final String	PAYRULE_ACH = "T";


	/*************************************************************************/

	/**
	 *  Pay Selection
	 *  @return C_PaySelection_ID
	 */
	public int getC_PaySelection_ID()
	{
		Integer ii = (Integer)getValue("C_PaySelection_ID");
		if (ii == null)
			return 0;
		return ii.intValue();
	}

	/**
	 *  Business Partner
	 *  @return C_BPartner_ID or 0
	 */
	public int getC_BPartner_ID()
	{
		Integer ii = (Integer)getValue("C_BPartner_ID");
		if (ii == null)
			return 0;
		return ii.intValue();
	}	//	getC_BPartner_ID

	/**
	 *  Payment Amount
	 *  @return PayAmt or 0
	 */
	public BigDecimal getPayAmt()
	{
		BigDecimal bd = (BigDecimal)getValue("PayAmt");
		if (bd == null)
			return Env.ZERO;
		return bd;
	}	//	getPayAmt

	/**
	 *  Number of Invoices
	 *  @return Qty or 0
	 */
	public int getQty()
	{
		Integer ii = (Integer)getValue("Qty");
		if (ii == null)
			return 0;
		return ii.intValue();
	}	//	getQty

	/**
	 *  Payment Rule
	 *  @return PaymentRule
	 */
	public String getPaymentRule()
	{
		return (String)getValue("PaymentRule");
	}	//	getPaymentRule

	/**
	 *  Payment Document No
	 *  @return DocumentNo
	 */
	public String getDocumentNo()
	{
		return (String)getValue("DocumentNo");
	}	//	getDocumentNo

	/**
	 *  Payment Document No
	 *  @param DocumentNo Document No
	 */
	public void setDocumentNo (String DocumentNo)
	{
		setValueNoCheck("DocumentNo", DocumentNo);
	}	//	setDocumentNo

	/**
	 *  Payment
	 *  @return C_Payment_ID or 0
	 */
	public int getC_Payment_ID()
	{
		Integer ii = (Integer)getValue("C_Payment_ID");
		if (ii == null)
			return 0;
		return ii.intValue();
	}	//	getC_Payment_ID

	/**
	 *  Payment
	 *  @param C_Payment_ID payment
	 */
	public void setC_Payment_ID (int C_Payment_ID)
	{
		setValueNoCheck("C_Payment_ID", new Integer (C_Payment_ID));
	}	//	setC_Payment_ID

	/**
	 * 	Is Printed
	 * 	@return printed
	 */
	public boolean isPrinted()
	{
		Boolean bb = (Boolean)getValue("IsPrinted");
		if (bb == null)
			return false;
		return bb.booleanValue();
	}	//	isPrinted

	/**
	 * 	Set Printed
	 * 	@param printed printed
	 */
	public void setPrinted (boolean printed)
	{
		setValueNoCheck("IsPrinted", new Boolean(printed));
	}	//	setPrinted

	/*************************************************************************/

	/**
	 * 	Bank Account
	 *  @return C_BankAccount_ID
	 */
	public int getC_BankAccount_ID()
	{
		if (m_C_BankAccount_ID == -1)
			setPaySelectionInfo();
		return m_C_BankAccount_ID;
	}	//	getC_BankAccount_ID

	/**
	 *  Payment Date
	 *  @return PayDate
	 */
	public Timestamp getPayDate()
	{
		if (m_PayDate == null)
			setPaySelectionInfo();
		return m_PayDate;
	}	//	getPayDate

	/**
	 *  Payment Currency
	 *  @return C_Currency_ID
	 */
	public int getC_Currency_ID()
	{
		if (m_C_Currency_ID == -1)
			setPaySelectionInfo();
		return m_C_Currency_ID;
	}	//	getC_Currency_ID

	/**
	 * 	String Representation
	 * 	@return info
	 */
	public String toString()
	{
		StringBuffer sb = new StringBuffer("MPaymentCheck[");
		sb.append(getID()).append("-").append(getDocumentNo())
			.append("-").append(getPayAmt()).append("-").append(getPayDate())
			.append(",PaymetRule=").append(getPaymentRule())
			.append(",Qty=").append(getQty())
			.append("]");
		return sb.toString();
	}	//	toString


	private int			m_C_BankAccount_ID = -1;
	private int			m_C_Currency_ID = -1;
	private Timestamp	m_PayDate = null;

	/**
	 * 	Get PaySelection Info
	 */
	private void setPaySelectionInfo()
	{
		String sql = "SELECT ps.C_BankAccount_ID, ps.PayDate, ba.C_Currency_ID "
			+ "FROM C_PaySelection ps"
			+ " INNER JOIN C_BankAccount ba ON (ps.C_BankAccount_ID=ba.C_BankAccount_ID) "
			+ "WHERE ps.C_PaySelection_ID=?";
		try
		{
			PreparedStatement pstmt = DB.prepareStatement(sql);
			pstmt.setInt(1, getC_PaySelection_ID());
			ResultSet rs = pstmt.executeQuery();
			if (rs.next())
			{
				m_C_BankAccount_ID = rs.getInt(1);
				m_PayDate = rs.getTimestamp(2);
				m_C_Currency_ID = rs.getInt(3);
			}
			else
				log.error("setPaySelectionInfo - Not found for ID=" + getC_PaySelection_ID());
			rs.close();
			pstmt.close();
		}
		catch (SQLException e)
		{
			log.error("setPaySelectionInfo", e);
		}
	}	//	setPaySelectionInfo

	/*************************************************************************/

	/**
	 * 	Get Invoice IDs
	 * 	@return array of C_Invoice_ID
	 */
	protected PaySelectionLine[] getPaySelectionLines ()
	{
		ArrayList list = new ArrayList();
		String sql = "SELECT psl.C_Invoice_ID, psl.PayAmt, psl.DifferenceAmt,"
			+ " i.DocumentNo, i.GrandTotal, i.C_Currency_ID, i.C_BPartner_ID "
			+ "FROM C_PaySelectionLine psl"
			+ " INNER JOIN C_Invoice i ON (psl.C_Invoice_ID=i.C_Invoice_ID) "
			+ "WHERE C_PaySelectionCheck_ID=?";
		try
		{
			PreparedStatement pstmt = DB.prepareStatement(sql);
			pstmt.setInt(1, getID());
			ResultSet rs = pstmt.executeQuery();
			while (rs.next())
			{
				int C_Invoice_ID = rs.getInt(1);
				BigDecimal PayAmt = rs.getBigDecimal(2);
				BigDecimal DifferenceAmt = rs.getBigDecimal(3);
				String DocumentNo = rs.getString(4);
				BigDecimal GrandTotal = rs.getBigDecimal(5);
				int C_Currency_ID = rs.getInt(6);
				int C_BPartner_ID = rs.getInt(7);
				//
				PaySelectionLine psl = new PaySelectionLine(C_Invoice_ID, DocumentNo,
					GrandTotal, PayAmt, DifferenceAmt, C_Currency_ID, C_BPartner_ID);
				list.add(psl);
			}
			rs.close();
			pstmt.close();
		}
		catch (SQLException e)
		{
			log.error("getPaySelectionLines", e);
		}
		//
		PaySelectionLine[] retValue = new PaySelectionLine[list.size()];
		list.toArray(retValue);
		return retValue;
	}	//	getInvoiceInfo

	/**
	 *	Payment Selection Line Info (Value Object)
	 */
	class PaySelectionLine
	{
		public PaySelectionLine (int C_Invoice_ID, String DocumentNo,
			BigDecimal GrandTotal, BigDecimal PayAmt, BigDecimal DifferenceAmt,
			int C_Currency_ID, int C_BPartner_ID)
		{
			this.C_Invoice_ID = C_Invoice_ID;
			this.DocumentNo = DocumentNo;
			if (GrandTotal != null)
				this.GrandTotal = GrandTotal;
			if (PayAmt != null)
				this.PayAmt = PayAmt;
			if (DifferenceAmt != null)
				this.DifferenceAmt = DifferenceAmt;
			this.C_Currency_ID = C_Currency_ID;
			this.C_BPartner_ID = C_BPartner_ID;
		}
		public int 			C_Invoice_ID;
		public String 		DocumentNo;
		public BigDecimal	GrandTotal = Env.ZERO;
		public BigDecimal 	PayAmt = Env.ZERO;
		public BigDecimal 	DifferenceAmt = Env.ZERO;
		public int 			C_Currency_ID;
		public int 			C_BPartner_ID;

		/**
		 * 	String Representation
		 * 	@return info
		 */
		public String toString()
		{
			StringBuffer sb = new StringBuffer("PaySelectionLine[");
			sb.append(DocumentNo).append(",GrandTotal=").append(GrandTotal)
				.append(",Difference=").append(DifferenceAmt)
				.append("]");
			return sb.toString();
		}	//	toString

	}	//	PaySelectionLine


	/*************************************************************************/

	/**
	 *  Get Checks of Payment Selection
	 *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -