📄 mpayselectionline.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.model;
import java.math.*;
import java.sql.*;
import java.util.*;
import org.compiere.util.*;
/**
* Payment Selection Line Model
*
* @author Jorg Janke
* @version $Id: MPaySelectionLine.java,v 1.11 2005/09/19 04:49:48 jjanke Exp $
*/
public class MPaySelectionLine extends X_C_PaySelectionLine
{
/**
* Standard Constructor
* @param ctx context
* @param C_PaySelectionLine_ID id
*/
public MPaySelectionLine (Properties ctx, int C_PaySelectionLine_ID, String trxName)
{
super(ctx, C_PaySelectionLine_ID, trxName);
if (C_PaySelectionLine_ID == 0)
{
// setC_PaySelection_ID (0);
// setPaymentRule (null); // S
// setLine (0); // @SQL=SELECT NVL(MAX(Line),0)+10 AS DefaultValue FROM C_PaySelectionLine WHERE C_PaySelection_ID=@C_PaySelection_ID@
// setC_Invoice_ID (0);
setIsSOTrx (false);
setOpenAmt(Env.ZERO);
setPayAmt (Env.ZERO);
setDiscountAmt(Env.ZERO);
setDifferenceAmt (Env.ZERO);
setIsManual (false);
}
} // MPaySelectionLine
/**
* Load Constructor
* @param ctx context
* @param rs result set
*/
public MPaySelectionLine(Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
} // MPaySelectionLine
/**
* Parent Constructor
* @param ps parent
* @param Line line
* @param PaymentRule payment rule
*/
public MPaySelectionLine (MPaySelection ps, int Line, String PaymentRule)
{
this (ps.getCtx(), 0, ps.get_TrxName());
setClientOrg(ps);
setC_PaySelection_ID(ps.getC_PaySelection_ID());
setLine(Line);
setPaymentRule(PaymentRule);
} // MPaySelectionLine
/** Invoice */
private MInvoice m_invoice = null;
/**
* Set Invoice Info
* @param C_Invoice_ID invoice
* @param isSOTrx sales trx
* @param PayAmt payment
* @param OpenAmt open
* @param DiscountAmt discount
*/
public void setInvoice (int C_Invoice_ID, boolean isSOTrx, BigDecimal OpenAmt,
BigDecimal PayAmt, BigDecimal DiscountAmt)
{
setC_Invoice_ID (C_Invoice_ID);
setIsSOTrx(isSOTrx);
setOpenAmt(OpenAmt);
setPayAmt (PayAmt);
setDiscountAmt(DiscountAmt);
setDifferenceAmt(OpenAmt.subtract(PayAmt).subtract(DiscountAmt));
} // setInvoive
/**
* Get Invoice
* @return invoice
*/
public MInvoice getInvoice()
{
if (m_invoice == null)
m_invoice = new MInvoice (getCtx(), getC_Invoice_ID(), get_TrxName());
return m_invoice;
} // getInvoice
/**
* Before Save
* @param newRecord new
* @return true
*/
protected boolean beforeSave (boolean newRecord)
{
setDifferenceAmt(getOpenAmt().subtract(getPayAmt()).subtract(getDiscountAmt()));
return true;
} // beforeSave
/**
* After Save
* @param newRecord new
* @param success success
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
setHeader();
return success;
} // afterSave
/**
* After Delete
* @param success success
* @return sucess
*/
protected boolean afterDelete (boolean success)
{
setHeader();
return success;
} // afterDelete
/**
* Recalculate Header Sum
*/
private void setHeader()
{
// Update Header
String sql = "UPDATE C_PaySelection ps "
+ "SET TotalAmt = (SELECT COALESCE(SUM(psl.PayAmt),0) "
+ "FROM C_PaySelectionLine psl "
+ "WHERE ps.C_PaySelection_ID=psl.C_PaySelection_ID AND psl.IsActive='Y') "
+ "WHERE C_PaySelection_ID=" + getC_PaySelection_ID();
DB.executeUpdate(sql, get_TrxName());
} // setHeader
/**
* String Representation
* @return info
*/
public String toString()
{
StringBuffer sb = new StringBuffer("MPaySelectionLine[");
sb.append(get_ID()).append(",C_Invoice_ID=").append(getC_Invoice_ID())
.append(",PayAmt=").append(getPayAmt())
.append(",DifferenceAmt=").append(getDifferenceAmt())
.append("]");
return sb.toString();
} // toString
} // MPaySelectionLine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -