hg merge release-6.2 (merge release6.2 into default)
This commit is contained in:
commit
8509f6f0f3
|
@ -1,500 +1,500 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Payment Callouts. org.compiere.model.CalloutPayment.*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: CalloutPayment.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>BF [ 1803316 ] CalloutPayment: use C_Order.Bill_BPartner_ID
|
||||
* @author j2garcia - GlobalQSS
|
||||
* <li>BF [ 2021745 ] Cannot assign project to payment with charge
|
||||
* @author Carlos Ruiz - GlobalQSS
|
||||
* <li>BF [ 1933948 ] CalloutPayment working just with Draft Status
|
||||
*/
|
||||
public class CalloutPayment extends CalloutEngine
|
||||
{
|
||||
|
||||
/**
|
||||
* Payment_Invoice. when Invoice selected - set C_Currency_ID -
|
||||
* C_BPartner_ID - DiscountAmt = C_Invoice_Discount (ID, DateTrx) - PayAmt =
|
||||
* invoiceOpen (ID) - Discount - WriteOffAmt = 0
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String invoice(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
Integer C_Invoice_ID = (Integer)value;
|
||||
if (isCalloutActive () // assuming it is resetting value
|
||||
|| C_Invoice_ID == null || C_Invoice_ID.intValue () == 0)
|
||||
return "";
|
||||
mTab.setValue ("C_Order_ID", null);
|
||||
mTab.setValue ("C_Charge_ID", null);
|
||||
mTab.setValue ("IsPrepayment", Boolean.FALSE);
|
||||
//
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
// mTab.setValue ("IsOverUnderPayment", Boolean.FALSE);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
int C_InvoicePaySchedule_ID = 0;
|
||||
if (Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_Invoice_ID") == C_Invoice_ID.intValue ()
|
||||
&& Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID") != 0)
|
||||
{
|
||||
C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");
|
||||
}
|
||||
// Payment Date
|
||||
Timestamp ts = (Timestamp)mTab.getValue ("DateTrx");
|
||||
if (ts == null)
|
||||
ts = new Timestamp (System.currentTimeMillis ());
|
||||
//
|
||||
String sql = "SELECT C_BPartner_ID,C_Currency_ID," // 1..2
|
||||
+ " invoiceOpen(C_Invoice_ID, ?)," // 3 #1
|
||||
+ " invoiceDiscount(C_Invoice_ID,?,?), IsSOTrx " // 4..5 #2/3
|
||||
+ "FROM C_Invoice WHERE C_Invoice_ID=?"; // #4
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, C_InvoicePaySchedule_ID);
|
||||
pstmt.setTimestamp (2, ts);
|
||||
pstmt.setInt (3, C_InvoicePaySchedule_ID);
|
||||
pstmt.setInt (4, C_Invoice_ID.intValue ());
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
{
|
||||
mTab.setValue ("C_BPartner_ID", Integer.valueOf(rs.getInt (1)));
|
||||
int C_Currency_ID = rs.getInt (2); // Set Invoice Currency
|
||||
mTab.setValue ("C_Currency_ID", Integer.valueOf(C_Currency_ID));
|
||||
//
|
||||
BigDecimal InvoiceOpen = rs.getBigDecimal (3); // Set Invoice
|
||||
// OPen Amount
|
||||
if (InvoiceOpen == null)
|
||||
InvoiceOpen = Env.ZERO;
|
||||
BigDecimal DiscountAmt = rs.getBigDecimal (4); // Set Discount
|
||||
// Amt
|
||||
if (DiscountAmt == null)
|
||||
DiscountAmt = Env.ZERO;
|
||||
mTab.setValue ("PayAmt", InvoiceOpen.subtract (DiscountAmt));
|
||||
mTab.setValue ("DiscountAmt", DiscountAmt);
|
||||
// reset as dependent fields get reset
|
||||
Env.setContext (ctx, WindowNo, "C_Invoice_ID", C_Invoice_ID
|
||||
.toString ());
|
||||
mTab.setValue ("C_Invoice_ID", C_Invoice_ID);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
return e.getLocalizedMessage ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close (rs, pstmt);
|
||||
}
|
||||
return docType (ctx, WindowNo, mTab, mField, value);
|
||||
} // invoice
|
||||
|
||||
/**
|
||||
* Payment_Order. when Waiting Payment Order selected - set C_Currency_ID -
|
||||
* C_BPartner_ID - DiscountAmt = C_Invoice_Discount (ID, DateTrx) - PayAmt =
|
||||
* invoiceOpen (ID) - Discount - WriteOffAmt = 0
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String order(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
Integer C_Order_ID = (Integer)value;
|
||||
if (isCalloutActive () // assuming it is resetting value
|
||||
|| C_Order_ID == null || C_Order_ID.intValue () == 0)
|
||||
return "";
|
||||
mTab.setValue ("C_Invoice_ID", null);
|
||||
mTab.setValue ("C_Charge_ID", null);
|
||||
mTab.setValue ("IsPrepayment", Boolean.TRUE);
|
||||
//
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
mTab.setValue ("IsOverUnderPayment", Boolean.FALSE);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
// Payment Date
|
||||
Timestamp ts = (Timestamp)mTab.getValue ("DateTrx");
|
||||
if (ts == null)
|
||||
ts = new Timestamp (System.currentTimeMillis ());
|
||||
//
|
||||
String sql = "SELECT COALESCE(Bill_BPartner_ID, C_BPartner_ID) as C_BPartner_ID "
|
||||
+ ", C_Currency_ID "
|
||||
+ ", GrandTotal "
|
||||
+ "FROM C_Order WHERE C_Order_ID=?"; // #1
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, C_Order_ID.intValue ());
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
{
|
||||
mTab.setValue ("C_BPartner_ID", Integer.valueOf(rs.getInt (1)));
|
||||
int C_Currency_ID = rs.getInt (2); // Set Order Currency
|
||||
mTab.setValue ("C_Currency_ID", Integer.valueOf(C_Currency_ID));
|
||||
//
|
||||
BigDecimal GrandTotal = rs.getBigDecimal (3); // Set Pay
|
||||
// Amount
|
||||
if (GrandTotal == null)
|
||||
GrandTotal = Env.ZERO;
|
||||
mTab.setValue ("PayAmt", GrandTotal);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
return e.getLocalizedMessage ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close (rs, pstmt);
|
||||
}
|
||||
return docType (ctx, WindowNo, mTab, mField, value);
|
||||
} // order
|
||||
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Payment Callouts. org.compiere.model.CalloutPayment.*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: CalloutPayment.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>BF [ 1803316 ] CalloutPayment: use C_Order.Bill_BPartner_ID
|
||||
* @author j2garcia - GlobalQSS
|
||||
* <li>BF [ 2021745 ] Cannot assign project to payment with charge
|
||||
* @author Carlos Ruiz - GlobalQSS
|
||||
* <li>BF [ 1933948 ] CalloutPayment working just with Draft Status
|
||||
*/
|
||||
public class CalloutPayment extends CalloutEngine
|
||||
{
|
||||
|
||||
/**
|
||||
* Payment_Invoice. when Invoice selected - set C_Currency_ID -
|
||||
* C_BPartner_ID - DiscountAmt = C_Invoice_Discount (ID, DateTrx) - PayAmt =
|
||||
* invoiceOpen (ID) - Discount - WriteOffAmt = 0
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String invoice(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
Integer C_Invoice_ID = (Integer)value;
|
||||
if (isCalloutActive () // assuming it is resetting value
|
||||
|| C_Invoice_ID == null || C_Invoice_ID.intValue () == 0)
|
||||
return "";
|
||||
mTab.setValue ("C_Order_ID", null);
|
||||
mTab.setValue ("C_Charge_ID", null);
|
||||
mTab.setValue ("IsPrepayment", Boolean.FALSE);
|
||||
//
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
// mTab.setValue ("IsOverUnderPayment", Boolean.FALSE);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
int C_InvoicePaySchedule_ID = 0;
|
||||
if (Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_Invoice_ID") == C_Invoice_ID.intValue ()
|
||||
&& Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID") != 0)
|
||||
{
|
||||
C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");
|
||||
}
|
||||
// Payment Date
|
||||
Timestamp ts = (Timestamp)mTab.getValue ("DateTrx");
|
||||
if (ts == null)
|
||||
ts = new Timestamp (System.currentTimeMillis ());
|
||||
//
|
||||
String sql = "SELECT C_BPartner_ID,C_Currency_ID," // 1..2
|
||||
+ " invoiceOpen(C_Invoice_ID, ?)," // 3 #1
|
||||
+ " invoiceDiscount(C_Invoice_ID,?,?), IsSOTrx " // 4..5 #2/3
|
||||
+ "FROM C_Invoice WHERE C_Invoice_ID=?"; // #4
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, C_InvoicePaySchedule_ID);
|
||||
pstmt.setTimestamp (2, ts);
|
||||
pstmt.setInt (3, C_InvoicePaySchedule_ID);
|
||||
pstmt.setInt (4, C_Invoice_ID.intValue ());
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
{
|
||||
mTab.setValue ("C_BPartner_ID", Integer.valueOf(rs.getInt (1)));
|
||||
int C_Currency_ID = rs.getInt (2); // Set Invoice Currency
|
||||
mTab.setValue ("C_Currency_ID", Integer.valueOf(C_Currency_ID));
|
||||
//
|
||||
BigDecimal InvoiceOpen = rs.getBigDecimal (3); // Set Invoice
|
||||
// OPen Amount
|
||||
if (InvoiceOpen == null)
|
||||
InvoiceOpen = Env.ZERO;
|
||||
BigDecimal DiscountAmt = rs.getBigDecimal (4); // Set Discount
|
||||
// Amt
|
||||
if (DiscountAmt == null)
|
||||
DiscountAmt = Env.ZERO;
|
||||
mTab.setValue ("PayAmt", InvoiceOpen.subtract (DiscountAmt));
|
||||
mTab.setValue ("DiscountAmt", DiscountAmt);
|
||||
// reset as dependent fields get reset
|
||||
Env.setContext (ctx, WindowNo, "C_Invoice_ID", C_Invoice_ID
|
||||
.toString ());
|
||||
mTab.setValue ("C_Invoice_ID", C_Invoice_ID);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
return e.getLocalizedMessage ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close (rs, pstmt);
|
||||
}
|
||||
return docType (ctx, WindowNo, mTab, mField, value);
|
||||
} // invoice
|
||||
|
||||
/**
|
||||
* Payment_Order. when Waiting Payment Order selected - set C_Currency_ID -
|
||||
* C_BPartner_ID - DiscountAmt = C_Invoice_Discount (ID, DateTrx) - PayAmt =
|
||||
* invoiceOpen (ID) - Discount - WriteOffAmt = 0
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String order(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
Integer C_Order_ID = (Integer)value;
|
||||
if (isCalloutActive () // assuming it is resetting value
|
||||
|| C_Order_ID == null || C_Order_ID.intValue () == 0)
|
||||
return "";
|
||||
mTab.setValue ("C_Invoice_ID", null);
|
||||
mTab.setValue ("C_Charge_ID", null);
|
||||
mTab.setValue ("IsPrepayment", Boolean.TRUE);
|
||||
//
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
mTab.setValue ("IsOverUnderPayment", Boolean.FALSE);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
// Payment Date
|
||||
Timestamp ts = (Timestamp)mTab.getValue ("DateTrx");
|
||||
if (ts == null)
|
||||
ts = new Timestamp (System.currentTimeMillis ());
|
||||
//
|
||||
String sql = "SELECT COALESCE(Bill_BPartner_ID, C_BPartner_ID) as C_BPartner_ID "
|
||||
+ ", C_Currency_ID "
|
||||
+ ", GrandTotal "
|
||||
+ "FROM C_Order WHERE C_Order_ID=?"; // #1
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, C_Order_ID.intValue ());
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
{
|
||||
mTab.setValue ("C_BPartner_ID", Integer.valueOf(rs.getInt (1)));
|
||||
int C_Currency_ID = rs.getInt (2); // Set Order Currency
|
||||
mTab.setValue ("C_Currency_ID", Integer.valueOf(C_Currency_ID));
|
||||
//
|
||||
BigDecimal GrandTotal = rs.getBigDecimal (3); // Set Pay
|
||||
// Amount
|
||||
if (GrandTotal == null)
|
||||
GrandTotal = Env.ZERO;
|
||||
mTab.setValue ("PayAmt", GrandTotal);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
return e.getLocalizedMessage ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close (rs, pstmt);
|
||||
}
|
||||
return docType (ctx, WindowNo, mTab, mField, value);
|
||||
} // order
|
||||
|
||||
// 2008/07/18 Globalqss [ 2021745 ]
|
||||
// Deleted project method
|
||||
|
||||
/**
|
||||
* Payment_Charge. - reset - C_BPartner_ID, Invoice, Order, Project,
|
||||
* Discount, WriteOff
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String charge(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
Integer C_Charge_ID = (Integer)value;
|
||||
if (isCalloutActive () // assuming it is resetting value
|
||||
|| C_Charge_ID == null || C_Charge_ID.intValue () == 0)
|
||||
return "";
|
||||
mTab.setValue ("C_Invoice_ID", null);
|
||||
mTab.setValue ("C_Order_ID", null);
|
||||
|
||||
/**
|
||||
* Payment_Charge. - reset - C_BPartner_ID, Invoice, Order, Project,
|
||||
* Discount, WriteOff
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String charge(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
Integer C_Charge_ID = (Integer)value;
|
||||
if (isCalloutActive () // assuming it is resetting value
|
||||
|| C_Charge_ID == null || C_Charge_ID.intValue () == 0)
|
||||
return "";
|
||||
mTab.setValue ("C_Invoice_ID", null);
|
||||
mTab.setValue ("C_Order_ID", null);
|
||||
// 2008/07/18 Globalqss [ 2021745 ]
|
||||
// mTab.setValue ("C_Project_ID", null);
|
||||
mTab.setValue ("IsPrepayment", Boolean.FALSE);
|
||||
//
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
mTab.setValue ("IsOverUnderPayment", Boolean.FALSE);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
return "";
|
||||
} // charge
|
||||
|
||||
/**
|
||||
* Payment_Document Type. Verify that Document Type (AP/AR) and Invoice
|
||||
* (SO/PO) are in sync
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String docType(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
int C_Invoice_ID = Env.getContextAsInt (ctx, WindowNo, "C_Invoice_ID");
|
||||
int C_Order_ID = Env.getContextAsInt (ctx, WindowNo, "C_Order_ID");
|
||||
int C_DocType_ID = Env.getContextAsInt (ctx, WindowNo, "C_DocType_ID");
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Payment_DocType - C_Invoice_ID=" + C_Invoice_ID
|
||||
+ ", C_DocType_ID=" + C_DocType_ID);
|
||||
MDocType dt = null;
|
||||
if (C_DocType_ID != 0)
|
||||
{
|
||||
dt = MDocType.get (ctx, C_DocType_ID);
|
||||
Env
|
||||
.setContext (ctx, WindowNo, "IsSOTrx", dt.isSOTrx () ? "Y"
|
||||
: "N");
|
||||
}
|
||||
// Invoice
|
||||
if (C_Invoice_ID != 0)
|
||||
{
|
||||
MInvoice inv = new MInvoice (ctx, C_Invoice_ID, null);
|
||||
if (dt != null)
|
||||
{
|
||||
if (inv.isSOTrx () != dt.isSOTrx ())
|
||||
return "PaymentDocTypeInvoiceInconsistent";
|
||||
}
|
||||
}
|
||||
// globalqss - Allow prepayment to Purchase Orders
|
||||
// Order Waiting Payment (can only be SO)
|
||||
// if (C_Order_ID != 0 && dt != null && !dt.isSOTrx())
|
||||
// return "PaymentDocTypeInvoiceInconsistent";
|
||||
// Order
|
||||
if (C_Order_ID != 0)
|
||||
{
|
||||
MOrder ord = new MOrder (ctx, C_Order_ID, null);
|
||||
if (dt != null)
|
||||
{
|
||||
if (ord.isSOTrx () != dt.isSOTrx ())
|
||||
return "PaymentDocTypeInvoiceInconsistent";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
} // docType
|
||||
|
||||
/**
|
||||
* Payment_Amounts. Change of: - IsOverUnderPayment -> set OverUnderAmt to 0 -
|
||||
* C_Currency_ID, C_ConvesionRate_ID -> convert all - PayAmt, DiscountAmt,
|
||||
* WriteOffAmt, OverUnderAmt -> PayAmt make sure that add up to
|
||||
* InvoiceOpenAmt
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @param oldValue Old Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String amounts(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value, Object oldValue)
|
||||
{
|
||||
if (isCalloutActive ()) // assuming it is resetting value
|
||||
return "";
|
||||
int C_Invoice_ID = Env.getContextAsInt (ctx, WindowNo, "C_Invoice_ID");
|
||||
// New Payment
|
||||
if (Env.getContextAsInt (ctx, WindowNo, "C_Payment_ID") == 0
|
||||
&& Env.getContextAsInt (ctx, WindowNo, "C_BPartner_ID") == 0
|
||||
&& C_Invoice_ID == 0)
|
||||
return "";
|
||||
// Changed Column
|
||||
String colName = mField.getColumnName ();
|
||||
if (colName.equals ("IsOverUnderPayment") // Set Over/Under Amt to
|
||||
// Zero
|
||||
|| !"Y".equals (Env
|
||||
.getContext (ctx, WindowNo, "IsOverUnderPayment")))
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
int C_InvoicePaySchedule_ID = 0;
|
||||
if (Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_Invoice_ID") == C_Invoice_ID
|
||||
&& Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID") != 0)
|
||||
{
|
||||
C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");
|
||||
}
|
||||
// Get Open Amount & Invoice Currency
|
||||
BigDecimal InvoiceOpenAmt = Env.ZERO;
|
||||
int C_Currency_Invoice_ID = 0;
|
||||
if (C_Invoice_ID != 0)
|
||||
{
|
||||
Timestamp ts = (Timestamp)mTab.getValue ("DateTrx");
|
||||
if (ts == null)
|
||||
ts = new Timestamp (System.currentTimeMillis ());
|
||||
String sql = "SELECT C_BPartner_ID,C_Currency_ID," // 1..2
|
||||
+ " invoiceOpen(C_Invoice_ID,?)," // 3 #1
|
||||
+ " invoiceDiscount(C_Invoice_ID,?,?), IsSOTrx " // 4..5 #2/3
|
||||
+ "FROM C_Invoice WHERE C_Invoice_ID=?"; // #4
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, C_InvoicePaySchedule_ID);
|
||||
pstmt.setTimestamp (2, ts);
|
||||
pstmt.setInt (3, C_InvoicePaySchedule_ID);
|
||||
pstmt.setInt (4, C_Invoice_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
{
|
||||
C_Currency_Invoice_ID = rs.getInt (2);
|
||||
InvoiceOpenAmt = rs.getBigDecimal (3); // Set Invoice Open
|
||||
// Amount
|
||||
if (InvoiceOpenAmt == null)
|
||||
InvoiceOpenAmt = Env.ZERO;
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
return e.getLocalizedMessage ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close (rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
} // get Invoice Info
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Open=" + InvoiceOpenAmt + ", C_Invoice_ID=" + C_Invoice_ID
|
||||
+ ", C_Currency_ID=" + C_Currency_Invoice_ID);
|
||||
// Get Info from Tab
|
||||
BigDecimal PayAmt = (BigDecimal)mTab.getValue ("PayAmt");
|
||||
if (PayAmt == null)
|
||||
PayAmt = Env.ZERO;
|
||||
BigDecimal DiscountAmt = (BigDecimal)mTab.getValue ("DiscountAmt");
|
||||
if (DiscountAmt == null)
|
||||
DiscountAmt = Env.ZERO;
|
||||
BigDecimal WriteOffAmt = (BigDecimal)mTab.getValue ("WriteOffAmt");
|
||||
if (WriteOffAmt == null)
|
||||
WriteOffAmt = Env.ZERO;
|
||||
BigDecimal OverUnderAmt = (BigDecimal)mTab.getValue ("OverUnderAmt");
|
||||
if (OverUnderAmt == null)
|
||||
OverUnderAmt = Env.ZERO;
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Pay=" + PayAmt + ", Discount=" + DiscountAmt + ", WriteOff="
|
||||
+ WriteOffAmt + ", OverUnderAmt=" + OverUnderAmt);
|
||||
// Get Currency Info
|
||||
Integer curr_int = (Integer) mTab.getValue ("C_Currency_ID");
|
||||
if (curr_int == null)
|
||||
curr_int = Integer.valueOf(0);
|
||||
int C_Currency_ID = curr_int.intValue ();
|
||||
MCurrency currency = MCurrency.get (ctx, C_Currency_ID);
|
||||
Timestamp ConvDate = (Timestamp)mTab.getValue ("DateTrx");
|
||||
int C_ConversionType_ID = 0;
|
||||
Integer ii = (Integer)mTab.getValue ("C_ConversionType_ID");
|
||||
if (ii != null)
|
||||
C_ConversionType_ID = ii.intValue ();
|
||||
int AD_Client_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Client_ID");
|
||||
int AD_Org_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Org_ID");
|
||||
// Get Currency Rate
|
||||
BigDecimal CurrencyRate = Env.ONE;
|
||||
if ((C_Currency_ID > 0 && C_Currency_Invoice_ID > 0 && C_Currency_ID != C_Currency_Invoice_ID)
|
||||
|| colName.equals ("C_Currency_ID")
|
||||
|| colName.equals ("C_ConversionType_ID"))
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("InvCurrency=" + C_Currency_Invoice_ID + ", PayCurrency="
|
||||
+ C_Currency_ID + ", Date=" + ConvDate + ", Type="
|
||||
+ C_ConversionType_ID);
|
||||
CurrencyRate = MConversionRate.getRate (C_Currency_Invoice_ID,
|
||||
C_Currency_ID, ConvDate, C_ConversionType_ID, AD_Client_ID,
|
||||
AD_Org_ID);
|
||||
if (CurrencyRate == null || CurrencyRate.compareTo (Env.ZERO) == 0)
|
||||
{
|
||||
// mTab.setValue("C_Currency_ID", new
|
||||
// Integer(C_Currency_Invoice_ID)); // does not work
|
||||
if (C_Currency_Invoice_ID == 0)
|
||||
return ""; // no error message when no invoice is selected
|
||||
return "NoCurrencyConversion";
|
||||
}
|
||||
//
|
||||
InvoiceOpenAmt = InvoiceOpenAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Rate=" + CurrencyRate + ", InvoiceOpenAmt="
|
||||
+ InvoiceOpenAmt);
|
||||
}
|
||||
// Currency Changed - convert all
|
||||
if (colName.equals ("C_Currency_ID")
|
||||
|| colName.equals ("C_ConversionType_ID"))
|
||||
{
|
||||
PayAmt = PayAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("PayAmt", PayAmt);
|
||||
DiscountAmt = DiscountAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("DiscountAmt", DiscountAmt);
|
||||
WriteOffAmt = WriteOffAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
||||
OverUnderAmt = OverUnderAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
||||
}
|
||||
// No Invoice - Set Discount, Writeoff, Under/Over to 0
|
||||
else if (C_Invoice_ID == 0)
|
||||
{
|
||||
if (Env.ZERO.compareTo (DiscountAmt) != 0)
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
if (Env.ZERO.compareTo (WriteOffAmt) != 0)
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
if (Env.ZERO.compareTo (OverUnderAmt) != 0)
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
} else {
|
||||
boolean processed = mTab.getValueAsBoolean(MPayment.COLUMNNAME_Processed);
|
||||
if (colName.equals ("PayAmt")
|
||||
&& (!processed)
|
||||
&& "Y".equals (Env.getContext (ctx, WindowNo, "IsOverUnderPayment")))
|
||||
{
|
||||
OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract(DiscountAmt).subtract (WriteOffAmt);
|
||||
if (OverUnderAmt.signum() > 0) { // no discount because is not paid in full
|
||||
DiscountAmt = Env.ZERO;
|
||||
mTab.setValue ("DiscountAmt", DiscountAmt);
|
||||
OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract(DiscountAmt).subtract (WriteOffAmt);
|
||||
}
|
||||
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
||||
}
|
||||
else if (colName.equals ("PayAmt")
|
||||
&& (!processed))
|
||||
{
|
||||
WriteOffAmt = InvoiceOpenAmt.subtract (PayAmt).subtract (
|
||||
DiscountAmt).subtract (OverUnderAmt);
|
||||
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
||||
}
|
||||
else if (colName.equals ("IsOverUnderPayment")
|
||||
&& (!processed))
|
||||
{
|
||||
boolean overUnderPaymentActive = "Y".equals (Env.getContext (ctx,
|
||||
WindowNo, "IsOverUnderPayment"));
|
||||
if (overUnderPaymentActive)
|
||||
{
|
||||
OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract (
|
||||
DiscountAmt);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
||||
}else{
|
||||
WriteOffAmt = InvoiceOpenAmt.subtract (PayAmt).subtract (
|
||||
DiscountAmt);
|
||||
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
}
|
||||
}
|
||||
// Added Lines By Goodwill (02-03-2006)
|
||||
// Reason: we must make the callout is called just when docstatus is
|
||||
// draft
|
||||
// Old Code : else // calculate PayAmt
|
||||
// New Code :
|
||||
else if ((!processed)) // calculate
|
||||
// PayAmt
|
||||
// End By Goodwill
|
||||
{
|
||||
PayAmt = InvoiceOpenAmt.subtract (DiscountAmt).subtract (
|
||||
WriteOffAmt).subtract (OverUnderAmt);
|
||||
mTab.setValue ("PayAmt", PayAmt);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
} // amounts
|
||||
} // CalloutPayment
|
||||
mTab.setValue ("IsPrepayment", Boolean.FALSE);
|
||||
//
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
mTab.setValue ("IsOverUnderPayment", Boolean.FALSE);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
return "";
|
||||
} // charge
|
||||
|
||||
/**
|
||||
* Payment_Document Type. Verify that Document Type (AP/AR) and Invoice
|
||||
* (SO/PO) are in sync
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String docType(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value)
|
||||
{
|
||||
int C_Invoice_ID = Env.getContextAsInt (ctx, WindowNo, "C_Invoice_ID");
|
||||
int C_Order_ID = Env.getContextAsInt (ctx, WindowNo, "C_Order_ID");
|
||||
int C_DocType_ID = Env.getContextAsInt (ctx, WindowNo, "C_DocType_ID");
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Payment_DocType - C_Invoice_ID=" + C_Invoice_ID
|
||||
+ ", C_DocType_ID=" + C_DocType_ID);
|
||||
MDocType dt = null;
|
||||
if (C_DocType_ID != 0)
|
||||
{
|
||||
dt = MDocType.get (ctx, C_DocType_ID);
|
||||
Env
|
||||
.setContext (ctx, WindowNo, "IsSOTrx", dt.isSOTrx () ? "Y"
|
||||
: "N");
|
||||
}
|
||||
// Invoice
|
||||
if (C_Invoice_ID != 0)
|
||||
{
|
||||
MInvoice inv = new MInvoice (ctx, C_Invoice_ID, null);
|
||||
if (dt != null)
|
||||
{
|
||||
if (inv.isSOTrx () != dt.isSOTrx ())
|
||||
return "PaymentDocTypeInvoiceInconsistent";
|
||||
}
|
||||
}
|
||||
// globalqss - Allow prepayment to Purchase Orders
|
||||
// Order Waiting Payment (can only be SO)
|
||||
// if (C_Order_ID != 0 && dt != null && !dt.isSOTrx())
|
||||
// return "PaymentDocTypeInvoiceInconsistent";
|
||||
// Order
|
||||
if (C_Order_ID != 0)
|
||||
{
|
||||
MOrder ord = new MOrder (ctx, C_Order_ID, null);
|
||||
if (dt != null)
|
||||
{
|
||||
if (ord.isSOTrx () != dt.isSOTrx ())
|
||||
return "PaymentDocTypeInvoiceInconsistent";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
} // docType
|
||||
|
||||
/**
|
||||
* Payment_Amounts. Change of: - IsOverUnderPayment -> set OverUnderAmt to 0 -
|
||||
* C_Currency_ID, C_ConvesionRate_ID -> convert all - PayAmt, DiscountAmt,
|
||||
* WriteOffAmt, OverUnderAmt -> PayAmt make sure that add up to
|
||||
* InvoiceOpenAmt
|
||||
* @param ctx context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Grid Tab
|
||||
* @param mField Grid Field
|
||||
* @param value New Value
|
||||
* @param oldValue Old Value
|
||||
* @return null or error message
|
||||
*/
|
||||
public String amounts(Properties ctx, int WindowNo, GridTab mTab,
|
||||
GridField mField, Object value, Object oldValue)
|
||||
{
|
||||
if (isCalloutActive ()) // assuming it is resetting value
|
||||
return "";
|
||||
int C_Invoice_ID = Env.getContextAsInt (ctx, WindowNo, "C_Invoice_ID");
|
||||
// New Payment
|
||||
if (Env.getContextAsInt (ctx, WindowNo, "C_Payment_ID") == 0
|
||||
&& Env.getContextAsInt (ctx, WindowNo, "C_BPartner_ID") == 0
|
||||
&& C_Invoice_ID == 0)
|
||||
return "";
|
||||
// Changed Column
|
||||
String colName = mField.getColumnName ();
|
||||
if (colName.equals ("IsOverUnderPayment") // Set Over/Under Amt to
|
||||
// Zero
|
||||
|| !"Y".equals (Env
|
||||
.getContext (ctx, WindowNo, "IsOverUnderPayment")))
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
int C_InvoicePaySchedule_ID = 0;
|
||||
if (Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_Invoice_ID") == C_Invoice_ID
|
||||
&& Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID") != 0)
|
||||
{
|
||||
C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");
|
||||
}
|
||||
// Get Open Amount & Invoice Currency
|
||||
BigDecimal InvoiceOpenAmt = Env.ZERO;
|
||||
int C_Currency_Invoice_ID = 0;
|
||||
if (C_Invoice_ID != 0)
|
||||
{
|
||||
Timestamp ts = (Timestamp)mTab.getValue ("DateTrx");
|
||||
if (ts == null)
|
||||
ts = new Timestamp (System.currentTimeMillis ());
|
||||
String sql = "SELECT C_BPartner_ID,C_Currency_ID," // 1..2
|
||||
+ " invoiceOpen(C_Invoice_ID,?)," // 3 #1
|
||||
+ " invoiceDiscount(C_Invoice_ID,?,?), IsSOTrx " // 4..5 #2/3
|
||||
+ "FROM C_Invoice WHERE C_Invoice_ID=?"; // #4
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, C_InvoicePaySchedule_ID);
|
||||
pstmt.setTimestamp (2, ts);
|
||||
pstmt.setInt (3, C_InvoicePaySchedule_ID);
|
||||
pstmt.setInt (4, C_Invoice_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
{
|
||||
C_Currency_Invoice_ID = rs.getInt (2);
|
||||
InvoiceOpenAmt = rs.getBigDecimal (3); // Set Invoice Open
|
||||
// Amount
|
||||
if (InvoiceOpenAmt == null)
|
||||
InvoiceOpenAmt = Env.ZERO;
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
return e.getLocalizedMessage ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close (rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
} // get Invoice Info
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Open=" + InvoiceOpenAmt + ", C_Invoice_ID=" + C_Invoice_ID
|
||||
+ ", C_Currency_ID=" + C_Currency_Invoice_ID);
|
||||
// Get Info from Tab
|
||||
BigDecimal PayAmt = (BigDecimal)mTab.getValue ("PayAmt");
|
||||
if (PayAmt == null)
|
||||
PayAmt = Env.ZERO;
|
||||
BigDecimal DiscountAmt = (BigDecimal)mTab.getValue ("DiscountAmt");
|
||||
if (DiscountAmt == null)
|
||||
DiscountAmt = Env.ZERO;
|
||||
BigDecimal WriteOffAmt = (BigDecimal)mTab.getValue ("WriteOffAmt");
|
||||
if (WriteOffAmt == null)
|
||||
WriteOffAmt = Env.ZERO;
|
||||
BigDecimal OverUnderAmt = (BigDecimal)mTab.getValue ("OverUnderAmt");
|
||||
if (OverUnderAmt == null)
|
||||
OverUnderAmt = Env.ZERO;
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Pay=" + PayAmt + ", Discount=" + DiscountAmt + ", WriteOff="
|
||||
+ WriteOffAmt + ", OverUnderAmt=" + OverUnderAmt);
|
||||
// Get Currency Info
|
||||
Integer curr_int = (Integer) mTab.getValue ("C_Currency_ID");
|
||||
if (curr_int == null)
|
||||
curr_int = Integer.valueOf(0);
|
||||
int C_Currency_ID = curr_int.intValue ();
|
||||
MCurrency currency = MCurrency.get (ctx, C_Currency_ID);
|
||||
Timestamp ConvDate = (Timestamp)mTab.getValue ("DateTrx");
|
||||
int C_ConversionType_ID = 0;
|
||||
Integer ii = (Integer)mTab.getValue ("C_ConversionType_ID");
|
||||
if (ii != null)
|
||||
C_ConversionType_ID = ii.intValue ();
|
||||
int AD_Client_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Client_ID");
|
||||
int AD_Org_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Org_ID");
|
||||
// Get Currency Rate
|
||||
BigDecimal CurrencyRate = Env.ONE;
|
||||
if ((C_Currency_ID > 0 && C_Currency_Invoice_ID > 0 && C_Currency_ID != C_Currency_Invoice_ID)
|
||||
|| colName.equals ("C_Currency_ID")
|
||||
|| colName.equals ("C_ConversionType_ID"))
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("InvCurrency=" + C_Currency_Invoice_ID + ", PayCurrency="
|
||||
+ C_Currency_ID + ", Date=" + ConvDate + ", Type="
|
||||
+ C_ConversionType_ID);
|
||||
CurrencyRate = MConversionRate.getRate (C_Currency_Invoice_ID,
|
||||
C_Currency_ID, ConvDate, C_ConversionType_ID, AD_Client_ID,
|
||||
AD_Org_ID);
|
||||
if (CurrencyRate == null || CurrencyRate.compareTo (Env.ZERO) == 0)
|
||||
{
|
||||
// mTab.setValue("C_Currency_ID", new
|
||||
// Integer(C_Currency_Invoice_ID)); // does not work
|
||||
if (C_Currency_Invoice_ID == 0)
|
||||
return ""; // no error message when no invoice is selected
|
||||
return "NoCurrencyConversion";
|
||||
}
|
||||
//
|
||||
InvoiceOpenAmt = InvoiceOpenAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("Rate=" + CurrencyRate + ", InvoiceOpenAmt="
|
||||
+ InvoiceOpenAmt);
|
||||
}
|
||||
// Currency Changed - convert all
|
||||
if (colName.equals ("C_Currency_ID")
|
||||
|| colName.equals ("C_ConversionType_ID"))
|
||||
{
|
||||
PayAmt = PayAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("PayAmt", PayAmt);
|
||||
DiscountAmt = DiscountAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("DiscountAmt", DiscountAmt);
|
||||
WriteOffAmt = WriteOffAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
||||
OverUnderAmt = OverUnderAmt.multiply (CurrencyRate).setScale (
|
||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
||||
}
|
||||
// No Invoice - Set Discount, Writeoff, Under/Over to 0
|
||||
else if (C_Invoice_ID == 0)
|
||||
{
|
||||
if (Env.ZERO.compareTo (DiscountAmt) != 0)
|
||||
mTab.setValue ("DiscountAmt", Env.ZERO);
|
||||
if (Env.ZERO.compareTo (WriteOffAmt) != 0)
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
if (Env.ZERO.compareTo (OverUnderAmt) != 0)
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
} else {
|
||||
boolean processed = mTab.getValueAsBoolean(MPayment.COLUMNNAME_Processed);
|
||||
if (colName.equals ("PayAmt")
|
||||
&& (!processed)
|
||||
&& "Y".equals (Env.getContext (ctx, WindowNo, "IsOverUnderPayment")))
|
||||
{
|
||||
OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract(DiscountAmt).subtract (WriteOffAmt);
|
||||
if (OverUnderAmt.signum() > 0) { // no discount because is not paid in full
|
||||
DiscountAmt = Env.ZERO;
|
||||
mTab.setValue ("DiscountAmt", DiscountAmt);
|
||||
OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract(DiscountAmt).subtract (WriteOffAmt);
|
||||
}
|
||||
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
||||
}
|
||||
else if (colName.equals ("PayAmt")
|
||||
&& (!processed))
|
||||
{
|
||||
WriteOffAmt = InvoiceOpenAmt.subtract (PayAmt).subtract (
|
||||
DiscountAmt).subtract (OverUnderAmt);
|
||||
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
||||
}
|
||||
else if (colName.equals ("IsOverUnderPayment")
|
||||
&& (!processed))
|
||||
{
|
||||
boolean overUnderPaymentActive = "Y".equals (Env.getContext (ctx,
|
||||
WindowNo, "IsOverUnderPayment"));
|
||||
if (overUnderPaymentActive)
|
||||
{
|
||||
OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract (
|
||||
DiscountAmt);
|
||||
mTab.setValue ("WriteOffAmt", Env.ZERO);
|
||||
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
||||
}else{
|
||||
WriteOffAmt = InvoiceOpenAmt.subtract (PayAmt).subtract (
|
||||
DiscountAmt);
|
||||
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
||||
mTab.setValue ("OverUnderAmt", Env.ZERO);
|
||||
}
|
||||
}
|
||||
// Added Lines By Goodwill (02-03-2006)
|
||||
// Reason: we must make the callout is called just when docstatus is
|
||||
// draft
|
||||
// Old Code : else // calculate PayAmt
|
||||
// New Code :
|
||||
else if ((!processed)) // calculate
|
||||
// PayAmt
|
||||
// End By Goodwill
|
||||
{
|
||||
PayAmt = InvoiceOpenAmt.subtract (DiscountAmt).subtract (
|
||||
WriteOffAmt).subtract (OverUnderAmt);
|
||||
mTab.setValue ("PayAmt", PayAmt);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
} // amounts
|
||||
} // CalloutPayment
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,31 +16,31 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MDunningLevel;
|
||||
import org.compiere.model.MDunningRun;
|
||||
import org.compiere.model.MDunningRunEntry;
|
||||
import org.compiere.model.MMailText;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.MUserMail;
|
||||
import org.compiere.model.PrintInfo;
|
||||
import org.compiere.print.MPrintFormat;
|
||||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.EMail;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MDunningLevel;
|
||||
import org.compiere.model.MDunningRun;
|
||||
import org.compiere.model.MDunningRunEntry;
|
||||
import org.compiere.model.MMailText;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.MUserMail;
|
||||
import org.compiere.model.PrintInfo;
|
||||
import org.compiere.print.MPrintFormat;
|
||||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.EMail;
|
||||
|
||||
/**
|
||||
* Dunning Letter Print
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: DunningPrint.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
|
||||
*
|
||||
* FR 2872010 - Dunning Run for a complete Dunning (not just level) - Developer: Carlos Ruiz - globalqss - Sponsor: Metas
|
||||
*
|
||||
* FR 2872010 - Dunning Run for a complete Dunning (not just level) - Developer: Carlos Ruiz - globalqss - Sponsor: Metas
|
||||
*/
|
||||
public class DunningPrint extends SvrProcess
|
||||
{
|
||||
|
@ -51,8 +51,8 @@ public class DunningPrint extends SvrProcess
|
|||
/** Dunning Run */
|
||||
private int p_C_DunningRun_ID = 0;
|
||||
/** Print only Outstanding */
|
||||
private boolean p_IsOnlyIfBPBalance = true;
|
||||
/** Print only unprocessed lines */
|
||||
private boolean p_IsOnlyIfBPBalance = true;
|
||||
/** Print only unprocessed lines */
|
||||
private boolean p_PrintUnprocessedOnly = true;
|
||||
|
||||
|
||||
|
@ -74,8 +74,8 @@ public class DunningPrint extends SvrProcess
|
|||
else if (name.equals("C_DunningRun_ID"))
|
||||
p_C_DunningRun_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("IsOnlyIfBPBalance"))
|
||||
p_IsOnlyIfBPBalance = "Y".equals(para[i].getParameter());
|
||||
else if (name.equals("PrintUnprocessedOnly"))
|
||||
p_IsOnlyIfBPBalance = "Y".equals(para[i].getParameter());
|
||||
else if (name.equals("PrintUnprocessedOnly"))
|
||||
p_PrintUnprocessedOnly = "Y".equals(para[i].getParameter());
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
|
@ -89,26 +89,26 @@ public class DunningPrint extends SvrProcess
|
|||
*/
|
||||
protected String doIt () throws Exception
|
||||
{
|
||||
if (log.isLoggable(Level.INFO)) log.info("C_DunningRun_ID=" + p_C_DunningRun_ID + ",R_MailText_ID=" + p_R_MailText_ID
|
||||
+ ", EmailPDF=" + p_EMailPDF + ",IsOnlyIfBPBalance=" + p_IsOnlyIfBPBalance
|
||||
if (log.isLoggable(Level.INFO)) log.info("C_DunningRun_ID=" + p_C_DunningRun_ID + ",R_MailText_ID=" + p_R_MailText_ID
|
||||
+ ", EmailPDF=" + p_EMailPDF + ",IsOnlyIfBPBalance=" + p_IsOnlyIfBPBalance
|
||||
+ ",PrintUnprocessedOnly=" + p_PrintUnprocessedOnly);
|
||||
|
||||
// Need to have Template
|
||||
if (p_EMailPDF && p_R_MailText_ID == 0)
|
||||
throw new AdempiereUserError ("@NotFound@: @R_MailText_ID@");
|
||||
// String subject = "";
|
||||
MMailText mText = null;
|
||||
if (p_EMailPDF)
|
||||
{
|
||||
mText = new MMailText (getCtx(), p_R_MailText_ID, get_TrxName());
|
||||
if (p_EMailPDF && mText.get_ID() == 0)
|
||||
throw new AdempiereUserError ("@NotFound@: @R_MailText_ID@ - " + p_R_MailText_ID);
|
||||
// subject = mText.getMailHeader();
|
||||
}
|
||||
//
|
||||
MDunningRun run = new MDunningRun (getCtx(), p_C_DunningRun_ID, get_TrxName());
|
||||
if (run.get_ID() == 0)
|
||||
throw new AdempiereUserError ("@NotFound@: @C_DunningRun_ID@ - " + p_C_DunningRun_ID);
|
||||
|
||||
// Need to have Template
|
||||
if (p_EMailPDF && p_R_MailText_ID == 0)
|
||||
throw new AdempiereUserError ("@NotFound@: @R_MailText_ID@");
|
||||
// String subject = "";
|
||||
MMailText mText = null;
|
||||
if (p_EMailPDF)
|
||||
{
|
||||
mText = new MMailText (getCtx(), p_R_MailText_ID, get_TrxName());
|
||||
if (p_EMailPDF && mText.get_ID() == 0)
|
||||
throw new AdempiereUserError ("@NotFound@: @R_MailText_ID@ - " + p_R_MailText_ID);
|
||||
// subject = mText.getMailHeader();
|
||||
}
|
||||
//
|
||||
MDunningRun run = new MDunningRun (getCtx(), p_C_DunningRun_ID, get_TrxName());
|
||||
if (run.get_ID() == 0)
|
||||
throw new AdempiereUserError ("@NotFound@: @C_DunningRun_ID@ - " + p_C_DunningRun_ID);
|
||||
MClient client = MClient.get(getCtx());
|
||||
|
||||
int count = 0;
|
||||
|
@ -117,23 +117,23 @@ public class DunningPrint extends SvrProcess
|
|||
for (int i = 0; i < entries.length; i++)
|
||||
{
|
||||
MDunningRunEntry entry = entries[i];
|
||||
|
||||
// Print Format on Dunning Level
|
||||
MDunningLevel level = new MDunningLevel (getCtx(), entry.getC_DunningLevel_ID(), get_TrxName());
|
||||
MPrintFormat format = null;
|
||||
if (level.getDunning_PrintFormat_ID() > 0)
|
||||
format = MPrintFormat.get (getCtx(), level.getDunning_PrintFormat_ID(), false);
|
||||
|
||||
|
||||
// Print Format on Dunning Level
|
||||
MDunningLevel level = new MDunningLevel (getCtx(), entry.getC_DunningLevel_ID(), get_TrxName());
|
||||
MPrintFormat format = null;
|
||||
if (level.getDunning_PrintFormat_ID() > 0)
|
||||
format = MPrintFormat.get (getCtx(), level.getDunning_PrintFormat_ID(), false);
|
||||
|
||||
if (p_IsOnlyIfBPBalance && entry.getAmt().signum() <= 0)
|
||||
continue;
|
||||
if (p_PrintUnprocessedOnly && entry.isProcessed())
|
||||
continue;
|
||||
if (p_PrintUnprocessedOnly && entry.isProcessed())
|
||||
continue;
|
||||
// To BPartner
|
||||
MBPartner bp = new MBPartner (getCtx(), entry.getC_BPartner_ID(), get_TrxName());
|
||||
if (bp.get_ID() == 0)
|
||||
{
|
||||
StringBuilder msglog = new StringBuilder("@NotFound@: @C_BPartner_ID@ ").append(entry.getC_BPartner_ID());
|
||||
addLog (entry.get_ID(), null, null,msglog.toString() );
|
||||
StringBuilder msglog = new StringBuilder("@NotFound@: @C_BPartner_ID@ ").append(entry.getC_BPartner_ID());
|
||||
addLog (entry.get_ID(), null, null,msglog.toString() );
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
|
@ -143,15 +143,15 @@ public class DunningPrint extends SvrProcess
|
|||
{
|
||||
if (to.get_ID() == 0)
|
||||
{
|
||||
StringBuilder msglog = new StringBuilder("@NotFound@: @AD_User_ID@ - ").append(bp.getName());
|
||||
addLog (entry.get_ID(), null, null,msglog.toString());
|
||||
StringBuilder msglog = new StringBuilder("@NotFound@: @AD_User_ID@ - ").append(bp.getName());
|
||||
addLog (entry.get_ID(), null, null,msglog.toString());
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
else if (to.getEMail() == null || to.getEMail().length() == 0)
|
||||
{
|
||||
StringBuilder msglog = new StringBuilder("@NotFound@: @EMail@ - ").append(to.getName());
|
||||
addLog (entry.get_ID(), null, null, msglog.toString());
|
||||
StringBuilder msglog = new StringBuilder("@NotFound@: @EMail@ - ").append(to.getName());
|
||||
addLog (entry.get_ID(), null, null, msglog.toString());
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
|
@ -164,23 +164,23 @@ public class DunningPrint extends SvrProcess
|
|||
// Engine
|
||||
PrintInfo info = new PrintInfo(
|
||||
bp.getName(),
|
||||
MDunningRunEntry.Table_ID,
|
||||
MDunningRunEntry.Table_ID,
|
||||
entry.getC_DunningRunEntry_ID(),
|
||||
entry.getC_BPartner_ID());
|
||||
StringBuilder msginfo = new StringBuilder().append(bp.getName()).append(", Amt=").append(entry.getAmt());
|
||||
info.setDescription(msginfo.toString());
|
||||
ReportEngine re = null;
|
||||
if (format != null)
|
||||
re = new ReportEngine(getCtx(), format, query, info);
|
||||
entry.getC_BPartner_ID());
|
||||
StringBuilder msginfo = new StringBuilder().append(bp.getName()).append(", Amt=").append(entry.getAmt());
|
||||
info.setDescription(msginfo.toString());
|
||||
ReportEngine re = null;
|
||||
if (format != null)
|
||||
re = new ReportEngine(getCtx(), format, query, info);
|
||||
boolean printed = false;
|
||||
if (p_EMailPDF)
|
||||
{
|
||||
EMail email = client.createEMail(to.getEMail(), null, null);
|
||||
if (!email.isValid())
|
||||
{
|
||||
StringBuilder msglog = new StringBuilder(
|
||||
"@RequestActionEMailError@ Invalid EMail: ").append(to);
|
||||
addLog (entry.get_ID(), null, null,msglog.toString() );
|
||||
StringBuilder msglog = new StringBuilder(
|
||||
"@RequestActionEMailError@ Invalid EMail: ").append(to);
|
||||
addLog (entry.get_ID(), null, null,msglog.toString() );
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
|
@ -196,56 +196,56 @@ public class DunningPrint extends SvrProcess
|
|||
email.setMessageText (message);
|
||||
}
|
||||
//
|
||||
if (re != null) {
|
||||
File attachment = re.getPDF(File.createTempFile("Dunning", ".pdf"));
|
||||
StringBuilder msglog = new StringBuilder().append(to.toString()).append(" - ").append(attachment);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
email.addAttachment(attachment);
|
||||
}
|
||||
if (re != null) {
|
||||
File attachment = re.getPDF(File.createTempFile("Dunning", ".pdf"));
|
||||
StringBuilder msglog = new StringBuilder().append(to.toString()).append(" - ").append(attachment);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
email.addAttachment(attachment);
|
||||
}
|
||||
//
|
||||
String msg = email.send();
|
||||
MUserMail um = new MUserMail(mText, entry.getAD_User_ID(), email);
|
||||
um.saveEx();
|
||||
if (msg.equals(EMail.SENT_OK))
|
||||
{
|
||||
StringBuilder msglog = new StringBuilder()
|
||||
.append(bp.getName()).append(" @RequestActionEMailOK@");
|
||||
addLog (entry.get_ID(), null, null,msglog.toString());
|
||||
StringBuilder msglog = new StringBuilder()
|
||||
.append(bp.getName()).append(" @RequestActionEMailOK@");
|
||||
addLog (entry.get_ID(), null, null,msglog.toString());
|
||||
count++;
|
||||
printed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder msglog = new StringBuilder().append(bp.getName()).append(" @RequestActionEMailError@ ").append(msg);
|
||||
addLog (entry.get_ID(), null, null,msglog.toString() );
|
||||
StringBuilder msglog = new StringBuilder().append(bp.getName()).append(" @RequestActionEMailError@ ").append(msg);
|
||||
addLog (entry.get_ID(), null, null,msglog.toString() );
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (re != null) {
|
||||
re.print ();
|
||||
count++;
|
||||
printed = true;
|
||||
}
|
||||
}
|
||||
if (printed)
|
||||
{
|
||||
entry.setProcessed (true);
|
||||
entry.saveEx();
|
||||
}
|
||||
|
||||
} // for all dunning letters
|
||||
if (errors==0) {
|
||||
run.setProcessed(true);
|
||||
run.saveEx();
|
||||
}
|
||||
if (p_EMailPDF){
|
||||
StringBuilder msgreturn = new StringBuilder("@Sent@=").append(count).append(" - @Errors@=").append(errors);
|
||||
return msgreturn.toString();
|
||||
}
|
||||
StringBuilder msgreturn = new StringBuilder("@Printed@=").append(count);
|
||||
return msgreturn.toString();
|
||||
if (re != null) {
|
||||
re.print ();
|
||||
count++;
|
||||
printed = true;
|
||||
}
|
||||
}
|
||||
if (printed)
|
||||
{
|
||||
entry.setProcessed (true);
|
||||
entry.saveEx();
|
||||
}
|
||||
|
||||
} // for all dunning letters
|
||||
if (errors==0) {
|
||||
run.setProcessed(true);
|
||||
run.saveEx();
|
||||
}
|
||||
if (p_EMailPDF){
|
||||
StringBuilder msgreturn = new StringBuilder("@Sent@=").append(count).append(" - @Errors@=").append(errors);
|
||||
return msgreturn.toString();
|
||||
}
|
||||
StringBuilder msgreturn = new StringBuilder("@Printed@=").append(count);
|
||||
return msgreturn.toString();
|
||||
} // doIt
|
||||
|
||||
} // DunningPrint
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -10,53 +10,53 @@
|
|||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
* Contributor: Carlos Ruiz - globalqss *
|
||||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.adempiere.model.ImportValidator;
|
||||
import org.adempiere.process.ImportProcess;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MBPartnerLocation;
|
||||
import org.compiere.model.MContactInterest;
|
||||
import org.compiere.model.MLocation;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.ModelValidationEngine;
|
||||
import org.compiere.model.X_I_BPartner;
|
||||
import org.compiere.util.DB;
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
* Contributor: Carlos Ruiz - globalqss *
|
||||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.adempiere.model.ImportValidator;
|
||||
import org.adempiere.process.ImportProcess;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MBPartnerLocation;
|
||||
import org.compiere.model.MContactInterest;
|
||||
import org.compiere.model.MLocation;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.ModelValidationEngine;
|
||||
import org.compiere.model.X_I_BPartner;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* Import BPartners from I_BPartner
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ImportBPartner.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
|
||||
*
|
||||
* @author Teo Sarca, www.arhipac.ro
|
||||
* <li>FR [ 2788074 ] ImportBPartner: add IsValidateOnly option
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=2788074&group_id=176962&atid=879335
|
||||
* <li>FR [ 2788278 ] Data Import Validator - migrate core processes
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=2788278&group_id=176962&atid=879335
|
||||
*
|
||||
* @author Teo Sarca, www.arhipac.ro
|
||||
* <li>FR [ 2788074 ] ImportBPartner: add IsValidateOnly option
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=2788074&group_id=176962&atid=879335
|
||||
* <li>FR [ 2788278 ] Data Import Validator - migrate core processes
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=2788278&group_id=176962&atid=879335
|
||||
*/
|
||||
public class ImportBPartner extends SvrProcess
|
||||
implements ImportProcess
|
||||
implements ImportProcess
|
||||
{
|
||||
/** Client to be imported to */
|
||||
private int m_AD_Client_ID = 0;
|
||||
/** Delete old Imported */
|
||||
private boolean m_deleteOldImported = false;
|
||||
/** Only validate, don't import */
|
||||
private boolean p_IsValidateOnly = false;
|
||||
/** Only validate, don't import */
|
||||
private boolean p_IsValidateOnly = false;
|
||||
|
||||
/** Effective */
|
||||
private Timestamp m_DateValue = null;
|
||||
|
@ -74,8 +74,8 @@ implements ImportProcess
|
|||
m_AD_Client_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
else if (name.equals("DeleteOldImported"))
|
||||
m_deleteOldImported = "Y".equals(para[i].getParameter());
|
||||
else if (name.equals("IsValidateOnly"))
|
||||
p_IsValidateOnly = para[i].getParameterAsBoolean();
|
||||
else if (name.equals("IsValidateOnly"))
|
||||
p_IsValidateOnly = para[i].getParameterAsBoolean();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ implements ImportProcess
|
|||
*/
|
||||
protected String doIt() throws java.lang.Exception
|
||||
{
|
||||
StringBuilder sql = null;
|
||||
StringBuilder sql = null;
|
||||
int no = 0;
|
||||
String clientCheck = getWhereClause();
|
||||
|
||||
|
@ -100,52 +100,52 @@ implements ImportProcess
|
|||
// Delete Old Imported
|
||||
if (m_deleteOldImported)
|
||||
{
|
||||
sql = new StringBuilder ("DELETE I_BPartner ")
|
||||
.append("WHERE I_IsImported='Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("DELETE I_BPartner ")
|
||||
.append("WHERE I_IsImported='Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Delete Old Impored =" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Delete Old Impored =" + no);
|
||||
}
|
||||
|
||||
// Set Client, Org, IsActive, Created/Updated
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
|
||||
.append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
|
||||
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||
.append(" Created = COALESCE (Created, SysDate),")
|
||||
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||
.append(" I_ErrorMsg = ' ',")
|
||||
.append(" I_IsImported = 'N' ")
|
||||
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
|
||||
.append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
|
||||
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||
.append(" Created = COALESCE (Created, SysDate),")
|
||||
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||
.append(" I_ErrorMsg = ' ',")
|
||||
.append(" I_IsImported = 'N' ")
|
||||
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Reset=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Reset=" + no);
|
||||
|
||||
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_BEFORE_VALIDATE);
|
||||
|
||||
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_BEFORE_VALIDATE);
|
||||
|
||||
// Set BP_Group
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET GroupValue=(SELECT MAX(Value) FROM C_BP_Group g WHERE g.IsDefault='Y'")
|
||||
.append(" AND g.AD_Client_ID=i.AD_Client_ID) ");
|
||||
sql.append("WHERE GroupValue IS NULL AND C_BP_Group_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET GroupValue=(SELECT MAX(Value) FROM C_BP_Group g WHERE g.IsDefault='Y'")
|
||||
.append(" AND g.AD_Client_ID=i.AD_Client_ID) ");
|
||||
sql.append("WHERE GroupValue IS NULL AND C_BP_Group_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Group Default=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Group Default=" + no);
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_BP_Group_ID=(SELECT C_BP_Group_ID FROM C_BP_Group g")
|
||||
.append(" WHERE i.GroupValue=g.Value AND g.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE C_BP_Group_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_BP_Group_ID=(SELECT C_BP_Group_ID FROM C_BP_Group g")
|
||||
.append(" WHERE i.GroupValue=g.Value AND g.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE C_BP_Group_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Group=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Group=" + no);
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Group, ' ")
|
||||
.append("WHERE C_BP_Group_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Group, ' ")
|
||||
.append("WHERE C_BP_Group_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Group=" + no);
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Group=" + no);
|
||||
|
||||
// Set Country
|
||||
/**
|
||||
|
@ -158,195 +158,195 @@ implements ImportProcess
|
|||
log.fine("Set Country Default=" + no);
|
||||
**/
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c")
|
||||
.append(" WHERE i.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||
.append("WHERE C_Country_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c")
|
||||
.append(" WHERE i.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||
.append("WHERE C_Country_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Country=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Country=" + no);
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' ")
|
||||
.append("WHERE C_Country_ID IS NULL AND (City IS NOT NULL OR Address1 IS NOT NULL)")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' ")
|
||||
.append("WHERE C_Country_ID IS NULL AND (City IS NOT NULL OR Address1 IS NOT NULL)")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Country=" + no);
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Country=" + no);
|
||||
|
||||
// Set Region
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("Set RegionName=(SELECT MAX(Name) FROM C_Region r")
|
||||
.append(" WHERE r.IsDefault='Y' AND r.C_Country_ID=i.C_Country_ID")
|
||||
.append(" AND r.AD_Client_ID IN (0, i.AD_Client_ID)) " );
|
||||
sql.append("WHERE RegionName IS NULL AND C_Region_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Region Default=" + no);
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r")
|
||||
.append(" WHERE r.Name=i.RegionName AND r.C_Country_ID=i.C_Country_ID")
|
||||
.append(" AND r.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||
.append("WHERE C_Region_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
// Set Region
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("Set RegionName=(SELECT MAX(Name) FROM C_Region r")
|
||||
.append(" WHERE r.IsDefault='Y' AND r.C_Country_ID=i.C_Country_ID")
|
||||
.append(" AND r.AD_Client_ID IN (0, i.AD_Client_ID)) " );
|
||||
sql.append("WHERE RegionName IS NULL AND C_Region_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Region=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Region Default=" + no);
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' ")
|
||||
.append("WHERE C_Region_ID IS NULL ")
|
||||
.append(" AND EXISTS (SELECT * FROM C_Country c")
|
||||
.append(" WHERE c.C_Country_ID=i.C_Country_ID AND c.HasRegion='Y')")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r")
|
||||
.append(" WHERE r.Name=i.RegionName AND r.C_Country_ID=i.C_Country_ID")
|
||||
.append(" AND r.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||
.append("WHERE C_Region_ID IS NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Region=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Region=" + no);
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' ")
|
||||
.append("WHERE C_Region_ID IS NULL ")
|
||||
.append(" AND EXISTS (SELECT * FROM C_Country c")
|
||||
.append(" WHERE c.C_Country_ID=i.C_Country_ID AND c.HasRegion='Y')")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Region=" + no);
|
||||
|
||||
// Set Greeting
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_Greeting_ID=(SELECT C_Greeting_ID FROM C_Greeting g")
|
||||
.append(" WHERE i.BPContactGreeting=g.Name AND g.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||
.append("WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_Greeting_ID=(SELECT C_Greeting_ID FROM C_Greeting g")
|
||||
.append(" WHERE i.BPContactGreeting=g.Name AND g.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||
.append("WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Greeting=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Greeting=" + no);
|
||||
//
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Greeting, ' ")
|
||||
.append("WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Greeting, ' ")
|
||||
.append("WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Greeting=" + no);
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Invalid Greeting=" + no);
|
||||
|
||||
// Existing User ?
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET (C_BPartner_ID,AD_User_ID)=")
|
||||
.append("(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u ")
|
||||
.append("WHERE i.EMail=u.EMail AND u.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE i.EMail IS NOT NULL AND I_IsImported='N'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET (C_BPartner_ID,AD_User_ID)=")
|
||||
.append("(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u ")
|
||||
.append("WHERE i.EMail=u.EMail AND u.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE i.EMail IS NOT NULL AND I_IsImported='N'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found EMail User=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found EMail User=" + no);
|
||||
|
||||
// Existing BPartner ? Match Value
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p")
|
||||
.append(" WHERE i.Value=p.Value AND p.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE C_BPartner_ID IS NULL AND Value IS NOT NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p")
|
||||
.append(" WHERE i.Value=p.Value AND p.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE C_BPartner_ID IS NULL AND Value IS NOT NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found BPartner=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found BPartner=" + no);
|
||||
|
||||
// Existing Contact ? Match Name
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET AD_User_ID=(SELECT AD_User_ID FROM AD_User c")
|
||||
.append(" WHERE i.ContactName=c.Name AND i.C_BPartner_ID=c.C_BPartner_ID AND c.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE C_BPartner_ID IS NOT NULL AND AD_User_ID IS NULL AND ContactName IS NOT NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET AD_User_ID=(SELECT AD_User_ID FROM AD_User c")
|
||||
.append(" WHERE i.ContactName=c.Name AND i.C_BPartner_ID=c.C_BPartner_ID AND c.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE C_BPartner_ID IS NOT NULL AND AD_User_ID IS NULL AND ContactName IS NOT NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found Contact=" + no);
|
||||
|
||||
// Existing Location ? Exact Match
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID")
|
||||
.append(" FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)")
|
||||
.append(" WHERE i.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=i.AD_Client_ID")
|
||||
.append(" AND (i.Address1=l.Address1 OR (i.Address1 IS NULL AND l.Address1 IS NULL))")
|
||||
.append(" AND (i.Address2=l.Address2 OR (i.Address2 IS NULL AND l.Address2 IS NULL))")
|
||||
.append(" AND (i.City=l.City OR (i.City IS NULL AND l.City IS NULL))")
|
||||
.append(" AND (i.Postal=l.Postal OR (i.Postal IS NULL AND l.Postal IS NULL))")
|
||||
.append(" AND (i.Postal_Add=l.Postal_Add OR (l.Postal_Add IS NULL AND l.Postal_Add IS NULL))")
|
||||
.append(" AND (i.C_Region_ID=l.C_Region_ID OR (l.C_Region_ID IS NULL AND i.C_Region_ID IS NULL))")
|
||||
.append(" AND i.C_Country_ID=l.C_Country_ID) ")
|
||||
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found Location=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found Contact=" + no);
|
||||
|
||||
// Existing Location ? Exact Match
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID")
|
||||
.append(" FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)")
|
||||
.append(" WHERE i.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=i.AD_Client_ID")
|
||||
.append(" AND (i.Address1=l.Address1 OR (i.Address1 IS NULL AND l.Address1 IS NULL))")
|
||||
.append(" AND (i.Address2=l.Address2 OR (i.Address2 IS NULL AND l.Address2 IS NULL))")
|
||||
.append(" AND (i.City=l.City OR (i.City IS NULL AND l.City IS NULL))")
|
||||
.append(" AND (i.Postal=l.Postal OR (i.Postal IS NULL AND l.Postal IS NULL))")
|
||||
.append(" AND (i.Postal_Add=l.Postal_Add OR (l.Postal_Add IS NULL AND l.Postal_Add IS NULL))")
|
||||
.append(" AND (i.C_Region_ID=l.C_Region_ID OR (l.C_Region_ID IS NULL AND i.C_Region_ID IS NULL))")
|
||||
.append(" AND i.C_Country_ID=l.C_Country_ID) ")
|
||||
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Found Location=" + no);
|
||||
|
||||
// Interest Area
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET R_InterestArea_ID=(SELECT R_InterestArea_ID FROM R_InterestArea ia ")
|
||||
.append("WHERE i.InterestAreaName=ia.Name AND ia.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE R_InterestArea_ID IS NULL AND InterestAreaName IS NOT NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET R_InterestArea_ID=(SELECT R_InterestArea_ID FROM R_InterestArea ia ")
|
||||
.append("WHERE i.InterestAreaName=ia.Name AND ia.AD_Client_ID=i.AD_Client_ID) ")
|
||||
.append("WHERE R_InterestArea_ID IS NULL AND InterestAreaName IS NOT NULL")
|
||||
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Interest Area=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Set Interest Area=" + no);
|
||||
|
||||
// Value is mandatory error
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Value is mandatory, ' ")
|
||||
.append("WHERE Value IS NULL ")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Value is mandatory=" + no);
|
||||
|
||||
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_AFTER_VALIDATE);
|
||||
// Value is mandatory error
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Value is mandatory, ' ")
|
||||
.append("WHERE Value IS NULL ")
|
||||
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Value is mandatory=" + no);
|
||||
|
||||
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_AFTER_VALIDATE);
|
||||
|
||||
commitEx();
|
||||
if (p_IsValidateOnly)
|
||||
{
|
||||
return "Validated";
|
||||
}
|
||||
if (p_IsValidateOnly)
|
||||
{
|
||||
return "Validated";
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
int noInsert = 0;
|
||||
int noUpdate = 0;
|
||||
|
||||
// Go through Records
|
||||
sql = new StringBuilder ("SELECT * FROM I_BPartner ")
|
||||
.append("WHERE I_IsImported='N'").append(clientCheck);
|
||||
// gody: 20070113 - Order so the same values are consecutive.
|
||||
sql.append(" ORDER BY Value, I_BPartner_ID");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
sql = new StringBuilder ("SELECT * FROM I_BPartner ")
|
||||
.append("WHERE I_IsImported='N'").append(clientCheck);
|
||||
// gody: 20070113 - Order so the same values are consecutive.
|
||||
sql.append(" ORDER BY Value, I_BPartner_ID");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
// Remember Previous BP Value BP is only first one, others are contacts.
|
||||
// All contacts share BP location.
|
||||
// bp and bpl declarations before loop, we need them for data.
|
||||
String Old_BPValue = "" ;
|
||||
MBPartner bp = null;
|
||||
MBPartnerLocation bpl = null;
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
// Remember Previous BP Value BP is only first one, others are contacts.
|
||||
// All contacts share BP location.
|
||||
// bp and bpl declarations before loop, we need them for data.
|
||||
String Old_BPValue = "" ;
|
||||
MBPartner bp = null;
|
||||
MBPartnerLocation bpl = null;
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Remember Value - only first occurance of the value is BP
|
||||
String New_BPValue = rs.getString("Value") ;
|
||||
|
||||
X_I_BPartner impBP = new X_I_BPartner (getCtx(), rs, get_TrxName());
|
||||
StringBuilder msglog = new StringBuilder("I_BPartner_ID=") .append(impBP.getI_BPartner_ID())
|
||||
.append(", C_BPartner_ID=").append(impBP.getC_BPartner_ID())
|
||||
.append(", C_BPartner_Location_ID=").append(impBP.getC_BPartner_Location_ID())
|
||||
.append(", AD_User_ID=").append(impBP.getAD_User_ID());
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
{
|
||||
// Remember Value - only first occurance of the value is BP
|
||||
String New_BPValue = rs.getString("Value") ;
|
||||
|
||||
X_I_BPartner impBP = new X_I_BPartner (getCtx(), rs, get_TrxName());
|
||||
StringBuilder msglog = new StringBuilder("I_BPartner_ID=") .append(impBP.getI_BPartner_ID())
|
||||
.append(", C_BPartner_ID=").append(impBP.getC_BPartner_ID())
|
||||
.append(", C_BPartner_Location_ID=").append(impBP.getC_BPartner_Location_ID())
|
||||
.append(", AD_User_ID=").append(impBP.getAD_User_ID());
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
|
||||
|
||||
if ( ! New_BPValue.equals(Old_BPValue)) {
|
||||
// **** Create/Update BPartner ****
|
||||
bp = null;
|
||||
|
||||
if ( ! New_BPValue.equals(Old_BPValue)) {
|
||||
// **** Create/Update BPartner ****
|
||||
bp = null;
|
||||
|
||||
if (impBP.getC_BPartner_ID() == 0) // Insert new BPartner
|
||||
{
|
||||
bp = new MBPartner(impBP);
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bp, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
|
||||
setTypeOfBPartner(impBP,bp);
|
||||
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bp, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
|
||||
setTypeOfBPartner(impBP,bp);
|
||||
|
||||
if (bp.save())
|
||||
{
|
||||
impBP.setC_BPartner_ID(bp.getC_BPartner_ID());
|
||||
msglog = new StringBuilder("Insert BPartner - ").append(bp.getC_BPartner_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
impBP.setC_BPartner_ID(bp.getC_BPartner_ID());
|
||||
msglog = new StringBuilder("Insert BPartner - ").append(bp.getC_BPartner_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
noInsert++;
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert BPartner, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
{
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert BPartner, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else // Update existing BPartner
|
||||
|
@ -364,30 +364,30 @@ implements ImportProcess
|
|||
if (impBP.getTaxID() != null)
|
||||
bp.setTaxID(impBP.getTaxID());
|
||||
if (impBP.getNAICS() != null)
|
||||
bp.setNAICS(impBP.getNAICS());
|
||||
if (impBP.getDescription() != null)
|
||||
bp.setDescription(impBP.getDescription());
|
||||
bp.setNAICS(impBP.getNAICS());
|
||||
if (impBP.getDescription() != null)
|
||||
bp.setDescription(impBP.getDescription());
|
||||
if (impBP.getC_BP_Group_ID() != 0)
|
||||
bp.setC_BP_Group_ID(impBP.getC_BP_Group_ID());
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bp, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
|
||||
setTypeOfBPartner(impBP,bp);
|
||||
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bp, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
|
||||
setTypeOfBPartner(impBP,bp);
|
||||
|
||||
//
|
||||
if (bp.save())
|
||||
{
|
||||
msglog = new StringBuilder("Update BPartner - ").append(bp.getC_BPartner_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
msglog = new StringBuilder("Update BPartner - ").append(bp.getC_BPartner_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
noUpdate++;
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Update BPartner, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
{
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Update BPartner, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ implements ImportProcess
|
|||
bpl.setPhone2(impBP.getPhone2());
|
||||
if (impBP.getFax() != null)
|
||||
bpl.setFax(impBP.getFax());
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bpl, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bpl, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
bpl.saveEx();
|
||||
}
|
||||
else // New Location
|
||||
|
@ -428,20 +428,20 @@ implements ImportProcess
|
|||
location.setAddress2(impBP.getAddress2());
|
||||
location.setPostal(impBP.getPostal());
|
||||
location.setPostal_Add(impBP.getPostal_Add());
|
||||
if (location.save()){
|
||||
msglog = new StringBuilder("Insert Location - ").append(location.getC_Location_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
}
|
||||
if (location.save()){
|
||||
msglog = new StringBuilder("Insert Location - ").append(location.getC_Location_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
rollback();
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert Location, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert Location, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
}
|
||||
//
|
||||
bpl = new MBPartnerLocation (bp);
|
||||
|
@ -449,28 +449,28 @@ implements ImportProcess
|
|||
bpl.setPhone(impBP.getPhone());
|
||||
bpl.setPhone2(impBP.getPhone2());
|
||||
bpl.setFax(impBP.getFax());
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bpl, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bpl, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
if (bpl.save())
|
||||
{
|
||||
msglog = new StringBuilder("Insert BP Location - ").append(bpl.getC_BPartner_Location_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
msglog = new StringBuilder("Insert BP Location - ").append(bpl.getC_BPartner_Location_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
impBP.setC_BPartner_Location_ID(bpl.getC_BPartner_Location_ID());
|
||||
}
|
||||
else
|
||||
{
|
||||
rollback();
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert BPLocation, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert BPLocation, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Old_BPValue = New_BPValue ;
|
||||
}
|
||||
}
|
||||
|
||||
Old_BPValue = New_BPValue ;
|
||||
|
||||
// **** Create/Update Contact ****
|
||||
MUser user = null;
|
||||
|
@ -482,13 +482,13 @@ implements ImportProcess
|
|||
else if (user.getC_BPartner_ID() != bp.getC_BPartner_ID())
|
||||
{
|
||||
rollback();
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'BP of User <> BP, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'BP of User <> BP, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
}
|
||||
if (impBP.getC_Greeting_ID() != 0)
|
||||
user.setC_Greeting_ID(impBP.getC_Greeting_ID());
|
||||
|
@ -514,22 +514,22 @@ implements ImportProcess
|
|||
user.setBirthday(impBP.getBirthday());
|
||||
if (bpl != null)
|
||||
user.setC_BPartner_Location_ID(bpl.getC_BPartner_Location_ID());
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
if (user.save())
|
||||
{
|
||||
msglog = new StringBuilder("Update BP Contact - ").append(user.getAD_User_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
msglog = new StringBuilder("Update BP Contact - ").append(user.getAD_User_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
rollback();
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Update BP Contact, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Update BP Contact, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else // New Contact
|
||||
|
@ -552,23 +552,23 @@ implements ImportProcess
|
|||
user.setBirthday(impBP.getBirthday());
|
||||
if (bpl != null)
|
||||
user.setC_BPartner_Location_ID(bpl.getC_BPartner_Location_ID());
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
||||
if (user.save())
|
||||
{
|
||||
msglog = new StringBuilder("Insert BP Contact - ").append(user.getAD_User_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
msglog = new StringBuilder("Insert BP Contact - ").append(user.getAD_User_ID());
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(msglog.toString());
|
||||
impBP.setAD_User_ID(user.getAD_User_ID());
|
||||
}
|
||||
else
|
||||
{
|
||||
rollback();
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert BPContact, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
noInsert--;
|
||||
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||
.append("'Cannot Insert BPContact, ' ")
|
||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,59 +592,59 @@ implements ImportProcess
|
|||
catch (SQLException e)
|
||||
{
|
||||
rollback();
|
||||
//log.log(Level.SEVERE, "", e);
|
||||
throw new DBException(e, sql.toString());
|
||||
//log.log(Level.SEVERE, "", e);
|
||||
throw new DBException(e, sql.toString());
|
||||
}
|
||||
finally
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
// Set Error to indicator to not imported
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||
addLog (0, null, new BigDecimal (noInsert), "@C_BPartner_ID@: @Inserted@");
|
||||
addLog (0, null, new BigDecimal (noUpdate), "@C_BPartner_ID@: @Updated@");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
} // doIt
|
||||
|
||||
|
||||
//@Override
|
||||
public String getWhereClause()
|
||||
{
|
||||
StringBuilder msgreturn = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||
return msgreturn.toString();
|
||||
}
|
||||
|
||||
|
||||
//@Override
|
||||
public String getImportTableName()
|
||||
{
|
||||
return X_I_BPartner.Table_Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type of Business Partner
|
||||
*
|
||||
* @param X_I_BPartner impBP
|
||||
* @param MBPartner bp
|
||||
*/
|
||||
private void setTypeOfBPartner(X_I_BPartner impBP, MBPartner bp){
|
||||
if (impBP.isVendor()){
|
||||
bp.setIsVendor(true);
|
||||
bp.setIsCustomer(false); // It is put to false since by default in C_BPartner is true
|
||||
}
|
||||
if (impBP.isEmployee()){
|
||||
bp.setIsEmployee(true);
|
||||
bp.setIsCustomer(false); // It is put to false since by default in C_BPartner is true
|
||||
}
|
||||
// it has to be the last if, to subscribe the bp.setIsCustomer (false) of the other two
|
||||
if (impBP.isCustomer()){
|
||||
bp.setIsCustomer(true);
|
||||
}
|
||||
} // setTypeOfBPartner
|
||||
|
||||
|
||||
//@Override
|
||||
public String getWhereClause()
|
||||
{
|
||||
StringBuilder msgreturn = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||
return msgreturn.toString();
|
||||
}
|
||||
|
||||
|
||||
//@Override
|
||||
public String getImportTableName()
|
||||
{
|
||||
return X_I_BPartner.Table_Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type of Business Partner
|
||||
*
|
||||
* @param X_I_BPartner impBP
|
||||
* @param MBPartner bp
|
||||
*/
|
||||
private void setTypeOfBPartner(X_I_BPartner impBP, MBPartner bp){
|
||||
if (impBP.isVendor()){
|
||||
bp.setIsVendor(true);
|
||||
bp.setIsCustomer(false); // It is put to false since by default in C_BPartner is true
|
||||
}
|
||||
if (impBP.isEmployee()){
|
||||
bp.setIsEmployee(true);
|
||||
bp.setIsCustomer(false); // It is put to false since by default in C_BPartner is true
|
||||
}
|
||||
// it has to be the last if, to subscribe the bp.setIsCustomer (false) of the other two
|
||||
if (impBP.isCustomer()){
|
||||
bp.setIsCustomer(true);
|
||||
}
|
||||
} // setTypeOfBPartner
|
||||
|
||||
} // ImportBPartner
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,33 +16,33 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAccount;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MAcctSchemaDefault;
|
||||
import org.compiere.model.MDocType;
|
||||
import org.compiere.model.MFactAcct;
|
||||
import org.compiere.model.MGLCategory;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MJournal;
|
||||
import org.compiere.model.MJournalLine;
|
||||
import org.compiere.model.MOrg;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_T_InvoiceGL;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAccount;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MAcctSchemaDefault;
|
||||
import org.compiere.model.MDocType;
|
||||
import org.compiere.model.MFactAcct;
|
||||
import org.compiere.model.MGLCategory;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MJournal;
|
||||
import org.compiere.model.MJournalLine;
|
||||
import org.compiere.model.MOrg;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_T_InvoiceGL;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
* Invoice Not realized Gain & Loss.
|
||||
* The actual data shown is T_InvoiceGL_v
|
||||
* @author Jorg Janke
|
||||
* @version $Id: InvoiceNGL.java,v 1.3 2006/08/04 03:53:59 jjanke Exp $
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
*/
|
||||
public class InvoiceNGL extends SvrProcess
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ public class InvoiceNGL extends SvrProcess
|
|||
{
|
||||
if (p_IsAllCurrencies)
|
||||
p_C_Currency_ID = 0;
|
||||
if (log.isLoggable(Level.INFO)) log.info("C_AcctSchema_ID=" + p_C_AcctSchema_ID
|
||||
if (log.isLoggable(Level.INFO)) log.info("C_AcctSchema_ID=" + p_C_AcctSchema_ID
|
||||
+ ",C_ConversionTypeReval_ID=" + p_C_ConversionTypeReval_ID
|
||||
+ ",DateReval=" + p_DateReval
|
||||
+ ", APAR=" + p_APAR
|
||||
|
@ -115,87 +115,87 @@ public class InvoiceNGL extends SvrProcess
|
|||
p_DateReval = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
// Delete - just to be sure
|
||||
StringBuilder sql = new StringBuilder("DELETE T_InvoiceGL WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
StringBuilder sql = new StringBuilder("DELETE T_InvoiceGL WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no > 0)
|
||||
if (log.isLoggable(Level.INFO)) log.info("Deleted #" + no);
|
||||
if (log.isLoggable(Level.INFO)) log.info("Deleted #" + no);
|
||||
|
||||
// Insert Trx
|
||||
String dateStr = DB.TO_DATE(p_DateReval, true);
|
||||
sql = new StringBuilder("INSERT INTO T_InvoiceGL (AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,")
|
||||
.append(" AD_PInstance_ID, C_Invoice_ID, GrandTotal, OpenAmt, ")
|
||||
.append(" Fact_Acct_ID, AmtSourceBalance, AmtAcctBalance, ")
|
||||
.append(" AmtRevalDr, AmtRevalCr, C_DocTypeReval_ID, IsAllCurrencies, ")
|
||||
.append(" DateReval, C_ConversionTypeReval_ID, AmtRevalDrDiff, AmtRevalCrDiff, APAR) ")
|
||||
sql = new StringBuilder("INSERT INTO T_InvoiceGL (AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,")
|
||||
.append(" AD_PInstance_ID, C_Invoice_ID, GrandTotal, OpenAmt, ")
|
||||
.append(" Fact_Acct_ID, AmtSourceBalance, AmtAcctBalance, ")
|
||||
.append(" AmtRevalDr, AmtRevalCr, C_DocTypeReval_ID, IsAllCurrencies, ")
|
||||
.append(" DateReval, C_ConversionTypeReval_ID, AmtRevalDrDiff, AmtRevalCrDiff, APAR) ")
|
||||
// --
|
||||
.append("SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,")
|
||||
.append( getAD_PInstance_ID()).append(", i.C_Invoice_ID, i.GrandTotal, invoiceOpen(i.C_Invoice_ID, 0), ")
|
||||
.append(" fa.Fact_Acct_ID, fa.AmtSourceDr-fa.AmtSourceCr, fa.AmtAcctDr-fa.AmtAcctCr, ")
|
||||
.append("SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy,")
|
||||
.append( getAD_PInstance_ID()).append(", i.C_Invoice_ID, i.GrandTotal, invoiceOpen(i.C_Invoice_ID, 0), ")
|
||||
.append(" fa.Fact_Acct_ID, fa.AmtSourceDr-fa.AmtSourceCr, fa.AmtAcctDr-fa.AmtAcctCr, ")
|
||||
// AmtRevalDr, AmtRevalCr,
|
||||
.append(" currencyConvert(fa.AmtSourceDr, i.C_Currency_ID, a.C_Currency_ID, ").append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", i.AD_Client_ID, i.AD_Org_ID),")
|
||||
.append(" currencyConvert(fa.AmtSourceCr, i.C_Currency_ID, a.C_Currency_ID, ").append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", i.AD_Client_ID, i.AD_Org_ID),")
|
||||
.append((p_C_DocTypeReval_ID==0 ? "NULL" : String.valueOf(p_C_DocTypeReval_ID))).append(", ")
|
||||
.append((p_IsAllCurrencies ? "'Y'," : "'N',"))
|
||||
.append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", 0, 0, '").append(p_APAR).append("' ")
|
||||
.append(" currencyConvert(fa.AmtSourceDr, i.C_Currency_ID, a.C_Currency_ID, ").append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", i.AD_Client_ID, i.AD_Org_ID),")
|
||||
.append(" currencyConvert(fa.AmtSourceCr, i.C_Currency_ID, a.C_Currency_ID, ").append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", i.AD_Client_ID, i.AD_Org_ID),")
|
||||
.append((p_C_DocTypeReval_ID==0 ? "NULL" : String.valueOf(p_C_DocTypeReval_ID))).append(", ")
|
||||
.append((p_IsAllCurrencies ? "'Y'," : "'N',"))
|
||||
.append(dateStr).append(", ").append(p_C_ConversionTypeReval_ID).append(", 0, 0, '").append(p_APAR).append("' ")
|
||||
//
|
||||
.append("FROM C_Invoice_v i")
|
||||
.append(" INNER JOIN Fact_Acct fa ON (fa.AD_Table_ID=318 AND fa.Record_ID=i.C_Invoice_ID")
|
||||
.append(" AND (i.GrandTotal=fa.AmtSourceDr OR i.GrandTotal=fa.AmtSourceCr))")
|
||||
.append(" INNER JOIN C_AcctSchema a ON (fa.C_AcctSchema_ID=a.C_AcctSchema_ID) ")
|
||||
.append("WHERE i.IsPaid='N'")
|
||||
.append(" AND EXISTS (SELECT * FROM C_ElementValue ev ")
|
||||
.append("WHERE ev.C_ElementValue_ID=fa.Account_ID AND (ev.AccountType='A' OR ev.AccountType='L'))")
|
||||
.append(" AND fa.C_AcctSchema_ID=").append(p_C_AcctSchema_ID);
|
||||
if (p_IsAllCurrencies)
|
||||
sql.append(" AND i.C_Currency_ID<>a.C_Currency_ID");
|
||||
.append("FROM C_Invoice_v i")
|
||||
.append(" INNER JOIN Fact_Acct fa ON (fa.AD_Table_ID=318 AND fa.Record_ID=i.C_Invoice_ID")
|
||||
.append(" AND (i.GrandTotal=fa.AmtSourceDr OR i.GrandTotal=fa.AmtSourceCr))")
|
||||
.append(" INNER JOIN C_AcctSchema a ON (fa.C_AcctSchema_ID=a.C_AcctSchema_ID) ")
|
||||
.append("WHERE i.IsPaid='N'")
|
||||
.append(" AND EXISTS (SELECT * FROM C_ElementValue ev ")
|
||||
.append("WHERE ev.C_ElementValue_ID=fa.Account_ID AND (ev.AccountType='A' OR ev.AccountType='L'))")
|
||||
.append(" AND fa.C_AcctSchema_ID=").append(p_C_AcctSchema_ID);
|
||||
if (p_IsAllCurrencies)
|
||||
sql.append(" AND i.C_Currency_ID<>a.C_Currency_ID");
|
||||
if (ONLY_AR.equals(p_APAR))
|
||||
sql.append(" AND i.IsSOTrx='Y'");
|
||||
sql.append(" AND i.IsSOTrx='Y'");
|
||||
else if (ONLY_AP.equals(p_APAR))
|
||||
sql.append(" AND i.IsSOTrx='N'");
|
||||
sql.append(" AND i.IsSOTrx='N'");
|
||||
if (!p_IsAllCurrencies && p_C_Currency_ID != 0)
|
||||
sql.append(" AND i.C_Currency_ID=").append(p_C_Currency_ID);
|
||||
sql.append(" AND i.C_Currency_ID=").append(p_C_Currency_ID);
|
||||
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no != 0) {
|
||||
if (log.isLoggable(Level.INFO)) log.info("Inserted #" + no);
|
||||
} else if (log.isLoggable(Level.FINER)) {
|
||||
log.warning("Inserted #" + no + " - " + sql);
|
||||
} else {
|
||||
log.warning("Inserted #" + no);
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no != 0) {
|
||||
if (log.isLoggable(Level.INFO)) log.info("Inserted #" + no);
|
||||
} else if (log.isLoggable(Level.FINER)) {
|
||||
log.warning("Inserted #" + no + " - " + sql);
|
||||
} else {
|
||||
log.warning("Inserted #" + no);
|
||||
}
|
||||
|
||||
// Calculate Difference
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL gl ")
|
||||
.append("SET (AmtRevalDrDiff,AmtRevalCrDiff)=")
|
||||
.append("(SELECT gl.AmtRevalDr-fa.AmtAcctDr, gl.AmtRevalCr-fa.AmtAcctCr ")
|
||||
.append("FROM Fact_Acct fa ")
|
||||
.append("WHERE gl.Fact_Acct_ID=fa.Fact_Acct_ID) ")
|
||||
.append("WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
int noT = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL gl ")
|
||||
.append("SET (AmtRevalDrDiff,AmtRevalCrDiff)=")
|
||||
.append("(SELECT gl.AmtRevalDr-fa.AmtAcctDr, gl.AmtRevalCr-fa.AmtAcctCr ")
|
||||
.append("FROM Fact_Acct fa ")
|
||||
.append("WHERE gl.Fact_Acct_ID=fa.Fact_Acct_ID) ")
|
||||
.append("WHERE AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
int noT = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (noT > 0)
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Difference #" + noT);
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Difference #" + noT);
|
||||
|
||||
// Percentage
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = 100 ")
|
||||
.append("WHERE GrandTotal=OpenAmt AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no > 0)
|
||||
if (log.isLoggable(Level.INFO)) log.info("Not Paid #" + no);
|
||||
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,6) ")
|
||||
.append("WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no > 0)
|
||||
if (log.isLoggable(Level.INFO)) log.info("Partial Paid #" + no);
|
||||
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL SET AmtRevalDr = AmtRevalDr * Percent/100,")
|
||||
.append(" AmtRevalCr = AmtRevalCr * Percent/100,")
|
||||
.append(" AmtRevalDrDiff = AmtRevalDrDiff * Percent/100,")
|
||||
.append(" AmtRevalCrDiff = AmtRevalCrDiff * Percent/100 ")
|
||||
.append("WHERE Percent <> 100 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = 100 ")
|
||||
.append("WHERE GrandTotal=OpenAmt AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no > 0)
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Partial Calc #" + no);
|
||||
if (log.isLoggable(Level.INFO)) log.info("Not Paid #" + no);
|
||||
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL SET Percent = ROUND(OpenAmt*100/GrandTotal,6) ")
|
||||
.append("WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no > 0)
|
||||
if (log.isLoggable(Level.INFO)) log.info("Partial Paid #" + no);
|
||||
|
||||
sql = new StringBuilder("UPDATE T_InvoiceGL SET AmtRevalDr = AmtRevalDr * Percent/100,")
|
||||
.append(" AmtRevalCr = AmtRevalCr * Percent/100,")
|
||||
.append(" AmtRevalDrDiff = AmtRevalDrDiff * Percent/100,")
|
||||
.append(" AmtRevalCrDiff = AmtRevalCrDiff * Percent/100 ")
|
||||
.append("WHERE Percent <> 100 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (no > 0)
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Partial Calc #" + no);
|
||||
|
||||
// Create Document
|
||||
String info = "";
|
||||
|
@ -205,9 +205,9 @@ public class InvoiceNGL extends SvrProcess
|
|||
log.warning("Can create Journal only for all currencies");
|
||||
else
|
||||
info = createGLJournal();
|
||||
}
|
||||
StringBuilder msgreturn = new StringBuilder("#").append(noT).append(info);
|
||||
return msgreturn.toString();
|
||||
}
|
||||
StringBuilder msgreturn = new StringBuilder("#").append(noT).append(info);
|
||||
return msgreturn.toString();
|
||||
} // doIt
|
||||
|
||||
/**
|
||||
|
@ -216,13 +216,13 @@ public class InvoiceNGL extends SvrProcess
|
|||
*/
|
||||
private String createGLJournal()
|
||||
{
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
final String whereClause = "AD_PInstance_ID=?";
|
||||
List <X_T_InvoiceGL> list = new Query(getCtx(), X_T_InvoiceGL.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(getAD_PInstance_ID())
|
||||
.setOrderBy("AD_Org_ID")
|
||||
.list();
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
final String whereClause = "AD_PInstance_ID=?";
|
||||
List <X_T_InvoiceGL> list = new Query(getCtx(), X_T_InvoiceGL.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(getAD_PInstance_ID())
|
||||
.setOrderBy("AD_Org_ID")
|
||||
.list();
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
|
||||
if (list.size() == 0)
|
||||
return " - No Records found";
|
||||
|
@ -237,23 +237,23 @@ public class InvoiceNGL extends SvrProcess
|
|||
cat = MGLCategory.get(getCtx(), docType.getGL_Category_ID());
|
||||
}
|
||||
//
|
||||
MJournal journal = new MJournal (getCtx(), 0, get_TrxName());
|
||||
journal.setC_DocType_ID(p_C_DocTypeReval_ID);
|
||||
journal.setPostingType(MJournal.POSTINGTYPE_Actual);
|
||||
journal.setDateDoc(p_DateReval);
|
||||
journal.setDateAcct(p_DateReval); // sets the period too
|
||||
journal.setC_Currency_ID(as.getC_Currency_ID());
|
||||
journal.setC_AcctSchema_ID (as.getC_AcctSchema_ID());
|
||||
journal.setC_ConversionType_ID(p_C_ConversionTypeReval_ID);
|
||||
journal.setGL_Category_ID (cat.getGL_Category_ID());
|
||||
journal.setDescription(getName()); // updated below
|
||||
if (!journal.save())
|
||||
return " - Could not create Journal";
|
||||
//
|
||||
MJournal journal = new MJournal (getCtx(), 0, get_TrxName());
|
||||
journal.setC_DocType_ID(p_C_DocTypeReval_ID);
|
||||
journal.setPostingType(MJournal.POSTINGTYPE_Actual);
|
||||
journal.setDateDoc(p_DateReval);
|
||||
journal.setDateAcct(p_DateReval); // sets the period too
|
||||
journal.setC_Currency_ID(as.getC_Currency_ID());
|
||||
journal.setC_AcctSchema_ID (as.getC_AcctSchema_ID());
|
||||
journal.setC_ConversionType_ID(p_C_ConversionTypeReval_ID);
|
||||
journal.setGL_Category_ID (cat.getGL_Category_ID());
|
||||
journal.setDescription(getName()); // updated below
|
||||
if (!journal.save())
|
||||
return " - Could not create Journal";
|
||||
//
|
||||
BigDecimal gainTotal = Env.ZERO;
|
||||
BigDecimal lossTotal = Env.ZERO;
|
||||
int AD_Org_ID = 0;
|
||||
MOrg org = null;
|
||||
MOrg org = null;
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
X_T_InvoiceGL gl = list.get(i);
|
||||
|
@ -261,65 +261,65 @@ public class InvoiceNGL extends SvrProcess
|
|||
continue;
|
||||
MInvoice invoice = new MInvoice(getCtx(), gl.getC_Invoice_ID(), null);
|
||||
if (invoice.getC_Currency_ID() == as.getC_Currency_ID())
|
||||
continue;
|
||||
//
|
||||
if (AD_Org_ID == 0) // invoice org id
|
||||
AD_Org_ID = gl.getAD_Org_ID();
|
||||
// Change in Org
|
||||
if (AD_Org_ID != gl.getAD_Org_ID())
|
||||
{
|
||||
createBalancing (asDefaultAccts, journal, gainTotal, lossTotal, AD_Org_ID, (i+1) * 10);
|
||||
//
|
||||
AD_Org_ID = gl.getAD_Org_ID();
|
||||
gainTotal = Env.ZERO;
|
||||
lossTotal = Env.ZERO;
|
||||
journal = null;
|
||||
}
|
||||
//
|
||||
if (org == null) {
|
||||
org = MOrg.get(getCtx(), gl.getAD_Org_ID());
|
||||
journal.setDescription (getName() + " - " + org.getName());
|
||||
if (!journal.save())
|
||||
return " - Could not set Description for Journal";
|
||||
continue;
|
||||
//
|
||||
if (AD_Org_ID == 0) // invoice org id
|
||||
AD_Org_ID = gl.getAD_Org_ID();
|
||||
// Change in Org
|
||||
if (AD_Org_ID != gl.getAD_Org_ID())
|
||||
{
|
||||
createBalancing (asDefaultAccts, journal, gainTotal, lossTotal, AD_Org_ID, (i+1) * 10);
|
||||
//
|
||||
AD_Org_ID = gl.getAD_Org_ID();
|
||||
gainTotal = Env.ZERO;
|
||||
lossTotal = Env.ZERO;
|
||||
journal = null;
|
||||
}
|
||||
//
|
||||
if (org == null) {
|
||||
org = MOrg.get(getCtx(), gl.getAD_Org_ID());
|
||||
journal.setDescription (getName() + " - " + org.getName());
|
||||
if (!journal.save())
|
||||
return " - Could not set Description for Journal";
|
||||
}
|
||||
//
|
||||
MJournalLine line = new MJournalLine(journal);
|
||||
line.setLine((i+1) * 10);
|
||||
line.setDescription(invoice.getSummary());
|
||||
//
|
||||
MFactAcct fa = new MFactAcct (getCtx(), gl.getFact_Acct_ID(), null);
|
||||
MFactAcct fa = new MFactAcct (getCtx(), gl.getFact_Acct_ID(), null);
|
||||
MAccount acct = MAccount.get(fa);
|
||||
line.setC_ValidCombination_ID(acct);
|
||||
BigDecimal dr = gl.getAmtRevalDrDiff();
|
||||
BigDecimal cr = gl.getAmtRevalCrDiff();
|
||||
// Check if acct.IsActiva to differentiate gain and loss ->
|
||||
// acct.isActiva negative dr or positive cr -> loss
|
||||
// acct.isActiva positive dr or negative cr -> gain
|
||||
// acct.isPassiva negative cr or positive dr -> gain
|
||||
// acct.isPassiva positive cr or negative dr -> loss
|
||||
if (acct.isActiva()) {
|
||||
if (dr.signum() < 0) {
|
||||
lossTotal = lossTotal.add(dr.negate());
|
||||
} else if (dr.signum() > 0) {
|
||||
gainTotal = gainTotal.add(dr);
|
||||
}
|
||||
if (cr.signum() > 0) {
|
||||
lossTotal = lossTotal.add(cr);
|
||||
} if (cr.signum() < 0) {
|
||||
gainTotal = gainTotal.add(cr.negate());
|
||||
}
|
||||
} else { // isPassiva
|
||||
if (cr.signum() < 0) {
|
||||
gainTotal = gainTotal.add(cr.negate());
|
||||
} else if (cr.signum() > 0) {
|
||||
lossTotal = lossTotal.add(cr);
|
||||
}
|
||||
if (dr.signum() > 0) {
|
||||
gainTotal = gainTotal.add(dr);
|
||||
} else if (dr.signum() < 0) {
|
||||
lossTotal = lossTotal.add(dr.negate());
|
||||
}
|
||||
}
|
||||
BigDecimal cr = gl.getAmtRevalCrDiff();
|
||||
// Check if acct.IsActiva to differentiate gain and loss ->
|
||||
// acct.isActiva negative dr or positive cr -> loss
|
||||
// acct.isActiva positive dr or negative cr -> gain
|
||||
// acct.isPassiva negative cr or positive dr -> gain
|
||||
// acct.isPassiva positive cr or negative dr -> loss
|
||||
if (acct.isActiva()) {
|
||||
if (dr.signum() < 0) {
|
||||
lossTotal = lossTotal.add(dr.negate());
|
||||
} else if (dr.signum() > 0) {
|
||||
gainTotal = gainTotal.add(dr);
|
||||
}
|
||||
if (cr.signum() > 0) {
|
||||
lossTotal = lossTotal.add(cr);
|
||||
} if (cr.signum() < 0) {
|
||||
gainTotal = gainTotal.add(cr.negate());
|
||||
}
|
||||
} else { // isPassiva
|
||||
if (cr.signum() < 0) {
|
||||
gainTotal = gainTotal.add(cr.negate());
|
||||
} else if (cr.signum() > 0) {
|
||||
lossTotal = lossTotal.add(cr);
|
||||
}
|
||||
if (dr.signum() > 0) {
|
||||
gainTotal = gainTotal.add(dr);
|
||||
} else if (dr.signum() < 0) {
|
||||
lossTotal = lossTotal.add(dr.negate());
|
||||
}
|
||||
}
|
||||
line.setAmtSourceDr (dr);
|
||||
line.setAmtAcctDr (dr);
|
||||
line.setAmtSourceCr (cr);
|
||||
|
@ -327,10 +327,10 @@ public class InvoiceNGL extends SvrProcess
|
|||
line.saveEx();
|
||||
}
|
||||
createBalancing (asDefaultAccts, journal, gainTotal, lossTotal, AD_Org_ID, (list.size()+1) * 10);
|
||||
|
||||
StringBuilder msgreturn = new StringBuilder(" - ").append(journal.getDocumentNo()).append(" #").append(list.size());
|
||||
addLog(journal.getGL_Journal_ID(), null, null, msgreturn.toString(), MJournal.Table_ID, journal.getGL_Journal_ID());
|
||||
return "OK";
|
||||
|
||||
StringBuilder msgreturn = new StringBuilder(" - ").append(journal.getDocumentNo()).append(" #").append(list.size());
|
||||
addLog(journal.getGL_Journal_ID(), null, null, msgreturn.toString(), MJournal.Table_ID, journal.getGL_Journal_ID());
|
||||
return "OK";
|
||||
} // createGLJournal
|
||||
|
||||
/**
|
||||
|
@ -346,7 +346,7 @@ public class InvoiceNGL extends SvrProcess
|
|||
BigDecimal gainTotal, BigDecimal lossTotal, int AD_Org_ID, int lineNo)
|
||||
{
|
||||
if (journal == null)
|
||||
throw new IllegalArgumentException("Journal is null");
|
||||
throw new IllegalArgumentException("Journal is null");
|
||||
// CR Entry = Gain
|
||||
if (gainTotal.signum() != 0)
|
||||
{
|
||||
|
@ -358,7 +358,7 @@ public class InvoiceNGL extends SvrProcess
|
|||
base.getM_Product_ID(), base.getC_BPartner_ID(), base.getAD_OrgTrx_ID(),
|
||||
base.getC_LocFrom_ID(), base.getC_LocTo_ID(), base.getC_SalesRegion_ID(),
|
||||
base.getC_Project_ID(), base.getC_Campaign_ID(), base.getC_Activity_ID(),
|
||||
base.getUser1_ID(), base.getUser2_ID(), base.getUserElement1_ID(), base.getUserElement2_ID(),
|
||||
base.getUser1_ID(), base.getUser2_ID(), base.getUserElement1_ID(), base.getUserElement2_ID(),
|
||||
get_TrxName());
|
||||
line.setDescription(Msg.getElement(getCtx(), "UnrealizedGain_Acct"));
|
||||
line.setC_ValidCombination_ID(acct.getC_ValidCombination_ID());
|
||||
|
@ -377,7 +377,7 @@ public class InvoiceNGL extends SvrProcess
|
|||
base.getM_Product_ID(), base.getC_BPartner_ID(), base.getAD_OrgTrx_ID(),
|
||||
base.getC_LocFrom_ID(), base.getC_LocTo_ID(), base.getC_SalesRegion_ID(),
|
||||
base.getC_Project_ID(), base.getC_Campaign_ID(), base.getC_Activity_ID(),
|
||||
base.getUser1_ID(), base.getUser2_ID(), base.getUserElement1_ID(), base.getUserElement2_ID(),
|
||||
base.getUser1_ID(), base.getUser2_ID(), base.getUserElement1_ID(), base.getUserElement2_ID(),
|
||||
get_TrxName());
|
||||
line.setDescription(Msg.getElement(getCtx(), "UnrealizedLoss_Acct"));
|
||||
line.setC_ValidCombination_ID(acct.getC_ValidCombination_ID());
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,20 +16,20 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.compiere.model.MPaySelection;
|
||||
import org.compiere.model.MPaySelectionLine;
|
||||
import org.compiere.model.X_C_Order;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.compiere.model.MPaySelection;
|
||||
import org.compiere.model.MPaySelectionLine;
|
||||
import org.compiere.model.X_C_Order;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public class PaySelectionCreateFrom extends SvrProcess
|
|||
p_C_BPartner_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("C_BP_Group_ID"))
|
||||
p_C_BP_Group_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("DueDate"))
|
||||
else if (name.equals("DueDate"))
|
||||
p_DueDate = (Timestamp) para[i].getParameter();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
|
@ -99,7 +99,7 @@ public class PaySelectionCreateFrom extends SvrProcess
|
|||
*/
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
if (log.isLoggable(Level.INFO)) log.info ("C_PaySelection_ID=" + p_C_PaySelection_ID
|
||||
if (log.isLoggable(Level.INFO)) log.info ("C_PaySelection_ID=" + p_C_PaySelection_ID
|
||||
+ ", OnlyDiscount=" + p_OnlyDiscount + ", OnlyDue=" + p_OnlyDue
|
||||
+ ", IncludeInDispute=" + p_IncludeInDispute
|
||||
+ ", MatchRequirement=" + p_MatchRequirement
|
||||
|
@ -112,95 +112,95 @@ public class PaySelectionCreateFrom extends SvrProcess
|
|||
if (psel.isProcessed())
|
||||
throw new IllegalArgumentException("@Processed@");
|
||||
|
||||
if ( p_DueDate == null )
|
||||
p_DueDate = psel.getPayDate();
|
||||
if ( p_DueDate == null )
|
||||
p_DueDate = psel.getPayDate();
|
||||
|
||||
// psel.getPayDate();
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT C_Invoice_ID,") // 1
|
||||
StringBuilder sql = new StringBuilder("SELECT C_Invoice_ID,") // 1
|
||||
// Open
|
||||
.append(" currencyConvert(invoiceOpen(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID)")
|
||||
.append(",i.C_Currency_ID, ?,?, i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS PayAmt,") // 2 ##p1/p2 Currency_To,PayDate
|
||||
// Discount
|
||||
.append(" currencyConvert(invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)") // ##p3 PayDate
|
||||
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS DiscountAmt,") // 3 ##p4/p5 Currency_To,PayDate
|
||||
.append(" PaymentRule, IsSOTrx, ") // 4..5
|
||||
.append(" currencyConvert(invoiceWriteOff(i.C_Invoice_ID) ")
|
||||
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS WriteOffAmt ") // 6 ##p6/p7 Currency_To,PayDate
|
||||
.append("FROM C_Invoice_v i WHERE ");
|
||||
if (X_C_Order.PAYMENTRULE_DirectDebit.equals(p_PaymentRule))
|
||||
sql.append("IsSOTrx='Y'");
|
||||
else
|
||||
sql.append("IsSOTrx='N'");
|
||||
sql.append(" AND IsPaid='N' AND DocStatus IN ('CO','CL')")
|
||||
.append(" AND AD_Client_ID=?") // ##p8
|
||||
// Existing Payments - Will reselect Invoice if prepared but not paid
|
||||
.append(" AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl")
|
||||
.append(" INNER JOIN C_PaySelectionCheck psc ON (psl.C_PaySelectionCheck_ID=psc.C_PaySelectionCheck_ID)")
|
||||
.append(" LEFT OUTER JOIN C_Payment pmt ON (pmt.C_Payment_ID=psc.C_Payment_ID)")
|
||||
.append(" WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.IsActive='Y'")
|
||||
.append(" AND (pmt.DocStatus IS NULL OR pmt.DocStatus NOT IN ('VO','RE')) )")
|
||||
// Don't generate again invoices already on this payment selection
|
||||
.append(" AND i.C_Invoice_ID NOT IN (SELECT i.C_Invoice_ID FROM C_PaySelectionLine psl WHERE psl.C_PaySelection_ID=?)"); // ##p9
|
||||
.append(" currencyConvert(invoiceOpen(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID)")
|
||||
.append(",i.C_Currency_ID, ?,?, i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS PayAmt,") // 2 ##p1/p2 Currency_To,PayDate
|
||||
// Discount
|
||||
.append(" currencyConvert(invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)") // ##p3 PayDate
|
||||
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS DiscountAmt,") // 3 ##p4/p5 Currency_To,PayDate
|
||||
.append(" PaymentRule, IsSOTrx, ") // 4..5
|
||||
.append(" currencyConvert(invoiceWriteOff(i.C_Invoice_ID) ")
|
||||
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS WriteOffAmt ") // 6 ##p6/p7 Currency_To,PayDate
|
||||
.append("FROM C_Invoice_v i WHERE ");
|
||||
if (X_C_Order.PAYMENTRULE_DirectDebit.equals(p_PaymentRule))
|
||||
sql.append("IsSOTrx='Y'");
|
||||
else
|
||||
sql.append("IsSOTrx='N'");
|
||||
sql.append(" AND IsPaid='N' AND DocStatus IN ('CO','CL')")
|
||||
.append(" AND AD_Client_ID=?") // ##p8
|
||||
// Existing Payments - Will reselect Invoice if prepared but not paid
|
||||
.append(" AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl")
|
||||
.append(" INNER JOIN C_PaySelectionCheck psc ON (psl.C_PaySelectionCheck_ID=psc.C_PaySelectionCheck_ID)")
|
||||
.append(" LEFT OUTER JOIN C_Payment pmt ON (pmt.C_Payment_ID=psc.C_Payment_ID)")
|
||||
.append(" WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.IsActive='Y'")
|
||||
.append(" AND (pmt.DocStatus IS NULL OR pmt.DocStatus NOT IN ('VO','RE')) )")
|
||||
// Don't generate again invoices already on this payment selection
|
||||
.append(" AND i.C_Invoice_ID NOT IN (SELECT i.C_Invoice_ID FROM C_PaySelectionLine psl WHERE psl.C_PaySelection_ID=?)"); // ##p9
|
||||
// Disputed
|
||||
if (!p_IncludeInDispute)
|
||||
sql.append(" AND i.IsInDispute='N'");
|
||||
sql.append(" AND i.IsInDispute='N'");
|
||||
// PaymentRule (optional)
|
||||
if (p_PaymentRule != null)
|
||||
sql.append(" AND PaymentRule=?"); // ##
|
||||
sql.append(" AND PaymentRule=?"); // ##
|
||||
// OnlyDiscount
|
||||
if (p_OnlyDiscount)
|
||||
{
|
||||
if (p_OnlyDue)
|
||||
sql.append(" AND (");
|
||||
sql.append(" AND (");
|
||||
else
|
||||
sql.append(" AND ");
|
||||
sql.append("invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID) > 0"); // ##
|
||||
sql.append(" AND ");
|
||||
sql.append("invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID) > 0"); // ##
|
||||
}
|
||||
// OnlyDue
|
||||
if (p_OnlyDue)
|
||||
{
|
||||
if (p_OnlyDiscount)
|
||||
sql.append(" OR ");
|
||||
sql.append(" OR ");
|
||||
else
|
||||
sql.append(" AND ");
|
||||
// sql.append("paymentTermDueDays(C_PaymentTerm_ID, DateInvoiced, ?) >= 0"); // ##
|
||||
sql.append("i.DueDate<=?"); // ##
|
||||
sql.append(" AND ");
|
||||
// sql.append("paymentTermDueDays(C_PaymentTerm_ID, DateInvoiced, ?) >= 0"); // ##
|
||||
sql.append("i.DueDate<=?"); // ##
|
||||
if (p_OnlyDiscount)
|
||||
sql.append(")");
|
||||
sql.append(")");
|
||||
}
|
||||
// Business Partner
|
||||
if (p_C_BPartner_ID != 0)
|
||||
sql.append(" AND C_BPartner_ID=?"); // ##
|
||||
sql.append(" AND C_BPartner_ID=?"); // ##
|
||||
// Business Partner Group
|
||||
else if (p_C_BP_Group_ID != 0)
|
||||
sql.append(" AND EXISTS (SELECT * FROM C_BPartner bp ")
|
||||
.append("WHERE bp.C_BPartner_ID=i.C_BPartner_ID AND bp.C_BP_Group_ID=?)"); // ##
|
||||
sql.append(" AND EXISTS (SELECT * FROM C_BPartner bp ")
|
||||
.append("WHERE bp.C_BPartner_ID=i.C_BPartner_ID AND bp.C_BP_Group_ID=?)"); // ##
|
||||
// PO Matching Requirement
|
||||
if (p_MatchRequirement.equals("P") || p_MatchRequirement.equals("B"))
|
||||
{
|
||||
sql.append(" AND EXISTS (SELECT * FROM C_InvoiceLine il ")
|
||||
.append("WHERE i.C_Invoice_ID=il.C_Invoice_ID")
|
||||
.append(" AND QtyInvoiced=(SELECT SUM(Qty) FROM M_MatchPO m ")
|
||||
.append("WHERE il.C_InvoiceLine_ID=m.C_InvoiceLine_ID))");
|
||||
sql.append(" AND EXISTS (SELECT * FROM C_InvoiceLine il ")
|
||||
.append("WHERE i.C_Invoice_ID=il.C_Invoice_ID")
|
||||
.append(" AND QtyInvoiced=(SELECT SUM(Qty) FROM M_MatchPO m ")
|
||||
.append("WHERE il.C_InvoiceLine_ID=m.C_InvoiceLine_ID))");
|
||||
}
|
||||
// Receipt Matching Requirement
|
||||
if (p_MatchRequirement.equals("R") || p_MatchRequirement.equals("B"))
|
||||
{
|
||||
sql.append(" AND EXISTS (SELECT * FROM C_InvoiceLine il ")
|
||||
.append("WHERE i.C_Invoice_ID=il.C_Invoice_ID")
|
||||
.append(" AND QtyInvoiced=(SELECT SUM(Qty) FROM M_MatchInv m ")
|
||||
.append("WHERE il.C_InvoiceLine_ID=m.C_InvoiceLine_ID))");
|
||||
sql.append(" AND EXISTS (SELECT * FROM C_InvoiceLine il ")
|
||||
.append("WHERE i.C_Invoice_ID=il.C_Invoice_ID")
|
||||
.append(" AND QtyInvoiced=(SELECT SUM(Qty) FROM M_MatchInv m ")
|
||||
.append("WHERE il.C_InvoiceLine_ID=m.C_InvoiceLine_ID))");
|
||||
}
|
||||
|
||||
//
|
||||
int lines = 0;
|
||||
int C_CurrencyTo_ID = psel.getC_Currency_ID();
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||
int index = 1;
|
||||
pstmt.setInt (index++, C_CurrencyTo_ID);
|
||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||
|
@ -208,11 +208,11 @@ public class PaySelectionCreateFrom extends SvrProcess
|
|||
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||
pstmt.setInt (index++, C_CurrencyTo_ID);
|
||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||
pstmt.setInt (index++, C_CurrencyTo_ID);
|
||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||
pstmt.setInt (index++, C_CurrencyTo_ID);
|
||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||
//
|
||||
pstmt.setInt(index++, psel.getAD_Client_ID());
|
||||
pstmt.setInt(index++, p_C_PaySelection_ID);
|
||||
pstmt.setInt(index++, p_C_PaySelection_ID);
|
||||
if (p_PaymentRule != null)
|
||||
pstmt.setString(index++, p_PaymentRule);
|
||||
if (p_OnlyDiscount)
|
||||
|
@ -224,7 +224,7 @@ public class PaySelectionCreateFrom extends SvrProcess
|
|||
else if (p_C_BP_Group_ID != 0)
|
||||
pstmt.setInt (index++, p_C_BP_Group_ID);
|
||||
//
|
||||
rs = pstmt.executeQuery ();
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
int C_Invoice_ID = rs.getInt(1);
|
||||
|
@ -232,7 +232,7 @@ public class PaySelectionCreateFrom extends SvrProcess
|
|||
if (C_Invoice_ID == 0 || Env.ZERO.compareTo(PayAmt) == 0)
|
||||
continue;
|
||||
BigDecimal DiscountAmt = rs.getBigDecimal(3);
|
||||
BigDecimal WriteOffAmt = rs.getBigDecimal(6);
|
||||
BigDecimal WriteOffAmt = rs.getBigDecimal(6);
|
||||
String PaymentRule = rs.getString(4);
|
||||
boolean isSOTrx = "Y".equals(rs.getString(5));
|
||||
//
|
||||
|
@ -245,23 +245,23 @@ public class PaySelectionCreateFrom extends SvrProcess
|
|||
throw new IllegalStateException ("Cannot save MPaySelectionLine");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DBException(e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
StringBuilder msgreturn = new StringBuilder("@C_PaySelectionLine_ID@ - #").append(lines);
|
||||
return msgreturn.toString();
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DBException(e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
StringBuilder msgreturn = new StringBuilder("@C_PaySelectionLine_ID@ - #").append(lines);
|
||||
return msgreturn.toString();
|
||||
} // doIt
|
||||
|
||||
} // PaySelectionCreateFrom
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MYear;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MYear;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
|
||||
/**
|
||||
* Create Periods of year
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: YearCreatePeriods.java,v 1.2 2006/07/30 00:51:01 jjanke Exp $
|
||||
*/
|
||||
public class YearCreatePeriods extends SvrProcess
|
||||
{
|
||||
private int p_C_Year_ID = 0;
|
||||
private Timestamp p_StartDate;
|
||||
private String p_DateFormat;
|
||||
|
||||
/**
|
||||
* Prepare
|
||||
*/
|
||||
protected void prepare ()
|
||||
{
|
||||
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
if (para[i].getParameter() == null)
|
||||
;
|
||||
else if (name.equals("StartDate"))
|
||||
p_StartDate = (Timestamp) para[i].getParameter();
|
||||
else if (name.equals("DateFormat"))
|
||||
p_DateFormat = (String) para[i].getParameter();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
p_C_Year_ID = getRecord_ID();
|
||||
} // prepare
|
||||
|
||||
/**
|
||||
* Process
|
||||
* @return info
|
||||
* @throws Exception
|
||||
*/
|
||||
protected String doIt ()
|
||||
throws Exception
|
||||
{
|
||||
MYear year = new MYear (getCtx(), p_C_Year_ID, get_TrxName());
|
||||
if (p_C_Year_ID == 0 || year.get_ID() != p_C_Year_ID)
|
||||
throw new AdempiereUserError ("@NotFound@: @C_Year_ID@ - " + p_C_Year_ID);
|
||||
if (log.isLoggable(Level.INFO)) log.info(year.toString());
|
||||
|
||||
/**
|
||||
* Create Periods of year
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: YearCreatePeriods.java,v 1.2 2006/07/30 00:51:01 jjanke Exp $
|
||||
*/
|
||||
public class YearCreatePeriods extends SvrProcess
|
||||
{
|
||||
private int p_C_Year_ID = 0;
|
||||
private Timestamp p_StartDate;
|
||||
private String p_DateFormat;
|
||||
|
||||
/**
|
||||
* Prepare
|
||||
*/
|
||||
protected void prepare ()
|
||||
{
|
||||
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
if (para[i].getParameter() == null)
|
||||
;
|
||||
else if (name.equals("StartDate"))
|
||||
p_StartDate = (Timestamp) para[i].getParameter();
|
||||
else if (name.equals("DateFormat"))
|
||||
p_DateFormat = (String) para[i].getParameter();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
p_C_Year_ID = getRecord_ID();
|
||||
} // prepare
|
||||
|
||||
/**
|
||||
* Process
|
||||
* @return info
|
||||
* @throws Exception
|
||||
*/
|
||||
protected String doIt ()
|
||||
throws Exception
|
||||
{
|
||||
MYear year = new MYear (getCtx(), p_C_Year_ID, get_TrxName());
|
||||
if (p_C_Year_ID == 0 || year.get_ID() != p_C_Year_ID)
|
||||
throw new AdempiereUserError ("@NotFound@: @C_Year_ID@ - " + p_C_Year_ID);
|
||||
if (log.isLoggable(Level.INFO)) log.info(year.toString());
|
||||
//
|
||||
if (year.createStdPeriods(null, p_StartDate, p_DateFormat))
|
||||
return "@OK@";
|
||||
if (year.createStdPeriods(null, p_StartDate, p_DateFormat))
|
||||
return "@OK@";
|
||||
return "@Error@";
|
||||
} // doIt
|
||||
|
||||
} // YearCreatePeriods
|
||||
} // doIt
|
||||
|
||||
} // YearCreatePeriods
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,177 +1,177 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.acct;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAccount;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MJournal;
|
||||
import org.compiere.model.MJournalLine;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Post GL Journal Documents.
|
||||
* <pre>
|
||||
* Table: GL_Journal (224)
|
||||
* Document Types: GLJ
|
||||
* </pre>
|
||||
* @author Jorg Janke
|
||||
* @version $Id: Doc_GLJournal.java,v 1.3 2006/07/30 00:53:33 jjanke Exp $
|
||||
*/
|
||||
public class Doc_GLJournal extends Doc
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param as accounting schema
|
||||
* @param rs record
|
||||
* @param trxName trx
|
||||
*/
|
||||
public Doc_GLJournal (MAcctSchema as, ResultSet rs, String trxName)
|
||||
{
|
||||
super(as, MJournal.class, rs, null, trxName);
|
||||
} // Doc_GL_Journal
|
||||
|
||||
/** Posting Type */
|
||||
protected String m_PostingType = null;
|
||||
protected int m_C_AcctSchema_ID = 0;
|
||||
|
||||
/**
|
||||
* Load Specific Document Details
|
||||
* @return error message or null
|
||||
*/
|
||||
protected String loadDocumentDetails ()
|
||||
{
|
||||
MJournal journal = (MJournal)getPO();
|
||||
m_PostingType = journal.getPostingType();
|
||||
m_C_AcctSchema_ID = journal.getC_AcctSchema_ID();
|
||||
|
||||
// Contained Objects
|
||||
p_lines = loadLines(journal);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Lines=" + p_lines.length);
|
||||
return null;
|
||||
} // loadDocumentDetails
|
||||
|
||||
|
||||
/**
|
||||
* Load Invoice Line
|
||||
* @param journal journal
|
||||
* @return DocLine Array
|
||||
*/
|
||||
protected DocLine[] loadLines(MJournal journal)
|
||||
{
|
||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||
MJournalLine[] lines = journal.getLines(false);
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
MJournalLine line = lines[i];
|
||||
DocLine docLine = new DocLine (line, this);
|
||||
// -- Quantity
|
||||
docLine.setQty(line.getQty(), false);
|
||||
// -- Source Amounts
|
||||
docLine.setAmount (line.getAmtSourceDr(), line.getAmtSourceCr());
|
||||
// -- Converted Amounts
|
||||
docLine.setConvertedAmt (m_C_AcctSchema_ID, line.getAmtAcctDr(), line.getAmtAcctCr());
|
||||
// -- Account
|
||||
MAccount account = line.getAccount_Combi();
|
||||
docLine.setAccount (account);
|
||||
// -- Organization of Line was set to Org of Account
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.acct;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAccount;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MJournal;
|
||||
import org.compiere.model.MJournalLine;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Post GL Journal Documents.
|
||||
* <pre>
|
||||
* Table: GL_Journal (224)
|
||||
* Document Types: GLJ
|
||||
* </pre>
|
||||
* @author Jorg Janke
|
||||
* @version $Id: Doc_GLJournal.java,v 1.3 2006/07/30 00:53:33 jjanke Exp $
|
||||
*/
|
||||
public class Doc_GLJournal extends Doc
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param as accounting schema
|
||||
* @param rs record
|
||||
* @param trxName trx
|
||||
*/
|
||||
public Doc_GLJournal (MAcctSchema as, ResultSet rs, String trxName)
|
||||
{
|
||||
super(as, MJournal.class, rs, null, trxName);
|
||||
} // Doc_GL_Journal
|
||||
|
||||
/** Posting Type */
|
||||
protected String m_PostingType = null;
|
||||
protected int m_C_AcctSchema_ID = 0;
|
||||
|
||||
/**
|
||||
* Load Specific Document Details
|
||||
* @return error message or null
|
||||
*/
|
||||
protected String loadDocumentDetails ()
|
||||
{
|
||||
MJournal journal = (MJournal)getPO();
|
||||
m_PostingType = journal.getPostingType();
|
||||
m_C_AcctSchema_ID = journal.getC_AcctSchema_ID();
|
||||
|
||||
// Contained Objects
|
||||
p_lines = loadLines(journal);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Lines=" + p_lines.length);
|
||||
return null;
|
||||
} // loadDocumentDetails
|
||||
|
||||
|
||||
/**
|
||||
* Load Invoice Line
|
||||
* @param journal journal
|
||||
* @return DocLine Array
|
||||
*/
|
||||
protected DocLine[] loadLines(MJournal journal)
|
||||
{
|
||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||
MJournalLine[] lines = journal.getLines(false);
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
MJournalLine line = lines[i];
|
||||
DocLine docLine = new DocLine (line, this);
|
||||
// -- Quantity
|
||||
docLine.setQty(line.getQty(), false);
|
||||
// -- Source Amounts
|
||||
docLine.setAmount (line.getAmtSourceDr(), line.getAmtSourceCr());
|
||||
// -- Converted Amounts
|
||||
docLine.setConvertedAmt (m_C_AcctSchema_ID, line.getAmtAcctDr(), line.getAmtAcctCr());
|
||||
// -- Account
|
||||
MAccount account = line.getAccount_Combi();
|
||||
docLine.setAccount (account);
|
||||
// -- Organization of Line was set to Org of Account
|
||||
list.add(docLine);
|
||||
|
||||
if (docLine.getC_Currency_ID() != getC_Currency_ID())
|
||||
setIsMultiCurrency(true);
|
||||
}
|
||||
// Return Array
|
||||
int size = list.size();
|
||||
DocLine[] dls = new DocLine[size];
|
||||
list.toArray(dls);
|
||||
return dls;
|
||||
} // loadLines
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Get Source Currency Balance - subtracts line and tax amounts from total - no rounding
|
||||
* @return positive amount, if total invoice is bigger than lines
|
||||
*/
|
||||
public BigDecimal getBalance()
|
||||
{
|
||||
BigDecimal retValue = Env.ZERO;
|
||||
StringBuilder sb = new StringBuilder (" [");
|
||||
// Lines
|
||||
for (int i = 0; i < p_lines.length; i++)
|
||||
{
|
||||
retValue = retValue.add(p_lines[i].getAmtSource());
|
||||
sb.append("+").append(p_lines[i].getAmtSource());
|
||||
}
|
||||
sb.append("]");
|
||||
//
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString() + " Balance=" + retValue + sb.toString());
|
||||
return retValue;
|
||||
} // getBalance
|
||||
|
||||
/**
|
||||
* Create Facts (the accounting logic) for
|
||||
* GLJ.
|
||||
* (only for the accounting scheme, it was created)
|
||||
* <pre>
|
||||
* account DR CR
|
||||
* </pre>
|
||||
* @param as acct schema
|
||||
* @return Fact
|
||||
*/
|
||||
public ArrayList<Fact> createFacts (MAcctSchema as)
|
||||
{
|
||||
ArrayList<Fact> facts = new ArrayList<Fact>();
|
||||
// Other Acct Schema
|
||||
if (as.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
|
||||
return facts;
|
||||
|
||||
// create Fact Header
|
||||
Fact fact = new Fact (this, as, m_PostingType);
|
||||
|
||||
// GLJ
|
||||
if (getDocumentType().equals(DOCTYPE_GLJournal))
|
||||
{
|
||||
// account DR CR
|
||||
for (int i = 0; i < p_lines.length; i++)
|
||||
{
|
||||
if (p_lines[i].getC_AcctSchema_ID () == as.getC_AcctSchema_ID ())
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
FactLine line = fact.createLine (p_lines[i],
|
||||
p_lines[i].getAccount (),
|
||||
p_lines[i].getC_Currency_ID(),
|
||||
p_lines[i].getAmtSourceDr (),
|
||||
p_lines[i].getAmtSourceCr ());
|
||||
}
|
||||
} // for all lines
|
||||
}
|
||||
else
|
||||
{
|
||||
p_Error = "DocumentType unknown: " + getDocumentType();
|
||||
log.log(Level.SEVERE, p_Error);
|
||||
fact = null;
|
||||
}
|
||||
//
|
||||
facts.add(fact);
|
||||
return facts;
|
||||
} // createFact
|
||||
|
||||
} // Doc_GLJournal
|
||||
setIsMultiCurrency(true);
|
||||
}
|
||||
// Return Array
|
||||
int size = list.size();
|
||||
DocLine[] dls = new DocLine[size];
|
||||
list.toArray(dls);
|
||||
return dls;
|
||||
} // loadLines
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Get Source Currency Balance - subtracts line and tax amounts from total - no rounding
|
||||
* @return positive amount, if total invoice is bigger than lines
|
||||
*/
|
||||
public BigDecimal getBalance()
|
||||
{
|
||||
BigDecimal retValue = Env.ZERO;
|
||||
StringBuilder sb = new StringBuilder (" [");
|
||||
// Lines
|
||||
for (int i = 0; i < p_lines.length; i++)
|
||||
{
|
||||
retValue = retValue.add(p_lines[i].getAmtSource());
|
||||
sb.append("+").append(p_lines[i].getAmtSource());
|
||||
}
|
||||
sb.append("]");
|
||||
//
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString() + " Balance=" + retValue + sb.toString());
|
||||
return retValue;
|
||||
} // getBalance
|
||||
|
||||
/**
|
||||
* Create Facts (the accounting logic) for
|
||||
* GLJ.
|
||||
* (only for the accounting scheme, it was created)
|
||||
* <pre>
|
||||
* account DR CR
|
||||
* </pre>
|
||||
* @param as acct schema
|
||||
* @return Fact
|
||||
*/
|
||||
public ArrayList<Fact> createFacts (MAcctSchema as)
|
||||
{
|
||||
ArrayList<Fact> facts = new ArrayList<Fact>();
|
||||
// Other Acct Schema
|
||||
if (as.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
|
||||
return facts;
|
||||
|
||||
// create Fact Header
|
||||
Fact fact = new Fact (this, as, m_PostingType);
|
||||
|
||||
// GLJ
|
||||
if (getDocumentType().equals(DOCTYPE_GLJournal))
|
||||
{
|
||||
// account DR CR
|
||||
for (int i = 0; i < p_lines.length; i++)
|
||||
{
|
||||
if (p_lines[i].getC_AcctSchema_ID () == as.getC_AcctSchema_ID ())
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
FactLine line = fact.createLine (p_lines[i],
|
||||
p_lines[i].getAccount (),
|
||||
p_lines[i].getC_Currency_ID(),
|
||||
p_lines[i].getAmtSourceDr (),
|
||||
p_lines[i].getAmtSourceCr ());
|
||||
}
|
||||
} // for all lines
|
||||
}
|
||||
else
|
||||
{
|
||||
p_Error = "DocumentType unknown: " + getDocumentType();
|
||||
log.log(Level.SEVERE, p_Error);
|
||||
fact = null;
|
||||
}
|
||||
//
|
||||
facts.add(fact);
|
||||
return facts;
|
||||
} // createFact
|
||||
|
||||
} // Doc_GLJournal
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,25 +16,25 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.acct;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAccount;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MClientInfo;
|
||||
import org.compiere.model.MCurrency;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.MRequisitionLine;
|
||||
import org.compiere.model.MTax;
|
||||
import org.compiere.model.ProductCost;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAccount;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MClientInfo;
|
||||
import org.compiere.model.MCurrency;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.MRequisitionLine;
|
||||
import org.compiere.model.MTax;
|
||||
import org.compiere.model.ProductCost;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Post Order Documents.
|
||||
|
@ -100,12 +100,12 @@ public class Doc_Order extends Doc
|
|||
{
|
||||
MOrderLine line = lines[i];
|
||||
DocLine docLine = new DocLine (line, this);
|
||||
BigDecimal Qty = line.getQtyOrdered();
|
||||
docLine.setQty(Qty, order.isSOTrx());
|
||||
//
|
||||
BigDecimal PriceCost = null;
|
||||
if (getDocumentType().equals(DOCTYPE_POrder)) // PO
|
||||
PriceCost = line.getPriceCost();
|
||||
BigDecimal Qty = line.getQtyOrdered();
|
||||
docLine.setQty(Qty, order.isSOTrx());
|
||||
//
|
||||
BigDecimal PriceCost = null;
|
||||
if (getDocumentType().equals(DOCTYPE_POrder)) // PO
|
||||
PriceCost = line.getPriceCost();
|
||||
BigDecimal LineNetAmt = null;
|
||||
if (PriceCost != null && PriceCost.signum() != 0)
|
||||
LineNetAmt = Qty.multiply(PriceCost);
|
||||
|
@ -121,7 +121,7 @@ public class Doc_Order extends Doc
|
|||
if (!tax.isZeroTax())
|
||||
{
|
||||
BigDecimal LineNetAmtTax = tax.calculateTax(LineNetAmt, true, getStdPrecision());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("LineNetAmt=" + LineNetAmt + " - Tax=" + LineNetAmtTax);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("LineNetAmt=" + LineNetAmt + " - Tax=" + LineNetAmtTax);
|
||||
LineNetAmt = LineNetAmt.subtract(LineNetAmtTax);
|
||||
for (int t = 0; t < m_taxes.length; t++)
|
||||
{
|
||||
|
@ -163,17 +163,17 @@ public class Doc_Order extends Doc
|
|||
}
|
||||
//
|
||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||
String sql = "SELECT * FROM M_RequisitionLine rl "
|
||||
+ "WHERE EXISTS (SELECT * FROM C_Order o "
|
||||
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID) "
|
||||
+ "WHERE ol.C_OrderLine_ID=rl.C_OrderLine_ID"
|
||||
+ " AND o.C_Order_ID=?) "
|
||||
+ "ORDER BY rl.C_OrderLine_ID";
|
||||
PreparedStatement pstmt = null;
|
||||
String sql = "SELECT * FROM M_RequisitionLine rl "
|
||||
+ "WHERE EXISTS (SELECT * FROM C_Order o "
|
||||
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID) "
|
||||
+ "WHERE ol.C_OrderLine_ID=rl.C_OrderLine_ID"
|
||||
+ " AND o.C_Order_ID=?) "
|
||||
+ "ORDER BY rl.C_OrderLine_ID";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, order.getC_Order_ID());
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
|
@ -200,12 +200,12 @@ public class Doc_Order extends Doc
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
// Return Array
|
||||
|
@ -233,14 +233,14 @@ public class Doc_Order extends Doc
|
|||
private DocTax[] loadTaxes()
|
||||
{
|
||||
ArrayList<DocTax> list = new ArrayList<DocTax>();
|
||||
StringBuilder sql = new StringBuilder("SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax ")
|
||||
.append("FROM C_Tax t, C_OrderTax it ")
|
||||
.append("WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Order_ID=?");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
StringBuilder sql = new StringBuilder("SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax ")
|
||||
.append("FROM C_Tax t, C_OrderTax it ")
|
||||
.append("WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Order_ID=?");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||
pstmt.setInt(1, get_ID());
|
||||
rs = pstmt.executeQuery();
|
||||
//
|
||||
|
@ -260,11 +260,11 @@ public class Doc_Order extends Doc
|
|||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
// Return Array
|
||||
|
@ -281,7 +281,7 @@ public class Doc_Order extends Doc
|
|||
public BigDecimal getBalance()
|
||||
{
|
||||
BigDecimal retValue = Env.ZERO;
|
||||
StringBuilder sb = new StringBuilder (" [");
|
||||
StringBuilder sb = new StringBuilder (" [");
|
||||
// Total
|
||||
retValue = retValue.add(getAmount(Doc.AMTTYPE_Gross));
|
||||
sb.append(getAmount(Doc.AMTTYPE_Gross));
|
||||
|
@ -311,11 +311,11 @@ public class Doc_Order extends Doc
|
|||
if (retValue.signum() != 0 // Sum of Cost(vs. Price) in lines may not add up
|
||||
&& getDocumentType().equals(DOCTYPE_POrder)) // PO
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString() + " Balance=" + retValue + sb.toString() + " (ignored)");
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString() + " Balance=" + retValue + sb.toString() + " (ignored)");
|
||||
retValue = Env.ZERO;
|
||||
}
|
||||
else
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString() + " Balance=" + retValue + sb.toString());
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString() + " Balance=" + retValue + sb.toString());
|
||||
return retValue;
|
||||
} // getBalance
|
||||
|
||||
|
@ -341,29 +341,29 @@ public class Doc_Order extends Doc
|
|||
// Purchase Order
|
||||
if (getDocumentType().equals(DOCTYPE_POrder))
|
||||
{
|
||||
updateProductPO(as);
|
||||
|
||||
//BigDecimal grossAmt = getAmount(Doc.AMTTYPE_Gross);
|
||||
|
||||
// Commitment
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
if (as.isCreatePOCommitment())
|
||||
{
|
||||
Fact fact = new Fact(this, as, Fact.POST_Commitment);
|
||||
updateProductPO(as);
|
||||
|
||||
//BigDecimal grossAmt = getAmount(Doc.AMTTYPE_Gross);
|
||||
|
||||
// Commitment
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
if (as.isCreatePOCommitment())
|
||||
{
|
||||
Fact fact = new Fact(this, as, Fact.POST_Commitment);
|
||||
BigDecimal total = Env.ZERO;
|
||||
for (int i = 0; i < p_lines.length; i++)
|
||||
{
|
||||
DocLine line = p_lines[i];
|
||||
BigDecimal cost = line.getAmtSource();
|
||||
total = total.add(cost);
|
||||
|
||||
// Account
|
||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||
fl = fact.createLine (line, expense,
|
||||
getC_Currency_ID(), cost, null);
|
||||
}
|
||||
// Offset
|
||||
|
||||
// Account
|
||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||
fl = fact.createLine (line, expense,
|
||||
getC_Currency_ID(), cost, null);
|
||||
}
|
||||
// Offset
|
||||
MAccount offset = getAccount(ACCTTYPE_CommitmentOffset, as);
|
||||
if (offset == null)
|
||||
{
|
||||
|
@ -389,15 +389,15 @@ public class Doc_Order extends Doc
|
|||
DocLine line = m_requisitions[i];
|
||||
BigDecimal cost = line.getAmtSource();
|
||||
total = total.add(cost);
|
||||
|
||||
// Account
|
||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||
fl = fact.createLine (line, expense,
|
||||
getC_Currency_ID(), null, cost);
|
||||
}
|
||||
// Offset
|
||||
if (m_requisitions.length > 0)
|
||||
{
|
||||
|
||||
// Account
|
||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||
fl = fact.createLine (line, expense,
|
||||
getC_Currency_ID(), null, cost);
|
||||
}
|
||||
// Offset
|
||||
if (m_requisitions.length > 0)
|
||||
{
|
||||
MAccount offset = getAccount(ACCTTYPE_CommitmentOffset, as);
|
||||
if (offset == null)
|
||||
{
|
||||
|
@ -407,47 +407,47 @@ public class Doc_Order extends Doc
|
|||
}
|
||||
fact.createLine (null, offset,
|
||||
getC_Currency_ID(), total, null);
|
||||
}
|
||||
}
|
||||
//
|
||||
facts.add(fact);
|
||||
} // reservations
|
||||
}
|
||||
// SO
|
||||
else if (getDocumentType().equals(DOCTYPE_SOrder))
|
||||
{
|
||||
// Commitment
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
if (as.isCreateSOCommitment())
|
||||
{
|
||||
Fact fact = new Fact(this, as, Fact.POST_Commitment);
|
||||
BigDecimal total = Env.ZERO;
|
||||
for (int i = 0; i < p_lines.length; i++)
|
||||
{
|
||||
DocLine line = p_lines[i];
|
||||
BigDecimal cost = line.getAmtSource();
|
||||
total = total.add(cost);
|
||||
|
||||
// Account
|
||||
MAccount revenue = line.getAccount(ProductCost.ACCTTYPE_P_Revenue, as);
|
||||
fl = fact.createLine (line, revenue,
|
||||
getC_Currency_ID(), null, cost);
|
||||
}
|
||||
// Offset
|
||||
MAccount offset = getAccount(ACCTTYPE_CommitmentOffsetSales, as);
|
||||
if (offset == null)
|
||||
{
|
||||
p_Error = "@NotFound@ @CommitmentOffsetSales_Acct@";
|
||||
log.log(Level.SEVERE, p_Error);
|
||||
return null;
|
||||
}
|
||||
fact.createLine (null, offset,
|
||||
getC_Currency_ID(), total, null);
|
||||
//
|
||||
facts.add(fact);
|
||||
}
|
||||
|
||||
}
|
||||
else if (getDocumentType().equals(DOCTYPE_SOrder))
|
||||
{
|
||||
// Commitment
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
if (as.isCreateSOCommitment())
|
||||
{
|
||||
Fact fact = new Fact(this, as, Fact.POST_Commitment);
|
||||
BigDecimal total = Env.ZERO;
|
||||
for (int i = 0; i < p_lines.length; i++)
|
||||
{
|
||||
DocLine line = p_lines[i];
|
||||
BigDecimal cost = line.getAmtSource();
|
||||
total = total.add(cost);
|
||||
|
||||
// Account
|
||||
MAccount revenue = line.getAccount(ProductCost.ACCTTYPE_P_Revenue, as);
|
||||
fl = fact.createLine (line, revenue,
|
||||
getC_Currency_ID(), null, cost);
|
||||
}
|
||||
// Offset
|
||||
MAccount offset = getAccount(ACCTTYPE_CommitmentOffsetSales, as);
|
||||
if (offset == null)
|
||||
{
|
||||
p_Error = "@NotFound@ @CommitmentOffsetSales_Acct@";
|
||||
log.log(Level.SEVERE, p_Error);
|
||||
return null;
|
||||
}
|
||||
fact.createLine (null, offset,
|
||||
getC_Currency_ID(), total, null);
|
||||
//
|
||||
facts.add(fact);
|
||||
}
|
||||
|
||||
}
|
||||
return facts;
|
||||
} // createFact
|
||||
|
||||
|
@ -462,31 +462,31 @@ public class Doc_Order extends Doc
|
|||
if (ci.getC_AcctSchema1_ID() != as.getC_AcctSchema_ID())
|
||||
return;
|
||||
|
||||
StringBuilder sql = new StringBuilder (
|
||||
"UPDATE M_Product_PO po ")
|
||||
.append("SET PriceLastPO = (SELECT currencyConvert(ol.PriceActual,ol.C_Currency_ID,po.C_Currency_ID,o.DateOrdered,o.C_ConversionType_ID,o.AD_Client_ID,o.AD_Org_ID) ")
|
||||
.append("FROM C_Order o, C_OrderLine ol ")
|
||||
.append("WHERE o.C_Order_ID=ol.C_Order_ID")
|
||||
.append(" AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID ");
|
||||
//jz + " AND ROWNUM=1 AND o.C_Order_ID=").append(get_ID()).append(") ")
|
||||
if (DB.isOracle()) //jz
|
||||
{
|
||||
sql.append(" AND ROWNUM=1 ");
|
||||
}
|
||||
else
|
||||
sql.append(" AND ol.C_OrderLine_ID = (SELECT MIN(ol1.C_OrderLine_ID) ")
|
||||
.append("FROM C_Order o1, C_OrderLine ol1 ")
|
||||
.append("WHERE o1.C_Order_ID=ol1.C_Order_ID")
|
||||
.append(" AND po.M_Product_ID=ol1.M_Product_ID AND po.C_BPartner_ID=o1.C_BPartner_ID")
|
||||
.append(" AND o1.C_Order_ID=").append(get_ID()).append(") ");
|
||||
sql.append(" AND o.C_Order_ID=").append(get_ID()).append(") ")
|
||||
.append("WHERE EXISTS (SELECT * ")
|
||||
.append("FROM C_Order o, C_OrderLine ol ")
|
||||
.append("WHERE o.C_Order_ID=ol.C_Order_ID")
|
||||
.append(" AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID")
|
||||
.append(" AND o.C_Order_ID=").append(get_ID()).append(")");
|
||||
StringBuilder sql = new StringBuilder (
|
||||
"UPDATE M_Product_PO po ")
|
||||
.append("SET PriceLastPO = (SELECT currencyConvert(ol.PriceActual,ol.C_Currency_ID,po.C_Currency_ID,o.DateOrdered,o.C_ConversionType_ID,o.AD_Client_ID,o.AD_Org_ID) ")
|
||||
.append("FROM C_Order o, C_OrderLine ol ")
|
||||
.append("WHERE o.C_Order_ID=ol.C_Order_ID")
|
||||
.append(" AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID ");
|
||||
//jz + " AND ROWNUM=1 AND o.C_Order_ID=").append(get_ID()).append(") ")
|
||||
if (DB.isOracle()) //jz
|
||||
{
|
||||
sql.append(" AND ROWNUM=1 ");
|
||||
}
|
||||
else
|
||||
sql.append(" AND ol.C_OrderLine_ID = (SELECT MIN(ol1.C_OrderLine_ID) ")
|
||||
.append("FROM C_Order o1, C_OrderLine ol1 ")
|
||||
.append("WHERE o1.C_Order_ID=ol1.C_Order_ID")
|
||||
.append(" AND po.M_Product_ID=ol1.M_Product_ID AND po.C_BPartner_ID=o1.C_BPartner_ID")
|
||||
.append(" AND o1.C_Order_ID=").append(get_ID()).append(") ");
|
||||
sql.append(" AND o.C_Order_ID=").append(get_ID()).append(") ")
|
||||
.append("WHERE EXISTS (SELECT * ")
|
||||
.append("FROM C_Order o, C_OrderLine ol ")
|
||||
.append("WHERE o.C_Order_ID=ol.C_Order_ID")
|
||||
.append(" AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID")
|
||||
.append(" AND o.C_Order_ID=").append(get_ID()).append(")");
|
||||
int no = DB.executeUpdate(sql.toString(), getTrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Updated=" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Updated=" + no);
|
||||
} // updateProductPO
|
||||
|
||||
|
||||
|
@ -502,20 +502,20 @@ public class Doc_Order extends Doc
|
|||
int precision = -1;
|
||||
//
|
||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM C_OrderLine ol ")
|
||||
.append("WHERE EXISTS ")
|
||||
.append("(SELECT * FROM C_InvoiceLine il ")
|
||||
.append("WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||
.append(" AND il.C_InvoiceLine_ID=?)")
|
||||
.append(" OR EXISTS ")
|
||||
.append("(SELECT * FROM M_MatchPO po ")
|
||||
.append("WHERE po.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||
.append(" AND po.C_InvoiceLine_ID=?)");
|
||||
PreparedStatement pstmt = null;
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM C_OrderLine ol ")
|
||||
.append("WHERE EXISTS ")
|
||||
.append("(SELECT * FROM C_InvoiceLine il ")
|
||||
.append("WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||
.append(" AND il.C_InvoiceLine_ID=?)")
|
||||
.append(" OR EXISTS ")
|
||||
.append("(SELECT * FROM M_MatchPO po ")
|
||||
.append("WHERE po.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||
.append(" AND po.C_InvoiceLine_ID=?)");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||
pstmt.setInt (1, C_InvoiceLine_ID);
|
||||
pstmt.setInt (2, C_InvoiceLine_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
|
@ -556,7 +556,7 @@ public class Doc_Order extends Doc
|
|||
if (!tax.isZeroTax())
|
||||
{
|
||||
BigDecimal LineNetAmtTax = tax.calculateTax(LineNetAmt, true, precision);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("LineNetAmt=" + LineNetAmt + " - Tax=" + LineNetAmtTax);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("LineNetAmt=" + LineNetAmt + " - Tax=" + LineNetAmtTax);
|
||||
LineNetAmt = LineNetAmt.subtract(LineNetAmtTax);
|
||||
BigDecimal PriceListTax = tax.calculateTax(PriceList, true, precision);
|
||||
PriceList = PriceList.subtract(PriceListTax);
|
||||
|
@ -569,12 +569,12 @@ public class Doc_Order extends Doc
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql.toString(), e);
|
||||
s_log.log (Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
// Return Array
|
||||
|
@ -598,14 +598,14 @@ public class Doc_Order extends Doc
|
|||
{
|
||||
Fact fact = new Fact(doc, as, Fact.POST_Commitment);
|
||||
DocLine[] commitments = Doc_Order.getCommitments(doc, Qty,
|
||||
C_InvoiceLine_ID);
|
||||
|
||||
BigDecimal total = Env.ZERO;
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
int C_Currency_ID = -1;
|
||||
for (int i = 0; i < commitments.length; i++)
|
||||
{
|
||||
C_InvoiceLine_ID);
|
||||
|
||||
BigDecimal total = Env.ZERO;
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
int C_Currency_ID = -1;
|
||||
for (int i = 0; i < commitments.length; i++)
|
||||
{
|
||||
DocLine line = commitments[i];
|
||||
if (C_Currency_ID == -1)
|
||||
C_Currency_ID = line.getC_Currency_ID();
|
||||
|
@ -617,13 +617,13 @@ public class Doc_Order extends Doc
|
|||
}
|
||||
BigDecimal cost = line.getAmtSource().multiply(multiplier);
|
||||
total = total.add(cost);
|
||||
|
||||
// Account
|
||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||
fl = fact.createLine (line, expense,
|
||||
C_Currency_ID, null, cost);
|
||||
}
|
||||
// Offset
|
||||
|
||||
// Account
|
||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||
fl = fact.createLine (line, expense,
|
||||
C_Currency_ID, null, cost);
|
||||
}
|
||||
// Offset
|
||||
MAccount offset = doc.getAccount(ACCTTYPE_CommitmentOffset, as);
|
||||
if (offset == null)
|
||||
{
|
||||
|
@ -636,144 +636,144 @@ public class Doc_Order extends Doc
|
|||
return fact;
|
||||
} // getCommitmentRelease
|
||||
|
||||
/**
|
||||
* Get Commitments Sales
|
||||
* @param doc document
|
||||
* @param maxQty Qty invoiced/matched
|
||||
* @param C_OrderLine_ID invoice line
|
||||
* @return commitments (order lines)
|
||||
*/
|
||||
protected static DocLine[] getCommitmentsSales(Doc doc, BigDecimal maxQty, int M_InOutLine_ID)
|
||||
{
|
||||
int precision = -1;
|
||||
//
|
||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM C_OrderLine ol ")
|
||||
.append("WHERE EXISTS ")
|
||||
.append("(SELECT * FROM M_InOutLine il ")
|
||||
.append("WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||
.append(" AND il.M_InOutLine_ID=?)");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||
pstmt.setInt (1, M_InOutLine_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
if (maxQty.signum() == 0)
|
||||
continue;
|
||||
MOrderLine line = new MOrderLine (doc.getCtx(), rs, null);
|
||||
DocLine docLine = new DocLine (line, doc);
|
||||
// Currency
|
||||
if (precision == -1)
|
||||
{
|
||||
doc.setC_Currency_ID(docLine.getC_Currency_ID());
|
||||
precision = MCurrency.getStdPrecision(doc.getCtx(), docLine.getC_Currency_ID());
|
||||
}
|
||||
// Qty
|
||||
BigDecimal Qty = line.getQtyOrdered().max(maxQty);
|
||||
docLine.setQty(Qty, false);
|
||||
//
|
||||
BigDecimal PriceActual = line.getPriceActual();
|
||||
BigDecimal PriceCost = line.getPriceCost();
|
||||
BigDecimal LineNetAmt = null;
|
||||
if (PriceCost != null && PriceCost.signum() != 0)
|
||||
LineNetAmt = Qty.multiply(PriceCost);
|
||||
else if (Qty.equals(maxQty))
|
||||
LineNetAmt = line.getLineNetAmt();
|
||||
else
|
||||
LineNetAmt = Qty.multiply(PriceActual);
|
||||
maxQty = maxQty.subtract(Qty);
|
||||
|
||||
docLine.setAmount (LineNetAmt); // DR
|
||||
BigDecimal PriceList = line.getPriceList();
|
||||
int C_Tax_ID = docLine.getC_Tax_ID();
|
||||
// Correct included Tax
|
||||
if (C_Tax_ID != 0 && line.getParent().isTaxIncluded())
|
||||
{
|
||||
MTax tax = MTax.get(doc.getCtx(), C_Tax_ID);
|
||||
if (!tax.isZeroTax())
|
||||
{
|
||||
BigDecimal LineNetAmtTax = tax.calculateTax(LineNetAmt, true, precision);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("LineNetAmt=" + LineNetAmt + " - Tax=" + LineNetAmtTax);
|
||||
LineNetAmt = LineNetAmt.subtract(LineNetAmtTax);
|
||||
BigDecimal PriceListTax = tax.calculateTax(PriceList, true, precision);
|
||||
PriceList = PriceList.subtract(PriceListTax);
|
||||
}
|
||||
} // correct included Tax
|
||||
|
||||
docLine.setAmount (LineNetAmt, PriceList, Qty);
|
||||
list.add(docLine);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
// Return Array
|
||||
DocLine[] dl = new DocLine[list.size()];
|
||||
list.toArray(dl);
|
||||
return dl;
|
||||
} // getCommitmentsSales
|
||||
|
||||
/**
|
||||
* Get Commitment Sales Release.
|
||||
* Called from InOut
|
||||
* @param as accounting schema
|
||||
* @param doc doc
|
||||
* @param Qty qty invoiced/matched
|
||||
* @param C_OrderLine_ID line
|
||||
* @param multiplier 1 for accrual
|
||||
* @return Fact
|
||||
*/
|
||||
public static Fact getCommitmentSalesRelease(MAcctSchema as, Doc doc,
|
||||
BigDecimal Qty, int M_InOutLine_ID, BigDecimal multiplier)
|
||||
{
|
||||
Fact fact = new Fact(doc, as, Fact.POST_Commitment);
|
||||
DocLine[] commitments = Doc_Order.getCommitmentsSales(doc, Qty,
|
||||
M_InOutLine_ID);
|
||||
|
||||
BigDecimal total = Env.ZERO;
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
int C_Currency_ID = -1;
|
||||
for (int i = 0; i < commitments.length; i++)
|
||||
{
|
||||
DocLine line = commitments[i];
|
||||
if (C_Currency_ID == -1)
|
||||
C_Currency_ID = line.getC_Currency_ID();
|
||||
else if (C_Currency_ID != line.getC_Currency_ID())
|
||||
{
|
||||
doc.p_Error = "Different Currencies of Order Lines";
|
||||
s_log.log(Level.SEVERE, doc.p_Error);
|
||||
return null;
|
||||
}
|
||||
BigDecimal cost = line.getAmtSource().multiply(multiplier);
|
||||
total = total.add(cost);
|
||||
|
||||
// Account
|
||||
MAccount revenue = line.getAccount(ProductCost.ACCTTYPE_P_Revenue, as);
|
||||
fl = fact.createLine (line, revenue,
|
||||
C_Currency_ID, cost, null);
|
||||
}
|
||||
// Offset
|
||||
MAccount offset = doc.getAccount(ACCTTYPE_CommitmentOffsetSales, as);
|
||||
if (offset == null)
|
||||
{
|
||||
doc.p_Error = "@NotFound@ @CommitmentOffsetSales_Acct@";
|
||||
s_log.log(Level.SEVERE, doc.p_Error);
|
||||
return null;
|
||||
}
|
||||
fact.createLine (null, offset,
|
||||
C_Currency_ID, null, total);
|
||||
return fact;
|
||||
/**
|
||||
* Get Commitments Sales
|
||||
* @param doc document
|
||||
* @param maxQty Qty invoiced/matched
|
||||
* @param C_OrderLine_ID invoice line
|
||||
* @return commitments (order lines)
|
||||
*/
|
||||
protected static DocLine[] getCommitmentsSales(Doc doc, BigDecimal maxQty, int M_InOutLine_ID)
|
||||
{
|
||||
int precision = -1;
|
||||
//
|
||||
ArrayList<DocLine> list = new ArrayList<DocLine>();
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM C_OrderLine ol ")
|
||||
.append("WHERE EXISTS ")
|
||||
.append("(SELECT * FROM M_InOutLine il ")
|
||||
.append("WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID")
|
||||
.append(" AND il.M_InOutLine_ID=?)");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql.toString(), null);
|
||||
pstmt.setInt (1, M_InOutLine_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
if (maxQty.signum() == 0)
|
||||
continue;
|
||||
MOrderLine line = new MOrderLine (doc.getCtx(), rs, null);
|
||||
DocLine docLine = new DocLine (line, doc);
|
||||
// Currency
|
||||
if (precision == -1)
|
||||
{
|
||||
doc.setC_Currency_ID(docLine.getC_Currency_ID());
|
||||
precision = MCurrency.getStdPrecision(doc.getCtx(), docLine.getC_Currency_ID());
|
||||
}
|
||||
// Qty
|
||||
BigDecimal Qty = line.getQtyOrdered().max(maxQty);
|
||||
docLine.setQty(Qty, false);
|
||||
//
|
||||
BigDecimal PriceActual = line.getPriceActual();
|
||||
BigDecimal PriceCost = line.getPriceCost();
|
||||
BigDecimal LineNetAmt = null;
|
||||
if (PriceCost != null && PriceCost.signum() != 0)
|
||||
LineNetAmt = Qty.multiply(PriceCost);
|
||||
else if (Qty.equals(maxQty))
|
||||
LineNetAmt = line.getLineNetAmt();
|
||||
else
|
||||
LineNetAmt = Qty.multiply(PriceActual);
|
||||
maxQty = maxQty.subtract(Qty);
|
||||
|
||||
docLine.setAmount (LineNetAmt); // DR
|
||||
BigDecimal PriceList = line.getPriceList();
|
||||
int C_Tax_ID = docLine.getC_Tax_ID();
|
||||
// Correct included Tax
|
||||
if (C_Tax_ID != 0 && line.getParent().isTaxIncluded())
|
||||
{
|
||||
MTax tax = MTax.get(doc.getCtx(), C_Tax_ID);
|
||||
if (!tax.isZeroTax())
|
||||
{
|
||||
BigDecimal LineNetAmtTax = tax.calculateTax(LineNetAmt, true, precision);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("LineNetAmt=" + LineNetAmt + " - Tax=" + LineNetAmtTax);
|
||||
LineNetAmt = LineNetAmt.subtract(LineNetAmtTax);
|
||||
BigDecimal PriceListTax = tax.calculateTax(PriceList, true, precision);
|
||||
PriceList = PriceList.subtract(PriceListTax);
|
||||
}
|
||||
} // correct included Tax
|
||||
|
||||
docLine.setAmount (LineNetAmt, PriceList, Qty);
|
||||
list.add(docLine);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
// Return Array
|
||||
DocLine[] dl = new DocLine[list.size()];
|
||||
list.toArray(dl);
|
||||
return dl;
|
||||
} // getCommitmentsSales
|
||||
|
||||
/**
|
||||
* Get Commitment Sales Release.
|
||||
* Called from InOut
|
||||
* @param as accounting schema
|
||||
* @param doc doc
|
||||
* @param Qty qty invoiced/matched
|
||||
* @param C_OrderLine_ID line
|
||||
* @param multiplier 1 for accrual
|
||||
* @return Fact
|
||||
*/
|
||||
public static Fact getCommitmentSalesRelease(MAcctSchema as, Doc doc,
|
||||
BigDecimal Qty, int M_InOutLine_ID, BigDecimal multiplier)
|
||||
{
|
||||
Fact fact = new Fact(doc, as, Fact.POST_Commitment);
|
||||
DocLine[] commitments = Doc_Order.getCommitmentsSales(doc, Qty,
|
||||
M_InOutLine_ID);
|
||||
|
||||
BigDecimal total = Env.ZERO;
|
||||
@SuppressWarnings("unused")
|
||||
FactLine fl = null;
|
||||
int C_Currency_ID = -1;
|
||||
for (int i = 0; i < commitments.length; i++)
|
||||
{
|
||||
DocLine line = commitments[i];
|
||||
if (C_Currency_ID == -1)
|
||||
C_Currency_ID = line.getC_Currency_ID();
|
||||
else if (C_Currency_ID != line.getC_Currency_ID())
|
||||
{
|
||||
doc.p_Error = "Different Currencies of Order Lines";
|
||||
s_log.log(Level.SEVERE, doc.p_Error);
|
||||
return null;
|
||||
}
|
||||
BigDecimal cost = line.getAmtSource().multiply(multiplier);
|
||||
total = total.add(cost);
|
||||
|
||||
// Account
|
||||
MAccount revenue = line.getAccount(ProductCost.ACCTTYPE_P_Revenue, as);
|
||||
fl = fact.createLine (line, revenue,
|
||||
C_Currency_ID, cost, null);
|
||||
}
|
||||
// Offset
|
||||
MAccount offset = doc.getAccount(ACCTTYPE_CommitmentOffsetSales, as);
|
||||
if (offset == null)
|
||||
{
|
||||
doc.p_Error = "@NotFound@ @CommitmentOffsetSales_Acct@";
|
||||
s_log.log(Level.SEVERE, doc.p_Error);
|
||||
return null;
|
||||
}
|
||||
fact.createLine (null, offset,
|
||||
C_Currency_ID, null, total);
|
||||
return fact;
|
||||
} // getCommitmentSalesRelease
|
||||
} // Doc_Order
|
|
@ -1,65 +1,65 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.db;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* Connection Resource Strings
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: DBRes.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
|
||||
*/
|
||||
public class DBRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** Data */
|
||||
static final Object[][] contents = new String[][]{
|
||||
{ "CConnectionDialog", "Adempiere szerver kapcsolat" },
|
||||
{ "Name", "Név" },
|
||||
{ "AppsHost", "Alkalmazás szerver" },
|
||||
{ "AppsPort", "Alkalmazás port" },
|
||||
{ "TestApps", "Teszt alkalmazás szerver" },
|
||||
{ "DBHost", "Adatbázis szerver" },
|
||||
{ "DBPort", "Adatbázis port" },
|
||||
{ "DBName", "Adatbázis név" },
|
||||
{ "DBUidPwd", "Felhasználó / Jelszó" },
|
||||
{ "ViaFirewall", "Firewallon keresztül" },
|
||||
{ "FWHost", "Firewall cím" },
|
||||
{ "FWPort", "Firewall port" },
|
||||
{ "TestConnection", "Test Adatbázis" },
|
||||
{ "Type", "Adatbázis típus" },
|
||||
{ "BequeathConnection", "Kapcsolat hagyományozása" },
|
||||
{ "Overwrite", "Felülír" },
|
||||
{ "ConnectionProfile", "Kapcsolat profil" },
|
||||
{ "LAN", "LAN" },
|
||||
{ "TerminalServer", "Terminál szerver" },
|
||||
{ "VPN", "VPN" },
|
||||
{ "WAN", "WAN" },
|
||||
{ "ConnectionError", "Kapcsolat hiba" },
|
||||
{ "ServerNotActive", "Szerver nem aktív" }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Contsnts
|
||||
* @return contents
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
} // getContent
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.db;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* Connection Resource Strings
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: DBRes.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
|
||||
*/
|
||||
public class DBRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** Data */
|
||||
static final Object[][] contents = new String[][]{
|
||||
{ "CConnectionDialog", "Adempiere szerver kapcsolat" },
|
||||
{ "Name", "Név" },
|
||||
{ "AppsHost", "Alkalmazás szerver" },
|
||||
{ "AppsPort", "Alkalmazás port" },
|
||||
{ "TestApps", "Teszt alkalmazás szerver" },
|
||||
{ "DBHost", "Adatbázis szerver" },
|
||||
{ "DBPort", "Adatbázis port" },
|
||||
{ "DBName", "Adatbázis név" },
|
||||
{ "DBUidPwd", "Felhasználó / Jelszó" },
|
||||
{ "ViaFirewall", "Firewallon keresztül" },
|
||||
{ "FWHost", "Firewall cím" },
|
||||
{ "FWPort", "Firewall port" },
|
||||
{ "TestConnection", "Test Adatbázis" },
|
||||
{ "Type", "Adatbázis típus" },
|
||||
{ "BequeathConnection", "Kapcsolat hagyományozása" },
|
||||
{ "Overwrite", "Felülír" },
|
||||
{ "ConnectionProfile", "Kapcsolat profil" },
|
||||
{ "LAN", "LAN" },
|
||||
{ "TerminalServer", "Terminál szerver" },
|
||||
{ "VPN", "VPN" },
|
||||
{ "WAN", "WAN" },
|
||||
{ "ConnectionError", "Kapcsolat hiba" },
|
||||
{ "ServerNotActive", "Szerver nem aktív" }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Contsnts
|
||||
* @return contents
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
} // getContent
|
||||
} // Res
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,134 +1,134 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* Accounting Schema GL info
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MAcctSchemaGL.java,v 1.3 2006/07/30 00:58:18 jjanke Exp $
|
||||
* @author victor.perez@e-evolution.com, www.e-evolution.com
|
||||
* <li>RF [ 2214883 ] Remove SQL code and Replace for Query http://sourceforge.net/tracker/index.php?func=detail&aid=2214883&group_id=176962&atid=879335
|
||||
*/
|
||||
public class MAcctSchemaGL extends X_C_AcctSchema_GL
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5303102649110271896L;
|
||||
|
||||
|
||||
/**
|
||||
* Get Accounting Schema GL Info
|
||||
* @param ctx context
|
||||
* @param C_AcctSchema_ID id
|
||||
* @return defaults
|
||||
*/
|
||||
public static MAcctSchemaGL get (Properties ctx, int C_AcctSchema_ID)
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Accounting Schema GL info
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MAcctSchemaGL.java,v 1.3 2006/07/30 00:58:18 jjanke Exp $
|
||||
* @author victor.perez@e-evolution.com, www.e-evolution.com
|
||||
* <li>RF [ 2214883 ] Remove SQL code and Replace for Query http://sourceforge.net/tracker/index.php?func=detail&aid=2214883&group_id=176962&atid=879335
|
||||
*/
|
||||
public class MAcctSchemaGL extends X_C_AcctSchema_GL
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5303102649110271896L;
|
||||
|
||||
|
||||
/**
|
||||
* Get Accounting Schema GL Info
|
||||
* @param ctx context
|
||||
* @param C_AcctSchema_ID id
|
||||
* @return defaults
|
||||
*/
|
||||
public static MAcctSchemaGL get (Properties ctx, int C_AcctSchema_ID)
|
||||
{
|
||||
final String whereClause = "C_AcctSchema_ID=?";
|
||||
return new Query(ctx,I_C_AcctSchema_GL.Table_Name,whereClause,null)
|
||||
.setParameters(C_AcctSchema_ID)
|
||||
final String whereClause = "C_AcctSchema_ID=?";
|
||||
return new Query(ctx,I_C_AcctSchema_GL.Table_Name,whereClause,null)
|
||||
.setParameters(C_AcctSchema_ID)
|
||||
.firstOnly();
|
||||
} // get
|
||||
|
||||
/** Logger */
|
||||
protected static CLogger s_log = CLogger.getCLogger(MAcctSchemaGL.class);
|
||||
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param C_AcctSchema_ID AcctSchema
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MAcctSchemaGL (Properties ctx, int C_AcctSchema_ID, String trxName)
|
||||
{
|
||||
super(ctx, C_AcctSchema_ID, trxName);
|
||||
if (C_AcctSchema_ID == 0)
|
||||
{
|
||||
setUseCurrencyBalancing (false);
|
||||
setUseSuspenseBalancing (false);
|
||||
setUseSuspenseError (false);
|
||||
}
|
||||
} // MAcctSchemaGL
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MAcctSchemaGL (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // MAcctSchemaGL
|
||||
|
||||
/**
|
||||
* Get Acct Info list
|
||||
* @return list
|
||||
*/
|
||||
public ArrayList<KeyNamePair> getAcctInfo()
|
||||
{
|
||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||
for (int i = 0; i < get_ColumnCount(); i++)
|
||||
{
|
||||
String columnName = get_ColumnName(i);
|
||||
if (columnName.endsWith("Acct"))
|
||||
{
|
||||
int id = ((Integer)get_Value(i));
|
||||
list.add(new KeyNamePair (id, columnName));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
} // getAcctInfo
|
||||
|
||||
/**
|
||||
* Set Value (don't use)
|
||||
* @param columnName column name
|
||||
* @param value value
|
||||
* @return true if set
|
||||
*/
|
||||
public boolean setValue (String columnName, Integer value)
|
||||
{
|
||||
return super.set_Value (columnName, value);
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
{
|
||||
if (getAD_Org_ID() != 0)
|
||||
setAD_Org_ID(0);
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
} // MAcctSchemaGL
|
||||
} // get
|
||||
|
||||
/** Logger */
|
||||
protected static CLogger s_log = CLogger.getCLogger(MAcctSchemaGL.class);
|
||||
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param C_AcctSchema_ID AcctSchema
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MAcctSchemaGL (Properties ctx, int C_AcctSchema_ID, String trxName)
|
||||
{
|
||||
super(ctx, C_AcctSchema_ID, trxName);
|
||||
if (C_AcctSchema_ID == 0)
|
||||
{
|
||||
setUseCurrencyBalancing (false);
|
||||
setUseSuspenseBalancing (false);
|
||||
setUseSuspenseError (false);
|
||||
}
|
||||
} // MAcctSchemaGL
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MAcctSchemaGL (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // MAcctSchemaGL
|
||||
|
||||
/**
|
||||
* Get Acct Info list
|
||||
* @return list
|
||||
*/
|
||||
public ArrayList<KeyNamePair> getAcctInfo()
|
||||
{
|
||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||
for (int i = 0; i < get_ColumnCount(); i++)
|
||||
{
|
||||
String columnName = get_ColumnName(i);
|
||||
if (columnName.endsWith("Acct"))
|
||||
{
|
||||
int id = ((Integer)get_Value(i));
|
||||
list.add(new KeyNamePair (id, columnName));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
} // getAcctInfo
|
||||
|
||||
/**
|
||||
* Set Value (don't use)
|
||||
* @param columnName column name
|
||||
* @param value value
|
||||
* @return true if set
|
||||
*/
|
||||
public boolean setValue (String columnName, Integer value)
|
||||
{
|
||||
return super.set_Value (columnName, value);
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
{
|
||||
if (getAD_Org_ID() != 0)
|
||||
setAD_Org_ID(0);
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
} // MAcctSchemaGL
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,150 +1,150 @@
|
|||
/******************************************************************************
|
||||
* The contents of this file are subject to the Compiere License Version 1.1
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* You may obtain a copy of the License at http://www.compiere.org/license.html
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
* The Original Code is Compiere ERP & CRM Smart Business Solution
|
||||
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
|
||||
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
|
||||
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MRefList;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
/**
|
||||
* Asset Addition Model
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
*
|
||||
*/
|
||||
public class MAssetChange extends X_A_Asset_Change
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4083373951793617528L;
|
||||
|
||||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger(MAssetChange.class);
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param ctx context
|
||||
* @param M_InventoryLine_ID line
|
||||
*/
|
||||
public MAssetChange (Properties ctx, int A_Asset_Change_ID, String trxName)
|
||||
{
|
||||
super (ctx, A_Asset_Change_ID, trxName);
|
||||
} // MAssetChange
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
*/
|
||||
public MAssetChange (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // MInventoryLine
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
{
|
||||
String textDetails = getTextDetails();
|
||||
if (textDetails == null || textDetails.length() == 0) {
|
||||
setTextDetails(MRefList.getListDescription (getCtx(),"A_Update_Type" , getChangeType()));
|
||||
}
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
public static MAssetChange createAddition(MAssetAddition assetAdd, MDepreciationWorkfile assetwk) {
|
||||
MAssetChange change = new MAssetChange (assetAdd.getCtx(), 0, assetAdd.get_TrxName());
|
||||
change.setAD_Org_ID(assetAdd.getAD_Org_ID()); //@win added
|
||||
change.setA_Asset_ID(assetAdd.getA_Asset_ID());
|
||||
change.setA_QTY_Current(assetAdd.getA_QTY_Current());
|
||||
change.setChangeType("ADD");
|
||||
change.setTextDetails(MRefList.getListDescription (assetAdd.getCtx(),"A_Update_Type" , "ADD"));
|
||||
change.setPostingType(assetwk.getPostingType());
|
||||
change.setAssetValueAmt(assetAdd.getAssetValueAmt());
|
||||
change.setA_QTY_Current(assetAdd.getA_QTY_Current());
|
||||
change.saveEx();
|
||||
|
||||
return change;
|
||||
}
|
||||
|
||||
public static MAssetChange create(Properties ctx, String changeType, PO[] pos, String trxName) {
|
||||
return create(ctx, changeType, pos, false, trxName);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param ctx
|
||||
* @param changeType
|
||||
* @param pos
|
||||
* @param trxName
|
||||
* @return
|
||||
*/
|
||||
public static MAssetChange createAndSave(Properties ctx, String changeType, PO[] pos, String trxName) {
|
||||
return null;
|
||||
//~ return create(ctx, changeType, pos, true, trxName);
|
||||
}
|
||||
|
||||
public static MAssetChange create(Properties ctx, String changeType, PO[] pos, boolean save, String trxName) {
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("Entering: changeType=" + changeType);
|
||||
if (pos == null || pos.length == 0) {
|
||||
s_log.fine("Entering/Leaving: POs is empty");
|
||||
return null;
|
||||
}
|
||||
MAssetChange change = new MAssetChange (ctx, 0, trxName);
|
||||
change.setChangeType(changeType);
|
||||
for (PO po : pos) {
|
||||
change.addChanges(po);
|
||||
}
|
||||
if (save) {
|
||||
change.saveEx();
|
||||
}
|
||||
//
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("Leaving: change=" + change);
|
||||
return change;
|
||||
}
|
||||
|
||||
public void addChanges(PO po) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Entering: po=" + po);
|
||||
if (po == null) {
|
||||
return;
|
||||
}
|
||||
/* arhipac: teo_sarca: TODO need to integrate
|
||||
for(int idx = 0; idx < po.get_ColumnCount_P(); idx++) {
|
||||
//~ if(!po.is_ValueChanged(idx)) {
|
||||
//~ continue;
|
||||
//~ }
|
||||
String colName = po.get_ColumnName_P(idx);
|
||||
int idx2 = get_ColumnIndex(colName);
|
||||
if(idx2 < 0) {
|
||||
if(CLogMgt.isLevelFine()) log.fine("Setting " + colName + ": SKIP (idx2 < 0)");
|
||||
continue;
|
||||
}
|
||||
|
||||
Object value = po.get_Value(idx2);
|
||||
set_Value(colName, value);
|
||||
if(CLogMgt.isLevelFine()) log.fine("Setting " + colName + "=" + value + " (from " + po.getClass() + ", idx=" + idx + ", idx2=" + idx2 + ")");
|
||||
}
|
||||
*/
|
||||
//
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Leaving: po=" + po);
|
||||
}
|
||||
/******************************************************************************
|
||||
* The contents of this file are subject to the Compiere License Version 1.1
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* You may obtain a copy of the License at http://www.compiere.org/license.html
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
* The Original Code is Compiere ERP & CRM Smart Business Solution
|
||||
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
|
||||
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
|
||||
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MRefList;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
/**
|
||||
* Asset Addition Model
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
*
|
||||
*/
|
||||
public class MAssetChange extends X_A_Asset_Change
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4083373951793617528L;
|
||||
|
||||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger(MAssetChange.class);
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param ctx context
|
||||
* @param M_InventoryLine_ID line
|
||||
*/
|
||||
public MAssetChange (Properties ctx, int A_Asset_Change_ID, String trxName)
|
||||
{
|
||||
super (ctx, A_Asset_Change_ID, trxName);
|
||||
} // MAssetChange
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
*/
|
||||
public MAssetChange (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // MInventoryLine
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
{
|
||||
String textDetails = getTextDetails();
|
||||
if (textDetails == null || textDetails.length() == 0) {
|
||||
setTextDetails(MRefList.getListDescription (getCtx(),"A_Update_Type" , getChangeType()));
|
||||
}
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
public static MAssetChange createAddition(MAssetAddition assetAdd, MDepreciationWorkfile assetwk) {
|
||||
MAssetChange change = new MAssetChange (assetAdd.getCtx(), 0, assetAdd.get_TrxName());
|
||||
change.setAD_Org_ID(assetAdd.getAD_Org_ID()); //@win added
|
||||
change.setA_Asset_ID(assetAdd.getA_Asset_ID());
|
||||
change.setA_QTY_Current(assetAdd.getA_QTY_Current());
|
||||
change.setChangeType("ADD");
|
||||
change.setTextDetails(MRefList.getListDescription (assetAdd.getCtx(),"A_Update_Type" , "ADD"));
|
||||
change.setPostingType(assetwk.getPostingType());
|
||||
change.setAssetValueAmt(assetAdd.getAssetValueAmt());
|
||||
change.setA_QTY_Current(assetAdd.getA_QTY_Current());
|
||||
change.saveEx();
|
||||
|
||||
return change;
|
||||
}
|
||||
|
||||
public static MAssetChange create(Properties ctx, String changeType, PO[] pos, String trxName) {
|
||||
return create(ctx, changeType, pos, false, trxName);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param ctx
|
||||
* @param changeType
|
||||
* @param pos
|
||||
* @param trxName
|
||||
* @return
|
||||
*/
|
||||
public static MAssetChange createAndSave(Properties ctx, String changeType, PO[] pos, String trxName) {
|
||||
return null;
|
||||
//~ return create(ctx, changeType, pos, true, trxName);
|
||||
}
|
||||
|
||||
public static MAssetChange create(Properties ctx, String changeType, PO[] pos, boolean save, String trxName) {
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("Entering: changeType=" + changeType);
|
||||
if (pos == null || pos.length == 0) {
|
||||
s_log.fine("Entering/Leaving: POs is empty");
|
||||
return null;
|
||||
}
|
||||
MAssetChange change = new MAssetChange (ctx, 0, trxName);
|
||||
change.setChangeType(changeType);
|
||||
for (PO po : pos) {
|
||||
change.addChanges(po);
|
||||
}
|
||||
if (save) {
|
||||
change.saveEx();
|
||||
}
|
||||
//
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("Leaving: change=" + change);
|
||||
return change;
|
||||
}
|
||||
|
||||
public void addChanges(PO po) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Entering: po=" + po);
|
||||
if (po == null) {
|
||||
return;
|
||||
}
|
||||
/* arhipac: teo_sarca: TODO need to integrate
|
||||
for(int idx = 0; idx < po.get_ColumnCount_P(); idx++) {
|
||||
//~ if(!po.is_ValueChanged(idx)) {
|
||||
//~ continue;
|
||||
//~ }
|
||||
String colName = po.get_ColumnName_P(idx);
|
||||
int idx2 = get_ColumnIndex(colName);
|
||||
if(idx2 < 0) {
|
||||
if(CLogMgt.isLevelFine()) log.fine("Setting " + colName + ": SKIP (idx2 < 0)");
|
||||
continue;
|
||||
}
|
||||
|
||||
Object value = po.get_Value(idx2);
|
||||
set_Value(colName, value);
|
||||
if(CLogMgt.isLevelFine()) log.fine("Setting " + colName + "=" + value + " (from " + po.getClass() + ", idx=" + idx + ", idx2=" + idx2 + ")");
|
||||
}
|
||||
*/
|
||||
//
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Leaving: po=" + po);
|
||||
}
|
||||
/** ARHIPAC: TEO: END ------------------------------------------------------------------ */
|
||||
} // MAssetChange
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -15,71 +15,71 @@
|
|||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.util.PaymentUtil;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.IBAN;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* BP Bank Account Model
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.util.PaymentUtil;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.IBAN;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* BP Bank Account Model
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MBPBankAccount.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
||||
*/
|
||||
public class MBPBankAccount extends X_C_BP_BankAccount
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6826961806519015878L;
|
||||
|
||||
/**
|
||||
* Get Accounts Of BPartner
|
||||
* @param ctx context
|
||||
* @param C_BPartner_ID bpartner
|
||||
* @return
|
||||
*/
|
||||
public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID)
|
||||
{
|
||||
final String whereClause = MBPBankAccount.COLUMNNAME_C_BPartner_ID+"=?";
|
||||
List<MBPBankAccount>list = new Query(ctx,I_C_BP_BankAccount.Table_Name,whereClause,null)
|
||||
.setParameters(C_BPartner_ID)
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
|
||||
MBPBankAccount[] retValue = new MBPBankAccount[list.size()];
|
||||
list.toArray(retValue);
|
||||
return retValue;
|
||||
} // getOfBPartner
|
||||
|
||||
/** Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger(MBPBankAccount.class);
|
||||
|
||||
/**************************************************************************
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
* @param C_BP_BankAccount_ID BP bank account
|
||||
*/
|
||||
public class MBPBankAccount extends X_C_BP_BankAccount
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6826961806519015878L;
|
||||
|
||||
/**
|
||||
* Get Accounts Of BPartner
|
||||
* @param ctx context
|
||||
* @param C_BPartner_ID bpartner
|
||||
* @return
|
||||
*/
|
||||
public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID)
|
||||
{
|
||||
final String whereClause = MBPBankAccount.COLUMNNAME_C_BPartner_ID+"=?";
|
||||
List<MBPBankAccount>list = new Query(ctx,I_C_BP_BankAccount.Table_Name,whereClause,null)
|
||||
.setParameters(C_BPartner_ID)
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
|
||||
MBPBankAccount[] retValue = new MBPBankAccount[list.size()];
|
||||
list.toArray(retValue);
|
||||
return retValue;
|
||||
} // getOfBPartner
|
||||
|
||||
/** Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger(MBPBankAccount.class);
|
||||
|
||||
/**************************************************************************
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
* @param C_BP_BankAccount_ID BP bank account
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MBPBankAccount (Properties ctx, int C_BP_BankAccount_ID, String trxName)
|
||||
{
|
||||
super (ctx, C_BP_BankAccount_ID, trxName);
|
||||
if (C_BP_BankAccount_ID == 0)
|
||||
{
|
||||
// setC_BPartner_ID (0);
|
||||
setIsACH (false);
|
||||
setBPBankAcctUse(BPBANKACCTUSE_Both);
|
||||
}
|
||||
} // MBP_BankAccount
|
||||
|
||||
{
|
||||
// setC_BPartner_ID (0);
|
||||
setIsACH (false);
|
||||
setBPBankAcctUse(BPBANKACCTUSE_Both);
|
||||
}
|
||||
} // MBP_BankAccount
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
|
@ -97,13 +97,13 @@ public class MBPBankAccount extends X_C_BP_BankAccount
|
|||
* @param bp BP
|
||||
* @param bpc BP Contact
|
||||
* @param location Location
|
||||
*/
|
||||
public MBPBankAccount (Properties ctx, MBPartner bp, MUser bpc, MLocation location)
|
||||
{
|
||||
this(ctx, 0, bp.get_TrxName());
|
||||
setIsACH (false);
|
||||
//
|
||||
setC_BPartner_ID(bp.getC_BPartner_ID());
|
||||
*/
|
||||
public MBPBankAccount (Properties ctx, MBPartner bp, MUser bpc, MLocation location)
|
||||
{
|
||||
this(ctx, 0, bp.get_TrxName());
|
||||
setIsACH (false);
|
||||
//
|
||||
setC_BPartner_ID(bp.getC_BPartner_ID());
|
||||
//
|
||||
setA_Name(bpc.getName());
|
||||
setA_EMail(bpc.getEMail());
|
||||
|
@ -112,125 +112,125 @@ public class MBPBankAccount extends X_C_BP_BankAccount
|
|||
setA_City(location.getCity());
|
||||
setA_Zip(location.getPostal());
|
||||
setA_State(location.getRegionName(true));
|
||||
setA_Country(location.getCountryName());
|
||||
} // 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_Bank_ID = getC_Bank_ID();
|
||||
if (C_Bank_ID == 0)
|
||||
return null;
|
||||
if (m_bank == null)
|
||||
m_bank = new MBank (getCtx(), C_Bank_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
|
||||
|
||||
/**
|
||||
* Get SwiftCode
|
||||
* @return SwiftCode
|
||||
*/
|
||||
public String getSwiftCode()
|
||||
{
|
||||
MBank bank = getBank();
|
||||
if (bank != null)
|
||||
return bank.getSwiftCode();
|
||||
return null;
|
||||
} // getSwiftCode
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
protected boolean beforeSave(boolean newRecord)
|
||||
{
|
||||
// maintain routing on bank level
|
||||
if (isACH() && getBank() != null)
|
||||
setRoutingNo(null);
|
||||
//
|
||||
if (getCreditCardNumber() != null)
|
||||
{
|
||||
String encrpytedCCNo = PaymentUtil.encrpytCreditCard(getCreditCardNumber());
|
||||
if (!encrpytedCCNo.equals(getCreditCardNumber()))
|
||||
setCreditCardNumber(encrpytedCCNo);
|
||||
}
|
||||
|
||||
if (getCreditCardVV() != null)
|
||||
{
|
||||
String encrpytedCvv = PaymentUtil.encrpytCvv(getCreditCardVV());
|
||||
if (!encrpytedCvv.equals(getCreditCardVV()))
|
||||
setCreditCardVV(encrpytedCvv);
|
||||
}
|
||||
|
||||
if (MSysConfig.getBooleanValue(MSysConfig.IBAN_VALIDATION, true, Env.getAD_Client_ID(Env.getCtx()))) {
|
||||
if (!Util.isEmpty(getIBAN())) {
|
||||
setIBAN(IBAN.normalizeIBAN(getIBAN()));
|
||||
if (!IBAN.isValid(getIBAN())) {
|
||||
log.saveError("Error", Msg.getMsg(getCtx(), "InvalidIBAN"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
setA_Country(location.getCountryName());
|
||||
} // 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_Bank_ID = getC_Bank_ID();
|
||||
if (C_Bank_ID == 0)
|
||||
return null;
|
||||
if (m_bank == null)
|
||||
m_bank = new MBank (getCtx(), C_Bank_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
|
||||
|
||||
/**
|
||||
* Get SwiftCode
|
||||
* @return SwiftCode
|
||||
*/
|
||||
public String getSwiftCode()
|
||||
{
|
||||
MBank bank = getBank();
|
||||
if (bank != null)
|
||||
return bank.getSwiftCode();
|
||||
return null;
|
||||
} // getSwiftCode
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
protected boolean beforeSave(boolean newRecord)
|
||||
{
|
||||
// maintain routing on bank level
|
||||
if (isACH() && getBank() != null)
|
||||
setRoutingNo(null);
|
||||
//
|
||||
if (getCreditCardNumber() != null)
|
||||
{
|
||||
String encrpytedCCNo = PaymentUtil.encrpytCreditCard(getCreditCardNumber());
|
||||
if (!encrpytedCCNo.equals(getCreditCardNumber()))
|
||||
setCreditCardNumber(encrpytedCCNo);
|
||||
}
|
||||
|
||||
if (getCreditCardVV() != null)
|
||||
{
|
||||
String encrpytedCvv = PaymentUtil.encrpytCvv(getCreditCardVV());
|
||||
if (!encrpytedCvv.equals(getCreditCardVV()))
|
||||
setCreditCardVV(encrpytedCvv);
|
||||
}
|
||||
|
||||
if (MSysConfig.getBooleanValue(MSysConfig.IBAN_VALIDATION, true, Env.getAD_Client_ID(Env.getCtx()))) {
|
||||
if (!Util.isEmpty(getIBAN())) {
|
||||
setIBAN(IBAN.normalizeIBAN(getIBAN()));
|
||||
if (!IBAN.isValid(getIBAN())) {
|
||||
log.saveError("Error", Msg.getMsg(getCtx(), "InvalidIBAN"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("MBP_BankAccount[")
|
||||
StringBuilder sb = new StringBuilder ("MBP_BankAccount[")
|
||||
.append (get_ID ())
|
||||
.append(", Name=").append(getA_Name())
|
||||
.append ("]");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,22 +16,22 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.ecs.xhtml.b;
|
||||
import org.apache.ecs.xhtml.hr;
|
||||
import org.apache.ecs.xhtml.p;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.ecs.xhtml.b;
|
||||
import org.apache.ecs.xhtml.hr;
|
||||
import org.apache.ecs.xhtml.p;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* Chat Model
|
||||
|
@ -41,11 +41,11 @@ import org.compiere.util.Util;
|
|||
*/
|
||||
public class MChat extends X_CM_Chat
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 9165439123618441913L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 9165439123618441913L;
|
||||
|
||||
/**
|
||||
* Get Chats Of Table - of client in context
|
||||
* @param ctx context
|
||||
|
@ -59,7 +59,7 @@ public class MChat extends X_CM_Chat
|
|||
//
|
||||
String sql = "SELECT * FROM CM_Chat "
|
||||
+ "WHERE AD_Client_ID=? AND AD_Table_ID=? ORDER BY Record_ID";
|
||||
PreparedStatement pstmt = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
|
@ -76,11 +76,11 @@ public class MChat extends X_CM_Chat
|
|||
{
|
||||
s_log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
//
|
||||
MChat[] retValue = new MChat[list.size()];
|
||||
|
@ -103,13 +103,13 @@ public class MChat extends X_CM_Chat
|
|||
super (ctx, CM_Chat_ID, trxName);
|
||||
if (CM_Chat_ID == 0)
|
||||
{
|
||||
// setAD_Table_ID (0);
|
||||
// setRecord_ID (0);
|
||||
setConfidentialType (CONFIDENTIALTYPE_PublicInformation);
|
||||
setModerationType (MODERATIONTYPE_NotModerated);
|
||||
// setDescription (null);
|
||||
}
|
||||
} // MChat
|
||||
// setAD_Table_ID (0);
|
||||
// setRecord_ID (0);
|
||||
setConfidentialType (CONFIDENTIALTYPE_PublicInformation);
|
||||
setModerationType (MODERATIONTYPE_NotModerated);
|
||||
// setDescription (null);
|
||||
}
|
||||
} // MChat
|
||||
|
||||
/**
|
||||
* Full Constructor
|
||||
|
@ -156,7 +156,7 @@ public class MChat extends X_CM_Chat
|
|||
return m_entries;
|
||||
ArrayList<MChatEntry> list = new ArrayList<MChatEntry>();
|
||||
String sql = "SELECT * FROM CM_ChatEntry WHERE CM_Chat_ID=? ORDER BY Created";
|
||||
PreparedStatement pstmt = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
|
@ -172,11 +172,11 @@ public class MChat extends X_CM_Chat
|
|||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
//
|
||||
m_entries = new MChatEntry[list.size ()];
|
||||
|
@ -194,10 +194,10 @@ public class MChat extends X_CM_Chat
|
|||
{
|
||||
if (Description != null && Description.length() > 0)
|
||||
super.setDescription (Description);
|
||||
else{
|
||||
StringBuilder msgsd = new StringBuilder().append(getAD_Table_ID()).append("#").append(getRecord_ID());
|
||||
super.setDescription (msgsd.toString());
|
||||
}
|
||||
else{
|
||||
StringBuilder msgsd = new StringBuilder().append(getAD_Table_ID()).append("#").append(getRecord_ID());
|
||||
super.setDescription (msgsd.toString());
|
||||
}
|
||||
} // setDescription
|
||||
|
||||
/**
|
||||
|
@ -239,19 +239,19 @@ public class MChat extends X_CM_Chat
|
|||
} // entry
|
||||
//
|
||||
return history;
|
||||
} // getHistory
|
||||
|
||||
/**
|
||||
* IDEMPIERE-530
|
||||
* Get the chat ID based on table_id and record_id
|
||||
* @param AD_Table_ID
|
||||
* @param Record_ID
|
||||
* @return CM_Chat_ID
|
||||
*/
|
||||
public static int getID(int Table_ID, int Record_ID) {
|
||||
String sql="SELECT CM_Chat_ID FROM CM_Chat WHERE AD_Table_ID=? AND Record_ID=?";
|
||||
int chatID = DB.getSQLValueEx(null, sql, Table_ID, Record_ID);
|
||||
return chatID;
|
||||
}
|
||||
} // getHistory
|
||||
|
||||
/**
|
||||
* IDEMPIERE-530
|
||||
* Get the chat ID based on table_id and record_id
|
||||
* @param AD_Table_ID
|
||||
* @param Record_ID
|
||||
* @return CM_Chat_ID
|
||||
*/
|
||||
public static int getID(int Table_ID, int Record_ID) {
|
||||
String sql="SELECT CM_Chat_ID FROM CM_Chat WHERE AD_Table_ID=? AND Record_ID=?";
|
||||
int chatID = DB.getSQLValueEx(null, sql, Table_ID, Record_ID);
|
||||
return chatID;
|
||||
}
|
||||
|
||||
} // MChat
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -15,40 +15,40 @@
|
|||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Chat Entry Model
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Chat Entry Model
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MChatEntry.java,v 1.2 2006/07/30 00:51:03 jjanke Exp $
|
||||
*/
|
||||
public class MChatEntry extends X_CM_ChatEntry
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -158924400098841023L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -158924400098841023L;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx cintext
|
||||
* @param CM_ChatEntry_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MChatEntry (Properties ctx, int CM_ChatEntry_ID, String trxName)
|
||||
{
|
||||
super (ctx, CM_ChatEntry_ID, trxName);
|
||||
if (CM_ChatEntry_ID == 0)
|
||||
{
|
||||
setChatEntryType (CHATENTRYTYPE_NoteFlat); // N
|
||||
setConfidentialType (CONFIDENTIALTYPE_PublicInformation);
|
||||
}
|
||||
} // MChatEntry
|
||||
|
||||
/**
|
||||
public MChatEntry (Properties ctx, int CM_ChatEntry_ID, String trxName)
|
||||
{
|
||||
super (ctx, CM_ChatEntry_ID, trxName);
|
||||
if (CM_ChatEntry_ID == 0)
|
||||
{
|
||||
setChatEntryType (CHATENTRYTYPE_NoteFlat); // N
|
||||
setConfidentialType (CONFIDENTIALTYPE_PublicInformation);
|
||||
}
|
||||
} // MChatEntry
|
||||
|
||||
/**
|
||||
* Parent Constructor
|
||||
* @param chat parent
|
||||
* @param data text
|
||||
|
@ -56,33 +56,33 @@ public class MChatEntry extends X_CM_ChatEntry
|
|||
public MChatEntry (MChat chat, String data)
|
||||
{
|
||||
this (chat.getCtx(), 0, chat.get_TrxName());
|
||||
setCM_Chat_ID(chat.getCM_Chat_ID());
|
||||
setConfidentialType(chat.getConfidentialType());
|
||||
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
|
||||
|
||||
/**
|
||||
setCM_Chat_ID(chat.getCM_Chat_ID());
|
||||
setConfidentialType(chat.getConfidentialType());
|
||||
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
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,10 +16,10 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
|
||||
/**
|
||||
* Chat Type Model
|
||||
|
@ -29,11 +29,11 @@ import org.compiere.util.CCache;
|
|||
*/
|
||||
public class MChatType extends X_CM_ChatType
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7933150405119053730L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7933150405119053730L;
|
||||
|
||||
/**
|
||||
* Get MChatType from Cache
|
||||
* @param ctx context
|
||||
|
@ -62,14 +62,14 @@ public class MChatType extends X_CM_ChatType
|
|||
* @param CM_ChatType_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MChatType (Properties ctx, int CM_ChatType_ID, String trxName)
|
||||
{
|
||||
super (ctx, CM_ChatType_ID, trxName);
|
||||
if (CM_ChatType_ID == 0)
|
||||
setModerationType (MODERATIONTYPE_NotModerated);
|
||||
} // MChatType
|
||||
|
||||
/**
|
||||
public MChatType (Properties ctx, int CM_ChatType_ID, String trxName)
|
||||
{
|
||||
super (ctx, CM_ChatType_ID, trxName);
|
||||
if (CM_ChatType_ID == 0)
|
||||
setModerationType (MODERATIONTYPE_NotModerated);
|
||||
} // MChatType
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,70 +16,70 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* Container Model
|
||||
*
|
||||
* @author Yves Sandfort
|
||||
* @version $Id: MContainer.java,v 1.20 2006/09/05 23:22:53 comdivision Exp $
|
||||
* @version $Id: MContainer.java,v 1.20 2006/09/05 23:22:53 comdivision Exp $
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
*/
|
||||
public class MContainer extends X_CM_Container
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3999588662066631303L;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "(RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(relURL, relURL+"/",CM_WebProject_Id)
|
||||
.first();
|
||||
|
||||
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;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "CM_Container_ID=? AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(CM_Container_ID, CM_WebProject_Id)
|
||||
.first();
|
||||
//
|
||||
return thisContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Stage into Container
|
||||
*
|
||||
*/
|
||||
public class MContainer extends X_CM_Container
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3999588662066631303L;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "(RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(relURL, relURL+"/",CM_WebProject_Id)
|
||||
.first();
|
||||
|
||||
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;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "CM_Container_ID=? AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(CM_Container_ID, CM_WebProject_Id)
|
||||
.first();
|
||||
//
|
||||
return thisContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Stage into Container
|
||||
*
|
||||
* @param project WebProject
|
||||
* @param stage Stage to copy from
|
||||
* @param path Relative URL to it
|
||||
|
@ -114,11 +114,11 @@ public class MContainer extends X_CM_Container
|
|||
String trxName)
|
||||
{
|
||||
MContainer cc = null;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "CM_Container_ID=?";
|
||||
cc = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(CM_Container_ID)
|
||||
.first();
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "CM_Container_ID=?";
|
||||
cc = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(CM_Container_ID)
|
||||
.first();
|
||||
//
|
||||
return cc;
|
||||
} // getDirect
|
||||
|
@ -132,12 +132,12 @@ public class MContainer extends X_CM_Container
|
|||
*/
|
||||
public static MContainer[] getContainers (MWebProject project)
|
||||
{
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "CM_WebProject_ID=?";
|
||||
List<MContainer> list = new Query(project.getCtx(), I_CM_Container.Table_Name, whereClause, project.get_TrxName())
|
||||
.setParameters(project.getCM_WebProject_ID ())
|
||||
.setOrderBy("CM_Container_ID")
|
||||
.list();
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
final String whereClause = "CM_WebProject_ID=?";
|
||||
List<MContainer> list = new Query(project.getCtx(), I_CM_Container.Table_Name, whereClause, project.get_TrxName())
|
||||
.setParameters(project.getCM_WebProject_ID ())
|
||||
.setOrderBy("CM_Container_ID")
|
||||
.list();
|
||||
//
|
||||
MContainer[] retValue = new MContainer[list.size ()];
|
||||
list.toArray (retValue);
|
||||
|
@ -145,7 +145,7 @@ public class MContainer extends X_CM_Container
|
|||
} // getContainers
|
||||
|
||||
/** Logger */
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger (MContainer.class);
|
||||
|
||||
|
||||
|
@ -276,20 +276,20 @@ public class MContainer extends X_CM_Container
|
|||
.getProperty ("java.naming.provider.url")), log, getCtx (),
|
||||
get_TrxName ());
|
||||
// First update the new ones...
|
||||
StringBuilder msgx = new StringBuilder("CM_CStage_ID=").append(stage.get_ID ());
|
||||
StringBuilder msgx = new StringBuilder("CM_CStage_ID=").append(stage.get_ID ());
|
||||
int[] tableKeys = X_CM_CStage_Element.getAllIDs ("CM_CStage_Element",
|
||||
msgx.toString(), trxName);
|
||||
msgx.toString(), trxName);
|
||||
if (tableKeys != null && tableKeys.length > 0)
|
||||
{
|
||||
for (int i = 0; i < tableKeys.length; i++)
|
||||
{
|
||||
X_CM_CStage_Element thisStageElement = new X_CM_CStage_Element (
|
||||
project.getCtx (), tableKeys[i], trxName);
|
||||
msgx = new StringBuilder("CM_Container_ID=")
|
||||
.append(stage.get_ID ()).append(" AND Name LIKE '")
|
||||
.append(thisStageElement.getName ()).append("'");
|
||||
project.getCtx (), tableKeys[i], trxName);
|
||||
msgx = new StringBuilder("CM_Container_ID=")
|
||||
.append(stage.get_ID ()).append(" AND Name LIKE '")
|
||||
.append(thisStageElement.getName ()).append("'");
|
||||
int[] thisContainerElementKeys = X_CM_Container_Element
|
||||
.getAllIDs ("CM_Container_Element", msgx.toString(), trxName);
|
||||
.getAllIDs ("CM_Container_Element", msgx.toString(), trxName);
|
||||
X_CM_Container_Element thisContainerElement;
|
||||
if (thisContainerElementKeys != null
|
||||
&& thisContainerElementKeys.length > 0)
|
||||
|
@ -322,20 +322,20 @@ public class MContainer extends X_CM_Container
|
|||
}
|
||||
}
|
||||
// Now we are checking the existing ones to delete the unneeded ones...
|
||||
msgx = new StringBuilder("CM_Container_ID=").append(stage.get_ID ());
|
||||
msgx = new StringBuilder("CM_Container_ID=").append(stage.get_ID ());
|
||||
tableKeys = X_CM_Container_Element.getAllIDs ("CM_Container_Element",
|
||||
msgx.toString(), trxName);
|
||||
msgx.toString(), trxName);
|
||||
if (tableKeys != null && tableKeys.length > 0)
|
||||
{
|
||||
for (int i = 0; i < tableKeys.length; i++)
|
||||
{
|
||||
X_CM_Container_Element thisContainerElement = new X_CM_Container_Element (
|
||||
project.getCtx (), tableKeys[i], trxName);
|
||||
msgx = new StringBuilder("CM_CStage_ID=")
|
||||
.append(stage.get_ID ()).append(" AND Name LIKE '")
|
||||
.append(thisContainerElement.getName ()).append("'");
|
||||
project.getCtx (), tableKeys[i], trxName);
|
||||
msgx = new StringBuilder("CM_CStage_ID=")
|
||||
.append(stage.get_ID ()).append(" AND Name LIKE '")
|
||||
.append(thisContainerElement.getName ()).append("'");
|
||||
int[] thisCStageElementKeys = X_CM_CStage_Element
|
||||
.getAllIDs ("CM_CStage_Element", msgx.toString(), trxName);
|
||||
.getAllIDs ("CM_CStage_Element", msgx.toString(), trxName);
|
||||
// If we cannot find a representative in the Stage we will delete from production
|
||||
if (thisCStageElementKeys == null
|
||||
|| thisCStageElementKeys.length < 1)
|
||||
|
@ -362,20 +362,20 @@ public class MContainer extends X_CM_Container
|
|||
protected void updateTTables (MWebProject project, MCStage stage,
|
||||
String trxName)
|
||||
{
|
||||
StringBuilder msgx = new StringBuilder("CM_CStage_ID=").append(stage.get_ID ());
|
||||
StringBuilder msgx = new StringBuilder("CM_CStage_ID=").append(stage.get_ID ());
|
||||
int[] tableKeys = X_CM_CStageTTable.getAllIDs (I_CM_CStageTTable.Table_Name,
|
||||
msgx.toString(), trxName);
|
||||
msgx.toString(), trxName);
|
||||
if (tableKeys != null && tableKeys.length > 0)
|
||||
{
|
||||
for (int i = 0; i < tableKeys.length; i++)
|
||||
{
|
||||
X_CM_CStageTTable thisStageTTable = new X_CM_CStageTTable (
|
||||
project.getCtx (), tableKeys[i], trxName);
|
||||
msgx = new StringBuilder("CM_Container_ID=").append(stage.get_ID ())
|
||||
.append(" AND CM_TemplateTable_ID=")
|
||||
.append(thisStageTTable.getCM_TemplateTable_ID ());
|
||||
project.getCtx (), tableKeys[i], trxName);
|
||||
msgx = new StringBuilder("CM_Container_ID=").append(stage.get_ID ())
|
||||
.append(" AND CM_TemplateTable_ID=")
|
||||
.append(thisStageTTable.getCM_TemplateTable_ID ());
|
||||
int[] thisContainerTTableKeys = X_CM_ContainerTTable.getAllIDs (
|
||||
I_CM_ContainerTTable.Table_Name, msgx.toString(), trxName);
|
||||
I_CM_ContainerTTable.Table_Name, msgx.toString(), trxName);
|
||||
X_CM_ContainerTTable thisContainerTTable;
|
||||
if (thisContainerTTableKeys != null
|
||||
&& thisContainerTTableKeys.length > 0)
|
||||
|
@ -415,7 +415,7 @@ public class MContainer extends X_CM_Container
|
|||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("MContainer[").append (get_ID ())
|
||||
StringBuilder sb = new StringBuilder ("MContainer[").append (get_ID ())
|
||||
.append ("-").append (getName ()).append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
@ -435,20 +435,20 @@ public class MContainer extends X_CM_Container
|
|||
return success;
|
||||
if (newRecord)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder (
|
||||
"INSERT INTO AD_TreeNodeCMC ")
|
||||
.append("(AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, ")
|
||||
.append("AD_Tree_ID, Node_ID, Parent_ID, SeqNo) ").append("VALUES (")
|
||||
StringBuilder sb = new StringBuilder (
|
||||
"INSERT INTO AD_TreeNodeCMC ")
|
||||
.append("(AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, ")
|
||||
.append("AD_Tree_ID, Node_ID, Parent_ID, SeqNo) ").append("VALUES (")
|
||||
.append (getAD_Client_ID ()).append (
|
||||
",0, 'Y', SysDate, 0, SysDate, 0,").append (
|
||||
getAD_Tree_ID ()).append (",").append (get_ID ()).append (
|
||||
", 0, 999)");
|
||||
int no = DB.executeUpdate (sb.toString (), get_TrxName ());
|
||||
if (no > 0) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("#" + no + " - TreeType=CMC");
|
||||
} else {
|
||||
log.warning ("#" + no + " - TreeType=CMC");
|
||||
}
|
||||
if (no > 0) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("#" + no + " - TreeType=CMC");
|
||||
} else {
|
||||
log.warning ("#" + no + " - TreeType=CMC");
|
||||
}
|
||||
return no > 0;
|
||||
}
|
||||
return success;
|
||||
|
@ -456,8 +456,8 @@ public class MContainer extends X_CM_Container
|
|||
|
||||
protected MContainerElement[] getAllElements()
|
||||
{
|
||||
StringBuilder msgmc = new StringBuilder("CM_Container_ID=").append(get_ID());
|
||||
int elements[] = MContainerElement.getAllIDs("CM_Container_Element", msgmc.toString(), get_TrxName());
|
||||
StringBuilder msgmc = new StringBuilder("CM_Container_ID=").append(get_ID());
|
||||
int elements[] = MContainerElement.getAllIDs("CM_Container_Element", msgmc.toString(), get_TrxName());
|
||||
if (elements.length>0)
|
||||
{
|
||||
MContainerElement[] containerElements = new MContainerElement[elements.length];
|
||||
|
@ -485,15 +485,15 @@ public class MContainer extends X_CM_Container
|
|||
}
|
||||
}
|
||||
//
|
||||
StringBuilder sb = new StringBuilder ("DELETE FROM AD_TreeNodeCMC ")
|
||||
StringBuilder sb = new StringBuilder ("DELETE FROM AD_TreeNodeCMC ")
|
||||
.append (" WHERE Node_ID=").append (get_ID ()).append (
|
||||
" AND AD_Tree_ID=").append (getAD_Tree_ID ());
|
||||
int no = DB.executeUpdate (sb.toString (), get_TrxName ());
|
||||
if (no > 0) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("#" + no + " - TreeType=CMC");
|
||||
} else {
|
||||
log.warning ("#" + no + " - TreeType=CMC");
|
||||
}
|
||||
if (no > 0) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("#" + no + " - TreeType=CMC");
|
||||
} else {
|
||||
log.warning ("#" + no + " - TreeType=CMC");
|
||||
}
|
||||
return no > 0;
|
||||
}
|
||||
|
||||
|
@ -508,16 +508,16 @@ public class MContainer extends X_CM_Container
|
|||
if (!success)
|
||||
return success;
|
||||
//
|
||||
StringBuilder sb = new StringBuilder ("DELETE FROM AD_TreeNodeCMC ")
|
||||
StringBuilder sb = new StringBuilder ("DELETE FROM AD_TreeNodeCMC ")
|
||||
.append (" WHERE Node_ID=").append (get_IDOld ()).append (
|
||||
" AND AD_Tree_ID=").append (getAD_Tree_ID ());
|
||||
int no = DB.executeUpdate (sb.toString (), get_TrxName ());
|
||||
// If 0 than there is nothing to delete which is okay.
|
||||
if (no > 0) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("#" + no + " - TreeType=CMC");
|
||||
} else {
|
||||
log.warning ("#" + no + " - TreeType=CMC");
|
||||
}
|
||||
if (no > 0) {
|
||||
if (log.isLoggable(Level.FINE)) log.fine ("#" + no + " - TreeType=CMC");
|
||||
} else {
|
||||
log.warning ("#" + no + " - TreeType=CMC");
|
||||
}
|
||||
return true;
|
||||
} // afterDelete
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,42 +16,42 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
/**
|
||||
* CStage Element
|
||||
*
|
||||
* @author Yves Sandfort
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MContainerElement extends X_CM_Container_Element
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8487403111353473486L;
|
||||
|
||||
/** Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger (MContainerElement.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) {
|
||||
return new MContainerElement(ctx, CM_ContainerElement_ID, trxName);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Standard Constructor
|
||||
*
|
||||
*/
|
||||
public class MContainerElement extends X_CM_Container_Element
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8487403111353473486L;
|
||||
|
||||
/** Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger (MContainerElement.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) {
|
||||
return new MContainerElement(ctx, CM_ContainerElement_ID, trxName);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Standard Constructor
|
||||
*
|
||||
* @param ctx context
|
||||
* @param CM_Container_Element_ID id
|
||||
* @param trxName transaction
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -15,35 +15,35 @@
|
|||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
|
||||
/**
|
||||
* Dunning Level Model
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MDunningLevel.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $
|
||||
*/
|
||||
public class MDunningLevel extends X_C_DunningLevel
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4869909989789113387L;
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MDunningLevel.class);
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
*/
|
||||
public class MDunningLevel extends X_C_DunningLevel
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4869909989789113387L;
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MDunningLevel.class);
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
* @param C_DunningLevel_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
|
@ -59,60 +59,60 @@ public class MDunningLevel extends X_C_DunningLevel
|
|||
* @param trxName transaction
|
||||
*/
|
||||
public MDunningLevel (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // 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;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||
pstmt.setInt(1, getParent().get_ID ());
|
||||
int totalDays = getDaysAfterDue ().intValue ()+getDaysBetweenDunning ();
|
||||
pstmt.setInt(2, totalDays);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
list.add(new MDunningLevel(getCtx(), rs, get_TrxName()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
//
|
||||
MDunningLevel[] retValue = new MDunningLevel[list.size()];
|
||||
list.toArray(retValue);
|
||||
return retValue;
|
||||
}
|
||||
} // MDunningLevel
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // 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;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||
pstmt.setInt(1, getParent().get_ID ());
|
||||
int totalDays = getDaysAfterDue ().intValue ()+getDaysBetweenDunning ();
|
||||
pstmt.setInt(2, totalDays);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
list.add(new MDunningLevel(getCtx(), rs, get_TrxName()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
//
|
||||
MDunningLevel[] retValue = new MDunningLevel[list.size()];
|
||||
list.toArray(retValue);
|
||||
return retValue;
|
||||
}
|
||||
} // MDunningLevel
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,12 +16,12 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Dunning Run Line Model
|
||||
|
@ -31,11 +31,11 @@ import org.compiere.util.Env;
|
|||
*/
|
||||
public class MDunningRunLine extends X_C_DunningRunLine
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6329441027195611155L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6329441027195611155L;
|
||||
|
||||
/**
|
||||
* Standarc Constructor
|
||||
* @param ctx ctx
|
||||
|
@ -142,54 +142,54 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
|||
/**
|
||||
* Set Invoice
|
||||
* @param C_Invoice_ID
|
||||
* @param C_Currency_ID
|
||||
* @param GrandTotal
|
||||
* @param Open
|
||||
* @param FeeAmount
|
||||
* @param DaysDue
|
||||
* @param IsInDispute
|
||||
* @param TimesDunned
|
||||
* @param C_Currency_ID
|
||||
* @param GrandTotal
|
||||
* @param Open
|
||||
* @param FeeAmount
|
||||
* @param DaysDue
|
||||
* @param IsInDispute
|
||||
* @param TimesDunned
|
||||
* @param DaysAfterLast not used
|
||||
*/
|
||||
public void setInvoice (int C_Invoice_ID, int C_Currency_ID,
|
||||
BigDecimal GrandTotal, BigDecimal Open,
|
||||
BigDecimal FeeAmount,
|
||||
int DaysDue, boolean IsInDispute,
|
||||
int TimesDunned, int DaysAfterLast)
|
||||
{
|
||||
*/
|
||||
public void setInvoice (int C_Invoice_ID, int C_Currency_ID,
|
||||
BigDecimal GrandTotal, BigDecimal Open,
|
||||
BigDecimal FeeAmount,
|
||||
int DaysDue, boolean IsInDispute,
|
||||
int TimesDunned, int DaysAfterLast)
|
||||
{
|
||||
setC_Invoice_ID(C_Invoice_ID);
|
||||
m_C_CurrencyFrom_ID = C_Currency_ID;
|
||||
setAmt (GrandTotal);
|
||||
setOpenAmt (Open);
|
||||
setFeeAmt (FeeAmount);
|
||||
setConvertedAmt (MConversionRate.convert(getCtx(), getOpenAmt(),
|
||||
C_Currency_ID, getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
||||
setIsInDispute(IsInDispute);
|
||||
m_C_CurrencyFrom_ID = C_Currency_ID;
|
||||
setAmt (GrandTotal);
|
||||
setOpenAmt (Open);
|
||||
setFeeAmt (FeeAmount);
|
||||
setConvertedAmt (MConversionRate.convert(getCtx(), getOpenAmt(),
|
||||
C_Currency_ID, getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
||||
setIsInDispute(IsInDispute);
|
||||
setDaysDue(DaysDue);
|
||||
setTimesDunned(TimesDunned);
|
||||
} // 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
|
||||
* @return Returns the payment.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return Returns the payment.
|
||||
*/
|
||||
public MPayment getPayment ()
|
||||
{
|
||||
if (getC_Payment_ID() == 0)
|
||||
|
@ -272,7 +272,7 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
|||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
{
|
||||
// Set Amt
|
||||
|
@ -286,28 +286,28 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
|||
setConvertedAmt (Env.ZERO);
|
||||
else if (Env.ZERO.compareTo(getConvertedAmt()) == 0)
|
||||
setConvertedAmt (MConversionRate.convert(getCtx(), getOpenAmt(),
|
||||
getC_CurrencyFrom_ID(), getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
||||
// Total
|
||||
setTotalAmt(getConvertedAmt().add(getFeeAmt()).add(getInterestAmt()));
|
||||
// Set Collection Status
|
||||
if (isProcessed() && getInvoice() != null)
|
||||
{
|
||||
I_C_DunningLevel level = getParent().getC_DunningLevel();
|
||||
if (level != null) {
|
||||
getInvoice().setC_DunningLevel_ID(level.getC_DunningLevel_ID());
|
||||
if (level.getInvoiceCollectionType() != null) {
|
||||
getInvoice().setInvoiceCollectionType (level.getInvoiceCollectionType());
|
||||
} else {
|
||||
if (! level.isStatement()) {
|
||||
getInvoice().setInvoiceCollectionType (MInvoice.INVOICECOLLECTIONTYPE_Dunning);
|
||||
}
|
||||
}
|
||||
getInvoice().saveEx();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} // beforeSave
|
||||
getC_CurrencyFrom_ID(), getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
|
||||
// Total
|
||||
setTotalAmt(getConvertedAmt().add(getFeeAmt()).add(getInterestAmt()));
|
||||
// Set Collection Status
|
||||
if (isProcessed() && getInvoice() != null)
|
||||
{
|
||||
I_C_DunningLevel level = getParent().getC_DunningLevel();
|
||||
if (level != null) {
|
||||
getInvoice().setC_DunningLevel_ID(level.getC_DunningLevel_ID());
|
||||
if (level.getInvoiceCollectionType() != null) {
|
||||
getInvoice().setInvoiceCollectionType (level.getInvoiceCollectionType());
|
||||
} else {
|
||||
if (! level.isStatement()) {
|
||||
getInvoice().setInvoiceCollectionType (MInvoice.INVOICECOLLECTIONTYPE_Dunning);
|
||||
}
|
||||
}
|
||||
getInvoice().saveEx();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
|
||||
/**
|
||||
|
@ -317,9 +317,9 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
|||
* @return success
|
||||
*/
|
||||
protected boolean afterSave (boolean newRecord, boolean success)
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
updateEntry();
|
||||
return success;
|
||||
} // afterSave
|
||||
|
@ -330,9 +330,9 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
|||
* @return success
|
||||
*/
|
||||
protected boolean afterDelete (boolean success)
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
updateEntry();
|
||||
return success;
|
||||
} // afterDelete
|
||||
|
@ -340,21 +340,21 @@ public class MDunningRunLine extends X_C_DunningRunLine
|
|||
/**
|
||||
* Update Entry.
|
||||
* Calculate/update Amt/Qty
|
||||
*/
|
||||
private void updateEntry()
|
||||
{
|
||||
// we do not count the fee line as an item, but it sum it up.
|
||||
StringBuilder sql = new StringBuilder("UPDATE C_DunningRunEntry e ")
|
||||
.append("SET Amt=NVL((SELECT SUM(ConvertedAmt)+SUM(FeeAmt)+SUM(InterestAmt)")
|
||||
.append(" FROM C_DunningRunLine l ")
|
||||
.append("WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID), 0), ")
|
||||
.append("QTY=(SELECT COUNT(*)")
|
||||
.append(" FROM C_DunningRunLine l ")
|
||||
.append("WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID ")
|
||||
.append(" AND (NOT C_Invoice_ID IS NULL OR NOT C_Payment_ID IS NULL))")
|
||||
.append(" WHERE C_DunningRunEntry_ID=").append(getC_DunningRunEntry_ID());
|
||||
|
||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
} // updateEntry
|
||||
|
||||
*/
|
||||
private void updateEntry()
|
||||
{
|
||||
// we do not count the fee line as an item, but it sum it up.
|
||||
StringBuilder sql = new StringBuilder("UPDATE C_DunningRunEntry e ")
|
||||
.append("SET Amt=NVL((SELECT SUM(ConvertedAmt)+SUM(FeeAmt)+SUM(InterestAmt)")
|
||||
.append(" FROM C_DunningRunLine l ")
|
||||
.append("WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID), 0), ")
|
||||
.append("QTY=(SELECT COUNT(*)")
|
||||
.append(" FROM C_DunningRunLine l ")
|
||||
.append("WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID ")
|
||||
.append(" AND (NOT C_Invoice_ID IS NULL OR NOT C_Payment_ID IS NULL))")
|
||||
.append(" WHERE C_DunningRunEntry_ID=").append(getC_DunningRunEntry_ID());
|
||||
|
||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
} // updateEntry
|
||||
|
||||
} // MDunningRunLine
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -15,18 +15,18 @@
|
|||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* Interest Area.
|
||||
* Note: if model is changed, update
|
||||
|
@ -36,55 +36,55 @@ import org.compiere.util.DB;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: MInterestArea.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
|
||||
*/
|
||||
public class MInterestArea extends X_R_InterestArea
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6910076559329764930L;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
MInterestArea ia = new MInterestArea (ctx, rs, null);
|
||||
list.add (ia);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
MInterestArea[] retValue = new MInterestArea[list.size ()];
|
||||
list.toArray (retValue);
|
||||
return retValue;
|
||||
} // getAll
|
||||
|
||||
|
||||
/**
|
||||
* Get MInterestArea from Cache
|
||||
* @param ctx context
|
||||
* @param R_InterestArea_ID id
|
||||
public class MInterestArea extends X_R_InterestArea
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6910076559329764930L;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
MInterestArea ia = new MInterestArea (ctx, rs, null);
|
||||
list.add (ia);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
MInterestArea[] retValue = new MInterestArea[list.size ()];
|
||||
list.toArray (retValue);
|
||||
return retValue;
|
||||
} // getAll
|
||||
|
||||
|
||||
/**
|
||||
* Get MInterestArea from Cache
|
||||
* @param ctx context
|
||||
* @param R_InterestArea_ID id
|
||||
* @return MInterestArea
|
||||
*/
|
||||
public static MInterestArea get (Properties ctx, int R_InterestArea_ID)
|
||||
|
@ -97,16 +97,16 @@ public class MInterestArea extends X_R_InterestArea
|
|||
if (retValue.get_ID () != 0)
|
||||
s_cache.put (key, retValue);
|
||||
return retValue;
|
||||
} // get
|
||||
|
||||
/** Cache */
|
||||
private static CCache<Integer,MInterestArea> s_cache =
|
||||
new CCache<Integer,MInterestArea>(Table_Name, 5);
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MInterestArea.class);
|
||||
|
||||
|
||||
/**
|
||||
} // get
|
||||
|
||||
/** Cache */
|
||||
private static CCache<Integer,MInterestArea> s_cache =
|
||||
new CCache<Integer,MInterestArea>(Table_Name, 5);
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MInterestArea.class);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
* @param R_InterestArea_ID interest area
|
||||
|
@ -116,13 +116,13 @@ public class MInterestArea extends X_R_InterestArea
|
|||
{
|
||||
super (ctx, R_InterestArea_ID, trxName);
|
||||
if (R_InterestArea_ID == 0)
|
||||
{
|
||||
// setName (null);
|
||||
// setR_InterestArea_ID (0);
|
||||
setIsSelfService (false);
|
||||
}
|
||||
} // MInterestArea
|
||||
|
||||
{
|
||||
// setName (null);
|
||||
// setR_InterestArea_ID (0);
|
||||
setIsSelfService (false);
|
||||
}
|
||||
} // MInterestArea
|
||||
|
||||
/**
|
||||
* Loader Constructor
|
||||
* @param ctx context
|
||||
|
@ -131,36 +131,36 @@ public class MInterestArea extends X_R_InterestArea
|
|||
*/
|
||||
public MInterestArea (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // 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
|
||||
super(ctx, rs, trxName);
|
||||
} // 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
|
||||
* @return info
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("MInterestArea[")
|
||||
.append (get_ID()).append(" - ").append(getName())
|
||||
.append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
StringBuilder sb = new StringBuilder ("MInterestArea[")
|
||||
.append (get_ID()).append(" - ").append(getName())
|
||||
.append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
private int m_AD_User_ID = -1;
|
||||
private MContactInterest m_ci = null;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,8 +16,8 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* News ItemModel
|
||||
|
@ -27,11 +27,11 @@ import java.util.Properties;
|
|||
*/
|
||||
public class MNewsItem extends X_CM_NewsItem
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8217571535161436997L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8217571535161436997L;
|
||||
|
||||
/***
|
||||
* Standard Constructor
|
||||
*
|
||||
|
@ -122,12 +122,12 @@ public class MNewsItem extends X_CM_NewsItem
|
|||
return success;
|
||||
} // afterSave
|
||||
|
||||
/**
|
||||
* reIndex
|
||||
* @param newRecord
|
||||
*/
|
||||
public void reIndex(boolean newRecord)
|
||||
{
|
||||
/**
|
||||
* reIndex
|
||||
* @param newRecord
|
||||
*/
|
||||
public void reIndex(boolean newRecord)
|
||||
{
|
||||
int CMWebProjectID = 0;
|
||||
if (getNewsChannel()!=null)
|
||||
CMWebProjectID = getNewsChannel().getCM_WebProject_ID();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,12 +16,12 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Payment Selection Line Model
|
||||
|
@ -31,11 +31,11 @@ import org.compiere.util.Env;
|
|||
*/
|
||||
public class MPaySelectionLine extends X_C_PaySelectionLine
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1880961891234637133L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1880961891234637133L;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
|
@ -54,9 +54,9 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
|||
setIsSOTrx (false);
|
||||
setOpenAmt(Env.ZERO);
|
||||
setPayAmt (Env.ZERO);
|
||||
setDiscountAmt(Env.ZERO);
|
||||
setDiscountAmt(Env.ZERO);
|
||||
setWriteOffAmt (Env.ZERO);
|
||||
setDifferenceAmt (Env.ZERO);
|
||||
setDifferenceAmt (Env.ZERO);
|
||||
setIsManual (false);
|
||||
}
|
||||
} // MPaySelectionLine
|
||||
|
@ -101,30 +101,30 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
|||
public void xsetInvoice (int C_Invoice_ID, boolean isSOTrx, BigDecimal OpenAmt,
|
||||
BigDecimal PayAmt, BigDecimal DiscountAmt)
|
||||
{
|
||||
setInvoice(C_Invoice_ID, isSOTrx, OpenAmt, PayAmt, DiscountAmt, Env.ZERO);
|
||||
setInvoice(C_Invoice_ID, isSOTrx, OpenAmt, PayAmt, DiscountAmt, Env.ZERO);
|
||||
} // setInvoive
|
||||
|
||||
/**
|
||||
* Set Invoice Info
|
||||
* @param C_Invoice_ID invoice
|
||||
* @param isSOTrx sales trx
|
||||
* @param PayAmt payment
|
||||
* @param OpenAmt open
|
||||
* @param DiscountAmt discount
|
||||
* @param WriteOffAmt writeoff
|
||||
*/
|
||||
public void setInvoice (int C_Invoice_ID, boolean isSOTrx, BigDecimal OpenAmt,
|
||||
BigDecimal PayAmt, BigDecimal DiscountAmt, BigDecimal WriteOffAmt)
|
||||
{
|
||||
setC_Invoice_ID (C_Invoice_ID);
|
||||
setIsSOTrx(isSOTrx);
|
||||
setOpenAmt(OpenAmt);
|
||||
setPayAmt (PayAmt);
|
||||
setDiscountAmt(DiscountAmt);
|
||||
setWriteOffAmt(WriteOffAmt);
|
||||
setDifferenceAmt(OpenAmt.subtract(PayAmt).subtract(DiscountAmt).subtract(WriteOffAmt));
|
||||
} // setInvoice
|
||||
|
||||
/**
|
||||
* Set Invoice Info
|
||||
* @param C_Invoice_ID invoice
|
||||
* @param isSOTrx sales trx
|
||||
* @param PayAmt payment
|
||||
* @param OpenAmt open
|
||||
* @param DiscountAmt discount
|
||||
* @param WriteOffAmt writeoff
|
||||
*/
|
||||
public void setInvoice (int C_Invoice_ID, boolean isSOTrx, BigDecimal OpenAmt,
|
||||
BigDecimal PayAmt, BigDecimal DiscountAmt, BigDecimal WriteOffAmt)
|
||||
{
|
||||
setC_Invoice_ID (C_Invoice_ID);
|
||||
setIsSOTrx(isSOTrx);
|
||||
setOpenAmt(OpenAmt);
|
||||
setPayAmt (PayAmt);
|
||||
setDiscountAmt(DiscountAmt);
|
||||
setWriteOffAmt(WriteOffAmt);
|
||||
setDifferenceAmt(OpenAmt.subtract(PayAmt).subtract(DiscountAmt).subtract(WriteOffAmt));
|
||||
} // setInvoice
|
||||
|
||||
/**
|
||||
* Get Invoice
|
||||
* @return invoice
|
||||
|
@ -133,12 +133,12 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
|||
{
|
||||
if (m_invoice == null)
|
||||
m_invoice = new MInvoice (getCtx(), getC_Invoice_ID(), get_TrxName());
|
||||
return m_invoice;
|
||||
} // getInvoice
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
return m_invoice;
|
||||
} // getInvoice
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
protected boolean beforeSave (boolean newRecord)
|
||||
|
@ -154,9 +154,9 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
|||
* @return success
|
||||
*/
|
||||
protected boolean afterSave (boolean newRecord, boolean success)
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
setHeader();
|
||||
return success;
|
||||
} // afterSave
|
||||
|
@ -167,9 +167,9 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
|||
* @return sucess
|
||||
*/
|
||||
protected boolean afterDelete (boolean success)
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
setHeader();
|
||||
return success;
|
||||
} // afterDelete
|
||||
|
@ -194,7 +194,7 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
|||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("MPaySelectionLine[");
|
||||
StringBuilder sb = new StringBuilder("MPaySelectionLine[");
|
||||
sb.append(get_ID()).append(",C_Invoice_ID=").append(getC_Invoice_ID())
|
||||
.append(",PayAmt=").append(getPayAmt())
|
||||
.append(",DifferenceAmt=").append(getDifferenceAmt())
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,11 +16,11 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import java.util.Calendar;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@ public class MPaymentValidate
|
|||
String ccNumber1 = checkNumeric(creditCardNumber);
|
||||
int ccLength = ccNumber1.length();
|
||||
// Reverse string
|
||||
StringBuilder buf = new StringBuilder();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i = ccLength; i != 0; i--)
|
||||
buf.append(ccNumber1.charAt(i-1));
|
||||
String ccNumber = buf.toString();
|
||||
|
@ -186,7 +186,7 @@ public class MPaymentValidate
|
|||
if (sum % 10 == 0)
|
||||
return "";
|
||||
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber - " + creditCardNumber + " -> "
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber - " + creditCardNumber + " -> "
|
||||
+ ccNumber + ", Luhn=" + sum);
|
||||
return "CreditCardNumberError";
|
||||
} // validateCreditCardNumber
|
||||
|
@ -206,33 +206,33 @@ public class MPaymentValidate
|
|||
// http://www.beachnet.com/~hstiles/cardtype.html
|
||||
// http://staff.semel.fi/~kribe/document/luhn.htm
|
||||
|
||||
String ccStartList = ""; // comma separated list of starting numbers
|
||||
String ccLengthList = ""; // comma separated list of lengths
|
||||
//
|
||||
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_MasterCard))
|
||||
{
|
||||
ccStartList = "51,52,53,54,55";
|
||||
ccLengthList = "16";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa))
|
||||
{
|
||||
ccStartList = "4";
|
||||
ccLengthList = "13,16";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Amex))
|
||||
{
|
||||
ccStartList = "34,37";
|
||||
ccLengthList = "15";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Discover))
|
||||
{
|
||||
ccStartList = "6011";
|
||||
ccLengthList = "16";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Diners))
|
||||
{
|
||||
ccStartList = "300,301,302,303,304,305,36,38";
|
||||
ccLengthList = "14";
|
||||
String ccStartList = ""; // comma separated list of starting numbers
|
||||
String ccLengthList = ""; // comma separated list of lengths
|
||||
//
|
||||
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_MasterCard))
|
||||
{
|
||||
ccStartList = "51,52,53,54,55";
|
||||
ccLengthList = "16";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa))
|
||||
{
|
||||
ccStartList = "4";
|
||||
ccLengthList = "13,16";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Amex))
|
||||
{
|
||||
ccStartList = "34,37";
|
||||
ccLengthList = "15";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Discover))
|
||||
{
|
||||
ccStartList = "6011";
|
||||
ccLengthList = "16";
|
||||
}
|
||||
else if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Diners))
|
||||
{
|
||||
ccStartList = "300,301,302,303,304,305,36,38";
|
||||
ccLengthList = "14";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -264,7 +264,7 @@ public class MPaymentValidate
|
|||
}
|
||||
if (!ccLengthOK)
|
||||
{
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber Length="
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber Length="
|
||||
+ ccLength + " <> " + ccLengthList);
|
||||
return "CreditCardNumberError";
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ public class MPaymentValidate
|
|||
ccIdentified = true;
|
||||
}
|
||||
if (!ccIdentified)
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber Type="
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber Type="
|
||||
+ creditCardType + " <> " + ccStartList);
|
||||
|
||||
//
|
||||
|
@ -312,9 +312,9 @@ public class MPaymentValidate
|
|||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex);
|
||||
}
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - length=" + length);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - length=" + length);
|
||||
return "CreditCardVVError";
|
||||
} // validateCreditCardVV
|
||||
|
||||
|
@ -331,13 +331,13 @@ public class MPaymentValidate
|
|||
|| creditCardType == null || creditCardType.length() == 0)
|
||||
return "";
|
||||
|
||||
int length = checkNumeric(creditCardVV).length();
|
||||
|
||||
// Amex = 4 digits
|
||||
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Amex))
|
||||
{
|
||||
if (length == 4)
|
||||
{
|
||||
int length = checkNumeric(creditCardVV).length();
|
||||
|
||||
// Amex = 4 digits
|
||||
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Amex))
|
||||
{
|
||||
if (length == 4)
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.parseInt (creditCardVV);
|
||||
|
@ -345,18 +345,18 @@ public class MPaymentValidate
|
|||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex);
|
||||
}
|
||||
}
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(4) CC=" + creditCardType + ", length=" + length);
|
||||
return "CreditCardVVError";
|
||||
}
|
||||
// Visa & MasterCard - 3 digits
|
||||
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa)
|
||||
|| creditCardType.equals(X_C_Payment.CREDITCARDTYPE_MasterCard))
|
||||
{
|
||||
if (length == 3)
|
||||
{
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(4) CC=" + creditCardType + ", length=" + length);
|
||||
return "CreditCardVVError";
|
||||
}
|
||||
// Visa & MasterCard - 3 digits
|
||||
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa)
|
||||
|| creditCardType.equals(X_C_Payment.CREDITCARDTYPE_MasterCard))
|
||||
{
|
||||
if (length == 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.parseInt (creditCardVV);
|
||||
|
@ -364,10 +364,10 @@ public class MPaymentValidate
|
|||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex);
|
||||
}
|
||||
}
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(3) CC=" + creditCardType + ", length=" + length);
|
||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(3) CC=" + creditCardType + ", length=" + length);
|
||||
return "CreditCardVVError";
|
||||
}
|
||||
|
||||
|
@ -384,15 +384,15 @@ public class MPaymentValidate
|
|||
public static String validateRoutingNo (String routingNo)
|
||||
{
|
||||
int length = checkNumeric(routingNo).length();
|
||||
// US - length 9
|
||||
// Germany - length 8
|
||||
// Japan - 7
|
||||
// CH - 5
|
||||
// Issue: Bank account country
|
||||
if (length > 0)
|
||||
return "";
|
||||
return "PaymentBankRoutingNotValid";
|
||||
} // validateBankRoutingNo
|
||||
// US - length 9
|
||||
// Germany - length 8
|
||||
// Japan - 7
|
||||
// CH - 5
|
||||
// Issue: Bank account country
|
||||
if (length > 0)
|
||||
return "";
|
||||
return "PaymentBankRoutingNotValid";
|
||||
} // validateBankRoutingNo
|
||||
|
||||
/**
|
||||
* Validate Account No
|
||||
|
@ -430,7 +430,7 @@ public class MPaymentValidate
|
|||
if (data == null || data.length() == 0)
|
||||
return "";
|
||||
// Remove all non Digits
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < data.length(); i++)
|
||||
{
|
||||
if (Character.isDigit(data.charAt(i)))
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,38 +16,38 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* Scheduler Log
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MSchedulerLog.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $
|
||||
*/
|
||||
public class MSchedulerLog extends X_AD_SchedulerLog
|
||||
implements AdempiereProcessorLog
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8105976307507562851L;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @version $Id: MSchedulerLog.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $
|
||||
*/
|
||||
public class MSchedulerLog extends X_AD_SchedulerLog
|
||||
implements AdempiereProcessorLog
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8105976307507562851L;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
* @param AD_SchedulerLog_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MSchedulerLog (Properties ctx, int AD_SchedulerLog_ID, String trxName)
|
||||
{
|
||||
super (ctx, AD_SchedulerLog_ID, trxName);
|
||||
if (AD_SchedulerLog_ID == 0)
|
||||
setIsError(false);
|
||||
} // MSchedulerLog
|
||||
|
||||
/**
|
||||
public MSchedulerLog (Properties ctx, int AD_SchedulerLog_ID, String trxName)
|
||||
{
|
||||
super (ctx, AD_SchedulerLog_ID, trxName);
|
||||
if (AD_SchedulerLog_ID == 0)
|
||||
setIsError(false);
|
||||
} // MSchedulerLog
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -15,32 +15,32 @@
|
|||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* Web Project Domain
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* Web Project Domain
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MWebProjectDomain.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
|
||||
*/
|
||||
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
|
||||
* @param ctx context
|
||||
*/
|
||||
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
|
||||
* @param ctx context
|
||||
* @param CM_WebProject_Domain_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
|
@ -56,42 +56,42 @@ public class MWebProjectDomain extends X_CM_WebProject_Domain
|
|||
* @param trxName transaction
|
||||
*/
|
||||
public MWebProjectDomain (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // 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;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, trxName);
|
||||
pstmt.setString(1, ServerName);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
thisWebProjectDomain = (new MWebProjectDomain(ctx, rs, trxName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
return thisWebProjectDomain;
|
||||
}
|
||||
|
||||
|
||||
} // MWebProjectDomain
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // 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;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, trxName);
|
||||
pstmt.setString(1, ServerName);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
thisWebProjectDomain = (new MWebProjectDomain(ctx, rs, trxName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
return thisWebProjectDomain;
|
||||
}
|
||||
|
||||
|
||||
} // MWebProjectDomain
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,14 +16,14 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,103 +31,103 @@ import org.compiere.util.Msg;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: M_Element.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1, teo_sarca
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1, teo_sarca
|
||||
*/
|
||||
public class M_Element extends X_AD_Element
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6644398794862560030L;
|
||||
|
||||
/**
|
||||
* Get case sensitive Column Name
|
||||
* @param columnName case insensitive column name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static String getColumnName (String columnName)
|
||||
{
|
||||
return getColumnName(columnName, null);
|
||||
}
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6644398794862560030L;
|
||||
|
||||
/**
|
||||
* Get case sensitive Column Name
|
||||
* @param columnName case insensitive column name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static String getColumnName (String columnName)
|
||||
{
|
||||
return getColumnName(columnName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get case sensitive Column Name
|
||||
* @param columnName case insensitive column name
|
||||
* @param columnName case insensitive column name
|
||||
* @param trxName optional transaction name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static String getColumnName (String columnName, String trxName)
|
||||
{
|
||||
if (columnName == null || columnName.length() == 0)
|
||||
return columnName;
|
||||
M_Element element = get(Env.getCtx(), columnName, trxName);
|
||||
if (element == null)
|
||||
return columnName;
|
||||
return element.getColumnName();
|
||||
return columnName;
|
||||
M_Element element = get(Env.getCtx(), columnName, trxName);
|
||||
if (element == null)
|
||||
return columnName;
|
||||
return element.getColumnName();
|
||||
|
||||
} // getColumnName
|
||||
|
||||
/**
|
||||
* Get Element
|
||||
* @param ctx context
|
||||
* @param columnName case insensitive column name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static M_Element get (Properties ctx, String columnName)
|
||||
{
|
||||
return get(ctx, columnName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Element
|
||||
* @param ctx context
|
||||
* @param columnName case insensitive column name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static M_Element get (Properties ctx, String columnName)
|
||||
{
|
||||
return get(ctx, columnName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Element
|
||||
* @param ctx context
|
||||
* @param columnName case insensitive column name
|
||||
* @param columnName case insensitive column name
|
||||
* @param trxName optional transaction name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static M_Element get (Properties ctx, String columnName, String trxName)
|
||||
{
|
||||
if (columnName == null || columnName.length() == 0)
|
||||
return null;
|
||||
//
|
||||
// TODO: caching if trxName == null
|
||||
final String whereClause = "UPPER(ColumnName)=?";
|
||||
M_Element retValue = new Query(ctx, I_AD_Element.Table_Name, whereClause, trxName)
|
||||
.setParameters(columnName.toUpperCase())
|
||||
.firstOnly();
|
||||
return null;
|
||||
//
|
||||
// TODO: caching if trxName == null
|
||||
final String whereClause = "UPPER(ColumnName)=?";
|
||||
M_Element retValue = new Query(ctx, I_AD_Element.Table_Name, whereClause, trxName)
|
||||
.setParameters(columnName.toUpperCase())
|
||||
.firstOnly();
|
||||
return retValue;
|
||||
} // get
|
||||
|
||||
/**
|
||||
* Get Element
|
||||
* @param ctx context
|
||||
* @param columnName case insensitive column name
|
||||
/**
|
||||
* Get Element
|
||||
* @param ctx context
|
||||
* @param columnName case insensitive column name
|
||||
* @param trxName trx
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static M_Element getOfColumn (Properties ctx, int AD_Column_ID, String trxName)
|
||||
{
|
||||
if (AD_Column_ID ==0)
|
||||
return null;
|
||||
final String whereClause = "EXISTS (SELECT 1 FROM AD_Column c "
|
||||
+ "WHERE c.AD_Element_ID=AD_Element.AD_Element_ID AND c.AD_Column_ID=?)";
|
||||
M_Element retValue = new Query(ctx, Table_Name, whereClause, trxName)
|
||||
.setParameters(AD_Column_ID)
|
||||
.firstOnly();
|
||||
return retValue;
|
||||
} // get
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static M_Element getOfColumn (Properties ctx, int AD_Column_ID, String trxName)
|
||||
{
|
||||
if (AD_Column_ID ==0)
|
||||
return null;
|
||||
final String whereClause = "EXISTS (SELECT 1 FROM AD_Column c "
|
||||
+ "WHERE c.AD_Element_ID=AD_Element.AD_Element_ID AND c.AD_Column_ID=?)";
|
||||
M_Element retValue = new Query(ctx, Table_Name, whereClause, trxName)
|
||||
.setParameters(AD_Column_ID)
|
||||
.firstOnly();
|
||||
return retValue;
|
||||
} // get
|
||||
|
||||
/**
|
||||
* Get Element
|
||||
* @param ctx context
|
||||
* @param columnName case insentitive column name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static M_Element getOfColumn (Properties ctx, int AD_Column_ID)
|
||||
{
|
||||
return getOfColumn(ctx, AD_Column_ID, null);
|
||||
} // get
|
||||
/**
|
||||
* Get Element
|
||||
* @param ctx context
|
||||
* @param columnName case insentitive column name
|
||||
* @return case sensitive column name
|
||||
*/
|
||||
public static M_Element getOfColumn (Properties ctx, int AD_Column_ID)
|
||||
{
|
||||
return getOfColumn(ctx, AD_Column_ID, null);
|
||||
} // get
|
||||
|
||||
/**************************************************************************
|
||||
* Standard Constructor
|
||||
|
@ -177,30 +177,30 @@ public class M_Element extends X_AD_Element
|
|||
} // M_Element
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.compiere.model.PO#beforeSave(boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord) {
|
||||
// Column AD_Element.ColumnName should be unique - teo_sarca [ 1613107 ]
|
||||
if (newRecord || is_ValueChanged(COLUMNNAME_ColumnName)) {
|
||||
String columnName = getColumnName().trim();
|
||||
if (getColumnName().length() != columnName.length())
|
||||
setColumnName(columnName);
|
||||
|
||||
StringBuilder sql = new StringBuilder("select count(*) from AD_Element where UPPER(ColumnName)=?");
|
||||
if (!newRecord)
|
||||
sql.append(" AND AD_Element_ID<>").append(get_ID());
|
||||
int no = DB.getSQLValue(null, sql.toString(), columnName.toUpperCase());
|
||||
if (no > 0) {
|
||||
log.saveError(DBException.SAVE_ERROR_NOT_UNIQUE_MSG, Msg.getElement(getCtx(), COLUMNNAME_ColumnName));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.compiere.model.PO#beforeSave(boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord) {
|
||||
// Column AD_Element.ColumnName should be unique - teo_sarca [ 1613107 ]
|
||||
if (newRecord || is_ValueChanged(COLUMNNAME_ColumnName)) {
|
||||
String columnName = getColumnName().trim();
|
||||
if (getColumnName().length() != columnName.length())
|
||||
setColumnName(columnName);
|
||||
|
||||
StringBuilder sql = new StringBuilder("select count(*) from AD_Element where UPPER(ColumnName)=?");
|
||||
if (!newRecord)
|
||||
sql.append(" AND AD_Element_ID<>").append(get_ID());
|
||||
int no = DB.getSQLValue(null, sql.toString(), columnName.toUpperCase());
|
||||
if (no > 0) {
|
||||
log.saveError(DBException.SAVE_ERROR_NOT_UNIQUE_MSG, Msg.getElement(getCtx(), COLUMNNAME_ColumnName));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* After Save
|
||||
* @param newRecord new
|
||||
|
@ -208,118 +208,118 @@ public class M_Element extends X_AD_Element
|
|||
* @return success
|
||||
*/
|
||||
protected boolean afterSave (boolean newRecord, boolean success)
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
{
|
||||
if (!success)
|
||||
return success;
|
||||
// Update Columns, Fields, Parameters, Print Info
|
||||
if (!newRecord)
|
||||
{
|
||||
StringBuilder sql = new StringBuilder();
|
||||
int no = 0;
|
||||
{
|
||||
StringBuilder sql = new StringBuilder();
|
||||
int no = 0;
|
||||
|
||||
if ( is_ValueChanged(M_Element.COLUMNNAME_Name)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Description)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Help)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Placeholder)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_ColumnName)
|
||||
) {
|
||||
// Column
|
||||
sql = new StringBuilder("UPDATE AD_Column SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Element_ID=").append(get_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("afterSave - Columns updated #" + no);
|
||||
|
||||
// Parameter
|
||||
sql = new StringBuilder("UPDATE AD_Process_Para SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", AD_Element_ID=").append(get_ID())
|
||||
.append(" WHERE UPPER(ColumnName)=")
|
||||
.append(DB.TO_STRING(getColumnName().toUpperCase()))
|
||||
.append(" AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL");
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
|
||||
sql = new StringBuilder("UPDATE AD_Process_Para SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Element_ID=").append(get_ID())
|
||||
.append(" AND IsCentrallyMaintained='Y'");
|
||||
no += DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Parameters updated #" + no);
|
||||
|
||||
// Info Column
|
||||
sql = new StringBuilder("UPDATE AD_InfoColumn SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Element_ID=").append(get_ID())
|
||||
.append(" AND IsCentrallyMaintained='Y'");
|
||||
no += DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Info Column updated #" + no);
|
||||
}
|
||||
if ( is_ValueChanged(M_Element.COLUMNNAME_Name)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Description)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Help)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Placeholder)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_ColumnName)
|
||||
) {
|
||||
// Column
|
||||
sql = new StringBuilder("UPDATE AD_Column SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Element_ID=").append(get_ID());
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("afterSave - Columns updated #" + no);
|
||||
|
||||
// Parameter
|
||||
sql = new StringBuilder("UPDATE AD_Process_Para SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", AD_Element_ID=").append(get_ID())
|
||||
.append(" WHERE UPPER(ColumnName)=")
|
||||
.append(DB.TO_STRING(getColumnName().toUpperCase()))
|
||||
.append(" AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL");
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
|
||||
sql = new StringBuilder("UPDATE AD_Process_Para SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Element_ID=").append(get_ID())
|
||||
.append(" AND IsCentrallyMaintained='Y'");
|
||||
no += DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Parameters updated #" + no);
|
||||
|
||||
// Info Column
|
||||
sql = new StringBuilder("UPDATE AD_InfoColumn SET ColumnName=")
|
||||
.append(DB.TO_STRING(getColumnName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Element_ID=").append(get_ID())
|
||||
.append(" AND IsCentrallyMaintained='Y'");
|
||||
no += DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Info Column updated #" + no);
|
||||
}
|
||||
|
||||
if ( is_ValueChanged(M_Element.COLUMNNAME_Name)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Description)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Help)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Placeholder)
|
||||
) {
|
||||
// Field
|
||||
sql = new StringBuilder("UPDATE AD_Field SET Name=")
|
||||
.append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=")
|
||||
.append(get_ID())
|
||||
.append(") AND IsCentrallyMaintained='Y'");
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Fields updated #" + no);
|
||||
|
||||
// Info Column - update Name, Description, Help - doesn't have IsCentrallyMaintained currently
|
||||
// no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
// log.fine("InfoColumn updated #" + no);
|
||||
}
|
||||
|
||||
if ( is_ValueChanged(M_Element.COLUMNNAME_PrintName)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Name)
|
||||
) {
|
||||
// Print Info
|
||||
sql = new StringBuilder("UPDATE AD_PrintFormatItem SET PrintName=")
|
||||
.append(DB.TO_STRING(getPrintName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(" WHERE IsCentrallyMaintained='Y'")
|
||||
.append(" AND EXISTS (SELECT * FROM AD_Column c ")
|
||||
.append("WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=")
|
||||
.append(get_ID()).append(")");
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("PrintFormatItem updated #" + no);
|
||||
}
|
||||
|
||||
}
|
||||
return success;
|
||||
} // afterSave
|
||||
if ( is_ValueChanged(M_Element.COLUMNNAME_Name)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Description)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Help)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Placeholder)
|
||||
) {
|
||||
// Field
|
||||
sql = new StringBuilder("UPDATE AD_Field SET Name=")
|
||||
.append(DB.TO_STRING(getName()))
|
||||
.append(", Description=").append(DB.TO_STRING(getDescription()))
|
||||
.append(", Help=").append(DB.TO_STRING(getHelp()))
|
||||
.append(", Placeholder=").append(DB.TO_STRING(getPlaceholder()))
|
||||
.append(" WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=")
|
||||
.append(get_ID())
|
||||
.append(") AND IsCentrallyMaintained='Y'");
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Fields updated #" + no);
|
||||
|
||||
// Info Column - update Name, Description, Help - doesn't have IsCentrallyMaintained currently
|
||||
// no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
// log.fine("InfoColumn updated #" + no);
|
||||
}
|
||||
|
||||
if ( is_ValueChanged(M_Element.COLUMNNAME_PrintName)
|
||||
|| is_ValueChanged(M_Element.COLUMNNAME_Name)
|
||||
) {
|
||||
// Print Info
|
||||
sql = new StringBuilder("UPDATE AD_PrintFormatItem SET PrintName=")
|
||||
.append(DB.TO_STRING(getPrintName()))
|
||||
.append(", Name=").append(DB.TO_STRING(getName()))
|
||||
.append(" WHERE IsCentrallyMaintained='Y'")
|
||||
.append(" AND EXISTS (SELECT * FROM AD_Column c ")
|
||||
.append("WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=")
|
||||
.append(get_ID()).append(")");
|
||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("PrintFormatItem updated #" + no);
|
||||
}
|
||||
|
||||
}
|
||||
return success;
|
||||
} // afterSave
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("M_Element[");
|
||||
sb.append (get_ID()).append ("-").append (getColumnName()).append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("M_Element[");
|
||||
sb.append (get_ID()).append ("-").append (getColumnName()).append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
} // M_Element
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,13 +16,13 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Translation Table Management
|
||||
|
@ -120,7 +120,7 @@ public class TranslationTable
|
|||
m_baseTableName = baseTableName;
|
||||
m_trlTableName = baseTableName + "_Trl";
|
||||
initColumns();
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString());
|
||||
if (log.isLoggable(Level.FINE)) log.fine(toString());
|
||||
} // TranslationTable
|
||||
|
||||
/** Static Logger */
|
||||
|
@ -195,13 +195,13 @@ public class TranslationTable
|
|||
sql2.append(",b.").append(columnName);
|
||||
}
|
||||
//
|
||||
StringBuilder sql = new StringBuilder();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append(sql1).append(sql2)
|
||||
.append(" FROM AD_Language l, " + m_baseTableName
|
||||
+ " b WHERE l.IsActive = 'Y' AND l.IsSystemLanguage = 'Y' AND b."
|
||||
+ m_baseTableName + "_ID=").append(po.get_ID());
|
||||
int no = DB.executeUpdate(sql.toString(), po.get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine(m_trlTableName + ": ID=" + po.get_ID() + " #" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(m_trlTableName + ": ID=" + po.get_ID() + " #" + no);
|
||||
return no != 0;
|
||||
} // createTranslation
|
||||
|
||||
|
@ -217,12 +217,12 @@ public class TranslationTable
|
|||
if (po.get_ID() == 0)
|
||||
throw new IllegalArgumentException("PO ID is 0");
|
||||
//
|
||||
StringBuilder sb = new StringBuilder("UPDATE ");
|
||||
StringBuilder sb = new StringBuilder("UPDATE ");
|
||||
sb.append(m_trlTableName)
|
||||
.append(" SET IsTranslated='N',Updated=SysDate WHERE ")
|
||||
.append(m_baseTableName).append("_ID=").append(po.get_ID());
|
||||
int no = DB.executeUpdate(sb.toString(), po.get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine(m_trlTableName + ": ID=" + po.get_ID() + " #" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(m_trlTableName + ": ID=" + po.get_ID() + " #" + no);
|
||||
return no != 0;
|
||||
} // resetTranslationFlag
|
||||
|
||||
|
@ -235,15 +235,15 @@ public class TranslationTable
|
|||
{
|
||||
if (!isActiveLanguages(false))
|
||||
return true;
|
||||
if (po.get_IDOld() == 0)
|
||||
throw new IllegalArgumentException("PO Old ID is 0");
|
||||
//
|
||||
StringBuilder sb = new StringBuilder("DELETE FROM ");
|
||||
sb.append(m_trlTableName)
|
||||
.append(" WHERE ")
|
||||
.append(m_baseTableName).append("_ID=").append(po.get_IDOld());
|
||||
if (po.get_IDOld() == 0)
|
||||
throw new IllegalArgumentException("PO Old ID is 0");
|
||||
//
|
||||
StringBuilder sb = new StringBuilder("DELETE FROM ");
|
||||
sb.append(m_trlTableName)
|
||||
.append(" WHERE ")
|
||||
.append(m_baseTableName).append("_ID=").append(po.get_IDOld());
|
||||
int no = DB.executeUpdate(sb.toString(), po.get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine(m_trlTableName + ": ID=" + po.get_IDOld() + " #" + no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(m_trlTableName + ": ID=" + po.get_IDOld() + " #" + no);
|
||||
return no != 0;
|
||||
} // resetTranslationFlag
|
||||
|
||||
|
@ -253,7 +253,7 @@ public class TranslationTable
|
|||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("TranslationTable[");
|
||||
StringBuilder sb = new StringBuilder ("TranslationTable[");
|
||||
sb.append(m_trlTableName)
|
||||
.append("(").append(m_baseTableName).append(")");
|
||||
for (int i = 0; i < m_columns.size(); i++)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,151 +1,151 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.report;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.X_PA_ReportColumn;
|
||||
|
||||
/**
|
||||
* Report Column Model
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MReportColumn.java,v 1.3 2006/08/03 22:16:52 jjanke Exp $
|
||||
*/
|
||||
public class MReportColumn extends X_PA_ReportColumn
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2395905882810790219L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
* @param PA_ReportColumn_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MReportColumn (Properties ctx, int PA_ReportColumn_ID, String trxName)
|
||||
{
|
||||
super (ctx, PA_ReportColumn_ID, trxName);
|
||||
if (PA_ReportColumn_ID == 0)
|
||||
{
|
||||
setIsPrinted (true);
|
||||
setSeqNo (0);
|
||||
}
|
||||
} // MReportColumn
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
* @param rs ResultSet to load from
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MReportColumn (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // MReportColumn
|
||||
|
||||
/**************************************************************************
|
||||
* Get Column SQL Select Clause.
|
||||
* @param withSum with SUM() function
|
||||
* @return select clause - AmtAcctCR+AmtAcctDR/etc or "null" if not defined
|
||||
*/
|
||||
public String getSelectClause (boolean withSum)
|
||||
{
|
||||
String amountType = getPAAmountType(); // first character
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (withSum)
|
||||
sb.append("SUM(");
|
||||
if (PAAMOUNTTYPE_BalanceExpectedSign.equals(amountType))
|
||||
// sb.append("AmtAcctDr-AmtAcctCr");
|
||||
sb.append("acctBalance(Account_ID,AmtAcctDr,AmtAcctCr)");
|
||||
else if ( PAAMOUNTTYPE_BalanceAccountedSign.equals(amountType) )
|
||||
sb.append("AmtAcctDr-AmtAcctCr");
|
||||
else if (PAAMOUNTTYPE_CreditOnly.equals(amountType))
|
||||
sb.append("AmtAcctCr");
|
||||
else if (PAAMOUNTTYPE_DebitOnly.equals(amountType))
|
||||
sb.append("AmtAcctDr");
|
||||
else if (PAAMOUNTTYPE_QuantityAccountedSign.equals(amountType))
|
||||
sb.append("Qty");
|
||||
else if (PAAMOUNTTYPE_QuantityExpectedSign.equals(amountType))
|
||||
sb.append("acctBalance(Account_ID,Qty,0)");
|
||||
else
|
||||
{
|
||||
log.log(Level.SEVERE, "AmountType=" + getPAAmountType () + ", at=" + amountType);
|
||||
return "NULL";
|
||||
}
|
||||
if (withSum)
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
} // getSelectClause
|
||||
|
||||
/**
|
||||
* Is it Period Info ?
|
||||
* @return true if Period Amount Type
|
||||
*/
|
||||
public boolean isPeriod()
|
||||
{
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Period.equals(pt);
|
||||
} // isPeriod
|
||||
|
||||
/**
|
||||
* Is it Year Info ?
|
||||
* @return true if Year Amount Type
|
||||
*/
|
||||
public boolean isYear()
|
||||
{
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Year.equals(pt);
|
||||
} // isYear
|
||||
|
||||
/**
|
||||
* Is it Total Info ?
|
||||
* @return true if Year Amount Type
|
||||
*/
|
||||
public boolean isTotal()
|
||||
{
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Total.equals(pt);
|
||||
} // isTotalBalance
|
||||
|
||||
/**
|
||||
* Is it natural balance ?
|
||||
* Natural balance means year balance for profit and loss a/c, total balance for balance sheet account
|
||||
* @return true if Natural Balance Amount Type
|
||||
*/
|
||||
public boolean isNatural() {
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Natural.equals(pt);
|
||||
}
|
||||
|
||||
/**
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.report;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.X_PA_ReportColumn;
|
||||
|
||||
/**
|
||||
* Report Column Model
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MReportColumn.java,v 1.3 2006/08/03 22:16:52 jjanke Exp $
|
||||
*/
|
||||
public class MReportColumn extends X_PA_ReportColumn
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2395905882810790219L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
* @param PA_ReportColumn_ID id
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MReportColumn (Properties ctx, int PA_ReportColumn_ID, String trxName)
|
||||
{
|
||||
super (ctx, PA_ReportColumn_ID, trxName);
|
||||
if (PA_ReportColumn_ID == 0)
|
||||
{
|
||||
setIsPrinted (true);
|
||||
setSeqNo (0);
|
||||
}
|
||||
} // MReportColumn
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
* @param rs ResultSet to load from
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MReportColumn (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
} // MReportColumn
|
||||
|
||||
/**************************************************************************
|
||||
* Get Column SQL Select Clause.
|
||||
* @param withSum with SUM() function
|
||||
* @return select clause - AmtAcctCR+AmtAcctDR/etc or "null" if not defined
|
||||
*/
|
||||
public String getSelectClause (boolean withSum)
|
||||
{
|
||||
String amountType = getPAAmountType(); // first character
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (withSum)
|
||||
sb.append("SUM(");
|
||||
if (PAAMOUNTTYPE_BalanceExpectedSign.equals(amountType))
|
||||
// sb.append("AmtAcctDr-AmtAcctCr");
|
||||
sb.append("acctBalance(Account_ID,AmtAcctDr,AmtAcctCr)");
|
||||
else if ( PAAMOUNTTYPE_BalanceAccountedSign.equals(amountType) )
|
||||
sb.append("AmtAcctDr-AmtAcctCr");
|
||||
else if (PAAMOUNTTYPE_CreditOnly.equals(amountType))
|
||||
sb.append("AmtAcctCr");
|
||||
else if (PAAMOUNTTYPE_DebitOnly.equals(amountType))
|
||||
sb.append("AmtAcctDr");
|
||||
else if (PAAMOUNTTYPE_QuantityAccountedSign.equals(amountType))
|
||||
sb.append("Qty");
|
||||
else if (PAAMOUNTTYPE_QuantityExpectedSign.equals(amountType))
|
||||
sb.append("acctBalance(Account_ID,Qty,0)");
|
||||
else
|
||||
{
|
||||
log.log(Level.SEVERE, "AmountType=" + getPAAmountType () + ", at=" + amountType);
|
||||
return "NULL";
|
||||
}
|
||||
if (withSum)
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
} // getSelectClause
|
||||
|
||||
/**
|
||||
* Is it Period Info ?
|
||||
* @return true if Period Amount Type
|
||||
*/
|
||||
public boolean isPeriod()
|
||||
{
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Period.equals(pt);
|
||||
} // isPeriod
|
||||
|
||||
/**
|
||||
* Is it Year Info ?
|
||||
* @return true if Year Amount Type
|
||||
*/
|
||||
public boolean isYear()
|
||||
{
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Year.equals(pt);
|
||||
} // isYear
|
||||
|
||||
/**
|
||||
* Is it Total Info ?
|
||||
* @return true if Year Amount Type
|
||||
*/
|
||||
public boolean isTotal()
|
||||
{
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Total.equals(pt);
|
||||
} // isTotalBalance
|
||||
|
||||
/**
|
||||
* Is it natural balance ?
|
||||
* Natural balance means year balance for profit and loss a/c, total balance for balance sheet account
|
||||
* @return true if Natural Balance Amount Type
|
||||
*/
|
||||
public boolean isNatural() {
|
||||
String pt = getPAPeriodType();
|
||||
if (pt == null)
|
||||
return false;
|
||||
return PAPERIODTYPE_Natural.equals(pt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Segment Value Where Clause
|
||||
* @param PA_Hierarchy_ID hierarchy
|
||||
* @return where clause
|
||||
|
@ -155,281 +155,281 @@ public class MReportColumn extends X_PA_ReportColumn
|
|||
if (!isColumnTypeSegmentValue())
|
||||
return "";
|
||||
|
||||
String et = getElementType();
|
||||
// ID for Tree Leaf Value
|
||||
int ID = 0;
|
||||
//
|
||||
if (MReportColumn.ELEMENTTYPE_Account.equals(et))
|
||||
ID = getC_ElementValue_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Activity.equals(et))
|
||||
ID = getC_Activity_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_BPartner.equals(et))
|
||||
ID = getC_BPartner_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Campaign.equals(et))
|
||||
ID = getC_Campaign_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_LocationFrom.equals(et))
|
||||
ID = getC_Location_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_LocationTo.equals(et))
|
||||
ID = getC_Location_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Organization.equals(et))
|
||||
ID = getOrg_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Product.equals(et))
|
||||
ID = getM_Product_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Project.equals(et))
|
||||
ID = getC_Project_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_SalesRegion.equals(et))
|
||||
ID = getC_SalesRegion_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_OrgTrx.equals(et))
|
||||
ID = getOrg_ID(); // (re)uses Org_ID
|
||||
else if (MReportColumn.ELEMENTTYPE_UserElementList1.equals(et))
|
||||
ID = getC_ElementValue_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_UserElementList2.equals(et))
|
||||
ID = getC_ElementValue_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_UserColumn1.equals(et))
|
||||
return " AND UserElement1_ID="+getUserElement1_ID(); // Not Tree
|
||||
else if (MReportColumn.ELEMENTTYPE_UserColumn2.equals(et))
|
||||
return " AND UserElement2_ID="+getUserElement2_ID(); // Not Tree
|
||||
// Financial Report Source with Type Combination
|
||||
else if (MReportColumn.ELEMENTTYPE_Combination.equals(et))
|
||||
String et = getElementType();
|
||||
// ID for Tree Leaf Value
|
||||
int ID = 0;
|
||||
//
|
||||
if (MReportColumn.ELEMENTTYPE_Account.equals(et))
|
||||
ID = getC_ElementValue_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Activity.equals(et))
|
||||
ID = getC_Activity_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_BPartner.equals(et))
|
||||
ID = getC_BPartner_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Campaign.equals(et))
|
||||
ID = getC_Campaign_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_LocationFrom.equals(et))
|
||||
ID = getC_Location_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_LocationTo.equals(et))
|
||||
ID = getC_Location_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Organization.equals(et))
|
||||
ID = getOrg_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Product.equals(et))
|
||||
ID = getM_Product_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_Project.equals(et))
|
||||
ID = getC_Project_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_SalesRegion.equals(et))
|
||||
ID = getC_SalesRegion_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_OrgTrx.equals(et))
|
||||
ID = getOrg_ID(); // (re)uses Org_ID
|
||||
else if (MReportColumn.ELEMENTTYPE_UserElementList1.equals(et))
|
||||
ID = getC_ElementValue_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_UserElementList2.equals(et))
|
||||
ID = getC_ElementValue_ID();
|
||||
else if (MReportColumn.ELEMENTTYPE_UserColumn1.equals(et))
|
||||
return " AND UserElement1_ID="+getUserElement1_ID(); // Not Tree
|
||||
else if (MReportColumn.ELEMENTTYPE_UserColumn2.equals(et))
|
||||
return " AND UserElement2_ID="+getUserElement2_ID(); // Not Tree
|
||||
// Financial Report Source with Type Combination
|
||||
else if (MReportColumn.ELEMENTTYPE_Combination.equals(et))
|
||||
return getWhereCombination(PA_Hierarchy_ID);
|
||||
else
|
||||
log.warning("Unsupported Element Type=" + et);
|
||||
|
||||
if (ID == 0)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine("No Restrictions - No ID for EntityType=" + et);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("No Restrictions - No ID for EntityType=" + et);
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return " AND " + MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, et, ID);
|
||||
} // getWhereClause
|
||||
|
||||
/**
|
||||
* Obtain where clause for the combination type
|
||||
* @param PA_Hierarchy_ID
|
||||
* @return
|
||||
*/
|
||||
private String getWhereCombination(int PA_Hierarchy_ID) {
|
||||
StringBuilder whcomb = new StringBuilder();
|
||||
if (getC_ElementValue_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Account, getC_ElementValue_ID());
|
||||
if (isIncludeNullsElementValue())
|
||||
whcomb.append(" AND (Account_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsElementValue())
|
||||
whcomb.append(" AND Account_ID IS NULL");
|
||||
|
||||
if (getC_Activity_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Activity, getC_Activity_ID());
|
||||
if (isIncludeNullsActivity())
|
||||
whcomb.append(" AND (C_Activity_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsActivity())
|
||||
whcomb.append(" AND C_Activity_ID IS NULL");
|
||||
|
||||
if (getC_BPartner_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_BPartner, getC_BPartner_ID());
|
||||
if (isIncludeNullsBPartner())
|
||||
whcomb.append(" AND (C_BPartner_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsBPartner())
|
||||
whcomb.append(" AND C_BPartner_ID IS NULL");
|
||||
|
||||
if (getC_Campaign_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Campaign, getC_Campaign_ID());
|
||||
if (isIncludeNullsCampaign())
|
||||
whcomb.append(" AND (C_Campaign_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsCampaign())
|
||||
whcomb.append(" AND C_Campaign_ID IS NULL");
|
||||
|
||||
if (getC_Location_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_LocationFrom, getC_Location_ID());
|
||||
if (isIncludeNullsLocation())
|
||||
whcomb.append(" AND (C_LocFrom_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsLocation())
|
||||
whcomb.append(" AND C_LocFrom_ID IS NULL");
|
||||
|
||||
if (getOrg_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Organization, getOrg_ID());
|
||||
if (isIncludeNullsOrg())
|
||||
whcomb.append(" AND (AD_Org_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsOrg())
|
||||
whcomb.append(" AND AD_Org_ID IS NULL");
|
||||
|
||||
if (getAD_OrgTrx_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_OrgTrx, getAD_OrgTrx_ID());
|
||||
if (isIncludeNullsOrgTrx())
|
||||
whcomb.append(" AND (AD_OrgTrx_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsOrgTrx())
|
||||
whcomb.append(" AND AD_OrgTrx_ID IS NULL");
|
||||
|
||||
|
||||
if (getM_Product_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Product, getM_Product_ID());
|
||||
if (isIncludeNullsProduct())
|
||||
whcomb.append(" AND (M_Product_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsProduct())
|
||||
whcomb.append(" AND M_Product_ID IS NULL");
|
||||
|
||||
if (getC_Project_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Project, getC_Project_ID());
|
||||
if (isIncludeNullsProject())
|
||||
whcomb.append(" AND (C_Project_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsProject())
|
||||
whcomb.append(" AND C_Project_ID IS NULL");
|
||||
|
||||
if (getC_SalesRegion_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_SalesRegion, getC_SalesRegion_ID());
|
||||
if (isIncludeNullsSalesRegion())
|
||||
whcomb.append(" AND (C_SalesRegion_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsSalesRegion())
|
||||
whcomb.append(" AND C_SalesRegion_ID IS NULL");
|
||||
|
||||
if (getUserElement1_ID() > 0) {
|
||||
String whtree = "UserElement1_ID=" + getUserElement1_ID(); // No Tree
|
||||
if (isIncludeNullsUserElement1())
|
||||
whcomb.append(" AND (UserElement1_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsUserElement1())
|
||||
whcomb.append(" AND UserElement1_ID IS NULL");
|
||||
|
||||
if (getUserElement2_ID() > 0) {
|
||||
String whtree = "UserElement2_ID=" + getUserElement2_ID(); // No Tree
|
||||
if (isIncludeNullsUserElement2())
|
||||
whcomb.append(" AND (UserElement2_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsUserElement2())
|
||||
whcomb.append(" AND UserElement2_ID IS NULL");
|
||||
|
||||
return whcomb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get String Representation
|
||||
* @return String Representation
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("MReportColumn[")
|
||||
.append(get_ID()).append(" - ").append(getName()).append(" - ").append(getDescription())
|
||||
.append(", SeqNo=").append(getSeqNo()).append(", AmountType=").append(getPAAmountType())
|
||||
.append(", PeriodType=").append(getPAPeriodType())
|
||||
.append(", CurrencyType=").append(getCurrencyType()).append("/").append(getC_Currency_ID())
|
||||
.append(" - ColumnType=").append(getColumnType());
|
||||
if (isColumnTypeCalculation())
|
||||
sb.append(" - Calculation=").append(getCalculationType())
|
||||
.append(" - ").append(getOper_1_ID()).append(" - ").append(getOper_2_ID());
|
||||
else if (isColumnTypeRelativePeriod())
|
||||
sb.append(" - Period=").append(getRelativePeriod());
|
||||
else
|
||||
sb.append(" - SegmentValue ElementType=").append(getElementType());
|
||||
sb.append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Calculation Type Range
|
||||
* @return true if range
|
||||
*/
|
||||
public boolean isCalculationTypeRange()
|
||||
{
|
||||
return CALCULATIONTYPE_AddRangeOp1ToOp2.equals(getCalculationType());
|
||||
}
|
||||
/**
|
||||
* Calculation Type Add
|
||||
* @return true id add
|
||||
*/
|
||||
public boolean isCalculationTypeAdd()
|
||||
{
|
||||
return CALCULATIONTYPE_AddOp1PlusOp2.equals(getCalculationType());
|
||||
}
|
||||
/**
|
||||
* Calculation Type Subtract
|
||||
* @return true if subtract
|
||||
*/
|
||||
public boolean isCalculationTypeSubtract()
|
||||
{
|
||||
return CALCULATIONTYPE_SubtractOp1_Op2.equals(getCalculationType());
|
||||
}
|
||||
/**
|
||||
* Calculation Type Percent
|
||||
* @return true if percent
|
||||
*/
|
||||
public boolean isCalculationTypePercent()
|
||||
{
|
||||
return CALCULATIONTYPE_PercentageOp1OfOp2.equals(getCalculationType());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Column Type Calculation
|
||||
* @return true if calculation
|
||||
*/
|
||||
public boolean isColumnTypeCalculation()
|
||||
{
|
||||
return COLUMNTYPE_Calculation.equals(getColumnType());
|
||||
}
|
||||
/**
|
||||
* Column Type Relative Period
|
||||
* @return true if relative period
|
||||
*/
|
||||
public boolean isColumnTypeRelativePeriod()
|
||||
{
|
||||
return COLUMNTYPE_RelativePeriod.equals(getColumnType());
|
||||
}
|
||||
/**
|
||||
* Column Type Segment Value
|
||||
* @return true if segment value
|
||||
*/
|
||||
public boolean isColumnTypeSegmentValue()
|
||||
{
|
||||
return COLUMNTYPE_SegmentValue.equals(getColumnType());
|
||||
}
|
||||
/**
|
||||
* Get Relative Period As Int
|
||||
* @return relative period
|
||||
*/
|
||||
public int getRelativePeriodAsInt ()
|
||||
{
|
||||
BigDecimal bd = getRelativePeriod();
|
||||
if (bd == null)
|
||||
return 0;
|
||||
return bd.intValue();
|
||||
} // getRelativePeriodAsInt
|
||||
|
||||
|
||||
/**
|
||||
* Obtain where clause for the combination type
|
||||
* @param PA_Hierarchy_ID
|
||||
* @return
|
||||
*/
|
||||
private String getWhereCombination(int PA_Hierarchy_ID) {
|
||||
StringBuilder whcomb = new StringBuilder();
|
||||
if (getC_ElementValue_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Account, getC_ElementValue_ID());
|
||||
if (isIncludeNullsElementValue())
|
||||
whcomb.append(" AND (Account_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsElementValue())
|
||||
whcomb.append(" AND Account_ID IS NULL");
|
||||
|
||||
if (getC_Activity_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Activity, getC_Activity_ID());
|
||||
if (isIncludeNullsActivity())
|
||||
whcomb.append(" AND (C_Activity_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsActivity())
|
||||
whcomb.append(" AND C_Activity_ID IS NULL");
|
||||
|
||||
if (getC_BPartner_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_BPartner, getC_BPartner_ID());
|
||||
if (isIncludeNullsBPartner())
|
||||
whcomb.append(" AND (C_BPartner_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsBPartner())
|
||||
whcomb.append(" AND C_BPartner_ID IS NULL");
|
||||
|
||||
if (getC_Campaign_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Campaign, getC_Campaign_ID());
|
||||
if (isIncludeNullsCampaign())
|
||||
whcomb.append(" AND (C_Campaign_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsCampaign())
|
||||
whcomb.append(" AND C_Campaign_ID IS NULL");
|
||||
|
||||
if (getC_Location_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_LocationFrom, getC_Location_ID());
|
||||
if (isIncludeNullsLocation())
|
||||
whcomb.append(" AND (C_LocFrom_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsLocation())
|
||||
whcomb.append(" AND C_LocFrom_ID IS NULL");
|
||||
|
||||
if (getOrg_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Organization, getOrg_ID());
|
||||
if (isIncludeNullsOrg())
|
||||
whcomb.append(" AND (AD_Org_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsOrg())
|
||||
whcomb.append(" AND AD_Org_ID IS NULL");
|
||||
|
||||
if (getAD_OrgTrx_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_OrgTrx, getAD_OrgTrx_ID());
|
||||
if (isIncludeNullsOrgTrx())
|
||||
whcomb.append(" AND (AD_OrgTrx_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsOrgTrx())
|
||||
whcomb.append(" AND AD_OrgTrx_ID IS NULL");
|
||||
|
||||
|
||||
if (getM_Product_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Product, getM_Product_ID());
|
||||
if (isIncludeNullsProduct())
|
||||
whcomb.append(" AND (M_Product_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsProduct())
|
||||
whcomb.append(" AND M_Product_ID IS NULL");
|
||||
|
||||
if (getC_Project_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_Project, getC_Project_ID());
|
||||
if (isIncludeNullsProject())
|
||||
whcomb.append(" AND (C_Project_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsProject())
|
||||
whcomb.append(" AND C_Project_ID IS NULL");
|
||||
|
||||
if (getC_SalesRegion_ID() > 0) {
|
||||
String whtree = MReportTree.getWhereClause (getCtx(), PA_Hierarchy_ID, MReportColumn.ELEMENTTYPE_SalesRegion, getC_SalesRegion_ID());
|
||||
if (isIncludeNullsSalesRegion())
|
||||
whcomb.append(" AND (C_SalesRegion_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsSalesRegion())
|
||||
whcomb.append(" AND C_SalesRegion_ID IS NULL");
|
||||
|
||||
if (getUserElement1_ID() > 0) {
|
||||
String whtree = "UserElement1_ID=" + getUserElement1_ID(); // No Tree
|
||||
if (isIncludeNullsUserElement1())
|
||||
whcomb.append(" AND (UserElement1_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsUserElement1())
|
||||
whcomb.append(" AND UserElement1_ID IS NULL");
|
||||
|
||||
if (getUserElement2_ID() > 0) {
|
||||
String whtree = "UserElement2_ID=" + getUserElement2_ID(); // No Tree
|
||||
if (isIncludeNullsUserElement2())
|
||||
whcomb.append(" AND (UserElement2_ID IS NULL OR ").append(whtree).append(")");
|
||||
else
|
||||
whcomb.append(" AND ").append(whtree);
|
||||
} else
|
||||
if (isIncludeNullsUserElement2())
|
||||
whcomb.append(" AND UserElement2_ID IS NULL");
|
||||
|
||||
return whcomb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get String Representation
|
||||
* @return String Representation
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("MReportColumn[")
|
||||
.append(get_ID()).append(" - ").append(getName()).append(" - ").append(getDescription())
|
||||
.append(", SeqNo=").append(getSeqNo()).append(", AmountType=").append(getPAAmountType())
|
||||
.append(", PeriodType=").append(getPAPeriodType())
|
||||
.append(", CurrencyType=").append(getCurrencyType()).append("/").append(getC_Currency_ID())
|
||||
.append(" - ColumnType=").append(getColumnType());
|
||||
if (isColumnTypeCalculation())
|
||||
sb.append(" - Calculation=").append(getCalculationType())
|
||||
.append(" - ").append(getOper_1_ID()).append(" - ").append(getOper_2_ID());
|
||||
else if (isColumnTypeRelativePeriod())
|
||||
sb.append(" - Period=").append(getRelativePeriod());
|
||||
else
|
||||
sb.append(" - SegmentValue ElementType=").append(getElementType());
|
||||
sb.append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Calculation Type Range
|
||||
* @return true if range
|
||||
*/
|
||||
public boolean isCalculationTypeRange()
|
||||
{
|
||||
return CALCULATIONTYPE_AddRangeOp1ToOp2.equals(getCalculationType());
|
||||
}
|
||||
/**
|
||||
* Calculation Type Add
|
||||
* @return true id add
|
||||
*/
|
||||
public boolean isCalculationTypeAdd()
|
||||
{
|
||||
return CALCULATIONTYPE_AddOp1PlusOp2.equals(getCalculationType());
|
||||
}
|
||||
/**
|
||||
* Calculation Type Subtract
|
||||
* @return true if subtract
|
||||
*/
|
||||
public boolean isCalculationTypeSubtract()
|
||||
{
|
||||
return CALCULATIONTYPE_SubtractOp1_Op2.equals(getCalculationType());
|
||||
}
|
||||
/**
|
||||
* Calculation Type Percent
|
||||
* @return true if percent
|
||||
*/
|
||||
public boolean isCalculationTypePercent()
|
||||
{
|
||||
return CALCULATIONTYPE_PercentageOp1OfOp2.equals(getCalculationType());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Column Type Calculation
|
||||
* @return true if calculation
|
||||
*/
|
||||
public boolean isColumnTypeCalculation()
|
||||
{
|
||||
return COLUMNTYPE_Calculation.equals(getColumnType());
|
||||
}
|
||||
/**
|
||||
* Column Type Relative Period
|
||||
* @return true if relative period
|
||||
*/
|
||||
public boolean isColumnTypeRelativePeriod()
|
||||
{
|
||||
return COLUMNTYPE_RelativePeriod.equals(getColumnType());
|
||||
}
|
||||
/**
|
||||
* Column Type Segment Value
|
||||
* @return true if segment value
|
||||
*/
|
||||
public boolean isColumnTypeSegmentValue()
|
||||
{
|
||||
return COLUMNTYPE_SegmentValue.equals(getColumnType());
|
||||
}
|
||||
/**
|
||||
* Get Relative Period As Int
|
||||
* @return relative period
|
||||
*/
|
||||
public int getRelativePeriodAsInt ()
|
||||
{
|
||||
BigDecimal bd = getRelativePeriod();
|
||||
if (bd == null)
|
||||
return 0;
|
||||
return bd.intValue();
|
||||
} // getRelativePeriodAsInt
|
||||
|
||||
/**
|
||||
* Get Relative Period
|
||||
* @return relative period
|
||||
|
@ -442,75 +442,75 @@ public class MReportColumn extends X_PA_ReportColumn
|
|||
return super.getRelativePeriod();
|
||||
return null;
|
||||
} // getRelativePeriod
|
||||
/**
|
||||
* Get Element Type
|
||||
*/
|
||||
@Override
|
||||
public String getElementType()
|
||||
{
|
||||
if (getColumnType().equals(COLUMNTYPE_SegmentValue))
|
||||
return super.getElementType();
|
||||
return null;
|
||||
} // getElementType
|
||||
|
||||
/**
|
||||
* Get Calculation Type
|
||||
*/
|
||||
@Override
|
||||
public String getCalculationType()
|
||||
{
|
||||
if (getColumnType().equals(COLUMNTYPE_Calculation))
|
||||
return super.getCalculationType();
|
||||
return null;
|
||||
} // getCalculationType
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord)
|
||||
{
|
||||
// Validate Type
|
||||
String ct = getColumnType();
|
||||
if (ct.equals(COLUMNTYPE_RelativePeriod))
|
||||
{
|
||||
setElementType(null);
|
||||
setCalculationType(null);
|
||||
}
|
||||
else if (ct.equals(COLUMNTYPE_Calculation))
|
||||
{
|
||||
setElementType(null);
|
||||
setRelativePeriod(null);
|
||||
}
|
||||
else if (ct.equals(COLUMNTYPE_SegmentValue))
|
||||
{
|
||||
setCalculationType(null);
|
||||
}
|
||||
return true;
|
||||
} // beforeSave
|
||||
/**************************************************************************
|
||||
|
||||
/**
|
||||
* Copy
|
||||
* @param ctx context
|
||||
* @param AD_Client_ID parent
|
||||
* @param AD_Org_ID parent
|
||||
* @param PA_ReportColumnSet_ID parent
|
||||
* @param source copy source
|
||||
* @param trxName transaction
|
||||
* @return Report Column
|
||||
*/
|
||||
public static MReportColumn copy (Properties ctx, int AD_Client_ID, int AD_Org_ID,
|
||||
int PA_ReportColumnSet_ID, MReportColumn source, String trxName)
|
||||
{
|
||||
MReportColumn retValue = new MReportColumn (ctx, 0, trxName);
|
||||
MReportColumn.copyValues(source, retValue, AD_Client_ID, AD_Org_ID);
|
||||
//
|
||||
retValue.setPA_ReportColumnSet_ID(PA_ReportColumnSet_ID); // parent
|
||||
retValue.setOper_1_ID(0);
|
||||
retValue.setOper_2_ID(0);
|
||||
return retValue;
|
||||
} // copy
|
||||
} // MReportColumn
|
||||
/**
|
||||
* Get Element Type
|
||||
*/
|
||||
@Override
|
||||
public String getElementType()
|
||||
{
|
||||
if (getColumnType().equals(COLUMNTYPE_SegmentValue))
|
||||
return super.getElementType();
|
||||
return null;
|
||||
} // getElementType
|
||||
|
||||
/**
|
||||
* Get Calculation Type
|
||||
*/
|
||||
@Override
|
||||
public String getCalculationType()
|
||||
{
|
||||
if (getColumnType().equals(COLUMNTYPE_Calculation))
|
||||
return super.getCalculationType();
|
||||
return null;
|
||||
} // getCalculationType
|
||||
|
||||
/**
|
||||
* Before Save
|
||||
* @param newRecord new
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord)
|
||||
{
|
||||
// Validate Type
|
||||
String ct = getColumnType();
|
||||
if (ct.equals(COLUMNTYPE_RelativePeriod))
|
||||
{
|
||||
setElementType(null);
|
||||
setCalculationType(null);
|
||||
}
|
||||
else if (ct.equals(COLUMNTYPE_Calculation))
|
||||
{
|
||||
setElementType(null);
|
||||
setRelativePeriod(null);
|
||||
}
|
||||
else if (ct.equals(COLUMNTYPE_SegmentValue))
|
||||
{
|
||||
setCalculationType(null);
|
||||
}
|
||||
return true;
|
||||
} // beforeSave
|
||||
/**************************************************************************
|
||||
|
||||
/**
|
||||
* Copy
|
||||
* @param ctx context
|
||||
* @param AD_Client_ID parent
|
||||
* @param AD_Org_ID parent
|
||||
* @param PA_ReportColumnSet_ID parent
|
||||
* @param source copy source
|
||||
* @param trxName transaction
|
||||
* @return Report Column
|
||||
*/
|
||||
public static MReportColumn copy (Properties ctx, int AD_Client_ID, int AD_Org_ID,
|
||||
int PA_ReportColumnSet_ID, MReportColumn source, String trxName)
|
||||
{
|
||||
MReportColumn retValue = new MReportColumn (ctx, 0, trxName);
|
||||
MReportColumn.copyValues(source, retValue, AD_Client_ID, AD_Org_ID);
|
||||
//
|
||||
retValue.setPA_ReportColumnSet_ID(PA_ReportColumnSet_ID); // parent
|
||||
retValue.setOper_1_ID(0);
|
||||
retValue.setOper_2_ID(0);
|
||||
return retValue;
|
||||
} // copy
|
||||
} // MReportColumn
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -11,23 +11,23 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.compiere.util;
|
||||
|
||||
/**
|
||||
* Amount in Words for Bahasa Indonesia
|
||||
*
|
||||
* Bugs item #1569711: remove hard-coded "Rupiah" to support all currency
|
||||
* Contributor: Armen Rizal (www.goodwill.co.id)
|
||||
*
|
||||
* @author Halim Englen
|
||||
* @version $Id: AmtInWords_IN.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
|
||||
*/
|
||||
public class AmtInWords_IN implements AmtInWords
|
||||
{
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.compiere.util;
|
||||
|
||||
/**
|
||||
* Amount in Words for Bahasa Indonesia
|
||||
*
|
||||
* Bugs item #1569711: remove hard-coded "Rupiah" to support all currency
|
||||
* Contributor: Armen Rizal (www.goodwill.co.id)
|
||||
*
|
||||
* @author Halim Englen
|
||||
* @version $Id: AmtInWords_IN.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
|
||||
*/
|
||||
public class AmtInWords_IN implements AmtInWords
|
||||
{
|
||||
/**
|
||||
* AmtInWords_IN
|
||||
*/
|
||||
|
@ -47,100 +47,100 @@ public class AmtInWords_IN implements AmtInWords
|
|||
"Tujuh",
|
||||
"Delapan",
|
||||
"Sembilan",
|
||||
"Sepuluh",
|
||||
"Sebelas",
|
||||
};
|
||||
|
||||
private static final long POWER_THREE = 1000L;
|
||||
private static final long POWER_SIX = 1000000L;
|
||||
private static final long POWER_NINE = 1000000000L;
|
||||
private static final long POWER_TWELVE = 1000000000000L;
|
||||
private static final long POWER_FIFTEEN = 1000000000000000L;
|
||||
|
||||
/** Static Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger (AmtInWords_IN.class);
|
||||
|
||||
//-------------------------- STATIC METHODS --------------------------
|
||||
|
||||
"Sepuluh",
|
||||
"Sebelas",
|
||||
};
|
||||
|
||||
private static final long POWER_THREE = 1000L;
|
||||
private static final long POWER_SIX = 1000000L;
|
||||
private static final long POWER_NINE = 1000000000L;
|
||||
private static final long POWER_TWELVE = 1000000000000L;
|
||||
private static final long POWER_FIFTEEN = 1000000000000000L;
|
||||
|
||||
/** Static Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger (AmtInWords_IN.class);
|
||||
|
||||
//-------------------------- STATIC METHODS --------------------------
|
||||
|
||||
/**
|
||||
* Convenient method for {@link #sayNumber(StringBuffer, long)}.
|
||||
*
|
||||
* @param number number to say
|
||||
* @return said number
|
||||
*/
|
||||
public static String sayNumber(double number) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
sayNumber(result, number);
|
||||
//result.append(" Rupiah");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
* @param number number to say
|
||||
* @return said number
|
||||
*/
|
||||
public static String sayNumber(double number) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
sayNumber(result, number);
|
||||
//result.append(" Rupiah");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Say a number. This method will append the result to the given string buffer.
|
||||
*
|
||||
* @param appendTo the string buffer
|
||||
* @param number number to say
|
||||
* @return said number
|
||||
* @throws IllegalArgumentException if the number equals to {@link Long#MIN_VALUE}
|
||||
*/
|
||||
public static String sayNumber(StringBuffer appendTo, double number)
|
||||
throws IllegalArgumentException {
|
||||
if (number == Double.MIN_VALUE) {
|
||||
throw new IllegalArgumentException("Out of range");
|
||||
}
|
||||
if (number < 0) {
|
||||
appendTo.append("Minus ");
|
||||
}
|
||||
double abs = Math.abs(number);
|
||||
// s_log.warning("Debug=" + abs);
|
||||
if (abs < POWER_THREE) {
|
||||
saySimpleNumber(appendTo, (int) abs);
|
||||
} else if (abs < 2000) {
|
||||
int thousand = (int) (abs % POWER_THREE);
|
||||
appendTo.append("Seribu ");
|
||||
saySimpleNumber(appendTo, thousand);
|
||||
} else if (abs < POWER_SIX) {
|
||||
int thousand = (int) (abs % POWER_SIX / POWER_THREE);
|
||||
saySimpleNumber(appendTo, thousand);
|
||||
appendTo.append(" Ribu");
|
||||
double remainder = abs - thousand * POWER_THREE;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
* @return said number
|
||||
* @throws IllegalArgumentException if the number equals to {@link Long#MIN_VALUE}
|
||||
*/
|
||||
public static String sayNumber(StringBuffer appendTo, double number)
|
||||
throws IllegalArgumentException {
|
||||
if (number == Double.MIN_VALUE) {
|
||||
throw new IllegalArgumentException("Out of range");
|
||||
}
|
||||
if (number < 0) {
|
||||
appendTo.append("Minus ");
|
||||
}
|
||||
double abs = Math.abs(number);
|
||||
// s_log.warning("Debug=" + abs);
|
||||
if (abs < POWER_THREE) {
|
||||
saySimpleNumber(appendTo, (int) abs);
|
||||
} else if (abs < 2000) {
|
||||
int thousand = (int) (abs % POWER_THREE);
|
||||
appendTo.append("Seribu ");
|
||||
saySimpleNumber(appendTo, thousand);
|
||||
} else if (abs < POWER_SIX) {
|
||||
int thousand = (int) (abs % POWER_SIX / POWER_THREE);
|
||||
saySimpleNumber(appendTo, thousand);
|
||||
appendTo.append(" Ribu");
|
||||
double remainder = abs - thousand * POWER_THREE;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
}
|
||||
} else if (abs < POWER_NINE) {
|
||||
int million = (int) (abs % POWER_NINE / POWER_SIX);
|
||||
saySimpleNumber(appendTo, million);
|
||||
appendTo.append(" Juta");
|
||||
double remainder = abs - million * POWER_SIX;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
int million = (int) (abs % POWER_NINE / POWER_SIX);
|
||||
saySimpleNumber(appendTo, million);
|
||||
appendTo.append(" Juta");
|
||||
double remainder = abs - million * POWER_SIX;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
}
|
||||
} else if (abs < POWER_TWELVE) {
|
||||
int billion = (int) (abs % POWER_TWELVE / POWER_NINE);
|
||||
saySimpleNumber(appendTo, billion);
|
||||
appendTo.append(" Milyar");
|
||||
double remainder = abs - billion * POWER_NINE;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
int billion = (int) (abs % POWER_TWELVE / POWER_NINE);
|
||||
saySimpleNumber(appendTo, billion);
|
||||
appendTo.append(" Milyar");
|
||||
double remainder = abs - billion * POWER_NINE;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
}
|
||||
} else if (abs < POWER_FIFTEEN) {
|
||||
int trillion = (int) (abs % POWER_FIFTEEN / POWER_TWELVE);
|
||||
saySimpleNumber(appendTo, trillion);
|
||||
appendTo.append(" Trilyun");
|
||||
double remainder = abs - trillion * POWER_TWELVE;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
}
|
||||
} else {
|
||||
appendTo.append("Lebih Dari Seribu Triliun");
|
||||
}
|
||||
return appendTo.toString();
|
||||
}
|
||||
int trillion = (int) (abs % POWER_FIFTEEN / POWER_TWELVE);
|
||||
saySimpleNumber(appendTo, trillion);
|
||||
appendTo.append(" Trilyun");
|
||||
double remainder = abs - trillion * POWER_TWELVE;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
sayNumber(appendTo, remainder);
|
||||
}
|
||||
} else {
|
||||
appendTo.append("Lebih Dari Seribu Triliun");
|
||||
}
|
||||
return appendTo.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -185,42 +185,42 @@ public class AmtInWords_IN implements AmtInWords
|
|||
appendTo.append(" Ratus");
|
||||
int remainder = number - ratusan * 100;
|
||||
if (remainder > 0) {
|
||||
appendTo.append(' ');
|
||||
saySimpleNumber(appendTo, remainder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appendTo.append(' ');
|
||||
saySimpleNumber(appendTo, remainder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Get Amount in Words
|
||||
* @param amount numeric amount (352.80)
|
||||
* @return amount in words (three*five*two 80/100)
|
||||
*/
|
||||
public String getAmtInWords (String amount) throws Exception
|
||||
{
|
||||
if (amount == null)
|
||||
return amount;
|
||||
//
|
||||
StringBuffer result = new StringBuffer();
|
||||
|
||||
int pos = amount.lastIndexOf ('.');
|
||||
String oldamt = amount;
|
||||
amount = amount.replaceAll (",", "");
|
||||
String cents = pos > 0 ? oldamt.substring (pos + 1):null;
|
||||
double numDouble = Double.parseDouble(amount);
|
||||
sayNumber(result, numDouble);
|
||||
if (cents != null)
|
||||
{
|
||||
result.append(" Koma ");
|
||||
numDouble = Double.parseDouble(cents);
|
||||
sayNumber(result, numDouble);
|
||||
}
|
||||
//result.append(" Rupiah");
|
||||
return result.toString();
|
||||
} // getAmtInWords
|
||||
|
||||
/**
|
||||
* Get Amount in Words
|
||||
* @param amount numeric amount (352.80)
|
||||
* @return amount in words (three*five*two 80/100)
|
||||
*/
|
||||
public String getAmtInWords (String amount) throws Exception
|
||||
{
|
||||
if (amount == null)
|
||||
return amount;
|
||||
//
|
||||
StringBuffer result = new StringBuffer();
|
||||
|
||||
int pos = amount.lastIndexOf ('.');
|
||||
String oldamt = amount;
|
||||
amount = amount.replaceAll (",", "");
|
||||
String cents = pos > 0 ? oldamt.substring (pos + 1):null;
|
||||
double numDouble = Double.parseDouble(amount);
|
||||
sayNumber(result, numDouble);
|
||||
if (cents != null)
|
||||
{
|
||||
result.append(" Koma ");
|
||||
numDouble = Double.parseDouble(cents);
|
||||
sayNumber(result, numDouble);
|
||||
}
|
||||
//result.append(" Rupiah");
|
||||
return result.toString();
|
||||
} // getAmtInWords
|
||||
|
||||
/**
|
||||
* Test Print
|
||||
* @param amt amount
|
||||
*/
|
||||
|
@ -240,29 +240,29 @@ public class AmtInWords_IN implements AmtInWords
|
|||
* Test
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main (String[] args)
|
||||
{
|
||||
AmtInWords_IN aiw = new AmtInWords_IN();
|
||||
aiw.print ("0.00");
|
||||
aiw.print ("0.23");
|
||||
aiw.print ("1.23876787");
|
||||
aiw.print ("11.45");
|
||||
aiw.print ("121.45");
|
||||
aiw.print ("1231.56");
|
||||
aiw.print ("10341.78");
|
||||
aiw.print ("12341.78");
|
||||
aiw.print ("123451.89");
|
||||
aiw.print ("12234571.90");
|
||||
aiw.print ("123234571.90");
|
||||
aiw.print ("1987234571.90");
|
||||
aiw.print ("11123234571.90");
|
||||
aiw.print ("123123234571.90");
|
||||
aiw.print ("2123123234571.90");
|
||||
aiw.print ("23,123,123,234,571.90");
|
||||
aiw.print ("100,000,000,000,000.90");
|
||||
aiw.print ("111,111,111");
|
||||
aiw.print ("222,222,222,222,222");
|
||||
aiw.print ("222,222,222,222,222,222,222");
|
||||
} // main
|
||||
|
||||
} // AmtInWords_IN
|
||||
public static void main (String[] args)
|
||||
{
|
||||
AmtInWords_IN aiw = new AmtInWords_IN();
|
||||
aiw.print ("0.00");
|
||||
aiw.print ("0.23");
|
||||
aiw.print ("1.23876787");
|
||||
aiw.print ("11.45");
|
||||
aiw.print ("121.45");
|
||||
aiw.print ("1231.56");
|
||||
aiw.print ("10341.78");
|
||||
aiw.print ("12341.78");
|
||||
aiw.print ("123451.89");
|
||||
aiw.print ("12234571.90");
|
||||
aiw.print ("123234571.90");
|
||||
aiw.print ("1987234571.90");
|
||||
aiw.print ("11123234571.90");
|
||||
aiw.print ("123123234571.90");
|
||||
aiw.print ("2123123234571.90");
|
||||
aiw.print ("23,123,123,234,571.90");
|
||||
aiw.print ("100,000,000,000,000.90");
|
||||
aiw.print ("111,111,111");
|
||||
aiw.print ("222,222,222,222,222");
|
||||
aiw.print ("222,222,222,222,222,222,222");
|
||||
} // main
|
||||
|
||||
} // AmtInWords_IN
|
||||
|
|
|
@ -1,263 +1,263 @@
|
|||
/******************************************************************************
|
||||
* 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. *
|
||||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
/**
|
||||
*Amount in Words for Serbia.
|
||||
* @author Nikola Petkov -The class is based on the AmtInWords_EN.java written
|
||||
* by jjanke
|
||||
*/
|
||||
public class AmtInWords_SR
|
||||
implements AmtInWords
|
||||
{
|
||||
|
||||
/**
|
||||
* AmtInWords_RS
|
||||
*/
|
||||
public AmtInWords_SR()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
private static final String zero = "Nula";
|
||||
|
||||
private static final String negative = "minus";
|
||||
|
||||
private static final String concat = "i";
|
||||
|
||||
private static final String din[] =
|
||||
{"dinar", "dinara"};
|
||||
|
||||
/** Thousands plus */
|
||||
private static final String[][] majorNames =
|
||||
{
|
||||
{"", "", ""},
|
||||
{"Hiljadu", "Hiljade", "Hiljada"},
|
||||
{"Milion", "Miliona", "Miliona"},
|
||||
{"Milijarda", "Milijarde", "Milijardi"},
|
||||
{"Bilion", "Biliona", "Biliona"},
|
||||
{"Bilijarda", "Bilijarde", "Bilijardi"},
|
||||
{"Trilion", "Triliona", "Triliona"}};
|
||||
|
||||
/** Ten to Ninety */
|
||||
private static final String[] tensNames =
|
||||
{"", "Deset", "Dvadeset", "Trideset", "Četrdeset", "Pedeset", "Šestdeset",
|
||||
"Sedamdeset", "Osamdeset", "Devedeset"};
|
||||
|
||||
/* 100-1000 */
|
||||
private static final String[] hundredNames =
|
||||
{"", "JednaStotina", "DveStotine", "TriStotine", "ČetiriStotine",
|
||||
"PetStotina", "ŠestStotina", "SedamStotina", "OsamStotina",
|
||||
"DevetStotina"};
|
||||
|
||||
/** numbers to 19 */
|
||||
private static final String[][] numNames =
|
||||
{
|
||||
{"", ""},
|
||||
{"Jedan", "Jedna"},
|
||||
{"Dva", "Dve"},
|
||||
{"Tri", "Tri"},
|
||||
{"Četiri", "Četiri"},
|
||||
{"Pet", "Pet"},
|
||||
{"Šest", "Šest"},
|
||||
{"Sedam", "Sedam"},
|
||||
{"Osam", "Osam"},
|
||||
{"Devet", "Devet"},
|
||||
{"Deset", "Deset"},
|
||||
{"Jedanaest", "Jedanast"},
|
||||
{"Dvanaeset", "Dvanaest"},
|
||||
{"Trinaeset", "Trinaest"},
|
||||
{"Četrnaest", "Četrnaest"},
|
||||
{"Petnaest", "Petnaest"},
|
||||
{"Šestnaest", "Šestnaest"},
|
||||
{"Sedamnaest", "Sedamnaest"},
|
||||
{"Osamnaest", "Osamnaest"},
|
||||
{"Devetnaest", "Devetnaest"}};
|
||||
|
||||
/**
|
||||
*Convert Less Than One Thousand
|
||||
* @param number
|
||||
*@return amt
|
||||
*/
|
||||
private String convertLessThanOneThousand(int number, int w)
|
||||
{
|
||||
String soFar;
|
||||
// Below 20
|
||||
if (number % 100 < 20)
|
||||
{
|
||||
soFar = numNames[number % 100][w];
|
||||
number /= 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
soFar = numNames[number % 10][w];
|
||||
number /= 10;
|
||||
if (soFar.compareTo ("") == 0)
|
||||
{
|
||||
soFar = tensNames[number % 10];
|
||||
}
|
||||
else
|
||||
{
|
||||
soFar = tensNames[number % 10] + concat + soFar;
|
||||
}
|
||||
number /= 10;
|
||||
}
|
||||
if (number == 0)
|
||||
return soFar;
|
||||
return hundredNames[number] + soFar;
|
||||
} // convertLessThanOneThousand
|
||||
|
||||
/**
|
||||
*Convert
|
||||
* @param number
|
||||
*@return amt
|
||||
*/
|
||||
private String convert(long number)
|
||||
{
|
||||
/* special case */
|
||||
if (number == 0)
|
||||
{
|
||||
return zero;
|
||||
}
|
||||
String prefix = "";
|
||||
if (number < 0)
|
||||
{
|
||||
number = -number;
|
||||
prefix = negative + " ";
|
||||
}
|
||||
String soFar = "";
|
||||
int place = 0;
|
||||
do
|
||||
{
|
||||
long n = number % 1000;
|
||||
if (n != 0)
|
||||
{
|
||||
String s = convertLessThanOneThousand ((int)n, place == 1 ? 1
|
||||
: 0);
|
||||
if ((place == 1) && (s.compareTo (numNames[1][1]) == 0))
|
||||
{
|
||||
soFar = majorNames[place][0] + soFar;
|
||||
}
|
||||
else
|
||||
{
|
||||
long lastDigit = n % 10;
|
||||
long lastTwoDigits = n % 100;
|
||||
boolean teen = (lastTwoDigits > 10 && lastTwoDigits < 20);
|
||||
String major = null;
|
||||
if (lastDigit == 1 && !teen)
|
||||
{
|
||||
major = majorNames[place][0];
|
||||
}
|
||||
// 2,3,4,22,23,24,32,33,34 ...
|
||||
else if ((lastDigit > 1 && lastDigit < 5) && !teen)
|
||||
{
|
||||
major = majorNames[place][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// 0,5,6,7,8,9,11,12,13,...,19
|
||||
major = majorNames[place][2];
|
||||
}
|
||||
soFar = s + major + soFar;
|
||||
}
|
||||
}
|
||||
place++;
|
||||
number /= 1000;
|
||||
}
|
||||
while (number > 0);
|
||||
return (prefix + soFar).trim ();
|
||||
} // convert
|
||||
|
||||
/**************************************************************************
|
||||
*Get Amount in Words
|
||||
* @param amount numeric amount (352.80)
|
||||
*@return amount in words (three*five*two 80/100)
|
||||
*@throws Exception
|
||||
*/
|
||||
public String getAmtInWords(String amount)
|
||||
throws Exception
|
||||
{
|
||||
if (amount == null)
|
||||
return amount;
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
amount = amount.replaceAll (" ", "").replaceAll ("\u00A0", "");
|
||||
char sep = amount.contains (",") ? ',' : '.'; // Try to determine the
|
||||
// separator either
|
||||
// comma or a full stop
|
||||
int pos = amount.lastIndexOf (sep);
|
||||
long dins = Long.parseLong ((pos >= 0) ? amount.substring (0, pos)
|
||||
: amount);
|
||||
sb.append (convert (dins) + " " + din[dins == 1 ? 0 : 1]);
|
||||
if (pos > 0)
|
||||
{
|
||||
String para = amount.substring (pos + 1);
|
||||
if (para.length () > 2)
|
||||
{
|
||||
para = para.substring (0, 2);
|
||||
}
|
||||
sb.append (" " + concat + " ").append (para).append ("/100"); // para"
|
||||
}
|
||||
return sb.toString ();
|
||||
} // getAmtInWords
|
||||
|
||||
/**
|
||||
*Test Print
|
||||
* @param amt amount
|
||||
*/
|
||||
private void print(String amt)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println (amt + " = " + getAmtInWords (amt));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
} // print
|
||||
|
||||
/**
|
||||
*Test
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
AmtInWords_SR aiw = new AmtInWords_SR ();
|
||||
aiw.print ("0.23");
|
||||
aiw.print ("23");
|
||||
aiw.print ("0,23");
|
||||
aiw.print ("1,23");
|
||||
aiw.print ("12,345");
|
||||
aiw.print ("123,45");
|
||||
aiw.print ("1 234,56");
|
||||
aiw.print ("12 345,78");
|
||||
aiw.print ("123 457,89");
|
||||
aiw.print ("1 234 578,90");
|
||||
aiw.print ("10,00");
|
||||
aiw.print ("50,00");
|
||||
aiw.print ("100,00");
|
||||
aiw.print ("300,00");
|
||||
aiw.print ("1 000,00");
|
||||
aiw.print ("3 000,00");
|
||||
aiw.print ("10 000,00");
|
||||
aiw.print ("1 000 000,00");
|
||||
aiw.print ("100 000 000,00");
|
||||
aiw.print ("100 000 000 000,00");
|
||||
aiw.print ("100 000 000 000 000,00");
|
||||
aiw.print ("1 000 000 000 000 000,00");
|
||||
aiw.print ("1 000 000 000 000 000 000,00");
|
||||
} // main
|
||||
} // AmtInWords_RS
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
/**
|
||||
*Amount in Words for Serbia.
|
||||
* @author Nikola Petkov -The class is based on the AmtInWords_EN.java written
|
||||
* by jjanke
|
||||
*/
|
||||
public class AmtInWords_SR
|
||||
implements AmtInWords
|
||||
{
|
||||
|
||||
/**
|
||||
* AmtInWords_RS
|
||||
*/
|
||||
public AmtInWords_SR()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
private static final String zero = "Nula";
|
||||
|
||||
private static final String negative = "minus";
|
||||
|
||||
private static final String concat = "i";
|
||||
|
||||
private static final String din[] =
|
||||
{"dinar", "dinara"};
|
||||
|
||||
/** Thousands plus */
|
||||
private static final String[][] majorNames =
|
||||
{
|
||||
{"", "", ""},
|
||||
{"Hiljadu", "Hiljade", "Hiljada"},
|
||||
{"Milion", "Miliona", "Miliona"},
|
||||
{"Milijarda", "Milijarde", "Milijardi"},
|
||||
{"Bilion", "Biliona", "Biliona"},
|
||||
{"Bilijarda", "Bilijarde", "Bilijardi"},
|
||||
{"Trilion", "Triliona", "Triliona"}};
|
||||
|
||||
/** Ten to Ninety */
|
||||
private static final String[] tensNames =
|
||||
{"", "Deset", "Dvadeset", "Trideset", "Četrdeset", "Pedeset", "Šestdeset",
|
||||
"Sedamdeset", "Osamdeset", "Devedeset"};
|
||||
|
||||
/* 100-1000 */
|
||||
private static final String[] hundredNames =
|
||||
{"", "JednaStotina", "DveStotine", "TriStotine", "ČetiriStotine",
|
||||
"PetStotina", "ŠestStotina", "SedamStotina", "OsamStotina",
|
||||
"DevetStotina"};
|
||||
|
||||
/** numbers to 19 */
|
||||
private static final String[][] numNames =
|
||||
{
|
||||
{"", ""},
|
||||
{"Jedan", "Jedna"},
|
||||
{"Dva", "Dve"},
|
||||
{"Tri", "Tri"},
|
||||
{"Četiri", "Četiri"},
|
||||
{"Pet", "Pet"},
|
||||
{"Šest", "Šest"},
|
||||
{"Sedam", "Sedam"},
|
||||
{"Osam", "Osam"},
|
||||
{"Devet", "Devet"},
|
||||
{"Deset", "Deset"},
|
||||
{"Jedanaest", "Jedanast"},
|
||||
{"Dvanaeset", "Dvanaest"},
|
||||
{"Trinaeset", "Trinaest"},
|
||||
{"Četrnaest", "Četrnaest"},
|
||||
{"Petnaest", "Petnaest"},
|
||||
{"Šestnaest", "Šestnaest"},
|
||||
{"Sedamnaest", "Sedamnaest"},
|
||||
{"Osamnaest", "Osamnaest"},
|
||||
{"Devetnaest", "Devetnaest"}};
|
||||
|
||||
/**
|
||||
*Convert Less Than One Thousand
|
||||
* @param number
|
||||
*@return amt
|
||||
*/
|
||||
private String convertLessThanOneThousand(int number, int w)
|
||||
{
|
||||
String soFar;
|
||||
// Below 20
|
||||
if (number % 100 < 20)
|
||||
{
|
||||
soFar = numNames[number % 100][w];
|
||||
number /= 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
soFar = numNames[number % 10][w];
|
||||
number /= 10;
|
||||
if (soFar.compareTo ("") == 0)
|
||||
{
|
||||
soFar = tensNames[number % 10];
|
||||
}
|
||||
else
|
||||
{
|
||||
soFar = tensNames[number % 10] + concat + soFar;
|
||||
}
|
||||
number /= 10;
|
||||
}
|
||||
if (number == 0)
|
||||
return soFar;
|
||||
return hundredNames[number] + soFar;
|
||||
} // convertLessThanOneThousand
|
||||
|
||||
/**
|
||||
*Convert
|
||||
* @param number
|
||||
*@return amt
|
||||
*/
|
||||
private String convert(long number)
|
||||
{
|
||||
/* special case */
|
||||
if (number == 0)
|
||||
{
|
||||
return zero;
|
||||
}
|
||||
String prefix = "";
|
||||
if (number < 0)
|
||||
{
|
||||
number = -number;
|
||||
prefix = negative + " ";
|
||||
}
|
||||
String soFar = "";
|
||||
int place = 0;
|
||||
do
|
||||
{
|
||||
long n = number % 1000;
|
||||
if (n != 0)
|
||||
{
|
||||
String s = convertLessThanOneThousand ((int)n, place == 1 ? 1
|
||||
: 0);
|
||||
if ((place == 1) && (s.compareTo (numNames[1][1]) == 0))
|
||||
{
|
||||
soFar = majorNames[place][0] + soFar;
|
||||
}
|
||||
else
|
||||
{
|
||||
long lastDigit = n % 10;
|
||||
long lastTwoDigits = n % 100;
|
||||
boolean teen = (lastTwoDigits > 10 && lastTwoDigits < 20);
|
||||
String major = null;
|
||||
if (lastDigit == 1 && !teen)
|
||||
{
|
||||
major = majorNames[place][0];
|
||||
}
|
||||
// 2,3,4,22,23,24,32,33,34 ...
|
||||
else if ((lastDigit > 1 && lastDigit < 5) && !teen)
|
||||
{
|
||||
major = majorNames[place][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// 0,5,6,7,8,9,11,12,13,...,19
|
||||
major = majorNames[place][2];
|
||||
}
|
||||
soFar = s + major + soFar;
|
||||
}
|
||||
}
|
||||
place++;
|
||||
number /= 1000;
|
||||
}
|
||||
while (number > 0);
|
||||
return (prefix + soFar).trim ();
|
||||
} // convert
|
||||
|
||||
/**************************************************************************
|
||||
*Get Amount in Words
|
||||
* @param amount numeric amount (352.80)
|
||||
*@return amount in words (three*five*two 80/100)
|
||||
*@throws Exception
|
||||
*/
|
||||
public String getAmtInWords(String amount)
|
||||
throws Exception
|
||||
{
|
||||
if (amount == null)
|
||||
return amount;
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
amount = amount.replaceAll (" ", "").replaceAll ("\u00A0", "");
|
||||
char sep = amount.contains (",") ? ',' : '.'; // Try to determine the
|
||||
// separator either
|
||||
// comma or a full stop
|
||||
int pos = amount.lastIndexOf (sep);
|
||||
long dins = Long.parseLong ((pos >= 0) ? amount.substring (0, pos)
|
||||
: amount);
|
||||
sb.append (convert (dins) + " " + din[dins == 1 ? 0 : 1]);
|
||||
if (pos > 0)
|
||||
{
|
||||
String para = amount.substring (pos + 1);
|
||||
if (para.length () > 2)
|
||||
{
|
||||
para = para.substring (0, 2);
|
||||
}
|
||||
sb.append (" " + concat + " ").append (para).append ("/100"); // para"
|
||||
}
|
||||
return sb.toString ();
|
||||
} // getAmtInWords
|
||||
|
||||
/**
|
||||
*Test Print
|
||||
* @param amt amount
|
||||
*/
|
||||
private void print(String amt)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println (amt + " = " + getAmtInWords (amt));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
} // print
|
||||
|
||||
/**
|
||||
*Test
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
AmtInWords_SR aiw = new AmtInWords_SR ();
|
||||
aiw.print ("0.23");
|
||||
aiw.print ("23");
|
||||
aiw.print ("0,23");
|
||||
aiw.print ("1,23");
|
||||
aiw.print ("12,345");
|
||||
aiw.print ("123,45");
|
||||
aiw.print ("1 234,56");
|
||||
aiw.print ("12 345,78");
|
||||
aiw.print ("123 457,89");
|
||||
aiw.print ("1 234 578,90");
|
||||
aiw.print ("10,00");
|
||||
aiw.print ("50,00");
|
||||
aiw.print ("100,00");
|
||||
aiw.print ("300,00");
|
||||
aiw.print ("1 000,00");
|
||||
aiw.print ("3 000,00");
|
||||
aiw.print ("10 000,00");
|
||||
aiw.print ("1 000 000,00");
|
||||
aiw.print ("100 000 000,00");
|
||||
aiw.print ("100 000 000 000,00");
|
||||
aiw.print ("100 000 000 000 000,00");
|
||||
aiw.print ("1 000 000 000 000 000,00");
|
||||
aiw.print ("1 000 000 000 000 000 000,00");
|
||||
} // main
|
||||
} // AmtInWords_RS
|
||||
|
||||
|
||||
|
|
|
@ -1,343 +1,343 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* idempiere Logger
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: CLogger.java,v 1.3 2006/08/09 16:38:47 jjanke Exp $
|
||||
*/
|
||||
public class CLogger extends Logger implements Serializable
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6492376264463028357L;
|
||||
private static final String LAST_INFO = "org.compiere.util.CLogger.lastInfo";
|
||||
private static final String LAST_WARNING = "org.compiere.util.CLogger.lastWarning";
|
||||
private static final String LAST_ERROR = "org.compiere.util.CLogger.lastError";
|
||||
private static final String LAST_EXCEPTION = "org.compiere.util.CLogger.lastException";
|
||||
|
||||
|
||||
/**
|
||||
* Get Logger
|
||||
* @param className class name
|
||||
* @return Logger
|
||||
*/
|
||||
public static synchronized CLogger getCLogger (String className)
|
||||
{
|
||||
return getCLogger(className, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Logger
|
||||
* @param className class name
|
||||
* @param usePackageLevel
|
||||
* @return Logger
|
||||
*/
|
||||
public static synchronized CLogger getCLogger (String className, boolean usePackageLevel)
|
||||
{
|
||||
// CLogMgt.initialize();
|
||||
LogManager manager = LogManager.getLogManager();
|
||||
if (className == null || className.trim().length() == 0)
|
||||
className = "";
|
||||
|
||||
Logger result = manager.getLogger(className);
|
||||
if (result != null && result instanceof CLogger)
|
||||
return (CLogger)result;
|
||||
|
||||
Logger packageLogger = null;
|
||||
if (className.indexOf(".") > 0 && usePackageLevel)
|
||||
{
|
||||
String s = className.substring(0, className.lastIndexOf("."));
|
||||
while(s.indexOf(".") > 0)
|
||||
{
|
||||
result = manager.getLogger(s);
|
||||
if (result != null && result instanceof CLogger)
|
||||
{
|
||||
packageLogger = result;
|
||||
break;
|
||||
}
|
||||
s = s.substring(0, s.lastIndexOf("."));
|
||||
}
|
||||
}
|
||||
//
|
||||
CLogger newLogger = new CLogger(className, null);
|
||||
if (packageLogger != null && packageLogger.getLevel() != null)
|
||||
newLogger.setLevel(packageLogger.getLevel());
|
||||
else
|
||||
newLogger.setLevel(CLogMgt.getLevel());
|
||||
manager.addLogger(newLogger);
|
||||
return newLogger;
|
||||
} // getLogger
|
||||
|
||||
/**
|
||||
* Get Logger
|
||||
* @param clazz class name
|
||||
* @return Logger
|
||||
*/
|
||||
public static CLogger getCLogger (Class<?> clazz)
|
||||
{
|
||||
if (clazz == null)
|
||||
return get();
|
||||
return getCLogger (clazz.getName());
|
||||
} // getLogger
|
||||
|
||||
/**
|
||||
* Get default idempiere Logger.
|
||||
* Need to be used in serialized objects
|
||||
* @return logger
|
||||
*/
|
||||
public static CLogger get()
|
||||
{
|
||||
if (s_logger == null)
|
||||
s_logger = getCLogger("org.compiere.default");
|
||||
return s_logger;
|
||||
} // get
|
||||
|
||||
/** Default Logger */
|
||||
private volatile static CLogger s_logger = null;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Standard constructor
|
||||
* @param name logger name
|
||||
* @param resourceBundleName optional resource bundle (ignored)
|
||||
*/
|
||||
private CLogger (String name, String resourceBundleName)
|
||||
{
|
||||
super (name, resourceBundleName);
|
||||
// setLevel(Level.ALL);
|
||||
} // CLogger
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Set and issue Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @return true (to avoid removal of method)
|
||||
*/
|
||||
public boolean saveError (String AD_Message, String message)
|
||||
{
|
||||
return saveError (AD_Message, message, true);
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Set and issue Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param ex exception
|
||||
* @return true (to avoid removal of method)
|
||||
*/
|
||||
public boolean saveError (String AD_Message, Exception ex)
|
||||
{
|
||||
Env.getCtx().put(LAST_EXCEPTION, ex);
|
||||
return saveError (AD_Message, ex.getLocalizedMessage(), true);
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Set and issue (if specified) Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param ex exception
|
||||
* @param issueError if true will issue an error
|
||||
* @return true (to avoid removal of method)
|
||||
*/
|
||||
public boolean saveError (String AD_Message, Exception ex, boolean issueError)
|
||||
{
|
||||
Env.getCtx().put(LAST_EXCEPTION, ex);
|
||||
return saveError (AD_Message, ex.getLocalizedMessage(), issueError);
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Set Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @param issueError print error message (default true)
|
||||
* @return true
|
||||
*/
|
||||
public boolean saveError (String AD_Message, String message, boolean issueError)
|
||||
{
|
||||
ValueNamePair lastError = new ValueNamePair (AD_Message, message);
|
||||
Env.getCtx().put(LAST_ERROR, lastError);
|
||||
// print it
|
||||
if (issueError)
|
||||
severe(AD_Message + " - " + message);
|
||||
return true;
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Get Error from Stack
|
||||
* @return AD_Message as Value and Message as String
|
||||
*/
|
||||
public static ValueNamePair retrieveError()
|
||||
{
|
||||
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_ERROR);
|
||||
return vp;
|
||||
} // retrieveError
|
||||
|
||||
/**
|
||||
* Get Error message from stack
|
||||
* @param defaultMsg default message (used when there are no errors on stack)
|
||||
* @return error message, or defaultMsg if there is not error message saved
|
||||
* @see #retrieveError()
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
*/
|
||||
public static String retrieveErrorString(String defaultMsg) {
|
||||
ValueNamePair vp = retrieveError();
|
||||
if (vp == null)
|
||||
return defaultMsg;
|
||||
return vp.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error from Stack
|
||||
* @return last exception
|
||||
*/
|
||||
public static Exception retrieveException()
|
||||
{
|
||||
Exception ex = (Exception) Env.getCtx().remove(LAST_EXCEPTION);
|
||||
return ex;
|
||||
} // retrieveError
|
||||
|
||||
/**
|
||||
* Save Warning as ValueNamePair.
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @return true
|
||||
*/
|
||||
public boolean saveWarning (String AD_Message, String message)
|
||||
{
|
||||
ValueNamePair lastWarning = new ValueNamePair(AD_Message, message);
|
||||
Env.getCtx().put(LAST_WARNING, lastWarning);
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* idempiere Logger
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: CLogger.java,v 1.3 2006/08/09 16:38:47 jjanke Exp $
|
||||
*/
|
||||
public class CLogger extends Logger implements Serializable
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6492376264463028357L;
|
||||
private static final String LAST_INFO = "org.compiere.util.CLogger.lastInfo";
|
||||
private static final String LAST_WARNING = "org.compiere.util.CLogger.lastWarning";
|
||||
private static final String LAST_ERROR = "org.compiere.util.CLogger.lastError";
|
||||
private static final String LAST_EXCEPTION = "org.compiere.util.CLogger.lastException";
|
||||
|
||||
|
||||
/**
|
||||
* Get Logger
|
||||
* @param className class name
|
||||
* @return Logger
|
||||
*/
|
||||
public static synchronized CLogger getCLogger (String className)
|
||||
{
|
||||
return getCLogger(className, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Logger
|
||||
* @param className class name
|
||||
* @param usePackageLevel
|
||||
* @return Logger
|
||||
*/
|
||||
public static synchronized CLogger getCLogger (String className, boolean usePackageLevel)
|
||||
{
|
||||
// CLogMgt.initialize();
|
||||
LogManager manager = LogManager.getLogManager();
|
||||
if (className == null || className.trim().length() == 0)
|
||||
className = "";
|
||||
|
||||
Logger result = manager.getLogger(className);
|
||||
if (result != null && result instanceof CLogger)
|
||||
return (CLogger)result;
|
||||
|
||||
Logger packageLogger = null;
|
||||
if (className.indexOf(".") > 0 && usePackageLevel)
|
||||
{
|
||||
String s = className.substring(0, className.lastIndexOf("."));
|
||||
while(s.indexOf(".") > 0)
|
||||
{
|
||||
result = manager.getLogger(s);
|
||||
if (result != null && result instanceof CLogger)
|
||||
{
|
||||
packageLogger = result;
|
||||
break;
|
||||
}
|
||||
s = s.substring(0, s.lastIndexOf("."));
|
||||
}
|
||||
}
|
||||
//
|
||||
CLogger newLogger = new CLogger(className, null);
|
||||
if (packageLogger != null && packageLogger.getLevel() != null)
|
||||
newLogger.setLevel(packageLogger.getLevel());
|
||||
else
|
||||
newLogger.setLevel(CLogMgt.getLevel());
|
||||
manager.addLogger(newLogger);
|
||||
return newLogger;
|
||||
} // getLogger
|
||||
|
||||
/**
|
||||
* Get Logger
|
||||
* @param clazz class name
|
||||
* @return Logger
|
||||
*/
|
||||
public static CLogger getCLogger (Class<?> clazz)
|
||||
{
|
||||
if (clazz == null)
|
||||
return get();
|
||||
return getCLogger (clazz.getName());
|
||||
} // getLogger
|
||||
|
||||
/**
|
||||
* Get default idempiere Logger.
|
||||
* Need to be used in serialized objects
|
||||
* @return logger
|
||||
*/
|
||||
public static CLogger get()
|
||||
{
|
||||
if (s_logger == null)
|
||||
s_logger = getCLogger("org.compiere.default");
|
||||
return s_logger;
|
||||
} // get
|
||||
|
||||
/** Default Logger */
|
||||
private volatile static CLogger s_logger = null;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Standard constructor
|
||||
* @param name logger name
|
||||
* @param resourceBundleName optional resource bundle (ignored)
|
||||
*/
|
||||
private CLogger (String name, String resourceBundleName)
|
||||
{
|
||||
super (name, resourceBundleName);
|
||||
// setLevel(Level.ALL);
|
||||
} // CLogger
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Set and issue Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @return true (to avoid removal of method)
|
||||
*/
|
||||
public boolean saveError (String AD_Message, String message)
|
||||
{
|
||||
return saveError (AD_Message, message, true);
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Set and issue Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param ex exception
|
||||
* @return true (to avoid removal of method)
|
||||
*/
|
||||
public boolean saveError (String AD_Message, Exception ex)
|
||||
{
|
||||
Env.getCtx().put(LAST_EXCEPTION, ex);
|
||||
return saveError (AD_Message, ex.getLocalizedMessage(), true);
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Set and issue (if specified) Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param ex exception
|
||||
* @param issueError if true will issue an error
|
||||
* @return true (to avoid removal of method)
|
||||
*/
|
||||
public boolean saveError (String AD_Message, Exception ex, boolean issueError)
|
||||
{
|
||||
Env.getCtx().put(LAST_EXCEPTION, ex);
|
||||
return saveError (AD_Message, ex.getLocalizedMessage(), issueError);
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Set Error and save as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @param issueError print error message (default true)
|
||||
* @return true
|
||||
*/
|
||||
public boolean saveError (String AD_Message, String message, boolean issueError)
|
||||
{
|
||||
ValueNamePair lastError = new ValueNamePair (AD_Message, message);
|
||||
Env.getCtx().put(LAST_ERROR, lastError);
|
||||
// print it
|
||||
if (issueError)
|
||||
severe(AD_Message + " - " + message);
|
||||
return true;
|
||||
} // saveError
|
||||
|
||||
/**
|
||||
* Get Error from Stack
|
||||
* @return AD_Message as Value and Message as String
|
||||
*/
|
||||
public static ValueNamePair retrieveError()
|
||||
{
|
||||
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_ERROR);
|
||||
return vp;
|
||||
} // retrieveError
|
||||
|
||||
/**
|
||||
* Get Error message from stack
|
||||
* @param defaultMsg default message (used when there are no errors on stack)
|
||||
* @return error message, or defaultMsg if there is not error message saved
|
||||
* @see #retrieveError()
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
*/
|
||||
public static String retrieveErrorString(String defaultMsg) {
|
||||
ValueNamePair vp = retrieveError();
|
||||
if (vp == null)
|
||||
return defaultMsg;
|
||||
return vp.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error from Stack
|
||||
* @return last exception
|
||||
*/
|
||||
public static Exception retrieveException()
|
||||
{
|
||||
Exception ex = (Exception) Env.getCtx().remove(LAST_EXCEPTION);
|
||||
return ex;
|
||||
} // retrieveError
|
||||
|
||||
/**
|
||||
* Save Warning as ValueNamePair.
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @return true
|
||||
*/
|
||||
public boolean saveWarning (String AD_Message, String message)
|
||||
{
|
||||
ValueNamePair lastWarning = new ValueNamePair(AD_Message, message);
|
||||
Env.getCtx().put(LAST_WARNING, lastWarning);
|
||||
// print it
|
||||
if (true) // issueError
|
||||
warning(AD_Message + " - " + message);
|
||||
return true;
|
||||
} // saveWarning
|
||||
|
||||
/**
|
||||
* Get Warning from Stack
|
||||
* @return AD_Message as Value and Message as String
|
||||
*/
|
||||
public static ValueNamePair retrieveWarning()
|
||||
{
|
||||
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_WARNING);
|
||||
return vp;
|
||||
} // retrieveWarning
|
||||
|
||||
/**
|
||||
* Save Info as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @return true
|
||||
*/
|
||||
public boolean saveInfo (String AD_Message, String message)
|
||||
{
|
||||
// s_lastInfo = new ValueNamePair (AD_Message, message);
|
||||
ValueNamePair lastInfo = new ValueNamePair (AD_Message, message);
|
||||
Env.getCtx().put(LAST_INFO, lastInfo);
|
||||
return true;
|
||||
} // saveInfo
|
||||
|
||||
/**
|
||||
* Get Info from Stack
|
||||
* @return AD_Message as Value and Message as String
|
||||
*/
|
||||
public static ValueNamePair retrieveInfo()
|
||||
{
|
||||
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_INFO);
|
||||
return vp;
|
||||
} // retrieveInfo
|
||||
|
||||
/**
|
||||
* Reset Saved Messages/Errors/Info
|
||||
*/
|
||||
public static void resetLast()
|
||||
{
|
||||
Env.getCtx().remove(LAST_ERROR);
|
||||
Env.getCtx().remove(LAST_EXCEPTION);
|
||||
Env.getCtx().remove(LAST_WARNING);
|
||||
Env.getCtx().remove(LAST_INFO);
|
||||
} // resetLast
|
||||
|
||||
/**
|
||||
* Get root cause
|
||||
* @param t
|
||||
* @return Throwable
|
||||
*/
|
||||
public static Throwable getRootCause(Throwable t)
|
||||
{
|
||||
Throwable cause = t;
|
||||
while (cause.getCause() != null)
|
||||
{
|
||||
cause = cause.getCause();
|
||||
}
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("CLogger[");
|
||||
sb.append (getName())
|
||||
.append (",Level=").append (getLevel()).append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Write Object - Serialization
|
||||
* @param out out
|
||||
* @throws IOException
|
||||
*
|
||||
private void writeObject (ObjectOutputStream out) throws IOException
|
||||
{
|
||||
out.writeObject(getName());
|
||||
System.out.println("====writeObject:" + getName());
|
||||
} // writeObject
|
||||
|
||||
private String m_className = null;
|
||||
|
||||
private void readObject (ObjectInputStream in) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
m_className = (String)in.readObject();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("====readObject:" + m_className);
|
||||
}
|
||||
|
||||
protected Object readResolve() throws ObjectStreamException
|
||||
{
|
||||
System.out.println("====readResolve:" + m_className);
|
||||
return getLogger(m_className);
|
||||
}
|
||||
/** **/
|
||||
} // CLogger
|
||||
return true;
|
||||
} // saveWarning
|
||||
|
||||
/**
|
||||
* Get Warning from Stack
|
||||
* @return AD_Message as Value and Message as String
|
||||
*/
|
||||
public static ValueNamePair retrieveWarning()
|
||||
{
|
||||
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_WARNING);
|
||||
return vp;
|
||||
} // retrieveWarning
|
||||
|
||||
/**
|
||||
* Save Info as ValueNamePair
|
||||
* @param AD_Message message key
|
||||
* @param message clear text message
|
||||
* @return true
|
||||
*/
|
||||
public boolean saveInfo (String AD_Message, String message)
|
||||
{
|
||||
// s_lastInfo = new ValueNamePair (AD_Message, message);
|
||||
ValueNamePair lastInfo = new ValueNamePair (AD_Message, message);
|
||||
Env.getCtx().put(LAST_INFO, lastInfo);
|
||||
return true;
|
||||
} // saveInfo
|
||||
|
||||
/**
|
||||
* Get Info from Stack
|
||||
* @return AD_Message as Value and Message as String
|
||||
*/
|
||||
public static ValueNamePair retrieveInfo()
|
||||
{
|
||||
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_INFO);
|
||||
return vp;
|
||||
} // retrieveInfo
|
||||
|
||||
/**
|
||||
* Reset Saved Messages/Errors/Info
|
||||
*/
|
||||
public static void resetLast()
|
||||
{
|
||||
Env.getCtx().remove(LAST_ERROR);
|
||||
Env.getCtx().remove(LAST_EXCEPTION);
|
||||
Env.getCtx().remove(LAST_WARNING);
|
||||
Env.getCtx().remove(LAST_INFO);
|
||||
} // resetLast
|
||||
|
||||
/**
|
||||
* Get root cause
|
||||
* @param t
|
||||
* @return Throwable
|
||||
*/
|
||||
public static Throwable getRootCause(Throwable t)
|
||||
{
|
||||
Throwable cause = t;
|
||||
while (cause.getCause() != null)
|
||||
{
|
||||
cause = cause.getCause();
|
||||
}
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("CLogger[");
|
||||
sb.append (getName())
|
||||
.append (",Level=").append (getLevel()).append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Write Object - Serialization
|
||||
* @param out out
|
||||
* @throws IOException
|
||||
*
|
||||
private void writeObject (ObjectOutputStream out) throws IOException
|
||||
{
|
||||
out.writeObject(getName());
|
||||
System.out.println("====writeObject:" + getName());
|
||||
} // writeObject
|
||||
|
||||
private String m_className = null;
|
||||
|
||||
private void readObject (ObjectInputStream in) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
m_className = (String)in.readObject();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("====readObject:" + m_className);
|
||||
}
|
||||
|
||||
protected Object readResolve() throws ObjectStreamException
|
||||
{
|
||||
System.out.println("====readResolve:" + m_className);
|
||||
return getLogger(m_className);
|
||||
}
|
||||
/** **/
|
||||
} // CLogger
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* License Dialog Translation
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: IniRes.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $
|
||||
*/
|
||||
public class IniRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** Translation Content */
|
||||
static final Object[][] contents = new String[][]
|
||||
{
|
||||
{ "Adempiere_License", "Licensz szerződés" },
|
||||
{ "Do_you_accept", "Elfogadja a licensz feltételeit?" },
|
||||
{ "No", "Nem" },
|
||||
{ "Yes_I_Understand", "Igen, Megértettem és Elfogadom" },
|
||||
{ "license_htm", "org/adempiere/license.htm" },
|
||||
{ "License_rejected", "Licensz elutasítva, vagy lejárt" }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Content
|
||||
* @return Content
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
} // getContent
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* License Dialog Translation
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: IniRes.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $
|
||||
*/
|
||||
public class IniRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** Translation Content */
|
||||
static final Object[][] contents = new String[][]
|
||||
{
|
||||
{ "Adempiere_License", "Licensz szerződés" },
|
||||
{ "Do_you_accept", "Elfogadja a licensz feltételeit?" },
|
||||
{ "No", "Nem" },
|
||||
{ "Yes_I_Understand", "Igen, Megértettem és Elfogadom" },
|
||||
{ "license_htm", "org/adempiere/license.htm" },
|
||||
{ "License_rejected", "Licensz elutasítva, vagy lejárt" }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Content
|
||||
* @return Content
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
} // getContent
|
||||
} // IniRes
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,17 +16,17 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.I_AD_Message;
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.I_AD_Message;
|
||||
|
||||
/**
|
||||
* Reads all Messages and stores them in a HashMap
|
||||
|
@ -68,9 +68,9 @@ public final class Msg
|
|||
|
||||
/** The Map */
|
||||
private CCache<String,CCache<String,String>> m_languages
|
||||
= new CCache<String,CCache<String,String>>(null, "msg_lang", 2, 0, false);
|
||||
|
||||
private CCache<String,CCache<String,String>> m_elementCache
|
||||
= new CCache<String,CCache<String,String>>(null, "msg_lang", 2, 0, false);
|
||||
|
||||
private CCache<String,CCache<String,String>> m_elementCache
|
||||
= new CCache<String,CCache<String,String>>(null, "msg_element", 2, 0, false);
|
||||
|
||||
/**
|
||||
|
@ -96,21 +96,21 @@ public final class Msg
|
|||
return retValue;
|
||||
}
|
||||
return retValue;
|
||||
} // getMsgMap
|
||||
|
||||
private CCache<String,String> getElementMap (String ad_language)
|
||||
{
|
||||
String AD_Language = ad_language;
|
||||
if (AD_Language == null || AD_Language.length() == 0)
|
||||
AD_Language = Language.getBaseAD_Language();
|
||||
// Do we have the language ?
|
||||
CCache<String,String> retValue = (CCache<String,String>)m_elementCache.get(AD_Language);
|
||||
if (retValue != null && retValue.size() > 0)
|
||||
return retValue;
|
||||
|
||||
retValue = new CCache<String, String>("element", 100, 0, false, 0);
|
||||
m_elementCache.put(AD_Language, retValue);
|
||||
return retValue;
|
||||
} // getMsgMap
|
||||
|
||||
private CCache<String,String> getElementMap (String ad_language)
|
||||
{
|
||||
String AD_Language = ad_language;
|
||||
if (AD_Language == null || AD_Language.length() == 0)
|
||||
AD_Language = Language.getBaseAD_Language();
|
||||
// Do we have the language ?
|
||||
CCache<String,String> retValue = (CCache<String,String>)m_elementCache.get(AD_Language);
|
||||
if (retValue != null && retValue.size() > 0)
|
||||
return retValue;
|
||||
|
||||
retValue = new CCache<String, String>("element", 100, 0, false, 0);
|
||||
m_elementCache.put(AD_Language, retValue);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,15 +124,15 @@ public final class Msg
|
|||
private CCache<String,String> initMsg (String AD_Language)
|
||||
{
|
||||
// Trace.printStack();
|
||||
CCache<String,String> msg = new CCache<String,String>(I_AD_Message.Table_Name, MAP_SIZE, 0, false, 0);
|
||||
CCache<String,String> msg = new CCache<String,String>(I_AD_Message.Table_Name, MAP_SIZE, 0, false, 0);
|
||||
//
|
||||
if (!DB.isConnected())
|
||||
{
|
||||
s_log.log(Level.SEVERE, "No DB Connection");
|
||||
return null;
|
||||
}
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
if (AD_Language == null || AD_Language.length() == 0 || Env.isBaseLanguage(AD_Language, "AD_Language"))
|
||||
|
@ -151,7 +151,7 @@ public final class Msg
|
|||
while (rs.next())
|
||||
{
|
||||
String AD_Message = rs.getString(1);
|
||||
StringBuilder MsgText = new StringBuilder();
|
||||
StringBuilder MsgText = new StringBuilder();
|
||||
MsgText.append(rs.getString(2));
|
||||
String MsgTip = rs.getString(3);
|
||||
//
|
||||
|
@ -164,11 +164,11 @@ public final class Msg
|
|||
{
|
||||
s_log.log(Level.SEVERE, "initMsg", e);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
//
|
||||
if (msg.size() < 100)
|
||||
|
@ -176,7 +176,7 @@ public final class Msg
|
|||
s_log.log(Level.SEVERE, "Too few (" + msg.size() + ") Records found for " + AD_Language);
|
||||
return null;
|
||||
}
|
||||
if (s_log.isLoggable(Level.INFO)) s_log.info("Records=" + msg.size() + " - " + AD_Language);
|
||||
if (s_log.isLoggable(Level.INFO)) s_log.info("Records=" + msg.size() + " - " + AD_Language);
|
||||
return msg;
|
||||
} // initMsg
|
||||
|
||||
|
@ -237,22 +237,22 @@ public final class Msg
|
|||
return text;
|
||||
// hardcoded trl
|
||||
if (text.equals("/") || text.equals("\\"))
|
||||
return File.separator;
|
||||
if (text.equals(";") || text.equals(":"))
|
||||
return File.pathSeparator;
|
||||
if (text.equals("IDEMPIERE_HOME"))
|
||||
return Adempiere.getAdempiereHome();
|
||||
if (text.equals("bat") || text.equals("sh"))
|
||||
{
|
||||
if (System.getProperty("os.name").startsWith("Win"))
|
||||
return File.separator;
|
||||
if (text.equals(";") || text.equals(":"))
|
||||
return File.pathSeparator;
|
||||
if (text.equals("IDEMPIERE_HOME"))
|
||||
return Adempiere.getAdempiereHome();
|
||||
if (text.equals("bat") || text.equals("sh"))
|
||||
{
|
||||
if (System.getProperty("os.name").startsWith("Win"))
|
||||
return "bat";
|
||||
return "sh";
|
||||
}
|
||||
if (text.equals("CopyRight"))
|
||||
return Adempiere.COPYRIGHT;
|
||||
//
|
||||
CCache<String, String> langMap = getMsgMap(AD_Language);
|
||||
if (langMap == null)
|
||||
return "sh";
|
||||
}
|
||||
if (text.equals("CopyRight"))
|
||||
return Adempiere.COPYRIGHT;
|
||||
//
|
||||
CCache<String, String> langMap = getMsgMap(AD_Language);
|
||||
if (langMap == null)
|
||||
return null;
|
||||
return (String)langMap.get(text);
|
||||
} // lookup
|
||||
|
@ -276,8 +276,8 @@ public final class Msg
|
|||
String retStr = get().lookup (AD_Language, AD_Message);
|
||||
//
|
||||
if (retStr == null || retStr.length() == 0)
|
||||
{
|
||||
s_log.warning("NOT found: " + AD_Message);
|
||||
{
|
||||
s_log.warning("NOT found: " + AD_Message);
|
||||
return AD_Message;
|
||||
}
|
||||
|
||||
|
@ -329,13 +329,13 @@ public final class Msg
|
|||
{
|
||||
if (getText)
|
||||
retStr = retStr.substring (0, pos);
|
||||
else
|
||||
{
|
||||
int start = pos + SEPARATOR.length();
|
||||
// int end = retStr.length();
|
||||
retStr = retStr.substring (start);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int start = pos + SEPARATOR.length();
|
||||
// int end = retStr.length();
|
||||
retStr = retStr.substring (start);
|
||||
}
|
||||
}
|
||||
return retStr;
|
||||
} // getMsg
|
||||
|
||||
|
@ -434,7 +434,7 @@ public final class Msg
|
|||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
s_log.warning("Class not found: " + className);
|
||||
s_log.warning("Class not found: " + className);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -442,7 +442,7 @@ public final class Msg
|
|||
}
|
||||
|
||||
// Fallback
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int pos = amount.lastIndexOf('.');
|
||||
int pos2 = amount.lastIndexOf(',');
|
||||
if (pos2 > pos)
|
||||
|
@ -482,18 +482,18 @@ public final class Msg
|
|||
return "";
|
||||
String AD_Language = ad_language;
|
||||
if (AD_Language == null || AD_Language.length() == 0)
|
||||
AD_Language = Language.getBaseAD_Language();
|
||||
|
||||
Msg msg = get();
|
||||
CCache<String, String> cache = msg.getElementMap(AD_Language);
|
||||
String key = ColumnName+"|"+isSOTrx;
|
||||
String retStr = cache.get(key);
|
||||
if (retStr != null)
|
||||
AD_Language = Language.getBaseAD_Language();
|
||||
|
||||
Msg msg = get();
|
||||
CCache<String, String> cache = msg.getElementMap(AD_Language);
|
||||
String key = ColumnName+"|"+isSOTrx;
|
||||
String retStr = cache.get(key);
|
||||
if (retStr != null)
|
||||
return retStr;
|
||||
|
||||
// Check AD_Element
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
// Check AD_Element
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
if (AD_Language == null || AD_Language.length() == 0 || Env.isBaseLanguage(AD_Language, "AD_Element"))
|
||||
|
@ -505,7 +505,7 @@ public final class Msg
|
|||
+ "AND t.AD_Language=?", null);
|
||||
pstmt.setString(2, AD_Language);
|
||||
}
|
||||
|
||||
|
||||
pstmt.setString(1, ColumnName.toUpperCase());
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
|
@ -523,16 +523,16 @@ public final class Msg
|
|||
{
|
||||
s_log.log(Level.SEVERE, "getElement", e);
|
||||
return "";
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
retStr = retStr == null ? "" : retStr.trim();
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
retStr = retStr == null ? "" : retStr.trim();
|
||||
cache.put(key, retStr);
|
||||
return retStr;
|
||||
return retStr;
|
||||
|
||||
} // getElement
|
||||
|
||||
|
@ -660,7 +660,7 @@ public final class Msg
|
|||
|
||||
String inStr = text;
|
||||
String token;
|
||||
StringBuilder outStr = new StringBuilder();
|
||||
StringBuilder outStr = new StringBuilder();
|
||||
|
||||
int i = inStr.indexOf('@');
|
||||
while (i != -1)
|
||||
|
@ -684,17 +684,17 @@ public final class Msg
|
|||
|
||||
outStr.append(inStr); // add remainder
|
||||
return outStr.toString();
|
||||
} // parseTranslation
|
||||
|
||||
|
||||
/**
|
||||
* Get translated text message for AD_Message, ampersand cleaned (used to indicate shortcut)
|
||||
* @param ctx Context to retrieve language
|
||||
* @param AD_Message - Message Key
|
||||
* @return translated text
|
||||
*/
|
||||
public static String getCleanMsg(Properties ctx, String string) {
|
||||
return Util.cleanAmp(getMsg(Env.getAD_Language(ctx), string));
|
||||
} // parseTranslation
|
||||
|
||||
|
||||
/**
|
||||
* Get translated text message for AD_Message, ampersand cleaned (used to indicate shortcut)
|
||||
* @param ctx Context to retrieve language
|
||||
* @param AD_Message - Message Key
|
||||
* @return translated text
|
||||
*/
|
||||
public static String getCleanMsg(Properties ctx, String string) {
|
||||
return Util.cleanAmp(getMsg(Env.getAD_Language(ctx), string));
|
||||
}
|
||||
|
||||
} // Msg
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
//MBPGroupTest.java
|
||||
//MBPGroupTest.java
|
||||
package test.functional;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.compiere.model.MBPGroup;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MBPGroupTest extends AdempiereTestCase {
|
||||
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.compiere.model.MBPGroup;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MBPGroupTest extends AdempiereTestCase {
|
||||
|
||||
// Variables needed for importing/migrating business partners
|
||||
//private MLocation location = null;
|
||||
//private MLocation location = null;
|
||||
|
||||
private MBPGroup m_group = null; //business partner
|
||||
/*
|
||||
|
@ -25,7 +25,7 @@ public class MBPGroupTest extends AdempiereTestCase {
|
|||
private MElementValue ev = null; //element value
|
||||
private MAcctSchema as = null; //account schema
|
||||
private MAccount acct = null; //account
|
||||
|
||||
|
||||
// Variables needed for importing/migrating bank statements
|
||||
private MBankStatement statement = null;
|
||||
private MBankAccount account = null;
|
||||
|
@ -38,7 +38,7 @@ public class MBPGroupTest extends AdempiereTestCase {
|
|||
private MJournalBatch batch = null;
|
||||
private MJournal journal = null;
|
||||
private MJournalLine line = null;
|
||||
|
||||
|
||||
// Variables needed for importing/migrating Inventory
|
||||
private MInventory inventory = null;
|
||||
private MProduct product = null;
|
||||
|
@ -514,13 +514,13 @@ public class MBPGroupTest extends AdempiereTestCase {
|
|||
m_group.setIsDefault (false);
|
||||
|
||||
m_group.setPriorityBase(MBPGroup.PRIORITYBASE_Same);
|
||||
m_group.saveEx();
|
||||
|
||||
m_group.saveEx();
|
||||
|
||||
commit();
|
||||
} catch(Exception e) {
|
||||
fail(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
//MBPartnerLocationTest.java
|
||||
package test.functional;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.compiere.model.MBPGroup;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MBPartnerLocation;
|
||||
import org.compiere.model.MLocation;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MBPartnerLocationTest extends AdempiereTestCase {
|
||||
|
||||
//MBPartnerLocationTest.java
|
||||
package test.functional;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.compiere.model.MBPGroup;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MBPartnerLocation;
|
||||
import org.compiere.model.MLocation;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MBPartnerLocationTest extends AdempiereTestCase {
|
||||
|
||||
// Variables needed for importing/migrating business partners
|
||||
private MBPartner m_partner = null; //business partner
|
||||
private MLocation location = null;
|
||||
private MLocation location = null;
|
||||
private MBPartnerLocation bpl = null; //business partner location
|
||||
private MBPGroup m_group = null;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class MBPartnerLocationTest extends AdempiereTestCase {
|
|||
private MElementValue ev = null; //element value
|
||||
private MAcctSchema as = null; //account schema
|
||||
private MAccount acct = null; //account
|
||||
|
||||
|
||||
// Variables needed for importing/migrating bank statements
|
||||
private MBankStatement statement = null;
|
||||
private MBankAccount account = null;
|
||||
|
@ -43,7 +43,7 @@ public class MBPartnerLocationTest extends AdempiereTestCase {
|
|||
private MJournalBatch batch = null;
|
||||
private MJournal journal = null;
|
||||
private MJournalLine line = null;
|
||||
|
||||
|
||||
// Variables needed for importing/migrating Inventory
|
||||
private MInventory inventory = null;
|
||||
private MProduct product = null;
|
||||
|
@ -570,6 +570,6 @@ public class MBPartnerLocationTest extends AdempiereTestCase {
|
|||
} catch(Exception e) {
|
||||
fail(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
//MBPartnerTest.java
|
||||
//MBPartnerTest.java
|
||||
package test.functional;
|
||||
|
||||
import org.compiere.model.MBPartner;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MBPartnerTest extends AdempiereTestCase {
|
||||
|
||||
// Variables needed for importing/migrating business partners
|
||||
//private MLocation location = null;
|
||||
|
||||
import org.compiere.model.MBPartner;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MBPartnerTest extends AdempiereTestCase {
|
||||
|
||||
//private MBPartner m_partner = null; //business partner
|
||||
// Variables needed for importing/migrating business partners
|
||||
//private MLocation location = null;
|
||||
|
||||
//private MBPartner m_partner = null; //business partner
|
||||
/*
|
||||
private MBPartnerLocation bpl = null; //business partner location
|
||||
private MUser user = null; //business contact
|
||||
|
@ -20,7 +20,7 @@ public class MBPartnerTest extends AdempiereTestCase {
|
|||
private MElementValue ev = null; //element value
|
||||
private MAcctSchema as = null; //account schema
|
||||
private MAccount acct = null; //account
|
||||
|
||||
|
||||
// Variables needed for importing/migrating bank statements
|
||||
private MBankStatement statement = null;
|
||||
private MBankAccount account = null;
|
||||
|
@ -33,7 +33,7 @@ public class MBPartnerTest extends AdempiereTestCase {
|
|||
private MJournalBatch batch = null;
|
||||
private MJournal journal = null;
|
||||
private MJournalLine line = null;
|
||||
|
||||
|
||||
// Variables needed for importing/migrating Inventory
|
||||
private MInventory inventory = null;
|
||||
private MProduct product = null;
|
||||
|
@ -507,7 +507,7 @@ public class MBPartnerTest extends AdempiereTestCase {
|
|||
try {
|
||||
m_partner = new MBPartner (getCtx(), 0, getTrxName());
|
||||
m_partner.setValue ("");
|
||||
m_partner.setName ("Test MBPartner");
|
||||
m_partner.setName ("Test MBPartner");
|
||||
m_partner.setName2 (null);
|
||||
m_partner.setDUNS("");
|
||||
m_partner.setFirstSale(null);
|
||||
|
@ -541,10 +541,10 @@ public class MBPartnerTest extends AdempiereTestCase {
|
|||
fail(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
} */
|
||||
public void testBPartner() {
|
||||
MBPartner test = MBPartner.getBPartnerCashTrx(getCtx(), 11);
|
||||
assertTrue("Confirming right BPartner record", test.getC_BPartner_ID() == 112);
|
||||
} */
|
||||
public void testBPartner() {
|
||||
MBPartner test = MBPartner.getBPartnerCashTrx(getCtx(), 11);
|
||||
assertTrue("Confirming right BPartner record", test.getC_BPartner_ID() == 112);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
//MProductTest.java
|
||||
package test.functional;
|
||||
|
||||
import org.compiere.model.MProductPrice;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MProductTest extends AdempiereTestCase {
|
||||
/*
|
||||
//MProductTest.java
|
||||
package test.functional;
|
||||
|
||||
import org.compiere.model.MProductPrice;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MProductTest extends AdempiereTestCase {
|
||||
/*
|
||||
public int getProduct_Category_ID(String productCategory) {
|
||||
String sql = "select m_product_category_id from m_product_category where name = ?";
|
||||
PreparedStatement pstmt = null;
|
||||
|
@ -63,9 +63,9 @@ public class MProductTest extends AdempiereTestCase {
|
|||
|
||||
}
|
||||
|
||||
public void testCreateMProduct() {
|
||||
MProduct m_product = new MProduct(getCtx(), 0, getTrxName());
|
||||
m_product.setAD_Org_ID(0);
|
||||
public void testCreateMProduct() {
|
||||
MProduct m_product = new MProduct(getCtx(), 0, getTrxName());
|
||||
m_product.setAD_Org_ID(0);
|
||||
m_product.setProductType (X_I_Product.PRODUCTTYPE_Item); // I
|
||||
m_product.setIsBOM (false); // N
|
||||
m_product.setIsInvoicePrintDetails (false);
|
||||
|
@ -81,20 +81,20 @@ public class MProductTest extends AdempiereTestCase {
|
|||
m_product.setProcessing (false); // N
|
||||
m_product.setName("Test Product"); // N
|
||||
m_product.setC_UOM_ID(getUOM_ID("Each"));
|
||||
|
||||
boolean saveResult = m_product.saveEx();
|
||||
assertEquals("Create new product.", true, saveResult);
|
||||
}
|
||||
|
||||
public void testSetBaseInfo() {
|
||||
MProductPricing prodprice = new MProductPricing(122,100, Env.ONEHUNDRED,true);
|
||||
int uom = 0;
|
||||
uom = prodprice.getC_UOM_ID();
|
||||
assertTrue("UOM must be correct", uom == 100);
|
||||
} */
|
||||
|
||||
public void testPrice() {
|
||||
MProductPrice test = MProductPrice.get(getCtx(), 105, 124, getTrxName());
|
||||
assertTrue("Confirming Prod ID to be true", test.getM_Product_ID() == 124);
|
||||
}
|
||||
}
|
||||
|
||||
boolean saveResult = m_product.saveEx();
|
||||
assertEquals("Create new product.", true, saveResult);
|
||||
}
|
||||
|
||||
public void testSetBaseInfo() {
|
||||
MProductPricing prodprice = new MProductPricing(122,100, Env.ONEHUNDRED,true);
|
||||
int uom = 0;
|
||||
uom = prodprice.getC_UOM_ID();
|
||||
assertTrue("UOM must be correct", uom == 100);
|
||||
} */
|
||||
|
||||
public void testPrice() {
|
||||
MProductPrice test = MProductPrice.get(getCtx(), 105, 124, getTrxName());
|
||||
assertTrue("Confirming Prod ID to be true", test.getM_Product_ID() == 124);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
//MUserTest.java
|
||||
//MUserTest.java
|
||||
package test.functional;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.compiere.model.MBPGroup;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MUserTest extends AdempiereTestCase {
|
||||
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.compiere.model.MBPGroup;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class MUserTest extends AdempiereTestCase {
|
||||
|
||||
// Variables needed for importing/migrating business partners
|
||||
//private MLocation location = null;
|
||||
//private MLocation location = null;
|
||||
|
||||
private MBPartner m_partner = null; //business partner
|
||||
private MUser m_contact = null; //business contact
|
||||
|
@ -28,7 +28,7 @@ public class MUserTest extends AdempiereTestCase {
|
|||
private MElementValue ev = null; //element value
|
||||
private MAcctSchema as = null; //account schema
|
||||
private MAccount acct = null; //account
|
||||
|
||||
|
||||
// Variables needed for importing/migrating bank statements
|
||||
private MBankStatement statement = null;
|
||||
private MBankAccount account = null;
|
||||
|
@ -41,7 +41,7 @@ public class MUserTest extends AdempiereTestCase {
|
|||
private MJournalBatch batch = null;
|
||||
private MJournal journal = null;
|
||||
private MJournalLine line = null;
|
||||
|
||||
|
||||
// Variables needed for importing/migrating Inventory
|
||||
private MInventory inventory = null;
|
||||
private MProduct product = null;
|
||||
|
@ -549,13 +549,13 @@ public class MUserTest extends AdempiereTestCase {
|
|||
m_contact.setIsActive(true);
|
||||
m_contact.setC_BPartner_ID(m_partner.get_ID());
|
||||
m_contact.saveEx();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
commit();
|
||||
} catch(Exception e) {
|
||||
fail(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
<!-- ====================================================== -->
|
||||
<!-- Setup Jetty For Development Environment -->
|
||||
<!-- ====================================================== -->
|
||||
|
||||
<project name="setup" default="setup" basedir=".">
|
||||
|
||||
<description>
|
||||
This buildfile is used to setup the idempiere Environment.
|
||||
</description>
|
||||
|
||||
<property environment="env" />
|
||||
<property name="envFile" value="../idempiereEnv.properties" />
|
||||
|
||||
<!-- ==================================================== -->
|
||||
<!-- Init -->
|
||||
<!-- ==================================================== -->
|
||||
<target name="setupJetty"
|
||||
description="setup jetty">
|
||||
|
||||
<echo message="Setup Jetty ===================" />
|
||||
<echo message="IDEMPIERE_HOME = ${env.IDEMPIERE_HOME}" />
|
||||
|
||||
<!-- create the time stamp and environment -->
|
||||
<tstamp />
|
||||
<available file="${envFile}" property="envFileExists" />
|
||||
<fail message="**** RUN_setup was not successful - please re-run ****" unless="envFileExists" />
|
||||
<property file="${envFile}"/>
|
||||
<filter filtersfile="${envFile}" />
|
||||
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-template.xml"
|
||||
tofile="../jettyhome/etc/jetty.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-ssl-template.xml"
|
||||
tofile="../jettyhome/etc/jetty-ssl.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-deployer.xml"
|
||||
tofile="../jettyhome/etc/jetty-deployer.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-https.xml"
|
||||
tofile="../jettyhome/etc/jetty-https.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-ssl-context-template.xml"
|
||||
tofile="../jettyhome/etc/jetty-ssl-context.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-http-template.xml"
|
||||
tofile="../jettyhome/etc/jetty-http.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-alpn.xml"
|
||||
tofile="../jettyhome/etc/jetty-alpn.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-http2.xml"
|
||||
tofile="../jettyhome/etc/jetty-http2.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-plus.xml"
|
||||
tofile="../jettyhome/etc/jetty-plus.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/hazelcast-template.xml"
|
||||
tofile="../hazelcast.xml" filtering="yes" overwrite="yes"/>
|
||||
</target>
|
||||
|
||||
<!-- ==================================================== -->
|
||||
<!-- Setup (Main) -->
|
||||
<!-- ==================================================== -->
|
||||
<target name="setup" depends="setupJetty"
|
||||
description="Setup iDempiere">
|
||||
</target>
|
||||
<!-- ====================================================== -->
|
||||
<!-- Setup Jetty For Development Environment -->
|
||||
<!-- ====================================================== -->
|
||||
|
||||
<project name="setup" default="setup" basedir=".">
|
||||
|
||||
<description>
|
||||
This buildfile is used to setup the idempiere Environment.
|
||||
</description>
|
||||
|
||||
<property environment="env" />
|
||||
<property name="envFile" value="../idempiereEnv.properties" />
|
||||
|
||||
<!-- ==================================================== -->
|
||||
<!-- Init -->
|
||||
<!-- ==================================================== -->
|
||||
<target name="setupJetty"
|
||||
description="setup jetty">
|
||||
|
||||
<echo message="Setup Jetty ===================" />
|
||||
<echo message="IDEMPIERE_HOME = ${env.IDEMPIERE_HOME}" />
|
||||
|
||||
<!-- create the time stamp and environment -->
|
||||
<tstamp />
|
||||
<available file="${envFile}" property="envFileExists" />
|
||||
<fail message="**** RUN_setup was not successful - please re-run ****" unless="envFileExists" />
|
||||
<property file="${envFile}"/>
|
||||
<filter filtersfile="${envFile}" />
|
||||
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-template.xml"
|
||||
tofile="../jettyhome/etc/jetty.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-ssl-template.xml"
|
||||
tofile="../jettyhome/etc/jetty-ssl.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-deployer.xml"
|
||||
tofile="../jettyhome/etc/jetty-deployer.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-https.xml"
|
||||
tofile="../jettyhome/etc/jetty-https.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-ssl-context-template.xml"
|
||||
tofile="../jettyhome/etc/jetty-ssl-context.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-http-template.xml"
|
||||
tofile="../jettyhome/etc/jetty-http.xml" filtering="yes" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-alpn.xml"
|
||||
tofile="../jettyhome/etc/jetty-alpn.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-http2.xml"
|
||||
tofile="../jettyhome/etc/jetty-http2.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/jettyhome/etc/jetty-plus.xml"
|
||||
tofile="../jettyhome/etc/jetty-plus.xml" filtering="no" overwrite="yes"/>
|
||||
<copy file="../org.adempiere.server-feature/hazelcast-template.xml"
|
||||
tofile="../hazelcast.xml" filtering="yes" overwrite="yes"/>
|
||||
</target>
|
||||
|
||||
<!-- ==================================================== -->
|
||||
<!-- Setup (Main) -->
|
||||
<!-- ==================================================== -->
|
||||
<target name="setup" depends="setupJetty"
|
||||
description="Setup iDempiere">
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
@ -1,119 +1,119 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.install;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* Setup Resources
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: SetupRes.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $
|
||||
*/
|
||||
public class SetupRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** Translation Info */
|
||||
static final Object[][] contents = new String[][]{
|
||||
{ "AdempiereServerSetup", "iDempiere Szerver Beállítása" },
|
||||
{ "Ok", "Ok" },
|
||||
{ "File", "Fájl" },
|
||||
{ "Exit", "Kilépés" },
|
||||
{ "Help", "Súgó" },
|
||||
{ "PleaseCheck", "Kérem ellenőrizze" },
|
||||
{ "UnableToConnect", "Nem sikerült elérni a súgót az iDempiere web oldalán" },
|
||||
//
|
||||
{ "AdempiereHomeInfo", "iDempiere Home is the main Folder" },
|
||||
{ "AdempiereHome", "iDempiere Home" },
|
||||
{ "WebPortInfo", "Web (HTML) Port" },
|
||||
{ "WebPort", "Web Port" },
|
||||
{ "AppsServerInfo", "Application Server Name" },
|
||||
{ "AppsServer", "Application Server" },
|
||||
{ "DatabaseTypeInfo", "Database Type" },
|
||||
{ "DatabaseType", "Database Type" },
|
||||
{ "DatabaseNameInfo", "Database (Service) Name" },
|
||||
{ "DatabaseName", "Database Name" },
|
||||
{ "DatabasePortInfo", "Database Listener Port" },
|
||||
{ "DatabasePort", "Database Port" },
|
||||
{ "DatabaseUserInfo", "Database iDempiere User ID" },
|
||||
{ "DatabaseUser", "Database User" },
|
||||
{ "DatabasePasswordInfo", "Database iDempiere User Password" },
|
||||
{ "DatabasePassword", "Database Password" },
|
||||
{ "TNSNameInfo", "Discovered Databases" },
|
||||
{ "TNSName", "Database Search" },
|
||||
{ "SystemPasswordInfo", "Database System User Password" },
|
||||
{ "SystemPassword", "System Password" },
|
||||
{ "MailServerInfo", "Mail Server" },
|
||||
{ "MailServer", "Mail Server" },
|
||||
{ "AdminEMailInfo", "iDempiere Administrator EMail" },
|
||||
{ "AdminEMail", "Admin EMail" },
|
||||
{ "DatabaseServerInfo", "Database Server Name" },
|
||||
{ "DatabaseServer", "Database Server" },
|
||||
{ "JavaHomeInfo", "Java Home Folder" },
|
||||
{ "JavaHome", "Java Home" },
|
||||
{ "JNPPortInfo", "Application Server JNP Port" },
|
||||
{ "JNPPort", "JNP Port" },
|
||||
{ "MailUserInfo", "iDempiere Mail User" },
|
||||
{ "MailUser", "Mail User" },
|
||||
{ "MailPasswordInfo", "iDempiere Mail User Password" },
|
||||
{ "MailPassword", "Mail Password" },
|
||||
{ "KeyStorePassword", "KeyStore Password" },
|
||||
{ "KeyStorePasswordInfo", "Password for SSL Key Store" },
|
||||
//
|
||||
{ "JavaType", "Java VM"},
|
||||
{ "JavaTypeInfo", "Java VM Vendor"},
|
||||
{ "AppsType", "Server Type"},
|
||||
{ "AppsTypeInfo", "J2EE Application Server Type"},
|
||||
{ "DeployDir", "Deployment"},
|
||||
{ "DeployDirInfo", "J2EE Deployment Directory"},
|
||||
{ "ErrorDeployDir", "Error Deployment Directory"},
|
||||
//
|
||||
{ "TestInfo", "Test the Setup" },
|
||||
{ "Test", "Test" },
|
||||
{ "SaveInfo", "Save the Setup" },
|
||||
{ "Save", "Save" },
|
||||
{ "HelpInfo", "Get Help" },
|
||||
//
|
||||
{ "ServerError", "Server Setup Error" },
|
||||
{ "ErrorJavaHome", "Error Java Home" },
|
||||
{ "ErrorAdempiereHome", "Error iDempiere Home" },
|
||||
{ "ErrorAppsServer", "Error Apps Server" },
|
||||
{ "ErrorWebPort", "Error Web Port" },
|
||||
{ "ErrorJNPPort", "Error JNP Port" },
|
||||
{ "ErrorDatabaseServer", "Error Database Server" },
|
||||
{ "ErrorDatabasePort", "Error Database Port" },
|
||||
{ "ErrorJDBC", "Error JDBC Connection" },
|
||||
{ "ErrorTNS", "Error TNS Connection" },
|
||||
{ "ErrorMailServer", "Error Mail Server" },
|
||||
{ "ErrorMail", "Error Mail" },
|
||||
{ "ErrorSave", "Error Saving File" },
|
||||
|
||||
{ "EnvironmentSaved", "Environment file saved .... starting Deployment\n"
|
||||
+ "You can re-start the Application Server after program completes.\n"
|
||||
+ "Please check Trace for errors.\n" }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Content
|
||||
* @return content array
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
} // getContents
|
||||
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.install;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* Setup Resources
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: SetupRes.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $
|
||||
*/
|
||||
public class SetupRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** Translation Info */
|
||||
static final Object[][] contents = new String[][]{
|
||||
{ "AdempiereServerSetup", "iDempiere Szerver Beállítása" },
|
||||
{ "Ok", "Ok" },
|
||||
{ "File", "Fájl" },
|
||||
{ "Exit", "Kilépés" },
|
||||
{ "Help", "Súgó" },
|
||||
{ "PleaseCheck", "Kérem ellenőrizze" },
|
||||
{ "UnableToConnect", "Nem sikerült elérni a súgót az iDempiere web oldalán" },
|
||||
//
|
||||
{ "AdempiereHomeInfo", "iDempiere Home is the main Folder" },
|
||||
{ "AdempiereHome", "iDempiere Home" },
|
||||
{ "WebPortInfo", "Web (HTML) Port" },
|
||||
{ "WebPort", "Web Port" },
|
||||
{ "AppsServerInfo", "Application Server Name" },
|
||||
{ "AppsServer", "Application Server" },
|
||||
{ "DatabaseTypeInfo", "Database Type" },
|
||||
{ "DatabaseType", "Database Type" },
|
||||
{ "DatabaseNameInfo", "Database (Service) Name" },
|
||||
{ "DatabaseName", "Database Name" },
|
||||
{ "DatabasePortInfo", "Database Listener Port" },
|
||||
{ "DatabasePort", "Database Port" },
|
||||
{ "DatabaseUserInfo", "Database iDempiere User ID" },
|
||||
{ "DatabaseUser", "Database User" },
|
||||
{ "DatabasePasswordInfo", "Database iDempiere User Password" },
|
||||
{ "DatabasePassword", "Database Password" },
|
||||
{ "TNSNameInfo", "Discovered Databases" },
|
||||
{ "TNSName", "Database Search" },
|
||||
{ "SystemPasswordInfo", "Database System User Password" },
|
||||
{ "SystemPassword", "System Password" },
|
||||
{ "MailServerInfo", "Mail Server" },
|
||||
{ "MailServer", "Mail Server" },
|
||||
{ "AdminEMailInfo", "iDempiere Administrator EMail" },
|
||||
{ "AdminEMail", "Admin EMail" },
|
||||
{ "DatabaseServerInfo", "Database Server Name" },
|
||||
{ "DatabaseServer", "Database Server" },
|
||||
{ "JavaHomeInfo", "Java Home Folder" },
|
||||
{ "JavaHome", "Java Home" },
|
||||
{ "JNPPortInfo", "Application Server JNP Port" },
|
||||
{ "JNPPort", "JNP Port" },
|
||||
{ "MailUserInfo", "iDempiere Mail User" },
|
||||
{ "MailUser", "Mail User" },
|
||||
{ "MailPasswordInfo", "iDempiere Mail User Password" },
|
||||
{ "MailPassword", "Mail Password" },
|
||||
{ "KeyStorePassword", "KeyStore Password" },
|
||||
{ "KeyStorePasswordInfo", "Password for SSL Key Store" },
|
||||
//
|
||||
{ "JavaType", "Java VM"},
|
||||
{ "JavaTypeInfo", "Java VM Vendor"},
|
||||
{ "AppsType", "Server Type"},
|
||||
{ "AppsTypeInfo", "J2EE Application Server Type"},
|
||||
{ "DeployDir", "Deployment"},
|
||||
{ "DeployDirInfo", "J2EE Deployment Directory"},
|
||||
{ "ErrorDeployDir", "Error Deployment Directory"},
|
||||
//
|
||||
{ "TestInfo", "Test the Setup" },
|
||||
{ "Test", "Test" },
|
||||
{ "SaveInfo", "Save the Setup" },
|
||||
{ "Save", "Save" },
|
||||
{ "HelpInfo", "Get Help" },
|
||||
//
|
||||
{ "ServerError", "Server Setup Error" },
|
||||
{ "ErrorJavaHome", "Error Java Home" },
|
||||
{ "ErrorAdempiereHome", "Error iDempiere Home" },
|
||||
{ "ErrorAppsServer", "Error Apps Server" },
|
||||
{ "ErrorWebPort", "Error Web Port" },
|
||||
{ "ErrorJNPPort", "Error JNP Port" },
|
||||
{ "ErrorDatabaseServer", "Error Database Server" },
|
||||
{ "ErrorDatabasePort", "Error Database Port" },
|
||||
{ "ErrorJDBC", "Error JDBC Connection" },
|
||||
{ "ErrorTNS", "Error TNS Connection" },
|
||||
{ "ErrorMailServer", "Error Mail Server" },
|
||||
{ "ErrorMail", "Error Mail" },
|
||||
{ "ErrorSave", "Error Saving File" },
|
||||
|
||||
{ "EnvironmentSaved", "Environment file saved .... starting Deployment\n"
|
||||
+ "You can re-start the Application Server after program completes.\n"
|
||||
+ "Please check Trace for errors.\n" }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Content
|
||||
* @return content array
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
} // getContents
|
||||
|
||||
} // SetupRes
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,25 +16,25 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.install.util;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
* Application Action.
|
||||
|
@ -47,11 +47,11 @@ import org.compiere.util.Msg;
|
|||
*/
|
||||
public final class AppsAction extends AbstractAction
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8522301377339185496L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8522301377339185496L;
|
||||
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
|
@ -146,13 +146,13 @@ public final class AppsAction extends AbstractAction
|
|||
m_button.setActionCommand(m_action);
|
||||
m_button.setMargin(BUTTON_INSETS);
|
||||
m_button.setSize(BUTTON_SIZE);
|
||||
//
|
||||
if (accelerator != null)
|
||||
{
|
||||
m_button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(accelerator, action);
|
||||
m_button.getActionMap().put(action, this);
|
||||
}
|
||||
} // Action
|
||||
//
|
||||
if (accelerator != null)
|
||||
{
|
||||
m_button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(accelerator, action);
|
||||
m_button.getActionMap().put(action, this);
|
||||
}
|
||||
} // Action
|
||||
|
||||
/** Button Size */
|
||||
public static final Dimension BUTTON_SIZE = new Dimension(28,28);
|
||||
|
@ -175,14 +175,14 @@ public final class AppsAction extends AbstractAction
|
|||
* @param name name
|
||||
* @param small small
|
||||
* @return Icon
|
||||
*/
|
||||
private ImageIcon getIcon(String name, boolean small)
|
||||
{
|
||||
String fullName = name + (small ? "16" : "24");
|
||||
return Env.getImageIcon2(fullName);
|
||||
} // getIcon
|
||||
|
||||
/**
|
||||
*/
|
||||
private ImageIcon getIcon(String name, boolean small)
|
||||
{
|
||||
String fullName = name + (small ? "16" : "24");
|
||||
return Env.getImageIcon2(fullName);
|
||||
} // getIcon
|
||||
|
||||
/**
|
||||
* Get Name/ActionCommand
|
||||
* @return ActionName
|
||||
*/
|
||||
|
@ -241,11 +241,11 @@ public final class AppsAction extends AbstractAction
|
|||
m_pressed = pressed;
|
||||
|
||||
// Set Button
|
||||
if (m_button != null)
|
||||
if (m_button != null)
|
||||
m_button.setSelected(pressed);
|
||||
|
||||
|
||||
// Set Menu
|
||||
if (m_menu != null)
|
||||
if (m_menu != null)
|
||||
m_menu.setSelected(pressed);
|
||||
} // setPressed
|
||||
|
||||
|
@ -300,7 +300,7 @@ public final class AppsAction extends AbstractAction
|
|||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("AppsAction[");
|
||||
StringBuilder sb = new StringBuilder("AppsAction[");
|
||||
sb.append(m_action);
|
||||
Object oo = getValue(Action.ACCELERATOR_KEY);
|
||||
if (oo != null)
|
||||
|
|
|
@ -1,169 +1,169 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 Adempiere, 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. *
|
||||
*
|
||||
* Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
|
||||
* Contributor(s): Low Heng Sin hengsin@avantz.com
|
||||
*****************************************************************************/
|
||||
package org.adempiere.pipo2.handler;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Savepoint;
|
||||
import java.sql.Statement;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
import org.adempiere.pipo2.AbstractElementHandler;
|
||||
import org.adempiere.pipo2.Element;
|
||||
import org.adempiere.pipo2.PIPOContext;
|
||||
import org.adempiere.pipo2.PackOut;
|
||||
import org.adempiere.pipo2.PackoutItem;
|
||||
import org.adempiere.pipo2.SQLElementParameters;
|
||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Trx;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class SQLStatementElementHandler extends AbstractElementHandler {
|
||||
|
||||
public void startElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
String elementValue = element.getElementValue();
|
||||
|
||||
log.info(elementValue);
|
||||
String DBType = getStringValue(element, "DBType");
|
||||
String sql = getStringValue(element, "statement");
|
||||
if (sql.endsWith(";") && !(sql.toLowerCase().endsWith("end;")))
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
sql=Env.parseContext(Env.getCtx(), 0, sql, false); // tbayen IDEMPIERE-2140
|
||||
Savepoint savepoint = null;
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 Adempiere, 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. *
|
||||
*
|
||||
* Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
|
||||
* Contributor(s): Low Heng Sin hengsin@avantz.com
|
||||
*****************************************************************************/
|
||||
package org.adempiere.pipo2.handler;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Savepoint;
|
||||
import java.sql.Statement;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
import org.adempiere.pipo2.AbstractElementHandler;
|
||||
import org.adempiere.pipo2.Element;
|
||||
import org.adempiere.pipo2.PIPOContext;
|
||||
import org.adempiere.pipo2.PackOut;
|
||||
import org.adempiere.pipo2.PackoutItem;
|
||||
import org.adempiere.pipo2.SQLElementParameters;
|
||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Trx;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class SQLStatementElementHandler extends AbstractElementHandler {
|
||||
|
||||
public void startElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
String elementValue = element.getElementValue();
|
||||
|
||||
log.info(elementValue);
|
||||
String DBType = getStringValue(element, "DBType");
|
||||
String sql = getStringValue(element, "statement");
|
||||
if (sql.endsWith(";") && !(sql.toLowerCase().endsWith("end;")))
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
sql=Env.parseContext(Env.getCtx(), 0, sql, false); // tbayen IDEMPIERE-2140
|
||||
Savepoint savepoint = null;
|
||||
int count = 0;
|
||||
PreparedStatement pstmt = null;
|
||||
X_AD_Package_Imp_Detail impDetail = null;
|
||||
impDetail = createImportDetail(ctx, element.qName, "", 0);
|
||||
try {
|
||||
// NOTE Postgres needs to commit DDL statements
|
||||
// add a SQL command just with COMMIT if you want to simulate the Oracle behavior (commit on DDL)
|
||||
// Use savepoint here so that SQL exception would not rollback the whole process
|
||||
Trx trx = Trx.get(getTrxName(ctx), true);
|
||||
savepoint = trx.setSavepoint(null);
|
||||
|
||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
if (DBType.equals("ALL")) {
|
||||
count = pstmt.executeUpdate();
|
||||
if (log.isLoggable(Level.INFO)) log.info("Executed SQL Statement: "+ getStringValue(element, "statement") + " ReturnValue="+count);
|
||||
} else if (DB.isOracle() == true && DBType.equals("Oracle")) {
|
||||
count = pstmt.executeUpdate();
|
||||
if (log.isLoggable(Level.INFO)) log.info("Executed SQL Statement for Oracle: "+ getStringValue(element, "statement") + " ReturnValue="+count);
|
||||
} else if (DB.isPostgreSQL()
|
||||
&& ( DBType.equals("Postgres")
|
||||
|| DBType.equals("PostgreSQL") // backward compatibility with old packages developed by hand
|
||||
)
|
||||
) {
|
||||
// Avoid convert layer - command specific for postgresql
|
||||
//
|
||||
// pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
// pstmt.executeUpdate();
|
||||
//
|
||||
|
||||
Statement stmt = null;
|
||||
try {
|
||||
stmt = pstmt.getConnection().createStatement();
|
||||
count = stmt.executeUpdate (sql);
|
||||
if (log.isLoggable(Level.INFO)) log.info("Executed SQL Statement for PostgreSQL: "+ getStringValue(element,"statement") + " ReturnValue="+count);
|
||||
} finally {
|
||||
DB.close(stmt);
|
||||
stmt = null;
|
||||
}
|
||||
}
|
||||
logImportDetail (ctx, impDetail, 1, "SQLStatement",count,"Execute");
|
||||
ctx.packIn.getNotifier().addSuccessLine("-> " + sql);
|
||||
} catch (Exception e) {
|
||||
// rollback immediately on exception to avoid a wrong SQL stop the whole process
|
||||
if (savepoint != null)
|
||||
{
|
||||
Trx trx = Trx.get(getTrxName(ctx), false);
|
||||
try {
|
||||
if (trx.getConnection() != null)
|
||||
trx.getConnection().rollback(savepoint);
|
||||
} catch (SQLException e1) {
|
||||
//a rollback or commit have happens making the savepoint becomes invalid.
|
||||
//rollback trx to continue
|
||||
trx.rollback();
|
||||
}
|
||||
savepoint = null;
|
||||
}
|
||||
ctx.packIn.getNotifier().addFailureLine("SQL statement failed but ignored, error (" + e.getLocalizedMessage() + "): ");
|
||||
logImportDetail (ctx, impDetail, 0, "SQLStatement",-1,"Execute");
|
||||
ctx.packIn.getNotifier().addFailureLine("-> " + sql);
|
||||
log.log(Level.SEVERE,"SQLStatement", e);
|
||||
} finally {
|
||||
DB.close(pstmt);
|
||||
pstmt = null;
|
||||
if (savepoint != null) {
|
||||
Trx trx = Trx.get(getTrxName(ctx), false);
|
||||
try {
|
||||
trx.releaseSavepoint(savepoint);
|
||||
} catch (SQLException e) {
|
||||
if (DB.isPostgreSQL()) {
|
||||
//a commit or rollback have happens that make the savepoint invalid.
|
||||
//need to call rollback to continue
|
||||
trx.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
}
|
||||
|
||||
public void create(PIPOContext ctx, TransformerHandler document)
|
||||
throws SAXException {
|
||||
String SQLStatement = Env.getContext(ctx.ctx, SQLElementParameters.SQL_STATEMENT);
|
||||
String DBType = Env.getContext(ctx.ctx, SQLElementParameters.DB_TYPE);
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
addTypeName(atts, "custom");
|
||||
document.startElement("","","SQLStatement",atts);
|
||||
createSQLStatmentBinding(document, SQLStatement, DBType);
|
||||
document.endElement("","","SQLStatement");
|
||||
}
|
||||
|
||||
private void createSQLStatmentBinding( TransformerHandler document, String sqlStatement, String DBType) throws SAXException
|
||||
{
|
||||
document.startElement("","","DBType", new AttributesImpl());
|
||||
char[] contents = DBType.toCharArray();
|
||||
document.characters(contents,0,contents.length);
|
||||
document.endElement("","","DBType");
|
||||
|
||||
document.startElement("","","statement", new AttributesImpl());
|
||||
contents = sqlStatement.toCharArray();
|
||||
document.startCDATA();
|
||||
document.characters(contents,0,contents.length);
|
||||
document.endCDATA();
|
||||
document.endElement("","","statement");
|
||||
|
||||
}
|
||||
|
||||
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int field) throws Exception
|
||||
{
|
||||
PackoutItem detail = packout.getCurrentPackoutItem();
|
||||
Env.setContext(packout.getCtx().ctx, SQLElementParameters.SQL_STATEMENT, (String)detail.getProperty(SQLElementParameters.SQL_STATEMENT));
|
||||
Env.setContext(packout.getCtx().ctx, SQLElementParameters.DB_TYPE, (String)detail.getProperty(SQLElementParameters.DB_TYPE));
|
||||
this.create(packout.getCtx(), packoutHandler);
|
||||
packout.getCtx().ctx.remove(SQLElementParameters.SQL_STATEMENT);
|
||||
packout.getCtx().ctx.remove(SQLElementParameters.DB_TYPE);
|
||||
}
|
||||
}
|
||||
PreparedStatement pstmt = null;
|
||||
X_AD_Package_Imp_Detail impDetail = null;
|
||||
impDetail = createImportDetail(ctx, element.qName, "", 0);
|
||||
try {
|
||||
// NOTE Postgres needs to commit DDL statements
|
||||
// add a SQL command just with COMMIT if you want to simulate the Oracle behavior (commit on DDL)
|
||||
// Use savepoint here so that SQL exception would not rollback the whole process
|
||||
Trx trx = Trx.get(getTrxName(ctx), true);
|
||||
savepoint = trx.setSavepoint(null);
|
||||
|
||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
if (DBType.equals("ALL")) {
|
||||
count = pstmt.executeUpdate();
|
||||
if (log.isLoggable(Level.INFO)) log.info("Executed SQL Statement: "+ getStringValue(element, "statement") + " ReturnValue="+count);
|
||||
} else if (DB.isOracle() == true && DBType.equals("Oracle")) {
|
||||
count = pstmt.executeUpdate();
|
||||
if (log.isLoggable(Level.INFO)) log.info("Executed SQL Statement for Oracle: "+ getStringValue(element, "statement") + " ReturnValue="+count);
|
||||
} else if (DB.isPostgreSQL()
|
||||
&& ( DBType.equals("Postgres")
|
||||
|| DBType.equals("PostgreSQL") // backward compatibility with old packages developed by hand
|
||||
)
|
||||
) {
|
||||
// Avoid convert layer - command specific for postgresql
|
||||
//
|
||||
// pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
// pstmt.executeUpdate();
|
||||
//
|
||||
|
||||
Statement stmt = null;
|
||||
try {
|
||||
stmt = pstmt.getConnection().createStatement();
|
||||
count = stmt.executeUpdate (sql);
|
||||
if (log.isLoggable(Level.INFO)) log.info("Executed SQL Statement for PostgreSQL: "+ getStringValue(element,"statement") + " ReturnValue="+count);
|
||||
} finally {
|
||||
DB.close(stmt);
|
||||
stmt = null;
|
||||
}
|
||||
}
|
||||
logImportDetail (ctx, impDetail, 1, "SQLStatement",count,"Execute");
|
||||
ctx.packIn.getNotifier().addSuccessLine("-> " + sql);
|
||||
} catch (Exception e) {
|
||||
// rollback immediately on exception to avoid a wrong SQL stop the whole process
|
||||
if (savepoint != null)
|
||||
{
|
||||
Trx trx = Trx.get(getTrxName(ctx), false);
|
||||
try {
|
||||
if (trx.getConnection() != null)
|
||||
trx.getConnection().rollback(savepoint);
|
||||
} catch (SQLException e1) {
|
||||
//a rollback or commit have happens making the savepoint becomes invalid.
|
||||
//rollback trx to continue
|
||||
trx.rollback();
|
||||
}
|
||||
savepoint = null;
|
||||
}
|
||||
ctx.packIn.getNotifier().addFailureLine("SQL statement failed but ignored, error (" + e.getLocalizedMessage() + "): ");
|
||||
logImportDetail (ctx, impDetail, 0, "SQLStatement",-1,"Execute");
|
||||
ctx.packIn.getNotifier().addFailureLine("-> " + sql);
|
||||
log.log(Level.SEVERE,"SQLStatement", e);
|
||||
} finally {
|
||||
DB.close(pstmt);
|
||||
pstmt = null;
|
||||
if (savepoint != null) {
|
||||
Trx trx = Trx.get(getTrxName(ctx), false);
|
||||
try {
|
||||
trx.releaseSavepoint(savepoint);
|
||||
} catch (SQLException e) {
|
||||
if (DB.isPostgreSQL()) {
|
||||
//a commit or rollback have happens that make the savepoint invalid.
|
||||
//need to call rollback to continue
|
||||
trx.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
}
|
||||
|
||||
public void create(PIPOContext ctx, TransformerHandler document)
|
||||
throws SAXException {
|
||||
String SQLStatement = Env.getContext(ctx.ctx, SQLElementParameters.SQL_STATEMENT);
|
||||
String DBType = Env.getContext(ctx.ctx, SQLElementParameters.DB_TYPE);
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
addTypeName(atts, "custom");
|
||||
document.startElement("","","SQLStatement",atts);
|
||||
createSQLStatmentBinding(document, SQLStatement, DBType);
|
||||
document.endElement("","","SQLStatement");
|
||||
}
|
||||
|
||||
private void createSQLStatmentBinding( TransformerHandler document, String sqlStatement, String DBType) throws SAXException
|
||||
{
|
||||
document.startElement("","","DBType", new AttributesImpl());
|
||||
char[] contents = DBType.toCharArray();
|
||||
document.characters(contents,0,contents.length);
|
||||
document.endElement("","","DBType");
|
||||
|
||||
document.startElement("","","statement", new AttributesImpl());
|
||||
contents = sqlStatement.toCharArray();
|
||||
document.startCDATA();
|
||||
document.characters(contents,0,contents.length);
|
||||
document.endCDATA();
|
||||
document.endElement("","","statement");
|
||||
|
||||
}
|
||||
|
||||
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int field) throws Exception
|
||||
{
|
||||
PackoutItem detail = packout.getCurrentPackoutItem();
|
||||
Env.setContext(packout.getCtx().ctx, SQLElementParameters.SQL_STATEMENT, (String)detail.getProperty(SQLElementParameters.SQL_STATEMENT));
|
||||
Env.setContext(packout.getCtx().ctx, SQLElementParameters.DB_TYPE, (String)detail.getProperty(SQLElementParameters.DB_TYPE));
|
||||
this.create(packout.getCtx(), packoutHandler);
|
||||
packout.getCtx().ctx.remove(SQLElementParameters.SQL_STATEMENT);
|
||||
packout.getCtx().ctx.remove(SQLElementParameters.DB_TYPE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,9 +87,9 @@ public abstract class AbstractElementHandler implements ElementHandler {
|
|||
int id = 0;
|
||||
TransformerHandler hd_document = getLogDocument(ctx);
|
||||
AttributesImpl attsOut = new AttributesImpl();
|
||||
String result = success == 1 ? "Success" : "Failure";
|
||||
|
||||
//hd_documemt.startElement("","","Successful",attsOut);
|
||||
String result = success == 1 ? "Success" : "Failure";
|
||||
|
||||
//hd_documemt.startElement("","","Successful",attsOut);
|
||||
recordLayout.append("Type:")
|
||||
.append(objectType)
|
||||
.append(" - Name:")
|
||||
|
@ -98,28 +98,28 @@ public abstract class AbstractElementHandler implements ElementHandler {
|
|||
.append(objectID)
|
||||
.append(" - Action:")
|
||||
.append(objectStatus)
|
||||
.append(" - " + result);
|
||||
.append(" - " + result);
|
||||
|
||||
hd_document.startElement("","",result,attsOut);
|
||||
hd_document.startElement("","",result,attsOut);
|
||||
hd_document.characters(recordLayout.toString().toCharArray(),0,recordLayout.length());
|
||||
hd_document.endElement("","",result);
|
||||
hd_document.endElement("","",result);
|
||||
|
||||
X_AD_Package_Imp_Detail detail = new X_AD_Package_Imp_Detail(ctx, 0, getTrxName(ctx));
|
||||
detail.setAD_Package_Imp_ID(getPackageImpId(ctx));
|
||||
detail.setAD_Org_ID(Env.getAD_Org_ID(ctx) );
|
||||
detail.setType(objectType);
|
||||
detail.setName(objectName);
|
||||
detail.setAction(objectStatus);
|
||||
detail.setSuccess(result);
|
||||
detail.setRecord_ID(objectID);
|
||||
detail.setAD_Backup_ID(objectIDBackup);
|
||||
detail.setTableName(tableName);
|
||||
detail.setAD_Table_ID(AD_Table_ID);
|
||||
X_AD_Package_Imp_Detail detail = new X_AD_Package_Imp_Detail(ctx, 0, getTrxName(ctx));
|
||||
detail.setAD_Package_Imp_ID(getPackageImpId(ctx));
|
||||
detail.setAD_Org_ID(Env.getAD_Org_ID(ctx) );
|
||||
detail.setType(objectType);
|
||||
detail.setName(objectName);
|
||||
detail.setAction(objectStatus);
|
||||
detail.setSuccess(result);
|
||||
detail.setRecord_ID(objectID);
|
||||
detail.setAD_Backup_ID(objectIDBackup);
|
||||
detail.setTableName(tableName);
|
||||
detail.setAD_Table_ID(AD_Table_ID);
|
||||
|
||||
if ( !detail.save(getTrxName(ctx)) )
|
||||
if ( !detail.save(getTrxName(ctx)) )
|
||||
log.info("Insert to import detail failed");
|
||||
|
||||
id = detail.get_ID();
|
||||
id = detail.get_ID();
|
||||
|
||||
return id;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,453 +1,453 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 Adempiere, 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. *
|
||||
*
|
||||
* Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
|
||||
* Contributor(s): Low Heng Sin hengsin@avantz.com
|
||||
* Teo Sarca, teo.sarca@gmail.com
|
||||
*****************************************************************************/
|
||||
package org.adempiere.pipo.handler;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
import org.adempiere.pipo.AbstractElementHandler;
|
||||
import org.adempiere.pipo.Element;
|
||||
import org.adempiere.pipo.PackOut;
|
||||
import org.adempiere.pipo.exception.DatabaseAccessException;
|
||||
import org.adempiere.pipo.exception.POSaveFailedException;
|
||||
import org.compiere.model.X_AD_Package_Exp_Detail;
|
||||
import org.compiere.model.X_AD_WF_NextCondition;
|
||||
import org.compiere.model.X_AD_WF_Node;
|
||||
import org.compiere.model.X_AD_WF_NodeNext;
|
||||
import org.compiere.model.X_AD_Workflow;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.wf.MWorkflow;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class WorkflowElementHandler extends AbstractElementHandler {
|
||||
|
||||
private WorkflowNodeElementHandler nodeHandler = new WorkflowNodeElementHandler();
|
||||
private WorkflowNodeNextElementHandler nodeNextHandler = new WorkflowNodeNextElementHandler();
|
||||
private WorkflowNodeNextConditionElementHandler nextConditionHandler = new WorkflowNodeNextConditionElementHandler();
|
||||
|
||||
private List<Integer> workflows = new ArrayList<Integer>();
|
||||
|
||||
public void startElement(Properties ctx, Element element)
|
||||
throws SAXException {
|
||||
Attributes atts = element.attributes;
|
||||
String elementValue = element.getElementValue();
|
||||
if (log.isLoggable(Level.INFO)) log.info(elementValue + " " + atts.getValue("Name"));
|
||||
String entitytype = atts.getValue("EntityType");
|
||||
if (log.isLoggable(Level.INFO)) log.info("entitytype " + atts.getValue("EntityType"));
|
||||
|
||||
if (isProcessElement(ctx, entitytype)) {
|
||||
|
||||
String workflowName = atts.getValue("Name");
|
||||
|
||||
int id = get_IDWithColumn(ctx, "AD_Workflow", "name", workflowName);
|
||||
if (id > 0 && workflows.contains(id)) {
|
||||
element.skip = true;
|
||||
return;
|
||||
}
|
||||
|
||||
MWorkflow m_Workflow = new MWorkflow(ctx, id, getTrxName(ctx));
|
||||
int AD_Backup_ID = -1;
|
||||
String Object_Status = null;
|
||||
if (id <= 0 && atts.getValue("AD_Workflow_ID") != null && Integer.parseInt(atts.getValue("AD_Workflow_ID")) <= PackOut.MAX_OFFICIAL_ID)
|
||||
m_Workflow.setAD_Workflow_ID(Integer.parseInt(atts.getValue("AD_Workflow_ID")));
|
||||
if (id > 0) {
|
||||
AD_Backup_ID = copyRecord(ctx, "AD_Workflow", m_Workflow);
|
||||
Object_Status = "Update";
|
||||
} else {
|
||||
Object_Status = "New";
|
||||
AD_Backup_ID = 0;
|
||||
}
|
||||
|
||||
String name = atts.getValue("ADWorkflowResponsibleNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
id = get_IDWithColumn(ctx, "AD_WF_Responsible", "Name", name);
|
||||
if (id <= 0) {
|
||||
element.defer = true;
|
||||
element.unresolved = "AD_WF_Responsible: " + name;
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_WF_Responsible_ID(id);
|
||||
}
|
||||
|
||||
name = atts.getValue("ADTableNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
|
||||
if (id <= 0) {
|
||||
element.defer = true;
|
||||
element.unresolved = "AD_Table: " + name;
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_Table_ID(id);
|
||||
|
||||
}
|
||||
|
||||
name = atts.getValue("ADWorkflowProcessorNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
id = get_IDWithColumn(ctx, "AD_WorkflowProcessor", "Name", name);
|
||||
if (id <= 0) {
|
||||
element.defer = true;
|
||||
element.unresolved = "AD_WorkflowProcessor: " + name;
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_WorkflowProcessor_ID(id);
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 Adempiere, 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. *
|
||||
*
|
||||
* Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
|
||||
* Contributor(s): Low Heng Sin hengsin@avantz.com
|
||||
* Teo Sarca, teo.sarca@gmail.com
|
||||
*****************************************************************************/
|
||||
package org.adempiere.pipo.handler;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
import org.adempiere.pipo.AbstractElementHandler;
|
||||
import org.adempiere.pipo.Element;
|
||||
import org.adempiere.pipo.PackOut;
|
||||
import org.adempiere.pipo.exception.DatabaseAccessException;
|
||||
import org.adempiere.pipo.exception.POSaveFailedException;
|
||||
import org.compiere.model.X_AD_Package_Exp_Detail;
|
||||
import org.compiere.model.X_AD_WF_NextCondition;
|
||||
import org.compiere.model.X_AD_WF_Node;
|
||||
import org.compiere.model.X_AD_WF_NodeNext;
|
||||
import org.compiere.model.X_AD_Workflow;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.wf.MWorkflow;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class WorkflowElementHandler extends AbstractElementHandler {
|
||||
|
||||
private WorkflowNodeElementHandler nodeHandler = new WorkflowNodeElementHandler();
|
||||
private WorkflowNodeNextElementHandler nodeNextHandler = new WorkflowNodeNextElementHandler();
|
||||
private WorkflowNodeNextConditionElementHandler nextConditionHandler = new WorkflowNodeNextConditionElementHandler();
|
||||
|
||||
private List<Integer> workflows = new ArrayList<Integer>();
|
||||
|
||||
public void startElement(Properties ctx, Element element)
|
||||
throws SAXException {
|
||||
Attributes atts = element.attributes;
|
||||
String elementValue = element.getElementValue();
|
||||
if (log.isLoggable(Level.INFO)) log.info(elementValue + " " + atts.getValue("Name"));
|
||||
String entitytype = atts.getValue("EntityType");
|
||||
if (log.isLoggable(Level.INFO)) log.info("entitytype " + atts.getValue("EntityType"));
|
||||
|
||||
if (isProcessElement(ctx, entitytype)) {
|
||||
|
||||
String workflowName = atts.getValue("Name");
|
||||
|
||||
int id = get_IDWithColumn(ctx, "AD_Workflow", "name", workflowName);
|
||||
if (id > 0 && workflows.contains(id)) {
|
||||
element.skip = true;
|
||||
return;
|
||||
}
|
||||
|
||||
MWorkflow m_Workflow = new MWorkflow(ctx, id, getTrxName(ctx));
|
||||
int AD_Backup_ID = -1;
|
||||
String Object_Status = null;
|
||||
if (id <= 0 && atts.getValue("AD_Workflow_ID") != null && Integer.parseInt(atts.getValue("AD_Workflow_ID")) <= PackOut.MAX_OFFICIAL_ID)
|
||||
m_Workflow.setAD_Workflow_ID(Integer.parseInt(atts.getValue("AD_Workflow_ID")));
|
||||
if (id > 0) {
|
||||
AD_Backup_ID = copyRecord(ctx, "AD_Workflow", m_Workflow);
|
||||
Object_Status = "Update";
|
||||
} else {
|
||||
Object_Status = "New";
|
||||
AD_Backup_ID = 0;
|
||||
}
|
||||
|
||||
String name = atts.getValue("ADWorkflowResponsibleNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
id = get_IDWithColumn(ctx, "AD_WF_Responsible", "Name", name);
|
||||
if (id <= 0) {
|
||||
element.defer = true;
|
||||
element.unresolved = "AD_WF_Responsible: " + name;
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_WF_Responsible_ID(id);
|
||||
}
|
||||
|
||||
name = atts.getValue("ADTableNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
|
||||
if (id <= 0) {
|
||||
element.defer = true;
|
||||
element.unresolved = "AD_Table: " + name;
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_Table_ID(id);
|
||||
|
||||
}
|
||||
|
||||
name = atts.getValue("ADWorkflowProcessorNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
id = get_IDWithColumn(ctx, "AD_WorkflowProcessor", "Name", name);
|
||||
if (id <= 0) {
|
||||
element.defer = true;
|
||||
element.unresolved = "AD_WorkflowProcessor: " + name;
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_WorkflowProcessor_ID(id);
|
||||
|
||||
}
|
||||
|
||||
m_Workflow.setValue(atts.getValue("Value"));
|
||||
m_Workflow.setName(workflowName);
|
||||
m_Workflow.setIsBetaFunctionality (Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
|
||||
m_Workflow.setAccessLevel(atts.getValue("AccessLevel"));
|
||||
m_Workflow.setDescription(getStringValue(atts,"Description"));
|
||||
m_Workflow.setHelp(getStringValue(atts,"Help"));
|
||||
m_Workflow.setDurationUnit(getStringValue(atts,"DurationUnit"));
|
||||
m_Workflow.setAuthor(getStringValue(atts,"Author"));
|
||||
if(getStringValue(atts, "Version") != null)
|
||||
m_Workflow.setVersion(Integer.valueOf(atts.getValue("Version")));
|
||||
if(getStringValue(atts, "Priority") != null)
|
||||
m_Workflow.setPriority(Integer.valueOf(atts.getValue("Priority")));
|
||||
if(getStringValue(atts, "Limit") != null)
|
||||
m_Workflow.setLimit(Integer.valueOf(atts.getValue("Limit")));
|
||||
if(getStringValue(atts, "Duration") != null)
|
||||
m_Workflow.setDuration(Integer.valueOf(atts.getValue("Duration")));
|
||||
if(getStringValue(atts, "Cost") != null)
|
||||
m_Workflow.setCost(new BigDecimal(atts.getValue("Cost")));
|
||||
|
||||
m_Workflow.setWorkingTime(Integer.valueOf(atts
|
||||
.getValue("WorkingTime")));
|
||||
m_Workflow.setWaitingTime(Integer.valueOf(atts
|
||||
.getValue("WaitingTime")));
|
||||
m_Workflow.setPublishStatus(atts.getValue("PublishStatus"));
|
||||
m_Workflow.setWorkflowType(atts.getValue("WorkflowType"));
|
||||
m_Workflow.setDocValueLogic(getStringValue(atts,"DocValueLogic"));
|
||||
m_Workflow.setIsValid(atts.getValue("isValid") != null ? Boolean
|
||||
.valueOf(atts.getValue("isValid")).booleanValue() : true);
|
||||
m_Workflow.setEntityType(atts.getValue("EntityType"));
|
||||
m_Workflow.setAD_WF_Node_ID(-1);
|
||||
log.info("about to execute m_Workflow.save");
|
||||
if (m_Workflow.save(getTrxName(ctx)) == true) {
|
||||
log.info("m_Workflow save success");
|
||||
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
workflows.add(m_Workflow.getAD_Workflow_ID());
|
||||
element.recordId = m_Workflow.getAD_Workflow_ID();
|
||||
} else {
|
||||
log.info("m_Workflow save failure");
|
||||
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
throw new POSaveFailedException("MWorkflow");
|
||||
}
|
||||
} else {
|
||||
element.skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctx
|
||||
* @param element
|
||||
*/
|
||||
public void endElement(Properties ctx, Element element) throws SAXException {
|
||||
if (!element.defer && !element.skip && element.recordId > 0) {
|
||||
Attributes atts = element.attributes;
|
||||
//set start node
|
||||
String name = atts.getValue("ADWorkflowNodeNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
MWorkflow m_Workflow = new MWorkflow(ctx, element.recordId, getTrxName(ctx));
|
||||
int id = get_IDWithMasterAndColumn(ctx, "AD_WF_Node", "Name", name, "AD_Workflow", m_Workflow.getAD_Workflow_ID());
|
||||
if (id <= 0) {
|
||||
log.warning("Failed to resolve start node reference for workflow element. Workflow="
|
||||
+ m_Workflow.getName() + " StartNode=" + name);
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_WF_Node_ID(id);
|
||||
if (m_Workflow.save(getTrxName(ctx)) == true) {
|
||||
log.info("m_Workflow update success");
|
||||
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), 0, "Update", "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
workflows.add(m_Workflow.getAD_Workflow_ID());
|
||||
element.recordId = m_Workflow.getAD_Workflow_ID();
|
||||
} else {
|
||||
log.info("m_Workflow update fail");
|
||||
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), 0, "Update", "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
throw new POSaveFailedException("MWorkflow");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void create(Properties ctx, TransformerHandler document)
|
||||
throws SAXException {
|
||||
int AD_Workflow_ID = Env.getContextAsInt(ctx,
|
||||
X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID);
|
||||
if (workflows.contains(AD_Workflow_ID))
|
||||
return;
|
||||
|
||||
workflows.add(AD_Workflow_ID);
|
||||
String sql = "SELECT Name FROM AD_Workflow WHERE AD_Workflow_ID= "
|
||||
+ AD_Workflow_ID;
|
||||
int ad_wf_nodenext_id = 0;
|
||||
int ad_wf_nodenextcondition_id = 0;
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
|
||||
try {
|
||||
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
X_AD_Workflow m_Workflow = new X_AD_Workflow(ctx,
|
||||
AD_Workflow_ID, null);
|
||||
|
||||
createWorkflowBinding(atts, m_Workflow);
|
||||
document.startElement("", "", "workflow", atts);
|
||||
String sql1 = "SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID = "
|
||||
+ AD_Workflow_ID
|
||||
+ " ORDER BY "+X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID
|
||||
;
|
||||
|
||||
PreparedStatement pstmt1 = null;
|
||||
ResultSet rs1 = null;
|
||||
try {
|
||||
pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
|
||||
// Generated workflowNodeNext(s) and
|
||||
// workflowNodeNextCondition(s)
|
||||
rs1 = pstmt1.executeQuery();
|
||||
while (rs1.next()) {
|
||||
|
||||
int nodeId = rs1.getInt("AD_WF_Node_ID");
|
||||
createNode(ctx, document, nodeId);
|
||||
|
||||
ad_wf_nodenext_id = 0;
|
||||
|
||||
String sqlnn = "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID = ?"
|
||||
+ " ORDER BY "+X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID;
|
||||
PreparedStatement pstmtnn = null;
|
||||
ResultSet rsnn = null;
|
||||
try {
|
||||
pstmtnn = DB.prepareStatement(sqlnn, getTrxName(ctx));
|
||||
pstmtnn.setInt(1, nodeId);
|
||||
rsnn = pstmtnn.executeQuery();
|
||||
while (rsnn.next()) {
|
||||
ad_wf_nodenext_id = rsnn.getInt("AD_WF_NodeNext_ID");
|
||||
if (ad_wf_nodenext_id > 0) {
|
||||
createNodeNext(ctx, document, ad_wf_nodenext_id);
|
||||
|
||||
ad_wf_nodenextcondition_id = 0;
|
||||
|
||||
String sqlnnc = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID = ?"
|
||||
+ " ORDER BY "+X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID;
|
||||
PreparedStatement pstmtnnc = null;
|
||||
ResultSet rsnnc = null;
|
||||
try {
|
||||
pstmtnnc = DB.prepareStatement(sqlnnc, getTrxName(ctx));
|
||||
pstmtnnc.setInt(1, ad_wf_nodenext_id);
|
||||
rsnnc = pstmtnnc.executeQuery();
|
||||
while (rsnnc.next()) {
|
||||
ad_wf_nodenextcondition_id = rsnnc.getInt("AD_WF_NextCondition_ID");
|
||||
if (log.isLoggable(Level.INFO)) log.info("ad_wf_nodenextcondition_id: " + String.valueOf(ad_wf_nodenextcondition_id));
|
||||
if (ad_wf_nodenextcondition_id > 0) {
|
||||
createNodeNextCondition(ctx, document, ad_wf_nodenextcondition_id);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
DB.close(rsnnc, pstmtnnc);
|
||||
rsnnc = null;
|
||||
pstmtnnc = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
DB.close(rsnn, pstmtnn);
|
||||
rsnn = null;
|
||||
pstmtnn = null;
|
||||
}
|
||||
|
||||
}
|
||||
} finally {
|
||||
DB.close(rs1, pstmt1);
|
||||
rs1 = null;
|
||||
pstmt1 = null;
|
||||
|
||||
document.endElement("", "", "workflow");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Workflow", e);
|
||||
if (e instanceof SAXException)
|
||||
throw (SAXException) e;
|
||||
else if (e instanceof SQLException)
|
||||
throw new DatabaseAccessException("Failed to export workflow.", e);
|
||||
else
|
||||
throw new RuntimeException("Failed to export workflow.", e);
|
||||
} finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void createNodeNextCondition(Properties ctx,
|
||||
TransformerHandler document, int ad_wf_nodenextcondition_id)
|
||||
throws SAXException {
|
||||
Env.setContext(ctx,
|
||||
X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID,
|
||||
ad_wf_nodenextcondition_id);
|
||||
nextConditionHandler.create(ctx, document);
|
||||
ctx.remove(X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID);
|
||||
}
|
||||
|
||||
private void createNodeNext(Properties ctx, TransformerHandler document,
|
||||
int ad_wf_nodenext_id) throws SAXException {
|
||||
Env.setContext(ctx, X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID,
|
||||
ad_wf_nodenext_id);
|
||||
nodeNextHandler.create(ctx, document);
|
||||
ctx.remove(X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID);
|
||||
}
|
||||
|
||||
private void createNode(Properties ctx, TransformerHandler document,
|
||||
int AD_WF_Node_ID) throws SAXException {
|
||||
Env.setContext(ctx, X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID,
|
||||
AD_WF_Node_ID);
|
||||
nodeHandler.create(ctx, document);
|
||||
ctx.remove(X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID);
|
||||
}
|
||||
|
||||
private AttributesImpl createWorkflowBinding(AttributesImpl atts,
|
||||
X_AD_Workflow m_Workflow) {
|
||||
String sql = null;
|
||||
String name = null;
|
||||
atts.clear();
|
||||
if (m_Workflow.getAD_Workflow_ID() <= PackOut.MAX_OFFICIAL_ID)
|
||||
atts.addAttribute("","","AD_Workflow_ID","CDATA",Integer.toString(m_Workflow.getAD_Workflow_ID()));
|
||||
atts.addAttribute("", "", "Value", "CDATA", (m_Workflow.getValue() != null ? m_Workflow.getValue() : ""));
|
||||
atts.addAttribute("", "", "Name", "CDATA",
|
||||
(m_Workflow.getName() != null ? m_Workflow.getName() : ""));
|
||||
if (m_Workflow.getAD_Table_ID() > 0) {
|
||||
sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow.getAD_Table_ID());
|
||||
atts.addAttribute("", "", "ADTableNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADTableNameID", "CDATA", "");
|
||||
|
||||
if (m_Workflow.getAD_WF_Node_ID() > 0) {
|
||||
sql = "SELECT Name FROM AD_WF_Node WHERE AD_WF_Node_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow
|
||||
.getAD_WF_Node_ID());
|
||||
atts.addAttribute("", "", "ADWorkflowNodeNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADWorkflowNodeNameID", "CDATA", "");
|
||||
|
||||
if (m_Workflow.getAD_WF_Responsible_ID() > 0) {
|
||||
sql = "SELECT Name FROM AD_WF_Responsible WHERE AD_WF_Responsible_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow
|
||||
.getAD_WF_Responsible_ID());
|
||||
atts.addAttribute("", "", "ADWorkflowResponsibleNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADWorkflowResponsibleNameID", "CDATA",
|
||||
"");
|
||||
|
||||
if (m_Workflow.getAD_WorkflowProcessor_ID() > 0) {
|
||||
sql = "SELECT Name FROM AD_WorkflowProcessor_ID WHERE AD_WorkflowProcessor_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow
|
||||
.getAD_WorkflowProcessor_ID());
|
||||
atts.addAttribute("", "", "ADWorkflowProcessorNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADWorkflowProcessorNameID", "CDATA", "");
|
||||
|
||||
atts.addAttribute("","","isBetaFunctionality","CDATA",(m_Workflow.isBetaFunctionality()== true ? "true":"false"));
|
||||
|
||||
atts.addAttribute("", "", "AccessLevel", "CDATA", (m_Workflow
|
||||
.getAccessLevel() != null ? m_Workflow.getAccessLevel() : ""));
|
||||
atts
|
||||
.addAttribute("", "", "DurationUnit", "CDATA", (m_Workflow
|
||||
.getDurationUnit() != null ? m_Workflow
|
||||
.getDurationUnit() : ""));
|
||||
atts.addAttribute("", "", "Help", "CDATA",
|
||||
(m_Workflow.getHelp() != null ? m_Workflow.getHelp() : ""));
|
||||
atts.addAttribute("", "", "Description", "CDATA", (m_Workflow
|
||||
.getDescription() != null ? m_Workflow.getDescription() : ""));
|
||||
atts.addAttribute("", "", "EntityType", "CDATA", (m_Workflow
|
||||
.getEntityType() != null ? m_Workflow.getEntityType() : ""));
|
||||
atts.addAttribute("", "", "Author", "CDATA",
|
||||
(m_Workflow.getAuthor() != null ? m_Workflow.getAuthor() : ""));
|
||||
atts.addAttribute("", "", "Version", "CDATA", (""
|
||||
+ m_Workflow.getVersion() != null ? ""
|
||||
+ m_Workflow.getVersion() : ""));
|
||||
// FIXME: Handle dates
|
||||
// atts.addAttribute("","","ValidFrom","CDATA",(m_Workflow.getValidFrom
|
||||
// ().toGMTString() != null ?
|
||||
// m_Workflow.getValidFrom().toGMTString():""));
|
||||
// atts.addAttribute("","","ValidTo","CDATA",(m_Workflow.getValidTo
|
||||
// ().toGMTString() != null ?
|
||||
// m_Workflow.getValidTo().toGMTString():""));
|
||||
atts.addAttribute("", "", "Priority", "CDATA", ("" + m_Workflow
|
||||
.getPriority()));
|
||||
atts.addAttribute("", "", "Limit", "CDATA",
|
||||
("" + m_Workflow.getLimit()));
|
||||
atts.addAttribute("", "", "Duration", "CDATA", ("" + m_Workflow
|
||||
.getDuration()));
|
||||
atts.addAttribute("", "", "Cost", "CDATA", ("" + m_Workflow.getCost()));
|
||||
atts.addAttribute("", "", "WorkingTime", "CDATA", ("" + m_Workflow
|
||||
.getWorkingTime()));
|
||||
atts.addAttribute("", "", "WaitingTime", "CDATA", ("" + m_Workflow
|
||||
.getWaitingTime()));
|
||||
atts.addAttribute("", "", "PublishStatus", "CDATA", (m_Workflow
|
||||
.getPublishStatus() != null ? m_Workflow.getPublishStatus()
|
||||
: ""));
|
||||
atts
|
||||
.addAttribute("", "", "WorkflowType", "CDATA", (m_Workflow
|
||||
.getWorkflowType() != null ? m_Workflow
|
||||
.getWorkflowType() : ""));
|
||||
atts.addAttribute("", "", "DocValueLogic", "CDATA", (m_Workflow
|
||||
.getDocValueLogic() != null ? m_Workflow.getDocValueLogic()
|
||||
: ""));
|
||||
atts.addAttribute("", "", "isValid", "CDATA",
|
||||
(m_Workflow.isValid() == true ? "true" : "false"));
|
||||
// Doesn't appear to be necessary
|
||||
// atts.addAttribute("","","SetupTime","CDATA",(""+m_Workflow.getSetupTime()
|
||||
// != null ? ""+m_Workflow.getSetupTime():""));
|
||||
return atts;
|
||||
}
|
||||
}
|
||||
m_Workflow.setName(workflowName);
|
||||
m_Workflow.setIsBetaFunctionality (Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
|
||||
m_Workflow.setAccessLevel(atts.getValue("AccessLevel"));
|
||||
m_Workflow.setDescription(getStringValue(atts,"Description"));
|
||||
m_Workflow.setHelp(getStringValue(atts,"Help"));
|
||||
m_Workflow.setDurationUnit(getStringValue(atts,"DurationUnit"));
|
||||
m_Workflow.setAuthor(getStringValue(atts,"Author"));
|
||||
if(getStringValue(atts, "Version") != null)
|
||||
m_Workflow.setVersion(Integer.valueOf(atts.getValue("Version")));
|
||||
if(getStringValue(atts, "Priority") != null)
|
||||
m_Workflow.setPriority(Integer.valueOf(atts.getValue("Priority")));
|
||||
if(getStringValue(atts, "Limit") != null)
|
||||
m_Workflow.setLimit(Integer.valueOf(atts.getValue("Limit")));
|
||||
if(getStringValue(atts, "Duration") != null)
|
||||
m_Workflow.setDuration(Integer.valueOf(atts.getValue("Duration")));
|
||||
if(getStringValue(atts, "Cost") != null)
|
||||
m_Workflow.setCost(new BigDecimal(atts.getValue("Cost")));
|
||||
|
||||
m_Workflow.setWorkingTime(Integer.valueOf(atts
|
||||
.getValue("WorkingTime")));
|
||||
m_Workflow.setWaitingTime(Integer.valueOf(atts
|
||||
.getValue("WaitingTime")));
|
||||
m_Workflow.setPublishStatus(atts.getValue("PublishStatus"));
|
||||
m_Workflow.setWorkflowType(atts.getValue("WorkflowType"));
|
||||
m_Workflow.setDocValueLogic(getStringValue(atts,"DocValueLogic"));
|
||||
m_Workflow.setIsValid(atts.getValue("isValid") != null ? Boolean
|
||||
.valueOf(atts.getValue("isValid")).booleanValue() : true);
|
||||
m_Workflow.setEntityType(atts.getValue("EntityType"));
|
||||
m_Workflow.setAD_WF_Node_ID(-1);
|
||||
log.info("about to execute m_Workflow.save");
|
||||
if (m_Workflow.save(getTrxName(ctx)) == true) {
|
||||
log.info("m_Workflow save success");
|
||||
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
workflows.add(m_Workflow.getAD_Workflow_ID());
|
||||
element.recordId = m_Workflow.getAD_Workflow_ID();
|
||||
} else {
|
||||
log.info("m_Workflow save failure");
|
||||
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
throw new POSaveFailedException("MWorkflow");
|
||||
}
|
||||
} else {
|
||||
element.skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctx
|
||||
* @param element
|
||||
*/
|
||||
public void endElement(Properties ctx, Element element) throws SAXException {
|
||||
if (!element.defer && !element.skip && element.recordId > 0) {
|
||||
Attributes atts = element.attributes;
|
||||
//set start node
|
||||
String name = atts.getValue("ADWorkflowNodeNameID");
|
||||
if (name != null && name.trim().length() > 0) {
|
||||
MWorkflow m_Workflow = new MWorkflow(ctx, element.recordId, getTrxName(ctx));
|
||||
int id = get_IDWithMasterAndColumn(ctx, "AD_WF_Node", "Name", name, "AD_Workflow", m_Workflow.getAD_Workflow_ID());
|
||||
if (id <= 0) {
|
||||
log.warning("Failed to resolve start node reference for workflow element. Workflow="
|
||||
+ m_Workflow.getName() + " StartNode=" + name);
|
||||
return;
|
||||
}
|
||||
m_Workflow.setAD_WF_Node_ID(id);
|
||||
if (m_Workflow.save(getTrxName(ctx)) == true) {
|
||||
log.info("m_Workflow update success");
|
||||
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), 0, "Update", "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
workflows.add(m_Workflow.getAD_Workflow_ID());
|
||||
element.recordId = m_Workflow.getAD_Workflow_ID();
|
||||
} else {
|
||||
log.info("m_Workflow update fail");
|
||||
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
|
||||
.get_ID(), 0, "Update", "AD_Workflow",
|
||||
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||
"AD_Workflow"));
|
||||
throw new POSaveFailedException("MWorkflow");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void create(Properties ctx, TransformerHandler document)
|
||||
throws SAXException {
|
||||
int AD_Workflow_ID = Env.getContextAsInt(ctx,
|
||||
X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID);
|
||||
if (workflows.contains(AD_Workflow_ID))
|
||||
return;
|
||||
|
||||
workflows.add(AD_Workflow_ID);
|
||||
String sql = "SELECT Name FROM AD_Workflow WHERE AD_Workflow_ID= "
|
||||
+ AD_Workflow_ID;
|
||||
int ad_wf_nodenext_id = 0;
|
||||
int ad_wf_nodenextcondition_id = 0;
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
|
||||
try {
|
||||
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
X_AD_Workflow m_Workflow = new X_AD_Workflow(ctx,
|
||||
AD_Workflow_ID, null);
|
||||
|
||||
createWorkflowBinding(atts, m_Workflow);
|
||||
document.startElement("", "", "workflow", atts);
|
||||
String sql1 = "SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID = "
|
||||
+ AD_Workflow_ID
|
||||
+ " ORDER BY "+X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID
|
||||
;
|
||||
|
||||
PreparedStatement pstmt1 = null;
|
||||
ResultSet rs1 = null;
|
||||
try {
|
||||
pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
|
||||
// Generated workflowNodeNext(s) and
|
||||
// workflowNodeNextCondition(s)
|
||||
rs1 = pstmt1.executeQuery();
|
||||
while (rs1.next()) {
|
||||
|
||||
int nodeId = rs1.getInt("AD_WF_Node_ID");
|
||||
createNode(ctx, document, nodeId);
|
||||
|
||||
ad_wf_nodenext_id = 0;
|
||||
|
||||
String sqlnn = "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID = ?"
|
||||
+ " ORDER BY "+X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID;
|
||||
PreparedStatement pstmtnn = null;
|
||||
ResultSet rsnn = null;
|
||||
try {
|
||||
pstmtnn = DB.prepareStatement(sqlnn, getTrxName(ctx));
|
||||
pstmtnn.setInt(1, nodeId);
|
||||
rsnn = pstmtnn.executeQuery();
|
||||
while (rsnn.next()) {
|
||||
ad_wf_nodenext_id = rsnn.getInt("AD_WF_NodeNext_ID");
|
||||
if (ad_wf_nodenext_id > 0) {
|
||||
createNodeNext(ctx, document, ad_wf_nodenext_id);
|
||||
|
||||
ad_wf_nodenextcondition_id = 0;
|
||||
|
||||
String sqlnnc = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID = ?"
|
||||
+ " ORDER BY "+X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID;
|
||||
PreparedStatement pstmtnnc = null;
|
||||
ResultSet rsnnc = null;
|
||||
try {
|
||||
pstmtnnc = DB.prepareStatement(sqlnnc, getTrxName(ctx));
|
||||
pstmtnnc.setInt(1, ad_wf_nodenext_id);
|
||||
rsnnc = pstmtnnc.executeQuery();
|
||||
while (rsnnc.next()) {
|
||||
ad_wf_nodenextcondition_id = rsnnc.getInt("AD_WF_NextCondition_ID");
|
||||
if (log.isLoggable(Level.INFO)) log.info("ad_wf_nodenextcondition_id: " + String.valueOf(ad_wf_nodenextcondition_id));
|
||||
if (ad_wf_nodenextcondition_id > 0) {
|
||||
createNodeNextCondition(ctx, document, ad_wf_nodenextcondition_id);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
DB.close(rsnnc, pstmtnnc);
|
||||
rsnnc = null;
|
||||
pstmtnnc = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
DB.close(rsnn, pstmtnn);
|
||||
rsnn = null;
|
||||
pstmtnn = null;
|
||||
}
|
||||
|
||||
}
|
||||
} finally {
|
||||
DB.close(rs1, pstmt1);
|
||||
rs1 = null;
|
||||
pstmt1 = null;
|
||||
|
||||
document.endElement("", "", "workflow");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Workflow", e);
|
||||
if (e instanceof SAXException)
|
||||
throw (SAXException) e;
|
||||
else if (e instanceof SQLException)
|
||||
throw new DatabaseAccessException("Failed to export workflow.", e);
|
||||
else
|
||||
throw new RuntimeException("Failed to export workflow.", e);
|
||||
} finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void createNodeNextCondition(Properties ctx,
|
||||
TransformerHandler document, int ad_wf_nodenextcondition_id)
|
||||
throws SAXException {
|
||||
Env.setContext(ctx,
|
||||
X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID,
|
||||
ad_wf_nodenextcondition_id);
|
||||
nextConditionHandler.create(ctx, document);
|
||||
ctx.remove(X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID);
|
||||
}
|
||||
|
||||
private void createNodeNext(Properties ctx, TransformerHandler document,
|
||||
int ad_wf_nodenext_id) throws SAXException {
|
||||
Env.setContext(ctx, X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID,
|
||||
ad_wf_nodenext_id);
|
||||
nodeNextHandler.create(ctx, document);
|
||||
ctx.remove(X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID);
|
||||
}
|
||||
|
||||
private void createNode(Properties ctx, TransformerHandler document,
|
||||
int AD_WF_Node_ID) throws SAXException {
|
||||
Env.setContext(ctx, X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID,
|
||||
AD_WF_Node_ID);
|
||||
nodeHandler.create(ctx, document);
|
||||
ctx.remove(X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID);
|
||||
}
|
||||
|
||||
private AttributesImpl createWorkflowBinding(AttributesImpl atts,
|
||||
X_AD_Workflow m_Workflow) {
|
||||
String sql = null;
|
||||
String name = null;
|
||||
atts.clear();
|
||||
if (m_Workflow.getAD_Workflow_ID() <= PackOut.MAX_OFFICIAL_ID)
|
||||
atts.addAttribute("","","AD_Workflow_ID","CDATA",Integer.toString(m_Workflow.getAD_Workflow_ID()));
|
||||
atts.addAttribute("", "", "Value", "CDATA", (m_Workflow.getValue() != null ? m_Workflow.getValue() : ""));
|
||||
atts.addAttribute("", "", "Name", "CDATA",
|
||||
(m_Workflow.getName() != null ? m_Workflow.getName() : ""));
|
||||
if (m_Workflow.getAD_Table_ID() > 0) {
|
||||
sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow.getAD_Table_ID());
|
||||
atts.addAttribute("", "", "ADTableNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADTableNameID", "CDATA", "");
|
||||
|
||||
if (m_Workflow.getAD_WF_Node_ID() > 0) {
|
||||
sql = "SELECT Name FROM AD_WF_Node WHERE AD_WF_Node_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow
|
||||
.getAD_WF_Node_ID());
|
||||
atts.addAttribute("", "", "ADWorkflowNodeNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADWorkflowNodeNameID", "CDATA", "");
|
||||
|
||||
if (m_Workflow.getAD_WF_Responsible_ID() > 0) {
|
||||
sql = "SELECT Name FROM AD_WF_Responsible WHERE AD_WF_Responsible_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow
|
||||
.getAD_WF_Responsible_ID());
|
||||
atts.addAttribute("", "", "ADWorkflowResponsibleNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADWorkflowResponsibleNameID", "CDATA",
|
||||
"");
|
||||
|
||||
if (m_Workflow.getAD_WorkflowProcessor_ID() > 0) {
|
||||
sql = "SELECT Name FROM AD_WorkflowProcessor_ID WHERE AD_WorkflowProcessor_ID=?";
|
||||
name = DB.getSQLValueString(null, sql, m_Workflow
|
||||
.getAD_WorkflowProcessor_ID());
|
||||
atts.addAttribute("", "", "ADWorkflowProcessorNameID", "CDATA",
|
||||
(name != null ? name : ""));
|
||||
} else
|
||||
atts.addAttribute("", "", "ADWorkflowProcessorNameID", "CDATA", "");
|
||||
|
||||
atts.addAttribute("","","isBetaFunctionality","CDATA",(m_Workflow.isBetaFunctionality()== true ? "true":"false"));
|
||||
|
||||
atts.addAttribute("", "", "AccessLevel", "CDATA", (m_Workflow
|
||||
.getAccessLevel() != null ? m_Workflow.getAccessLevel() : ""));
|
||||
atts
|
||||
.addAttribute("", "", "DurationUnit", "CDATA", (m_Workflow
|
||||
.getDurationUnit() != null ? m_Workflow
|
||||
.getDurationUnit() : ""));
|
||||
atts.addAttribute("", "", "Help", "CDATA",
|
||||
(m_Workflow.getHelp() != null ? m_Workflow.getHelp() : ""));
|
||||
atts.addAttribute("", "", "Description", "CDATA", (m_Workflow
|
||||
.getDescription() != null ? m_Workflow.getDescription() : ""));
|
||||
atts.addAttribute("", "", "EntityType", "CDATA", (m_Workflow
|
||||
.getEntityType() != null ? m_Workflow.getEntityType() : ""));
|
||||
atts.addAttribute("", "", "Author", "CDATA",
|
||||
(m_Workflow.getAuthor() != null ? m_Workflow.getAuthor() : ""));
|
||||
atts.addAttribute("", "", "Version", "CDATA", (""
|
||||
+ m_Workflow.getVersion() != null ? ""
|
||||
+ m_Workflow.getVersion() : ""));
|
||||
// FIXME: Handle dates
|
||||
// atts.addAttribute("","","ValidFrom","CDATA",(m_Workflow.getValidFrom
|
||||
// ().toGMTString() != null ?
|
||||
// m_Workflow.getValidFrom().toGMTString():""));
|
||||
// atts.addAttribute("","","ValidTo","CDATA",(m_Workflow.getValidTo
|
||||
// ().toGMTString() != null ?
|
||||
// m_Workflow.getValidTo().toGMTString():""));
|
||||
atts.addAttribute("", "", "Priority", "CDATA", ("" + m_Workflow
|
||||
.getPriority()));
|
||||
atts.addAttribute("", "", "Limit", "CDATA",
|
||||
("" + m_Workflow.getLimit()));
|
||||
atts.addAttribute("", "", "Duration", "CDATA", ("" + m_Workflow
|
||||
.getDuration()));
|
||||
atts.addAttribute("", "", "Cost", "CDATA", ("" + m_Workflow.getCost()));
|
||||
atts.addAttribute("", "", "WorkingTime", "CDATA", ("" + m_Workflow
|
||||
.getWorkingTime()));
|
||||
atts.addAttribute("", "", "WaitingTime", "CDATA", ("" + m_Workflow
|
||||
.getWaitingTime()));
|
||||
atts.addAttribute("", "", "PublishStatus", "CDATA", (m_Workflow
|
||||
.getPublishStatus() != null ? m_Workflow.getPublishStatus()
|
||||
: ""));
|
||||
atts
|
||||
.addAttribute("", "", "WorkflowType", "CDATA", (m_Workflow
|
||||
.getWorkflowType() != null ? m_Workflow
|
||||
.getWorkflowType() : ""));
|
||||
atts.addAttribute("", "", "DocValueLogic", "CDATA", (m_Workflow
|
||||
.getDocValueLogic() != null ? m_Workflow.getDocValueLogic()
|
||||
: ""));
|
||||
atts.addAttribute("", "", "isValid", "CDATA",
|
||||
(m_Workflow.isValid() == true ? "true" : "false"));
|
||||
// Doesn't appear to be necessary
|
||||
// atts.addAttribute("","","SetupTime","CDATA",(""+m_Workflow.getSetupTime()
|
||||
// != null ? ""+m_Workflow.getSetupTime():""));
|
||||
return atts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
//PackOutTest.java
|
||||
package test.functional;
|
||||
|
||||
import org.adempiere.pipo.IDFinder;
|
||||
import org.adempiere.pipo.PackInHandler;
|
||||
import org.adempiere.pipo.PackOut;
|
||||
import org.compiere.model.MLocation;
|
||||
import org.compiere.model.MPackageExp;
|
||||
import org.compiere.model.X_AD_Package_Exp_Detail;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class PackOutTest extends AdempiereTestCase {
|
||||
|
||||
// Test: Specific variables
|
||||
@SuppressWarnings("unused")
|
||||
private MLocation location = null;
|
||||
|
||||
|
||||
public void testPackOut() {
|
||||
//PackOutTest.java
|
||||
package test.functional;
|
||||
|
||||
import org.adempiere.pipo.IDFinder;
|
||||
import org.adempiere.pipo.PackInHandler;
|
||||
import org.adempiere.pipo.PackOut;
|
||||
import org.compiere.model.MLocation;
|
||||
import org.compiere.model.MPackageExp;
|
||||
import org.compiere.model.X_AD_Package_Exp_Detail;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
public class PackOutTest extends AdempiereTestCase {
|
||||
|
||||
// Test: Specific variables
|
||||
@SuppressWarnings("unused")
|
||||
private MLocation location = null;
|
||||
|
||||
|
||||
public void testPackOut() {
|
||||
PackOut m_PackOut = new PackOut();
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings("unused")
|
||||
PackInHandler m_PackInHandler = new PackInHandler();
|
||||
Trx m_trx = Trx.get(getTrxName(), true);
|
||||
int m_ad_process_id = IDFinder.get_IDWithColumn("ad_process", "Name", "PackOut", getAD_Client_ID(), getTrxName());
|
||||
|
@ -40,7 +40,7 @@ public class PackOutTest extends AdempiereTestCase {
|
|||
m_MPackageExp.setVersion("1.0");
|
||||
m_MPackageExp.setPK_Version("1.0");
|
||||
|
||||
boolean saveResult = m_MPackageExp.save();
|
||||
boolean saveResult = m_MPackageExp.save();
|
||||
assertTrue("MPackageExp.save()", saveResult);
|
||||
|
||||
X_AD_Package_Exp_Detail m_PackDetail =new X_AD_Package_Exp_Detail(getCtx(), 0, getTrxName());
|
||||
|
@ -69,20 +69,20 @@ public class PackOutTest extends AdempiereTestCase {
|
|||
m_PackDetail.setAD_ReportView_ID(rs.getInt("AD_REPORTVIEW_ID"));
|
||||
*/
|
||||
m_PackDetail.setLine(10);
|
||||
saveResult = m_PackDetail.save();
|
||||
assertTrue("X_AD_Package_Exp_Detail.save()", saveResult);
|
||||
saveResult = m_PackDetail.save();
|
||||
assertTrue("X_AD_Package_Exp_Detail.save()", saveResult);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings("unused")
|
||||
int m_ad_record_id = IDFinder.get_IDWithColumn("ad_package_exp", "Name", "test2packJunit", getAD_Client_ID(), getTrxName());
|
||||
|
||||
ProcessInfo m_ProcessInfo = new ProcessInfo("PackOut", m_ad_process_id, m_ad_table_id, m_MPackageExp.get_ID());
|
||||
m_PackOut.startProcess(getCtx(), m_ProcessInfo, m_trx);
|
||||
assertFalse("PackOut", m_ProcessInfo.isError());
|
||||
|
||||
try {
|
||||
commit();
|
||||
} catch (Exception e) {
|
||||
fail(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
assertFalse("PackOut", m_ProcessInfo.isError());
|
||||
|
||||
try {
|
||||
commit();
|
||||
} catch (Exception e) {
|
||||
fail(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.compiere.model.PO;
|
|||
import org.compiere.model.POInfo;
|
||||
import org.compiere.model.X_AD_EntityType;
|
||||
import org.compiere.model.X_AD_Package_Imp_Backup;
|
||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,54 +1,54 @@
|
|||
@Echo idempiere Database Import $Revision: 1.3 $
|
||||
|
||||
@Rem $Id: ImportIdempiere.bat,v 1.3 2005/01/22 21:59:15 jjanke Exp $
|
||||
|
||||
@Echo Importing idempiere DB from %IDEMPIERE_HOME%\data\seed\Adempiere%5.dmp (%ADEMPIERE_DB_NAME%)
|
||||
|
||||
@if (%IDEMPIERE_HOME%) == () goto environment
|
||||
@if (%ADEMPIERE_DB_NAME%) == () goto environment
|
||||
@if (%ADEMPIERE_DB_SERVER%) == () goto environment
|
||||
@if (%ADEMPIERE_DB_PORT%) == () goto environment
|
||||
@Rem Must have parameters systemAccount AdempiereID AdempierePwd
|
||||
@if (%1) == () goto usage
|
||||
@if (%2) == () goto usage
|
||||
@if (%3) == () goto usage
|
||||
|
||||
@set PGPASSWORD=%4
|
||||
@echo -------------------------------------
|
||||
@echo Re-Create user and database
|
||||
@echo -------------------------------------
|
||||
@dropdb -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %ADEMPIERE_DB_NAME%
|
||||
@dropuser -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %2
|
||||
@set ADEMPIERE_CREATE_ROLE_SQL=CREATE ROLE %2 SUPERUSER LOGIN PASSWORD '%3'
|
||||
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres -c "%ADEMPIERE_CREATE_ROLE_SQL%"
|
||||
@set ADEMPIERE_CREATE_ROLE_SQL=
|
||||
|
||||
@set PGPASSWORD=%3
|
||||
@createdb --template=template0 -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -E UNICODE -O %2 -U %2 %ADEMPIERE_DB_NAME%
|
||||
|
||||
@echo -------------------------------------
|
||||
@echo Import Adempiere%5.dmp
|
||||
@echo -------------------------------------
|
||||
@Echo idempiere Database Import $Revision: 1.3 $
|
||||
|
||||
@Rem $Id: ImportIdempiere.bat,v 1.3 2005/01/22 21:59:15 jjanke Exp $
|
||||
|
||||
@Echo Importing idempiere DB from %IDEMPIERE_HOME%\data\seed\Adempiere%5.dmp (%ADEMPIERE_DB_NAME%)
|
||||
|
||||
@if (%IDEMPIERE_HOME%) == () goto environment
|
||||
@if (%ADEMPIERE_DB_NAME%) == () goto environment
|
||||
@if (%ADEMPIERE_DB_SERVER%) == () goto environment
|
||||
@if (%ADEMPIERE_DB_PORT%) == () goto environment
|
||||
@Rem Must have parameters systemAccount AdempiereID AdempierePwd
|
||||
@if (%1) == () goto usage
|
||||
@if (%2) == () goto usage
|
||||
@if (%3) == () goto usage
|
||||
|
||||
@set PGPASSWORD=%4
|
||||
@echo -------------------------------------
|
||||
@echo Re-Create user and database
|
||||
@echo -------------------------------------
|
||||
@dropdb -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %ADEMPIERE_DB_NAME%
|
||||
@dropuser -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %2
|
||||
@set ADEMPIERE_CREATE_ROLE_SQL=CREATE ROLE %2 SUPERUSER LOGIN PASSWORD '%3'
|
||||
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres -c "%ADEMPIERE_CREATE_ROLE_SQL%"
|
||||
@set ADEMPIERE_CREATE_ROLE_SQL=
|
||||
|
||||
@set PGPASSWORD=%3
|
||||
@createdb --template=template0 -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -E UNICODE -O %2 -U %2 %ADEMPIERE_DB_NAME%
|
||||
|
||||
@echo -------------------------------------
|
||||
@echo Import Adempiere%5.dmp
|
||||
@echo -------------------------------------
|
||||
@set ADEMPIERE_ALTER_ROLE_SQL=ALTER ROLE %2 SET search_path TO adempiere, pg_catalog
|
||||
|
||||
|
||||
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -c "%ADEMPIERE_ALTER_ROLE_SQL%"
|
||||
|
||||
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -f %IDEMPIERE_HOME%/data/seed/Adempiere%5.dmp
|
||||
|
||||
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -f %IDEMPIERE_HOME%/data/seed/Adempiere%5.dmp
|
||||
@set ADEMPIERE_ALTER_ROLE_SQL=
|
||||
|
||||
|
||||
@set PGPASSWORD=
|
||||
@goto end
|
||||
|
||||
:environment
|
||||
@Echo Please make sure that the enviroment variables are set correctly:
|
||||
@Echo IDEMPIERE_HOME e.g. D:\idempiere
|
||||
@Echo ADEMPIERE_DB_NAME e.g. adempiere
|
||||
@Echo ADEMPIERE_DB_SERVER e.g. dbserver.idempiere.org
|
||||
@Echo ADEMPIERE_DB_PORT e.g. 5432
|
||||
|
||||
:usage
|
||||
@echo Usage: %0 <systemAccount> <AdempiereID> <AdempierePwd> <PostgresPwd>
|
||||
@echo Example: %0 postgres idempiere idempiere postgresPwd
|
||||
|
||||
:end
|
||||
|
||||
@set PGPASSWORD=
|
||||
@goto end
|
||||
|
||||
:environment
|
||||
@Echo Please make sure that the enviroment variables are set correctly:
|
||||
@Echo IDEMPIERE_HOME e.g. D:\idempiere
|
||||
@Echo ADEMPIERE_DB_NAME e.g. adempiere
|
||||
@Echo ADEMPIERE_DB_SERVER e.g. dbserver.idempiere.org
|
||||
@Echo ADEMPIERE_DB_PORT e.g. 5432
|
||||
|
||||
:usage
|
||||
@echo Usage: %0 <systemAccount> <AdempiereID> <AdempierePwd> <PostgresPwd>
|
||||
@echo Example: %0 postgres idempiere idempiere postgresPwd
|
||||
|
||||
:end
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
/******************************************************************************
|
||||
* 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.ldap;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.Hashtable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
|
||||
import org.compiere.model.MLdapProcessor;
|
||||
import org.compiere.model.MLdapUser;
|
||||
import org.compiere.util.CLogger;
|
||||
/******************************************************************************
|
||||
* 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.ldap;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.Hashtable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
|
||||
import org.compiere.model.MLdapProcessor;
|
||||
import org.compiere.model.MLdapUser;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
/**
|
||||
* LDAP Connection Handler
|
||||
|
@ -57,14 +57,14 @@ import org.compiere.util.CLogger;
|
|||
* - bind again with returned object name and password
|
||||
* The protocol for the java client, please refer to the sample code in main().
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: LdapConnectionHandler.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
||||
*/
|
||||
public class LdapConnectionHandler extends Thread
|
||||
{
|
||||
/**
|
||||
* Ldap Connection Handler
|
||||
* @param socket server socket
|
||||
* @author Jorg Janke
|
||||
* @version $Id: LdapConnectionHandler.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
||||
*/
|
||||
public class LdapConnectionHandler extends Thread
|
||||
{
|
||||
/**
|
||||
* Ldap Connection Handler
|
||||
* @param socket server socket
|
||||
* @param model model
|
||||
*/
|
||||
public LdapConnectionHandler(Socket socket, MLdapProcessor model)
|
||||
|
@ -74,43 +74,43 @@ public class LdapConnectionHandler extends Thread
|
|||
m_socket = socket;
|
||||
m_socket.setTcpNoDelay(true); // should not be required
|
||||
m_model = model;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
} // no timeout
|
||||
} // LdapConnectionHandler
|
||||
|
||||
/** Socket */
|
||||
private Socket m_socket = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
} // no timeout
|
||||
} // LdapConnectionHandler
|
||||
|
||||
/** Socket */
|
||||
private Socket m_socket = null;
|
||||
/** Ldap Model */
|
||||
private MLdapProcessor m_model = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger (LdapConnectionHandler.class);
|
||||
|
||||
|
||||
/**
|
||||
* Do Work
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_socket == null || m_socket.isClosed())
|
||||
return;
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger (LdapConnectionHandler.class);
|
||||
|
||||
|
||||
/**
|
||||
* Do Work
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_socket == null || m_socket.isClosed())
|
||||
return;
|
||||
|
||||
LdapMessage msg = new LdapMessage();
|
||||
MLdapUser ldapUser = new MLdapUser();
|
||||
LdapResult result = new LdapResult();
|
||||
boolean activeSession = true;
|
||||
while (activeSession)
|
||||
{
|
||||
InputStream in = m_socket.getInputStream();
|
||||
BufferedOutputStream out = new BufferedOutputStream(m_socket.getOutputStream());
|
||||
// Read
|
||||
byte[] buffer = new byte[512];
|
||||
int length = in.read(buffer, 0, 512);
|
||||
|
||||
boolean activeSession = true;
|
||||
while (activeSession)
|
||||
{
|
||||
InputStream in = m_socket.getInputStream();
|
||||
BufferedOutputStream out = new BufferedOutputStream(m_socket.getOutputStream());
|
||||
// Read
|
||||
byte[] buffer = new byte[512];
|
||||
int length = in.read(buffer, 0, 512);
|
||||
|
||||
// Decode the input message buffer
|
||||
result.reset(msg, ldapUser);
|
||||
msg.reset(result);
|
||||
|
@ -136,34 +136,34 @@ public class LdapConnectionHandler extends Thread
|
|||
break;
|
||||
}
|
||||
} // while(activeSession)
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_socket.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.WARNING, "Socket", e);
|
||||
}
|
||||
m_socket = null;
|
||||
} // run
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("LdapConnectionHandler[");
|
||||
sb.append (hashCode()).append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_socket.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.WARNING, "Socket", e);
|
||||
}
|
||||
m_socket = null;
|
||||
} // run
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return info
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ("LdapConnectionHandler[");
|
||||
sb.append (hashCode()).append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Test using the java client.
|
||||
* Ldap v3 won't need to do any bind, search, bind anymore.
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
/******************************************************************************
|
||||
* 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.ldap;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
import com.sun.jndi.ldap.BerDecoder;
|
||||
|
||||
/**
|
||||
* Ldap Message
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: LdapMessage.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
||||
*/
|
||||
public class LdapMessage
|
||||
{
|
||||
/******************************************************************************
|
||||
* 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.ldap;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
import com.sun.jndi.ldap.BerDecoder;
|
||||
|
||||
/**
|
||||
* Ldap Message
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: LdapMessage.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
||||
*/
|
||||
public class LdapMessage
|
||||
{
|
||||
static public final int BIND_REQUEST = 96;
|
||||
static public final int BIND_RESPONSE = 97;
|
||||
static public final int UNBIND_REQUEST = 98;
|
||||
|
@ -124,12 +124,12 @@ public class LdapMessage
|
|||
|
||||
//
|
||||
// Payload
|
||||
if (m_protocolOp == BIND_REQUEST) {
|
||||
if (m_protocolOp == BIND_REQUEST) {
|
||||
handleBind();
|
||||
} else if (m_protocolOp == UNBIND_REQUEST) {
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": unbind");
|
||||
} else if (m_protocolOp == SEARCH_REQUEST) {
|
||||
handleSearch();
|
||||
} else if (m_protocolOp == UNBIND_REQUEST) {
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": unbind");
|
||||
} else if (m_protocolOp == SEARCH_REQUEST) {
|
||||
handleSearch();
|
||||
} else { // Only supoort BIND, UNBIND and SEARCH
|
||||
result.setErrorNo(LdapResult.LDAP_PROTOCOL_ERROR);
|
||||
result.setErrorString(": Unsupported Request");
|
||||
|
@ -202,7 +202,7 @@ public class LdapMessage
|
|||
{
|
||||
result.setErrorNo(LdapResult.LDAP_PROTOCOL_ERROR);
|
||||
result.setErrorString("Unsupported LDAP version");
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": unsupported LDAP version - " + version);
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": unsupported LDAP version - " + version);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class LdapMessage
|
|||
if (auth != SIMPLE_AUTHENTICATION) // 0x80 - simple authentication
|
||||
{
|
||||
result.setErrorNo(LdapResult.LDAP_AUTH_METHOD_NOT_SUPPORTED);
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": unsupported authentication method - " + auth);
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": unsupported authentication method - " + auth);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -227,13 +227,13 @@ public class LdapMessage
|
|||
{
|
||||
result.setErrorNo(LdapResult.LDAP_NO_SUCH_OBJECT);
|
||||
result.setErrorString(": \"cn\" not defined");
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": \"cn\" not defined");
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": \"cn\" not defined");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Log the information
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": bind - version=" + version + ", userId=" + userId);
|
||||
if (log.isLoggable(Level.INFO)) log.info("#" + msgId + ": bind - version=" + version + ", userId=" + userId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -257,16 +257,16 @@ public class LdapMessage
|
|||
orgUnit = dnArray[i].split("=")[1];
|
||||
}
|
||||
} // parseDN()
|
||||
|
||||
/**
|
||||
* Get Operation Code
|
||||
* @return protocolOp
|
||||
*/
|
||||
public int getOperation()
|
||||
{
|
||||
return m_protocolOp;
|
||||
} // getOperation
|
||||
|
||||
|
||||
/**
|
||||
* Get Operation Code
|
||||
* @return protocolOp
|
||||
*/
|
||||
public int getOperation()
|
||||
{
|
||||
return m_protocolOp;
|
||||
} // getOperation
|
||||
|
||||
/**
|
||||
* Get message id
|
||||
* @return msgId
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
/******************************************************************************
|
||||
* 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.ldap;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MLdapProcessor;
|
||||
import org.compiere.model.MLdapUser;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
import com.sun.jndi.ldap.BerEncoder;
|
||||
|
||||
/**
|
||||
* Ldap Wire Response
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: LdapResult.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
||||
*/
|
||||
public class LdapResult
|
||||
{
|
||||
/******************************************************************************
|
||||
* 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.ldap;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MLdapProcessor;
|
||||
import org.compiere.model.MLdapUser;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
import com.sun.jndi.ldap.BerEncoder;
|
||||
|
||||
/**
|
||||
* Ldap Wire Response
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: LdapResult.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
||||
*/
|
||||
public class LdapResult
|
||||
{
|
||||
/** LdapMesssage */
|
||||
private LdapMessage ldapMsg = null;
|
||||
/** Encoder */
|
||||
|
@ -132,7 +132,7 @@ public class LdapResult
|
|||
generateResult("", LdapMessage.BIND_RESPONSE,
|
||||
LDAP_INAPPROPRIATE_AUTHENTICATION,
|
||||
ldapErrorMessage[LDAP_INAPPROPRIATE_AUTHENTICATION]);
|
||||
if (log.isLoggable(Level.INFO)) log.info("Failed : " + ldapErrorMessage[LDAP_INAPPROPRIATE_AUTHENTICATION]);
|
||||
if (log.isLoggable(Level.INFO)) log.info("Failed : " + ldapErrorMessage[LDAP_INAPPROPRIATE_AUTHENTICATION]);
|
||||
}
|
||||
}
|
||||
else if (ldapMsg.getOperation() == LdapMessage.SEARCH_REQUEST)
|
||||
|
|
|
@ -1,151 +1,151 @@
|
|||
/* Adempiere Root (c) Jorg Janke */
|
||||
/* $Id: standard.css,v 1.1 2006/04/21 18:04:14 jjanke Exp $ */
|
||||
body{
|
||||
background-color: #FFFFFF;
|
||||
/* Adempiere Root (c) Jorg Janke */
|
||||
/* $Id: standard.css,v 1.1 2006/04/21 18:04:14 jjanke Exp $ */
|
||||
body{
|
||||
background-color: #FFFFFF;
|
||||
color: #000000;
|
||||
font-size: 76%;
|
||||
font-family: Verdana, Arial, sans-serif;
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
a{
|
||||
color: #3465a4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1{
|
||||
color: #FF0000;
|
||||
font-size: x-large;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h2{
|
||||
color: #000066;
|
||||
font-size: large;
|
||||
}
|
||||
|
||||
h3{
|
||||
color: #0000CC;
|
||||
font-size: medium;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h4{
|
||||
color: #6600CC;
|
||||
font-size: medium;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
h5{
|
||||
color: #660099;
|
||||
font-size: medium;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h6{
|
||||
font-size: larger;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
hr{
|
||||
color: #000099;
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
p{
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
th{
|
||||
background-color: #E6E6FA;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
caption{
|
||||
color: #660099;
|
||||
text-align: left;
|
||||
font-style: italic;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
|
||||
.menuDetail{
|
||||
color: #660099;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 12px;
|
||||
padding-bottom: 0;
|
||||
padding-left: 20px;
|
||||
padding-top: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.menuDetail:hover{
|
||||
color: #660099;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 12px;
|
||||
padding-bottom: 0;
|
||||
padding-left: 20px;
|
||||
padding-top: 0;
|
||||
text-decoration: none;
|
||||
background-color: #99FFFF;
|
||||
}
|
||||
|
||||
.menuMain{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 16px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.menuMain:hover{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 16px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
background-color: #99FFFF;
|
||||
}
|
||||
|
||||
.menuSub{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 14px;
|
||||
padding-left: 10px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.menuSub:hover{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 14px;
|
||||
padding-left: 10px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
background-color: #99FFFF;
|
||||
}
|
||||
|
||||
.Cerror{
|
||||
background:#FF4A4A;
|
||||
}
|
||||
.Cmandatory{
|
||||
background:#9DFFFF;
|
||||
}
|
||||
.Cbasket{
|
||||
font-size: 9px;
|
||||
display: inline;
|
||||
}
|
||||
#imgButton{
|
||||
border-style:outset;
|
||||
}
|
||||
#imgButtonPressed{
|
||||
border-style:inset;
|
||||
}
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
a{
|
||||
color: #3465a4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1{
|
||||
color: #FF0000;
|
||||
font-size: x-large;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h2{
|
||||
color: #000066;
|
||||
font-size: large;
|
||||
}
|
||||
|
||||
h3{
|
||||
color: #0000CC;
|
||||
font-size: medium;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h4{
|
||||
color: #6600CC;
|
||||
font-size: medium;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
h5{
|
||||
color: #660099;
|
||||
font-size: medium;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h6{
|
||||
font-size: larger;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
hr{
|
||||
color: #000099;
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
p{
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
th{
|
||||
background-color: #E6E6FA;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
caption{
|
||||
color: #660099;
|
||||
text-align: left;
|
||||
font-style: italic;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
|
||||
.menuDetail{
|
||||
color: #660099;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 12px;
|
||||
padding-bottom: 0;
|
||||
padding-left: 20px;
|
||||
padding-top: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.menuDetail:hover{
|
||||
color: #660099;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 12px;
|
||||
padding-bottom: 0;
|
||||
padding-left: 20px;
|
||||
padding-top: 0;
|
||||
text-decoration: none;
|
||||
background-color: #99FFFF;
|
||||
}
|
||||
|
||||
.menuMain{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 16px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.menuMain:hover{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 16px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
background-color: #99FFFF;
|
||||
}
|
||||
|
||||
.menuSub{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 14px;
|
||||
padding-left: 10px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.menuSub:hover{
|
||||
color: #000066;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 14px;
|
||||
padding-left: 10px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
background-color: #99FFFF;
|
||||
}
|
||||
|
||||
.Cerror{
|
||||
background:#FF4A4A;
|
||||
}
|
||||
.Cmandatory{
|
||||
background:#9DFFFF;
|
||||
}
|
||||
.Cbasket{
|
||||
font-size: 9px;
|
||||
display: inline;
|
||||
}
|
||||
#imgButton{
|
||||
border-style:outset;
|
||||
}
|
||||
#imgButtonPressed{
|
||||
border-style:inset;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,26 +16,26 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.compiere.swing.CButton;
|
||||
import org.compiere.swing.CCheckBoxMenuItem;
|
||||
import org.compiere.swing.CMenuItem;
|
||||
import org.compiere.swing.CToggleButton;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.compiere.swing.CButton;
|
||||
import org.compiere.swing.CCheckBoxMenuItem;
|
||||
import org.compiere.swing.CMenuItem;
|
||||
import org.compiere.swing.CToggleButton;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
* Application Action.
|
||||
|
@ -48,11 +48,11 @@ import org.compiere.util.Msg;
|
|||
*/
|
||||
public final class AppsAction extends AbstractAction
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8522301377339185496L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8522301377339185496L;
|
||||
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
|
@ -147,13 +147,13 @@ public final class AppsAction extends AbstractAction
|
|||
m_button.setActionCommand(m_action);
|
||||
m_button.setMargin(BUTTON_INSETS);
|
||||
m_button.setSize(BUTTON_SIZE);
|
||||
//
|
||||
if (accelerator != null)
|
||||
{
|
||||
m_button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(accelerator, action);
|
||||
m_button.getActionMap().put(action, this);
|
||||
}
|
||||
} // Action
|
||||
//
|
||||
if (accelerator != null)
|
||||
{
|
||||
m_button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(accelerator, action);
|
||||
m_button.getActionMap().put(action, this);
|
||||
}
|
||||
} // Action
|
||||
|
||||
/** Button Size */
|
||||
public static final Dimension BUTTON_SIZE = new Dimension(28,28);
|
||||
|
@ -176,14 +176,14 @@ public final class AppsAction extends AbstractAction
|
|||
* @param name name
|
||||
* @param small small
|
||||
* @return Icon
|
||||
*/
|
||||
private ImageIcon getIcon(String name, boolean small)
|
||||
{
|
||||
String fullName = name + (small ? "16" : "24");
|
||||
return Env.getImageIcon2(fullName);
|
||||
} // getIcon
|
||||
|
||||
/**
|
||||
*/
|
||||
private ImageIcon getIcon(String name, boolean small)
|
||||
{
|
||||
String fullName = name + (small ? "16" : "24");
|
||||
return Env.getImageIcon2(fullName);
|
||||
} // getIcon
|
||||
|
||||
/**
|
||||
* Get Name/ActionCommand
|
||||
* @return ActionName
|
||||
*/
|
||||
|
@ -242,11 +242,11 @@ public final class AppsAction extends AbstractAction
|
|||
m_pressed = pressed;
|
||||
|
||||
// Set Button
|
||||
if (m_button != null)
|
||||
if (m_button != null)
|
||||
m_button.setSelected(pressed);
|
||||
|
||||
|
||||
// Set Menu
|
||||
if (m_menu != null)
|
||||
if (m_menu != null)
|
||||
m_menu.setSelected(pressed);
|
||||
} // setPressed
|
||||
|
||||
|
@ -301,7 +301,7 @@ public final class AppsAction extends AbstractAction
|
|||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("AppsAction[");
|
||||
StringBuilder sb = new StringBuilder("AppsAction[");
|
||||
sb.append(m_action);
|
||||
Object oo = getValue(Action.ACCELERATOR_KEY);
|
||||
if (oo != null)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,446 +1,446 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.adempiere.client.Client;
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.AGlassPane;
|
||||
import org.compiere.apps.AMenu;
|
||||
import org.compiere.apps.Help;
|
||||
import org.compiere.apps.WindowMenu;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.swing.CFrame;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Trace;
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.adempiere.client.Client;
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.AGlassPane;
|
||||
import org.compiere.apps.AMenu;
|
||||
import org.compiere.apps.Help;
|
||||
import org.compiere.apps.WindowMenu;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.swing.CFrame;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Trace;
|
||||
|
||||
|
||||
/**
|
||||
* Form Framework
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: FormFrame.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*
|
||||
* Colin Rooney 2007/03/20 RFE#1670185 & BUG#1684142
|
||||
* Extend security to Info Queries
|
||||
*/
|
||||
public class FormFrame extends CFrame
|
||||
implements ActionListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2559005548469735515L;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Create Form.
|
||||
* Need to call openForm
|
||||
*/
|
||||
public FormFrame ()
|
||||
{
|
||||
this(null);
|
||||
} // FormFrame
|
||||
|
||||
/**
|
||||
* Create Form.
|
||||
* Need to call openForm
|
||||
* @param gc
|
||||
*/
|
||||
public FormFrame (GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
addWindowListener(new java.awt.event.WindowAdapter()
|
||||
{
|
||||
public void windowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
formWindowOpened(evt);
|
||||
}
|
||||
});
|
||||
|
||||
m_WindowNo = AEnv.createWindowNo (this);
|
||||
setGlassPane(m_glassPane);
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
createMenu();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // FormFrame
|
||||
|
||||
/**
|
||||
* Form Framework
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: FormFrame.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*
|
||||
* Colin Rooney 2007/03/20 RFE#1670185 & BUG#1684142
|
||||
* Extend security to Info Queries
|
||||
*/
|
||||
public class FormFrame extends CFrame
|
||||
implements ActionListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2559005548469735515L;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Create Form.
|
||||
* Need to call openForm
|
||||
*/
|
||||
public FormFrame ()
|
||||
{
|
||||
this(null);
|
||||
} // FormFrame
|
||||
|
||||
/**
|
||||
* Create Form.
|
||||
* Need to call openForm
|
||||
* @param gc
|
||||
*/
|
||||
public FormFrame (GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
addWindowListener(new java.awt.event.WindowAdapter()
|
||||
{
|
||||
public void windowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
formWindowOpened(evt);
|
||||
}
|
||||
});
|
||||
|
||||
m_WindowNo = AEnv.createWindowNo (this);
|
||||
setGlassPane(m_glassPane);
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
createMenu();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // FormFrame
|
||||
|
||||
private ProcessInfo m_pi;
|
||||
|
||||
/** WindowNo */
|
||||
private int m_WindowNo;
|
||||
/** The GlassPane */
|
||||
private AGlassPane m_glassPane = new AGlassPane();
|
||||
/** Description */
|
||||
private String m_Description = null;
|
||||
/** Help */
|
||||
private String m_Help = null;
|
||||
/** Menu Bar */
|
||||
private JMenuBar menuBar = new JMenuBar();
|
||||
/** The Panel to be displayed */
|
||||
private FormPanel m_panel = null;
|
||||
/** Maximize Window */
|
||||
public boolean m_maximize = false;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(FormFrame.class);
|
||||
|
||||
/** Form ID */
|
||||
private int p_AD_Form_ID = 0;
|
||||
|
||||
/**
|
||||
* Static Init
|
||||
* @throws Exception
|
||||
*/
|
||||
private void jbInit() throws Exception
|
||||
{
|
||||
this.setIconImage(org.compiere.Adempiere.getImage16());
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.setJMenuBar(menuBar);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Create Menu
|
||||
*/
|
||||
private void createMenu()
|
||||
{
|
||||
// File
|
||||
JMenu mFile = AEnv.getMenu("File");
|
||||
menuBar.add(mFile);
|
||||
AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this);
|
||||
AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, ActionEvent.SHIFT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Report", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK), mFile, this);
|
||||
mFile.addSeparator();
|
||||
AEnv.addMenuItem("End", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), mFile, this);
|
||||
|
||||
// View
|
||||
JMenu mView = AEnv.getMenu("View");
|
||||
menuBar.add(mView);
|
||||
|
||||
if (MRole.getDefault().isAllow_Info_Product())
|
||||
{
|
||||
AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK), mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_BPartner())
|
||||
{
|
||||
AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account())
|
||||
{
|
||||
AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Schedule())
|
||||
{
|
||||
AEnv.addMenuItem("InfoSchedule", null, null, mView, this);
|
||||
}
|
||||
mView.addSeparator();
|
||||
if (MRole.getDefault().isAllow_Info_Order())
|
||||
{
|
||||
AEnv.addMenuItem("InfoOrder", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Invoice())
|
||||
{
|
||||
AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_InOut())
|
||||
{
|
||||
AEnv.addMenuItem("InfoInOut", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Payment())
|
||||
{
|
||||
AEnv.addMenuItem("InfoPayment", "Info", null, mView, this);
|
||||
}
|
||||
// if (MRole.getDefault().isAllow_Info_CashJournal())
|
||||
// {
|
||||
// AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this);
|
||||
// }
|
||||
if (MRole.getDefault().isAllow_Info_Resource())
|
||||
{
|
||||
AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Asset())
|
||||
{
|
||||
AEnv.addMenuItem("InfoAsset", "Info", null, mView, this);
|
||||
}
|
||||
// Tools
|
||||
JMenu mTools = AEnv.getMenu("Tools");
|
||||
menuBar.add(mTools);
|
||||
AEnv.addMenuItem("Calculator", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Calendar", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Editor", null, null, mTools, this);
|
||||
MUser user = MUser.get(Env.getCtx());
|
||||
if (user.isAdministrator())
|
||||
AEnv.addMenuItem("Script", null, null, mTools, this);
|
||||
if (MRole.getDefault().isShowPreference())
|
||||
{
|
||||
mTools.addSeparator();
|
||||
AEnv.addMenuItem("Preference", null, null, mTools, this);
|
||||
}
|
||||
|
||||
// Window
|
||||
AMenu aMenu = (AMenu)AEnv.getWindow(0);
|
||||
JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), this);
|
||||
menuBar.add(mWindow);
|
||||
|
||||
// Help
|
||||
JMenu mHelp = AEnv.getMenu("Help");
|
||||
menuBar.add(mHelp);
|
||||
AEnv.addMenuItem("Help", "Help", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), mHelp, this);
|
||||
AEnv.addMenuItem("Online", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("EMailSupport", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("About", null, null, mHelp, this);
|
||||
} // createMenu
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
log.config("");
|
||||
// recursive calls
|
||||
if (Trace.isCalledFrom("JFrame") && m_panel != null) // [x] close window pressed
|
||||
m_panel.dispose();
|
||||
m_panel = null;
|
||||
Env.clearWinContext(m_WindowNo);
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID form
|
||||
* @return true if form opened
|
||||
*/
|
||||
public boolean openForm (int AD_Form_ID)
|
||||
{
|
||||
return openForm(AD_Form_ID, null);
|
||||
}
|
||||
|
||||
public boolean openForm (int AD_Form_ID, GridTab gridTab)
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
//
|
||||
String name = null;
|
||||
String className = null;
|
||||
String sql = "SELECT Name, Description, ClassName, Help FROM AD_Form WHERE AD_Form_ID=?";
|
||||
boolean trl = !Env.isBaseLanguage(ctx, "AD_Form");
|
||||
if (trl)
|
||||
sql = "SELECT t.Name, t.Description, f.ClassName, t.Help "
|
||||
+ "FROM AD_Form f INNER JOIN AD_Form_Trl t"
|
||||
+ " ON (f.AD_Form_ID=t.AD_Form_ID AND AD_Language=?)"
|
||||
+ "WHERE f.AD_Form_ID=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
if (trl)
|
||||
{
|
||||
pstmt.setString(1, Env.getAD_Language(ctx));
|
||||
pstmt.setInt(2, AD_Form_ID);
|
||||
}
|
||||
else
|
||||
pstmt.setInt(1, AD_Form_ID);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
name = rs.getString(1);
|
||||
m_Description = rs.getString(2);
|
||||
className = rs.getString(3);
|
||||
m_Help = rs.getString(4);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
if (className == null)
|
||||
return false;
|
||||
//
|
||||
return openForm(AD_Form_ID, className, name, gridTab);
|
||||
} // openForm
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID Form
|
||||
* @param className class name
|
||||
* @param name title
|
||||
* @return true if started
|
||||
*/
|
||||
protected boolean openForm (int AD_Form_ID, String className, String name)
|
||||
{
|
||||
return openForm(AD_Form_ID, className, name, null);
|
||||
}
|
||||
|
||||
protected boolean openForm (int AD_Form_ID, String className, String name, GridTab gridTab)
|
||||
{
|
||||
if (log.isLoggable(Level.INFO)) log.info("AD_Form_ID=" + AD_Form_ID + " - Class=" + className);
|
||||
Properties ctx = Env.getCtx();
|
||||
Env.setContext(ctx, m_WindowNo, "_WinInfo_WindowName", name);
|
||||
setTitle(Env.getHeader(ctx, m_WindowNo));
|
||||
this.gridTab = gridTab;
|
||||
|
||||
try
|
||||
{
|
||||
// Create instance w/o parameters
|
||||
// Try equinox extension then java classpath
|
||||
m_panel = Client.getFormPanel(className);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "Class=" + className + ", AD_Form_ID=" + AD_Form_ID, e);
|
||||
return false;
|
||||
}
|
||||
//
|
||||
m_panel.init(m_WindowNo, this);
|
||||
p_AD_Form_ID = AD_Form_ID;
|
||||
return true;
|
||||
} // openForm
|
||||
|
||||
/**
|
||||
* Get Form Panel
|
||||
* @return form panel
|
||||
*/
|
||||
public FormPanel getFormPanel()
|
||||
{
|
||||
return m_panel;
|
||||
} // getFormPanel
|
||||
|
||||
/**
|
||||
* Action Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
String cmd = e.getActionCommand();
|
||||
if (cmd.equals("End"))
|
||||
dispose();
|
||||
else if (cmd.equals("Help"))
|
||||
actionHelp();
|
||||
else if (!AEnv.actionPerformed(cmd, m_WindowNo, this))
|
||||
log.log(Level.SEVERE, "Not handeled=" + cmd);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Show Help
|
||||
*/
|
||||
private void actionHelp()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (m_Description != null && m_Description.length() > 0)
|
||||
sb.append("<h2>").append(m_Description).append("</h2>");
|
||||
if (m_Help != null && m_Help.length() > 0)
|
||||
sb.append("<p>").append(m_Help);
|
||||
Help hlp = new Help (AEnv.getFrame(this), this.getTitle(), sb.toString());
|
||||
hlp.setVisible(true);
|
||||
} // actionHelp
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Set Window Busy
|
||||
* @param busy busy
|
||||
*/
|
||||
public void setBusy (boolean busy)
|
||||
{
|
||||
if (busy == m_glassPane.isVisible())
|
||||
return;
|
||||
if (log.isLoggable(Level.INFO)) log.info("Busy=" + busy);
|
||||
if (busy)
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
else
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
m_glassPane.setMessage(null);
|
||||
m_glassPane.setVisible(busy);
|
||||
m_glassPane.requestFocus();
|
||||
} // setBusy
|
||||
|
||||
/**
|
||||
* Set Busy Message
|
||||
* @param AD_Message message
|
||||
*/
|
||||
public void setBusyMessage (String AD_Message)
|
||||
{
|
||||
m_glassPane.setMessage(AD_Message);
|
||||
} // setBusyMessage
|
||||
|
||||
/**
|
||||
* Set and start Busy Counter
|
||||
* @param time in seconds
|
||||
*/
|
||||
public void setBusyTimer (int time)
|
||||
{
|
||||
m_glassPane.setBusyTimer (time);
|
||||
} // setBusyTimer
|
||||
|
||||
|
||||
/**
|
||||
* Set Maximize Window
|
||||
* @param max maximize
|
||||
*/
|
||||
public void setMaximize (boolean max)
|
||||
{
|
||||
m_maximize = max;
|
||||
} // setMaximize
|
||||
|
||||
|
||||
/**
|
||||
* Form Window Opened.
|
||||
* Maximize window if required
|
||||
* @param evt event
|
||||
*/
|
||||
private void formWindowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
if (m_maximize == true)
|
||||
{
|
||||
super.setVisible(true);
|
||||
super.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
}
|
||||
} // formWindowOpened
|
||||
|
||||
/** WindowNo */
|
||||
private int m_WindowNo;
|
||||
/** The GlassPane */
|
||||
private AGlassPane m_glassPane = new AGlassPane();
|
||||
/** Description */
|
||||
private String m_Description = null;
|
||||
/** Help */
|
||||
private String m_Help = null;
|
||||
/** Menu Bar */
|
||||
private JMenuBar menuBar = new JMenuBar();
|
||||
/** The Panel to be displayed */
|
||||
private FormPanel m_panel = null;
|
||||
/** Maximize Window */
|
||||
public boolean m_maximize = false;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(FormFrame.class);
|
||||
|
||||
/** Form ID */
|
||||
private int p_AD_Form_ID = 0;
|
||||
|
||||
/**
|
||||
* Static Init
|
||||
* @throws Exception
|
||||
*/
|
||||
private void jbInit() throws Exception
|
||||
{
|
||||
this.setIconImage(org.compiere.Adempiere.getImage16());
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.setJMenuBar(menuBar);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Create Menu
|
||||
*/
|
||||
private void createMenu()
|
||||
{
|
||||
// File
|
||||
JMenu mFile = AEnv.getMenu("File");
|
||||
menuBar.add(mFile);
|
||||
AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this);
|
||||
AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, ActionEvent.SHIFT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Report", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK), mFile, this);
|
||||
mFile.addSeparator();
|
||||
AEnv.addMenuItem("End", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), mFile, this);
|
||||
|
||||
// View
|
||||
JMenu mView = AEnv.getMenu("View");
|
||||
menuBar.add(mView);
|
||||
|
||||
if (MRole.getDefault().isAllow_Info_Product())
|
||||
{
|
||||
AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK), mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_BPartner())
|
||||
{
|
||||
AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account())
|
||||
{
|
||||
AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Schedule())
|
||||
{
|
||||
AEnv.addMenuItem("InfoSchedule", null, null, mView, this);
|
||||
}
|
||||
mView.addSeparator();
|
||||
if (MRole.getDefault().isAllow_Info_Order())
|
||||
{
|
||||
AEnv.addMenuItem("InfoOrder", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Invoice())
|
||||
{
|
||||
AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_InOut())
|
||||
{
|
||||
AEnv.addMenuItem("InfoInOut", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Payment())
|
||||
{
|
||||
AEnv.addMenuItem("InfoPayment", "Info", null, mView, this);
|
||||
}
|
||||
// if (MRole.getDefault().isAllow_Info_CashJournal())
|
||||
// {
|
||||
// AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this);
|
||||
// }
|
||||
if (MRole.getDefault().isAllow_Info_Resource())
|
||||
{
|
||||
AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this);
|
||||
}
|
||||
if (MRole.getDefault().isAllow_Info_Asset())
|
||||
{
|
||||
AEnv.addMenuItem("InfoAsset", "Info", null, mView, this);
|
||||
}
|
||||
// Tools
|
||||
JMenu mTools = AEnv.getMenu("Tools");
|
||||
menuBar.add(mTools);
|
||||
AEnv.addMenuItem("Calculator", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Calendar", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Editor", null, null, mTools, this);
|
||||
MUser user = MUser.get(Env.getCtx());
|
||||
if (user.isAdministrator())
|
||||
AEnv.addMenuItem("Script", null, null, mTools, this);
|
||||
if (MRole.getDefault().isShowPreference())
|
||||
{
|
||||
mTools.addSeparator();
|
||||
AEnv.addMenuItem("Preference", null, null, mTools, this);
|
||||
}
|
||||
|
||||
// Window
|
||||
AMenu aMenu = (AMenu)AEnv.getWindow(0);
|
||||
JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), this);
|
||||
menuBar.add(mWindow);
|
||||
|
||||
// Help
|
||||
JMenu mHelp = AEnv.getMenu("Help");
|
||||
menuBar.add(mHelp);
|
||||
AEnv.addMenuItem("Help", "Help", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), mHelp, this);
|
||||
AEnv.addMenuItem("Online", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("EMailSupport", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("About", null, null, mHelp, this);
|
||||
} // createMenu
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
log.config("");
|
||||
// recursive calls
|
||||
if (Trace.isCalledFrom("JFrame") && m_panel != null) // [x] close window pressed
|
||||
m_panel.dispose();
|
||||
m_panel = null;
|
||||
Env.clearWinContext(m_WindowNo);
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID form
|
||||
* @return true if form opened
|
||||
*/
|
||||
public boolean openForm (int AD_Form_ID)
|
||||
{
|
||||
return openForm(AD_Form_ID, null);
|
||||
}
|
||||
|
||||
public boolean openForm (int AD_Form_ID, GridTab gridTab)
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
//
|
||||
String name = null;
|
||||
String className = null;
|
||||
String sql = "SELECT Name, Description, ClassName, Help FROM AD_Form WHERE AD_Form_ID=?";
|
||||
boolean trl = !Env.isBaseLanguage(ctx, "AD_Form");
|
||||
if (trl)
|
||||
sql = "SELECT t.Name, t.Description, f.ClassName, t.Help "
|
||||
+ "FROM AD_Form f INNER JOIN AD_Form_Trl t"
|
||||
+ " ON (f.AD_Form_ID=t.AD_Form_ID AND AD_Language=?)"
|
||||
+ "WHERE f.AD_Form_ID=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
if (trl)
|
||||
{
|
||||
pstmt.setString(1, Env.getAD_Language(ctx));
|
||||
pstmt.setInt(2, AD_Form_ID);
|
||||
}
|
||||
else
|
||||
pstmt.setInt(1, AD_Form_ID);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
name = rs.getString(1);
|
||||
m_Description = rs.getString(2);
|
||||
className = rs.getString(3);
|
||||
m_Help = rs.getString(4);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
if (className == null)
|
||||
return false;
|
||||
//
|
||||
return openForm(AD_Form_ID, className, name, gridTab);
|
||||
} // openForm
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID Form
|
||||
* @param className class name
|
||||
* @param name title
|
||||
* @return true if started
|
||||
*/
|
||||
protected boolean openForm (int AD_Form_ID, String className, String name)
|
||||
{
|
||||
return openForm(AD_Form_ID, className, name, null);
|
||||
}
|
||||
|
||||
protected boolean openForm (int AD_Form_ID, String className, String name, GridTab gridTab)
|
||||
{
|
||||
if (log.isLoggable(Level.INFO)) log.info("AD_Form_ID=" + AD_Form_ID + " - Class=" + className);
|
||||
Properties ctx = Env.getCtx();
|
||||
Env.setContext(ctx, m_WindowNo, "_WinInfo_WindowName", name);
|
||||
setTitle(Env.getHeader(ctx, m_WindowNo));
|
||||
this.gridTab = gridTab;
|
||||
|
||||
try
|
||||
{
|
||||
// Create instance w/o parameters
|
||||
// Try equinox extension then java classpath
|
||||
m_panel = Client.getFormPanel(className);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "Class=" + className + ", AD_Form_ID=" + AD_Form_ID, e);
|
||||
return false;
|
||||
}
|
||||
//
|
||||
m_panel.init(m_WindowNo, this);
|
||||
p_AD_Form_ID = AD_Form_ID;
|
||||
return true;
|
||||
} // openForm
|
||||
|
||||
/**
|
||||
* Get Form Panel
|
||||
* @return form panel
|
||||
*/
|
||||
public FormPanel getFormPanel()
|
||||
{
|
||||
return m_panel;
|
||||
} // getFormPanel
|
||||
|
||||
/**
|
||||
* Action Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
String cmd = e.getActionCommand();
|
||||
if (cmd.equals("End"))
|
||||
dispose();
|
||||
else if (cmd.equals("Help"))
|
||||
actionHelp();
|
||||
else if (!AEnv.actionPerformed(cmd, m_WindowNo, this))
|
||||
log.log(Level.SEVERE, "Not handeled=" + cmd);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Show Help
|
||||
*/
|
||||
private void actionHelp()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (m_Description != null && m_Description.length() > 0)
|
||||
sb.append("<h2>").append(m_Description).append("</h2>");
|
||||
if (m_Help != null && m_Help.length() > 0)
|
||||
sb.append("<p>").append(m_Help);
|
||||
Help hlp = new Help (AEnv.getFrame(this), this.getTitle(), sb.toString());
|
||||
hlp.setVisible(true);
|
||||
} // actionHelp
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Set Window Busy
|
||||
* @param busy busy
|
||||
*/
|
||||
public void setBusy (boolean busy)
|
||||
{
|
||||
if (busy == m_glassPane.isVisible())
|
||||
return;
|
||||
if (log.isLoggable(Level.INFO)) log.info("Busy=" + busy);
|
||||
if (busy)
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
else
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
m_glassPane.setMessage(null);
|
||||
m_glassPane.setVisible(busy);
|
||||
m_glassPane.requestFocus();
|
||||
} // setBusy
|
||||
|
||||
/**
|
||||
* Set Busy Message
|
||||
* @param AD_Message message
|
||||
*/
|
||||
public void setBusyMessage (String AD_Message)
|
||||
{
|
||||
m_glassPane.setMessage(AD_Message);
|
||||
} // setBusyMessage
|
||||
|
||||
/**
|
||||
* Set and start Busy Counter
|
||||
* @param time in seconds
|
||||
*/
|
||||
public void setBusyTimer (int time)
|
||||
{
|
||||
m_glassPane.setBusyTimer (time);
|
||||
} // setBusyTimer
|
||||
|
||||
|
||||
/**
|
||||
* Set Maximize Window
|
||||
* @param max maximize
|
||||
*/
|
||||
public void setMaximize (boolean max)
|
||||
{
|
||||
m_maximize = max;
|
||||
} // setMaximize
|
||||
|
||||
|
||||
/**
|
||||
* Form Window Opened.
|
||||
* Maximize window if required
|
||||
* @param evt event
|
||||
*/
|
||||
private void formWindowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
if (m_maximize == true)
|
||||
{
|
||||
super.setVisible(true);
|
||||
super.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
}
|
||||
} // formWindowOpened
|
||||
|
||||
// Add window and tab no called from
|
||||
|
||||
public void setProcessInfo(ProcessInfo pi)
|
||||
|
@ -456,45 +456,45 @@ public class FormFrame extends CFrame
|
|||
|
||||
// End
|
||||
|
||||
/**
|
||||
* Start Batch
|
||||
* @param process
|
||||
* @return running thread
|
||||
*/
|
||||
public Thread startBatch (final Runnable process)
|
||||
{
|
||||
Thread worker = new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
setBusy(true);
|
||||
process.run();
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
return worker;
|
||||
} // startBatch
|
||||
|
||||
/**
|
||||
* @return Returns the AD_Form_ID.
|
||||
*/
|
||||
public int getAD_Form_ID ()
|
||||
{
|
||||
return p_AD_Form_ID;
|
||||
} // getAD_Window_ID
|
||||
/**
|
||||
* @return Returns the manuBar
|
||||
*/
|
||||
public JMenuBar getMenu()
|
||||
{
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
private GridTab gridTab;
|
||||
|
||||
public GridTab getGridTab()
|
||||
{
|
||||
return gridTab;
|
||||
}
|
||||
} // FormFrame
|
||||
/**
|
||||
* Start Batch
|
||||
* @param process
|
||||
* @return running thread
|
||||
*/
|
||||
public Thread startBatch (final Runnable process)
|
||||
{
|
||||
Thread worker = new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
setBusy(true);
|
||||
process.run();
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
return worker;
|
||||
} // startBatch
|
||||
|
||||
/**
|
||||
* @return Returns the AD_Form_ID.
|
||||
*/
|
||||
public int getAD_Form_ID ()
|
||||
{
|
||||
return p_AD_Form_ID;
|
||||
} // getAD_Window_ID
|
||||
/**
|
||||
* @return Returns the manuBar
|
||||
*/
|
||||
public JMenuBar getMenu()
|
||||
{
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
private GridTab gridTab;
|
||||
|
||||
public GridTab getGridTab()
|
||||
{
|
||||
return gridTab;
|
||||
}
|
||||
} // FormFrame
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/******************************************************************************
|
||||
* 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 *
|
||||
/******************************************************************************
|
||||
* 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. *
|
||||
|
@ -16,36 +16,36 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.minigrid;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import org.compiere.apps.search.Info_Column;
|
||||
import org.compiere.grid.ed.VCellRenderer;
|
||||
import org.compiere.grid.ed.VHeaderRenderer;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.swing.CCheckBox;
|
||||
import org.compiere.swing.CTable;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Util;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import org.compiere.apps.search.Info_Column;
|
||||
import org.compiere.grid.ed.VCellRenderer;
|
||||
import org.compiere.grid.ed.VHeaderRenderer;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.swing.CCheckBox;
|
||||
import org.compiere.swing.CTable;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* Mini Table.
|
||||
|
@ -63,23 +63,23 @@ import org.compiere.util.Util;
|
|||
* </code>
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MiniTable.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
|
||||
*
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>BF [ 1891082 ] NPE on MiniTable when you hide some columns
|
||||
* <li>FR [ 1974299 ] Add MiniTable.getSelectedKeys method
|
||||
* <li>FR [ 2847295 ] MiniTable multiselection checkboxes not working
|
||||
* https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2847295&group_id=176962
|
||||
* @author Teo Sarca, teo.sarca@gmail.com
|
||||
* <li>BF [ 2876895 ] MiniTable.loadTable: NPE if column is null
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=2876895&group_id=176962&atid=879332
|
||||
*
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>BF [ 1891082 ] NPE on MiniTable when you hide some columns
|
||||
* <li>FR [ 1974299 ] Add MiniTable.getSelectedKeys method
|
||||
* <li>FR [ 2847295 ] MiniTable multiselection checkboxes not working
|
||||
* https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2847295&group_id=176962
|
||||
* @author Teo Sarca, teo.sarca@gmail.com
|
||||
* <li>BF [ 2876895 ] MiniTable.loadTable: NPE if column is null
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=2876895&group_id=176962&atid=879332
|
||||
*/
|
||||
public class MiniTable extends CTable implements IMiniTable
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 281959800766140642L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 281959800766140642L;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
|
@ -109,46 +109,46 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
/** Lauout set in prepareTable and used in loadTable */
|
||||
private ColumnInfo[] m_layout = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(MiniTable.class);
|
||||
/** Is Total Show */
|
||||
private boolean showTotals = false;
|
||||
private boolean autoResize = true;
|
||||
|
||||
public boolean isAutoResize() {
|
||||
return autoResize;
|
||||
}
|
||||
|
||||
public void setAutoResize(boolean autoResize) {
|
||||
this.autoResize = autoResize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the swing column of given index. No index checking
|
||||
* is done.
|
||||
*
|
||||
* @param col
|
||||
* @return
|
||||
*/
|
||||
public TableColumn getColumn(int col) {
|
||||
return(getColumnModel().getColumn(col));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of columns in the mini table
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
return(getColumnModel().getColumnCount());
|
||||
}
|
||||
private static CLogger log = CLogger.getCLogger(MiniTable.class);
|
||||
/** Is Total Show */
|
||||
private boolean showTotals = false;
|
||||
private boolean autoResize = true;
|
||||
|
||||
public boolean isAutoResize() {
|
||||
return autoResize;
|
||||
}
|
||||
|
||||
public void setAutoResize(boolean autoResize) {
|
||||
this.autoResize = autoResize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the swing column of given index. No index checking
|
||||
* is done.
|
||||
*
|
||||
* @param col
|
||||
* @return
|
||||
*/
|
||||
public TableColumn getColumn(int col) {
|
||||
return(getColumnModel().getColumn(col));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of columns in the mini table
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
return(getColumnModel().getColumnCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Size Columns.
|
||||
* Uses Mimimum Column Size
|
||||
*/
|
||||
public void autoSize()
|
||||
{
|
||||
if ( !autoResize )
|
||||
return;
|
||||
|
||||
{
|
||||
if ( !autoResize )
|
||||
return;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
//
|
||||
final int SLACK = 8; // making sure it fits in a column
|
||||
|
@ -182,17 +182,17 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
renderer = getCellRenderer(row, col);
|
||||
comp = renderer.getTableCellRendererComponent
|
||||
(this, getValueAt(row, col), false, false, row, col);
|
||||
if (comp != null) {
|
||||
if (comp != null) {
|
||||
int rowWidth = comp.getPreferredSize().width + SLACK;
|
||||
width = Math.max(width, rowWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Width not greater ..
|
||||
width = Math.min(MAXSIZE, width);
|
||||
tc.setPreferredWidth(width);
|
||||
// log.fine( "width=" + width);
|
||||
} // for all columns
|
||||
if (log.isLoggable(Level.FINER)) log.finer("Cols=" + size + " - " + (System.currentTimeMillis()-start) + "ms");
|
||||
if (log.isLoggable(Level.FINER)) log.finer("Cols=" + size + " - " + (System.currentTimeMillis()-start) + "ms");
|
||||
} // autoSize
|
||||
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
m_layout = layout;
|
||||
m_multiSelection = multiSelection;
|
||||
//
|
||||
StringBuilder sql = new StringBuilder ("SELECT ");
|
||||
StringBuilder sql = new StringBuilder ("SELECT ");
|
||||
// add columns & sql
|
||||
for (int i = 0; i < layout.length; i++)
|
||||
{
|
||||
|
@ -307,12 +307,12 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
* (DefaultTableModel fires TableStructureChanged, which calls
|
||||
* JTable.tableChanged .. createDefaultColumnsFromModel
|
||||
* @param header header
|
||||
*/
|
||||
public void addColumn (String header)
|
||||
{
|
||||
if (getModel() instanceof DefaultTableModel)
|
||||
{
|
||||
DefaultTableModel model = (DefaultTableModel)getModel();
|
||||
*/
|
||||
public void addColumn (String header)
|
||||
{
|
||||
if (getModel() instanceof DefaultTableModel)
|
||||
{
|
||||
DefaultTableModel model = (DefaultTableModel)getModel();
|
||||
model.addColumn(Util.cleanAmp(header));
|
||||
}
|
||||
else
|
||||
|
@ -326,7 +326,7 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
* @param c class of column - determines renderere
|
||||
* @param readOnly read only flag
|
||||
*/
|
||||
public void setColumnClass (int index, Class<?> c, boolean readOnly)
|
||||
public void setColumnClass (int index, Class<?> c, boolean readOnly)
|
||||
{
|
||||
setColumnClass(index, c, readOnly, null);
|
||||
} // setColumnClass
|
||||
|
@ -341,7 +341,7 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
* @param readOnly read only flag
|
||||
* @param header optional header value
|
||||
*/
|
||||
public void setColumnClass (int index, Class<?> c, boolean readOnly, String header)
|
||||
public void setColumnClass (int index, Class<?> c, boolean readOnly, String header)
|
||||
{
|
||||
// log.config( "MiniTable.setColumnClass - " + index, c.getName() + ", r/o=" + readOnly);
|
||||
TableColumn tc = getColumnModel().getColumn(index);
|
||||
|
@ -358,20 +358,20 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
if (c == IDColumn.class)
|
||||
{
|
||||
tc.setCellRenderer(new IDColumnRenderer(m_multiSelection));
|
||||
if (m_multiSelection)
|
||||
if (m_multiSelection)
|
||||
{
|
||||
tc.setCellEditor(new IDColumnEditor());
|
||||
setColumnReadOnly(index, false);
|
||||
tc.setCellEditor(new IDColumnEditor());
|
||||
setColumnReadOnly(index, false);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
tc.setCellEditor(new ROCellEditor());
|
||||
tc.setCellEditor(new ROCellEditor());
|
||||
}
|
||||
m_minWidth.add(Integer.valueOf(10));
|
||||
tc.setMaxWidth(20);
|
||||
tc.setPreferredWidth(20);
|
||||
tc.setResizable(false);
|
||||
|
||||
tc.setResizable(false);
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
|
||||
}
|
||||
// Boolean
|
||||
|
@ -381,15 +381,15 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
if (readOnly)
|
||||
tc.setCellEditor(new ROCellEditor());
|
||||
else
|
||||
{
|
||||
CCheckBox check = new CCheckBox();
|
||||
check.setMargin(new Insets(0,0,0,0));
|
||||
check.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
tc.setCellEditor(new DefaultCellEditor(check));
|
||||
}
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.YesNo));
|
||||
{
|
||||
CCheckBox check = new CCheckBox();
|
||||
check.setMargin(new Insets(0,0,0,0));
|
||||
check.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
tc.setCellEditor(new DefaultCellEditor(check));
|
||||
}
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.YesNo));
|
||||
}
|
||||
// Date
|
||||
else if (c == Timestamp.class)
|
||||
|
@ -399,8 +399,8 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
tc.setCellEditor(new ROCellEditor());
|
||||
else
|
||||
tc.setCellEditor(new MiniCellEditor(c));
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.DateTime));
|
||||
}
|
||||
// Amount
|
||||
|
@ -416,8 +416,8 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
{
|
||||
tc.setCellEditor(new MiniCellEditor(c));
|
||||
m_minWidth.add(Integer.valueOf(80));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
|
||||
}
|
||||
// Number
|
||||
|
@ -433,8 +433,8 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
{
|
||||
tc.setCellEditor(new MiniCellEditor(c));
|
||||
m_minWidth.add(Integer.valueOf(80));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
|
||||
}
|
||||
// Integer
|
||||
|
@ -445,8 +445,8 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
tc.setCellEditor(new ROCellEditor());
|
||||
else
|
||||
tc.setCellEditor(new MiniCellEditor(c));
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
|
||||
}
|
||||
// String
|
||||
|
@ -457,8 +457,8 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
tc.setCellEditor(new ROCellEditor());
|
||||
else
|
||||
tc.setCellEditor(new MiniCellEditor(String.class));
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
m_minWidth.add(Integer.valueOf(30));
|
||||
|
||||
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.String));
|
||||
}
|
||||
// log.fine( "Renderer=" + tc.getCellRenderer().toString() + ", Editor=" + tc.getCellEditor().toString());
|
||||
|
@ -505,7 +505,7 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
{
|
||||
Object data = null;
|
||||
Class<?> c = m_layout[col].getColClass();
|
||||
int colIndex = col + colOffset;
|
||||
int colIndex = col + colOffset;
|
||||
if (c == IDColumn.class)
|
||||
data = new IDColumn(rs.getInt(colIndex));
|
||||
else if (c == Boolean.class)
|
||||
|
@ -535,20 +535,20 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
setValueAt(data, row, col);
|
||||
// log.fine( "r=" + row + ", c=" + col + " " + m_layout[col].getColHeader(),
|
||||
// "data=" + data.toString() + " " + data.getClass().getName() + " * " + m_table.getCellRenderer(row, col));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
if(getShowTotals())
|
||||
}
|
||||
if(getShowTotals())
|
||||
addTotals(m_layout);
|
||||
autoSize();
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Row(rs)=" + getRowCount());
|
||||
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Row(rs)=" + getRowCount());
|
||||
|
||||
|
||||
} // loadTable
|
||||
|
||||
|
@ -585,11 +585,11 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
// store
|
||||
setValueAt(data, row, col);
|
||||
}
|
||||
}
|
||||
if(getShowTotals())
|
||||
}
|
||||
if(getShowTotals())
|
||||
addTotals(m_layout);
|
||||
autoSize();
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Row(array)=" + getRowCount());
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Row(array)=" + getRowCount());
|
||||
} // loadTable
|
||||
|
||||
|
||||
|
@ -614,35 +614,35 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
return null;
|
||||
} // getSelectedRowKey
|
||||
|
||||
/**
|
||||
* @return collection of selected IDs
|
||||
*/
|
||||
public Collection<Integer> getSelectedKeys()
|
||||
{
|
||||
if (m_layout == null)
|
||||
{
|
||||
throw new UnsupportedOperationException("Layout not defined");
|
||||
}
|
||||
if (p_keyColumnIndex < 0)
|
||||
{
|
||||
throw new UnsupportedOperationException("Key Column is not defined");
|
||||
}
|
||||
//
|
||||
ArrayList<Integer> list = new ArrayList<Integer>();
|
||||
for (int row = 0; row < getRowCount(); row++)
|
||||
{
|
||||
Object data = getModel().getValueAt(row, p_keyColumnIndex);
|
||||
if (data instanceof IDColumn)
|
||||
{
|
||||
IDColumn record = (IDColumn)data;
|
||||
if (record.isSelected())
|
||||
{
|
||||
list.add(record.getRecord_ID());
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* @return collection of selected IDs
|
||||
*/
|
||||
public Collection<Integer> getSelectedKeys()
|
||||
{
|
||||
if (m_layout == null)
|
||||
{
|
||||
throw new UnsupportedOperationException("Layout not defined");
|
||||
}
|
||||
if (p_keyColumnIndex < 0)
|
||||
{
|
||||
throw new UnsupportedOperationException("Key Column is not defined");
|
||||
}
|
||||
//
|
||||
ArrayList<Integer> list = new ArrayList<Integer>();
|
||||
for (int row = 0; row < getRowCount(); row++)
|
||||
{
|
||||
Object data = getModel().getValueAt(row, p_keyColumnIndex);
|
||||
if (data instanceof IDColumn)
|
||||
{
|
||||
IDColumn record = (IDColumn)data;
|
||||
if (record.isSelected())
|
||||
{
|
||||
list.add(record.getRecord_ID());
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Get Layout
|
||||
|
@ -738,173 +738,173 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
if (cmp < 0)
|
||||
return 1;
|
||||
return 0;
|
||||
} // getColorCode
|
||||
|
||||
|
||||
/**
|
||||
* Set if Totals is Show
|
||||
* @param boolean Show
|
||||
*/
|
||||
public void setShowTotals(boolean show)
|
||||
{
|
||||
showTotals= show;
|
||||
}
|
||||
/**
|
||||
* get if Totals is Show
|
||||
* @param boolean Show
|
||||
*/
|
||||
public boolean getShowTotals()
|
||||
{
|
||||
return showTotals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding a new row with the totals
|
||||
*/
|
||||
public void addTotals(ColumnInfo[] layout)
|
||||
{
|
||||
if (getRowCount() == 0 || layout.length == 0)
|
||||
return;
|
||||
|
||||
Object[] total = new Object[layout.length];
|
||||
|
||||
for (int row = 0 ; row < getRowCount(); row ++)
|
||||
{
|
||||
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Object data = getModel().getValueAt(row, col);
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
BigDecimal subtotal = Env.ZERO;
|
||||
if(total[col]!= null)
|
||||
subtotal = (BigDecimal)(total[col]);
|
||||
|
||||
BigDecimal amt = (BigDecimal) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Env.ZERO;
|
||||
if(amt == null )
|
||||
amt = Env.ZERO;
|
||||
total[col] = subtotal.add(amt);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
Double subtotal = Double.valueOf(0);
|
||||
if(total[col] != null)
|
||||
subtotal = (Double)(total[col]);
|
||||
|
||||
Double amt = (Double) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Double.valueOf(0);
|
||||
if(amt == null )
|
||||
amt = Double.valueOf(0);
|
||||
total[col] = subtotal + amt;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//adding total row
|
||||
|
||||
int row = getRowCount() + 1;
|
||||
setRowCount(row);
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
setValueAt(total[col] , row - 1, col);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
setValueAt(total[col] , row -1 , col);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(col == 0 )
|
||||
{
|
||||
setValueAt(" Σ " , row -1 , col);
|
||||
}
|
||||
else
|
||||
setValueAt(null , row - 1, col );
|
||||
}
|
||||
|
||||
}
|
||||
} // getColorCode
|
||||
|
||||
|
||||
/**
|
||||
* Set if Totals is Show
|
||||
* @param boolean Show
|
||||
*/
|
||||
public void setShowTotals(boolean show)
|
||||
{
|
||||
showTotals= show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding a new row with the totals
|
||||
*/
|
||||
public void addTotals(Info_Column[] layout)
|
||||
{
|
||||
if (getRowCount() == 0 || layout.length == 0)
|
||||
return;
|
||||
|
||||
Object[] total = new Object[layout.length];
|
||||
|
||||
for (int row = 0 ; row < getRowCount(); row ++)
|
||||
{
|
||||
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Object data = getModel().getValueAt(row, col);
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
BigDecimal subtotal = Env.ZERO;
|
||||
if(total[col]!= null)
|
||||
subtotal = (BigDecimal)(total[col]);
|
||||
|
||||
BigDecimal amt = (BigDecimal) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Env.ZERO;
|
||||
if(amt == null )
|
||||
amt = Env.ZERO;
|
||||
total[col] = subtotal.add(amt);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
Double subtotal = Double.valueOf(0);
|
||||
if(total[col] != null)
|
||||
subtotal = (Double)(total[col]);
|
||||
|
||||
Double amt = (Double) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Double.valueOf(0);
|
||||
if(amt == null )
|
||||
amt = Double.valueOf(0);
|
||||
total[col] = subtotal + amt;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//adding total row
|
||||
|
||||
int row = getRowCount() + 1;
|
||||
setRowCount(row);
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
setValueAt(total[col] , row - 1, col);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
setValueAt(total[col] , row -1 , col);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(col == 1 )
|
||||
{
|
||||
setValueAt(" Σ " , row -1 , col );
|
||||
}
|
||||
else
|
||||
setValueAt(null , row - 1, col );
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* get if Totals is Show
|
||||
* @param boolean Show
|
||||
*/
|
||||
public boolean getShowTotals()
|
||||
{
|
||||
return showTotals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding a new row with the totals
|
||||
*/
|
||||
public void addTotals(ColumnInfo[] layout)
|
||||
{
|
||||
if (getRowCount() == 0 || layout.length == 0)
|
||||
return;
|
||||
|
||||
Object[] total = new Object[layout.length];
|
||||
|
||||
for (int row = 0 ; row < getRowCount(); row ++)
|
||||
{
|
||||
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Object data = getModel().getValueAt(row, col);
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
BigDecimal subtotal = Env.ZERO;
|
||||
if(total[col]!= null)
|
||||
subtotal = (BigDecimal)(total[col]);
|
||||
|
||||
BigDecimal amt = (BigDecimal) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Env.ZERO;
|
||||
if(amt == null )
|
||||
amt = Env.ZERO;
|
||||
total[col] = subtotal.add(amt);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
Double subtotal = Double.valueOf(0);
|
||||
if(total[col] != null)
|
||||
subtotal = (Double)(total[col]);
|
||||
|
||||
Double amt = (Double) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Double.valueOf(0);
|
||||
if(amt == null )
|
||||
amt = Double.valueOf(0);
|
||||
total[col] = subtotal + amt;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//adding total row
|
||||
|
||||
int row = getRowCount() + 1;
|
||||
setRowCount(row);
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
setValueAt(total[col] , row - 1, col);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
setValueAt(total[col] , row -1 , col);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(col == 0 )
|
||||
{
|
||||
setValueAt(" Σ " , row -1 , col);
|
||||
}
|
||||
else
|
||||
setValueAt(null , row - 1, col );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding a new row with the totals
|
||||
*/
|
||||
public void addTotals(Info_Column[] layout)
|
||||
{
|
||||
if (getRowCount() == 0 || layout.length == 0)
|
||||
return;
|
||||
|
||||
Object[] total = new Object[layout.length];
|
||||
|
||||
for (int row = 0 ; row < getRowCount(); row ++)
|
||||
{
|
||||
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Object data = getModel().getValueAt(row, col);
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
BigDecimal subtotal = Env.ZERO;
|
||||
if(total[col]!= null)
|
||||
subtotal = (BigDecimal)(total[col]);
|
||||
|
||||
BigDecimal amt = (BigDecimal) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Env.ZERO;
|
||||
if(amt == null )
|
||||
amt = Env.ZERO;
|
||||
total[col] = subtotal.add(amt);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
Double subtotal = Double.valueOf(0);
|
||||
if(total[col] != null)
|
||||
subtotal = (Double)(total[col]);
|
||||
|
||||
Double amt = (Double) data;
|
||||
if(subtotal == null)
|
||||
subtotal = Double.valueOf(0);
|
||||
if(amt == null )
|
||||
amt = Double.valueOf(0);
|
||||
total[col] = subtotal + amt;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//adding total row
|
||||
|
||||
int row = getRowCount() + 1;
|
||||
setRowCount(row);
|
||||
for (int col = 0; col < layout.length; col++)
|
||||
{
|
||||
Class<?> c = layout[col].getColClass();
|
||||
if (c == BigDecimal.class)
|
||||
{
|
||||
setValueAt(total[col] , row - 1, col);
|
||||
}
|
||||
else if (c == Double.class)
|
||||
{
|
||||
setValueAt(total[col] , row -1 , col);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(col == 1 )
|
||||
{
|
||||
setValueAt(" Σ " , row -1 , col );
|
||||
}
|
||||
else
|
||||
setValueAt(null , row - 1, col );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // MiniTable
|
||||
|
|
|
@ -1,133 +1,133 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.plaf;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* Translation Texts for Look & Feel
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: PlafRes.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $
|
||||
*/
|
||||
public class PlafRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** The data */
|
||||
static final Object[][] contents = new String[][]
|
||||
{
|
||||
{ "BackColType", "Háttérszín típus" },
|
||||
{ "BackColType_Flat", "Sima" },
|
||||
{ "BackColType_Gradient", "Gradiens" },
|
||||
{ "BackColType_Lines", "Vonalas" },
|
||||
{ "BackColType_Texture", "Textúrázott" },
|
||||
//
|
||||
{ "LookAndFeelEditor", "Look & Feel Editor" },
|
||||
{ "LookAndFeel", "Look & Feel" },
|
||||
{ "Theme", "Theme" },
|
||||
{ "EditAdempiereTheme", "Edit Adempiere Theme" },
|
||||
{ "SetDefault", "Default Background" },
|
||||
{ "SetDefaultColor", "Background Color" },
|
||||
{ "ColorBlind", "Color Deficiency" },
|
||||
{ "Example", "Example" },
|
||||
{ "Reset", "Reset" },
|
||||
{ "OK", "OK" },
|
||||
{ "Cancel", "Cancel" },
|
||||
//
|
||||
{ "AdempiereThemeEditor", "Adempiere Theme Editor" },
|
||||
{ "MetalColors", "Metal Colors" },
|
||||
{ "AdempiereColors", "Adempiere Colors" },
|
||||
{ "AdempiereFonts", "Adempiere Fonts" },
|
||||
{ "Primary1Info", "Shadow, Separator" },
|
||||
{ "Primary1", "Primary 1" },
|
||||
{ "Primary2Info", "Focus Line, Selected Menu" },
|
||||
{ "Primary2", "Primary 2" },
|
||||
{ "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" },
|
||||
{ "Primary3", "Primary 3" },
|
||||
{ "Secondary1Info", "Border Lines" },
|
||||
{ "Secondary1", "Secondary 1" },
|
||||
{ "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" },
|
||||
{ "Secondary2", "Secondary 2" },
|
||||
{ "Secondary3Info", "Background" },
|
||||
{ "Secondary3", "Secondary 3" },
|
||||
//
|
||||
{ "ControlFontInfo", "Control Font" },
|
||||
{ "ControlFont", "Label Font" },
|
||||
{ "SystemFontInfo", "Tool Tip, Tree nodes" },
|
||||
{ "SystemFont", "System Font" },
|
||||
{ "UserFontInfo", "User Entered Data" },
|
||||
{ "UserFont", "Field Font" },
|
||||
// { "SmallFontInfo", "Reports" },
|
||||
{ "SmallFont", "Small Font" },
|
||||
{ "WindowTitleFont", "Title Font" },
|
||||
{ "MenuFont", "Menu Font" },
|
||||
//
|
||||
{ "MandatoryInfo", "Mandatory Field Background" },
|
||||
{ "Mandatory", "Mandatory" },
|
||||
{ "ErrorInfo", "Error Field Background" },
|
||||
{ "Error", "Error" },
|
||||
{ "InfoInfo", "Info Field Background" },
|
||||
{ "Info", "Info" },
|
||||
{ "WhiteInfo", "Lines" },
|
||||
{ "White", "White" },
|
||||
{ "BlackInfo", "Lines, Text" },
|
||||
{ "Black", "Black" },
|
||||
{ "InactiveInfo", "Inactive Field Background" },
|
||||
{ "Inactive", "Inactive" },
|
||||
{ "TextOKInfo", "OK Text Foreground" },
|
||||
{ "TextOK", "Text - OK" },
|
||||
{ "TextIssueInfo", "Error Text Foreground" },
|
||||
{ "TextIssue", "Text - Error" },
|
||||
//
|
||||
{ "FontChooser", "Font Chooser" },
|
||||
{ "Fonts", "Fonts" },
|
||||
{ "Plain", "Plain" },
|
||||
{ "Italic", "Italic" },
|
||||
{ "Bold", "Bold" },
|
||||
{ "BoldItalic", "Bold & Italic" },
|
||||
{ "Name", "Name" },
|
||||
{ "Size", "Size" },
|
||||
{ "Style", "Style" },
|
||||
{ "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" },
|
||||
{ "FontString", "Font" },
|
||||
//
|
||||
{ "AdempiereColorEditor", "Adempiere Color Editor" },
|
||||
{ "AdempiereType", "Color Type" },
|
||||
{ "GradientUpperColor", "Gradient Upper Color" },
|
||||
{ "GradientLowerColor", "Gradient Lower Color" },
|
||||
{ "GradientStart", "Gradient Start" },
|
||||
{ "GradientDistance", "Gradient Distance" },
|
||||
{ "TextureURL", "Texture URL" },
|
||||
{ "TextureAlpha", "Texture Alpha" },
|
||||
{ "TextureTaintColor", "Texture Taint Color" },
|
||||
{ "LineColor", "Line Color" },
|
||||
{ "LineBackColor", "Background Color" },
|
||||
{ "LineWidth", "Line Width" },
|
||||
{ "LineDistance", "Line Distance" },
|
||||
{ "FlatColor", "Flat Color" },
|
||||
{ "UITheme", "User Interface Theme" },
|
||||
{ "Preview", "Preview" }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Contents
|
||||
* @return contents
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
}
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.plaf;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* Translation Texts for Look & Feel
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: PlafRes.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $
|
||||
*/
|
||||
public class PlafRes_hu extends ListResourceBundle
|
||||
{
|
||||
/** The data */
|
||||
static final Object[][] contents = new String[][]
|
||||
{
|
||||
{ "BackColType", "Háttérszín típus" },
|
||||
{ "BackColType_Flat", "Sima" },
|
||||
{ "BackColType_Gradient", "Gradiens" },
|
||||
{ "BackColType_Lines", "Vonalas" },
|
||||
{ "BackColType_Texture", "Textúrázott" },
|
||||
//
|
||||
{ "LookAndFeelEditor", "Look & Feel Editor" },
|
||||
{ "LookAndFeel", "Look & Feel" },
|
||||
{ "Theme", "Theme" },
|
||||
{ "EditAdempiereTheme", "Edit Adempiere Theme" },
|
||||
{ "SetDefault", "Default Background" },
|
||||
{ "SetDefaultColor", "Background Color" },
|
||||
{ "ColorBlind", "Color Deficiency" },
|
||||
{ "Example", "Example" },
|
||||
{ "Reset", "Reset" },
|
||||
{ "OK", "OK" },
|
||||
{ "Cancel", "Cancel" },
|
||||
//
|
||||
{ "AdempiereThemeEditor", "Adempiere Theme Editor" },
|
||||
{ "MetalColors", "Metal Colors" },
|
||||
{ "AdempiereColors", "Adempiere Colors" },
|
||||
{ "AdempiereFonts", "Adempiere Fonts" },
|
||||
{ "Primary1Info", "Shadow, Separator" },
|
||||
{ "Primary1", "Primary 1" },
|
||||
{ "Primary2Info", "Focus Line, Selected Menu" },
|
||||
{ "Primary2", "Primary 2" },
|
||||
{ "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" },
|
||||
{ "Primary3", "Primary 3" },
|
||||
{ "Secondary1Info", "Border Lines" },
|
||||
{ "Secondary1", "Secondary 1" },
|
||||
{ "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" },
|
||||
{ "Secondary2", "Secondary 2" },
|
||||
{ "Secondary3Info", "Background" },
|
||||
{ "Secondary3", "Secondary 3" },
|
||||
//
|
||||
{ "ControlFontInfo", "Control Font" },
|
||||
{ "ControlFont", "Label Font" },
|
||||
{ "SystemFontInfo", "Tool Tip, Tree nodes" },
|
||||
{ "SystemFont", "System Font" },
|
||||
{ "UserFontInfo", "User Entered Data" },
|
||||
{ "UserFont", "Field Font" },
|
||||
// { "SmallFontInfo", "Reports" },
|
||||
{ "SmallFont", "Small Font" },
|
||||
{ "WindowTitleFont", "Title Font" },
|
||||
{ "MenuFont", "Menu Font" },
|
||||
//
|
||||
{ "MandatoryInfo", "Mandatory Field Background" },
|
||||
{ "Mandatory", "Mandatory" },
|
||||
{ "ErrorInfo", "Error Field Background" },
|
||||
{ "Error", "Error" },
|
||||
{ "InfoInfo", "Info Field Background" },
|
||||
{ "Info", "Info" },
|
||||
{ "WhiteInfo", "Lines" },
|
||||
{ "White", "White" },
|
||||
{ "BlackInfo", "Lines, Text" },
|
||||
{ "Black", "Black" },
|
||||
{ "InactiveInfo", "Inactive Field Background" },
|
||||
{ "Inactive", "Inactive" },
|
||||
{ "TextOKInfo", "OK Text Foreground" },
|
||||
{ "TextOK", "Text - OK" },
|
||||
{ "TextIssueInfo", "Error Text Foreground" },
|
||||
{ "TextIssue", "Text - Error" },
|
||||
//
|
||||
{ "FontChooser", "Font Chooser" },
|
||||
{ "Fonts", "Fonts" },
|
||||
{ "Plain", "Plain" },
|
||||
{ "Italic", "Italic" },
|
||||
{ "Bold", "Bold" },
|
||||
{ "BoldItalic", "Bold & Italic" },
|
||||
{ "Name", "Name" },
|
||||
{ "Size", "Size" },
|
||||
{ "Style", "Style" },
|
||||
{ "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" },
|
||||
{ "FontString", "Font" },
|
||||
//
|
||||
{ "AdempiereColorEditor", "Adempiere Color Editor" },
|
||||
{ "AdempiereType", "Color Type" },
|
||||
{ "GradientUpperColor", "Gradient Upper Color" },
|
||||
{ "GradientLowerColor", "Gradient Lower Color" },
|
||||
{ "GradientStart", "Gradient Start" },
|
||||
{ "GradientDistance", "Gradient Distance" },
|
||||
{ "TextureURL", "Texture URL" },
|
||||
{ "TextureAlpha", "Texture Alpha" },
|
||||
{ "TextureTaintColor", "Texture Taint Color" },
|
||||
{ "LineColor", "Line Color" },
|
||||
{ "LineBackColor", "Background Color" },
|
||||
{ "LineWidth", "Line Width" },
|
||||
{ "LineDistance", "Line Distance" },
|
||||
{ "FlatColor", "Flat Color" },
|
||||
{ "UITheme", "User Interface Theme" },
|
||||
{ "Preview", "Preview" }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Contents
|
||||
* @return contents
|
||||
*/
|
||||
public Object[][] getContents()
|
||||
{
|
||||
return contents;
|
||||
}
|
||||
} // Res
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,8 +91,8 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
protected Login login;
|
||||
|
||||
protected Combobox lstRole, lstClient, lstOrganisation, lstWarehouse;
|
||||
protected Label lblRole, lblClient, lblOrganisation, lblWarehouse, lblDate;
|
||||
protected WDateEditor lstDate;
|
||||
protected Label lblRole, lblClient, lblOrganisation, lblWarehouse, lblDate;
|
||||
protected WDateEditor lstDate;
|
||||
protected Button btnOk, btnCancel;
|
||||
|
||||
/** Context */
|
||||
|
@ -249,18 +249,18 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
tr.appendChild(td);
|
||||
td.appendChild(lstWarehouse);
|
||||
|
||||
tr = new Tr();
|
||||
tr.setId("rowDate");
|
||||
table.appendChild(tr);
|
||||
td = new Td();
|
||||
tr.appendChild(td);
|
||||
td.setSclass(ITheme.LOGIN_LABEL_CLASS);
|
||||
td.appendChild(lblDate.rightAlign());
|
||||
td = new Td();
|
||||
td.setSclass(ITheme.LOGIN_FIELD_CLASS);
|
||||
tr.appendChild(td);
|
||||
td.appendChild(lstDate.getComponent());
|
||||
|
||||
tr = new Tr();
|
||||
tr.setId("rowDate");
|
||||
table.appendChild(tr);
|
||||
td = new Td();
|
||||
tr.appendChild(td);
|
||||
td.setSclass(ITheme.LOGIN_LABEL_CLASS);
|
||||
td.appendChild(lblDate.rightAlign());
|
||||
td = new Td();
|
||||
td.setSclass(ITheme.LOGIN_FIELD_CLASS);
|
||||
tr.appendChild(td);
|
||||
td.appendChild(lstDate.getComponent());
|
||||
|
||||
div = new Div();
|
||||
div.setSclass(ITheme.LOGIN_BOX_FOOTER_CLASS);
|
||||
ConfirmPanel pnlButtons = new ConfirmPanel(true, false, false, false, false, false, true);
|
||||
|
@ -296,15 +296,15 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
lblWarehouse.setId("lblWarehouse");
|
||||
lblWarehouse.setValue(Msg.getMsg(language,"Warehouse"));
|
||||
|
||||
lblDate = new Label();
|
||||
lblDate.setId("lblDate");
|
||||
lblDate = new Label();
|
||||
lblDate.setId("lblDate");
|
||||
lblDate.setValue(Msg.getMsg(language,"Date"));
|
||||
|
||||
|
||||
lstRole = new Combobox();
|
||||
lstRole.setAutocomplete(true);
|
||||
lstRole.setAutodrop(true);
|
||||
lstRole.setId("lstRole");
|
||||
|
||||
|
||||
lstRole.addEventListener(Events.ON_SELECT, this);
|
||||
ZKUpdateUtil.setWidth(lstRole, "220px");
|
||||
|
||||
|
@ -312,7 +312,7 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
lstClient.setAutocomplete(true);
|
||||
lstClient.setAutodrop(true);
|
||||
lstClient.setId("lstClient");
|
||||
|
||||
|
||||
lstClient.addEventListener(Events.ON_SELECT, this);
|
||||
ZKUpdateUtil.setWidth(lstClient, "220px");
|
||||
|
||||
|
@ -320,7 +320,7 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
lstOrganisation.setAutocomplete(true);
|
||||
lstOrganisation.setAutodrop(true);
|
||||
lstOrganisation.setId("lstOrganisation");
|
||||
|
||||
|
||||
lstOrganisation.addEventListener(Events.ON_SELECT, this);
|
||||
ZKUpdateUtil.setWidth(lstOrganisation, "220px");
|
||||
|
||||
|
@ -328,14 +328,14 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
lstWarehouse.setAutocomplete(true);
|
||||
lstWarehouse.setAutodrop(true);
|
||||
lstWarehouse.setId("lstWarehouse");
|
||||
|
||||
|
||||
lstWarehouse.addEventListener(Events.ON_SELECT, this);
|
||||
ZKUpdateUtil.setWidth(lstWarehouse, "220px");
|
||||
|
||||
lstDate = new WDateEditor();
|
||||
lstDate = new WDateEditor();
|
||||
lstDate.setValue(new Timestamp(System.currentTimeMillis()));
|
||||
lstDate.getComponent().setId("loginDate");
|
||||
|
||||
lstDate.getComponent().setId("loginDate");
|
||||
|
||||
btnOk = new Button();
|
||||
btnOk.setId("btnOk");
|
||||
btnOk.setLabel("Ok");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,9 +23,9 @@
|
|||
<listener-class>org.adempiere.webui.util.LogEventInterceptor</listener-class>
|
||||
</listener -->
|
||||
|
||||
<!-- false to use compress js which is much smaller. change to true if you need to debug -->
|
||||
<!-- false to use compress js which is much smaller. change to true if you need to debug -->
|
||||
<client-config>
|
||||
<processing-prompt-delay>500</processing-prompt-delay>
|
||||
<processing-prompt-delay>500</processing-prompt-delay>
|
||||
</client-config>
|
||||
|
||||
<desktop-config>
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<%@ page language="java" contentType="image/gif"%>
|
||||
<%
|
||||
String fileName = request.getParameter("f");
|
||||
if (fileName != null && fileName.endsWith(".gif")) {
|
||||
java.io.File f = new java.io.File(fileName);
|
||||
if (f.exists() && f.canRead()) {
|
||||
response.setContentLength(new Long(f.length()).intValue());
|
||||
java.io.FileInputStream fis = new java.io.FileInputStream(f);
|
||||
java.io.BufferedInputStream bis = new java.io.BufferedInputStream(fis);
|
||||
java.io.OutputStream os = response.getOutputStream();
|
||||
java.io.BufferedOutputStream bos = new java.io.BufferedOutputStream(os);
|
||||
while (bis.available() > 0)
|
||||
{
|
||||
bos.write(bis.read());
|
||||
}
|
||||
bis.close();
|
||||
bos.flush();
|
||||
bos.close();
|
||||
}
|
||||
}
|
||||
%>
|
||||
<%
|
||||
String fileName = request.getParameter("f");
|
||||
if (fileName != null && fileName.endsWith(".gif")) {
|
||||
java.io.File f = new java.io.File(fileName);
|
||||
if (f.exists() && f.canRead()) {
|
||||
response.setContentLength(new Long(f.length()).intValue());
|
||||
java.io.FileInputStream fis = new java.io.FileInputStream(f);
|
||||
java.io.BufferedInputStream bis = new java.io.BufferedInputStream(fis);
|
||||
java.io.OutputStream os = response.getOutputStream();
|
||||
java.io.BufferedOutputStream bos = new java.io.BufferedOutputStream(os);
|
||||
while (bis.available() > 0)
|
||||
{
|
||||
bos.write(bis.read());
|
||||
}
|
||||
bis.close();
|
||||
bos.flush();
|
||||
bos.close();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
<%@ page language="java" contentType="application/octet-stream"%>
|
||||
<%@ page trimDirectiveWhitespaces="true" %>
|
||||
<%@page import="org.compiere.model.MArchive"%>
|
||||
<%@page import="org.compiere.util.Env"%>
|
||||
<%@page import="java.io.ByteArrayOutputStream"%>
|
||||
<%@page import="java.io.FileInputStream"%>
|
||||
<%@page import="java.io.File"%>
|
||||
<%@page import="java.io.BufferedOutputStream"%>
|
||||
<%@page import="java.io.OutputStream"%>
|
||||
<%
|
||||
try
|
||||
{
|
||||
String fileid = request.getParameter("fileid");
|
||||
if (fileid == null || fileid.trim().length() == 0)
|
||||
{
|
||||
response.setContentLength(0);
|
||||
return;
|
||||
}
|
||||
|
||||
int AD_Archive_ID = Integer.parseInt(fileid);
|
||||
if (AD_Archive_ID > 0)
|
||||
{
|
||||
MArchive archive = new MArchive(Env.getCtx(), AD_Archive_ID, null);
|
||||
if (archive != null && archive.getAD_Archive_ID() > 0)
|
||||
{
|
||||
byte[] data = archive.getBinaryData();
|
||||
response.setContentLength(data.length);
|
||||
|
||||
OutputStream os = response.getOutputStream();
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
||||
bos.write(data);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
archive.delete(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
response.setContentLength(0);
|
||||
}
|
||||
<%@ page language="java" contentType="application/octet-stream"%>
|
||||
<%@ page trimDirectiveWhitespaces="true" %>
|
||||
<%@page import="org.compiere.model.MArchive"%>
|
||||
<%@page import="org.compiere.util.Env"%>
|
||||
<%@page import="java.io.ByteArrayOutputStream"%>
|
||||
<%@page import="java.io.FileInputStream"%>
|
||||
<%@page import="java.io.File"%>
|
||||
<%@page import="java.io.BufferedOutputStream"%>
|
||||
<%@page import="java.io.OutputStream"%>
|
||||
<%
|
||||
try
|
||||
{
|
||||
String fileid = request.getParameter("fileid");
|
||||
if (fileid == null || fileid.trim().length() == 0)
|
||||
{
|
||||
response.setContentLength(0);
|
||||
return;
|
||||
}
|
||||
|
||||
int AD_Archive_ID = Integer.parseInt(fileid);
|
||||
if (AD_Archive_ID > 0)
|
||||
{
|
||||
MArchive archive = new MArchive(Env.getCtx(), AD_Archive_ID, null);
|
||||
if (archive != null && archive.getAD_Archive_ID() > 0)
|
||||
{
|
||||
byte[] data = archive.getBinaryData();
|
||||
response.setContentLength(data.length);
|
||||
|
||||
OutputStream os = response.getOutputStream();
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
||||
bos.write(data);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
archive.delete(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
response.setContentLength(0);
|
||||
}
|
||||
%>
|
||||
|
|
|
@ -1,153 +1,153 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2009 Low Heng Sin *
|
||||
* Copyright (C) 2009 Idalica Corporation *
|
||||
* 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. *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import static org.compiere.model.SystemIDs.WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.apps.IStatusBar;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.GridWindow;
|
||||
import org.compiere.model.GridWindowVO;
|
||||
import org.compiere.model.I_C_ProjectIssue;
|
||||
import org.compiere.model.I_M_InOutLine;
|
||||
import org.compiere.model.I_M_InventoryLine;
|
||||
import org.compiere.model.I_M_MovementLine;
|
||||
import org.compiere.model.I_M_ProductionLine;
|
||||
import org.compiere.model.I_M_Transaction;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
public class TrxMaterial {
|
||||
|
||||
/** Window No */
|
||||
public int m_WindowNo = 0;
|
||||
/** MWindow */
|
||||
public GridWindow m_mWindow = null;
|
||||
/** MTab pointer */
|
||||
public GridTab m_mTab = null;
|
||||
|
||||
public MQuery m_staticQuery = null;
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(TrxMaterial.class);
|
||||
|
||||
/**
|
||||
* Dynamic Layout (Grid).
|
||||
* Based on AD_Window: Material Transactions
|
||||
*/
|
||||
public void dynInit(IStatusBar statusBar)
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2009 Low Heng Sin *
|
||||
* Copyright (C) 2009 Idalica Corporation *
|
||||
* 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. *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import static org.compiere.model.SystemIDs.WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.apps.IStatusBar;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.GridWindow;
|
||||
import org.compiere.model.GridWindowVO;
|
||||
import org.compiere.model.I_C_ProjectIssue;
|
||||
import org.compiere.model.I_M_InOutLine;
|
||||
import org.compiere.model.I_M_InventoryLine;
|
||||
import org.compiere.model.I_M_MovementLine;
|
||||
import org.compiere.model.I_M_ProductionLine;
|
||||
import org.compiere.model.I_M_Transaction;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
public class TrxMaterial {
|
||||
|
||||
/** Window No */
|
||||
public int m_WindowNo = 0;
|
||||
/** MWindow */
|
||||
public GridWindow m_mWindow = null;
|
||||
/** MTab pointer */
|
||||
public GridTab m_mTab = null;
|
||||
|
||||
public MQuery m_staticQuery = null;
|
||||
/** Logger */
|
||||
public static CLogger log = CLogger.getCLogger(TrxMaterial.class);
|
||||
|
||||
/**
|
||||
* Dynamic Layout (Grid).
|
||||
* Based on AD_Window: Material Transactions
|
||||
*/
|
||||
public void dynInit(IStatusBar statusBar)
|
||||
{
|
||||
m_staticQuery = new MQuery();
|
||||
m_staticQuery.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
|
||||
int AD_Window_ID = WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER; // Hardcoded
|
||||
GridWindowVO wVO = Env.getMWindowVO (m_WindowNo, AD_Window_ID, 0);
|
||||
if (wVO == null)
|
||||
return;
|
||||
m_mWindow = new GridWindow (wVO);
|
||||
m_mTab = m_mWindow.getTab(0);
|
||||
m_mWindow.initTab(0);
|
||||
//
|
||||
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
|
||||
m_mTab.query(false);
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(" ");
|
||||
} // dynInit
|
||||
|
||||
/**************************************************************************
|
||||
* Refresh - Create Query and refresh grid
|
||||
*/
|
||||
public void refresh(Object organization, Object locator, Object product, Object movementType,
|
||||
Timestamp movementDateFrom, Timestamp movementDateTo, IStatusBar statusBar)
|
||||
{
|
||||
/**
|
||||
* Create Where Clause
|
||||
*/
|
||||
MQuery query = m_staticQuery.deepCopy();
|
||||
// Organization
|
||||
if (organization != null && organization.toString().length() > 0)
|
||||
query.addRestriction("AD_Org_ID", MQuery.EQUAL, organization);
|
||||
// Locator
|
||||
if (locator != null && locator.toString().length() > 0)
|
||||
query.addRestriction("M_Locator_ID", MQuery.EQUAL, locator);
|
||||
// Product
|
||||
if (product != null && product.toString().length() > 0)
|
||||
query.addRestriction("M_Product_ID", MQuery.EQUAL, product);
|
||||
// MovementType
|
||||
if (movementType != null && movementType.toString().length() > 0)
|
||||
query.addRestriction("MovementType", MQuery.EQUAL, movementType);
|
||||
// DateFrom
|
||||
if (movementDateFrom != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.GREATER_EQUAL, movementDateFrom);
|
||||
// DateTO
|
||||
if (movementDateTo != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.LESS_EQUAL, movementDateTo);
|
||||
if (log.isLoggable(Level.INFO)) log.info( "VTrxMaterial.refresh query=" + query.toString());
|
||||
|
||||
/**
|
||||
* Refresh/Requery
|
||||
*/
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false);
|
||||
//
|
||||
m_mTab.setQuery(query);
|
||||
m_mTab.query(false);
|
||||
//
|
||||
int no = m_mTab.getRowCount();
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(Integer.toString(no));
|
||||
} // refresh
|
||||
|
||||
public int AD_Table_ID;
|
||||
public int Record_ID;
|
||||
/**
|
||||
* Zoom
|
||||
*/
|
||||
public void zoom()
|
||||
{
|
||||
log.info("");
|
||||
//
|
||||
AD_Table_ID = 0;
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_InOutLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_InOutLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_InventoryLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_InventoryLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_MovementLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_MovementLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_ProductionLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_ProductionLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_C_ProjectIssue_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_C_ProjectIssue.Table_ID;
|
||||
} else {
|
||||
log.warning("Not found zoom table WindowNo=" + m_WindowNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // zoom
|
||||
|
||||
|
||||
}
|
||||
m_staticQuery = new MQuery();
|
||||
m_staticQuery.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
|
||||
int AD_Window_ID = WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER; // Hardcoded
|
||||
GridWindowVO wVO = Env.getMWindowVO (m_WindowNo, AD_Window_ID, 0);
|
||||
if (wVO == null)
|
||||
return;
|
||||
m_mWindow = new GridWindow (wVO);
|
||||
m_mTab = m_mWindow.getTab(0);
|
||||
m_mWindow.initTab(0);
|
||||
//
|
||||
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
|
||||
m_mTab.query(false);
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(" ");
|
||||
} // dynInit
|
||||
|
||||
/**************************************************************************
|
||||
* Refresh - Create Query and refresh grid
|
||||
*/
|
||||
public void refresh(Object organization, Object locator, Object product, Object movementType,
|
||||
Timestamp movementDateFrom, Timestamp movementDateTo, IStatusBar statusBar)
|
||||
{
|
||||
/**
|
||||
* Create Where Clause
|
||||
*/
|
||||
MQuery query = m_staticQuery.deepCopy();
|
||||
// Organization
|
||||
if (organization != null && organization.toString().length() > 0)
|
||||
query.addRestriction("AD_Org_ID", MQuery.EQUAL, organization);
|
||||
// Locator
|
||||
if (locator != null && locator.toString().length() > 0)
|
||||
query.addRestriction("M_Locator_ID", MQuery.EQUAL, locator);
|
||||
// Product
|
||||
if (product != null && product.toString().length() > 0)
|
||||
query.addRestriction("M_Product_ID", MQuery.EQUAL, product);
|
||||
// MovementType
|
||||
if (movementType != null && movementType.toString().length() > 0)
|
||||
query.addRestriction("MovementType", MQuery.EQUAL, movementType);
|
||||
// DateFrom
|
||||
if (movementDateFrom != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.GREATER_EQUAL, movementDateFrom);
|
||||
// DateTO
|
||||
if (movementDateTo != null)
|
||||
query.addRestriction("TRUNC(MovementDate)", MQuery.LESS_EQUAL, movementDateTo);
|
||||
if (log.isLoggable(Level.INFO)) log.info( "VTrxMaterial.refresh query=" + query.toString());
|
||||
|
||||
/**
|
||||
* Refresh/Requery
|
||||
*/
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false);
|
||||
//
|
||||
m_mTab.setQuery(query);
|
||||
m_mTab.query(false);
|
||||
//
|
||||
int no = m_mTab.getRowCount();
|
||||
statusBar.setStatusLine(" ", false);
|
||||
statusBar.setStatusDB(Integer.toString(no));
|
||||
} // refresh
|
||||
|
||||
public int AD_Table_ID;
|
||||
public int Record_ID;
|
||||
/**
|
||||
* Zoom
|
||||
*/
|
||||
public void zoom()
|
||||
{
|
||||
log.info("");
|
||||
//
|
||||
AD_Table_ID = 0;
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_InOutLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_InOutLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_InventoryLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_InventoryLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_MovementLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_MovementLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_ProductionLine_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_M_ProductionLine.Table_ID;
|
||||
} else {
|
||||
Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_C_ProjectIssue_ID);
|
||||
if (Record_ID != 0) {
|
||||
AD_Table_ID = I_C_ProjectIssue.Table_ID;
|
||||
} else {
|
||||
log.warning("Not found zoom table WindowNo=" + m_WindowNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // zoom
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue