Carlos Ruiz 2011-03-25 22:30:09 -05:00
parent 962fe09801
commit a7d5781c17
18 changed files with 3960 additions and 124 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -721,6 +721,35 @@ public class CalloutOrder extends CalloutEngine
return "";
} // priceList
/**
* Set Payment Term.
* Payment Term has changed
* @param ctx context
* @param WindowNo window no
* @param mTab tab
* @param mField field
* @param value value
* @return null or error message
*/
public String paymentTerm (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
Integer C_PaymentTerm_ID = (Integer)value;
int C_Order_ID = Env.getContextAsInt(ctx, WindowNo, "C_Order_ID");
if (C_PaymentTerm_ID == null || C_PaymentTerm_ID.intValue() == 0
|| C_Order_ID == 0) // not saved yet
return "";
//
MPaymentTerm pt = new MPaymentTerm (ctx, C_PaymentTerm_ID.intValue(), null);
if (pt.get_ID() == 0)
return "PaymentTerm not found";
boolean valid = pt.applyOrder (C_Order_ID);
mTab.setValue("IsPayScheduleValid", valid ? "Y" : "N");
return "";
} // paymentTerm
/*************************************************************************
* Order Line - Product.

View File

@ -16,12 +16,19 @@
*****************************************************************************/
package org.compiere.process;
import java.math.BigDecimal;
import java.util.logging.Level;
import org.compiere.model.MCurrency;
import org.compiere.model.MInOut;
import org.compiere.model.MInOutLine;
import org.compiere.model.MInvoice;
import org.compiere.model.MInvoiceLine;
import org.compiere.model.MInvoicePaySchedule;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderPaySchedule;
import org.compiere.model.PO;
import org.compiere.util.Env;
/**
* Create (Generate) Invoice from Shipment
@ -72,7 +79,7 @@ public class InOutCreateInvoice extends SvrProcess
if (p_M_InOut_ID == 0)
throw new IllegalArgumentException("No Shipment");
//
MInOut ship = new MInOut (getCtx(), p_M_InOut_ID, null);
MInOut ship = new MInOut (getCtx(), p_M_InOut_ID, get_TrxName());
if (ship.get_ID() == 0)
throw new IllegalArgumentException("Shipment not found");
if (!MInOut.DOCSTATUS_Completed.equals(ship.getDocStatus()))
@ -101,6 +108,44 @@ public class InOutCreateInvoice extends SvrProcess
throw new IllegalArgumentException("Cannot save Invoice Line");
}
MOrder order = new MOrder(getCtx(), invoice.getC_Order_ID(), get_TrxName());
if (order != null) {
invoice.setPaymentRule(order.getPaymentRule());
invoice.setC_PaymentTerm_ID(order.getC_PaymentTerm_ID());
invoice.saveEx();
invoice.load(invoice.get_TrxName()); // refresh from DB
// copy payment schedule from order if invoice doesn't have a current payment schedule
MOrderPaySchedule[] opss = MOrderPaySchedule.getOrderPaySchedule(getCtx(), order.getC_Order_ID(), 0, get_TrxName());
MInvoicePaySchedule[] ipss = MInvoicePaySchedule.getInvoicePaySchedule(getCtx(), invoice.getC_Invoice_ID(), 0, get_TrxName());
if (ipss.length == 0 && opss.length > 0) {
BigDecimal ogt = order.getGrandTotal();
BigDecimal igt = invoice.getGrandTotal();
BigDecimal percent = Env.ONE;
if (ogt.compareTo(igt) != 0)
percent = igt.divide(ogt, 10, BigDecimal.ROUND_HALF_UP);
MCurrency cur = MCurrency.get(order.getCtx(), order.getC_Currency_ID());
int scale = cur.getStdPrecision();
for (MOrderPaySchedule ops : opss) {
MInvoicePaySchedule ips = new MInvoicePaySchedule(getCtx(), 0, get_TrxName());
PO.copyValues(ops, ips);
if (percent != Env.ONE) {
BigDecimal propDueAmt = ops.getDueAmt().multiply(percent);
if (propDueAmt.scale() > scale)
propDueAmt = propDueAmt.setScale(scale, BigDecimal.ROUND_HALF_UP);
ips.setDueAmt(propDueAmt);
}
ips.setC_Invoice_ID(invoice.getC_Invoice_ID());
ips.setAD_Org_ID(ops.getAD_Org_ID());
ips.setProcessing(ops.isProcessing());
ips.setIsActive(ops.isActive());
ips.saveEx();
}
}
invoice.validatePaySchedule();
invoice.saveEx();
}
return invoice.getDocumentNo();
} // InOutCreateInvoice

View File

@ -24,15 +24,19 @@ import java.util.logging.Level;
import org.compiere.model.MBPartner;
import org.compiere.model.MClient;
import org.compiere.model.MCurrency;
import org.compiere.model.MDocType;
import org.compiere.model.MInOut;
import org.compiere.model.MInOutLine;
import org.compiere.model.MInvoice;
import org.compiere.model.MInvoiceLine;
import org.compiere.model.MInvoicePaySchedule;
import org.compiere.model.MInvoiceSchedule;
import org.compiere.model.MLocation;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MOrderPaySchedule;
import org.compiere.model.PO;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
@ -444,6 +448,44 @@ public class InvoiceGenerate extends SvrProcess
{
if (m_invoice != null)
{
MOrder order = new MOrder(getCtx(), m_invoice.getC_Order_ID(), get_TrxName());
if (order != null) {
m_invoice.setPaymentRule(order.getPaymentRule());
m_invoice.setC_PaymentTerm_ID(order.getC_PaymentTerm_ID());
m_invoice.saveEx();
m_invoice.load(m_invoice.get_TrxName()); // refresh from DB
// copy payment schedule from order if invoice doesn't have a current payment schedule
MOrderPaySchedule[] opss = MOrderPaySchedule.getOrderPaySchedule(getCtx(), order.getC_Order_ID(), 0, get_TrxName());
MInvoicePaySchedule[] ipss = MInvoicePaySchedule.getInvoicePaySchedule(getCtx(), m_invoice.getC_Invoice_ID(), 0, get_TrxName());
if (ipss.length == 0 && opss.length > 0) {
BigDecimal ogt = order.getGrandTotal();
BigDecimal igt = m_invoice.getGrandTotal();
BigDecimal percent = Env.ONE;
if (ogt.compareTo(igt) != 0)
percent = igt.divide(ogt, 10, BigDecimal.ROUND_HALF_UP);
MCurrency cur = MCurrency.get(order.getCtx(), order.getC_Currency_ID());
int scale = cur.getStdPrecision();
for (MOrderPaySchedule ops : opss) {
MInvoicePaySchedule ips = new MInvoicePaySchedule(getCtx(), 0, get_TrxName());
PO.copyValues(ops, ips);
if (percent != Env.ONE) {
BigDecimal propDueAmt = ops.getDueAmt().multiply(percent);
if (propDueAmt.scale() > scale)
propDueAmt = propDueAmt.setScale(scale, BigDecimal.ROUND_HALF_UP);
ips.setDueAmt(propDueAmt);
}
ips.setC_Invoice_ID(m_invoice.getC_Invoice_ID());
ips.setAD_Org_ID(ops.getAD_Org_ID());
ips.setProcessing(ops.isProcessing());
ips.setIsActive(ops.isActive());
ips.save();
}
m_invoice.validatePaySchedule();
m_invoice.saveEx();
}
}
if (!m_invoice.processIt(p_docAction))
{
log.warning("completeInvoice - failed: " + m_invoice);

View File

@ -31,7 +31,7 @@ public interface I_C_Order
public static final String Table_Name = "C_Order";
/** AD_Table_ID=259 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
public static final int Table_ID = 259;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
@ -78,17 +78,17 @@ public interface I_C_Order
/** Column name AD_User_ID */
public static final String COLUMNNAME_AD_User_ID = "AD_User_ID";
/** Set User/Contact.
/** Set Usuario.
* User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID);
/** Get User/Contact.
/** Get Usuario.
* User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID();
public I_AD_User getAD_User() throws RuntimeException;
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException;
/** Column name AmountRefunded */
public static final String COLUMNNAME_AmountRefunded = "AmountRefunded";
@ -121,7 +121,7 @@ public interface I_C_Order
*/
public int getBill_BPartner_ID();
public I_C_BPartner getBill_BPartner() throws RuntimeException;
public org.compiere.model.I_C_BPartner getBill_BPartner() throws RuntimeException;
/** Column name Bill_Location_ID */
public static final String COLUMNNAME_Bill_Location_ID = "Bill_Location_ID";
@ -136,7 +136,7 @@ public interface I_C_Order
*/
public int getBill_Location_ID();
public I_C_BPartner_Location getBill_Location() throws RuntimeException;
public org.compiere.model.I_C_BPartner_Location getBill_Location() throws RuntimeException;
/** Column name Bill_User_ID */
public static final String COLUMNNAME_Bill_User_ID = "Bill_User_ID";
@ -151,7 +151,7 @@ public interface I_C_Order
*/
public int getBill_User_ID();
public I_AD_User getBill_User() throws RuntimeException;
public org.compiere.model.I_AD_User getBill_User() throws RuntimeException;
/** Column name C_Activity_ID */
public static final String COLUMNNAME_C_Activity_ID = "C_Activity_ID";
@ -166,7 +166,7 @@ public interface I_C_Order
*/
public int getC_Activity_ID();
public I_C_Activity getC_Activity() throws RuntimeException;
public org.compiere.model.I_C_Activity getC_Activity() throws RuntimeException;
/** Column name C_BPartner_ID */
public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID";
@ -181,7 +181,7 @@ public interface I_C_Order
*/
public int getC_BPartner_ID();
public I_C_BPartner getC_BPartner() throws RuntimeException;
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException;
/** Column name C_BPartner_Location_ID */
public static final String COLUMNNAME_C_BPartner_Location_ID = "C_BPartner_Location_ID";
@ -196,7 +196,7 @@ public interface I_C_Order
*/
public int getC_BPartner_Location_ID();
public I_C_BPartner_Location getC_BPartner_Location() throws RuntimeException;
public org.compiere.model.I_C_BPartner_Location getC_BPartner_Location() throws RuntimeException;
/** Column name C_Campaign_ID */
public static final String COLUMNNAME_C_Campaign_ID = "C_Campaign_ID";
@ -211,7 +211,7 @@ public interface I_C_Order
*/
public int getC_Campaign_ID();
public I_C_Campaign getC_Campaign() throws RuntimeException;
public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException;
/** Column name C_CashLine_ID */
public static final String COLUMNNAME_C_CashLine_ID = "C_CashLine_ID";
@ -226,7 +226,7 @@ public interface I_C_Order
*/
public int getC_CashLine_ID();
public I_C_CashLine getC_CashLine() throws RuntimeException;
public org.compiere.model.I_C_CashLine getC_CashLine() throws RuntimeException;
/** Column name C_Charge_ID */
public static final String COLUMNNAME_C_Charge_ID = "C_Charge_ID";
@ -241,7 +241,7 @@ public interface I_C_Order
*/
public int getC_Charge_ID();
public I_C_Charge getC_Charge() throws RuntimeException;
public org.compiere.model.I_C_Charge getC_Charge() throws RuntimeException;
/** Column name C_ConversionType_ID */
public static final String COLUMNNAME_C_ConversionType_ID = "C_ConversionType_ID";
@ -256,7 +256,7 @@ public interface I_C_Order
*/
public int getC_ConversionType_ID();
public I_C_ConversionType getC_ConversionType() throws RuntimeException;
public org.compiere.model.I_C_ConversionType getC_ConversionType() throws RuntimeException;
/** Column name C_Currency_ID */
public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID";
@ -271,7 +271,7 @@ public interface I_C_Order
*/
public int getC_Currency_ID();
public I_C_Currency getC_Currency() throws RuntimeException;
public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException;
/** Column name C_DocType_ID */
public static final String COLUMNNAME_C_DocType_ID = "C_DocType_ID";
@ -286,7 +286,7 @@ public interface I_C_Order
*/
public int getC_DocType_ID();
public I_C_DocType getC_DocType() throws RuntimeException;
public org.compiere.model.I_C_DocType getC_DocType() throws RuntimeException;
/** Column name C_DocTypeTarget_ID */
public static final String COLUMNNAME_C_DocTypeTarget_ID = "C_DocTypeTarget_ID";
@ -301,7 +301,7 @@ public interface I_C_Order
*/
public int getC_DocTypeTarget_ID();
public I_C_DocType getC_DocTypeTarget() throws RuntimeException;
public org.compiere.model.I_C_DocType getC_DocTypeTarget() throws RuntimeException;
/** Column name ChargeAmt */
public static final String COLUMNNAME_ChargeAmt = "ChargeAmt";
@ -351,7 +351,7 @@ public interface I_C_Order
/** Get Order Source */
public int getC_OrderSource_ID();
public I_C_OrderSource getC_OrderSource() throws RuntimeException;
public org.compiere.model.I_C_OrderSource getC_OrderSource() throws RuntimeException;
/** Column name C_Payment_ID */
public static final String COLUMNNAME_C_Payment_ID = "C_Payment_ID";
@ -366,7 +366,7 @@ public interface I_C_Order
*/
public int getC_Payment_ID();
public I_C_Payment getC_Payment() throws RuntimeException;
public org.compiere.model.I_C_Payment getC_Payment() throws RuntimeException;
/** Column name C_PaymentTerm_ID */
public static final String COLUMNNAME_C_PaymentTerm_ID = "C_PaymentTerm_ID";
@ -381,7 +381,7 @@ public interface I_C_Order
*/
public int getC_PaymentTerm_ID();
public I_C_PaymentTerm getC_PaymentTerm() throws RuntimeException;
public org.compiere.model.I_C_PaymentTerm getC_PaymentTerm() throws RuntimeException;
/** Column name C_POS_ID */
public static final String COLUMNNAME_C_POS_ID = "C_POS_ID";
@ -396,7 +396,7 @@ public interface I_C_Order
*/
public int getC_POS_ID();
public I_C_POS getC_POS() throws RuntimeException;
public org.compiere.model.I_C_POS getC_POS() throws RuntimeException;
/** Column name C_Project_ID */
public static final String COLUMNNAME_C_Project_ID = "C_Project_ID";
@ -411,7 +411,7 @@ public interface I_C_Order
*/
public int getC_Project_ID();
public I_C_Project getC_Project() throws RuntimeException;
public org.compiere.model.I_C_Project getC_Project() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
@ -572,7 +572,7 @@ public interface I_C_Order
*/
public int getDropShip_BPartner_ID();
public I_C_BPartner getDropShip_BPartner() throws RuntimeException;
public org.compiere.model.I_C_BPartner getDropShip_BPartner() throws RuntimeException;
/** Column name DropShip_Location_ID */
public static final String COLUMNNAME_DropShip_Location_ID = "DropShip_Location_ID";
@ -587,7 +587,7 @@ public interface I_C_Order
*/
public int getDropShip_Location_ID();
public I_C_BPartner_Location getDropShip_Location() throws RuntimeException;
public org.compiere.model.I_C_BPartner_Location getDropShip_Location() throws RuntimeException;
/** Column name DropShip_User_ID */
public static final String COLUMNNAME_DropShip_User_ID = "DropShip_User_ID";
@ -602,7 +602,7 @@ public interface I_C_Order
*/
public int getDropShip_User_ID();
public I_AD_User getDropShip_User() throws RuntimeException;
public org.compiere.model.I_AD_User getDropShip_User() throws RuntimeException;
/** Column name FreightAmt */
public static final String COLUMNNAME_FreightAmt = "FreightAmt";
@ -743,6 +743,19 @@ public interface I_C_Order
*/
public boolean isInvoiced();
/** Column name IsPayScheduleValid */
public static final String COLUMNNAME_IsPayScheduleValid = "IsPayScheduleValid";
/** Set Pay Schedule valid.
* Is the Payment Schedule is valid
*/
public void setIsPayScheduleValid (boolean IsPayScheduleValid);
/** Get Pay Schedule valid.
* Is the Payment Schedule is valid
*/
public boolean isPayScheduleValid();
/** Column name IsPrinted */
public static final String COLUMNNAME_IsPrinted = "IsPrinted";
@ -830,7 +843,7 @@ public interface I_C_Order
*/
public int getLink_Order_ID();
public I_C_Order getLink_Order() throws RuntimeException;
public org.compiere.model.I_C_Order getLink_Order() throws RuntimeException;
/** Column name M_FreightCategory_ID */
public static final String COLUMNNAME_M_FreightCategory_ID = "M_FreightCategory_ID";
@ -845,7 +858,7 @@ public interface I_C_Order
*/
public int getM_FreightCategory_ID();
public I_M_FreightCategory getM_FreightCategory() throws RuntimeException;
public org.compiere.model.I_M_FreightCategory getM_FreightCategory() throws RuntimeException;
/** Column name M_PriceList_ID */
public static final String COLUMNNAME_M_PriceList_ID = "M_PriceList_ID";
@ -860,7 +873,7 @@ public interface I_C_Order
*/
public int getM_PriceList_ID();
public I_M_PriceList getM_PriceList() throws RuntimeException;
public org.compiere.model.I_M_PriceList getM_PriceList() throws RuntimeException;
/** Column name M_Shipper_ID */
public static final String COLUMNNAME_M_Shipper_ID = "M_Shipper_ID";
@ -875,7 +888,7 @@ public interface I_C_Order
*/
public int getM_Shipper_ID();
public I_M_Shipper getM_Shipper() throws RuntimeException;
public org.compiere.model.I_M_Shipper getM_Shipper() throws RuntimeException;
/** Column name M_Warehouse_ID */
public static final String COLUMNNAME_M_Warehouse_ID = "M_Warehouse_ID";
@ -890,7 +903,7 @@ public interface I_C_Order
*/
public int getM_Warehouse_ID();
public I_M_Warehouse getM_Warehouse() throws RuntimeException;
public org.compiere.model.I_M_Warehouse getM_Warehouse() throws RuntimeException;
/** Column name OrderType */
public static final String COLUMNNAME_OrderType = "OrderType";
@ -1044,7 +1057,7 @@ public interface I_C_Order
*/
public int getRef_Order_ID();
public I_C_Order getRef_Order() throws RuntimeException;
public org.compiere.model.I_C_Order getRef_Order() throws RuntimeException;
/** Column name SalesRep_ID */
public static final String COLUMNNAME_SalesRep_ID = "SalesRep_ID";
@ -1059,7 +1072,7 @@ public interface I_C_Order
*/
public int getSalesRep_ID();
public I_AD_User getSalesRep() throws RuntimeException;
public org.compiere.model.I_AD_User getSalesRep() throws RuntimeException;
/** Column name SendEMail */
public static final String COLUMNNAME_SendEMail = "SendEMail";
@ -1116,7 +1129,7 @@ public interface I_C_Order
*/
public int getUser1_ID();
public I_C_ElementValue getUser1() throws RuntimeException;
public org.compiere.model.I_C_ElementValue getUser1() throws RuntimeException;
/** Column name User2_ID */
public static final String COLUMNNAME_User2_ID = "User2_ID";
@ -1131,7 +1144,7 @@ public interface I_C_Order
*/
public int getUser2_ID();
public I_C_ElementValue getUser2() throws RuntimeException;
public org.compiere.model.I_C_ElementValue getUser2() throws RuntimeException;
/** Column name Volume */
public static final String COLUMNNAME_Volume = "Volume";

