Adempiere 3.1.2
This commit is contained in:
parent
39a4889c05
commit
6c5fa90281
|
@ -103,25 +103,25 @@ public class CalloutOrder extends CalloutEngine
|
||||||
|
|
||||||
// Delivery Rule
|
// Delivery Rule
|
||||||
if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS))
|
if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS))
|
||||||
mTab.setValue ("DeliveryRule", MOrder.DELIVERYRULE_Force);
|
mTab.setValue ("DeliveryRule", X_C_Order.DELIVERYRULE_Force);
|
||||||
else if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_Prepay))
|
else if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_Prepay))
|
||||||
mTab.setValue ("DeliveryRule", MOrder.DELIVERYRULE_AfterReceipt);
|
mTab.setValue ("DeliveryRule", X_C_Order.DELIVERYRULE_AfterReceipt);
|
||||||
else
|
else
|
||||||
mTab.setValue ("DeliveryRule", MOrder.DELIVERYRULE_Availability);
|
mTab.setValue ("DeliveryRule", X_C_Order.DELIVERYRULE_Availability);
|
||||||
|
|
||||||
// Invoice Rule
|
// Invoice Rule
|
||||||
if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS)
|
if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS)
|
||||||
|| DocSubTypeSO.equals(MOrder.DocSubTypeSO_Prepay)
|
|| DocSubTypeSO.equals(MOrder.DocSubTypeSO_Prepay)
|
||||||
|| DocSubTypeSO.equals(MOrder.DocSubTypeSO_OnCredit) )
|
|| DocSubTypeSO.equals(MOrder.DocSubTypeSO_OnCredit) )
|
||||||
mTab.setValue ("InvoiceRule", MOrder.INVOICERULE_Immediate);
|
mTab.setValue ("InvoiceRule", X_C_Order.INVOICERULE_Immediate);
|
||||||
else
|
else
|
||||||
mTab.setValue ("InvoiceRule", MOrder.INVOICERULE_AfterDelivery);
|
mTab.setValue ("InvoiceRule", X_C_Order.INVOICERULE_AfterDelivery);
|
||||||
|
|
||||||
// Payment Rule - POS Order
|
// Payment Rule - POS Order
|
||||||
if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS))
|
if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS))
|
||||||
mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_Cash);
|
mTab.setValue("PaymentRule", X_C_Order.PAYMENTRULE_Cash);
|
||||||
else
|
else
|
||||||
mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_OnCredit);
|
mTab.setValue("PaymentRule", X_C_Order.PAYMENTRULE_OnCredit);
|
||||||
|
|
||||||
// IsSOTrx
|
// IsSOTrx
|
||||||
if ("N".equals(rs.getString(8)))
|
if ("N".equals(rs.getString(8)))
|
||||||
|
@ -344,16 +344,16 @@ public class CalloutOrder extends CalloutEngine
|
||||||
|
|
||||||
// Defaults, if not Walkin Receipt or Walkin Invoice
|
// Defaults, if not Walkin Receipt or Walkin Invoice
|
||||||
String OrderType = Env.getContext(ctx, WindowNo, "OrderType");
|
String OrderType = Env.getContext(ctx, WindowNo, "OrderType");
|
||||||
mTab.setValue("InvoiceRule", MOrder.INVOICERULE_AfterDelivery);
|
mTab.setValue("InvoiceRule", X_C_Order.INVOICERULE_AfterDelivery);
|
||||||
mTab.setValue("DeliveryRule", MOrder.DELIVERYRULE_Availability);
|
mTab.setValue("DeliveryRule", X_C_Order.DELIVERYRULE_Availability);
|
||||||
mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_OnCredit);
|
mTab.setValue("PaymentRule", X_C_Order.PAYMENTRULE_OnCredit);
|
||||||
if (OrderType.equals(MOrder.DocSubTypeSO_Prepay))
|
if (OrderType.equals(MOrder.DocSubTypeSO_Prepay))
|
||||||
{
|
{
|
||||||
mTab.setValue("InvoiceRule", MOrder.INVOICERULE_Immediate);
|
mTab.setValue("InvoiceRule", X_C_Order.INVOICERULE_Immediate);
|
||||||
mTab.setValue("DeliveryRule", MOrder.DELIVERYRULE_AfterReceipt);
|
mTab.setValue("DeliveryRule", X_C_Order.DELIVERYRULE_AfterReceipt);
|
||||||
}
|
}
|
||||||
else if (OrderType.equals(MOrder.DocSubTypeSO_POS)) // for POS
|
else if (OrderType.equals(MOrder.DocSubTypeSO_POS)) // for POS
|
||||||
mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_Cash);
|
mTab.setValue("PaymentRule", X_C_Order.PAYMENTRULE_Cash);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// PaymentRule
|
// PaymentRule
|
||||||
|
@ -519,12 +519,12 @@ public class CalloutOrder extends CalloutEngine
|
||||||
|
|
||||||
// Defaults, if not Walkin Receipt or Walkin Invoice
|
// Defaults, if not Walkin Receipt or Walkin Invoice
|
||||||
String OrderType = Env.getContext(ctx, WindowNo, "OrderType");
|
String OrderType = Env.getContext(ctx, WindowNo, "OrderType");
|
||||||
mTab.setValue("InvoiceRule", MOrder.INVOICERULE_AfterDelivery);
|
mTab.setValue("InvoiceRule", X_C_Order.INVOICERULE_AfterDelivery);
|
||||||
mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_OnCredit);
|
mTab.setValue("PaymentRule", X_C_Order.PAYMENTRULE_OnCredit);
|
||||||
if (OrderType.equals(MOrder.DocSubTypeSO_Prepay))
|
if (OrderType.equals(MOrder.DocSubTypeSO_Prepay))
|
||||||
mTab.setValue("InvoiceRule", MOrder.INVOICERULE_Immediate);
|
mTab.setValue("InvoiceRule", X_C_Order.INVOICERULE_Immediate);
|
||||||
else if (OrderType.equals(MOrder.DocSubTypeSO_POS)) // for POS
|
else if (OrderType.equals(MOrder.DocSubTypeSO_POS)) // for POS
|
||||||
mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_Cash);
|
mTab.setValue("PaymentRule", X_C_Order.PAYMENTRULE_Cash);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// PaymentRule
|
// PaymentRule
|
||||||
|
|
|
@ -2137,15 +2137,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
} // setCurrentRow
|
} // setCurrentRow
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set current row - used for deleteSelection
|
|
||||||
* @return current row
|
|
||||||
*/
|
|
||||||
public void setCurrentRow(int row){
|
|
||||||
setCurrentRow(row, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Get RowCount
|
* Get RowCount
|
||||||
* @return row count
|
* @return row count
|
||||||
|
@ -2469,5 +2460,4 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
m_listenerList.add(DataStatusListener.class, l);
|
m_listenerList.add(DataStatusListener.class, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // MTab
|
} // MTab
|
||||||
|
|
|
@ -18,6 +18,10 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BP Bank Account Model
|
* BP Bank Account Model
|
||||||
|
@ -27,7 +31,53 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class MBPBankAccount extends X_C_BP_BankAccount
|
public class MBPBankAccount extends X_C_BP_BankAccount
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get Accounst Of BPartner
|
||||||
|
* @param ctx context
|
||||||
|
* @param C_BPartner_ID bpartner
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
String sql = "SELECT * FROM C_BP_BankAccount WHERE C_BPartner_ID=? AND IsActive='Y'";
|
||||||
|
ArrayList<MBPBankAccount> list = new ArrayList<MBPBankAccount>();
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
list.add(new MBPBankAccount(ctx, rs, null));
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MBPBankAccount[] retValue = new MBPBankAccount[list.size()];
|
||||||
|
list.toArray(retValue);
|
||||||
|
return retValue;
|
||||||
|
} // getOfBPartner
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger s_log = CLogger.getCLogger(MBPBankAccount.class);
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param C_BP_BankAccount_ID BP bank account
|
* @param C_BP_BankAccount_ID BP bank account
|
||||||
|
@ -40,6 +90,7 @@ public class MBPBankAccount extends X_C_BP_BankAccount
|
||||||
{
|
{
|
||||||
// setC_BPartner_ID (0);
|
// setC_BPartner_ID (0);
|
||||||
setIsACH (false);
|
setIsACH (false);
|
||||||
|
setBPBankAcctUse(BPBANKACCTUSE_Both);
|
||||||
}
|
}
|
||||||
} // MBP_BankAccount
|
} // MBP_BankAccount
|
||||||
|
|
||||||
|
@ -63,7 +114,7 @@ public class MBPBankAccount extends X_C_BP_BankAccount
|
||||||
*/
|
*/
|
||||||
public MBPBankAccount (Properties ctx, MBPartner bp, MUser bpc, MLocation location)
|
public MBPBankAccount (Properties ctx, MBPartner bp, MUser bpc, MLocation location)
|
||||||
{
|
{
|
||||||
super(ctx, 0, bp.get_TrxName());
|
this(ctx, 0, bp.get_TrxName());
|
||||||
setIsACH (false);
|
setIsACH (false);
|
||||||
//
|
//
|
||||||
setC_BPartner_ID(bp.getC_BPartner_ID());
|
setC_BPartner_ID(bp.getC_BPartner_ID());
|
||||||
|
@ -78,8 +129,78 @@ public class MBPBankAccount extends X_C_BP_BankAccount
|
||||||
setA_Country(location.getCountryName());
|
setA_Country(location.getCountryName());
|
||||||
} // MBP_BankAccount
|
} // MBP_BankAccount
|
||||||
|
|
||||||
|
/** Bank Link */
|
||||||
|
private MBank m_bank = null;
|
||||||
|
|
||||||
/*************************************************************************/
|
/**
|
||||||
|
* Is Direct Deposit
|
||||||
|
* @return true if dd
|
||||||
|
*/
|
||||||
|
public boolean isDirectDeposit()
|
||||||
|
{
|
||||||
|
if (!isACH())
|
||||||
|
return false;
|
||||||
|
String s = getBPBankAcctUse();
|
||||||
|
if (s == null)
|
||||||
|
return true;
|
||||||
|
return (s.equals(BPBANKACCTUSE_Both) || s.equals(BPBANKACCTUSE_DirectDeposit));
|
||||||
|
} // isDirectDeposit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is Direct Debit
|
||||||
|
* @return true if dd
|
||||||
|
*/
|
||||||
|
public boolean isDirectDebit()
|
||||||
|
{
|
||||||
|
if (!isACH())
|
||||||
|
return false;
|
||||||
|
String s = getBPBankAcctUse();
|
||||||
|
if (s == null)
|
||||||
|
return true;
|
||||||
|
return (s.equals(BPBANKACCTUSE_Both) || s.equals(BPBANKACCTUSE_DirectDebit));
|
||||||
|
} // isDirectDebit
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Bank
|
||||||
|
* @return bank
|
||||||
|
*/
|
||||||
|
public MBank getBank()
|
||||||
|
{
|
||||||
|
int C_BP_BankAccount_ID = getC_BP_BankAccount_ID();
|
||||||
|
if (C_BP_BankAccount_ID == 0)
|
||||||
|
return null;
|
||||||
|
if (m_bank == null)
|
||||||
|
m_bank = new MBank (getCtx(), C_BP_BankAccount_ID, get_TrxName());
|
||||||
|
return m_bank;
|
||||||
|
} // getBank
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Routing No
|
||||||
|
* @return routing No
|
||||||
|
*/
|
||||||
|
public String getRoutingNo()
|
||||||
|
{
|
||||||
|
MBank bank = getBank();
|
||||||
|
String rt = super.getRoutingNo();
|
||||||
|
if (bank != null)
|
||||||
|
rt = bank.getRoutingNo();
|
||||||
|
return rt;
|
||||||
|
} // getRoutingNo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before Save
|
||||||
|
* @param newRecord new
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
protected boolean beforeSave(boolean newRecord)
|
||||||
|
{
|
||||||
|
// maintain routing on bank level
|
||||||
|
if (isACH() && getBank() != null)
|
||||||
|
setRoutingNo(null);
|
||||||
|
//
|
||||||
|
return true;
|
||||||
|
} // beforeSave
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
|
|
|
@ -97,6 +97,7 @@ public class MChat extends X_CM_Chat
|
||||||
// setAD_Table_ID (0);
|
// setAD_Table_ID (0);
|
||||||
// setRecord_ID (0);
|
// setRecord_ID (0);
|
||||||
setConfidentialType (CONFIDENTIALTYPE_PublicInformation);
|
setConfidentialType (CONFIDENTIALTYPE_PublicInformation);
|
||||||
|
setModerationType (MODERATIONTYPE_NotModerated);
|
||||||
// setDescription (null);
|
// setDescription (null);
|
||||||
}
|
}
|
||||||
} // MChat
|
} // MChat
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.compiere.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chat Entry Model
|
* Chat Entry Model
|
||||||
|
@ -37,6 +36,11 @@ public class MChatEntry extends X_CM_ChatEntry
|
||||||
public MChatEntry (Properties ctx, int CM_ChatEntry_ID, String trxName)
|
public MChatEntry (Properties ctx, int CM_ChatEntry_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, CM_ChatEntry_ID, trxName);
|
super (ctx, CM_ChatEntry_ID, trxName);
|
||||||
|
if (CM_ChatEntry_ID == 0)
|
||||||
|
{
|
||||||
|
setChatEntryType (CHATENTRYTYPE_NoteFlat); // N
|
||||||
|
setConfidentialType (CONFIDENTIALTYPE_PublicInformation);
|
||||||
|
}
|
||||||
} // MChatEntry
|
} // MChatEntry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +54,27 @@ public class MChatEntry extends X_CM_ChatEntry
|
||||||
setCM_Chat_ID(chat.getCM_Chat_ID());
|
setCM_Chat_ID(chat.getCM_Chat_ID());
|
||||||
setConfidentialType(chat.getConfidentialType());
|
setConfidentialType(chat.getConfidentialType());
|
||||||
setCharacterData(data);
|
setCharacterData(data);
|
||||||
|
setChatEntryType (CHATENTRYTYPE_NoteFlat); // N
|
||||||
|
} // MChatEntry
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread Constructor
|
||||||
|
* @param entry peer
|
||||||
|
* @param data text
|
||||||
|
*/
|
||||||
|
public MChatEntry (MChatEntry peer, String data)
|
||||||
|
{
|
||||||
|
this (peer.getCtx(), 0, peer.get_TrxName());
|
||||||
|
setCM_Chat_ID(peer.getCM_Chat_ID());
|
||||||
|
setCM_ChatEntryParent_ID (peer.getCM_ChatEntryParent_ID());
|
||||||
|
// Set GrandParent
|
||||||
|
int id = peer.getCM_ChatEntryGrandParent_ID();
|
||||||
|
if (id == 0)
|
||||||
|
id = peer.getCM_ChatEntryParent_ID();
|
||||||
|
setCM_ChatEntryGrandParent_ID (id);
|
||||||
|
setConfidentialType(peer.getConfidentialType());
|
||||||
|
setCharacterData(data);
|
||||||
|
setChatEntryType (CHATENTRYTYPE_ForumThreaded);
|
||||||
} // MChatEntry
|
} // MChatEntry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,6 +59,8 @@ public class MChatType extends X_CM_ChatType
|
||||||
public MChatType (Properties ctx, int CM_ChatType_ID, String trxName)
|
public MChatType (Properties ctx, int CM_ChatType_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, CM_ChatType_ID, trxName);
|
super (ctx, CM_ChatType_ID, trxName);
|
||||||
|
if (CM_ChatType_ID == 0)
|
||||||
|
setModerationType (MODERATIONTYPE_NotModerated);
|
||||||
} // MChatType
|
} // MChatType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,6 +29,92 @@ import org.compiere.util.*;
|
||||||
*/
|
*/
|
||||||
public class MContainer extends X_CM_Container
|
public class MContainer extends X_CM_Container
|
||||||
{
|
{
|
||||||
|
/** serialVersionUID */
|
||||||
|
private static final long serialVersionUID = 395679572291279730L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Container by Relative URL
|
||||||
|
* @param ctx
|
||||||
|
* @param relURL
|
||||||
|
* @param CM_WebProject_Id
|
||||||
|
* @param trxName
|
||||||
|
* @return Container or null if not found
|
||||||
|
*/
|
||||||
|
public static MContainer get(Properties ctx, String relURL, int CM_WebProject_Id, String trxName) {
|
||||||
|
MContainer thisContainer = null;
|
||||||
|
String sql = "SELECT * FROM CM_Container WHERE (RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
|
pstmt.setString (1,relURL);
|
||||||
|
pstmt.setString (2,relURL+"/");
|
||||||
|
pstmt.setInt(3, CM_WebProject_Id);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
thisContainer = (new MContainer(ctx, rs, trxName));
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
return thisContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Container
|
||||||
|
* @param ctx
|
||||||
|
* @param CM_Container_ID
|
||||||
|
* @param CM_WebProject_Id
|
||||||
|
* @param trxName
|
||||||
|
* @return Container or null if not found
|
||||||
|
*/
|
||||||
|
public static MContainer get(Properties ctx, int CM_Container_ID, int CM_WebProject_Id, String trxName) {
|
||||||
|
MContainer thisContainer = null;
|
||||||
|
String sql = "SELECT * FROM CM_Container WHERE CM_Container_ID=? AND CM_WebProject_ID=?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
|
pstmt.setInt(1, CM_Container_ID);
|
||||||
|
pstmt.setInt(2, CM_WebProject_Id);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
thisContainer = (new MContainer(ctx, rs, trxName));
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
return thisContainer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy Stage into Container
|
* Copy Stage into Container
|
||||||
|
|
|
@ -29,6 +29,51 @@ import org.compiere.util.*;
|
||||||
*/
|
*/
|
||||||
public class MContainerElement extends X_CM_Container_Element
|
public class MContainerElement extends X_CM_Container_Element
|
||||||
{
|
{
|
||||||
|
/** serialVersionUID */
|
||||||
|
private static final long serialVersionUID = 7230036377422361941L;
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger s_log = CLogger.getCLogger (MContainer.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Container Element by ID
|
||||||
|
* @param ctx
|
||||||
|
* @param CM_ContainerElement_ID
|
||||||
|
* @param trxName
|
||||||
|
* @return ContainerElement
|
||||||
|
*/
|
||||||
|
public static MContainerElement get(Properties ctx, int CM_ContainerElement_ID, String trxName) {
|
||||||
|
MContainerElement thisContainerElement = null;
|
||||||
|
String sql = "SELECT * FROM CM_Container_Element WHERE CM_Container_Element_ID=?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
|
pstmt.setInt(1, CM_ContainerElement_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
thisContainerElement = (new MContainerElement(ctx, rs, trxName));
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
return thisContainerElement;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,6 +18,9 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +31,9 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class MDunningLevel extends X_C_DunningLevel
|
public class MDunningLevel extends X_C_DunningLevel
|
||||||
{
|
{
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger s_log = CLogger.getCLogger (MPayment.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -50,4 +56,62 @@ public class MDunningLevel extends X_C_DunningLevel
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} // MDunningLevel
|
} // MDunningLevel
|
||||||
|
|
||||||
|
private MDunning m_dunning = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Parent
|
||||||
|
* @return Parent Dunning
|
||||||
|
*/
|
||||||
|
public MDunning getParent()
|
||||||
|
{
|
||||||
|
if (m_dunning==null)
|
||||||
|
m_dunning = new MDunning(getCtx(), getC_Dunning_ID(), get_TrxName());
|
||||||
|
return m_dunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Previous Levels
|
||||||
|
* @return Array of previous DunningLevels
|
||||||
|
*/
|
||||||
|
public MDunningLevel[] getPreviousLevels()
|
||||||
|
{
|
||||||
|
// Prevent generation if not Sequentially
|
||||||
|
if (!getParent().isCreateLevelsSequentially ())
|
||||||
|
return null;
|
||||||
|
ArrayList<MDunningLevel> list = new ArrayList<MDunningLevel>();
|
||||||
|
String sql = "SELECT * FROM C_DunningLevel WHERE C_Dunning_ID=? AND DaysAfterDue+DaysBetweenDunning<?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
|
pstmt.setInt(1, getParent().get_ID ());
|
||||||
|
int totalDays = getDaysAfterDue ().intValue ()+getDaysBetweenDunning ();
|
||||||
|
pstmt.setInt(2, totalDays);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
list.add(new MDunningLevel(getCtx(), rs, get_TrxName()));
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
MDunningLevel[] retValue = new MDunningLevel[list.size()];
|
||||||
|
list.toArray(retValue);
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
} // MDunningLevel
|
} // MDunningLevel
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +29,9 @@ import org.compiere.util.*;
|
||||||
*/
|
*/
|
||||||
public class MDunningRunEntry extends X_C_DunningRunEntry
|
public class MDunningRunEntry extends X_C_DunningRunEntry
|
||||||
{
|
{
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger s_log = CLogger.getCLogger (MPayment.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -133,4 +137,72 @@ public class MDunningRunEntry extends X_C_DunningRunEntry
|
||||||
setSalesRep_ID (SalesRep_ID);
|
setSalesRep_ID (SalesRep_ID);
|
||||||
} // setBPartner
|
} // setBPartner
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Lines
|
||||||
|
* @return Array of all lines for this Run
|
||||||
|
*/
|
||||||
|
public MDunningRunLine[] getLines()
|
||||||
|
{
|
||||||
|
ArrayList<MDunningRunLine> list = new ArrayList<MDunningRunLine>();
|
||||||
|
String sql = "SELECT * FROM C_DunningRunLine WHERE C_DunningRunEntry_ID=?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
|
pstmt.setInt(1, get_ID ());
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
|
list.add(new MDunningRunLine(getCtx(), rs, get_TrxName()));
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
MDunningRunLine[] retValue = new MDunningRunLine[list.size()];
|
||||||
|
list.toArray(retValue);
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean beforeSave (boolean newRecord)
|
||||||
|
{
|
||||||
|
// Set Amt
|
||||||
|
if (isProcessed ())
|
||||||
|
{
|
||||||
|
MDunningRunLine[] theseLines = getLines();
|
||||||
|
for (int i=0;i<theseLines.length;i++)
|
||||||
|
{
|
||||||
|
theseLines[i].setProcessed (true);
|
||||||
|
theseLines[i].save (get_TrxName());
|
||||||
|
}
|
||||||
|
if (m_parent.getLevel ().isSetCreditStop () || m_parent.getLevel ().isSetPaymentTerm ())
|
||||||
|
{
|
||||||
|
MBPartner thisBPartner = MBPartner.get (getCtx(), getC_BPartner_ID());
|
||||||
|
if (m_parent.getLevel ().isSetCreditStop ())
|
||||||
|
thisBPartner.setSOCreditStatus (X_C_BPartner.SOCREDITSTATUS_CreditStop);
|
||||||
|
if (m_parent.getLevel ().isSetPaymentTerm ())
|
||||||
|
thisBPartner.setC_PaymentTerm_ID (m_parent.getLevel().getC_PaymentTerm_ID ());
|
||||||
|
thisBPartner.save ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} // beforeSave
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // MDunningRunEntry
|
} // MDunningRunEntry
|
||||||
|
|
|
@ -138,6 +138,7 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
||||||
* @param C_Currency_ID
|
* @param C_Currency_ID
|
||||||
* @param GrandTotal
|
* @param GrandTotal
|
||||||
* @param Open
|
* @param Open
|
||||||
|
* @param FeeAmount
|
||||||
* @param DaysDue
|
* @param DaysDue
|
||||||
* @param IsInDispute
|
* @param IsInDispute
|
||||||
* @param TimesDunned
|
* @param TimesDunned
|
||||||
|
@ -145,6 +146,7 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
||||||
*/
|
*/
|
||||||
public void setInvoice (int C_Invoice_ID, int C_Currency_ID,
|
public void setInvoice (int C_Invoice_ID, int C_Currency_ID,
|
||||||
BigDecimal GrandTotal, BigDecimal Open,
|
BigDecimal GrandTotal, BigDecimal Open,
|
||||||
|
BigDecimal FeeAmount,
|
||||||
int DaysDue, boolean IsInDispute,
|
int DaysDue, boolean IsInDispute,
|
||||||
int TimesDunned, int DaysAfterLast)
|
int TimesDunned, int DaysAfterLast)
|
||||||
{
|
{
|
||||||
|
@ -152,6 +154,7 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
||||||
m_C_CurrencyFrom_ID = C_Currency_ID;
|
m_C_CurrencyFrom_ID = C_Currency_ID;
|
||||||
setAmt (GrandTotal);
|
setAmt (GrandTotal);
|
||||||
setOpenAmt (Open);
|
setOpenAmt (Open);
|
||||||
|
setFeeAmt (FeeAmount);
|
||||||
setConvertedAmt (MConversionRate.convert(getCtx(), getOpenAmt(),
|
setConvertedAmt (MConversionRate.convert(getCtx(), getOpenAmt(),
|
||||||
C_Currency_ID, getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
C_Currency_ID, getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
||||||
setIsInDispute(IsInDispute);
|
setIsInDispute(IsInDispute);
|
||||||
|
@ -160,6 +163,22 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
||||||
} // setInvoice
|
} // setInvoice
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Fee
|
||||||
|
* @param C_Currency_ID
|
||||||
|
* @param FeeAmount
|
||||||
|
*/
|
||||||
|
public void setFee (int C_Currency_ID,
|
||||||
|
BigDecimal FeeAmount)
|
||||||
|
{
|
||||||
|
m_C_CurrencyFrom_ID = C_Currency_ID;
|
||||||
|
setAmt (FeeAmount);
|
||||||
|
setOpenAmt (FeeAmount);
|
||||||
|
setFeeAmt (FeeAmount);
|
||||||
|
setConvertedAmt (MConversionRate.convert(getCtx(), getOpenAmt(),
|
||||||
|
C_Currency_ID, getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
||||||
|
} // setInvoice
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Payment
|
* Get Payment
|
||||||
* @return Returns the payment.
|
* @return Returns the payment.
|
||||||
|
@ -262,6 +281,15 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
||||||
getC_CurrencyFrom_ID(), getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
getC_CurrencyFrom_ID(), getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
||||||
// Total
|
// Total
|
||||||
setTotalAmt(getConvertedAmt().add(getFeeAmt()).add(getInterestAmt()));
|
setTotalAmt(getConvertedAmt().add(getFeeAmt()).add(getInterestAmt()));
|
||||||
|
// Reset Collection Status only if null
|
||||||
|
if (getInvoice().getInvoiceCollectionType ()==null)
|
||||||
|
{
|
||||||
|
if (m_invoice!=null)
|
||||||
|
{
|
||||||
|
m_invoice.setInvoiceCollectionType (X_C_Invoice.INVOICECOLLECTIONTYPE_Dunning);
|
||||||
|
m_invoice.save ();
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
@ -296,10 +324,17 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
||||||
*/
|
*/
|
||||||
private void updateEntry()
|
private void updateEntry()
|
||||||
{
|
{
|
||||||
|
// we do not count the fee line as an item, but it sum it up.
|
||||||
String sql = "UPDATE C_DunningRunEntry e "
|
String sql = "UPDATE C_DunningRunEntry e "
|
||||||
+ "SET (Amt,Qty)=(SELECT SUM(Amt),COUNT(*) FROM C_DunningRunLine l "
|
+ "SET Amt=(SELECT SUM(ConvertedAmt)+SUM(FeeAmt)"
|
||||||
+ "WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID) "
|
+ " FROM C_DunningRunLine l "
|
||||||
|
+ "WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID), "
|
||||||
|
+ "QTY=(SELECT COUNT(*)"
|
||||||
|
+ " FROM C_DunningRunLine l "
|
||||||
|
+ "WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID "
|
||||||
|
+ " AND (NOT C_Invoice_ID IS NULL OR NOT C_Payment_ID IS NULL))"
|
||||||
+ " WHERE C_DunningRunEntry_ID=" + getC_DunningRunEntry_ID();
|
+ " WHERE C_DunningRunEntry_ID=" + getC_DunningRunEntry_ID();
|
||||||
|
|
||||||
DB.executeUpdate(sql, get_TrxName());
|
DB.executeUpdate(sql, get_TrxName());
|
||||||
} // updateEntry
|
} // updateEntry
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.*;
|
||||||
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
@ -32,6 +33,49 @@ import org.compiere.util.*;
|
||||||
*/
|
*/
|
||||||
public class MInterestArea extends X_R_InterestArea
|
public class MInterestArea extends X_R_InterestArea
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get all active interest areas
|
||||||
|
* @param ctx context
|
||||||
|
* @return interest areas
|
||||||
|
*/
|
||||||
|
public static MInterestArea[] getAll (Properties ctx)
|
||||||
|
{
|
||||||
|
ArrayList<MInterestArea> list = new ArrayList<MInterestArea>();
|
||||||
|
String sql = "SELECT * FROM R_InterestArea WHERE IsActive='Y'";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
|
while (rs.next ())
|
||||||
|
{
|
||||||
|
MInterestArea ia = new MInterestArea (ctx, rs, null);
|
||||||
|
list.add (ia);
|
||||||
|
}
|
||||||
|
rs.close ();
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
MInterestArea[] retValue = new MInterestArea[list.size ()];
|
||||||
|
list.toArray (retValue);
|
||||||
|
return retValue;
|
||||||
|
} // getAll
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get MInterestArea from Cache
|
* Get MInterestArea from Cache
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -51,7 +95,10 @@ public class MInterestArea extends X_R_InterestArea
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/** Cache */
|
/** Cache */
|
||||||
private static CCache<Integer,MInterestArea> s_cache = new CCache<Integer,MInterestArea>("R_InterestArea", 5);
|
private static CCache<Integer,MInterestArea> s_cache =
|
||||||
|
new CCache<Integer,MInterestArea>("R_InterestArea", 5);
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger s_log = CLogger.getCLogger (MInterestArea.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +114,7 @@ public class MInterestArea extends X_R_InterestArea
|
||||||
{
|
{
|
||||||
// setName (null);
|
// setName (null);
|
||||||
// setR_InterestArea_ID (0);
|
// setR_InterestArea_ID (0);
|
||||||
|
setIsSelfService (false);
|
||||||
}
|
}
|
||||||
} // MInterestArea
|
} // MInterestArea
|
||||||
|
|
||||||
|
@ -82,6 +130,18 @@ public class MInterestArea extends X_R_InterestArea
|
||||||
} // MInterestArea
|
} // MInterestArea
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Value
|
||||||
|
* @return value
|
||||||
|
*/
|
||||||
|
public String getValue()
|
||||||
|
{
|
||||||
|
String s = super.getValue ();
|
||||||
|
if (s != null && s.length () > 0)
|
||||||
|
return s;
|
||||||
|
return super.getName();
|
||||||
|
} // getValue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation
|
* String representation
|
||||||
* @return info
|
* @return info
|
||||||
|
@ -92,7 +152,7 @@ public class MInterestArea extends X_R_InterestArea
|
||||||
.append (get_ID()).append(" - ").append(getName())
|
.append (get_ID()).append(" - ").append(getName())
|
||||||
.append ("]");
|
.append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
}
|
} // toString
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class MInventoryLine extends X_M_InventoryLine
|
||||||
* Get Parent
|
* Get Parent
|
||||||
* @return parent
|
* @return parent
|
||||||
*/
|
*/
|
||||||
private MInventory getParent()
|
public MInventory getParent()
|
||||||
{
|
{
|
||||||
if (m_parent == null)
|
if (m_parent == null)
|
||||||
m_parent = new MInventory (getCtx(), getM_Inventory_ID(), get_TrxName());
|
m_parent = new MInventory (getCtx(), getM_Inventory_ID(), get_TrxName());
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ldap Access Log
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class MLdapAccess extends X_AD_LdapAccess
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param AD_LdapAccess_ID id
|
||||||
|
* @param trxName trx
|
||||||
|
*/
|
||||||
|
public MLdapAccess(Properties ctx, int AD_LdapAccess_ID, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, AD_LdapAccess_ID, trxName);
|
||||||
|
} // MLdapAccess
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param rs result set
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MLdapAccess(Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, rs, trxName);
|
||||||
|
} // MLdapAccess
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // MLdapAccess
|
|
@ -0,0 +1,545 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAP Server Model
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProcessor
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get Active LDAP Server
|
||||||
|
* @return array of Servers
|
||||||
|
*/
|
||||||
|
public static MLdapProcessor[] getActive(Properties ctx)
|
||||||
|
{
|
||||||
|
ArrayList<MLdapProcessor> list = new ArrayList<MLdapProcessor>();
|
||||||
|
String sql = "SELECT * FROM AD_LdapProcessor WHERE IsActive='Y'";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
|
while (rs.next ())
|
||||||
|
list.add (new MLdapProcessor (ctx, rs, null));
|
||||||
|
rs.close ();
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log (Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
MLdapProcessor[] retValue = new MLdapProcessor[list.size()];
|
||||||
|
list.toArray(retValue);
|
||||||
|
return retValue;
|
||||||
|
} // getActive
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger log = CLogger.getCLogger (MLdapProcessor.class);
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Ldap Processor
|
||||||
|
* @param ctx context
|
||||||
|
* @param AD_LdapProcessor_ID id
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MLdapProcessor(Properties ctx, int AD_LdapProcessor_ID, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, AD_LdapProcessor_ID, trxName);
|
||||||
|
} // MLdapProcessor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ldap Processor
|
||||||
|
* @param ctx context
|
||||||
|
* @param rs result set
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MLdapProcessor(Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, rs, trxName);
|
||||||
|
} // MLdapProcessor
|
||||||
|
|
||||||
|
/** Array of Clients */
|
||||||
|
private MClient[] m_clients = null;
|
||||||
|
/** Array of Interest Areas */
|
||||||
|
private MInterestArea[] m_interests = null;
|
||||||
|
|
||||||
|
private int m_auth = 0;
|
||||||
|
private int m_ok = 0;
|
||||||
|
private int m_error = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Server ID
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
public String getServerID ()
|
||||||
|
{
|
||||||
|
return "Ldap" + get_ID();
|
||||||
|
} // getServerID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Info
|
||||||
|
* @return info
|
||||||
|
*/
|
||||||
|
public String getInfo()
|
||||||
|
{
|
||||||
|
return "Auth=" + m_auth
|
||||||
|
+ ", OK=" + m_ok + ", Error=" + m_error;
|
||||||
|
} // getInfo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Date Next Run
|
||||||
|
* @param requery requery
|
||||||
|
* @return date next run
|
||||||
|
*/
|
||||||
|
public Timestamp getDateNextRun (boolean requery)
|
||||||
|
{
|
||||||
|
if (requery)
|
||||||
|
load(get_TrxName());
|
||||||
|
return getDateNextRun();
|
||||||
|
} // getDateNextRun
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Logs
|
||||||
|
* @return logs
|
||||||
|
*/
|
||||||
|
public AdempiereProcessorLog[] getLogs ()
|
||||||
|
{
|
||||||
|
ArrayList<MLdapProcessorLog> list = new ArrayList<MLdapProcessorLog>();
|
||||||
|
String sql = "SELECT * "
|
||||||
|
+ "FROM AD_LdapProcessorLog "
|
||||||
|
+ "WHERE AD_LdapProcessor_ID=? "
|
||||||
|
+ "ORDER BY Created DESC";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||||
|
pstmt.setInt (1, getAD_LdapProcessor_ID());
|
||||||
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
|
while (rs.next ())
|
||||||
|
list.add (new MLdapProcessorLog (getCtx(), rs, get_TrxName()));
|
||||||
|
rs.close ();
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
MLdapProcessorLog[] retValue = new MLdapProcessorLog[list.size ()];
|
||||||
|
list.toArray (retValue);
|
||||||
|
return retValue;
|
||||||
|
} // getLogs
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete old Request Log
|
||||||
|
* @return number of records
|
||||||
|
*/
|
||||||
|
public int deleteLog()
|
||||||
|
{
|
||||||
|
if (getKeepLogDays() < 1)
|
||||||
|
return 0;
|
||||||
|
String sql = "DELETE AD_LdapProcessorLog "
|
||||||
|
+ "WHERE AD_LdapProcessor_ID=" + getAD_LdapProcessor_ID()
|
||||||
|
+ " AND (Created+" + getKeepLogDays() + ") < SysDate";
|
||||||
|
int no = DB.executeUpdate(sql, get_TrxName());
|
||||||
|
return no;
|
||||||
|
} // deleteLog
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Frequency (n/a)
|
||||||
|
* @return 1
|
||||||
|
*/
|
||||||
|
public int getFrequency()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
} // getFrequency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Frequency Type (n/a)
|
||||||
|
* @return minute
|
||||||
|
*/
|
||||||
|
public String getFrequencyType()
|
||||||
|
{
|
||||||
|
return X_R_RequestProcessor.FREQUENCYTYPE_Minute;
|
||||||
|
} // getFrequencyType
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String Representation
|
||||||
|
* @return info
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuffer sb = new StringBuffer ("MLdapProcessor[");
|
||||||
|
sb.append (get_ID()).append ("-").append (getName())
|
||||||
|
.append (",Port=").append (getLdapPort())
|
||||||
|
.append ("]");
|
||||||
|
return sb.toString ();
|
||||||
|
} // toString
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Authenticate and Authorize
|
||||||
|
* @param ldapUser MLdapUser object
|
||||||
|
* @param usr user name
|
||||||
|
* @param o organization = Client Name
|
||||||
|
* @param ou optional organization unit = Interest Group
|
||||||
|
* @return ldapUser MLdapUser with updated information
|
||||||
|
*/
|
||||||
|
public MLdapUser authenticate(MLdapUser ldapUser, String usr, String o, String ou)
|
||||||
|
{
|
||||||
|
// Ensure something to return
|
||||||
|
if (ldapUser == null)
|
||||||
|
ldapUser = new MLdapUser();
|
||||||
|
|
||||||
|
String error = null;
|
||||||
|
String info = null;
|
||||||
|
|
||||||
|
// User
|
||||||
|
if (usr == null || usr.trim().length () == 0)
|
||||||
|
{
|
||||||
|
error = "@NotFound@ User";
|
||||||
|
ldapUser.setErrorString(error);
|
||||||
|
m_error++;
|
||||||
|
log.warning (error);
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
usr = usr.trim();
|
||||||
|
// Client
|
||||||
|
if (o == null || o.length () == 0)
|
||||||
|
{
|
||||||
|
error = "@NotFound@ O";
|
||||||
|
ldapUser.setErrorString(error);
|
||||||
|
m_error++;
|
||||||
|
log.warning (error);
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
int AD_Client_ID = findClient(o);
|
||||||
|
if (AD_Client_ID == 0)
|
||||||
|
{
|
||||||
|
error = "@NotFound@ O=" + o;
|
||||||
|
ldapUser.setErrorString(error);
|
||||||
|
m_error++;
|
||||||
|
log.config (error);
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
// Optional Interest Area
|
||||||
|
int R_InterestArea_ID = 0;
|
||||||
|
if (ou != null && ou.length () > 0)
|
||||||
|
{
|
||||||
|
R_InterestArea_ID = findInterestArea (AD_Client_ID, ou);
|
||||||
|
if (R_InterestArea_ID == 0)
|
||||||
|
{
|
||||||
|
error = "@NotFound@ OU=" + ou;
|
||||||
|
ldapUser.setErrorString(error);
|
||||||
|
m_error++;
|
||||||
|
log.config (error);
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_auth++;
|
||||||
|
// Query 1 - Validate User
|
||||||
|
int AD_User_ID = 0;
|
||||||
|
String Value = null;
|
||||||
|
String LdapUser = null;
|
||||||
|
String EMail = null;
|
||||||
|
String Name = null;
|
||||||
|
String Password = null;
|
||||||
|
boolean IsActive = false;
|
||||||
|
String EMailVerify = null; // is timestamp
|
||||||
|
boolean isUnique = false;
|
||||||
|
//
|
||||||
|
String sql = "SELECT AD_User_ID, Value, LdapUser, EMail," // 1..4
|
||||||
|
+ " Name, Password, IsActive, EMailVerify "
|
||||||
|
+ "FROM AD_User "
|
||||||
|
+ "WHERE AD_Client_ID=? AND (EMail=? OR Value=? OR LdapUser=?)";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
|
pstmt.setInt (1, AD_Client_ID);
|
||||||
|
pstmt.setString (2, usr);
|
||||||
|
pstmt.setString (3, usr);
|
||||||
|
pstmt.setString (4, usr);
|
||||||
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
|
if (rs.next())
|
||||||
|
{
|
||||||
|
AD_User_ID = rs.getInt (1);
|
||||||
|
Value = rs.getString (2);
|
||||||
|
LdapUser = rs.getString (3);
|
||||||
|
EMail = rs.getString (4);
|
||||||
|
//
|
||||||
|
Name = rs.getString (5);
|
||||||
|
Password = rs.getString (6);
|
||||||
|
IsActive = "Y".equals (rs.getString (7));
|
||||||
|
EMailVerify = rs.getString (8);
|
||||||
|
isUnique = rs.next();
|
||||||
|
}
|
||||||
|
rs.close ();
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log (Level.SEVERE, sql, e);
|
||||||
|
error = "System Error";
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
if (error != null)
|
||||||
|
{
|
||||||
|
m_error++;
|
||||||
|
ldapUser.setErrorString(error);
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (AD_User_ID == 0)
|
||||||
|
{
|
||||||
|
error = "@NotFound@ User=" + usr;
|
||||||
|
info = "User not found - " + usr;
|
||||||
|
}
|
||||||
|
else if (!IsActive)
|
||||||
|
{
|
||||||
|
error = "@NotFound@ User=" + usr;
|
||||||
|
info = "User not active - " + usr;
|
||||||
|
}
|
||||||
|
else if (EMailVerify == null)
|
||||||
|
{
|
||||||
|
error = "@UserNotVerified@ User=" + usr;
|
||||||
|
info = "User EMail not verified - " + usr;
|
||||||
|
}
|
||||||
|
else if (usr.equalsIgnoreCase(LdapUser))
|
||||||
|
info = "User verified - Ldap=" + usr
|
||||||
|
+ (isUnique ? "" : " - Not Unique");
|
||||||
|
else if (usr.equalsIgnoreCase(Value))
|
||||||
|
info = "User verified - Value=" + usr
|
||||||
|
+ (isUnique ? "" : " - Not Unique");
|
||||||
|
else if (usr.equalsIgnoreCase(EMail))
|
||||||
|
info = "User verified - EMail=" + usr
|
||||||
|
+ (isUnique ? "" : " - Not Unique");
|
||||||
|
else
|
||||||
|
info = "User verified ?? " + usr
|
||||||
|
+ " - Name=" + Name
|
||||||
|
+ ", Ldap=" + LdapUser + ", Value=" + Value
|
||||||
|
+ (isUnique ? "" : " - Not Unique");
|
||||||
|
|
||||||
|
// Error
|
||||||
|
if (error != null) // should use Language of the User
|
||||||
|
{
|
||||||
|
logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, error);
|
||||||
|
ldapUser.setErrorString(Msg.translate (getCtx(), error));
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
// Done
|
||||||
|
if (R_InterestArea_ID == 0)
|
||||||
|
{
|
||||||
|
logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, null);
|
||||||
|
ldapUser.setOrg(o);
|
||||||
|
ldapUser.setOrgUnit(ou);
|
||||||
|
ldapUser.setUserId(usr);
|
||||||
|
ldapUser.setPassword(Password);
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query 2 - Validate Subscription
|
||||||
|
String OptOutDate = null;
|
||||||
|
boolean found = false;
|
||||||
|
sql = "SELECT IsActive, OptOutDate "
|
||||||
|
+ "FROM R_ContactInterest "
|
||||||
|
+ "WHERE R_InterestArea_ID=? AND AD_User_ID=?";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
|
pstmt.setInt (1, R_InterestArea_ID);
|
||||||
|
pstmt.setInt (2, AD_User_ID);
|
||||||
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
|
if (rs.next())
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
IsActive = "Y".equals (rs.getString (1));
|
||||||
|
OptOutDate = rs.getString (2);
|
||||||
|
isUnique = rs.next();
|
||||||
|
}
|
||||||
|
rs.close ();
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log (Level.SEVERE, sql, e);
|
||||||
|
error = "System Error (2)";
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close ();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
// System Error
|
||||||
|
if (error != null)
|
||||||
|
{
|
||||||
|
m_error++;
|
||||||
|
ldapUser.setErrorString(error);
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
error = "@UserNotSubscribed@ User=" + usr;
|
||||||
|
info = "No User Interest - " + usr
|
||||||
|
+ " - R_InterestArea_ID=" + R_InterestArea_ID;
|
||||||
|
}
|
||||||
|
else if (OptOutDate != null)
|
||||||
|
{
|
||||||
|
error = "@UserNotSubscribed@ User=" + usr + " @OptOutDate@=" + OptOutDate;
|
||||||
|
info = "Opted out - " + usr + " - OptOutDate=" + OptOutDate;
|
||||||
|
}
|
||||||
|
else if (!IsActive)
|
||||||
|
{
|
||||||
|
error = "@UserNotSubscribed@ User=" + usr;
|
||||||
|
info = "User Interest Not Active - " + usr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
info = "User subscribed - " + usr;
|
||||||
|
|
||||||
|
|
||||||
|
if (error != null) // should use Language of the User
|
||||||
|
{
|
||||||
|
logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, error);
|
||||||
|
ldapUser.setErrorString(Msg.translate (getCtx(), error));
|
||||||
|
return ldapUser;
|
||||||
|
}
|
||||||
|
// Done
|
||||||
|
logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, null);
|
||||||
|
ldapUser.setOrg(o);
|
||||||
|
ldapUser.setOrgUnit(ou);
|
||||||
|
ldapUser.setUserId(usr);
|
||||||
|
ldapUser.setPassword(Password);
|
||||||
|
return ldapUser;
|
||||||
|
} // authenticate
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Client
|
||||||
|
* @param client client name
|
||||||
|
* @return AD_Client_ID
|
||||||
|
*/
|
||||||
|
private int findClient (String client)
|
||||||
|
{
|
||||||
|
if (m_clients == null)
|
||||||
|
m_clients = MClient.getAll(getCtx());
|
||||||
|
for (int i = 0; i < m_clients.length; i++)
|
||||||
|
{
|
||||||
|
if ((client.equalsIgnoreCase (m_clients[i].getValue())))
|
||||||
|
return m_clients[i].getAD_Client_ID ();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} // findClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Interest Area
|
||||||
|
* @param interset Name client name
|
||||||
|
* @return AD_Client_ID
|
||||||
|
*/
|
||||||
|
private int findInterestArea (int AD_Client_ID, String interestArea)
|
||||||
|
{
|
||||||
|
if (m_interests == null)
|
||||||
|
m_interests = MInterestArea.getAll(getCtx());
|
||||||
|
for (int i = 0; i < m_interests.length; i++)
|
||||||
|
{
|
||||||
|
if (AD_Client_ID == m_interests[i].getAD_Client_ID()
|
||||||
|
&& interestArea.equalsIgnoreCase (m_interests[i].getValue ()))
|
||||||
|
return m_interests[i].getR_InterestArea_ID();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} // findInterestArea
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log Access
|
||||||
|
* @param AD_Client_ID client
|
||||||
|
* @param AD_User_ID user
|
||||||
|
* @param R_InterestArea_ID interest area
|
||||||
|
* @param info info
|
||||||
|
* @param error error
|
||||||
|
*/
|
||||||
|
private void logAccess (int AD_Client_ID,
|
||||||
|
int AD_User_ID, int R_InterestArea_ID,
|
||||||
|
String info, String error)
|
||||||
|
{
|
||||||
|
if (error != null)
|
||||||
|
{
|
||||||
|
log.log (Level.CONFIG, info);
|
||||||
|
m_error++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.log (Level.INFO, info);
|
||||||
|
m_ok++;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
MLdapAccess access = new MLdapAccess (getCtx(), 0, null);
|
||||||
|
access.setAD_Client_ID (AD_Client_ID);
|
||||||
|
access.setAD_User_ID (AD_User_ID);
|
||||||
|
access.setR_InterestArea_ID (R_InterestArea_ID);
|
||||||
|
access.setIsError (error != null);
|
||||||
|
access.setSummary (info);
|
||||||
|
access.save ();
|
||||||
|
} // logAccess
|
||||||
|
|
||||||
|
} // MLdapProcessor
|
|
@ -0,0 +1,72 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAP Server Log
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class MLdapProcessorLog extends X_AD_LdapProcessorLog implements AdempiereProcessorLog
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param AD_LdapProcessorLog_ID id
|
||||||
|
* @param trxName trx
|
||||||
|
*/
|
||||||
|
public MLdapProcessorLog(Properties ctx, int AD_LdapProcessorLog_ID,
|
||||||
|
String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, AD_LdapProcessorLog_ID, trxName);
|
||||||
|
if (AD_LdapProcessorLog_ID == 0)
|
||||||
|
{
|
||||||
|
// setAD_LdapProcessorLog_ID (0);
|
||||||
|
// setAD_LdapProcessor_ID (0);
|
||||||
|
setIsError (false);
|
||||||
|
}
|
||||||
|
} // MLdapProcessorLog
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param rs result set
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MLdapProcessorLog(Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, rs, trxName);
|
||||||
|
} // MLdapProcessorLog
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parent Constructor
|
||||||
|
* @param parent parent
|
||||||
|
* @param summary summary
|
||||||
|
*/
|
||||||
|
public MLdapProcessorLog(MLdapProcessor parent, String summary)
|
||||||
|
{
|
||||||
|
this (parent.getCtx (), 0, null);
|
||||||
|
setClientOrg (parent);
|
||||||
|
setAD_LdapProcessor_ID (parent.getAD_LdapProcessor_ID());
|
||||||
|
setSummary (summary);
|
||||||
|
} // MLdapProcessorLog
|
||||||
|
|
||||||
|
} // MLdapProcessorLog
|
|
@ -0,0 +1,140 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MLdapUser, data object stores the user information such as userid,
|
||||||
|
* password, organization and so on.
|
||||||
|
*/
|
||||||
|
public class MLdapUser
|
||||||
|
{
|
||||||
|
/** organization */
|
||||||
|
private String org = null;
|
||||||
|
/** organization unit */
|
||||||
|
private String orgUnit = null;
|
||||||
|
/** user password */
|
||||||
|
private String passwd = null;
|
||||||
|
/** user id */
|
||||||
|
private String userId = null;
|
||||||
|
/** error string */
|
||||||
|
private String errStr = null;
|
||||||
|
|
||||||
|
public MLdapUser()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reset attributes
|
||||||
|
*/
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
org = null;
|
||||||
|
orgUnit = null;
|
||||||
|
passwd = null;
|
||||||
|
userId = null;
|
||||||
|
errStr = null;
|
||||||
|
} // reset()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the organization
|
||||||
|
* @param org organization
|
||||||
|
*/
|
||||||
|
public void setOrg(String org)
|
||||||
|
{
|
||||||
|
this.org = org;
|
||||||
|
} // setOrg()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the organization unit
|
||||||
|
* @param orgUnit organization unit
|
||||||
|
*/
|
||||||
|
public void setOrgUnit(String orgUnit)
|
||||||
|
{
|
||||||
|
this.orgUnit = orgUnit;
|
||||||
|
} // setOrg()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the user password
|
||||||
|
* @param passwd User password string
|
||||||
|
*/
|
||||||
|
public void setPassword(String passwd)
|
||||||
|
{
|
||||||
|
this.passwd = passwd;
|
||||||
|
} // setPassword()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the user id
|
||||||
|
* @param passwd User id string
|
||||||
|
*/
|
||||||
|
public void setUserId(String userId)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
} // setUserId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the error String
|
||||||
|
* @param errStr Error String
|
||||||
|
*/
|
||||||
|
public void setErrorString(String errStr)
|
||||||
|
{
|
||||||
|
this.errStr = errStr;
|
||||||
|
} // setErrorStr()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the organization
|
||||||
|
* @return org organization
|
||||||
|
*/
|
||||||
|
public String getOrg()
|
||||||
|
{
|
||||||
|
return org;
|
||||||
|
} // getOrg()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the organization unit
|
||||||
|
* @return orgUnit organization unit
|
||||||
|
*/
|
||||||
|
public String getOrgUnit()
|
||||||
|
{
|
||||||
|
return orgUnit;
|
||||||
|
} // getOrgUnit()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user password
|
||||||
|
* @return passwd User password string
|
||||||
|
*/
|
||||||
|
public String getPassword()
|
||||||
|
{
|
||||||
|
return passwd;
|
||||||
|
} // getPassword()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user id
|
||||||
|
* @return User id string
|
||||||
|
*/
|
||||||
|
public String getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
} // getUserId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the error string
|
||||||
|
* @return errStr Error String
|
||||||
|
*/
|
||||||
|
public String getErrorMsg()
|
||||||
|
{
|
||||||
|
return errStr;
|
||||||
|
} // getErrorString()
|
||||||
|
} // MLdapUser
|
|
@ -130,6 +130,20 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
super.setMovementQty(MovementQty);
|
super.setMovementQty(MovementQty);
|
||||||
} // setMovementQty
|
} // setMovementQty
|
||||||
|
|
||||||
|
/** Parent */
|
||||||
|
private MMovement m_parent = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Parent
|
||||||
|
* @return Parent Movement
|
||||||
|
*/
|
||||||
|
public MMovement getParent()
|
||||||
|
{
|
||||||
|
if (m_parent == null)
|
||||||
|
m_parent = new MMovement (getCtx(), getM_Movement_ID(), get_TrxName());
|
||||||
|
return m_parent;
|
||||||
|
} // getParent
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Before Save
|
* Before Save
|
||||||
|
@ -141,7 +155,7 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
// Set Line No
|
// Set Line No
|
||||||
if (getLine() == 0)
|
if (getLine() == 0)
|
||||||
{
|
{
|
||||||
String sql = "SELECT COALESCE(MAX(Line),0)+10 AS DefaultValue FROM M_MovementLine WHERE M_Movement_ID=?";
|
String sql = "SELECT COALESCE(MAX(Line),0)+10 AS DefaultValue FROM C_M_MovementLine WHERE M_Movement_ID=?";
|
||||||
int ii = DB.getSQLValue (get_TrxName(), sql, getM_Movement_ID());
|
int ii = DB.getSQLValue (get_TrxName(), sql, getM_Movement_ID());
|
||||||
setLine (ii);
|
setLine (ii);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,6 @@ public class MNewsItem extends X_CM_NewsItem
|
||||||
/**
|
/**
|
||||||
* reIndex
|
* reIndex
|
||||||
* @param newRecord
|
* @param newRecord
|
||||||
* @throws SQLException
|
|
||||||
*/
|
*/
|
||||||
public void reIndex(boolean newRecord)
|
public void reIndex(boolean newRecord)
|
||||||
{
|
{
|
||||||
|
|
|
@ -771,6 +771,8 @@ public class MOrderLine extends X_C_OrderLine
|
||||||
|| is_ValueChanged("M_Warehouse_ID")))
|
|| is_ValueChanged("M_Warehouse_ID")))
|
||||||
{
|
{
|
||||||
MProduct product = getProduct();
|
MProduct product = getProduct();
|
||||||
|
if (product.isStocked())
|
||||||
|
{
|
||||||
int M_AttributeSet_ID = product.getM_AttributeSet_ID();
|
int M_AttributeSet_ID = product.getM_AttributeSet_ID();
|
||||||
boolean isInstance = M_AttributeSet_ID != 0;
|
boolean isInstance = M_AttributeSet_ID != 0;
|
||||||
if (isInstance)
|
if (isInstance)
|
||||||
|
@ -797,7 +799,8 @@ public class MOrderLine extends X_C_OrderLine
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // stocked
|
||||||
|
} // SO instance
|
||||||
|
|
||||||
// FreightAmt Not used
|
// FreightAmt Not used
|
||||||
if (Env.ZERO.compareTo(getFreightAmt()) != 0)
|
if (Env.ZERO.compareTo(getFreightAmt()) != 0)
|
||||||
|
|
|
@ -200,7 +200,7 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
MPaySelectionCheck[] retValue = new MPaySelectionCheck[list.size()];
|
MPaySelectionCheck[] retValue = new MPaySelectionCheck[list.size()];
|
||||||
list.toArray(retValue);
|
list.toArray(retValue);
|
||||||
return retValue;
|
return retValue;
|
||||||
} // createPayments
|
} // get
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -216,7 +216,7 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
// Must be a file
|
// Must be a file
|
||||||
if (file.isDirectory())
|
if (file.isDirectory())
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "exportToFile - file is directory - " + file.getAbsolutePath());
|
s_log.log(Level.WARNING, "File is directory - " + file.getAbsolutePath());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// delete if exists
|
// delete if exists
|
||||||
|
@ -227,7 +227,7 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "exportToFile - could not delete - " + file.getAbsolutePath(), e);
|
s_log.log(Level.WARNING, "Could not delete - " + file.getAbsolutePath(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
char x = '"'; // ease
|
char x = '"'; // ease
|
||||||
|
@ -375,7 +375,7 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "getBPartnerInfo", e);
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
return bp;
|
return bp;
|
||||||
} // getBPartnerInfo
|
} // getBPartnerInfo
|
||||||
|
@ -416,8 +416,8 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
else if (check.getPaymentRule().equals(PAYMENTRULE_CreditCard))
|
else if (check.getPaymentRule().equals(PAYMENTRULE_CreditCard))
|
||||||
payment.setTenderType(X_C_Payment.TENDERTYPE_CreditCard);
|
payment.setTenderType(X_C_Payment.TENDERTYPE_CreditCard);
|
||||||
else if (check.getPaymentRule().equals(PAYMENTRULE_DirectDeposit)
|
else if (check.getPaymentRule().equals(PAYMENTRULE_DirectDeposit)
|
||||||
|| check.getPaymentRule().equals(PAYMENTRULE_DirectDeposit))
|
|| check.getPaymentRule().equals(PAYMENTRULE_DirectDebit))
|
||||||
payment.setBankACH(check.getParent().getC_BankAccount_ID(), false);
|
payment.setBankACH(check);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "Unsupported Payment Rule=" + check.getPaymentRule());
|
s_log.log(Level.SEVERE, "Unsupported Payment Rule=" + check.getPaymentRule());
|
||||||
|
@ -559,7 +559,35 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
this (line.getCtx(), 0, line.get_TrxName());
|
this (line.getCtx(), 0, line.get_TrxName());
|
||||||
setClientOrg(line);
|
setClientOrg(line);
|
||||||
setC_PaySelection_ID (line.getC_PaySelection_ID());
|
setC_PaySelection_ID (line.getC_PaySelection_ID());
|
||||||
setC_BPartner_ID (line.getInvoice().getC_BPartner_ID());
|
int C_BPartner_ID = line.getInvoice().getC_BPartner_ID();
|
||||||
|
setC_BPartner_ID (C_BPartner_ID);
|
||||||
|
//
|
||||||
|
if (X_C_Order.PAYMENTRULE_DirectDebit.equals(PaymentRule))
|
||||||
|
{
|
||||||
|
MBPBankAccount[] bas = MBPBankAccount.getOfBPartner (line.getCtx(), C_BPartner_ID);
|
||||||
|
for (int i = 0; i < bas.length; i++)
|
||||||
|
{
|
||||||
|
MBPBankAccount account = bas[i];
|
||||||
|
if (account.isDirectDebit())
|
||||||
|
{
|
||||||
|
setC_BP_BankAccount_ID(account.getC_BP_BankAccount_ID());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (X_C_Order.PAYMENTRULE_DirectDeposit.equals(PaymentRule))
|
||||||
|
{
|
||||||
|
MBPBankAccount[] bas = MBPBankAccount.getOfBPartner (line.getCtx(), C_BPartner_ID);
|
||||||
|
for (int i = 0; i < bas.length; i++)
|
||||||
|
{
|
||||||
|
MBPBankAccount account = bas[i];
|
||||||
|
if (account.isDirectDeposit())
|
||||||
|
{
|
||||||
|
setC_BP_BankAccount_ID(account.getC_BP_BankAccount_ID());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
setPaymentRule (PaymentRule);
|
setPaymentRule (PaymentRule);
|
||||||
//
|
//
|
||||||
setIsReceipt(line.isSOTrx());
|
setIsReceipt(line.isSOTrx());
|
||||||
|
@ -621,6 +649,27 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
return m_parent;
|
return m_parent;
|
||||||
} // getParent
|
} // getParent
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this a valid Prepared Payment
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
if (getC_BP_BankAccount_ID() != 0)
|
||||||
|
return true;
|
||||||
|
return !isDirect();
|
||||||
|
} // isValid
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this a direct Debit or Deposit
|
||||||
|
* @return true if direct
|
||||||
|
*/
|
||||||
|
public boolean isDirect()
|
||||||
|
{
|
||||||
|
return (X_C_Order.PAYMENTRULE_DirectDeposit.equals(getPaymentRule())
|
||||||
|
|| X_C_Order.PAYMENTRULE_DirectDebit.equals(getPaymentRule()));
|
||||||
|
} // isDirect
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
|
|
|
@ -112,7 +112,6 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
||||||
return m_invoice;
|
return m_invoice;
|
||||||
} // getInvoice
|
} // getInvoice
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Before Save
|
* Before Save
|
||||||
* @param newRecord new
|
* @param newRecord new
|
||||||
|
|
|
@ -258,10 +258,17 @@ public final class MPayment extends X_C_Payment
|
||||||
* @param isReceipt true if receipt
|
* @param isReceipt true if receipt
|
||||||
* @return true if valid
|
* @return true if valid
|
||||||
*/
|
*/
|
||||||
public boolean setBankACH (int C_BankAccount_ID, boolean isReceipt)
|
public boolean setBankACH (MPaySelectionCheck preparedPayment)
|
||||||
{
|
{
|
||||||
setBankAccountDetails(C_BankAccount_ID);
|
// Our Bank
|
||||||
setIsReceipt (isReceipt);
|
setC_BankAccount_ID(preparedPayment.getParent().getC_BankAccount_ID());
|
||||||
|
// Target Bank
|
||||||
|
int C_BP_BankAccount_ID = preparedPayment.getC_BP_BankAccount_ID();
|
||||||
|
MBPBankAccount ba = new MBPBankAccount (preparedPayment.getCtx(), C_BP_BankAccount_ID, null);
|
||||||
|
setRoutingNo(ba.getRoutingNo());
|
||||||
|
setAccountNo(ba.getAccountNo());
|
||||||
|
setIsReceipt (X_C_Order.PAYMENTRULE_DirectDebit.equals // AR only
|
||||||
|
(preparedPayment.getPaymentRule()));
|
||||||
//
|
//
|
||||||
int check = MPaymentValidate.validateRoutingNo(getRoutingNo()).length()
|
int check = MPaymentValidate.validateRoutingNo(getRoutingNo()).length()
|
||||||
+ MPaymentValidate.validateAccountNo(getAccountNo()).length();
|
+ MPaymentValidate.validateAccountNo(getAccountNo()).length();
|
||||||
|
@ -1216,9 +1223,9 @@ public final class MPayment extends X_C_Payment
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());
|
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
pstmt.setInt(1, getAD_Client_ID());
|
pstmt.setInt(1, getAD_Client_ID());
|
||||||
if (isReceipt)
|
if (isReceipt)
|
||||||
pstmt.setString(2, MDocType.DOCBASETYPE_ARReceipt);
|
pstmt.setString(2, X_C_DocType.DOCBASETYPE_ARReceipt);
|
||||||
else
|
else
|
||||||
pstmt.setString(2, MDocType.DOCBASETYPE_APPayment);
|
pstmt.setString(2, X_C_DocType.DOCBASETYPE_APPayment);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
setC_DocType_ID(rs.getInt(1));
|
setC_DocType_ID(rs.getInt(1));
|
||||||
|
@ -1447,7 +1454,7 @@ public final class MPayment extends X_C_Payment
|
||||||
*/
|
*/
|
||||||
public boolean unlockIt()
|
public boolean unlockIt()
|
||||||
{
|
{
|
||||||
log.info("unlockIt - " + toString());
|
log.info(toString());
|
||||||
setProcessing(false);
|
setProcessing(false);
|
||||||
return true;
|
return true;
|
||||||
} // unlockIt
|
} // unlockIt
|
||||||
|
@ -1458,7 +1465,7 @@ public final class MPayment extends X_C_Payment
|
||||||
*/
|
*/
|
||||||
public boolean invalidateIt()
|
public boolean invalidateIt()
|
||||||
{
|
{
|
||||||
log.info("invalidateIt - " + toString());
|
log.info(toString());
|
||||||
setDocAction(DOCACTION_Prepare);
|
setDocAction(DOCACTION_Prepare);
|
||||||
return true;
|
return true;
|
||||||
} // invalidateIt
|
} // invalidateIt
|
||||||
|
@ -1477,7 +1484,7 @@ public final class MPayment extends X_C_Payment
|
||||||
|
|
||||||
// Std Period open?
|
// Std Period open?
|
||||||
if (!MPeriod.isOpen(getCtx(), getDateAcct(),
|
if (!MPeriod.isOpen(getCtx(), getDateAcct(),
|
||||||
isReceipt() ? MDocType.DOCBASETYPE_ARReceipt : MDocType.DOCBASETYPE_APPayment))
|
isReceipt() ? X_C_DocType.DOCBASETYPE_ARReceipt : X_C_DocType.DOCBASETYPE_APPayment))
|
||||||
{
|
{
|
||||||
m_processMsg = "@PeriodClosed@";
|
m_processMsg = "@PeriodClosed@";
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
|
@ -1500,9 +1507,10 @@ public final class MPayment extends X_C_Payment
|
||||||
if (DOCSTATUS_WaitingPayment.equals(order.getDocStatus()))
|
if (DOCSTATUS_WaitingPayment.equals(order.getDocStatus()))
|
||||||
{
|
{
|
||||||
order.setC_Payment_ID(getC_Payment_ID());
|
order.setC_Payment_ID(getC_Payment_ID());
|
||||||
order.setDocAction(MOrder.DOCACTION_WaitComplete);
|
order.setDocAction(X_C_Order.DOCACTION_WaitComplete);
|
||||||
order.set_TrxName(get_TrxName());
|
order.set_TrxName(get_TrxName());
|
||||||
boolean ok = order.processIt (MOrder.DOCACTION_WaitComplete);
|
// boolean ok =
|
||||||
|
order.processIt (X_C_Order.DOCACTION_WaitComplete);
|
||||||
m_processMsg = order.getProcessMsg();
|
m_processMsg = order.getProcessMsg();
|
||||||
order.save(get_TrxName());
|
order.save(get_TrxName());
|
||||||
// Set Invoice
|
// Set Invoice
|
||||||
|
@ -1530,14 +1538,14 @@ public final class MPayment extends X_C_Payment
|
||||||
if (!isReceipt())
|
if (!isReceipt())
|
||||||
{
|
{
|
||||||
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
||||||
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
|
if (X_C_BPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
|
||||||
{
|
{
|
||||||
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
|
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
|
||||||
+ bp.getTotalOpenBalance()
|
+ bp.getTotalOpenBalance()
|
||||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
}
|
}
|
||||||
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus()))
|
if (X_C_BPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus()))
|
||||||
{
|
{
|
||||||
m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
|
m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
|
||||||
+ bp.getTotalOpenBalance()
|
+ bp.getTotalOpenBalance()
|
||||||
|
@ -1657,7 +1665,7 @@ public final class MPayment extends X_C_Payment
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null);
|
MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null);
|
||||||
MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID);
|
// MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID);
|
||||||
log.info("Counter BP=" + counterBP.getName());
|
log.info("Counter BP=" + counterBP.getName());
|
||||||
|
|
||||||
// Document Type
|
// Document Type
|
||||||
|
@ -2045,7 +2053,7 @@ public final class MPayment extends X_C_Payment
|
||||||
// Std Period open?
|
// Std Period open?
|
||||||
Timestamp dateAcct = getDateAcct();
|
Timestamp dateAcct = getDateAcct();
|
||||||
if (!MPeriod.isOpen(getCtx(), dateAcct,
|
if (!MPeriod.isOpen(getCtx(), dateAcct,
|
||||||
isReceipt() ? MDocType.DOCBASETYPE_ARReceipt : MDocType.DOCBASETYPE_APPayment))
|
isReceipt() ? X_C_DocType.DOCBASETYPE_ARReceipt : X_C_DocType.DOCBASETYPE_APPayment))
|
||||||
dateAcct = new Timestamp(System.currentTimeMillis());
|
dateAcct = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
// Auto Reconcile if not on Bank Statement
|
// Auto Reconcile if not on Bank Statement
|
||||||
|
|
|
@ -206,27 +206,27 @@ public class MPaymentValidate
|
||||||
String ccStartList = ""; // comma separated list of starting numbers
|
String ccStartList = ""; // comma separated list of starting numbers
|
||||||
String ccLengthList = ""; // comma separated list of lengths
|
String ccLengthList = ""; // comma separated list of lengths
|
||||||
//
|
//
|
||||||
if (creditCardType.equals(MPayment.CREDITCARDTYPE_MasterCard))
|
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_MasterCard))
|
||||||
{
|
{
|
||||||
ccStartList = "51,52,53,54,55";
|
ccStartList = "51,52,53,54,55";
|
||||||
ccLengthList = "16";
|
ccLengthList = "16";
|
||||||
}
|
}
|
||||||
else if (creditCardType.equals(MPayment.CREDITCARDTYPE_Visa))
|
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa))
|
||||||
{
|
{
|
||||||
ccStartList = "4";
|
ccStartList = "4";
|
||||||
ccLengthList = "13,16";
|
ccLengthList = "13,16";
|
||||||
}
|
}
|
||||||
else if (creditCardType.equals(MPayment.CREDITCARDTYPE_Amex))
|
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Amex))
|
||||||
{
|
{
|
||||||
ccStartList = "34,37";
|
ccStartList = "34,37";
|
||||||
ccLengthList = "15";
|
ccLengthList = "15";
|
||||||
}
|
}
|
||||||
else if (creditCardType.equals(MPayment.CREDITCARDTYPE_Discover))
|
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Discover))
|
||||||
{
|
{
|
||||||
ccStartList = "6011";
|
ccStartList = "6011";
|
||||||
ccLengthList = "16";
|
ccLengthList = "16";
|
||||||
}
|
}
|
||||||
else if (creditCardType.equals(MPayment.CREDITCARDTYPE_Diners))
|
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Diners))
|
||||||
{
|
{
|
||||||
ccStartList = "300,301,302,303,304,305,36,38";
|
ccStartList = "300,301,302,303,304,305,36,38";
|
||||||
ccLengthList = "14";
|
ccLengthList = "14";
|
||||||
|
@ -331,7 +331,7 @@ public class MPaymentValidate
|
||||||
int length = checkNumeric(creditCardVV).length();
|
int length = checkNumeric(creditCardVV).length();
|
||||||
|
|
||||||
// Amex = 4 digits
|
// Amex = 4 digits
|
||||||
if (creditCardType.equals(MPayment.CREDITCARDTYPE_Amex))
|
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Amex))
|
||||||
{
|
{
|
||||||
if (length == 4)
|
if (length == 4)
|
||||||
{
|
{
|
||||||
|
@ -349,8 +349,8 @@ public class MPaymentValidate
|
||||||
return "CreditCardVVError";
|
return "CreditCardVVError";
|
||||||
}
|
}
|
||||||
// Visa & MasterCard - 3 digits
|
// Visa & MasterCard - 3 digits
|
||||||
if (creditCardType.equals(MPayment.CREDITCARDTYPE_Visa)
|
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa)
|
||||||
|| creditCardType.equals(MPayment.CREDITCARDTYPE_MasterCard))
|
|| creditCardType.equals(X_C_Payment.CREDITCARDTYPE_MasterCard))
|
||||||
{
|
{
|
||||||
if (length == 3)
|
if (length == 3)
|
||||||
{
|
{
|
||||||
|
@ -384,7 +384,9 @@ public class MPaymentValidate
|
||||||
// US - length 9
|
// US - length 9
|
||||||
// Germany - length 8
|
// Germany - length 8
|
||||||
// Japan - 7
|
// Japan - 7
|
||||||
if (length == 7 || length == 8 || length == 9)
|
// CH - 5
|
||||||
|
// Issue: Bank account country
|
||||||
|
if (length > 0)
|
||||||
return "";
|
return "";
|
||||||
return "PaymentBankRoutingNotValid";
|
return "PaymentBankRoutingNotValid";
|
||||||
} // validateBankRoutingNo
|
} // validateBankRoutingNo
|
||||||
|
|
|
@ -102,7 +102,6 @@ public class MProduct extends X_M_Product
|
||||||
*/
|
*/
|
||||||
public static boolean isProductStocked (Properties ctx, int M_Product_ID)
|
public static boolean isProductStocked (Properties ctx, int M_Product_ID)
|
||||||
{
|
{
|
||||||
boolean retValue = false;
|
|
||||||
MProduct product = get (ctx, M_Product_ID);
|
MProduct product = get (ctx, M_Product_ID);
|
||||||
return product.isStocked();
|
return product.isStocked();
|
||||||
} // isProductStocked
|
} // isProductStocked
|
||||||
|
@ -164,7 +163,7 @@ public class MProduct extends X_M_Product
|
||||||
public MProduct (MExpenseType et)
|
public MProduct (MExpenseType et)
|
||||||
{
|
{
|
||||||
this (et.getCtx(), 0, et.get_TrxName());
|
this (et.getCtx(), 0, et.get_TrxName());
|
||||||
setProductType(MProduct.PRODUCTTYPE_ExpenseType);
|
setProductType(X_M_Product.PRODUCTTYPE_ExpenseType);
|
||||||
setExpenseType(et);
|
setExpenseType(et);
|
||||||
} // MProduct
|
} // MProduct
|
||||||
|
|
||||||
|
@ -176,7 +175,7 @@ public class MProduct extends X_M_Product
|
||||||
public MProduct (MResource resource, MResourceType resourceType)
|
public MProduct (MResource resource, MResourceType resourceType)
|
||||||
{
|
{
|
||||||
this (resource.getCtx(), 0, resource.get_TrxName());
|
this (resource.getCtx(), 0, resource.get_TrxName());
|
||||||
setProductType(MProduct.PRODUCTTYPE_Resource);
|
setProductType(X_M_Product.PRODUCTTYPE_Resource);
|
||||||
setResource(resource);
|
setResource(resource);
|
||||||
setResource(resourceType);
|
setResource(resourceType);
|
||||||
} // MProduct
|
} // MProduct
|
||||||
|
@ -614,7 +613,7 @@ public class MProduct extends X_M_Product
|
||||||
{
|
{
|
||||||
insert_Accounting("M_Product_Acct", "M_Product_Category_Acct",
|
insert_Accounting("M_Product_Acct", "M_Product_Category_Acct",
|
||||||
"p.M_Product_Category_ID=" + getM_Product_Category_ID());
|
"p.M_Product_Category_ID=" + getM_Product_Category_ID());
|
||||||
insert_Tree(MTree_Base.TREETYPE_Product);
|
insert_Tree(X_AD_Tree.TREETYPE_Product);
|
||||||
//
|
//
|
||||||
MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID(), get_TrxName());
|
MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID(), get_TrxName());
|
||||||
for (int i = 0; i < mass.length; i++)
|
for (int i = 0; i < mass.length; i++)
|
||||||
|
@ -626,7 +625,7 @@ public class MProduct extends X_M_Product
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Costing
|
// New Costing
|
||||||
if (newRecord || is_ValueChanged("M_Product_Category"))
|
if (newRecord || is_ValueChanged("M_Product_Category_ID"))
|
||||||
MCost.create(this);
|
MCost.create(this);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -681,7 +680,7 @@ public class MProduct extends X_M_Product
|
||||||
protected boolean afterDelete (boolean success)
|
protected boolean afterDelete (boolean success)
|
||||||
{
|
{
|
||||||
if (success)
|
if (success)
|
||||||
delete_Tree(MTree_Base.TREETYPE_Product);
|
delete_Tree(X_AD_Tree.TREETYPE_Product);
|
||||||
return success;
|
return success;
|
||||||
} // afterDelete
|
} // afterDelete
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ public class MSchedulerLog extends X_AD_SchedulerLog
|
||||||
public MSchedulerLog (Properties ctx, int AD_SchedulerLog_ID, String trxName)
|
public MSchedulerLog (Properties ctx, int AD_SchedulerLog_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, AD_SchedulerLog_ID, trxName);
|
super (ctx, AD_SchedulerLog_ID, trxName);
|
||||||
|
if (AD_SchedulerLog_ID == 0)
|
||||||
|
setIsError(false);
|
||||||
} // MSchedulerLog
|
} // MSchedulerLog
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,9 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web Project Domain
|
* Web Project Domain
|
||||||
|
@ -27,6 +30,12 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class MWebProjectDomain extends X_CM_WebProject_Domain
|
public class MWebProjectDomain extends X_CM_WebProject_Domain
|
||||||
{
|
{
|
||||||
|
/** serialVersionUID */
|
||||||
|
private static final long serialVersionUID = 5134789895039452551L;
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger s_log = CLogger.getCLogger (MContainer.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web Project Domain Constructor
|
* Web Project Domain Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -49,4 +58,44 @@ public class MWebProjectDomain extends X_CM_WebProject_Domain
|
||||||
super (ctx, rs, trxName);
|
super (ctx, rs, trxName);
|
||||||
} // MWebProjectDomain
|
} // MWebProjectDomain
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get WebProjectDomain by Name
|
||||||
|
* @param ctx
|
||||||
|
* @param ServerName
|
||||||
|
* @param trxName
|
||||||
|
* @return ContainerElement
|
||||||
|
*/
|
||||||
|
public static MWebProjectDomain get(Properties ctx, String ServerName, String trxName) {
|
||||||
|
MWebProjectDomain thisWebProjectDomain = null;
|
||||||
|
String sql = "SELECT * FROM CM_WebProject_Domain WHERE lower(FQDN) LIKE ? ORDER by CM_WebProject_Domain_ID DESC";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
|
pstmt.setString(1, ServerName);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
thisWebProjectDomain = (new MWebProjectDomain(ctx, rs, trxName));
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (pstmt != null)
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
return thisWebProjectDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // MWebProjectDomain
|
} // MWebProjectDomain
|
||||||
|
|
|
@ -206,6 +206,11 @@ public class DunningPrint extends SvrProcess
|
||||||
count++;
|
count++;
|
||||||
printed = true;
|
printed = true;
|
||||||
}
|
}
|
||||||
|
if (printed)
|
||||||
|
{
|
||||||
|
entry.setProcessed (true);
|
||||||
|
entry.save ();
|
||||||
|
}
|
||||||
|
|
||||||
} // for all dunning letters
|
} // for all dunning letters
|
||||||
if (p_EMailPDF)
|
if (p_EMailPDF)
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class DunningRunCreate extends SvrProcess
|
||||||
{
|
{
|
||||||
private boolean p_IncludeInDispute = false;
|
private boolean p_IncludeInDispute = false;
|
||||||
private boolean p_OnlySOTrx = false;
|
private boolean p_OnlySOTrx = false;
|
||||||
|
private boolean p_IsAllCurrencies = false;
|
||||||
private int p_SalesRep_ID = 0;
|
private int p_SalesRep_ID = 0;
|
||||||
private int p_C_Currency_ID = 0;
|
private int p_C_Currency_ID = 0;
|
||||||
private int p_C_BPartner_ID = 0;
|
private int p_C_BPartner_ID = 0;
|
||||||
|
@ -40,6 +41,7 @@ public class DunningRunCreate extends SvrProcess
|
||||||
private int p_C_DunningRun_ID = 0;
|
private int p_C_DunningRun_ID = 0;
|
||||||
|
|
||||||
private MDunningRun m_run = null;
|
private MDunningRun m_run = null;
|
||||||
|
private MDunningLevel m_level = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare - e.g., get Parameters.
|
* Prepare - e.g., get Parameters.
|
||||||
|
@ -56,6 +58,8 @@ public class DunningRunCreate extends SvrProcess
|
||||||
p_IncludeInDispute = "Y".equals(para[i].getParameter());
|
p_IncludeInDispute = "Y".equals(para[i].getParameter());
|
||||||
else if (name.equals("OnlySOTrx"))
|
else if (name.equals("OnlySOTrx"))
|
||||||
p_OnlySOTrx = "Y".equals(para[i].getParameter());
|
p_OnlySOTrx = "Y".equals(para[i].getParameter());
|
||||||
|
else if (name.equals("IsAllCurrencies"))
|
||||||
|
p_IsAllCurrencies = "Y".equals(para[i].getParameter());
|
||||||
else if (name.equals("SalesRep_ID"))
|
else if (name.equals("SalesRep_ID"))
|
||||||
p_SalesRep_ID = para[i].getParameterAsInt();
|
p_SalesRep_ID = para[i].getParameterAsInt();
|
||||||
else if (name.equals("C_Currency_ID"))
|
else if (name.equals("C_Currency_ID"))
|
||||||
|
@ -91,9 +95,14 @@ public class DunningRunCreate extends SvrProcess
|
||||||
if (p_C_Currency_ID == 0)
|
if (p_C_Currency_ID == 0)
|
||||||
throw new IllegalArgumentException ("No Currency");
|
throw new IllegalArgumentException ("No Currency");
|
||||||
//
|
//
|
||||||
|
m_level = m_run.getLevel ();
|
||||||
|
|
||||||
int inv = addInvoices();
|
int inv = addInvoices();
|
||||||
int pay = addPayments();
|
int pay = addPayments();
|
||||||
|
|
||||||
|
if (m_level.isChargeFee ())
|
||||||
|
addFees();
|
||||||
|
|
||||||
return "@C_Invoice_ID@ #" + inv + " - @C_Payment_ID@=" + pay;
|
return "@C_Invoice_ID@ #" + inv + " - @C_Payment_ID@=" + pay;
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
|
@ -129,15 +138,36 @@ public class DunningRunCreate extends SvrProcess
|
||||||
+ "WHERE i.C_BPartner_ID=bp.C_BPartner_ID AND bp.C_BP_Group_ID=?)"; // ##5
|
+ "WHERE i.C_BPartner_ID=bp.C_BPartner_ID AND bp.C_BP_Group_ID=?)"; // ##5
|
||||||
if (p_OnlySOTrx)
|
if (p_OnlySOTrx)
|
||||||
sql += " AND i.IsSOTrx='Y'";
|
sql += " AND i.IsSOTrx='Y'";
|
||||||
|
if (!p_IsAllCurrencies)
|
||||||
|
sql += " AND i.C_Currency_ID=" + p_C_Currency_ID;
|
||||||
// log.info(sql);
|
// log.info(sql);
|
||||||
|
|
||||||
// Sub Query
|
String sql2=null;
|
||||||
String sql2 = "SELECT COUNT(*), COALESCE(TRUNC(SysDate-MAX(dr.DunningDate)),0) "
|
|
||||||
|
// if sequentially we must check for other levels with smaller days for
|
||||||
|
// which this invoice is not yet included!
|
||||||
|
if (m_level.getParent ().isCreateLevelsSequentially ()) {
|
||||||
|
// Build a list of all topmost Dunning Levels
|
||||||
|
MDunningLevel[] previousLevels = m_level.getPreviousLevels();
|
||||||
|
if (previousLevels!=null && previousLevels.length>0) {
|
||||||
|
String sqlAppend = "";
|
||||||
|
for (int i=0; i<previousLevels.length; i++)
|
||||||
|
{
|
||||||
|
sqlAppend += " AND i.C_Invoice_ID IN (SELECT C_Invoice_ID FROM C_DunningRunLine WHERE " +
|
||||||
|
"C_DunningRunEntry_ID IN (SELECT C_DunningRunEntry_ID FROM C_DunningRunEntry WHERE " +
|
||||||
|
"C_DunningRun_ID IN (SELECT C_DunningRun_ID FROM C_DunningRun WHERE " +
|
||||||
|
"C_DunningLevel_ID=" + previousLevels[i].get_ID () + ")) AND Processed<>'N')";
|
||||||
|
}
|
||||||
|
sql += sqlAppend;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sql2 = "SELECT COUNT(*), COALESCE(TRUNC(SysDate-MAX(dr.DunningDate)),0) "
|
||||||
+ "FROM C_DunningRun dr"
|
+ "FROM C_DunningRun dr"
|
||||||
+ " INNER JOIN C_DunningRunEntry dre ON (dr.C_DunningRun_ID=dre.C_DunningRun_ID)"
|
+ " 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) "
|
+ " 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=?";
|
||||||
|
|
||||||
|
|
||||||
BigDecimal DaysAfterDue = m_run.getLevel().getDaysAfterDue();
|
BigDecimal DaysAfterDue = m_run.getLevel().getDaysAfterDue();
|
||||||
int DaysBetweenDunning = m_run.getLevel().getDaysBetweenDunning();
|
int DaysBetweenDunning = m_run.getLevel().getDaysBetweenDunning();
|
||||||
|
|
||||||
|
@ -170,7 +200,7 @@ public class DunningRunCreate extends SvrProcess
|
||||||
//
|
//
|
||||||
if (!p_IncludeInDispute && IsInDispute)
|
if (!p_IncludeInDispute && IsInDispute)
|
||||||
continue;
|
continue;
|
||||||
if (DaysDue < DaysAfterDue.intValue())
|
if (DaysDue < DaysAfterDue.intValue() && !m_level.isShowAllDue ())
|
||||||
continue;
|
continue;
|
||||||
if (Env.ZERO.compareTo(Open) == 0)
|
if (Env.ZERO.compareTo(Open) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -187,7 +217,8 @@ public class DunningRunCreate extends SvrProcess
|
||||||
}
|
}
|
||||||
rs2.close();
|
rs2.close();
|
||||||
// SubQuery
|
// SubQuery
|
||||||
if (DaysBetweenDunning != 0 && DaysAfterLast < DaysBetweenDunning)
|
|
||||||
|
if (DaysBetweenDunning != 0 && DaysAfterLast < DaysBetweenDunning && !m_level.isShowAllDue () && !m_level.isShowNotDue ())
|
||||||
continue;
|
continue;
|
||||||
//
|
//
|
||||||
createInvoiceLine (C_Invoice_ID, C_Currency_ID, GrandTotal, Open,
|
createInvoiceLine (C_Invoice_ID, C_Currency_ID, GrandTotal, Open,
|
||||||
|
@ -246,7 +277,8 @@ public class DunningRunCreate extends SvrProcess
|
||||||
//
|
//
|
||||||
MDunningRunLine line = new MDunningRunLine (entry);
|
MDunningRunLine line = new MDunningRunLine (entry);
|
||||||
line.setInvoice(C_Invoice_ID, C_Currency_ID, GrandTotal, Open,
|
line.setInvoice(C_Invoice_ID, C_Currency_ID, GrandTotal, Open,
|
||||||
DaysDue, IsInDispute, TimesDunned, DaysAfterLast);
|
new BigDecimal(0), DaysDue, IsInDispute, TimesDunned,
|
||||||
|
DaysAfterLast);
|
||||||
if (!line.save())
|
if (!line.save())
|
||||||
throw new IllegalStateException("Cannot save MDunningRunLine");
|
throw new IllegalStateException("Cannot save MDunningRunLine");
|
||||||
} // createInvoiceLine
|
} // createInvoiceLine
|
||||||
|
@ -348,5 +380,18 @@ public class DunningRunCreate extends SvrProcess
|
||||||
throw new IllegalStateException("Cannot save MDunningRunLine");
|
throw new IllegalStateException("Cannot save MDunningRunLine");
|
||||||
} // createPaymentLine
|
} // createPaymentLine
|
||||||
|
|
||||||
|
private void addFees()
|
||||||
|
{
|
||||||
|
MDunningRunEntry [] entries = m_run.getEntries (true);
|
||||||
|
if (entries!=null && entries.length>0) {
|
||||||
|
for (int i=0;i<entries.length;i++) {
|
||||||
|
MDunningRunLine line = new MDunningRunLine (entries[i]);
|
||||||
|
line.setFee (p_C_Currency_ID, m_level.getFeeAmt ());
|
||||||
|
if (!line.save())
|
||||||
|
throw new IllegalStateException("Cannot save MDunningRunLine");
|
||||||
|
entries[i].setQty (entries[i].getQty ().subtract (new BigDecimal(1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // DunningRunCreate
|
} // DunningRunCreate
|
||||||
|
|
|
@ -279,7 +279,7 @@ public class ImportBPartner extends SvrProcess
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuffer ("UPDATE I_BPartner i "
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert BPartner, ' ")
|
.append("Cannot Insert BPartner")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -313,7 +313,7 @@ public class ImportBPartner extends SvrProcess
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuffer ("UPDATE I_BPartner i "
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Update BPartner, ' ")
|
.append("Cannot Update BPartner")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -364,7 +364,7 @@ public class ImportBPartner extends SvrProcess
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuffer ("UPDATE I_BPartner i "
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert Location, ' ")
|
.append("Cannot Insert Location")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -386,7 +386,7 @@ public class ImportBPartner extends SvrProcess
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuffer ("UPDATE I_BPartner i "
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert BPLocation, ' ")
|
.append("Cannot Insert BPLocation")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -406,7 +406,7 @@ public class ImportBPartner extends SvrProcess
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuffer ("UPDATE I_BPartner i "
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'BP of User <> BP, ' ")
|
.append("BP of User <> BP")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -445,7 +445,7 @@ public class ImportBPartner extends SvrProcess
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuffer ("UPDATE I_BPartner i "
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Update BP Contact, ' ")
|
.append("Cannot Update BP Contact")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -482,7 +482,7 @@ public class ImportBPartner extends SvrProcess
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuffer ("UPDATE I_BPartner i "
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert BPContact, ' ")
|
.append("Cannot Insert BPContact")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class InvoiceNGL extends SvrProcess
|
||||||
if (no > 0)
|
if (no > 0)
|
||||||
log.info("Not Paid #" + no);
|
log.info("Not Paid #" + no);
|
||||||
|
|
||||||
sql = "UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,4) "
|
sql = "UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,6) "
|
||||||
+ "WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=" + getAD_PInstance_ID();
|
+ "WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=" + getAD_PInstance_ID();
|
||||||
no = DB.executeUpdate(sql, get_TrxName());
|
no = DB.executeUpdate(sql, get_TrxName());
|
||||||
if (no > 0)
|
if (no > 0)
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.compiere.process;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.util.AdempiereUserError;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,9 +51,11 @@ public class PaySelectionCreateCheck extends SvrProcess
|
||||||
else if (name.equals("PaymentRule"))
|
else if (name.equals("PaymentRule"))
|
||||||
p_PaymentRule = (String)para[i].getParameter();
|
p_PaymentRule = (String)para[i].getParameter();
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
|
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||||
}
|
}
|
||||||
p_C_PaySelection_ID = getRecord_ID();
|
p_C_PaySelection_ID = getRecord_ID();
|
||||||
|
if (p_PaymentRule != null & p_PaymentRule.equals(X_C_Order.PAYMENTRULE_DirectDebit))
|
||||||
|
p_PaymentRule = null;
|
||||||
} // prepare
|
} // prepare
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +65,7 @@ public class PaySelectionCreateCheck extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt () throws Exception
|
protected String doIt () throws Exception
|
||||||
{
|
{
|
||||||
log.info ("doIt - C_PaySelection_ID=" + p_C_PaySelection_ID
|
log.info ("C_PaySelection_ID=" + p_C_PaySelection_ID
|
||||||
+ ", PaymentRule=" + p_PaymentRule);
|
+ ", PaymentRule=" + p_PaymentRule);
|
||||||
|
|
||||||
MPaySelection psel = new MPaySelection (getCtx(), p_C_PaySelection_ID, get_TrxName());
|
MPaySelection psel = new MPaySelection (getCtx(), p_C_PaySelection_ID, get_TrxName());
|
||||||
|
@ -70,8 +73,6 @@ public class PaySelectionCreateCheck extends SvrProcess
|
||||||
throw new IllegalArgumentException("Not found C_PaySelection_ID=" + p_C_PaySelection_ID);
|
throw new IllegalArgumentException("Not found C_PaySelection_ID=" + p_C_PaySelection_ID);
|
||||||
if (psel.isProcessed())
|
if (psel.isProcessed())
|
||||||
throw new IllegalArgumentException("@Processed@");
|
throw new IllegalArgumentException("@Processed@");
|
||||||
if (p_PaymentRule == null)
|
|
||||||
throw new IllegalArgumentException("No PaymentRule");
|
|
||||||
//
|
//
|
||||||
MPaySelectionLine[] lines = psel.getLines(false);
|
MPaySelectionLine[] lines = psel.getLines(false);
|
||||||
for (int i = 0; i < lines.length; i++)
|
for (int i = 0; i < lines.length; i++)
|
||||||
|
@ -91,8 +92,9 @@ public class PaySelectionCreateCheck extends SvrProcess
|
||||||
/**
|
/**
|
||||||
* Create Check from line
|
* Create Check from line
|
||||||
* @param line
|
* @param line
|
||||||
|
* @throws Exception for invalid bank accounts
|
||||||
*/
|
*/
|
||||||
private void createCheck (MPaySelectionLine line)
|
private void createCheck (MPaySelectionLine line) throws Exception
|
||||||
{
|
{
|
||||||
// Try to find one
|
// Try to find one
|
||||||
for (int i = 0; i < m_list.size(); i++)
|
for (int i = 0; i < m_list.size(); i++)
|
||||||
|
@ -103,22 +105,35 @@ public class PaySelectionCreateCheck extends SvrProcess
|
||||||
{
|
{
|
||||||
check.addLine(line);
|
check.addLine(line);
|
||||||
if (!check.save())
|
if (!check.save())
|
||||||
throw new IllegalStateException("Cannot Save MPaySelectionCheck");
|
throw new IllegalStateException("Cannot save MPaySelectionCheck");
|
||||||
line.setC_PaySelectionCheck_ID(check.getC_PaySelectionCheck_ID());
|
line.setC_PaySelectionCheck_ID(check.getC_PaySelectionCheck_ID());
|
||||||
line.setProcessed(true);
|
line.setProcessed(true);
|
||||||
if (!line.save())
|
if (!line.save())
|
||||||
throw new IllegalStateException("Cannot Save MPaySelectionLine");
|
throw new IllegalStateException("Cannot save MPaySelectionLine");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create new
|
// Create new
|
||||||
MPaySelectionCheck check = new MPaySelectionCheck(line, p_PaymentRule);
|
String PaymentRule = line.getPaymentRule();
|
||||||
|
if (p_PaymentRule != null)
|
||||||
|
{
|
||||||
|
if (!X_C_Order.PAYMENTRULE_DirectDebit.equals(PaymentRule))
|
||||||
|
PaymentRule = p_PaymentRule;
|
||||||
|
}
|
||||||
|
MPaySelectionCheck check = new MPaySelectionCheck(line, PaymentRule);
|
||||||
|
if (!check.isValid())
|
||||||
|
{
|
||||||
|
int C_BPartner_ID = check.getC_BPartner_ID();
|
||||||
|
MBPartner bp = MBPartner.get(getCtx(), C_BPartner_ID);
|
||||||
|
String msg = "@NotFound@ @C_BP_BankAccount@: " + bp.getName();
|
||||||
|
throw new AdempiereUserError(msg);
|
||||||
|
}
|
||||||
if (!check.save())
|
if (!check.save())
|
||||||
throw new IllegalStateException("Cannot Save MPaySelectionCheck");
|
throw new IllegalStateException("Cannot save MPaySelectionCheck");
|
||||||
line.setC_PaySelectionCheck_ID(check.getC_PaySelectionCheck_ID());
|
line.setC_PaySelectionCheck_ID(check.getC_PaySelectionCheck_ID());
|
||||||
line.setProcessed(true);
|
line.setProcessed(true);
|
||||||
if (!line.save())
|
if (!line.save())
|
||||||
throw new IllegalStateException("Cannot Save MPaySelectionLine");
|
throw new IllegalStateException("Cannot save MPaySelectionLine");
|
||||||
m_list.add(check);
|
m_list.add(check);
|
||||||
} // createCheck
|
} // createCheck
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class PaySelectionCreateFrom extends SvrProcess
|
||||||
// Discount
|
// Discount
|
||||||
+ " currencyConvert(paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)" // ##3 PayDate
|
+ " currencyConvert(paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)" // ##3 PayDate
|
||||||
+ ",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)," // ##4/5 Currency_To,PayDate
|
+ ",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)," // ##4/5 Currency_To,PayDate
|
||||||
+ " PaymentRule, IsSOTrx "
|
+ " PaymentRule, IsSOTrx " // 4..6
|
||||||
+ "FROM C_Invoice i "
|
+ "FROM C_Invoice i "
|
||||||
+ "WHERE IsSOTrx='N' AND IsPaid='N' AND DocStatus IN ('CO','CL')"
|
+ "WHERE IsSOTrx='N' AND IsPaid='N' AND DocStatus IN ('CO','CL')"
|
||||||
+ " AND AD_Client_ID=?" // ##6
|
+ " AND AD_Client_ID=?" // ##6
|
||||||
|
@ -219,7 +219,7 @@ public class PaySelectionCreateFrom extends SvrProcess
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "doIt - " + sql, e);
|
log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue