FR [ 1804068 ] Make Dunning (More) Usable

FR [ 1799601 ] Dunning Block/Delay
This commit is contained in:
kthiemann 2007-11-01 12:47:59 +00:00
parent 1aeeaeed8d
commit 14ffcb8bf0
10 changed files with 3613 additions and 2599 deletions

View File

@ -32,14 +32,12 @@
**********************************************************************/
package org.compiere.model;
import java.util.*;
import java.sql.Timestamp;
import java.math.*;
import org.compiere.util.*;
import java.math.BigDecimal;
import org.compiere.util.KeyNamePair;
/** Generated Interface for C_DunningRunLine
* @author Trifon Trifonov (generated)
* @version Release 3.3.0 - 2007-08-24 11:39:40.156
* @version Release 3.3.0
*/
public interface I_C_DunningRunLine
{
@ -54,7 +52,7 @@ import org.compiere.util.*;
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = new BigDecimal(3);
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
@ -84,7 +82,7 @@ import org.compiere.util.*;
*/
public int getC_DunningRunEntry_ID();
public I_C_DunningRunEntry getI_C_DunningRunEntry() throws Exception;
public I_C_DunningRunEntry getC_DunningRunEntry() throws Exception;
/** Column name C_DunningRunLine_ID */
public static final String COLUMNNAME_C_DunningRunLine_ID = "C_DunningRunLine_ID";
@ -99,6 +97,21 @@ import org.compiere.util.*;
*/
public int getC_DunningRunLine_ID();
/** Column name C_InvoicePaySchedule_ID */
public static final String COLUMNNAME_C_InvoicePaySchedule_ID = "C_InvoicePaySchedule_ID";
/** Set Invoice Payment Schedule.
* Invoice Payment Schedule
*/
public void setC_InvoicePaySchedule_ID (int C_InvoicePaySchedule_ID);
/** Get Invoice Payment Schedule.
* Invoice Payment Schedule
*/
public int getC_InvoicePaySchedule_ID();
public I_C_InvoicePaySchedule getC_InvoicePaySchedule() throws Exception;
/** Column name C_Invoice_ID */
public static final String COLUMNNAME_C_Invoice_ID = "C_Invoice_ID";

View File

@ -32,14 +32,13 @@
**********************************************************************/
package org.compiere.model;
import java.util.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.math.*;
import org.compiere.util.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for C_Invoice
* @author Trifon Trifonov (generated)
* @version Release 3.3.0 - 2007-08-24 11:39:40.375
* @version Release 3.3.0
*/
public interface I_C_Invoice
{
@ -54,7 +53,7 @@ import org.compiere.util.*;
/** AccessLevel = 1 - Org
*/
BigDecimal accessLevel = new BigDecimal(1);
BigDecimal accessLevel = BigDecimal.valueOf(1);
/** Load Meta Data */
@ -84,7 +83,7 @@ import org.compiere.util.*;
*/
public int getAD_User_ID();
public I_AD_User getI_AD_User() throws Exception;
public I_AD_User getAD_User() throws Exception;
/** Column name C_Activity_ID */
public static final String COLUMNNAME_C_Activity_ID = "C_Activity_ID";
@ -99,7 +98,7 @@ import org.compiere.util.*;
*/
public int getC_Activity_ID();
public I_C_Activity getI_C_Activity() throws Exception;
public I_C_Activity getC_Activity() throws Exception;
/** Column name C_BPartner_ID */
public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID";
@ -127,7 +126,7 @@ import org.compiere.util.*;
*/
public int getC_BPartner_Location_ID();
public I_C_BPartner_Location getI_C_BPartner_Location() throws Exception;
public I_C_BPartner_Location getC_BPartner_Location() throws Exception;
/** Column name C_Campaign_ID */
public static final String COLUMNNAME_C_Campaign_ID = "C_Campaign_ID";
@ -142,7 +141,7 @@ import org.compiere.util.*;
*/
public int getC_Campaign_ID();
public I_C_Campaign getI_C_Campaign() throws Exception;
public I_C_Campaign getC_Campaign() throws Exception;
/** Column name C_CashLine_ID */
public static final String COLUMNNAME_C_CashLine_ID = "C_CashLine_ID";
@ -183,7 +182,7 @@ import org.compiere.util.*;
*/
public int getC_ConversionType_ID();
public I_C_ConversionType getI_C_ConversionType() throws Exception;
public I_C_ConversionType getC_ConversionType() throws Exception;
/** Column name C_Currency_ID */
public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID";
@ -198,7 +197,7 @@ import org.compiere.util.*;
*/
public int getC_Currency_ID();
public I_C_Currency getI_C_Currency() throws Exception;
public I_C_Currency getC_Currency() throws Exception;
/** Column name C_DocTypeTarget_ID */
public static final String COLUMNNAME_C_DocTypeTarget_ID = "C_DocTypeTarget_ID";
@ -226,7 +225,22 @@ import org.compiere.util.*;
*/
public int getC_DocType_ID();
public I_C_DocType getI_C_DocType() throws Exception;
public I_C_DocType getC_DocType() throws Exception;
/** Column name C_DunningLevel_ID */
public static final String COLUMNNAME_C_DunningLevel_ID = "C_DunningLevel_ID";
/** Set Dunning Level.
* Dunning Level
*/
public void setC_DunningLevel_ID (int C_DunningLevel_ID);
/** Get Dunning Level.
* Dunning Level
*/
public int getC_DunningLevel_ID();
public I_C_DunningLevel getC_DunningLevel() throws Exception;
/** Column name C_Invoice_ID */
public static final String COLUMNNAME_C_Invoice_ID = "C_Invoice_ID";
@ -267,7 +281,7 @@ import org.compiere.util.*;
*/
public int getC_PaymentTerm_ID();
public I_C_PaymentTerm getI_C_PaymentTerm() throws Exception;
public I_C_PaymentTerm getC_PaymentTerm() throws Exception;
/** Column name C_Payment_ID */
public static final String COLUMNNAME_C_Payment_ID = "C_Payment_ID";
@ -295,7 +309,7 @@ import org.compiere.util.*;
*/
public int getC_Project_ID();
public I_C_Project getI_C_Project() throws Exception;
public I_C_Project getC_Project() throws Exception;
/** Column name ChargeAmt */
public static final String COLUMNNAME_ChargeAmt = "ChargeAmt";
@ -440,6 +454,19 @@ import org.compiere.util.*;
*/
public String getDocumentNo();
/** Column name DunningGrace */
public static final String COLUMNNAME_DunningGrace = "DunningGrace";
/** Set Dunning Grace.
* Delay/block the dunning until this date is reached.
*/
public void setDunningGrace (Timestamp DunningGrace);
/** Get Dunning Grace.
* Delay/block the dunning until this date is reached.
*/
public Timestamp getDunningGrace();
/** Column name GenerateTo */
public static final String COLUMNNAME_GenerateTo = "GenerateTo";
@ -622,7 +649,7 @@ import org.compiere.util.*;
*/
public int getM_PriceList_ID();
public I_M_PriceList getI_M_PriceList() throws Exception;
public I_M_PriceList getM_PriceList() throws Exception;
/** Column name M_RMA_ID */
public static final String COLUMNNAME_M_RMA_ID = "M_RMA_ID";
@ -637,7 +664,7 @@ import org.compiere.util.*;
*/
public int getM_RMA_ID();
public I_M_RMA getI_M_RMA() throws Exception;
public I_M_RMA getM_RMA() throws Exception;
/** Column name POReference */
public static final String COLUMNNAME_POReference = "POReference";
@ -773,4 +800,5 @@ import org.compiere.util.*;
* User defined list element #2
*/
public int getUser2_ID();
}

View File

@ -17,12 +17,13 @@
/** Generated Model - DO NOT CHANGE */
package org.compiere.model;
import java.util.*;
import java.sql.*;
import java.math.*;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.*;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
/** Generated Model for C_DunningRunLine
* @author Adempiere (generated)
@ -39,7 +40,9 @@ public class X_C_DunningRunLine extends PO implements I_C_DunningRunLine, I_Pers
public X_C_DunningRunLine (Properties ctx, int C_DunningRunLine_ID, String trxName)
{
super (ctx, C_DunningRunLine_ID, trxName);
/** if (C_DunningRunLine_ID == 0) { setAmt (Env.ZERO);
/** if (C_DunningRunLine_ID == 0)
{
setAmt (Env.ZERO);
setC_DunningRunEntry_ID (0);
setC_DunningRunLine_ID (0);
setConvertedAmt (Env.ZERO);
@ -104,7 +107,7 @@ public class X_C_DunningRunLine extends PO implements I_C_DunningRunLine, I_Pers
return bd;
}
public I_C_DunningRunEntry getI_C_DunningRunEntry() throws Exception
public I_C_DunningRunEntry getC_DunningRunEntry() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_DunningRunEntry.Table_Name);
I_C_DunningRunEntry result = null;
@ -164,13 +167,53 @@ public class X_C_DunningRunLine extends PO implements I_C_DunningRunLine, I_Pers
return ii.intValue();
}
public I_C_InvoicePaySchedule getC_InvoicePaySchedule() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_InvoicePaySchedule.Table_Name);
I_C_InvoicePaySchedule result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_C_InvoicePaySchedule)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_InvoicePaySchedule_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw e;
}
return result;
}
/** Set Invoice Payment Schedule.
@param C_InvoicePaySchedule_ID
Invoice Payment Schedule
*/
public void setC_InvoicePaySchedule_ID (int C_InvoicePaySchedule_ID)
{
if (C_InvoicePaySchedule_ID <= 0)
set_Value (COLUMNNAME_C_InvoicePaySchedule_ID, null);
else
set_Value (COLUMNNAME_C_InvoicePaySchedule_ID, Integer.valueOf(C_InvoicePaySchedule_ID));
}
/** Get Invoice Payment Schedule.
@return Invoice Payment Schedule
*/
public int getC_InvoicePaySchedule_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_InvoicePaySchedule_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Invoice.
@param C_Invoice_ID
Invoice Identifier
*/
public void setC_Invoice_ID (int C_Invoice_ID)
{
if (C_Invoice_ID <= 0) set_Value (COLUMNNAME_C_Invoice_ID, null);
if (C_Invoice_ID <= 0)
set_Value (COLUMNNAME_C_Invoice_ID, null);
else
set_Value (COLUMNNAME_C_Invoice_ID, Integer.valueOf(C_Invoice_ID));
}
@ -200,7 +243,8 @@ public class X_C_DunningRunLine extends PO implements I_C_DunningRunLine, I_Pers
*/
public void setC_Payment_ID (int C_Payment_ID)
{
if (C_Payment_ID <= 0) set_Value (COLUMNNAME_C_Payment_ID, null);
if (C_Payment_ID <= 0)
set_Value (COLUMNNAME_C_Payment_ID, null);
else
set_Value (COLUMNNAME_C_Payment_ID, Integer.valueOf(C_Payment_ID));
}

View File

@ -17,12 +17,14 @@
/** Generated Model - DO NOT CHANGE */
package org.compiere.model;
import java.util.*;
import java.sql.*;
import java.math.*;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.*;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
/** Generated Model for C_Invoice
* @author Adempiere (generated)
@ -39,7 +41,9 @@ public class X_C_Invoice extends PO implements I_C_Invoice, I_Persistent
public X_C_Invoice (Properties ctx, int C_Invoice_ID, String trxName)
{
super (ctx, C_Invoice_ID, trxName);
/** if (C_Invoice_ID == 0) { setC_BPartner_ID (0);
/** if (C_Invoice_ID == 0)
{
setC_BPartner_ID (0);
setC_BPartner_Location_ID (0);
setC_Currency_ID (0);
// @C_Currency_ID@
@ -79,6 +83,7 @@ public class X_C_Invoice extends PO implements I_C_Invoice, I_Persistent
setProcessed (false);
setSendEMail (false);
setTotalLines (Env.ZERO);
// 'Y'
} */
}
@ -118,7 +123,8 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
*/
public void setAD_OrgTrx_ID (int AD_OrgTrx_ID)
{
if (AD_OrgTrx_ID <= 0) set_Value (COLUMNNAME_AD_OrgTrx_ID, null);
if (AD_OrgTrx_ID <= 0)
set_Value (COLUMNNAME_AD_OrgTrx_ID, null);
else
set_Value (COLUMNNAME_AD_OrgTrx_ID, Integer.valueOf(AD_OrgTrx_ID));
}
@ -134,7 +140,7 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
return ii.intValue();
}
public I_AD_User getI_AD_User() throws Exception
public I_AD_User getAD_User() throws Exception
{
Class<?> clazz = MTable.getClass(I_AD_User.Table_Name);
I_AD_User result = null;
@ -156,7 +162,8 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
*/
public void setAD_User_ID (int AD_User_ID)
{
if (AD_User_ID <= 0) set_Value (COLUMNNAME_AD_User_ID, null);
if (AD_User_ID <= 0)
set_Value (COLUMNNAME_AD_User_ID, null);
else
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
}
@ -172,7 +179,7 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
return ii.intValue();
}
public I_C_Activity getI_C_Activity() throws Exception
public I_C_Activity getC_Activity() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_Activity.Table_Name);
I_C_Activity result = null;
@ -194,7 +201,8 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
*/
public void setC_Activity_ID (int C_Activity_ID)
{
if (C_Activity_ID <= 0) set_Value (COLUMNNAME_C_Activity_ID, null);
if (C_Activity_ID <= 0)
set_Value (COLUMNNAME_C_Activity_ID, null);
else
set_Value (COLUMNNAME_C_Activity_ID, Integer.valueOf(C_Activity_ID));
}
@ -232,7 +240,7 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
return ii.intValue();
}
public I_C_BPartner_Location getI_C_BPartner_Location() throws Exception
public I_C_BPartner_Location getC_BPartner_Location() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_BPartner_Location.Table_Name);
I_C_BPartner_Location result = null;
@ -270,7 +278,7 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
return ii.intValue();
}
public I_C_Campaign getI_C_Campaign() throws Exception
public I_C_Campaign getC_Campaign() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_Campaign.Table_Name);
I_C_Campaign result = null;
@ -292,7 +300,8 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
*/
public void setC_Campaign_ID (int C_Campaign_ID)
{
if (C_Campaign_ID <= 0) set_Value (COLUMNNAME_C_Campaign_ID, null);
if (C_Campaign_ID <= 0)
set_Value (COLUMNNAME_C_Campaign_ID, null);
else
set_Value (COLUMNNAME_C_Campaign_ID, Integer.valueOf(C_Campaign_ID));
}
@ -314,7 +323,8 @@ public static final int AD_ORGTRX_ID_AD_Reference_ID=130;
*/
public void setC_CashLine_ID (int C_CashLine_ID)
{
if (C_CashLine_ID <= 0) set_Value (COLUMNNAME_C_CashLine_ID, null);
if (C_CashLine_ID <= 0)
set_Value (COLUMNNAME_C_CashLine_ID, null);
else
set_Value (COLUMNNAME_C_CashLine_ID, Integer.valueOf(C_CashLine_ID));
}
@ -338,7 +348,8 @@ public static final int C_CHARGE_ID_AD_Reference_ID=200;
*/
public void setC_Charge_ID (int C_Charge_ID)
{
if (C_Charge_ID <= 0) set_Value (COLUMNNAME_C_Charge_ID, null);
if (C_Charge_ID <= 0)
set_Value (COLUMNNAME_C_Charge_ID, null);
else
set_Value (COLUMNNAME_C_Charge_ID, Integer.valueOf(C_Charge_ID));
}
@ -354,7 +365,7 @@ public static final int C_CHARGE_ID_AD_Reference_ID=200;
return ii.intValue();
}
public I_C_ConversionType getI_C_ConversionType() throws Exception
public I_C_ConversionType getC_ConversionType() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_ConversionType.Table_Name);
I_C_ConversionType result = null;
@ -376,7 +387,8 @@ public static final int C_CHARGE_ID_AD_Reference_ID=200;
*/
public void setC_ConversionType_ID (int C_ConversionType_ID)
{
if (C_ConversionType_ID <= 0) set_Value (COLUMNNAME_C_ConversionType_ID, null);
if (C_ConversionType_ID <= 0)
set_Value (COLUMNNAME_C_ConversionType_ID, null);
else
set_Value (COLUMNNAME_C_ConversionType_ID, Integer.valueOf(C_ConversionType_ID));
}
@ -392,7 +404,7 @@ public static final int C_CHARGE_ID_AD_Reference_ID=200;
return ii.intValue();
}
public I_C_Currency getI_C_Currency() throws Exception
public I_C_Currency getC_Currency() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_Currency.Table_Name);
I_C_Currency result = null;
@ -454,7 +466,7 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
return ii.intValue();
}
public I_C_DocType getI_C_DocType() throws Exception
public I_C_DocType getC_DocType() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_DocType.Table_Name);
I_C_DocType result = null;
@ -492,6 +504,45 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
return ii.intValue();
}
public I_C_DunningLevel getC_DunningLevel() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_DunningLevel.Table_Name);
I_C_DunningLevel result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_C_DunningLevel)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_DunningLevel_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw e;
}
return result;
}
/** Set Dunning Level.
@param C_DunningLevel_ID
Dunning Level
*/
public void setC_DunningLevel_ID (int C_DunningLevel_ID)
{
if (C_DunningLevel_ID <= 0)
set_Value (COLUMNNAME_C_DunningLevel_ID, null);
else
set_Value (COLUMNNAME_C_DunningLevel_ID, Integer.valueOf(C_DunningLevel_ID));
}
/** Get Dunning Level.
@return Dunning Level
*/
public int getC_DunningLevel_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_DunningLevel_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Invoice.
@param C_Invoice_ID
Invoice Identifier
@ -520,7 +571,8 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
*/
public void setC_Order_ID (int C_Order_ID)
{
if (C_Order_ID <= 0) set_ValueNoCheck (COLUMNNAME_C_Order_ID, null);
if (C_Order_ID <= 0)
set_ValueNoCheck (COLUMNNAME_C_Order_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_Order_ID, Integer.valueOf(C_Order_ID));
}
@ -536,7 +588,7 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
return ii.intValue();
}
public I_C_PaymentTerm getI_C_PaymentTerm() throws Exception
public I_C_PaymentTerm getC_PaymentTerm() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_PaymentTerm.Table_Name);
I_C_PaymentTerm result = null;
@ -580,7 +632,8 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
*/
public void setC_Payment_ID (int C_Payment_ID)
{
if (C_Payment_ID <= 0) set_Value (COLUMNNAME_C_Payment_ID, null);
if (C_Payment_ID <= 0)
set_Value (COLUMNNAME_C_Payment_ID, null);
else
set_Value (COLUMNNAME_C_Payment_ID, Integer.valueOf(C_Payment_ID));
}
@ -596,7 +649,7 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
return ii.intValue();
}
public I_C_Project getI_C_Project() throws Exception
public I_C_Project getC_Project() throws Exception
{
Class<?> clazz = MTable.getClass(I_C_Project.Table_Name);
I_C_Project result = null;
@ -618,7 +671,8 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
*/
public void setC_Project_ID (int C_Project_ID)
{
if (C_Project_ID <= 0) set_Value (COLUMNNAME_C_Project_ID, null);
if (C_Project_ID <= 0)
set_Value (COLUMNNAME_C_Project_ID, null);
else
set_Value (COLUMNNAME_C_Project_ID, Integer.valueOf(C_Project_ID));
}
@ -660,6 +714,7 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
*/
public void setCopyFrom (String CopyFrom)
{
if (CopyFrom != null && CopyFrom.length() > 1)
{
log.warning("Length > 1 - truncated");
@ -682,6 +737,7 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
*/
public void setCreateFrom (String CreateFrom)
{
if (CreateFrom != null && CreateFrom.length() > 1)
{
log.warning("Length > 1 - truncated");
@ -776,6 +832,7 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
*/
public void setDescription (String Description)
{
if (Description != null && Description.length() > 255)
{
log.warning("Length > 255 - truncated");
@ -793,28 +850,44 @@ public static final int C_DOCTYPETARGET_ID_AD_Reference_ID=170;
}
/** DocAction AD_Reference_ID=135 */
public static final int DOCACTION_AD_Reference_ID=135;/** <None> = -- */
public static final String DOCACTION_None = "--";/** Approve = AP */
public static final String DOCACTION_Approve = "AP";/** Close = CL */
public static final String DOCACTION_Close = "CL";/** Complete = CO */
public static final String DOCACTION_Complete = "CO";/** Invalidate = IN */
public static final String DOCACTION_Invalidate = "IN";/** Post = PO */
public static final String DOCACTION_Post = "PO";/** Prepare = PR */
public static final String DOCACTION_Prepare = "PR";/** Reverse - Accrual = RA */
public static final String DOCACTION_Reverse_Accrual = "RA";/** Reverse - Correct = RC */
public static final String DOCACTION_Reverse_Correct = "RC";/** Re-activate = RE */
public static final String DOCACTION_Re_Activate = "RE";/** Reject = RJ */
public static final String DOCACTION_Reject = "RJ";/** Void = VO */
public static final String DOCACTION_Void = "VO";/** Wait Complete = WC */
public static final String DOCACTION_WaitComplete = "WC";/** Unlock = XL */
public static final int DOCACTION_AD_Reference_ID=135;
/** Complete = CO */
public static final String DOCACTION_Complete = "CO";
/** Approve = AP */
public static final String DOCACTION_Approve = "AP";
/** Reject = RJ */
public static final String DOCACTION_Reject = "RJ";
/** Post = PO */
public static final String DOCACTION_Post = "PO";
/** Void = VO */
public static final String DOCACTION_Void = "VO";
/** Close = CL */
public static final String DOCACTION_Close = "CL";
/** Reverse - Correct = RC */
public static final String DOCACTION_Reverse_Correct = "RC";
/** Reverse - Accrual = RA */
public static final String DOCACTION_Reverse_Accrual = "RA";
/** Invalidate = IN */
public static final String DOCACTION_Invalidate = "IN";
/** Re-activate = RE */
public static final String DOCACTION_Re_Activate = "RE";
/** <None> = -- */
public static final String DOCACTION_None = "--";
/** Prepare = PR */
public static final String DOCACTION_Prepare = "PR";
/** Unlock = XL */
public static final String DOCACTION_Unlock = "XL";
/** Wait Complete = WC */
public static final String DOCACTION_WaitComplete = "WC";
/** Set Document Action.
@param DocAction
The targeted status of the document
*/
public void setDocAction (String DocAction)
{
if (DocAction == null) throw new IllegalArgumentException ("DocAction is mandatory");if (DocAction.equals("--") || DocAction.equals("AP") || DocAction.equals("CL") || DocAction.equals("CO") || DocAction.equals("IN") || DocAction.equals("PO") || DocAction.equals("PR") || DocAction.equals("RA") || DocAction.equals("RC") || DocAction.equals("RE") || DocAction.equals("RJ") || DocAction.equals("VO") || DocAction.equals("WC") || DocAction.equals("XL")); else throw new IllegalArgumentException ("DocAction Invalid value - " + DocAction + " - Reference_ID=135 - -- - AP - CL - CO - IN - PO - PR - RA - RC - RE - RJ - VO - WC - XL"); if (DocAction.length() > 2)
if (DocAction == null) throw new IllegalArgumentException ("DocAction is mandatory");
if (DocAction.equals("CO") || DocAction.equals("AP") || DocAction.equals("RJ") || DocAction.equals("PO") || DocAction.equals("VO") || DocAction.equals("CL") || DocAction.equals("RC") || DocAction.equals("RA") || DocAction.equals("IN") || DocAction.equals("RE") || DocAction.equals("--") || DocAction.equals("PR") || DocAction.equals("XL") || DocAction.equals("WC")); else throw new IllegalArgumentException ("DocAction Invalid value - " + DocAction + " - Reference_ID=135 - CO - AP - RJ - PO - VO - CL - RC - RA - IN - RE - -- - PR - XL - WC");
if (DocAction.length() > 2)
{
log.warning("Length > 2 - truncated");
DocAction = DocAction.substring(0, 1);
@ -831,26 +904,40 @@ if (DocAction == null) throw new IllegalArgumentException ("DocAction is mandato
}
/** DocStatus AD_Reference_ID=131 */
public static final int DOCSTATUS_AD_Reference_ID=131;/** Unknown = ?? */
public static final String DOCSTATUS_Unknown = "??";/** Approved = AP */
public static final String DOCSTATUS_Approved = "AP";/** Closed = CL */
public static final String DOCSTATUS_Closed = "CL";/** Completed = CO */
public static final String DOCSTATUS_Completed = "CO";/** Drafted = DR */
public static final String DOCSTATUS_Drafted = "DR";/** Invalid = IN */
public static final String DOCSTATUS_Invalid = "IN";/** In Progress = IP */
public static final String DOCSTATUS_InProgress = "IP";/** Not Approved = NA */
public static final String DOCSTATUS_NotApproved = "NA";/** Reversed = RE */
public static final String DOCSTATUS_Reversed = "RE";/** Voided = VO */
public static final String DOCSTATUS_Voided = "VO";/** Waiting Confirmation = WC */
public static final String DOCSTATUS_WaitingConfirmation = "WC";/** Waiting Payment = WP */
public static final int DOCSTATUS_AD_Reference_ID=131;
/** Drafted = DR */
public static final String DOCSTATUS_Drafted = "DR";
/** Completed = CO */
public static final String DOCSTATUS_Completed = "CO";
/** Approved = AP */
public static final String DOCSTATUS_Approved = "AP";
/** Not Approved = NA */
public static final String DOCSTATUS_NotApproved = "NA";
/** Voided = VO */
public static final String DOCSTATUS_Voided = "VO";
/** Invalid = IN */
public static final String DOCSTATUS_Invalid = "IN";
/** Reversed = RE */
public static final String DOCSTATUS_Reversed = "RE";
/** Closed = CL */
public static final String DOCSTATUS_Closed = "CL";
/** Unknown = ?? */
public static final String DOCSTATUS_Unknown = "??";
/** In Progress = IP */
public static final String DOCSTATUS_InProgress = "IP";
/** Waiting Payment = WP */
public static final String DOCSTATUS_WaitingPayment = "WP";
/** Waiting Confirmation = WC */
public static final String DOCSTATUS_WaitingConfirmation = "WC";
/** Set Document Status.
@param DocStatus
The current status of the document
*/
public void setDocStatus (String DocStatus)
{
if (DocStatus == null) throw new IllegalArgumentException ("DocStatus is mandatory");if (DocStatus.equals("??") || DocStatus.equals("AP") || DocStatus.equals("CL") || DocStatus.equals("CO") || DocStatus.equals("DR") || DocStatus.equals("IN") || DocStatus.equals("IP") || DocStatus.equals("NA") || DocStatus.equals("RE") || DocStatus.equals("VO") || DocStatus.equals("WC") || DocStatus.equals("WP")); else throw new IllegalArgumentException ("DocStatus Invalid value - " + DocStatus + " - Reference_ID=131 - ?? - AP - CL - CO - DR - IN - IP - NA - RE - VO - WC - WP"); if (DocStatus.length() > 2)
if (DocStatus == null) throw new IllegalArgumentException ("DocStatus is mandatory");
if (DocStatus.equals("DR") || DocStatus.equals("CO") || DocStatus.equals("AP") || DocStatus.equals("NA") || DocStatus.equals("VO") || DocStatus.equals("IN") || DocStatus.equals("RE") || DocStatus.equals("CL") || DocStatus.equals("??") || DocStatus.equals("IP") || DocStatus.equals("WP") || DocStatus.equals("WC")); else throw new IllegalArgumentException ("DocStatus Invalid value - " + DocStatus + " - Reference_ID=131 - DR - CO - AP - NA - VO - IN - RE - CL - ?? - IP - WP - WC");
if (DocStatus.length() > 2)
{
log.warning("Length > 2 - truncated");
DocStatus = DocStatus.substring(0, 1);
@ -874,6 +961,7 @@ if (DocStatus == null) throw new IllegalArgumentException ("DocStatus is mandato
{
if (DocumentNo == null)
throw new IllegalArgumentException ("DocumentNo is mandatory.");
if (DocumentNo.length() > 30)
{
log.warning("Length > 30 - truncated");
@ -898,12 +986,30 @@ if (DocStatus == null) throw new IllegalArgumentException ("DocStatus is mandato
return new KeyNamePair(get_ID(), getDocumentNo());
}
/** Set Dunning Grace.
@param DunningGrace
Delay/block the dunning until this date is reached.
*/
public void setDunningGrace (Timestamp DunningGrace)
{
set_Value (COLUMNNAME_DunningGrace, DunningGrace);
}
/** Get Dunning Grace.
@return Delay/block the dunning until this date is reached.
*/
public Timestamp getDunningGrace ()
{
return (Timestamp)get_Value(COLUMNNAME_DunningGrace);
}
/** Set Generate To.
@param GenerateTo
Generate To
*/
public void setGenerateTo (String GenerateTo)
{
if (GenerateTo != null && GenerateTo.length() > 1)
{
log.warning("Length > 1 - truncated");
@ -943,10 +1049,14 @@ if (DocStatus == null) throw new IllegalArgumentException ("DocStatus is mandato
}
/** InvoiceCollectionType AD_Reference_ID=394 */
public static final int INVOICECOLLECTIONTYPE_AD_Reference_ID=394;/** Collection Agency = C */
public static final String INVOICECOLLECTIONTYPE_CollectionAgency = "C";/** Dunning = D */
public static final String INVOICECOLLECTIONTYPE_Dunning = "D";/** Legal Procedure = L */
public static final String INVOICECOLLECTIONTYPE_LegalProcedure = "L";/** Uncollectable = U */
public static final int INVOICECOLLECTIONTYPE_AD_Reference_ID=394;
/** Dunning = D */
public static final String INVOICECOLLECTIONTYPE_Dunning = "D";
/** Collection Agency = C */
public static final String INVOICECOLLECTIONTYPE_CollectionAgency = "C";
/** Legal Procedure = L */
public static final String INVOICECOLLECTIONTYPE_LegalProcedure = "L";
/** Uncollectable = U */
public static final String INVOICECOLLECTIONTYPE_Uncollectable = "U";
/** Set Collection Status.
@param InvoiceCollectionType
@ -954,7 +1064,9 @@ public static final String INVOICECOLLECTIONTYPE_Uncollectable = "U";
*/
public void setInvoiceCollectionType (String InvoiceCollectionType)
{
if (InvoiceCollectionType == null || InvoiceCollectionType.equals("C") || InvoiceCollectionType.equals("D") || InvoiceCollectionType.equals("L") || InvoiceCollectionType.equals("U")); else throw new IllegalArgumentException ("InvoiceCollectionType Invalid value - " + InvoiceCollectionType + " - Reference_ID=394 - C - D - L - U"); if (InvoiceCollectionType != null && InvoiceCollectionType.length() > 1)
if (InvoiceCollectionType == null || InvoiceCollectionType.equals("D") || InvoiceCollectionType.equals("C") || InvoiceCollectionType.equals("L") || InvoiceCollectionType.equals("U")); else throw new IllegalArgumentException ("InvoiceCollectionType Invalid value - " + InvoiceCollectionType + " - Reference_ID=394 - D - C - L - U");
if (InvoiceCollectionType != null && InvoiceCollectionType.length() > 1)
{
log.warning("Length > 1 - truncated");
InvoiceCollectionType = InvoiceCollectionType.substring(0, 0);
@ -1210,7 +1322,7 @@ if (InvoiceCollectionType == null || InvoiceCollectionType.equals("C") || Invoic
return false;
}
public I_M_PriceList getI_M_PriceList() throws Exception
public I_M_PriceList getM_PriceList() throws Exception
{
Class<?> clazz = MTable.getClass(I_M_PriceList.Table_Name);
I_M_PriceList result = null;
@ -1248,7 +1360,7 @@ if (InvoiceCollectionType == null || InvoiceCollectionType.equals("C") || Invoic
return ii.intValue();
}
public I_M_RMA getI_M_RMA() throws Exception
public I_M_RMA getM_RMA() throws Exception
{
Class<?> clazz = MTable.getClass(I_M_RMA.Table_Name);
I_M_RMA result = null;
@ -1270,7 +1382,8 @@ if (InvoiceCollectionType == null || InvoiceCollectionType.equals("C") || Invoic
*/
public void setM_RMA_ID (int M_RMA_ID)
{
if (M_RMA_ID <= 0) set_Value (COLUMNNAME_M_RMA_ID, null);
if (M_RMA_ID <= 0)
set_Value (COLUMNNAME_M_RMA_ID, null);
else
set_Value (COLUMNNAME_M_RMA_ID, Integer.valueOf(M_RMA_ID));
}
@ -1292,6 +1405,7 @@ if (InvoiceCollectionType == null || InvoiceCollectionType.equals("C") || Invoic
*/
public void setPOReference (String POReference)
{
if (POReference != null && POReference.length() > 20)
{
log.warning("Length > 20 - truncated");
@ -1309,20 +1423,28 @@ if (InvoiceCollectionType == null || InvoiceCollectionType.equals("C") || Invoic
}
/** PaymentRule AD_Reference_ID=195 */
public static final int PAYMENTRULE_AD_Reference_ID=195;/** Cash = B */
public static final String PAYMENTRULE_Cash = "B";/** Direct Debit = D */
public static final String PAYMENTRULE_DirectDebit = "D";/** Credit Card = K */
public static final String PAYMENTRULE_CreditCard = "K";/** On Credit = P */
public static final String PAYMENTRULE_OnCredit = "P";/** Check = S */
public static final String PAYMENTRULE_Check = "S";/** Direct Deposit = T */
public static final int PAYMENTRULE_AD_Reference_ID=195;
/** Cash = B */
public static final String PAYMENTRULE_Cash = "B";
/** Credit Card = K */
public static final String PAYMENTRULE_CreditCard = "K";
/** Direct Deposit = T */
public static final String PAYMENTRULE_DirectDeposit = "T";
/** Check = S */
public static final String PAYMENTRULE_Check = "S";
/** On Credit = P */
public static final String PAYMENTRULE_OnCredit = "P";
/** Direct Debit = D */
public static final String PAYMENTRULE_DirectDebit = "D";
/** Set Payment Rule.
@param PaymentRule
How you pay the invoice
*/
public void setPaymentRule (String PaymentRule)
{
if (PaymentRule == null) throw new IllegalArgumentException ("PaymentRule is mandatory");if (PaymentRule.equals("B") || PaymentRule.equals("D") || PaymentRule.equals("K") || PaymentRule.equals("P") || PaymentRule.equals("S") || PaymentRule.equals("T")); else throw new IllegalArgumentException ("PaymentRule Invalid value - " + PaymentRule + " - Reference_ID=195 - B - D - K - P - S - T"); if (PaymentRule.length() > 1)
if (PaymentRule == null) throw new IllegalArgumentException ("PaymentRule is mandatory");
if (PaymentRule.equals("B") || PaymentRule.equals("K") || PaymentRule.equals("T") || PaymentRule.equals("S") || PaymentRule.equals("P") || PaymentRule.equals("D")); else throw new IllegalArgumentException ("PaymentRule Invalid value - " + PaymentRule + " - Reference_ID=195 - B - K - T - S - P - D");
if (PaymentRule.length() > 1)
{
log.warning("Length > 1 - truncated");
PaymentRule = PaymentRule.substring(0, 0);
@ -1411,7 +1533,8 @@ if (PaymentRule == null) throw new IllegalArgumentException ("PaymentRule is man
@param Ref_Invoice_ID Referenced Invoice */
public void setRef_Invoice_ID (int Ref_Invoice_ID)
{
if (Ref_Invoice_ID <= 0) set_Value (COLUMNNAME_Ref_Invoice_ID, null);
if (Ref_Invoice_ID <= 0)
set_Value (COLUMNNAME_Ref_Invoice_ID, null);
else
set_Value (COLUMNNAME_Ref_Invoice_ID, Integer.valueOf(Ref_Invoice_ID));
}
@ -1434,7 +1557,8 @@ public static final int SALESREP_ID_AD_Reference_ID=190;
*/
public void setSalesRep_ID (int SalesRep_ID)
{
if (SalesRep_ID <= 0) set_Value (COLUMNNAME_SalesRep_ID, null);
if (SalesRep_ID <= 0)
set_Value (COLUMNNAME_SalesRep_ID, null);
else
set_Value (COLUMNNAME_SalesRep_ID, Integer.valueOf(SalesRep_ID));
}
@ -1504,7 +1628,8 @@ public static final int USER1_ID_AD_Reference_ID=134;
*/
public void setUser1_ID (int User1_ID)
{
if (User1_ID <= 0) set_Value (COLUMNNAME_User1_ID, null);
if (User1_ID <= 0)
set_Value (COLUMNNAME_User1_ID, null);
else
set_Value (COLUMNNAME_User1_ID, Integer.valueOf(User1_ID));
}
@ -1528,7 +1653,8 @@ public static final int USER2_ID_AD_Reference_ID=137;
*/
public void setUser2_ID (int User2_ID)
{
if (User2_ID <= 0) set_Value (COLUMNNAME_User2_ID, null);
if (User2_ID <= 0)
set_Value (COLUMNNAME_User2_ID, null);
else
set_Value (COLUMNNAME_User2_ID, Integer.valueOf(User2_ID));
}

View File

@ -16,11 +16,24 @@
*****************************************************************************/
package org.compiere.process;
import java.io.*;
import java.util.logging.*;
import org.compiere.model.*;
import org.compiere.print.*;
import org.compiere.util.*;
import java.io.File;
import java.util.logging.Level;
import org.compiere.model.MBPartner;
import org.compiere.model.MClient;
import org.compiere.model.MDunningLevel;
import org.compiere.model.MDunningRun;
import org.compiere.model.MDunningRunEntry;
import org.compiere.model.MMailText;
import org.compiere.model.MQuery;
import org.compiere.model.MUser;
import org.compiere.model.MUserMail;
import org.compiere.model.PrintInfo;
import org.compiere.model.X_C_DunningRunEntry;
import org.compiere.print.MPrintFormat;
import org.compiere.print.ReportEngine;
import org.compiere.util.AdempiereUserError;
import org.compiere.util.EMail;
/**
* Dunning Letter Print
@ -38,6 +51,8 @@ public class DunningPrint extends SvrProcess
private int p_C_DunningRun_ID = 0;
/** Print only Outstanding */
private boolean p_IsOnlyIfBPBalance = true;
/** Print only unprocessed lines */
private boolean p_PrintUnprocessedOnly = true;
/**
@ -59,6 +74,8 @@ public class DunningPrint extends SvrProcess
p_C_DunningRun_ID = para[i].getParameterAsInt();
else if (name.equals("IsOnlyIfBPBalance"))
p_IsOnlyIfBPBalance = "Y".equals(para[i].getParameter());
else if (name.equals("PrintUnprocessedOnly"))
p_PrintUnprocessedOnly = "Y".equals(para[i].getParameter());
else
log.log(Level.SEVERE, "Unknown Parameter: " + name);
}
@ -72,7 +89,8 @@ public class DunningPrint extends SvrProcess
protected String doIt () throws Exception
{
log.info("C_DunningRun_ID=" + p_C_DunningRun_ID + ",R_MailText_ID=" + p_R_MailText_ID
+ ", EmailPDF=" + p_EMailPDF + ",IsOnlyIfBPBalance=" + p_IsOnlyIfBPBalance);
+ ", EmailPDF=" + p_EMailPDF + ",IsOnlyIfBPBalance=" + p_IsOnlyIfBPBalance
+ ",PrintUnprocessedOnly=" + p_PrintUnprocessedOnly);
// Need to have Template
if (p_EMailPDF && p_R_MailText_ID == 0)
@ -104,6 +122,8 @@ public class DunningPrint extends SvrProcess
MDunningRunEntry entry = entries[i];
if (p_IsOnlyIfBPBalance && entry.getAmt().signum() <= 0)
continue;
if (p_PrintUnprocessedOnly && entry.isProcessed())
continue;
// To BPartner
MBPartner bp = new MBPartner (getCtx(), entry.getC_BPartner_ID(), get_TrxName());
if (bp.get_ID() == 0)
@ -199,6 +219,10 @@ public class DunningPrint extends SvrProcess
}
} // for all dunning letters
if (errors==0) {
run.setProcessed(true);
run.save();
}
if (p_EMailPDF)
return "@Sent@=" + count + " - @Errors@=" + errors;
return "@Printed@=" + count;

View File

@ -16,11 +16,18 @@
*****************************************************************************/
package org.compiere.process;
import java.math.*;
import java.sql.*;
import java.util.logging.*;
import org.compiere.model.*;
import org.compiere.util.*;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import org.compiere.model.MDunningLevel;
import org.compiere.model.MDunningRun;
import org.compiere.model.MDunningRunEntry;
import org.compiere.model.MDunningRunLine;
import org.compiere.model.MInvoice;
import org.compiere.util.DB;
import org.compiere.util.Env;
/**
@ -118,11 +125,12 @@ public class DunningRunCreate extends SvrProcess
+ " i.GrandTotal*i.MultiplierAP,"
+ " invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)*MultiplierAP,"
+ " COALESCE(daysBetween(?,ips.DueDate),paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced,?))," // ##1/2
+ " i.IsInDispute, i.C_BPartner_ID "
+ " i.IsInDispute, i.C_BPartner_ID, i.C_InvoicePaySchedule_ID "
+ "FROM C_Invoice_v i "
+ " LEFT OUTER JOIN C_InvoicePaySchedule ips ON (i.C_InvoicePaySchedule_ID=ips.C_InvoicePaySchedule_ID) "
+ "WHERE i.IsPaid='N' AND i.AD_Client_ID=?" // ##3
+ " AND i.DocStatus IN ('CO','CL')"
+ " AND (i.DunningGrace IS NULL OR i.DunningGrace<?) "
// Only BP(Group) with Dunning defined
+ " AND EXISTS (SELECT * FROM C_DunningLevel dl "
+ "WHERE dl.C_DunningLevel_ID=?" // // ##4
@ -130,7 +138,8 @@ public class DunningRunCreate extends SvrProcess
+ "(SELECT COALESCE(bp.C_Dunning_ID, bpg.C_Dunning_ID) "
+ "FROM C_BPartner bp"
+ " INNER JOIN C_BP_Group bpg ON (bp.C_BP_Group_ID=bpg.C_BP_Group_ID) "
+ "WHERE i.C_BPartner_ID=bp.C_BPartner_ID))";
+ "WHERE i.C_BPartner_ID=bp.C_BPartner_ID" +
" AND (bp.DunningGrace IS NULL OR bp.DunningGrace<?)))";
if (p_C_BPartner_ID != 0)
sql += " AND i.C_BPartner_ID=?"; // ##5
else if (p_C_BP_Group_ID != 0)
@ -146,9 +155,10 @@ public class DunningRunCreate extends SvrProcess
// if sequentially we must check for other levels with smaller days for
// which this invoice is not yet included!
MDunningLevel[] previousLevels = null;
if (m_level.getParent ().isCreateLevelsSequentially ()) {
// Build a list of all topmost Dunning Levels
MDunningLevel[] previousLevels = m_level.getPreviousLevels();
previousLevels = m_level.getPreviousLevels();
if (previousLevels!=null && previousLevels.length>0) {
String sqlAppend = "";
for (int i=0; i<previousLevels.length; i++)
@ -161,11 +171,11 @@ public class DunningRunCreate extends SvrProcess
sql += sqlAppend;
}
}
sql2 = "SELECT COUNT(*), COALESCE(TRUNC(SysDate-MAX(dr.DunningDate)),0) "
sql2 = "SELECT COUNT(*), COALESCE(TRUNC(?-MAX(dr.DunningDate)),0) "
+ "FROM C_DunningRun dr"
+ " INNER JOIN C_DunningRunEntry dre ON (dr.C_DunningRun_ID=dre.C_DunningRun_ID)"
+ " INNER JOIN C_DunningRunLine drl ON (dre.C_DunningRunEntry_ID=drl.C_DunningRunEntry_ID) "
+ "WHERE drl.Processed='Y' AND drl.C_Invoice_ID=?";
+ "WHERE drl.Processed='Y' AND drl.C_Invoice_ID=? AND COALESCE(drl.C_InvoicePaySchedule_ID, 0)=?";
BigDecimal DaysAfterDue = m_run.getLevel().getDaysAfterDue();
@ -179,11 +189,13 @@ public class DunningRunCreate extends SvrProcess
pstmt.setTimestamp(1, m_run.getDunningDate());
pstmt.setTimestamp(2, m_run.getDunningDate());
pstmt.setInt (3, m_run.getAD_Client_ID());
pstmt.setInt(4, m_run.getC_DunningLevel_ID());
pstmt.setTimestamp(4, m_run.getDunningDate());
pstmt.setInt(5, m_run.getC_DunningLevel_ID());
pstmt.setTimestamp(6, m_run.getDunningDate());
if (p_C_BPartner_ID != 0)
pstmt.setInt (5, p_C_BPartner_ID);
pstmt.setInt (7, p_C_BPartner_ID);
else if (p_C_BP_Group_ID != 0)
pstmt.setInt (5, p_C_BP_Group_ID);
pstmt.setInt (7, p_C_BP_Group_ID);
//
pstmt2 = DB.prepareStatement (sql2, get_TrxName());
//
@ -197,6 +209,10 @@ public class DunningRunCreate extends SvrProcess
int DaysDue = rs.getInt(5);
boolean IsInDispute = "Y".equals(rs.getString(6));
int C_BPartner_ID = rs.getInt(7);
int C_InvoicePaySchedule_ID = rs.getInt(8);
log.fine("DaysAfterDue: " + DaysAfterDue.intValue() + " isShowAllDue: " + m_level.isShowAllDue());
log.fine("C_Invoice_ID - DaysDue - GrandTotal: " + C_Invoice_ID + " - " + DaysDue + " - " + GrandTotal);
log.fine("C_InvoicePaySchedule_ID: " + C_InvoicePaySchedule_ID);
//
if (!p_IncludeInDispute && IsInDispute)
continue;
@ -208,7 +224,9 @@ public class DunningRunCreate extends SvrProcess
int TimesDunned = 0;
int DaysAfterLast = 0;
// SubQuery
pstmt2.setInt (1, C_Invoice_ID);
pstmt2.setTimestamp(1, m_run.getDunningDate());
pstmt2.setInt (2, C_Invoice_ID);
pstmt2.setInt (3, C_InvoicePaySchedule_ID);
ResultSet rs2 = pstmt2.executeQuery ();
if (rs2.next())
{
@ -216,12 +234,19 @@ public class DunningRunCreate extends SvrProcess
DaysAfterLast = rs2.getInt(2);
}
rs2.close();
if(previousLevels != null){
log.fine(TimesDunned + " - " + previousLevels.length);
}
// SubQuery
if (m_level.getParent().isCreateLevelsSequentially() && previousLevels!=null && TimesDunned>previousLevels.length
&& !m_level.isShowAllDue() && !m_level.isShowNotDue()) {
continue;
}
log.fine(DaysBetweenDunning + " - " + DaysAfterLast);
if (DaysBetweenDunning != 0 && DaysAfterLast < DaysBetweenDunning && !m_level.isShowAllDue () && !m_level.isShowNotDue ())
continue;
//
createInvoiceLine (C_Invoice_ID, C_Currency_ID, GrandTotal, Open,
createInvoiceLine (C_Invoice_ID, C_InvoicePaySchedule_ID, C_Currency_ID, GrandTotal, Open,
DaysDue, IsInDispute, C_BPartner_ID,
TimesDunned, DaysAfterLast);
count++;
@ -265,7 +290,7 @@ public class DunningRunCreate extends SvrProcess
* @param TimesDunned
* @param DaysAfterLast
*/
private void createInvoiceLine (int C_Invoice_ID, int C_Currency_ID,
private void createInvoiceLine (int C_Invoice_ID, int C_InvoicePaySchedule_ID, int C_Currency_ID,
BigDecimal GrandTotal, BigDecimal Open,
int DaysDue, boolean IsInDispute,
int C_BPartner_ID, int TimesDunned, int DaysAfterLast)
@ -279,8 +304,13 @@ public class DunningRunCreate extends SvrProcess
line.setInvoice(C_Invoice_ID, C_Currency_ID, GrandTotal, Open,
new BigDecimal(0), DaysDue, IsInDispute, TimesDunned,
DaysAfterLast);
line.setC_InvoicePaySchedule_ID(C_InvoicePaySchedule_ID);
if (!line.save())
throw new IllegalStateException("Cannot save MDunningRunLine");
MInvoice invoice = new MInvoice(getCtx(),C_Invoice_ID, get_TrxName());
invoice.setC_DunningLevel_ID(m_run.getC_DunningLevel_ID());
if (!invoice.save())
throw new IllegalStateException("Cannot update dunning level information in invoice");
} // createInvoiceLine

View File

@ -0,0 +1,176 @@
SET DEFINE OFF;
INSERT INTO ad_element
(ad_element_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
columnname, entitytype, NAME,
printname
)
VALUES (53223, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'DunningGrace', 'D', 'Dunning Grace',
'Dunning Grace'
);
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53246, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.', 1,
'D', 'DunningGrace', 291, 15,
7, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 53223, 'N',
'N'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype,
displaylogic
)
VALUES (53256, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.',
'Y', 260 ,223,
53246, 'Y', 14, 'N',
'N', 'N', 'N', 'N', 'D',
'@IsCustomer@=Y'
);
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53247, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.', 1,
'D', 'DunningGrace', 318, 15,
7, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 53223, 'N',
'Y'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype
)
VALUES (53257, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.',
'Y', 410 ,263,
53247, 'Y', 14, 'N',
'N', 'N', 'N', 'N', 'D'
);
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_element_id) + 1
FROM ad_element
WHERE ad_element_id < 1000000)
WHERE NAME = 'AD_Element';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_column_id) + 1
FROM ad_column
WHERE ad_column_id < 1000000)
WHERE NAME = 'AD_Column';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_field_id) + 1
FROM ad_field
WHERE ad_field_id < 1000000)
WHERE NAME = 'AD_Field';
ALTER TABLE C_BPartner ADD DunningGrace date NULL;
ALTER TABLE C_Invoice ADD DunningGrace date NULL;
CREATE OR REPLACE FORCE VIEW C_INVOICE_V AS
SELECT i.C_Invoice_ID, i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created, i.CreatedBy, i.Updated, i.UpdatedBy,
i.IsSOTrx, i.DocumentNo, i.DocStatus, i.DocAction, i.Processing, i.Processed, i.C_DocType_ID,
i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved, i.IsTransferred,
i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct, i.C_BPartner_ID, i.C_BPartner_Location_ID,
i.AD_User_ID, i.POReference, i.DateOrdered, i.C_Currency_ID, i.C_ConversionType_ID, i.PaymentRule,
i.C_PaymentTerm_ID, i.C_Charge_ID, i.M_PriceList_ID, i.C_Campaign_ID, i.C_Project_ID,
i.C_Activity_ID, i.IsPrinted, i.IsDiscountPrinted, i.IsPaid, i.IsInDispute,
i.IsPayScheduleValid, null AS C_InvoicePaySchedule_ID, i.InvoiceCollectionType,
i.DunningGrace,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.ChargeAmt*-1 ELSE i.ChargeAmt END AS ChargeAmt,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.TotalLines*-1 ELSE i.TotalLines END AS TotalLines,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN i.GrandTotal*-1 ELSE i.GrandTotal END AS GrandTotal,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END AS Multiplier,
CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1 ELSE 1 END AS MultiplierAP,
d.DocBaseType
FROM C_Invoice i
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
WHERE i.IsPayScheduleValid<>'Y'
UNION
SELECT i.C_Invoice_ID, i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created, i.CreatedBy, i.Updated, i.UpdatedBy,
i.IsSOTrx, i.DocumentNo, i.DocStatus, i.DocAction, i.Processing, i.Processed, i.C_DocType_ID,
i.C_DocTypeTarget_ID, i.C_Order_ID, i.Description, i.IsApproved, i.IsTransferred,
i.SalesRep_ID, i.DateInvoiced, i.DatePrinted, i.DateAcct, i.C_BPartner_ID, i.C_BPartner_Location_ID,
i.AD_User_ID, i.POReference, i.DateOrdered, i.C_Currency_ID, i.C_ConversionType_ID, i.PaymentRule,
i.C_PaymentTerm_ID, i.C_Charge_ID, i.M_PriceList_ID, i.C_Campaign_ID, i.C_Project_ID,
i.C_Activity_ID, i.IsPrinted, i.IsDiscountPrinted, i.IsPaid, i.IsInDispute,
i.IsPayScheduleValid, ips.C_InvoicePaySchedule_ID, i.InvoiceCollectionType,
i.DunningGrace,
null AS ChargeAmt,
null AS TotalLines,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN ips.DueAmt*-1 ELSE ips.DueAmt END AS GrandTotal,
CASE WHEN charAt(d.DocBaseType,3)='C' THEN -1 ELSE 1 END AS Multiplier,
CASE WHEN charAt(d.DocBaseType,2)='P' THEN -1 ELSE 1 END AS MultiplierAP,
d.DocBaseType
FROM C_Invoice i
INNER JOIN C_DocType d ON (i.C_DocType_ID=d.C_DocType_ID)
INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID)
WHERE i.IsPayScheduleValid='Y'
AND ips.IsValid='Y';
COMMIT ;

View File

@ -0,0 +1,183 @@
SET DEFINE OFF;
update AD_Column set IsAlwaysUpdateable='Y' where AD_Column_ID=12569;
update AD_Column set IsAlwaysUpdateable='Y' where AD_Column_ID=12566;
INSERT INTO ad_element
(ad_element_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
columnname, entitytype, NAME,
printname
)
VALUES (53224, 0, 0, 'Y',
TO_DATE ('2007-09-28', 'YYYY-MM-DD'), 100,
TO_DATE ('2007-09-28', 'YYYY-MM-DD'), 100,
'PrintUnprocessedOnly', 'D', 'Print Unprocessed Entries Only',
'Print Unprocessed Entries Only'
);
INSERT INTO AD_Process_Para
(AD_Process_Para_ID, AD_Client_ID, AD_Org_ID, IsActive, Created,
CreatedBy, Updated, UpdatedBy, Name,
Description,
Help,
AD_Process_ID, SeqNo, AD_Reference_ID, AD_Reference_Value_ID,
AD_Val_Rule_ID, ColumnName, IsCentrallyMaintained, FieldLength,
IsMandatory, DefaultValue, IsRange, AD_Element_ID, EntityType
)
VALUES
(53011 , 0, 0, 'Y', TO_DATE ('2007-09-28', 'YYYY-MM-DD'),
100, TO_DATE ('2007-09-28', 'YYYY-MM-DD'), 100, 'Print Unprocessed Entries Only',
'Print the unprocessed (unprinted) entries of the dunning run only.',
'Print the unprocessed (unprinted) entries of the dunning run only. This allows you to reprint only certain dunning entries.',
312, 50, 20, NULL,
NULL, 'PrintUnprocessedOnly', 'N', 1,
'Y', 'Y', 'N', 53224, 'D'
);
INSERT INTO AD_VAL_RULE(
AD_VAL_RULE_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,
UPDATED,UPDATEDBY,
NAME,DESCRIPTION,
TYPE,CODE,ENTITYTYPE)
values(51003,0,0,'Y',to_date('2007-09-28','RRRR-MM-DD'),100,
to_date('2007-09-28','RRRR-MM-DD'),100,
'C_DunningRun Unprocessed','Unprocessed Dunning Runs',
'S','C_DunningRun.Processed=''N''','D');
UPDATE AD_Process_Para SET AD_Val_Rule_ID=51003 WHERE AD_Process_Para_ID=578;
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53248, 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'),
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
100, 'Dunning Level', 'Dunning Level',
'Dunning Level', 1,
'D', 'C_DunningLevel_ID', 318, 19,
22, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 1075, 'N',
'N'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype,
displaylogic
)
VALUES (53258 , 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
'Dunning Level', 'Dunning Level',
'Dunning Level',
'Y', 420 ,263,
53248, 'Y', 14, 'Y',
'Y', 'N', 'N', 'N', 'D',
'@Processed@=Y'
);
ALTER TABLE C_Invoice ADD C_DunningLevel_ID NUMBER(10,0) NULL;
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53249, 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'),
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
100, 'Invoice Payment Schedule', 'Invoice Payment Schedule',
'Invoice Payment Schedule', 1,
'D', 'C_InvoicePaySchedule_ID', 524, 19,
22, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 1995, 'N',
'N'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype
)
VALUES (53259 , 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
'Invoice Payment Schedule', 'Invoice Payment Schedule',
'Invoice Payment Schedule',
'Y', 65 ,635,
53249, 'Y', 26, 'Y',
'N', 'N', 'N', 'N', 'D'
);
ALTER TABLE C_DunningRunLine ADD C_InvoicePaySchedule_ID NUMBER(10,0) NULL;
COMMIT;
UPDATE AD_SEQUENCE
SET currentnextsys = (SELECT MAX (ad_process_para_id) + 1
FROM AD_Process_Para
WHERE AD_Process_Para_ID < 1000000)
WHERE NAME = 'AD_Process_Para';
UPDATE AD_SEQUENCE
SET currentnextsys = (SELECT MAX (AD_Val_Rule_id) + 1
FROM AD_Val_Rule
WHERE AD_Val_Rule_ID < 1000000)
WHERE NAME = 'AD_Val_Rule';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_element_id) + 1
FROM ad_element
WHERE ad_element_id < 1000000)
WHERE NAME = 'AD_Element';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_column_id) + 1
FROM ad_column
WHERE ad_column_id < 1000000)
WHERE NAME = 'AD_Column';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_field_id) + 1
FROM ad_field
WHERE ad_field_id < 1000000)
WHERE NAME = 'AD_Field';
COMMIT;

View File

@ -0,0 +1,211 @@
INSERT INTO ad_element
(ad_element_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
columnname, entitytype, NAME,
printname
)
VALUES (53223, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'DunningGrace', 'D', 'Dunning Grace',
'Dunning Grace'
);
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53246, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.', 1,
'D', 'DunningGrace', 291, 15,
7, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 53223, 'N',
'N'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype,
displaylogic
)
VALUES (53256, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.',
'Y', 260 ,223,
53246, 'Y', 14, 'N',
'N', 'N', 'N', 'N', 'D',
'@IsCustomer@=Y'
);
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53247, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.', 1,
'D', 'DunningGrace', 318, 15,
7, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 53223, 'N',
'Y'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype
)
VALUES (53257, 0, 0, 'Y',
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/21/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Dunning Grace', 'Delay/block the dunning until this date is reached.',
'Delay/block the dunning until this date is reached.',
'Y', 410 ,263,
53247, 'Y', 14, 'N',
'N', 'N', 'N', 'N', 'D'
);
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_element_id) + 1
FROM ad_element
WHERE ad_element_id < 1000000)
WHERE NAME = 'AD_Element';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_column_id) + 1
FROM ad_column
WHERE ad_column_id < 1000000)
WHERE NAME = 'AD_Column';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_field_id) + 1
FROM ad_field
WHERE ad_field_id < 1000000)
WHERE NAME = 'AD_Field';
ALTER TABLE C_BPartner ADD DunningGrace date NULL;
ALTER TABLE C_Invoice ADD DunningGrace date NULL;
DROP VIEW c_invoiceline_v;
DROP VIEW rv_bpartneropen;
DROP VIEW c_invoice_v;
CREATE OR REPLACE VIEW c_invoice_v AS
SELECT i.c_invoice_id, i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.issotrx, i.documentno, i.docstatus, i.docaction, i.processing, i.processed, i.c_doctype_id, i.c_doctypetarget_id, i.c_order_id,
i.description, i.isapproved, i.istransferred, i.salesrep_id, i.dateinvoiced, i.dateprinted, i.dateacct, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, i.poreference, i.dateordered, i.c_currency_id, i.c_conversiontype_id, i.paymentrule,
i.c_paymentterm_id, i.c_charge_id, i.m_pricelist_id, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.isprinted, i.isdiscountprinted, i.ispaid, i.isindispute, i.ispayschedulevalid, NULL::numeric AS c_invoicepayschedule_id, i.invoicecollectiontype, i.dunninggrace,
CASE
WHEN charat(d.docbasetype::character varying, 3)::text = 'C'::text THEN i.chargeamt * -1::numeric
ELSE i.chargeamt
END AS chargeamt,
CASE
WHEN charat(d.docbasetype::character varying, 3)::text = 'C'::text THEN i.totallines * -1::numeric
ELSE i.totallines
END AS totallines,
CASE
WHEN charat(d.docbasetype::character varying, 3)::text = 'C'::text THEN i.grandtotal * -1::numeric
ELSE i.grandtotal
END AS grandtotal,
CASE
WHEN charat(d.docbasetype::character varying, 3)::text = 'C'::text THEN -1
ELSE 1
END::numeric AS multiplier,
CASE
WHEN charat(d.docbasetype::character varying, 2)::text = 'P'::text THEN -1
ELSE 1
END::numeric AS multiplierap, d.docbasetype
FROM c_invoice i
JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id
WHERE i.ispayschedulevalid <> 'Y'::bpchar
UNION
SELECT i.c_invoice_id, i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.issotrx, i.documentno, i.docstatus, i.docaction, i.processing, i.processed, i.c_doctype_id, i.c_doctypetarget_id, i.c_order_id,
i.description, i.isapproved, i.istransferred, i.salesrep_id, i.dateinvoiced, i.dateprinted, i.dateacct, i.c_bpartner_id, i.c_bpartner_location_id, i.ad_user_id, i.poreference, i.dateordered, i.c_currency_id, i.c_conversiontype_id, i.paymentrule,
i.c_paymentterm_id, i.c_charge_id, i.m_pricelist_id, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.isprinted, i.isdiscountprinted, i.ispaid, i.isindispute, i.ispayschedulevalid, ips.c_invoicepayschedule_id, i.invoicecollectiontype, i.dunninggrace,
NULL::"unknown" AS chargeamt, NULL::"unknown" AS totallines,
CASE
WHEN charat(d.docbasetype::character varying, 3)::text = 'C'::text THEN ips.dueamt * -1::numeric
ELSE ips.dueamt
END AS grandtotal,
CASE
WHEN charat(d.docbasetype::character varying, 3)::text = 'C'::text THEN -1
ELSE 1
END AS multiplier,
CASE
WHEN charat(d.docbasetype::character varying, 2)::text = 'P'::text THEN -1
ELSE 1
END AS multiplierap, d.docbasetype
FROM c_invoice i
JOIN c_doctype d ON i.c_doctype_id = d.c_doctype_id
JOIN c_invoicepayschedule ips ON i.c_invoice_id = ips.c_invoice_id
WHERE i.ispayschedulevalid = 'Y'::bpchar AND ips.isvalid = 'Y'::bpchar;
CREATE OR REPLACE VIEW c_invoiceline_v AS
SELECT il.ad_client_id, il.ad_org_id, il.c_invoiceline_id, i.c_invoice_id, i.salesrep_id, i.c_bpartner_id, il.m_product_id, i.documentno, i.dateinvoiced, i.dateacct, i.issotrx, i.docstatus, round(i.multiplier * il.linenetamt, 2) AS linenetamt, round(i.multiplier * il.pricelist * il.qtyinvoiced, 2) AS linelistamt,
CASE
WHEN COALESCE(il.pricelimit, 0::numeric) = 0::numeric THEN round(i.multiplier * il.linenetamt, 2)
ELSE round(i.multiplier * il.pricelimit * il.qtyinvoiced, 2)
END AS linelimitamt, round(i.multiplier * il.pricelist * il.qtyinvoiced - il.linenetamt, 2) AS linediscountamt,
CASE
WHEN COALESCE(il.pricelimit, 0::numeric) = 0::numeric THEN 0::numeric
ELSE round(i.multiplier * il.linenetamt - il.pricelimit * il.qtyinvoiced, 2)
END AS lineoverlimitamt, il.qtyinvoiced, il.qtyentered, il.line, il.c_orderline_id, il.c_uom_id, il.c_campaign_id, il.c_project_id, il.c_activity_id, il.c_projectphase_id, il.c_projecttask_id
FROM c_invoice_v i, c_invoiceline il
WHERE i.c_invoice_id = il.c_invoice_id;
CREATE OR REPLACE VIEW rv_bpartneropen AS
SELECT i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.c_bpartner_id, i.c_currency_id, i.grandtotal * i.multiplierap AS amt, invoiceopen(i.c_invoice_id, i.c_invoicepayschedule_id) * i.multiplierap AS openamt, i.dateinvoiced AS datedoc, COALESCE(daysbetween(getdate(), ips.duedate::timestamp with time zone), paymenttermduedays(i.c_paymentterm_id, i.dateinvoiced::timestamp with time zone, getdate())) AS daysdue, i.c_campaign_id, i.c_project_id, i.c_activity_id
FROM c_invoice_v i
LEFT JOIN c_invoicepayschedule ips ON i.c_invoicepayschedule_id = ips.c_invoicepayschedule_id
WHERE i.ispaid = 'N'::bpchar AND (i.docstatus = ANY (ARRAY['CO'::bpchar, 'CL'::bpchar]))
UNION
SELECT p.ad_client_id, p.ad_org_id, p.isactive, p.created, p.createdby, p.updated, p.updatedby, p.c_bpartner_id, p.c_currency_id, p.payamt * p.multiplierap::numeric * -1::numeric AS amt, paymentavailable(p.c_payment_id) * p.multiplierap::numeric * -1::numeric AS openamt, p.datetrx AS datedoc, NULL::"unknown" AS daysdue, p.c_campaign_id, p.c_project_id, p.c_activity_id
FROM c_payment_v p
WHERE p.isallocated = 'N'::bpchar AND p.c_bpartner_id IS NOT NULL AND (p.docstatus = ANY (ARRAY['CO'::bpchar, 'CL'::bpchar]));
COMMIT ;

View File

@ -0,0 +1,179 @@
update AD_Column set IsAlwaysUpdateable='Y' where AD_Column_ID=12569;
update AD_Column set IsAlwaysUpdateable='Y' where AD_Column_ID=12566;
INSERT INTO ad_element
(ad_element_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
columnname, entitytype, NAME,
printname
)
VALUES (53224, 0, 0, 'Y',
TO_DATE ('2007-09-28', 'YYYY-MM-DD'), 100,
TO_DATE ('2007-09-28', 'YYYY-MM-DD'), 100,
'PrintUnprocessedOnly', 'D', 'Print Unprocessed Entries Only',
'Print Unprocessed Entries Only'
);
INSERT INTO AD_Process_Para
(AD_Process_Para_ID, AD_Client_ID, AD_Org_ID, IsActive, Created,
CreatedBy, Updated, UpdatedBy, Name,
Description,
Help,
AD_Process_ID, SeqNo, AD_Reference_ID, AD_Reference_Value_ID,
AD_Val_Rule_ID, ColumnName, IsCentrallyMaintained, FieldLength,
IsMandatory, DefaultValue, IsRange, AD_Element_ID, EntityType
)
VALUES
(53011 , 0, 0, 'Y', TO_DATE ('2007-09-28', 'YYYY-MM-DD'),
100, TO_DATE ('2007-09-28', 'YYYY-MM-DD'), 100, 'Print Unprocessed Entries Only',
'Print the unprocessed (unprinted) entries of the dunning run only.',
'Print the unprocessed (unprinted) entries of the dunning run only. This allows you to reprint only certain dunning entries.',
312, 50, 20, NULL,
NULL, 'PrintUnprocessedOnly', 'N', 1,
'Y', 'Y', 'N', 53224, 'D'
);
INSERT INTO AD_VAL_RULE(
AD_VAL_RULE_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,
UPDATED,UPDATEDBY,
NAME,DESCRIPTION,
TYPE,CODE,ENTITYTYPE)
values(51003,0,0,'Y',to_date('2007-09-28','RRRR-MM-DD'),100,
to_date('2007-09-28','RRRR-MM-DD'),100,
'C_DunningRun Unprocessed','Unprocessed Dunning Runs',
'S','C_DunningRun.Processed=''N''','D');
UPDATE AD_Process_Para SET AD_Val_Rule_ID=51003 WHERE AD_Process_Para_ID=578;
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53248, 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'),
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
100, 'Dunning Level', 'Dunning Level',
'Dunning Level', 1,
'D', 'C_DunningLevel_ID', 318, 19,
22, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 1075, 'N',
'N'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype,
displaylogic
)
VALUES (53258 , 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
'Dunning Level', 'Dunning Level',
'Dunning Level',
'Y', 420 ,263,
53248, 'Y', 14, 'Y',
'Y', 'N', 'N', 'N', 'D',
'@Processed@=Y'
);
ALTER TABLE C_Invoice ADD C_DunningLevel_ID NUMERIC(10) NULL;
INSERT INTO ad_column
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
help, VERSION,
entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, seqno, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53249, 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'),
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
100, 'Invoice Payment Schedule', 'Invoice Payment Schedule',
'Invoice Payment Schedule', 1,
'D', 'C_InvoicePaySchedule_ID', 524, 19,
22, 'N', 'N', 'N', 'Y',
'N', 0, 'N', 'N',
'N', 1995, 'N',
'N'
);
INSERT INTO ad_field
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
help,
iscentrallymaintained, seqno, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly,
issameline, isheading, isfieldonly, isencrypted, entitytype
)
VALUES (53259 , 0, 0, 'Y',
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
TO_DATE ('2007-09-28','RRRR-MM-DD'), 100,
'Invoice Payment Schedule', 'Invoice Payment Schedule',
'Invoice Payment Schedule',
'Y', 65 ,635,
53249, 'Y', 26, 'Y',
'N', 'N', 'N', 'N', 'D'
);
ALTER TABLE C_DunningRunLine ADD C_InvoicePaySchedule_ID NUMERIC(10) NULL;
COMMIT;
UPDATE AD_SEQUENCE
SET currentnextsys = (SELECT MAX (ad_process_para_id) + 1
FROM AD_Process_Para
WHERE AD_Process_Para_ID < 1000000)
WHERE NAME = 'AD_Process_Para';
UPDATE AD_SEQUENCE
SET currentnextsys = (SELECT MAX (AD_Val_Rule_id) + 1
FROM AD_Val_Rule
WHERE AD_Val_Rule_ID < 1000000)
WHERE NAME = 'AD_Val_Rule';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_element_id) + 1
FROM ad_element
WHERE ad_element_id < 1000000)
WHERE NAME = 'AD_Element';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_column_id) + 1
FROM ad_column
WHERE ad_column_id < 1000000)
WHERE NAME = 'AD_Column';
UPDATE ad_sequence
SET currentnextsys = (SELECT MAX (ad_field_id) + 1
FROM ad_field
WHERE ad_field_id < 1000000)
WHERE NAME = 'AD_Field';
COMMIT;