View File

@ -0,0 +1,235 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.util.KeyNamePair;
/** Generated Interface for C_OrderPaySchedule
* @author Adempiere (generated)
* @version Release 3.6.0LTS
*/
public interface I_C_OrderPaySchedule
{
/** TableName=C_OrderPaySchedule */
public static final String Table_Name = "C_OrderPaySchedule";
/** AD_Table_ID=53296 */
public static final int Table_ID = 53296;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 1 - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(1);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name C_Order_ID */
public static final String COLUMNNAME_C_Order_ID = "C_Order_ID";
/** Set Order.
* Order
*/
public void setC_Order_ID (int C_Order_ID);
/** Get Order.
* Order
*/
public int getC_Order_ID();
public org.compiere.model.I_C_Order getC_Order() throws RuntimeException;
/** Column name C_OrderPaySchedule_ID */
public static final String COLUMNNAME_C_OrderPaySchedule_ID = "C_OrderPaySchedule_ID";
/** Set Order Payment Schedule */
public void setC_OrderPaySchedule_ID (int C_OrderPaySchedule_ID);
/** Get Order Payment Schedule */
public int getC_OrderPaySchedule_ID();
/** Column name C_PaySchedule_ID */
public static final String COLUMNNAME_C_PaySchedule_ID = "C_PaySchedule_ID";
/** Set Payment Schedule.
* Payment Schedule Template
*/
public void setC_PaySchedule_ID (int C_PaySchedule_ID);
/** Get Payment Schedule.
* Payment Schedule Template
*/
public int getC_PaySchedule_ID();
public org.compiere.model.I_C_PaySchedule getC_PaySchedule() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name DiscountAmt */
public static final String COLUMNNAME_DiscountAmt = "DiscountAmt";
/** Set Discount Amount.
* Calculated amount of discount
*/
public void setDiscountAmt (BigDecimal DiscountAmt);
/** Get Discount Amount.
* Calculated amount of discount
*/
public BigDecimal getDiscountAmt();
/** Column name DiscountDate */
public static final String COLUMNNAME_DiscountDate = "DiscountDate";
/** Set Discount Date.
* Last Date for payments with discount
*/
public void setDiscountDate (Timestamp DiscountDate);
/** Get Discount Date.
* Last Date for payments with discount
*/
public Timestamp getDiscountDate();
/** Column name DueAmt */
public static final String COLUMNNAME_DueAmt = "DueAmt";
/** Set Amount due.
* Amount of the payment due
*/
public void setDueAmt (BigDecimal DueAmt);
/** Get Amount due.
* Amount of the payment due
*/
public BigDecimal getDueAmt();
/** Column name DueDate */
public static final String COLUMNNAME_DueDate = "DueDate";
/** Set Due Date.
* Date when the payment is due
*/
public void setDueDate (Timestamp DueDate);
/** Get Due Date.
* Date when the payment is due
*/
public Timestamp getDueDate();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name IsValid */
public static final String COLUMNNAME_IsValid = "IsValid";
/** Set Valid.
* Element is valid
*/
public void setIsValid (boolean IsValid);
/** Get Valid.
* Element is valid
*/
public boolean isValid();
/** Column name Processed */
public static final String COLUMNNAME_Processed = "Processed";
/** Set Processed.
* The document has been processed
*/
public void setProcessed (boolean Processed);
/** Get Processed.
* The document has been processed
*/
public boolean isProcessed();
/** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing";
/** Set Process Now */
public void setProcessing (boolean Processing);
/** Get Process Now */
public boolean isProcessing();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -31,7 +31,7 @@ public interface I_C_PaymentTerm
public static final String Table_Name = "C_PaymentTerm";
/** AD_Table_ID=113 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
public static final int Table_ID = 113;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
@ -338,6 +338,19 @@ public interface I_C_PaymentTerm
*/
public int getNetDays();
/** Column name PaymentTermUsage */
public static final String COLUMNNAME_PaymentTermUsage = "PaymentTermUsage";
/** Set Payment Term Usage.
* Payment term usage indicates if this payment term is used for sales, purchases or both.
*/
public void setPaymentTermUsage (String PaymentTermUsage);
/** Get Payment Term Usage.
* Payment term usage indicates if this payment term is used for sales, purchases or both.
*/
public String getPaymentTermUsage();
/** Column name Processing */
public static final String COLUMNNAME_Processing = "Processing";

View File

@ -1334,7 +1334,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid;
}
createPaySchedule();
if (!createPaySchedule())
{
m_processMsg = "@ErrorPaymentSchedule@";
return DocAction.STATUS_Invalid;
}
// Credit Status
if (isSOTrx() && !isReversal())
@ -1550,6 +1554,13 @@ public class MInvoice extends X_C_Invoice implements DocAction
return false;
MPaymentTerm pt = new MPaymentTerm(getCtx(), getC_PaymentTerm_ID(), null);
log.fine(pt.toString());
MInvoicePaySchedule[] schedule = MInvoicePaySchedule.getInvoicePaySchedule
(getCtx(), getC_Invoice_ID(), 0, get_TrxName());
if (schedule.length > 0)
return validatePaySchedule();
else
return pt.apply(this); // calls validate pay schedule
} // createPaySchedule

View File

@ -42,7 +42,6 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule
*/
private static final long serialVersionUID = -1529278048406862670L;
/**
* Get Payment Schedule of the invoice
* @param ctx context
@ -54,11 +53,11 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule
public static MInvoicePaySchedule[] getInvoicePaySchedule(Properties ctx,
int C_Invoice_ID, int C_InvoicePaySchedule_ID, String trxName)
{
String sql = "SELECT * FROM C_InvoicePaySchedule ips ";
String sql = "SELECT * FROM C_InvoicePaySchedule ips WHERE IsActive='Y' ";
if (C_Invoice_ID != 0)
sql += "WHERE C_Invoice_ID=? ";
sql += "AND C_Invoice_ID=? ";
else
sql += "WHERE EXISTS (SELECT * FROM C_InvoicePaySchedule x"
sql += "AND EXISTS (SELECT * FROM C_InvoicePaySchedule x"
+ " WHERE x.C_InvoicePaySchedule_ID=? AND ips.C_Invoice_ID=x.C_Invoice_ID) ";
sql += "ORDER BY DueDate";
//

View File

@ -69,7 +69,7 @@ public class MOrder extends X_C_Order implements DocAction
/**
*
*/
private static final long serialVersionUID = -1575104995897726572L;
private static final long serialVersionUID = -846451837699702120L;
/**
* Create new Order by copying
@ -860,6 +860,45 @@ public class MOrder extends X_C_Order implements DocAction
/**
* Validate Order Pay Schedule
* @return pay schedule is valid
*/
public boolean validatePaySchedule()
{
MOrderPaySchedule[] schedule = MOrderPaySchedule.getOrderPaySchedule
(getCtx(), getC_Order_ID(), 0, get_TrxName());
log.fine("#" + schedule.length);
if (schedule.length == 0)
{
setIsPayScheduleValid(false);
return false;
}
// Add up due amounts
BigDecimal total = Env.ZERO;
for (int i = 0; i < schedule.length; i++)
{
schedule[i].setParent(this);
BigDecimal due = schedule[i].getDueAmt();
if (due != null)
total = total.add(due);
}
boolean valid = getGrandTotal().compareTo(total) == 0;
setIsPayScheduleValid(valid);
// Update Schedule Lines
for (int i = 0; i < schedule.length; i++)
{
if (schedule[i].isValid() != valid)
{
schedule[i].setIsValid(valid);
schedule[i].save(get_TrxName());
}
}
return valid;
} // validatePaySchedule
/**************************************************************************
* Before Save
* @param newRecord new
@ -1246,6 +1285,12 @@ public class MOrder extends X_C_Order implements DocAction
return DocAction.STATUS_Invalid;
}
if (!createPaySchedule())
{
m_processMsg = "@ErrorPaymentSchedule@";
return DocAction.STATUS_Invalid;
}
// Credit Check
if (isSOTrx())
{
@ -1593,6 +1638,27 @@ public class MOrder extends X_C_Order implements DocAction
} // calculateTaxTotal
/**
* (Re) Create Pay Schedule
* @return true if valid schedule
*/
private boolean createPaySchedule()
{
if (getC_PaymentTerm_ID() == 0)
return false;
MPaymentTerm pt = new MPaymentTerm(getCtx(), getC_PaymentTerm_ID(), null);
log.fine(pt.toString());
MOrderPaySchedule[] schedule = MOrderPaySchedule.getOrderPaySchedule
(getCtx(), getC_Order_ID(), 0, get_TrxName());
if (schedule.length > 0)
return validatePaySchedule();
else
return pt.applyOrder(this); // calls validate pay schedule
} // createPaySchedule
/**
* Approve Document
* @return true if success
@ -1890,6 +1956,21 @@ public class MOrder extends X_C_Order implements DocAction
}
}
}
// Copy payment schedule from order to invoice if any
for (MOrderPaySchedule ops : MOrderPaySchedule.getOrderPaySchedule(getCtx(), getC_Order_ID(), 0, get_TrxName())) {
MInvoicePaySchedule ips = new MInvoicePaySchedule(getCtx(), 0, get_TrxName());
PO.copyValues(ops, ips);
ips.setC_Invoice_ID(invoice.getC_Invoice_ID());
ips.setAD_Org_ID(ops.getAD_Org_ID());
ips.setProcessing(ops.isProcessing());
ips.setIsActive(ops.isActive());
if (!ips.save()) {
m_processMsg = "ERROR: creating pay schedule for invoice from : "+ ops.toString();
return null;
}
}
// Manually Process Invoice
invoice.processIt(DocAction.ACTION_Complete);
invoice.saveEx(get_TrxName());

View File

@ -0,0 +1,251 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
/**
* Order Payment Schedule Model
*
* @author Jorg Janke
* @version $Id: MOrderPaySchedule.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/
public class MOrderPaySchedule extends X_C_OrderPaySchedule
{
/**
*
*/
private static final long serialVersionUID = -5506706349428999742L;
/**
* Get Payment Schedule of the Order
* @param ctx context
* @param C_Order_ID order id (direct)
* @param C_OrderPaySchedule_ID id (indirect)
* @param trxName transaction
* @return array of schedule
*/
public static MOrderPaySchedule[] getOrderPaySchedule(Properties ctx,
int C_Order_ID, int C_OrderPaySchedule_ID, String trxName)
{
String sql = "SELECT * FROM C_OrderPaySchedule ips WHERE IsActive='Y' ";
if (C_Order_ID != 0)
sql += "AND C_Order_ID=? ";
else
sql += "AND EXISTS (SELECT * FROM C_OrderPaySchedule x"
+ " WHERE x.C_OrderPaySchedule_ID=? AND ips.C_Order_ID=x.C_Order_ID) ";
sql += "ORDER BY DueDate";
//
ArrayList<MOrderPaySchedule> list = new ArrayList<MOrderPaySchedule>();
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
if (C_Order_ID != 0)
pstmt.setInt(1, C_Order_ID);
else
pstmt.setInt(1, C_OrderPaySchedule_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
list.add (new MOrderPaySchedule(ctx, rs, trxName));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "getOrderPaySchedule", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MOrderPaySchedule[] retValue = new MOrderPaySchedule[list.size()];
list.toArray(retValue);
return retValue;
} // getSchedule
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MOrderPaySchedule.class);
/** 100 */
private final static BigDecimal HUNDRED = new BigDecimal(100);
/**************************************************************************
* Standard Constructor
* @param ctx context
* @param C_OrderPaySchedule_ID id
* @param trxName transaction
*/
public MOrderPaySchedule (Properties ctx, int C_OrderPaySchedule_ID, String trxName)
{
super(ctx, C_OrderPaySchedule_ID, trxName);
if (C_OrderPaySchedule_ID == 0)
{
// setC_Order_ID (0);
// setDiscountAmt (Env.ZERO);
// setDiscountDate (new Timestamp(System.currentTimeMillis()));
// setDueAmt (Env.ZERO);
// setDueDate (new Timestamp(System.currentTimeMillis()));
setIsValid (false);
}
} // MOrderPaySchedule
/**
* Load Constructor
* @param ctx context
* @param rs result set
* @param trxName transaction
*/
public MOrderPaySchedule (Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
} // MOrderPaySchedule
/**
* Parent Constructor
* @param order order
* @param paySchedule payment schedule
*/
public MOrderPaySchedule (MOrder order, MPaySchedule paySchedule)
{
super (order.getCtx(), 0, order.get_TrxName());
m_parent = order;
setClientOrg(order);
setC_Order_ID(order.getC_Order_ID());
setC_PaySchedule_ID(paySchedule.getC_PaySchedule_ID());
// Amounts
int scale = MCurrency.getStdPrecision(getCtx(), order.getC_Currency_ID());
BigDecimal due = order.getGrandTotal();
if (due.compareTo(Env.ZERO) == 0)
{
setDueAmt (Env.ZERO);
setDiscountAmt (Env.ZERO);
setIsValid(false);
}
else
{
due = due.multiply(paySchedule.getPercentage())
.divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP);
setDueAmt (due);
BigDecimal discount = due.multiply(paySchedule.getDiscount())
.divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP);
setDiscountAmt (discount);
setIsValid(true);
}
// Dates
Timestamp dueDate = TimeUtil.addDays(order.getDateOrdered(), paySchedule.getNetDays());
setDueDate (dueDate);
Timestamp discountDate = TimeUtil.addDays(order.getDateOrdered(), paySchedule.getDiscountDays());
setDiscountDate (discountDate);
} // MOrderPaySchedule
/** Parent */
private MOrder m_parent = null;
/**
* @return Returns the parent.
*/
public MOrder getParent ()
{
if (m_parent == null)
m_parent = new MOrder (getCtx(), getC_Order_ID(), get_TrxName());
return m_parent;
} // getParent
/**
* @param parent The parent to set.
*/
public void setParent (MOrder parent)
{
m_parent = parent;
} // setParent
/**
* String Representation
* @return info
*/
public String toString()
{
StringBuffer sb = new StringBuffer("MOrderPaySchedule[");
sb.append(get_ID()).append("-Due=" + getDueDate() + "/" + getDueAmt())
.append(";Discount=").append(getDiscountDate() + "/" + getDiscountAmt())
.append("]");
return sb.toString();
} // toString
/**
* Before Save
* @param newRecord new
* @return true
*/
protected boolean beforeSave (boolean newRecord)
{
if (is_ValueChanged("DueAmt"))
{
log.fine("beforeSave");
setIsValid(false);
}
return true;
} // beforeSave
/**
* After Save
* @param newRecord new
* @param success success
* @return success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (is_ValueChanged("DueAmt"))
{
log.fine("afterSave");
getParent();
m_parent.validatePaySchedule();
m_parent.save();
}
return success;
} // afterSave
} // MOrderPaySchedule

View File

@ -40,11 +40,10 @@ import org.compiere.util.Msg;
*/
public class MPaymentTerm extends X_C_PaymentTerm
{
/**
*
*/
private static final long serialVersionUID = 2494915482340569386L;
private static final long serialVersionUID = -4506224598566445450L;
/**
* Standard Constructor
@ -145,17 +144,17 @@ public class MPaymentTerm extends X_C_PaymentTerm
setIsValid(true);
return "@OK@";
}
if (m_schedule.length == 1)
{
if (isValid())
setIsValid(false);
if (m_schedule[0].isValid())
{
m_schedule[0].setIsValid(false);
m_schedule[0].save();
}
return "@Invalid@ @Count@ # = 1 (@C_PaySchedule_ID@)";
}
// Allow schedules with just one record
// if (m_schedule.length == 1)
// {
// setIsValid(false);
// if (m_schedule[0].isValid())
// {
// m_schedule[0].setIsValid(false);
// m_schedule[0].save();
// }
// return "@Invalid@ @Count@ # = 1 (@C_PaySchedule_ID@)";
// }
// Add up
BigDecimal total = Env.ZERO;
@ -216,7 +215,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
return applyNoSchedule (invoice);
//
getSchedule(true);
if (m_schedule.length <= 1)
if (m_schedule.length <= 0) // Allow schedules with just one record
return applyNoSchedule (invoice);
else // only if valid
return applySchedule(invoice);
@ -225,7 +224,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
/**
* Apply Payment Term without schedule to Invoice
* @param invoice invoice
* @return false as no payment schedule
* @return true as no payment schedule
*/
private boolean applyNoSchedule (MInvoice invoice)
{
@ -235,7 +234,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
invoice.setC_PaymentTerm_ID(getC_PaymentTerm_ID());
if (invoice.isPayScheduleValid())
invoice.setIsPayScheduleValid(false);
return false;
return true;
} // applyNoSchedule
/**
@ -283,6 +282,106 @@ public class MPaymentTerm extends X_C_PaymentTerm
} // deleteInvoicePaySchedule
/*************************************************************************
* Apply Payment Term to Order -
* @param C_Order_ID order
* @return true if payment schedule is valid
*/
public boolean applyOrder (int C_Order_ID)
{
MOrder order = new MOrder (getCtx(), C_Order_ID, get_TrxName());
if (order == null || order.get_ID() == 0)
{
log.log(Level.SEVERE, "apply - Not valid C_Order_ID=" + C_Order_ID);
return false;
}
return applyOrder (order);
} // applyOrder
/**
* Apply Payment Term to Order
* @param order order
* @return true if payment schedule is valid
*/
public boolean applyOrder (MOrder order)
{
if (order == null || order.get_ID() == 0)
{
log.log(Level.SEVERE, "No valid order - " + order);
return false;
}
if (!isValid())
return applyOrderNoSchedule (order);
//
getSchedule(true);
if (m_schedule.length <= 0) // Allow schedules with just one record
return applyOrderNoSchedule (order);
else // only if valid
return applyOrderSchedule(order);
} // applyOrder
/**
* Apply Payment Term without schedule to Order
* @param order order
* @return true as no payment schedule
*/
private boolean applyOrderNoSchedule (MOrder order)
{
deleteOrderPaySchedule (order.getC_Order_ID(), order.get_TrxName());
// updateOrder
if (order.getC_PaymentTerm_ID() != getC_PaymentTerm_ID())
order.setC_PaymentTerm_ID(getC_PaymentTerm_ID());
if (order.isPayScheduleValid())
order.setIsPayScheduleValid(false);
return true;
} // applyOrderNoSchedule
/**
* Apply Payment Term with schedule to Order
* @param order order
* @return true if payment schedule is valid
*/
private boolean applyOrderSchedule (MOrder order)
{
deleteOrderPaySchedule (order.getC_Order_ID(), order.get_TrxName());
// Create Schedule
MOrderPaySchedule ops = null;
BigDecimal remainder = order.getGrandTotal();
for (int i = 0; i < m_schedule.length; i++)
{
ops = new MOrderPaySchedule (order, m_schedule[i]);
ops.save(order.get_TrxName());
log.fine(ops.toString());
remainder = remainder.subtract(ops.getDueAmt());
} // for all schedules
// Remainder - update last
if (remainder.compareTo(Env.ZERO) != 0 && ops != null)
{
ops.setDueAmt(ops.getDueAmt().add(remainder));
ops.save(order.get_TrxName());
log.fine("Remainder=" + remainder + " - " + ops);
}
// updateOrder
if (order.getC_PaymentTerm_ID() != getC_PaymentTerm_ID())
order.setC_PaymentTerm_ID(getC_PaymentTerm_ID());
return order.validatePaySchedule();
} // applyOrderSchedule
/**
* Delete existing Order Payment Schedule
* @param C_Order_ID id
* @param trxName transaction
*/
private void deleteOrderPaySchedule (int C_Order_ID, String trxName)
{
String sql = "DELETE C_OrderPaySchedule WHERE C_Order_ID=" + C_Order_ID;
int no = DB.executeUpdate(sql, trxName);
log.fine("C_Order_ID=" + C_Order_ID + " - #" + no);
} // deleteOrderPaySchedule
/**************************************************************************
* String Representation
* @return info

View File

@ -33,7 +33,7 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20100614L;
private static final long serialVersionUID = 20110325L;
/** Standard Constructor */
public X_C_Order (Properties ctx, int C_Order_ID, String trxName)
@ -79,6 +79,8 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
setIsDropShip (false);
// N
setIsInvoiced (false);
setIsPayScheduleValid (false);
// N
setIsPrinted (false);
setIsSelected (false);
setIsSelfService (false);
@ -152,12 +154,12 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_AD_User getAD_User() throws RuntimeException
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException
{
return (I_AD_User)MTable.get(getCtx(), I_AD_User.Table_Name)
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getAD_User_ID(), get_TrxName()); }
/** Set User/Contact.
/** Set Usuario.
@param AD_User_ID
User within the system - Internal or Business Partner Contact
*/
@ -169,7 +171,7 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
}
/** Get User/Contact.
/** Get Usuario.
@return User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID ()
@ -214,9 +216,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return bd;
}
public I_C_BPartner getBill_BPartner() throws RuntimeException
public org.compiere.model.I_C_BPartner getBill_BPartner() throws RuntimeException
{
return (I_C_BPartner)MTable.get(getCtx(), I_C_BPartner.Table_Name)
return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name)
.getPO(getBill_BPartner_ID(), get_TrxName()); }
/** Set Invoice Partner.
@ -242,9 +244,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_BPartner_Location getBill_Location() throws RuntimeException
public org.compiere.model.I_C_BPartner_Location getBill_Location() throws RuntimeException
{
return (I_C_BPartner_Location)MTable.get(getCtx(), I_C_BPartner_Location.Table_Name)
return (org.compiere.model.I_C_BPartner_Location)MTable.get(getCtx(), org.compiere.model.I_C_BPartner_Location.Table_Name)
.getPO(getBill_Location_ID(), get_TrxName()); }
/** Set Invoice Location.
@ -270,9 +272,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_AD_User getBill_User() throws RuntimeException
public org.compiere.model.I_AD_User getBill_User() throws RuntimeException
{
return (I_AD_User)MTable.get(getCtx(), I_AD_User.Table_Name)
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getBill_User_ID(), get_TrxName()); }
/** Set Invoice Contact.
@ -298,9 +300,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_Activity getC_Activity() throws RuntimeException
public org.compiere.model.I_C_Activity getC_Activity() throws RuntimeException
{
return (I_C_Activity)MTable.get(getCtx(), I_C_Activity.Table_Name)
return (org.compiere.model.I_C_Activity)MTable.get(getCtx(), org.compiere.model.I_C_Activity.Table_Name)
.getPO(getC_Activity_ID(), get_TrxName()); }
/** Set Activity.
@ -326,9 +328,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_BPartner getC_BPartner() throws RuntimeException
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException
{
return (I_C_BPartner)MTable.get(getCtx(), I_C_BPartner.Table_Name)
return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name)
.getPO(getC_BPartner_ID(), get_TrxName()); }
/** Set Business Partner .
@ -354,9 +356,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_BPartner_Location getC_BPartner_Location() throws RuntimeException
public org.compiere.model.I_C_BPartner_Location getC_BPartner_Location() throws RuntimeException
{
return (I_C_BPartner_Location)MTable.get(getCtx(), I_C_BPartner_Location.Table_Name)
return (org.compiere.model.I_C_BPartner_Location)MTable.get(getCtx(), org.compiere.model.I_C_BPartner_Location.Table_Name)
.getPO(getC_BPartner_Location_ID(), get_TrxName()); }
/** Set Partner Location.
@ -382,9 +384,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_Campaign getC_Campaign() throws RuntimeException
public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException
{
return (I_C_Campaign)MTable.get(getCtx(), I_C_Campaign.Table_Name)
return (org.compiere.model.I_C_Campaign)MTable.get(getCtx(), org.compiere.model.I_C_Campaign.Table_Name)
.getPO(getC_Campaign_ID(), get_TrxName()); }
/** Set Campaign.
@ -410,9 +412,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_CashLine getC_CashLine() throws RuntimeException
public org.compiere.model.I_C_CashLine getC_CashLine() throws RuntimeException
{
return (I_C_CashLine)MTable.get(getCtx(), I_C_CashLine.Table_Name)
return (org.compiere.model.I_C_CashLine)MTable.get(getCtx(), org.compiere.model.I_C_CashLine.Table_Name)
.getPO(getC_CashLine_ID(), get_TrxName()); }
/** Set Cash Journal Line.
@ -438,9 +440,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_Charge getC_Charge() throws RuntimeException
public org.compiere.model.I_C_Charge getC_Charge() throws RuntimeException
{
return (I_C_Charge)MTable.get(getCtx(), I_C_Charge.Table_Name)
return (org.compiere.model.I_C_Charge)MTable.get(getCtx(), org.compiere.model.I_C_Charge.Table_Name)
.getPO(getC_Charge_ID(), get_TrxName()); }
/** Set Charge.
@ -466,9 +468,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_ConversionType getC_ConversionType() throws RuntimeException
public org.compiere.model.I_C_ConversionType getC_ConversionType() throws RuntimeException
{
return (I_C_ConversionType)MTable.get(getCtx(), I_C_ConversionType.Table_Name)
return (org.compiere.model.I_C_ConversionType)MTable.get(getCtx(), org.compiere.model.I_C_ConversionType.Table_Name)
.getPO(getC_ConversionType_ID(), get_TrxName()); }
/** Set Currency Type.
@ -494,9 +496,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_Currency getC_Currency() throws RuntimeException
public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException
{
return (I_C_Currency)MTable.get(getCtx(), I_C_Currency.Table_Name)
return (org.compiere.model.I_C_Currency)MTable.get(getCtx(), org.compiere.model.I_C_Currency.Table_Name)
.getPO(getC_Currency_ID(), get_TrxName()); }
/** Set Currency.
@ -522,9 +524,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_DocType getC_DocType() throws RuntimeException
public org.compiere.model.I_C_DocType getC_DocType() throws RuntimeException
{
return (I_C_DocType)MTable.get(getCtx(), I_C_DocType.Table_Name)
return (org.compiere.model.I_C_DocType)MTable.get(getCtx(), org.compiere.model.I_C_DocType.Table_Name)
.getPO(getC_DocType_ID(), get_TrxName()); }
/** Set Document Type.
@ -550,9 +552,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_DocType getC_DocTypeTarget() throws RuntimeException
public org.compiere.model.I_C_DocType getC_DocTypeTarget() throws RuntimeException
{
return (I_C_DocType)MTable.get(getCtx(), I_C_DocType.Table_Name)
return (org.compiere.model.I_C_DocType)MTable.get(getCtx(), org.compiere.model.I_C_DocType.Table_Name)
.getPO(getC_DocTypeTarget_ID(), get_TrxName()); }
/** Set Target Document Type.
@ -638,9 +640,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_OrderSource getC_OrderSource() throws RuntimeException
public org.compiere.model.I_C_OrderSource getC_OrderSource() throws RuntimeException
{
return (I_C_OrderSource)MTable.get(getCtx(), I_C_OrderSource.Table_Name)
return (org.compiere.model.I_C_OrderSource)MTable.get(getCtx(), org.compiere.model.I_C_OrderSource.Table_Name)
.getPO(getC_OrderSource_ID(), get_TrxName()); }
/** Set Order Source.
@ -663,9 +665,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_Payment getC_Payment() throws RuntimeException
public org.compiere.model.I_C_Payment getC_Payment() throws RuntimeException
{
return (I_C_Payment)MTable.get(getCtx(), I_C_Payment.Table_Name)
return (org.compiere.model.I_C_Payment)MTable.get(getCtx(), org.compiere.model.I_C_Payment.Table_Name)
.getPO(getC_Payment_ID(), get_TrxName()); }
/** Set Payment.
@ -691,9 +693,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_PaymentTerm getC_PaymentTerm() throws RuntimeException
public org.compiere.model.I_C_PaymentTerm getC_PaymentTerm() throws RuntimeException
{
return (I_C_PaymentTerm)MTable.get(getCtx(), I_C_PaymentTerm.Table_Name)
return (org.compiere.model.I_C_PaymentTerm)MTable.get(getCtx(), org.compiere.model.I_C_PaymentTerm.Table_Name)
.getPO(getC_PaymentTerm_ID(), get_TrxName()); }
/** Set Payment Term.
@ -719,9 +721,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_POS getC_POS() throws RuntimeException
public org.compiere.model.I_C_POS getC_POS() throws RuntimeException
{
return (I_C_POS)MTable.get(getCtx(), I_C_POS.Table_Name)
return (org.compiere.model.I_C_POS)MTable.get(getCtx(), org.compiere.model.I_C_POS.Table_Name)
.getPO(getC_POS_ID(), get_TrxName()); }
/** Set POS Terminal.
@ -747,9 +749,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_Project getC_Project() throws RuntimeException
public org.compiere.model.I_C_Project getC_Project() throws RuntimeException
{
return (I_C_Project)MTable.get(getCtx(), I_C_Project.Table_Name)
return (org.compiere.model.I_C_Project)MTable.get(getCtx(), org.compiere.model.I_C_Project.Table_Name)
.getPO(getC_Project_ID(), get_TrxName()); }
/** Set Project.
@ -1035,9 +1037,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return new KeyNamePair(get_ID(), getDocumentNo());
}
public I_C_BPartner getDropShip_BPartner() throws RuntimeException
public org.compiere.model.I_C_BPartner getDropShip_BPartner() throws RuntimeException
{
return (I_C_BPartner)MTable.get(getCtx(), I_C_BPartner.Table_Name)
return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name)
.getPO(getDropShip_BPartner_ID(), get_TrxName()); }
/** Set Drop Shipment Partner.
@ -1063,9 +1065,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_BPartner_Location getDropShip_Location() throws RuntimeException
public org.compiere.model.I_C_BPartner_Location getDropShip_Location() throws RuntimeException
{
return (I_C_BPartner_Location)MTable.get(getCtx(), I_C_BPartner_Location.Table_Name)
return (org.compiere.model.I_C_BPartner_Location)MTable.get(getCtx(), org.compiere.model.I_C_BPartner_Location.Table_Name)
.getPO(getDropShip_Location_ID(), get_TrxName()); }
/** Set Drop Shipment Location.
@ -1091,9 +1093,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_AD_User getDropShip_User() throws RuntimeException
public org.compiere.model.I_AD_User getDropShip_User() throws RuntimeException
{
return (I_AD_User)MTable.get(getCtx(), I_AD_User.Table_Name)
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getDropShip_User_ID(), get_TrxName()); }
/** Set Drop Shipment Contact.
@ -1356,6 +1358,30 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return false;
}
/** Set Pay Schedule valid.
@param IsPayScheduleValid
Is the Payment Schedule is valid
*/
public void setIsPayScheduleValid (boolean IsPayScheduleValid)
{
set_Value (COLUMNNAME_IsPayScheduleValid, Boolean.valueOf(IsPayScheduleValid));
}
/** Get Pay Schedule valid.
@return Is the Payment Schedule is valid
*/
public boolean isPayScheduleValid ()
{
Object oo = get_Value(COLUMNNAME_IsPayScheduleValid);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Printed.
@param IsPrinted
Indicates if this document / line is printed
@ -1497,9 +1523,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return false;
}
public I_C_Order getLink_Order() throws RuntimeException
public org.compiere.model.I_C_Order getLink_Order() throws RuntimeException
{
return (I_C_Order)MTable.get(getCtx(), I_C_Order.Table_Name)
return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_Name)
.getPO(getLink_Order_ID(), get_TrxName()); }
/** Set Linked Order.
@ -1525,9 +1551,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_M_FreightCategory getM_FreightCategory() throws RuntimeException
public org.compiere.model.I_M_FreightCategory getM_FreightCategory() throws RuntimeException
{
return (I_M_FreightCategory)MTable.get(getCtx(), I_M_FreightCategory.Table_Name)
return (org.compiere.model.I_M_FreightCategory)MTable.get(getCtx(), org.compiere.model.I_M_FreightCategory.Table_Name)
.getPO(getM_FreightCategory_ID(), get_TrxName()); }
/** Set Freight Category.
@ -1553,9 +1579,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_M_PriceList getM_PriceList() throws RuntimeException
public org.compiere.model.I_M_PriceList getM_PriceList() throws RuntimeException
{
return (I_M_PriceList)MTable.get(getCtx(), I_M_PriceList.Table_Name)
return (org.compiere.model.I_M_PriceList)MTable.get(getCtx(), org.compiere.model.I_M_PriceList.Table_Name)
.getPO(getM_PriceList_ID(), get_TrxName()); }
/** Set Price List.
@ -1581,9 +1607,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_M_Shipper getM_Shipper() throws RuntimeException
public org.compiere.model.I_M_Shipper getM_Shipper() throws RuntimeException
{
return (I_M_Shipper)MTable.get(getCtx(), I_M_Shipper.Table_Name)
return (org.compiere.model.I_M_Shipper)MTable.get(getCtx(), org.compiere.model.I_M_Shipper.Table_Name)
.getPO(getM_Shipper_ID(), get_TrxName()); }
/** Set Shipper.
@ -1609,9 +1635,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_M_Warehouse getM_Warehouse() throws RuntimeException
public org.compiere.model.I_M_Warehouse getM_Warehouse() throws RuntimeException
{
return (I_M_Warehouse)MTable.get(getCtx(), I_M_Warehouse.Table_Name)
return (org.compiere.model.I_M_Warehouse)MTable.get(getCtx(), org.compiere.model.I_M_Warehouse.Table_Name)
.getPO(getM_Warehouse_ID(), get_TrxName()); }
/** Set Warehouse.
@ -1887,9 +1913,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return (String)get_Value(COLUMNNAME_PromotionCode);
}
public I_C_Order getRef_Order() throws RuntimeException
public org.compiere.model.I_C_Order getRef_Order() throws RuntimeException
{
return (I_C_Order)MTable.get(getCtx(), I_C_Order.Table_Name)
return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_Name)
.getPO(getRef_Order_ID(), get_TrxName()); }
/** Set Referenced Order.
@ -1915,9 +1941,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_AD_User getSalesRep() throws RuntimeException
public org.compiere.model.I_AD_User getSalesRep() throws RuntimeException
{
return (I_AD_User)MTable.get(getCtx(), I_AD_User.Table_Name)
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getSalesRep_ID(), get_TrxName()); }
/** Set Sales Representative.
@ -1987,9 +2013,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return bd;
}
public I_C_ElementValue getUser1() throws RuntimeException
public org.compiere.model.I_C_ElementValue getUser1() throws RuntimeException
{
return (I_C_ElementValue)MTable.get(getCtx(), I_C_ElementValue.Table_Name)
return (org.compiere.model.I_C_ElementValue)MTable.get(getCtx(), org.compiere.model.I_C_ElementValue.Table_Name)
.getPO(getUser1_ID(), get_TrxName()); }
/** Set User List 1.
@ -2015,9 +2041,9 @@ public class X_C_Order extends PO implements I_C_Order, I_Persistent
return ii.intValue();
}
public I_C_ElementValue getUser2() throws RuntimeException
public org.compiere.model.I_C_ElementValue getUser2() throws RuntimeException
{
return (I_C_ElementValue)MTable.get(getCtx(), I_C_ElementValue.Table_Name)
return (org.compiere.model.I_C_ElementValue)MTable.get(getCtx(), org.compiere.model.I_C_ElementValue.Table_Name)
.getPO(getUser2_ID(), get_TrxName()); }
/** Set User List 2.

View File

@ -0,0 +1,309 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
/** Generated Model for C_OrderPaySchedule
* @author Adempiere (generated)
* @version Release 3.6.0LTS - $Id$ */
public class X_C_OrderPaySchedule extends PO implements I_C_OrderPaySchedule, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20110325L;
/** Standard Constructor */
public X_C_OrderPaySchedule (Properties ctx, int C_OrderPaySchedule_ID, String trxName)
{
super (ctx, C_OrderPaySchedule_ID, trxName);
/** if (C_OrderPaySchedule_ID == 0)
{
setC_Order_ID (0);
setC_OrderPaySchedule_ID (0);
setDiscountAmt (Env.ZERO);
setDiscountDate (new Timestamp( System.currentTimeMillis() ));
setDueAmt (Env.ZERO);
setDueDate (new Timestamp( System.currentTimeMillis() ));
setIsValid (false);
setProcessed (false);
} */
}
/** Load Constructor */
public X_C_OrderPaySchedule (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 1 - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_C_OrderPaySchedule[")
.append(get_ID()).append("]");
return sb.toString();
}
public org.compiere.model.I_C_Order getC_Order() throws RuntimeException
{
return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_Name)
.getPO(getC_Order_ID(), get_TrxName()); }
/** Set Order.
@param C_Order_ID
Order
*/
public void setC_Order_ID (int C_Order_ID)
{
if (C_Order_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_Order_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_Order_ID, Integer.valueOf(C_Order_ID));
}
/** Get Order.
@return Order
*/
public int getC_Order_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_Order_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Order Payment Schedule.
@param C_OrderPaySchedule_ID Order Payment Schedule */
public void setC_OrderPaySchedule_ID (int C_OrderPaySchedule_ID)
{
if (C_OrderPaySchedule_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_OrderPaySchedule_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_OrderPaySchedule_ID, Integer.valueOf(C_OrderPaySchedule_ID));
}
/** Get Order Payment Schedule.
@return Order Payment Schedule */
public int getC_OrderPaySchedule_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_OrderPaySchedule_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_PaySchedule getC_PaySchedule() throws RuntimeException
{
return (org.compiere.model.I_C_PaySchedule)MTable.get(getCtx(), org.compiere.model.I_C_PaySchedule.Table_Name)
.getPO(getC_PaySchedule_ID(), get_TrxName()); }
/** Set Payment Schedule.
@param C_PaySchedule_ID
Payment Schedule Template
*/
public void setC_PaySchedule_ID (int C_PaySchedule_ID)
{
if (C_PaySchedule_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_PaySchedule_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_PaySchedule_ID, Integer.valueOf(C_PaySchedule_ID));
}
/** Get Payment Schedule.
@return Payment Schedule Template
*/
public int getC_PaySchedule_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_PaySchedule_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Discount Amount.
@param DiscountAmt
Calculated amount of discount
*/
public void setDiscountAmt (BigDecimal DiscountAmt)
{
set_Value (COLUMNNAME_DiscountAmt, DiscountAmt);
}
/** Get Discount Amount.
@return Calculated amount of discount
*/
public BigDecimal getDiscountAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_DiscountAmt);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Discount Date.
@param DiscountDate
Last Date for payments with discount
*/
public void setDiscountDate (Timestamp DiscountDate)
{
set_Value (COLUMNNAME_DiscountDate, DiscountDate);
}
/** Get Discount Date.
@return Last Date for payments with discount
*/
public Timestamp getDiscountDate ()
{
return (Timestamp)get_Value(COLUMNNAME_DiscountDate);
}
/** Get Record ID/ColumnName
@return ID/ColumnName pair
*/
public KeyNamePair getKeyNamePair()
{
return new KeyNamePair(get_ID(), String.valueOf(getDiscountDate()));
}
/** Set Amount due.
@param DueAmt
Amount of the payment due
*/
public void setDueAmt (BigDecimal DueAmt)
{
set_Value (COLUMNNAME_DueAmt, DueAmt);
}
/** Get Amount due.
@return Amount of the payment due
*/
public BigDecimal getDueAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_DueAmt);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Due Date.
@param DueDate
Date when the payment is due
*/
public void setDueDate (Timestamp DueDate)
{
set_Value (COLUMNNAME_DueDate, DueDate);
}
/** Get Due Date.
@return Date when the payment is due
*/
public Timestamp getDueDate ()
{
return (Timestamp)get_Value(COLUMNNAME_DueDate);
}
/** Set Valid.
@param IsValid
Element is valid
*/
public void setIsValid (boolean IsValid)
{
set_Value (COLUMNNAME_IsValid, Boolean.valueOf(IsValid));
}
/** Get Valid.
@return Element is valid
*/
public boolean isValid ()
{
Object oo = get_Value(COLUMNNAME_IsValid);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Processed.
@param Processed
The document has been processed
*/
public void setProcessed (boolean Processed)
{
set_Value (COLUMNNAME_Processed, Boolean.valueOf(Processed));
}
/** Get Processed.
@return The document has been processed
*/
public boolean isProcessed ()
{
Object oo = get_Value(COLUMNNAME_Processed);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Process Now.
@param Processing Process Now */
public void setProcessing (boolean Processing)
{
set_Value (COLUMNNAME_Processing, Boolean.valueOf(Processing));
}
/** Get Process Now.
@return Process Now */
public boolean isProcessing ()
{
Object oo = get_Value(COLUMNNAME_Processing);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
}

View File

@ -32,7 +32,7 @@ public class X_C_PaymentTerm extends PO implements I_C_PaymentTerm, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20100614L;
private static final long serialVersionUID = 20110325L;
/** Standard Constructor */
public X_C_PaymentTerm (Properties ctx, int C_PaymentTerm_ID, String trxName)
@ -51,6 +51,8 @@ public class X_C_PaymentTerm extends PO implements I_C_PaymentTerm, I_Persistent
setIsValid (false);
setName (null);
setNetDays (0);
setPaymentTermUsage (null);
// B
setValue (null);
} */
}
@ -499,6 +501,32 @@ public class X_C_PaymentTerm extends PO implements I_C_PaymentTerm, I_Persistent
return ii.intValue();
}
/** PaymentTermUsage AD_Reference_ID=53382 */
public static final int PAYMENTTERMUSAGE_AD_Reference_ID=53382;
/** Both = B */
public static final String PAYMENTTERMUSAGE_Both = "B";
/** Sales = S */
public static final String PAYMENTTERMUSAGE_Sales = "S";
/** Purchases = P */
public static final String PAYMENTTERMUSAGE_Purchases = "P";
/** Set Payment Term Usage.
@param PaymentTermUsage
Payment term usage indicates if this payment term is used for sales, purchases or both.
*/
public void setPaymentTermUsage (String PaymentTermUsage)
{
set_Value (COLUMNNAME_PaymentTermUsage, PaymentTermUsage);
}
/** Get Payment Term Usage.
@return Payment term usage indicates if this payment term is used for sales, purchases or both.
*/
public String getPaymentTermUsage ()
{
return (String)get_Value(COLUMNNAME_PaymentTermUsage);
}
/** Set Process Now.
@param Processing Process Now */
public void setProcessing (boolean Processing)

View File

@ -0,0 +1,94 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.process;
import java.math.BigDecimal;
import java.util.logging.Level;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderPaySchedule;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* Validate Order Payment Schedule
*
* @author Carlos Ruiz - GlobalQSS
*/
public class OrderPayScheduleValidate extends SvrProcess
{
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare()
{
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
}
} // prepare
/**
* Perform process.
* @return Message (clear text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception
{
log.info ("C_OrderPaySchedule_ID=" + getRecord_ID());
MOrderPaySchedule[] schedule = MOrderPaySchedule.getOrderPaySchedule
(getCtx(), 0, getRecord_ID(), null);
if (schedule.length == 0)
throw new IllegalArgumentException("OrderPayScheduleValidate - No Schedule");
// Get Order
MOrder order = new MOrder (getCtx(), schedule[0].getC_Order_ID(), null);
if (order.get_ID() == 0)
throw new IllegalArgumentException("OrderPayScheduleValidate - No Order");
//
BigDecimal total = Env.ZERO;
for (int i = 0; i < schedule.length; i++)
{
BigDecimal due = schedule[i].getDueAmt();
if (due != null)
total = total.add(due);
}
boolean valid = order.getGrandTotal().compareTo(total) == 0;
order.setIsPayScheduleValid(valid);
order.save();
// Schedule
for (int i = 0; i < schedule.length; i++)
{
if (schedule[i].isValid() != valid)
{
schedule[i].setIsValid(valid);
schedule[i].save();
}
}
String msg = "@OK@";
if (!valid)
msg = "@GrandTotal@ = " + order.getGrandTotal()
+ " <> @Total@ = " + total
+ " - @Difference@ = " + order.getGrandTotal().subtract(total);
return Msg.parseTranslation(getCtx(), msg);
} // doIt
} // OrderPayScheduleValidate

View File

@ -23,16 +23,20 @@ import java.util.logging.Level;
import org.compiere.minigrid.IMiniTable;
import org.compiere.model.GridTab;
import org.compiere.model.MCurrency;
import org.compiere.model.MInOut;
import org.compiere.model.MInOutLine;
import org.compiere.model.MInvoice;
import org.compiere.model.MInvoiceLine;
import org.compiere.model.MInvoicePaySchedule;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MOrderPaySchedule;
import org.compiere.model.MProduct;
import org.compiere.model.MRMA;
import org.compiere.model.MRMALine;
import org.compiere.model.MUOMConversion;
import org.compiere.model.PO;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
@ -535,6 +539,43 @@ public class CreateFromInvoice extends CreateFrom
} // if selected
} // for all rows
if (p_order != null) {
invoice.setPaymentRule(p_order.getPaymentRule());
invoice.setC_PaymentTerm_ID(p_order.getC_PaymentTerm_ID());
invoice.saveEx();
invoice.load(invoice.get_TrxName()); // refresh from DB
// copy payment schedule from order if invoice doesn't have a current payment schedule
MOrderPaySchedule[] opss = MOrderPaySchedule.getOrderPaySchedule(invoice.getCtx(), p_order.getC_Order_ID(), 0, invoice.get_TrxName());
MInvoicePaySchedule[] ipss = MInvoicePaySchedule.getInvoicePaySchedule(invoice.getCtx(), invoice.getC_Invoice_ID(), 0, invoice.get_TrxName());
if (ipss.length == 0 && opss.length > 0) {
BigDecimal ogt = p_order.getGrandTotal();
BigDecimal igt = invoice.getGrandTotal();
BigDecimal percent = Env.ONE;
if (ogt.compareTo(igt) != 0)
percent = igt.divide(ogt, 10, BigDecimal.ROUND_HALF_UP);
MCurrency cur = MCurrency.get(p_order.getCtx(), p_order.getC_Currency_ID());
int scale = cur.getStdPrecision();
for (MOrderPaySchedule ops : opss) {
MInvoicePaySchedule ips = new MInvoicePaySchedule(invoice.getCtx(), 0, invoice.get_TrxName());
PO.copyValues(ops, ips);
if (percent != Env.ONE) {
BigDecimal propDueAmt = ops.getDueAmt().multiply(percent);
if (propDueAmt.scale() > scale)
propDueAmt = propDueAmt.setScale(scale, BigDecimal.ROUND_HALF_UP);
ips.setDueAmt(propDueAmt);
}
ips.setC_Invoice_ID(invoice.getC_Invoice_ID());
ips.setAD_Org_ID(ops.getAD_Org_ID());
ips.setProcessing(ops.isProcessing());
ips.setIsActive(ops.isActive());
ips.saveEx();
}
invoice.validatePaySchedule();
invoice.saveEx();
}
}
return true;
} // saveInvoice