IDEMPIERE-308 Performance: Replace with StringBuilder / Thanks to Richard Morales and David Peñuela
This commit is contained in:
parent
9eb8996340
commit
27bc656e22
|
@ -76,21 +76,21 @@ public class ExpenseAPInvoice extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer ("SELECT * "
|
StringBuilder sql = new StringBuilder ("SELECT * ")
|
||||||
+ "FROM S_TimeExpense e "
|
.append("FROM S_TimeExpense e ")
|
||||||
+ "WHERE e.Processed='Y'"
|
.append("WHERE e.Processed='Y'")
|
||||||
+ " AND e.AD_Client_ID=?"); // #1
|
.append(" AND e.AD_Client_ID=?"); // #1
|
||||||
if (m_C_BPartner_ID != 0)
|
if (m_C_BPartner_ID != 0)
|
||||||
sql.append(" AND e.C_BPartner_ID=?"); // #2
|
sql.append(" AND e.C_BPartner_ID=?"); // #2
|
||||||
if (m_DateFrom != null)
|
if (m_DateFrom != null)
|
||||||
sql.append(" AND e.DateReport >= ?"); // #3
|
sql.append(" AND e.DateReport >= ?"); // #3
|
||||||
if (m_DateTo != null)
|
if (m_DateTo != null)
|
||||||
sql.append(" AND e.DateReport <= ?"); // #4
|
sql.append(" AND e.DateReport <= ?"); // #4
|
||||||
sql.append(" AND EXISTS (SELECT * FROM S_TimeExpenseLine el "
|
sql.append(" AND EXISTS (SELECT * FROM S_TimeExpenseLine el ")
|
||||||
+ "WHERE e.S_TimeExpense_ID=el.S_TimeExpense_ID"
|
.append("WHERE e.S_TimeExpense_ID=el.S_TimeExpense_ID")
|
||||||
+ " AND el.C_InvoiceLine_ID IS NULL"
|
.append(" AND el.C_InvoiceLine_ID IS NULL")
|
||||||
+ " AND el.ConvertedAmt<>0) "
|
.append(" AND el.ConvertedAmt<>0) ")
|
||||||
+ "ORDER BY e.C_BPartner_ID, e.S_TimeExpense_ID");
|
.append("ORDER BY e.C_BPartner_ID, e.S_TimeExpense_ID");
|
||||||
//
|
//
|
||||||
int old_BPartner_ID = -1;
|
int old_BPartner_ID = -1;
|
||||||
MInvoice invoice = null;
|
MInvoice invoice = null;
|
||||||
|
@ -128,18 +128,19 @@ public class ExpenseAPInvoice extends SvrProcess
|
||||||
invoice.setBPartner(bp);
|
invoice.setBPartner(bp);
|
||||||
if (invoice.getC_BPartner_Location_ID() == 0)
|
if (invoice.getC_BPartner_Location_ID() == 0)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "No BP Location: " + bp);
|
StringBuilder msglog = new StringBuilder("No BP Location: ").append(bp);
|
||||||
addLog(0, te.getDateReport(),
|
log.log(Level.SEVERE, msglog.toString());
|
||||||
null, "No Location: " + te.getDocumentNo() + " " + bp.getName());
|
msglog = new StringBuilder("No Location: ").append(te.getDocumentNo()).append(" ").append(bp.getName());
|
||||||
|
addLog(0, te.getDateReport(), null, msglog.toString() );
|
||||||
invoice = null;
|
invoice = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
invoice.setM_PriceList_ID(te.getM_PriceList_ID());
|
invoice.setM_PriceList_ID(te.getM_PriceList_ID());
|
||||||
invoice.setSalesRep_ID(te.getDoc_User_ID());
|
invoice.setSalesRep_ID(te.getDoc_User_ID());
|
||||||
String descr = Msg.translate(getCtx(), "S_TimeExpense_ID")
|
StringBuilder descr = new StringBuilder(Msg.translate(getCtx(), "S_TimeExpense_ID"))
|
||||||
+ ": " + te.getDocumentNo() + " "
|
.append(": ").append(te.getDocumentNo()).append(" " )
|
||||||
+ DisplayType.getDateFormat(DisplayType.Date).format(te.getDateReport());
|
.append(DisplayType.getDateFormat(DisplayType.Date).format(te.getDateReport()));
|
||||||
invoice.setDescription(descr);
|
invoice.setDescription(descr.toString());
|
||||||
if (!invoice.save())
|
if (!invoice.save())
|
||||||
new IllegalStateException("Cannot save Invoice");
|
new IllegalStateException("Cannot save Invoice");
|
||||||
old_BPartner_ID = bp.getC_BPartner_ID();
|
old_BPartner_ID = bp.getC_BPartner_ID();
|
||||||
|
@ -200,7 +201,8 @@ public class ExpenseAPInvoice extends SvrProcess
|
||||||
rs = null; pstmt = null;
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
completeInvoice (invoice);
|
completeInvoice (invoice);
|
||||||
return "@Created@=" + m_noInvoices;
|
StringBuilder msgreturn = new StringBuilder("@Created@=").append(m_noInvoices);
|
||||||
|
return msgreturn.toString();
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -213,8 +215,9 @@ public class ExpenseAPInvoice extends SvrProcess
|
||||||
return;
|
return;
|
||||||
invoice.setDocAction(DocAction.ACTION_Prepare);
|
invoice.setDocAction(DocAction.ACTION_Prepare);
|
||||||
if (!invoice.processIt(DocAction.ACTION_Prepare)) {
|
if (!invoice.processIt(DocAction.ACTION_Prepare)) {
|
||||||
log.warning("Invoice Process Failed: " + invoice + " - " + invoice.getProcessMsg());
|
StringBuilder msglog = new StringBuilder("Invoice Process Failed: ").append(invoice).append(" - ").append(invoice.getProcessMsg());
|
||||||
throw new IllegalStateException("Invoice Process Failed: " + invoice + " - " + invoice.getProcessMsg());
|
log.warning(msglog.toString());
|
||||||
|
throw new IllegalStateException(msglog.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!invoice.save())
|
if (!invoice.save())
|
||||||
|
|
|
@ -84,18 +84,18 @@ public class ExpenseSOrder extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer("SELECT * FROM S_TimeExpenseLine el "
|
StringBuilder sql = new StringBuilder("SELECT * FROM S_TimeExpenseLine el ")
|
||||||
+ "WHERE el.AD_Client_ID=?" // #1
|
.append("WHERE el.AD_Client_ID=?") // #1
|
||||||
+ " AND el.C_BPartner_ID>0 AND el.IsInvoiced='Y'" // Business Partner && to be invoiced
|
.append(" AND el.C_BPartner_ID>0 AND el.IsInvoiced='Y'") // Business Partner && to be invoiced
|
||||||
+ " AND el.C_OrderLine_ID IS NULL" // not invoiced yet
|
.append(" AND el.C_OrderLine_ID IS NULL") // not invoiced yet
|
||||||
+ " AND EXISTS (SELECT * FROM S_TimeExpense e " // processed only
|
.append(" AND EXISTS (SELECT * FROM S_TimeExpense e ") // processed only
|
||||||
+ "WHERE el.S_TimeExpense_ID=e.S_TimeExpense_ID AND e.Processed='Y')");
|
.append("WHERE el.S_TimeExpense_ID=e.S_TimeExpense_ID AND e.Processed='Y')");
|
||||||
if (p_C_BPartner_ID != 0)
|
if (p_C_BPartner_ID != 0)
|
||||||
sql.append(" AND el.C_BPartner_ID=?"); // #2
|
sql.append(" AND el.C_BPartner_ID=?"); // #2
|
||||||
if (p_DateFrom != null || m_DateTo != null)
|
if (p_DateFrom != null || m_DateTo != null)
|
||||||
{
|
{
|
||||||
sql.append(" AND EXISTS (SELECT * FROM S_TimeExpense e "
|
sql.append(" AND EXISTS (SELECT * FROM S_TimeExpense e ")
|
||||||
+ "WHERE el.S_TimeExpense_ID=e.S_TimeExpense_ID");
|
.append("WHERE el.S_TimeExpense_ID=e.S_TimeExpense_ID");
|
||||||
if (p_DateFrom != null)
|
if (p_DateFrom != null)
|
||||||
sql.append(" AND e.DateReport >= ?"); // #3
|
sql.append(" AND e.DateReport >= ?"); // #3
|
||||||
if (m_DateTo != null)
|
if (m_DateTo != null)
|
||||||
|
@ -158,8 +158,8 @@ public class ExpenseSOrder extends SvrProcess
|
||||||
rs = null; pstmt = null;
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
completeOrder ();
|
completeOrder ();
|
||||||
|
StringBuilder msgreturn = new StringBuilder("@Created@=").append(m_noOrders);
|
||||||
return "@Created@=" + m_noOrders;
|
return msgreturn.toString();
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,9 +180,11 @@ public class ExpenseSOrder extends SvrProcess
|
||||||
m_order.setBPartner(bp);
|
m_order.setBPartner(bp);
|
||||||
if (m_order.getC_BPartner_Location_ID() == 0)
|
if (m_order.getC_BPartner_Location_ID() == 0)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "No BP Location: " + bp);
|
StringBuilder msglog = new StringBuilder("No BP Location: ").append(bp);
|
||||||
|
log.log(Level.SEVERE, msglog.toString());
|
||||||
|
msglog = new StringBuilder("No Location: ").append(te.getDocumentNo()).append(" ").append(bp.getName());
|
||||||
addLog(0, te.getDateReport(),
|
addLog(0, te.getDateReport(),
|
||||||
null, "No Location: " + te.getDocumentNo() + " " + bp.getName());
|
null, msglog.toString());
|
||||||
m_order = null;
|
m_order = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,8 +273,10 @@ public class ExpenseSOrder extends SvrProcess
|
||||||
return;
|
return;
|
||||||
m_order.setDocAction(DocAction.ACTION_Prepare);
|
m_order.setDocAction(DocAction.ACTION_Prepare);
|
||||||
if (!m_order.processIt(DocAction.ACTION_Prepare)) {
|
if (!m_order.processIt(DocAction.ACTION_Prepare)) {
|
||||||
log.warning("Order Process Failed: " + m_order + " - " + m_order.getProcessMsg());
|
StringBuilder msglog = new StringBuilder("Order Process Failed: ").append(m_order).append(" - ").append(m_order.getProcessMsg());
|
||||||
throw new IllegalStateException("Order Process Failed: " + m_order + " - " + m_order.getProcessMsg());
|
log.warning(msglog.toString());
|
||||||
|
msglog = new StringBuilder("Order Process Failed: ").append(m_order).append(" - ").append(m_order.getProcessMsg());
|
||||||
|
throw new IllegalStateException(msglog.toString());
|
||||||
}
|
}
|
||||||
if (!m_order.save())
|
if (!m_order.save())
|
||||||
throw new IllegalStateException("Cannot save Order");
|
throw new IllegalStateException("Cannot save Order");
|
||||||
|
|
|
@ -55,11 +55,11 @@ public class FactAcctSummary extends SvrProcess {
|
||||||
@Override
|
@Override
|
||||||
protected String doIt() throws Exception {
|
protected String doIt() throws Exception {
|
||||||
|
|
||||||
String where = "";
|
StringBuilder where = new StringBuilder();
|
||||||
if ( p_Cube_ID > 0)
|
if ( p_Cube_ID > 0)
|
||||||
where = "PA_ReportCube_ID = " + p_Cube_ID;
|
where = new StringBuilder("PA_ReportCube_ID = ").append(p_Cube_ID);
|
||||||
|
|
||||||
List<MReportCube> cubes = new Query(getCtx(), MReportCube.Table_Name, where, get_TrxName())
|
List<MReportCube> cubes = new Query(getCtx(), MReportCube.Table_Name, where.toString(), get_TrxName())
|
||||||
.setOnlyActiveRecords(true).setClient_ID()
|
.setOnlyActiveRecords(true).setClient_ID()
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
|
|
|
@ -88,35 +88,35 @@ public class ImportAccount extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||||
|
|
||||||
// **** Prepare ****
|
// **** Prepare ****
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (m_deleteOldImported)
|
if (m_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_ElementValue "
|
sql = new StringBuilder ("DELETE I_ElementValue ")
|
||||||
+ "WHERE I_IsImported='Y'").append(clientCheck);
|
.append("WHERE I_IsImported='Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IsActive, Created/Updated
|
// Set Client, Org, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID, 0),"
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
|
||||||
+ " IsActive = COALESCE (IsActive, 'Y'),"
|
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " Processed = 'N', "
|
.append(" Processed = 'N', ")
|
||||||
+ " Processing = 'Y', "
|
.append(" Processing = 'Y', ")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Reset=" + no);
|
log.fine("Reset=" + no);
|
||||||
|
|
||||||
|
@ -125,53 +125,53 @@ public class ImportAccount extends SvrProcess
|
||||||
// Set Element
|
// Set Element
|
||||||
if (m_C_Element_ID != 0)
|
if (m_C_Element_ID != 0)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET ElementName=(SELECT Name FROM C_Element WHERE C_Element_ID=").append(m_C_Element_ID).append(") "
|
.append("SET ElementName=(SELECT Name FROM C_Element WHERE C_Element_ID=").append(m_C_Element_ID).append(") ")
|
||||||
+ "WHERE ElementName IS NULL AND C_Element_ID IS NULL"
|
.append("WHERE ElementName IS NULL AND C_Element_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Element Default=" + no);
|
log.fine("Set Element Default=" + no);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue i "
|
sql = new StringBuilder ("UPDATE I_ElementValue i ")
|
||||||
+ "SET C_Element_ID = (SELECT C_Element_ID FROM C_Element e"
|
.append("SET C_Element_ID = (SELECT C_Element_ID FROM C_Element e")
|
||||||
+ " WHERE i.ElementName=e.Name AND i.AD_Client_ID=e.AD_Client_ID)"
|
.append(" WHERE i.ElementName=e.Name AND i.AD_Client_ID=e.AD_Client_ID)")
|
||||||
+ "WHERE C_Element_ID IS NULL"
|
.append("WHERE C_Element_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Element=" + no);
|
log.fine("Set Element=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Element, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Element, ' ")
|
||||||
+ "WHERE C_Element_ID IS NULL"
|
.append("WHERE C_Element_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Element=" + no);
|
log.config("Invalid Element=" + no);
|
||||||
|
|
||||||
// No Name, Value
|
// No Name, Value
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Name, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Name, ' ")
|
||||||
+ "WHERE (Value IS NULL OR Name IS NULL)"
|
.append("WHERE (Value IS NULL OR Name IS NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Name=" + no);
|
log.config("Invalid Name=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Set Column
|
// Set Column
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue i "
|
sql = new StringBuilder ("UPDATE I_ElementValue i ")
|
||||||
+ "SET AD_Column_ID = (SELECT AD_Column_ID FROM AD_Column c"
|
.append("SET AD_Column_ID = (SELECT AD_Column_ID FROM AD_Column c")
|
||||||
+ " WHERE UPPER(i.Default_Account)=UPPER(c.ColumnName)"
|
.append(" WHERE UPPER(i.Default_Account)=UPPER(c.ColumnName)")
|
||||||
+ " AND c.AD_Table_ID IN (315,266) AND AD_Reference_ID=25) "
|
.append(" AND c.AD_Table_ID IN (315,266) AND AD_Reference_ID=25) ")
|
||||||
+ "WHERE Default_Account IS NOT NULL AND AD_Column_ID IS NULL"
|
.append("WHERE Default_Account IS NOT NULL AND AD_Column_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Column=" + no);
|
log.fine("Set Column=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Column, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Column, ' ")
|
||||||
+ "WHERE AD_Column_ID IS NULL AND Default_Account IS NOT NULL"
|
.append("WHERE AD_Column_ID IS NULL AND Default_Account IS NOT NULL")
|
||||||
+ " AND UPPER(Default_Account)<>'DEFAULT_ACCT'" // ignore default account
|
.append(" AND UPPER(Default_Account)<>'DEFAULT_ACCT'") // ignore default account
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Column=" + no);
|
log.config("Invalid Column=" + no);
|
||||||
|
|
||||||
|
@ -179,76 +179,77 @@ public class ImportAccount extends SvrProcess
|
||||||
String[] yColumns = new String[] {"PostActual", "PostBudget", "PostStatistical", "PostEncumbrance"};
|
String[] yColumns = new String[] {"PostActual", "PostBudget", "PostStatistical", "PostEncumbrance"};
|
||||||
for (int i = 0; i < yColumns.length; i++)
|
for (int i = 0; i < yColumns.length; i++)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue SET ")
|
sql = new StringBuilder ("UPDATE I_ElementValue SET ")
|
||||||
.append(yColumns[i]).append("='Y' WHERE ")
|
.append(yColumns[i]).append("='Y' WHERE ")
|
||||||
.append(yColumns[i]).append(" IS NULL OR ")
|
.append(yColumns[i]).append(" IS NULL OR ")
|
||||||
.append(yColumns[i]).append(" NOT IN ('Y','N')"
|
.append(yColumns[i]).append(" NOT IN ('Y','N')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set " + yColumns[i] + " Default=" + no);
|
StringBuilder msglog = new StringBuilder("Set ").append(yColumns[i]).append(" Default=").append(no);
|
||||||
|
log.fine(msglog.toString());
|
||||||
}
|
}
|
||||||
// Summary
|
// Summary
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET IsSummary='N' "
|
.append("SET IsSummary='N' ")
|
||||||
+ "WHERE IsSummary IS NULL OR IsSummary NOT IN ('Y','N')"
|
.append("WHERE IsSummary IS NULL OR IsSummary NOT IN ('Y','N')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsSummary Default=" + no);
|
log.fine("Set IsSummary Default=" + no);
|
||||||
|
|
||||||
// Doc Controlled
|
// Doc Controlled
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET IsDocControlled = CASE WHEN AD_Column_ID IS NOT NULL THEN 'Y' ELSE 'N' END "
|
.append("SET IsDocControlled = CASE WHEN AD_Column_ID IS NOT NULL THEN 'Y' ELSE 'N' END ")
|
||||||
+ "WHERE IsDocControlled IS NULL OR IsDocControlled NOT IN ('Y','N')"
|
.append("WHERE IsDocControlled IS NULL OR IsDocControlled NOT IN ('Y','N')")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsDocumentControlled Default=" + no);
|
log.fine("Set IsDocumentControlled Default=" + no);
|
||||||
|
|
||||||
// Check Account Type A (E) L M O R
|
// Check Account Type A (E) L M O R
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET AccountType='E' "
|
.append("SET AccountType='E' ")
|
||||||
+ "WHERE AccountType IS NULL"
|
.append("WHERE AccountType IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set AccountType Default=" + no);
|
log.fine("Set AccountType Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid AccountType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid AccountType, ' ")
|
||||||
+ "WHERE AccountType NOT IN ('A','E','L','M','O','R')"
|
.append("WHERE AccountType NOT IN ('A','E','L','M','O','R')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid AccountType=" + no);
|
log.config("Invalid AccountType=" + no);
|
||||||
|
|
||||||
// Check Account Sign (N) C B
|
// Check Account Sign (N) C B
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET AccountSign='N' "
|
.append("SET AccountSign='N' ")
|
||||||
+ "WHERE AccountSign IS NULL"
|
.append("WHERE AccountSign IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set AccountSign Default=" + no);
|
log.fine("Set AccountSign Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid AccountSign, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid AccountSign, ' ")
|
||||||
+ "WHERE AccountSign NOT IN ('N','C','D')"
|
.append("WHERE AccountSign NOT IN ('N','C','D')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid AccountSign=" + no);
|
log.config("Invalid AccountSign=" + no);
|
||||||
|
|
||||||
// No Value
|
// No Value
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Key, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Key, ' ")
|
||||||
+ "WHERE (Value IS NULL OR Value='')"
|
.append("WHERE (Value IS NULL OR Value='')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Key=" + no);
|
log.config("Invalid Key=" + no);
|
||||||
|
|
||||||
// **** Update ElementValue from existing
|
// **** Update ElementValue from existing
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue i "
|
sql = new StringBuilder ("UPDATE I_ElementValue i ")
|
||||||
+ "SET C_ElementValue_ID=(SELECT C_ElementValue_ID FROM C_ElementValue ev"
|
.append("SET C_ElementValue_ID=(SELECT C_ElementValue_ID FROM C_ElementValue ev")
|
||||||
+ " INNER JOIN C_Element e ON (ev.C_Element_ID=e.C_Element_ID)"
|
.append(" INNER JOIN C_Element e ON (ev.C_Element_ID=e.C_Element_ID)")
|
||||||
+ " WHERE i.C_Element_ID=e.C_Element_ID AND i.AD_Client_ID=e.AD_Client_ID"
|
.append(" WHERE i.C_Element_ID=e.C_Element_ID AND i.AD_Client_ID=e.AD_Client_ID")
|
||||||
+ " AND i.Value=ev.Value) "
|
.append(" AND i.Value=ev.Value) ")
|
||||||
+ "WHERE C_ElementValue_ID IS NULL"
|
.append("WHERE C_ElementValue_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Found ElementValue=" + no);
|
log.fine("Found ElementValue=" + no);
|
||||||
|
|
||||||
|
@ -259,9 +260,9 @@ public class ImportAccount extends SvrProcess
|
||||||
int noUpdate = 0;
|
int noUpdate = 0;
|
||||||
|
|
||||||
// Go through Records
|
// Go through Records
|
||||||
sql = new StringBuffer ("SELECT * "
|
sql = new StringBuilder ("SELECT * ")
|
||||||
+ "FROM I_ElementValue "
|
.append("FROM I_ElementValue ")
|
||||||
+ "WHERE I_IsImported='N'").append(clientCheck)
|
.append("WHERE I_IsImported='N'").append(clientCheck)
|
||||||
.append(" ORDER BY I_ElementValue_ID");
|
.append(" ORDER BY I_ElementValue_ID");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -286,8 +287,8 @@ public class ImportAccount extends SvrProcess
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue i "
|
sql = new StringBuilder ("UPDATE I_ElementValue i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert ElementValue "))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert ElementValue "))
|
||||||
.append("WHERE I_ElementValue_ID=").append(I_ElementValue_ID);
|
.append("WHERE I_ElementValue_ID=").append(I_ElementValue_ID);
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
}
|
}
|
||||||
|
@ -308,8 +309,8 @@ public class ImportAccount extends SvrProcess
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue i "
|
sql = new StringBuilder ("UPDATE I_ElementValue i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update ElementValue"))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update ElementValue"))
|
||||||
.append("WHERE I_ElementValue_ID=").append(I_ElementValue_ID);
|
.append("WHERE I_ElementValue_ID=").append(I_ElementValue_ID);
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
}
|
}
|
||||||
|
@ -324,9 +325,9 @@ public class ImportAccount extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
addLog (0, null, new BigDecimal (noInsert), "@C_ElementValue_ID@: @Inserted@");
|
addLog (0, null, new BigDecimal (noInsert), "@C_ElementValue_ID@: @Inserted@");
|
||||||
|
@ -335,29 +336,29 @@ public class ImportAccount extends SvrProcess
|
||||||
commitEx();
|
commitEx();
|
||||||
|
|
||||||
// ***** Set Parent
|
// ***** Set Parent
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue i "
|
sql = new StringBuilder ("UPDATE I_ElementValue i ")
|
||||||
+ "SET ParentElementValue_ID=(SELECT C_ElementValue_ID"
|
.append("SET ParentElementValue_ID=(SELECT C_ElementValue_ID")
|
||||||
+ " FROM C_ElementValue ev WHERE i.C_Element_ID=ev.C_Element_ID"
|
.append(" FROM C_ElementValue ev WHERE i.C_Element_ID=ev.C_Element_ID")
|
||||||
+ " AND i.ParentValue=ev.Value AND i.AD_Client_ID=ev.AD_Client_ID) "
|
.append(" AND i.ParentValue=ev.Value AND i.AD_Client_ID=ev.AD_Client_ID) ")
|
||||||
+ "WHERE ParentElementValue_ID IS NULL"
|
.append("WHERE ParentElementValue_ID IS NULL")
|
||||||
+ " AND I_IsImported='Y'").append(clientCheck);
|
.append(" AND I_IsImported='Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Found Parent ElementValue=" + no);
|
log.fine("Found Parent ElementValue=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET I_ErrorMsg=I_ErrorMsg||'Info=ParentNotFound, ' "
|
.append("SET I_ErrorMsg=I_ErrorMsg||'Info=ParentNotFound, ' ")
|
||||||
+ "WHERE ParentElementValue_ID IS NULL AND ParentValue IS NOT NULL"
|
.append("WHERE ParentElementValue_ID IS NULL AND ParentValue IS NOT NULL")
|
||||||
+ " AND I_IsImported='Y' AND Processed='N'").append(clientCheck);
|
.append(" AND I_IsImported='Y' AND Processed='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Not Found Parent ElementValue=" + no);
|
log.config("Not Found Parent ElementValue=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("SELECT i.ParentElementValue_ID, i.I_ElementValue_ID,"
|
sql = new StringBuilder ("SELECT i.ParentElementValue_ID, i.I_ElementValue_ID,")
|
||||||
+ " e.AD_Tree_ID, i.C_ElementValue_ID, i.Value||'-'||i.Name AS Info "
|
.append(" e.AD_Tree_ID, i.C_ElementValue_ID, i.Value||'-'||i.Name AS Info ")
|
||||||
+ "FROM I_ElementValue i"
|
.append("FROM I_ElementValue i")
|
||||||
+ " INNER JOIN C_Element e ON (i.C_Element_ID=e.C_Element_ID) "
|
.append(" INNER JOIN C_Element e ON (i.C_Element_ID=e.C_Element_ID) ")
|
||||||
+ "WHERE i.C_ElementValue_ID IS NOT NULL AND e.AD_Tree_ID IS NOT NULL"
|
.append("WHERE i.C_ElementValue_ID IS NOT NULL AND e.AD_Tree_ID IS NOT NULL")
|
||||||
+ " AND i.ParentElementValue_ID IS NOT NULL"
|
.append(" AND i.ParentElementValue_ID IS NOT NULL")
|
||||||
+ " AND i.I_IsImported='Y' AND Processed='N' AND i.AD_Client_ID=").append(m_AD_Client_ID);
|
.append(" AND i.I_IsImported='Y' AND Processed='N' AND i.AD_Client_ID=").append(m_AD_Client_ID);
|
||||||
int noParentUpdate = 0;
|
int noParentUpdate = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -402,10 +403,10 @@ public class ImportAccount extends SvrProcess
|
||||||
commitEx();
|
commitEx();
|
||||||
|
|
||||||
// Reset Processing Flag
|
// Reset Processing Flag
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET Processing='-'"
|
.append("SET Processing='-'")
|
||||||
+ "WHERE I_IsImported='Y' AND Processed='N' AND Processing='Y'"
|
.append("WHERE I_IsImported='Y' AND Processed='N' AND Processing='Y'")
|
||||||
+ " AND C_ElementValue_ID IS NOT NULL")
|
.append(" AND C_ElementValue_ID IS NOT NULL")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
if (m_updateDefaultAccounts)
|
if (m_updateDefaultAccounts)
|
||||||
sql.append(" AND AD_Column_ID IS NULL");
|
sql.append(" AND AD_Column_ID IS NULL");
|
||||||
|
@ -413,17 +414,17 @@ public class ImportAccount extends SvrProcess
|
||||||
log.fine("Reset Processing Flag=" + no);
|
log.fine("Reset Processing Flag=" + no);
|
||||||
|
|
||||||
if (m_updateDefaultAccounts)
|
if (m_updateDefaultAccounts)
|
||||||
updateDefaults(clientCheck);
|
updateDefaults(clientCheck.toString());
|
||||||
|
|
||||||
// Update Description
|
// Update Description
|
||||||
sql = new StringBuffer("SELECT * FROM C_ValidCombination vc "
|
sql = new StringBuilder("SELECT * FROM C_ValidCombination vc ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM I_ElementValue i "
|
.append("WHERE EXISTS (SELECT * FROM I_ElementValue i ")
|
||||||
+ "WHERE vc.Account_ID=i.C_ElementValue_ID)");
|
.append("WHERE vc.Account_ID=i.C_ElementValue_ID)");
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
sql = new StringBuffer ("UPDATE I_ElementValue "
|
sql = new StringBuilder ("UPDATE I_ElementValue ")
|
||||||
+ "SET Processing='N', Processed='Y'"
|
.append("SET Processing='N', Processed='Y'")
|
||||||
+ "WHERE I_IsImported='Y'")
|
.append("WHERE I_IsImported='Y'")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Processed=" + no);
|
log.fine("Processed=" + no);
|
||||||
|
@ -441,8 +442,8 @@ public class ImportAccount extends SvrProcess
|
||||||
log.config("CreateNewCombination=" + m_createNewCombination);
|
log.config("CreateNewCombination=" + m_createNewCombination);
|
||||||
|
|
||||||
// **** Update Defaults
|
// **** Update Defaults
|
||||||
StringBuffer sql = new StringBuffer ("SELECT C_AcctSchema_ID FROM C_AcctSchema_Element "
|
StringBuilder sql = new StringBuilder ("SELECT C_AcctSchema_ID FROM C_AcctSchema_Element ")
|
||||||
+ "WHERE C_Element_ID=?").append(clientCheck);
|
.append("WHERE C_Element_ID=?").append(clientCheck);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||||
|
@ -459,14 +460,14 @@ public class ImportAccount extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default Account DEFAULT_ACCT
|
// Default Account DEFAULT_ACCT
|
||||||
sql = new StringBuffer ("UPDATE C_AcctSchema_Element e "
|
sql = new StringBuilder ("UPDATE C_AcctSchema_Element e ")
|
||||||
+ "SET C_ElementValue_ID=(SELECT C_ElementValue_ID FROM I_ElementValue i"
|
.append("SET C_ElementValue_ID=(SELECT C_ElementValue_ID FROM I_ElementValue i")
|
||||||
+ " WHERE e.C_Element_ID=i.C_Element_ID AND i.C_ElementValue_ID IS NOT NULL"
|
.append(" WHERE e.C_Element_ID=i.C_Element_ID AND i.C_ElementValue_ID IS NOT NULL")
|
||||||
+ " AND UPPER(i.Default_Account)='DEFAULT_ACCT') "
|
.append(" AND UPPER(i.Default_Account)='DEFAULT_ACCT') ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM I_ElementValue i"
|
.append("WHERE EXISTS (SELECT * FROM I_ElementValue i")
|
||||||
+ " WHERE e.C_Element_ID=i.C_Element_ID AND i.C_ElementValue_ID IS NOT NULL"
|
.append(" WHERE e.C_Element_ID=i.C_Element_ID AND i.C_ElementValue_ID IS NOT NULL")
|
||||||
+ " AND UPPER(i.Default_Account)='DEFAULT_ACCT' "
|
.append(" AND UPPER(i.Default_Account)='DEFAULT_ACCT' ")
|
||||||
+ " AND i.I_IsImported='Y' AND i.Processing='-')")
|
.append(" AND i.I_IsImported='Y' AND i.Processing='-')")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@C_AcctSchema_Element_ID@: @Updated@");
|
addLog (0, null, new BigDecimal (no), "@C_AcctSchema_Element_ID@: @Updated@");
|
||||||
|
@ -484,21 +485,22 @@ public class ImportAccount extends SvrProcess
|
||||||
MAcctSchema as = new MAcctSchema (getCtx(), C_AcctSchema_ID, get_TrxName());
|
MAcctSchema as = new MAcctSchema (getCtx(), C_AcctSchema_ID, get_TrxName());
|
||||||
if (as.getAcctSchemaElement("AC").getC_Element_ID() != m_C_Element_ID)
|
if (as.getAcctSchemaElement("AC").getC_Element_ID() != m_C_Element_ID)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "C_Element_ID=" + m_C_Element_ID + " not in AcctSchema=" + as);
|
StringBuilder msglog = new StringBuilder("C_Element_ID=").append(m_C_Element_ID).append(" not in AcctSchema=").append(as);
|
||||||
|
log.log(Level.SEVERE, msglog.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] counts = new int[] {0, 0, 0};
|
int[] counts = new int[] {0, 0, 0};
|
||||||
|
|
||||||
String sql = "SELECT i.C_ElementValue_ID, t.TableName, c.ColumnName, i.I_ElementValue_ID "
|
StringBuilder sql = new StringBuilder("SELECT i.C_ElementValue_ID, t.TableName, c.ColumnName, i.I_ElementValue_ID ")
|
||||||
+ "FROM I_ElementValue i"
|
.append("FROM I_ElementValue i")
|
||||||
+ " INNER JOIN AD_Column c ON (i.AD_Column_ID=c.AD_Column_ID)"
|
.append(" INNER JOIN AD_Column c ON (i.AD_Column_ID=c.AD_Column_ID)")
|
||||||
+ " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID) "
|
.append(" INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID) ")
|
||||||
+ "WHERE i.I_IsImported='Y' AND Processing='Y'"
|
.append("WHERE i.I_IsImported='Y' AND Processing='Y'")
|
||||||
+ " AND i.C_ElementValue_ID IS NOT NULL AND C_Element_ID=?";
|
.append(" AND i.C_ElementValue_ID IS NOT NULL AND C_Element_ID=?");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||||
pstmt.setInt(1, m_C_Element_ID);
|
pstmt.setInt(1, m_C_Element_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -512,8 +514,8 @@ public class ImportAccount extends SvrProcess
|
||||||
counts[u]++;
|
counts[u]++;
|
||||||
if (u != UPDATE_ERROR)
|
if (u != UPDATE_ERROR)
|
||||||
{
|
{
|
||||||
sql = "UPDATE I_ElementValue SET Processing='N' "
|
sql = new StringBuilder("UPDATE I_ElementValue SET Processing='N' ")
|
||||||
+ "WHERE I_ElementValue_ID=" + I_ElementValue_ID;
|
.append("WHERE I_ElementValue_ID=").append(I_ElementValue_ID);
|
||||||
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 1)
|
if (no != 1)
|
||||||
log.log(Level.SEVERE, "Updated=" + no);
|
log.log(Level.SEVERE, "Updated=" + no);
|
||||||
|
@ -552,9 +554,10 @@ public class ImportAccount extends SvrProcess
|
||||||
*/
|
*/
|
||||||
private int updateDefaultAccount (String TableName, String ColumnName, int C_AcctSchema_ID, int C_ElementValue_ID)
|
private int updateDefaultAccount (String TableName, String ColumnName, int C_AcctSchema_ID, int C_ElementValue_ID)
|
||||||
{
|
{
|
||||||
log.fine(TableName + "." + ColumnName + " - " + C_ElementValue_ID);
|
StringBuilder msglog = new StringBuilder(TableName).append(".").append(ColumnName).append(" - ").append(C_ElementValue_ID);
|
||||||
|
log.fine(msglog.toString());
|
||||||
int retValue = UPDATE_ERROR;
|
int retValue = UPDATE_ERROR;
|
||||||
StringBuffer sql = new StringBuffer ("SELECT x.")
|
StringBuilder sql = new StringBuilder ("SELECT x.")
|
||||||
.append(ColumnName).append(",Account_ID FROM ")
|
.append(ColumnName).append(",Account_ID FROM ")
|
||||||
.append(TableName).append(" x INNER JOIN C_ValidCombination vc ON (x.")
|
.append(TableName).append(" x INNER JOIN C_ValidCombination vc ON (x.")
|
||||||
.append(ColumnName).append("=vc.C_ValidCombination_ID) ")
|
.append(ColumnName).append("=vc.C_ValidCombination_ID) ")
|
||||||
|
@ -586,13 +589,14 @@ public class ImportAccount extends SvrProcess
|
||||||
int newC_ValidCombination_ID = acct.getC_ValidCombination_ID();
|
int newC_ValidCombination_ID = acct.getC_ValidCombination_ID();
|
||||||
if (C_ValidCombination_ID != newC_ValidCombination_ID)
|
if (C_ValidCombination_ID != newC_ValidCombination_ID)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE ").append(TableName)
|
sql = new StringBuilder ("UPDATE ").append(TableName)
|
||||||
.append(" SET ").append(ColumnName).append("=").append(newC_ValidCombination_ID)
|
.append(" SET ").append(ColumnName).append("=").append(newC_ValidCombination_ID)
|
||||||
.append(" WHERE C_AcctSchema_ID=").append(C_AcctSchema_ID);
|
.append(" WHERE C_AcctSchema_ID=").append(C_AcctSchema_ID);
|
||||||
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("New #" + no + " - "
|
msglog = new StringBuilder("New #").append(no).append(" - ")
|
||||||
+ TableName + "." + ColumnName + " - " + C_ElementValue_ID
|
.append(TableName).append(".").append(ColumnName).append(" - ").append(C_ElementValue_ID)
|
||||||
+ " -- " + C_ValidCombination_ID + " -> " + newC_ValidCombination_ID);
|
.append(" -- ").append(C_ValidCombination_ID).append(" -> ").append(newC_ValidCombination_ID);
|
||||||
|
log.fine(msglog.toString());
|
||||||
if (no == 1)
|
if (no == 1)
|
||||||
retValue = UPDATE_YES;
|
retValue = UPDATE_YES;
|
||||||
}
|
}
|
||||||
|
@ -603,25 +607,28 @@ public class ImportAccount extends SvrProcess
|
||||||
else // Replace Combination
|
else // Replace Combination
|
||||||
{
|
{
|
||||||
// Only Acct Combination directly
|
// Only Acct Combination directly
|
||||||
sql = new StringBuffer ("UPDATE C_ValidCombination SET Account_ID=")
|
sql = new StringBuilder ("UPDATE C_ValidCombination SET Account_ID=")
|
||||||
.append(C_ElementValue_ID).append(" WHERE C_ValidCombination_ID=").append(C_ValidCombination_ID);
|
.append(C_ElementValue_ID).append(" WHERE C_ValidCombination_ID=").append(C_ValidCombination_ID);
|
||||||
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Replace #" + no + " - "
|
msglog = new StringBuilder("Replace #").append(no).append(" - ")
|
||||||
+ "C_ValidCombination_ID=" + C_ValidCombination_ID + ", New Account_ID=" + C_ElementValue_ID);
|
.append("C_ValidCombination_ID=").append(C_ValidCombination_ID).append(", New Account_ID=").append(C_ElementValue_ID);
|
||||||
|
log.fine(msglog.toString());
|
||||||
if (no == 1)
|
if (no == 1)
|
||||||
{
|
{
|
||||||
retValue = UPDATE_YES;
|
retValue = UPDATE_YES;
|
||||||
// Where Acct was used
|
// Where Acct was used
|
||||||
sql = new StringBuffer ("UPDATE C_ValidCombination SET Account_ID=")
|
sql = new StringBuilder ("UPDATE C_ValidCombination SET Account_ID=")
|
||||||
.append(C_ElementValue_ID).append(" WHERE Account_ID=").append(Account_ID);
|
.append(C_ElementValue_ID).append(" WHERE Account_ID=").append(Account_ID);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("ImportAccount.updateDefaultAccount - Replace VC #" + no + " - "
|
msglog = new StringBuilder("ImportAccount.updateDefaultAccount - Replace VC #").append(no).append(" - ")
|
||||||
+ "Account_ID=" + Account_ID + ", New Account_ID=" + C_ElementValue_ID);
|
.append("Account_ID=").append(Account_ID).append(", New Account_ID=").append(C_ElementValue_ID);
|
||||||
sql = new StringBuffer ("UPDATE Fact_Acct SET Account_ID=")
|
log.fine(msglog.toString());
|
||||||
|
sql = new StringBuilder ("UPDATE Fact_Acct SET Account_ID=")
|
||||||
.append(C_ElementValue_ID).append(" WHERE Account_ID=").append(Account_ID);
|
.append(C_ElementValue_ID).append(" WHERE Account_ID=").append(Account_ID);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("ImportAccount.updateDefaultAccount - Replace Fact #" + no + " - "
|
msglog = new StringBuilder("ImportAccount.updateDefaultAccount - Replace Fact #").append(no).append(" - ")
|
||||||
+ "Account_ID=" + Account_ID + ", New Account_ID=" + C_ElementValue_ID);
|
.append("Account_ID=").append(Account_ID).append(", New Account_ID=").append(C_ElementValue_ID);
|
||||||
|
log.fine(msglog.toString());
|
||||||
}
|
}
|
||||||
} // replace combination
|
} // replace combination
|
||||||
} // need to update
|
} // need to update
|
||||||
|
|
|
@ -91,7 +91,7 @@ implements ImportProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = getWhereClause();
|
String clientCheck = getWhereClause();
|
||||||
|
|
||||||
|
@ -100,50 +100,50 @@ implements ImportProcess
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (m_deleteOldImported)
|
if (m_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_BPartner "
|
sql = new StringBuilder ("DELETE I_BPartner ")
|
||||||
+ "WHERE I_IsImported='Y'").append(clientCheck);
|
.append("WHERE I_IsImported='Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IsActive, Created/Updated
|
// Set Client, Org, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner "
|
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID, 0),"
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
|
||||||
+ " IsActive = COALESCE (IsActive, 'Y'),"
|
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Reset=" + no);
|
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
|
// Set BP_Group
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET GroupValue=(SELECT MAX(Value) FROM C_BP_Group g WHERE g.IsDefault='Y'"
|
.append("SET GroupValue=(SELECT MAX(Value) FROM C_BP_Group g WHERE g.IsDefault='Y'")
|
||||||
+ " AND g.AD_Client_ID=i.AD_Client_ID) ");
|
.append(" AND g.AD_Client_ID=i.AD_Client_ID) ");
|
||||||
sql.append("WHERE GroupValue IS NULL AND C_BP_Group_ID IS NULL"
|
sql.append("WHERE GroupValue IS NULL AND C_BP_Group_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Group Default=" + no);
|
log.fine("Set Group Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET C_BP_Group_ID=(SELECT C_BP_Group_ID FROM C_BP_Group g"
|
.append("SET C_BP_Group_ID=(SELECT C_BP_Group_ID FROM C_BP_Group g")
|
||||||
+ " WHERE i.GroupValue=g.Value AND g.AD_Client_ID=i.AD_Client_ID) "
|
.append(" WHERE i.GroupValue=g.Value AND g.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE C_BP_Group_ID IS NULL"
|
.append("WHERE C_BP_Group_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Group=" + no);
|
log.fine("Set Group=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner "
|
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Group, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Group, ' ")
|
||||||
+ "WHERE C_BP_Group_ID IS NULL"
|
.append("WHERE C_BP_Group_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Group=" + no);
|
log.config("Invalid Group=" + no);
|
||||||
|
|
||||||
|
@ -158,123 +158,123 @@ implements ImportProcess
|
||||||
log.fine("Set Country Default=" + no);
|
log.fine("Set Country Default=" + no);
|
||||||
**/
|
**/
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c"
|
.append("SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c")
|
||||||
+ " WHERE i.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, i.AD_Client_ID)) "
|
.append(" WHERE i.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_Country_ID IS NULL"
|
.append("WHERE C_Country_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Country=" + no);
|
log.fine("Set Country=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner "
|
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' ")
|
||||||
+ "WHERE C_Country_ID IS NULL AND (City IS NOT NULL OR Address1 IS NOT NULL)"
|
.append("WHERE C_Country_ID IS NULL AND (City IS NOT NULL OR Address1 IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Country=" + no);
|
log.config("Invalid Country=" + no);
|
||||||
|
|
||||||
// Set Region
|
// Set Region
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "Set RegionName=(SELECT MAX(Name) FROM C_Region r"
|
.append("Set RegionName=(SELECT MAX(Name) FROM C_Region r")
|
||||||
+ " WHERE r.IsDefault='Y' AND r.C_Country_ID=i.C_Country_ID"
|
.append(" WHERE r.IsDefault='Y' AND r.C_Country_ID=i.C_Country_ID")
|
||||||
+ " AND r.AD_Client_ID IN (0, i.AD_Client_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"
|
sql.append("WHERE RegionName IS NULL AND C_Region_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Region Default=" + no);
|
log.fine("Set Region Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r"
|
.append("Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r")
|
||||||
+ " WHERE r.Name=i.RegionName AND r.C_Country_ID=i.C_Country_ID"
|
.append(" WHERE r.Name=i.RegionName AND r.C_Country_ID=i.C_Country_ID")
|
||||||
+ " AND r.AD_Client_ID IN (0, i.AD_Client_ID)) "
|
.append(" AND r.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_Region_ID IS NULL"
|
.append("WHERE C_Region_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Region=" + no);
|
log.fine("Set Region=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' ")
|
||||||
+ "WHERE C_Region_ID IS NULL "
|
.append("WHERE C_Region_ID IS NULL ")
|
||||||
+ " AND EXISTS (SELECT * FROM C_Country c"
|
.append(" AND EXISTS (SELECT * FROM C_Country c")
|
||||||
+ " WHERE c.C_Country_ID=i.C_Country_ID AND c.HasRegion='Y')"
|
.append(" WHERE c.C_Country_ID=i.C_Country_ID AND c.HasRegion='Y')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Region=" + no);
|
log.config("Invalid Region=" + no);
|
||||||
|
|
||||||
// Set Greeting
|
// Set Greeting
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET C_Greeting_ID=(SELECT C_Greeting_ID FROM C_Greeting g"
|
.append("SET C_Greeting_ID=(SELECT C_Greeting_ID FROM C_Greeting g")
|
||||||
+ " WHERE i.BPContactGreeting=g.Name AND g.AD_Client_ID IN (0, i.AD_Client_ID)) "
|
.append(" WHERE i.BPContactGreeting=g.Name AND g.AD_Client_ID IN (0, i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL"
|
.append("WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Greeting=" + no);
|
log.fine("Set Greeting=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Greeting, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Greeting, ' ")
|
||||||
+ "WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL"
|
.append("WHERE C_Greeting_ID IS NULL AND BPContactGreeting IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid Greeting=" + no);
|
log.config("Invalid Greeting=" + no);
|
||||||
|
|
||||||
// Existing User ?
|
// Existing User ?
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET (C_BPartner_ID,AD_User_ID)="
|
.append("SET (C_BPartner_ID,AD_User_ID)=")
|
||||||
+ "(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u "
|
.append("(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u ")
|
||||||
+ "WHERE i.EMail=u.EMail AND u.AD_Client_ID=i.AD_Client_ID) "
|
.append("WHERE i.EMail=u.EMail AND u.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE i.EMail IS NOT NULL AND I_IsImported='N'").append(clientCheck);
|
.append("WHERE i.EMail IS NOT NULL AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Found EMail User=" + no);
|
log.fine("Found EMail User=" + no);
|
||||||
|
|
||||||
// Existing BPartner ? Match Value
|
// Existing BPartner ? Match Value
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p"
|
.append("SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p")
|
||||||
+ " WHERE i.Value=p.Value AND p.AD_Client_ID=i.AD_Client_ID) "
|
.append(" WHERE i.Value=p.Value AND p.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND Value IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND Value IS NOT NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Found BPartner=" + no);
|
log.fine("Found BPartner=" + no);
|
||||||
|
|
||||||
// Existing Contact ? Match Name
|
// Existing Contact ? Match Name
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET AD_User_ID=(SELECT AD_User_ID FROM AD_User c"
|
.append("SET AD_User_ID=(SELECT AD_User_ID FROM AD_User c")
|
||||||
+ " 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 i.ContactName=c.Name AND i.C_BPartner_ID=c.C_BPartner_ID AND c.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND AD_User_ID IS NULL AND ContactName IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND AD_User_ID IS NULL AND ContactName IS NOT NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Found Contact=" + no);
|
log.fine("Found Contact=" + no);
|
||||||
|
|
||||||
// Existing Location ? Exact Match
|
// Existing Location ? Exact Match
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID"
|
.append("SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID")
|
||||||
+ " FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)"
|
.append(" FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)")
|
||||||
+ " WHERE i.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=i.AD_Client_ID"
|
.append(" WHERE i.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=i.AD_Client_ID")
|
||||||
+ " AND (i.Address1=l.Address1 OR (i.Address1 IS NULL AND l.Address1 IS NULL))"
|
.append(" AND (i.Address1=l.Address1 OR (i.Address1 IS NULL AND l.Address1 IS NULL))")
|
||||||
+ " AND (i.Address2=l.Address2 OR (i.Address2 IS NULL AND l.Address2 IS NULL))"
|
.append(" AND (i.Address2=l.Address2 OR (i.Address2 IS NULL AND l.Address2 IS NULL))")
|
||||||
+ " AND (i.City=l.City OR (i.City IS NULL AND l.City IS NULL))"
|
.append(" AND (i.City=l.City OR (i.City IS NULL AND l.City IS NULL))")
|
||||||
+ " AND (i.Postal=l.Postal OR (i.Postal IS NULL AND l.Postal IS NULL))"
|
.append(" AND (i.Postal=l.Postal OR (i.Postal IS NULL AND l.Postal IS NULL))")
|
||||||
+ " AND (i.Postal_Add=l.Postal_Add OR (l.Postal_Add IS NULL AND l.Postal_Add IS NULL))"
|
.append(" AND (i.Postal_Add=l.Postal_Add OR (l.Postal_Add IS NULL AND l.Postal_Add IS NULL))")
|
||||||
+ " 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_Region_ID=l.C_Region_ID OR (l.C_Region_ID IS NULL AND i.C_Region_ID IS NULL))")
|
||||||
+ " AND i.C_Country_ID=l.C_Country_ID) "
|
.append(" AND i.C_Country_ID=l.C_Country_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Found Location=" + no);
|
log.fine("Found Location=" + no);
|
||||||
|
|
||||||
// Interest Area
|
// Interest Area
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET R_InterestArea_ID=(SELECT R_InterestArea_ID FROM R_InterestArea ia "
|
.append("SET R_InterestArea_ID=(SELECT R_InterestArea_ID FROM R_InterestArea ia ")
|
||||||
+ "WHERE i.InterestAreaName=ia.Name AND ia.AD_Client_ID=i.AD_Client_ID) "
|
.append("WHERE i.InterestAreaName=ia.Name AND ia.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE R_InterestArea_ID IS NULL AND InterestAreaName IS NOT NULL"
|
.append("WHERE R_InterestArea_ID IS NULL AND InterestAreaName IS NOT NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Interest Area=" + no);
|
log.fine("Set Interest Area=" + no);
|
||||||
|
|
||||||
// Value is mandatory error
|
// Value is mandatory error
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner "
|
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Value is mandatory, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Value is mandatory, ' ")
|
||||||
+ "WHERE Value IS NULL "
|
.append("WHERE Value IS NULL ")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
log.config("Value is mandatory=" + no);
|
log.config("Value is mandatory=" + no);
|
||||||
|
|
||||||
|
@ -290,8 +290,8 @@ implements ImportProcess
|
||||||
int noUpdate = 0;
|
int noUpdate = 0;
|
||||||
|
|
||||||
// Go through Records
|
// Go through Records
|
||||||
sql = new StringBuffer ("SELECT * FROM I_BPartner "
|
sql = new StringBuilder ("SELECT * FROM I_BPartner ")
|
||||||
+ "WHERE I_IsImported='N'").append(clientCheck);
|
.append("WHERE I_IsImported='N'").append(clientCheck);
|
||||||
// gody: 20070113 - Order so the same values are consecutive.
|
// gody: 20070113 - Order so the same values are consecutive.
|
||||||
sql.append(" ORDER BY Value, I_BPartner_ID");
|
sql.append(" ORDER BY Value, I_BPartner_ID");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
@ -313,11 +313,12 @@ implements ImportProcess
|
||||||
// Remember Value - only first occurance of the value is BP
|
// Remember Value - only first occurance of the value is BP
|
||||||
String New_BPValue = rs.getString("Value") ;
|
String New_BPValue = rs.getString("Value") ;
|
||||||
|
|
||||||
X_I_BPartner impBP = new X_I_BPartner (getCtx(), rs, get_TrxName());
|
X_I_BPartner impBP = new X_I_BPartner (getCtx(), rs, get_TrxName());
|
||||||
log.fine("I_BPartner_ID=" + impBP.getI_BPartner_ID()
|
StringBuilder msglog = new StringBuilder("I_BPartner_ID=") .append(impBP.getI_BPartner_ID())
|
||||||
+ ", C_BPartner_ID=" + impBP.getC_BPartner_ID()
|
.append(", C_BPartner_ID=").append(impBP.getC_BPartner_ID())
|
||||||
+ ", C_BPartner_Location_ID=" + impBP.getC_BPartner_Location_ID()
|
.append(", C_BPartner_Location_ID=").append(impBP.getC_BPartner_Location_ID())
|
||||||
+ ", AD_User_ID=" + impBP.getAD_User_ID());
|
.append(", AD_User_ID=").append(impBP.getAD_User_ID());
|
||||||
|
log.fine(msglog.toString());
|
||||||
|
|
||||||
|
|
||||||
if ( ! New_BPValue.equals(Old_BPValue)) {
|
if ( ! New_BPValue.equals(Old_BPValue)) {
|
||||||
|
@ -333,14 +334,15 @@ implements ImportProcess
|
||||||
|
|
||||||
if (bp.save())
|
if (bp.save())
|
||||||
{
|
{
|
||||||
impBP.setC_BPartner_ID(bp.getC_BPartner_ID());
|
impBP.setC_BPartner_ID(bp.getC_BPartner_ID());
|
||||||
log.finest("Insert BPartner - " + bp.getC_BPartner_ID());
|
msglog = new StringBuilder("Insert BPartner - ").append(bp.getC_BPartner_ID());
|
||||||
|
log.finest(msglog.toString());
|
||||||
noInsert++;
|
noInsert++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert BPartner, ' ")
|
.append("'Cannot Insert BPartner, ' ")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
|
@ -374,13 +376,14 @@ implements ImportProcess
|
||||||
//
|
//
|
||||||
if (bp.save())
|
if (bp.save())
|
||||||
{
|
{
|
||||||
log.finest("Update BPartner - " + bp.getC_BPartner_ID());
|
msglog = new StringBuilder("Update BPartner - ").append(bp.getC_BPartner_ID());
|
||||||
|
log.finest(msglog.toString());
|
||||||
noUpdate++;
|
noUpdate++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Update BPartner, ' ")
|
.append("'Cannot Update BPartner, ' ")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
|
@ -425,14 +428,16 @@ implements ImportProcess
|
||||||
location.setAddress2(impBP.getAddress2());
|
location.setAddress2(impBP.getAddress2());
|
||||||
location.setPostal(impBP.getPostal());
|
location.setPostal(impBP.getPostal());
|
||||||
location.setPostal_Add(impBP.getPostal_Add());
|
location.setPostal_Add(impBP.getPostal_Add());
|
||||||
if (location.save())
|
if (location.save()){
|
||||||
log.finest("Insert Location - " + location.getC_Location_ID());
|
msglog = new StringBuilder("Insert Location - ").append(location.getC_Location_ID());
|
||||||
|
log.finest(msglog.toString());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rollback();
|
rollback();
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert Location, ' ")
|
.append("'Cannot Insert Location, ' ")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
|
@ -447,15 +452,16 @@ implements ImportProcess
|
||||||
ModelValidationEngine.get().fireImportValidate(this, impBP, bpl, ImportValidator.TIMING_AFTER_IMPORT);
|
ModelValidationEngine.get().fireImportValidate(this, impBP, bpl, ImportValidator.TIMING_AFTER_IMPORT);
|
||||||
if (bpl.save())
|
if (bpl.save())
|
||||||
{
|
{
|
||||||
log.finest("Insert BP Location - " + bpl.getC_BPartner_Location_ID());
|
msglog = new StringBuilder("Insert BP Location - ").append(bpl.getC_BPartner_Location_ID());
|
||||||
|
log.finest(msglog.toString());
|
||||||
impBP.setC_BPartner_Location_ID(bpl.getC_BPartner_Location_ID());
|
impBP.setC_BPartner_Location_ID(bpl.getC_BPartner_Location_ID());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rollback();
|
rollback();
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert BPLocation, ' ")
|
.append("'Cannot Insert BPLocation, ' ")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
|
@ -477,8 +483,8 @@ implements ImportProcess
|
||||||
{
|
{
|
||||||
rollback();
|
rollback();
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'BP of User <> BP, ' ")
|
.append("'BP of User <> BP, ' ")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
|
@ -511,14 +517,15 @@ implements ImportProcess
|
||||||
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
||||||
if (user.save())
|
if (user.save())
|
||||||
{
|
{
|
||||||
log.finest("Update BP Contact - " + user.getAD_User_ID());
|
msglog = new StringBuilder("Update BP Contact - ").append(user.getAD_User_ID());
|
||||||
|
log.finest(msglog.toString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rollback();
|
rollback();
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Update BP Contact, ' ")
|
.append("'Cannot Update BP Contact, ' ")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
|
@ -548,15 +555,16 @@ implements ImportProcess
|
||||||
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
ModelValidationEngine.get().fireImportValidate(this, impBP, user, ImportValidator.TIMING_AFTER_IMPORT);
|
||||||
if (user.save())
|
if (user.save())
|
||||||
{
|
{
|
||||||
log.finest("Insert BP Contact - " + user.getAD_User_ID());
|
msglog = new StringBuilder("Insert BP Contact - ").append(user.getAD_User_ID());
|
||||||
|
log.finest(msglog.toString());
|
||||||
impBP.setAD_User_ID(user.getAD_User_ID());
|
impBP.setAD_User_ID(user.getAD_User_ID());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rollback();
|
rollback();
|
||||||
noInsert--;
|
noInsert--;
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner i "
|
sql = new StringBuilder ("UPDATE I_BPartner i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||")
|
||||||
.append("'Cannot Insert BPContact, ' ")
|
.append("'Cannot Insert BPContact, ' ")
|
||||||
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
.append("WHERE I_BPartner_ID=").append(impBP.getI_BPartner_ID());
|
||||||
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
|
@ -592,9 +600,9 @@ implements ImportProcess
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
rs = null; pstmt = null;
|
rs = null; pstmt = null;
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_BPartner "
|
sql = new StringBuilder ("UPDATE I_BPartner ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
no = DB.executeUpdateEx(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
addLog (0, null, new BigDecimal (noInsert), "@C_BPartner_ID@: @Inserted@");
|
addLog (0, null, new BigDecimal (noInsert), "@C_BPartner_ID@: @Inserted@");
|
||||||
|
@ -607,7 +615,8 @@ implements ImportProcess
|
||||||
//@Override
|
//@Override
|
||||||
public String getWhereClause()
|
public String getWhereClause()
|
||||||
{
|
{
|
||||||
return " AND AD_Client_ID=" + m_AD_Client_ID;
|
StringBuilder msgreturn = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||||
|
return msgreturn.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,249 +82,250 @@ public class ImportBankStatement extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
log.info("AD_Org_ID=" + p_AD_Org_ID + ", C_BankAccount_ID" + p_C_BankAccount_ID);
|
StringBuilder msglog = new StringBuilder("AD_Org_ID=").append(p_AD_Org_ID).append(", C_BankAccount_ID").append(p_C_BankAccount_ID);
|
||||||
StringBuffer sql = null;
|
log.info(msglog.toString());
|
||||||
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + p_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(p_AD_Client_ID);
|
||||||
|
|
||||||
// **** Prepare ****
|
// **** Prepare ****
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (p_deleteOldImported)
|
if (p_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_BankStatement "
|
sql = new StringBuilder ("DELETE I_BankStatement ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IsActive, Created/Updated
|
// Set Client, Org, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_BankStatement "
|
sql = new StringBuilder ("UPDATE I_BankStatement ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append ("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append ("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID,").append (p_AD_Org_ID).append ("),");
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID,").append (p_AD_Org_ID).append ("),");
|
||||||
sql.append(" IsActive = COALESCE (IsActive, 'Y'),"
|
sql.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL OR AD_Client_ID IS NULL OR AD_Org_ID IS NULL OR AD_Client_ID=0 OR AD_Org_ID=0");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL OR AD_Client_ID IS NULL OR AD_Org_ID IS NULL OR AD_Client_ID=0 OR AD_Org_ID=0");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info ("Reset=" + no);
|
log.info ("Reset=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_BankStatement o "
|
sql = new StringBuilder ("UPDATE I_BankStatement o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Org=" + no);
|
log.warning ("Invalid Org=" + no);
|
||||||
|
|
||||||
// Set Bank Account
|
// Set Bank Account
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement i "
|
sql = new StringBuilder("UPDATE I_BankStatement i ")
|
||||||
+ "SET C_BankAccount_ID="
|
.append("SET C_BankAccount_ID=")
|
||||||
+ "( "
|
.append("( ")
|
||||||
+ " SELECT C_BankAccount_ID "
|
.append(" SELECT C_BankAccount_ID ")
|
||||||
+ " FROM C_BankAccount a, C_Bank b "
|
.append(" FROM C_BankAccount a, C_Bank b ")
|
||||||
+ " WHERE b.IsOwnBank='Y' "
|
.append(" WHERE b.IsOwnBank='Y' ")
|
||||||
+ " AND a.AD_Client_ID=i.AD_Client_ID "
|
.append(" AND a.AD_Client_ID=i.AD_Client_ID ")
|
||||||
+ " AND a.C_Bank_ID=b.C_Bank_ID "
|
.append(" AND a.C_Bank_ID=b.C_Bank_ID ")
|
||||||
+ " AND a.AccountNo=i.BankAccountNo "
|
.append(" AND a.AccountNo=i.BankAccountNo ")
|
||||||
+ " AND b.RoutingNo=i.RoutingNo "
|
.append(" AND b.RoutingNo=i.RoutingNo ")
|
||||||
+ " OR b.SwiftCode=i.RoutingNo "
|
.append(" OR b.SwiftCode=i.RoutingNo ")
|
||||||
+ ") "
|
.append(") ")
|
||||||
+ "WHERE i.C_BankAccount_ID IS NULL "
|
.append("WHERE i.C_BankAccount_ID IS NULL ")
|
||||||
+ "AND i.I_IsImported<>'Y' "
|
.append("AND i.I_IsImported<>'Y' ")
|
||||||
+ "OR i.I_IsImported IS NULL").append(clientCheck);
|
.append("OR i.I_IsImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Bank Account (With Routing No)=" + no);
|
log.info("Bank Account (With Routing No)=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement i "
|
sql = new StringBuilder("UPDATE I_BankStatement i ")
|
||||||
+ "SET C_BankAccount_ID="
|
.append("SET C_BankAccount_ID=")
|
||||||
+ "( "
|
.append("( ")
|
||||||
+ " SELECT C_BankAccount_ID "
|
.append(" SELECT C_BankAccount_ID ")
|
||||||
+ " FROM C_BankAccount a, C_Bank b "
|
.append(" FROM C_BankAccount a, C_Bank b ")
|
||||||
+ " WHERE b.IsOwnBank='Y' "
|
.append(" WHERE b.IsOwnBank='Y' ")
|
||||||
+ " AND a.C_Bank_ID=b.C_Bank_ID "
|
.append(" AND a.C_Bank_ID=b.C_Bank_ID ")
|
||||||
+ " AND a.AccountNo=i.BankAccountNo "
|
.append(" AND a.AccountNo=i.BankAccountNo ")
|
||||||
+ " AND a.AD_Client_ID=i.AD_Client_ID "
|
.append(" AND a.AD_Client_ID=i.AD_Client_ID ")
|
||||||
+ ") "
|
.append(") ")
|
||||||
+ "WHERE i.C_BankAccount_ID IS NULL "
|
.append("WHERE i.C_BankAccount_ID IS NULL ")
|
||||||
+ "AND i.I_isImported<>'Y' "
|
.append("AND i.I_isImported<>'Y' ")
|
||||||
+ "OR i.I_isImported IS NULL").append(clientCheck);
|
.append("OR i.I_isImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Bank Account (Without Routing No)=" + no);
|
log.info("Bank Account (Without Routing No)=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement i "
|
sql = new StringBuilder("UPDATE I_BankStatement i ")
|
||||||
+ "SET C_BankAccount_ID=(SELECT C_BankAccount_ID FROM C_BankAccount a WHERE a.C_BankAccount_ID=").append(p_C_BankAccount_ID);
|
.append("SET C_BankAccount_ID=(SELECT C_BankAccount_ID FROM C_BankAccount a WHERE a.C_BankAccount_ID=").append(p_C_BankAccount_ID)
|
||||||
sql.append(" and a.AD_Client_ID=i.AD_Client_ID) "
|
.append(" and a.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE i.C_BankAccount_ID IS NULL "
|
.append("WHERE i.C_BankAccount_ID IS NULL ")
|
||||||
+ "AND i.BankAccountNo IS NULL "
|
.append("AND i.BankAccountNo IS NULL ")
|
||||||
+ "AND i.I_isImported<>'Y' "
|
.append("AND i.I_isImported<>'Y' ")
|
||||||
+ "OR i.I_isImported IS NULL").append(clientCheck);
|
.append("OR i.I_isImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Bank Account=" + no);
|
log.info("Bank Account=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET I_isImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Bank Account, ' "
|
.append("SET I_isImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Bank Account, ' ")
|
||||||
+ "WHERE C_BankAccount_ID IS NULL "
|
.append("WHERE C_BankAccount_ID IS NULL ")
|
||||||
+ "AND I_isImported<>'Y' "
|
.append("AND I_isImported<>'Y' ")
|
||||||
+ "OR I_isImported IS NULL").append(clientCheck);
|
.append("OR I_isImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid Bank Account=" + no);
|
log.warning("Invalid Bank Account=" + no);
|
||||||
|
|
||||||
// Set Currency
|
// Set Currency
|
||||||
sql = new StringBuffer ("UPDATE I_BankStatement i "
|
sql = new StringBuilder ("UPDATE I_BankStatement i ")
|
||||||
+ "SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c"
|
.append("SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c")
|
||||||
+ " WHERE i.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) "
|
.append(" WHERE i.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_Currency_ID IS NULL"
|
.append("WHERE C_Currency_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Set Currency=" + no);
|
log.info("Set Currency=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement i "
|
sql = new StringBuilder("UPDATE I_BankStatement i ")
|
||||||
+ "SET C_Currency_ID=(SELECT C_Currency_ID FROM C_BankAccount WHERE C_BankAccount_ID=i.C_BankAccount_ID) "
|
.append("SET C_Currency_ID=(SELECT C_Currency_ID FROM C_BankAccount WHERE C_BankAccount_ID=i.C_BankAccount_ID) ")
|
||||||
+ "WHERE i.C_Currency_ID IS NULL "
|
.append("WHERE i.C_Currency_ID IS NULL ")
|
||||||
+ "AND i.ISO_Code IS NULL").append(clientCheck);
|
.append("AND i.ISO_Code IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Set Currency=" + no);
|
log.info("Set Currency=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_BankStatement "
|
sql = new StringBuilder ("UPDATE I_BankStatement ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency,' ")
|
||||||
+ "WHERE C_Currency_ID IS NULL "
|
.append("WHERE C_Currency_ID IS NULL ")
|
||||||
+ "AND I_IsImported<>'E' "
|
.append("AND I_IsImported<>'E' ")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid Currency=" + no);
|
log.warning("Invalid Currency=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Set Amount
|
// Set Amount
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET ChargeAmt=0 "
|
.append("SET ChargeAmt=0 ")
|
||||||
+ "WHERE ChargeAmt IS NULL "
|
.append("WHERE ChargeAmt IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Charge Amount=" + no);
|
log.info("Charge Amount=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET InterestAmt=0 "
|
.append("SET InterestAmt=0 ")
|
||||||
+ "WHERE InterestAmt IS NULL "
|
.append("WHERE InterestAmt IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Interest Amount=" + no);
|
log.info("Interest Amount=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET TrxAmt=StmtAmt - InterestAmt - ChargeAmt "
|
.append("SET TrxAmt=StmtAmt - InterestAmt - ChargeAmt ")
|
||||||
+ "WHERE TrxAmt IS NULL "
|
.append("WHERE TrxAmt IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Transaction Amount=" + no);
|
log.info("Transaction Amount=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET I_isImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Amount, ' "
|
.append("SET I_isImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Amount, ' ")
|
||||||
+ "WHERE TrxAmt + ChargeAmt + InterestAmt <> StmtAmt "
|
.append("WHERE TrxAmt + ChargeAmt + InterestAmt <> StmtAmt ")
|
||||||
+ "AND I_isImported<>'Y'").append(clientCheck);
|
.append("AND I_isImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Invaid Amount=" + no);
|
log.info("Invaid Amount=" + no);
|
||||||
|
|
||||||
// Set Valuta Date
|
// Set Valuta Date
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET ValutaDate=StatementLineDate "
|
.append("SET ValutaDate=StatementLineDate ")
|
||||||
+ "WHERE ValutaDate IS NULL "
|
.append("WHERE ValutaDate IS NULL ")
|
||||||
+ "AND I_isImported<>'Y'").append(clientCheck);
|
.append("AND I_isImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Valuta Date=" + no);
|
log.info("Valuta Date=" + no);
|
||||||
|
|
||||||
// Check Payment<->Invoice combination
|
// Check Payment<->Invoice combination
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->Invoice, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->Invoice, ' ")
|
||||||
+ "WHERE I_BankStatement_ID IN "
|
.append("WHERE I_BankStatement_ID IN ")
|
||||||
+ "(SELECT I_BankStatement_ID "
|
.append("(SELECT I_BankStatement_ID ")
|
||||||
+ "FROM I_BankStatement i"
|
.append("FROM I_BankStatement i")
|
||||||
+ " INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) "
|
.append(" INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) ")
|
||||||
+ "WHERE i.C_Invoice_ID IS NOT NULL "
|
.append("WHERE i.C_Invoice_ID IS NOT NULL ")
|
||||||
+ " AND p.C_Invoice_ID IS NOT NULL "
|
.append(" AND p.C_Invoice_ID IS NOT NULL ")
|
||||||
+ " AND p.C_Invoice_ID<>i.C_Invoice_ID) ")
|
.append(" AND p.C_Invoice_ID<>i.C_Invoice_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Payment<->Invoice Mismatch=" + no);
|
log.info("Payment<->Invoice Mismatch=" + no);
|
||||||
|
|
||||||
// Check Payment<->BPartner combination
|
// Check Payment<->BPartner combination
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->BPartner, ' ")
|
||||||
+ "WHERE I_BankStatement_ID IN "
|
.append("WHERE I_BankStatement_ID IN ")
|
||||||
+ "(SELECT I_BankStatement_ID "
|
.append("(SELECT I_BankStatement_ID ")
|
||||||
+ "FROM I_BankStatement i"
|
.append("FROM I_BankStatement i")
|
||||||
+ " INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) "
|
.append(" INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) ")
|
||||||
+ "WHERE i.C_BPartner_ID IS NOT NULL "
|
.append("WHERE i.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND p.C_BPartner_ID IS NOT NULL "
|
.append(" AND p.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND p.C_BPartner_ID<>i.C_BPartner_ID) ")
|
.append(" AND p.C_BPartner_ID<>i.C_BPartner_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Payment<->BPartner Mismatch=" + no);
|
log.info("Payment<->BPartner Mismatch=" + no);
|
||||||
|
|
||||||
// Check Invoice<->BPartner combination
|
// Check Invoice<->BPartner combination
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice<->BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice<->BPartner, ' ")
|
||||||
+ "WHERE I_BankStatement_ID IN "
|
.append("WHERE I_BankStatement_ID IN ")
|
||||||
+ "(SELECT I_BankStatement_ID "
|
.append("(SELECT I_BankStatement_ID ")
|
||||||
+ "FROM I_BankStatement i"
|
.append("FROM I_BankStatement i")
|
||||||
+ " INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID) "
|
.append(" INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID) ")
|
||||||
+ "WHERE i.C_BPartner_ID IS NOT NULL "
|
.append("WHERE i.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND v.C_BPartner_ID IS NOT NULL "
|
.append(" AND v.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND v.C_BPartner_ID<>i.C_BPartner_ID) ")
|
.append(" AND v.C_BPartner_ID<>i.C_BPartner_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Invoice<->BPartner Mismatch=" + no);
|
log.info("Invoice<->BPartner Mismatch=" + no);
|
||||||
|
|
||||||
// Check Invoice.BPartner<->Payment.BPartner combination
|
// Check Invoice.BPartner<->Payment.BPartner combination
|
||||||
sql = new StringBuffer("UPDATE I_BankStatement "
|
sql = new StringBuilder("UPDATE I_BankStatement ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice.BPartner<->Payment.BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice.BPartner<->Payment.BPartner, ' ")
|
||||||
+ "WHERE I_BankStatement_ID IN "
|
.append("WHERE I_BankStatement_ID IN ")
|
||||||
+ "(SELECT I_BankStatement_ID "
|
.append("(SELECT I_BankStatement_ID ")
|
||||||
+ "FROM I_BankStatement i"
|
.append("FROM I_BankStatement i")
|
||||||
+ " INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID)"
|
.append(" INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID)")
|
||||||
+ " INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) "
|
.append(" INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) ")
|
||||||
+ "WHERE p.C_Invoice_ID<>v.C_Invoice_ID"
|
.append("WHERE p.C_Invoice_ID<>v.C_Invoice_ID")
|
||||||
+ " AND v.C_BPartner_ID<>p.C_BPartner_ID) ")
|
.append(" AND v.C_BPartner_ID<>p.C_BPartner_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Invoice.BPartner<->Payment.BPartner Mismatch=" + no);
|
log.info("Invoice.BPartner<->Payment.BPartner Mismatch=" + no);
|
||||||
|
|
||||||
// Detect Duplicates
|
// Detect Duplicates
|
||||||
sql = new StringBuffer("SELECT i.I_BankStatement_ID, l.C_BankStatementLine_ID, i.EftTrxID "
|
sql = new StringBuilder("SELECT i.I_BankStatement_ID, l.C_BankStatementLine_ID, i.EftTrxID ")
|
||||||
+ "FROM I_BankStatement i, C_BankStatement s, C_BankStatementLine l "
|
.append("FROM I_BankStatement i, C_BankStatement s, C_BankStatementLine l ")
|
||||||
+ "WHERE i.I_isImported='N' "
|
.append("WHERE i.I_isImported='N' ")
|
||||||
+ "AND s.C_BankStatement_ID=l.C_BankStatement_ID "
|
.append("AND s.C_BankStatement_ID=l.C_BankStatement_ID ")
|
||||||
+ "AND i.EftTrxID IS NOT NULL AND "
|
.append("AND i.EftTrxID IS NOT NULL AND ")
|
||||||
// Concatenate EFT Info
|
// Concatenate EFT Info
|
||||||
+ "(l.EftTrxID||l.EftAmt||l.EftStatementLineDate||l.EftValutaDate||l.EftTrxType||l.EftCurrency||l.EftReference||s.EftStatementReference "
|
.append("(l.EftTrxID||l.EftAmt||l.EftStatementLineDate||l.EftValutaDate||l.EftTrxType||l.EftCurrency||l.EftReference||s.EftStatementReference ")
|
||||||
+ "||l.EftCheckNo||l.EftMemo||l.EftPayee||l.EftPayeeAccount) "
|
.append("||l.EftCheckNo||l.EftMemo||l.EftPayee||l.EftPayeeAccount) ")
|
||||||
+ "= "
|
.append("= ")
|
||||||
+ "(i.EftTrxID||i.EftAmt||i.EftStatementLineDate||i.EftValutaDate||i.EftTrxType||i.EftCurrency||i.EftReference||i.EftStatementReference "
|
.append("(i.EftTrxID||i.EftAmt||i.EftStatementLineDate||i.EftValutaDate||i.EftTrxType||i.EftCurrency||i.EftReference||i.EftStatementReference ")
|
||||||
+ "||i.EftCheckNo||i.EftMemo||i.EftPayee||i.EftPayeeAccount) ");
|
.append("||i.EftCheckNo||i.EftMemo||i.EftPayee||i.EftPayeeAccount) ");
|
||||||
|
|
||||||
StringBuffer updateSql = new StringBuffer("UPDATE I_Bankstatement "
|
StringBuilder updateSql = new StringBuilder("UPDATE I_Bankstatement ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Duplicate['||?||']' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Duplicate['||?||']' ")
|
||||||
+ "WHERE I_BankStatement_ID=?").append(clientCheck);
|
.append("WHERE I_BankStatement_ID=?").append(clientCheck);
|
||||||
PreparedStatement pupdt = DB.prepareStatement(updateSql.toString(), get_TrxName());
|
PreparedStatement pupdt = DB.prepareStatement(updateSql.toString(), get_TrxName());
|
||||||
|
|
||||||
PreparedStatement pstmtDuplicates = null;
|
PreparedStatement pstmtDuplicates = null;
|
||||||
|
@ -335,9 +336,9 @@ public class ImportBankStatement extends SvrProcess
|
||||||
ResultSet rs = pstmtDuplicates.executeQuery();
|
ResultSet rs = pstmtDuplicates.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
String info = "Line_ID=" + rs.getInt(2) // l.C_BankStatementLine_ID
|
StringBuilder info = new StringBuilder("Line_ID=").append(rs.getInt(2)) // l.C_BankStatementLine_ID
|
||||||
+ ",EDTTrxID=" + rs.getString(3); // i.EftTrxID
|
.append(",EDTTrxID=").append(rs.getString(3)); // i.EftTrxID
|
||||||
pupdt.setString(1, info);
|
pupdt.setString(1, info.toString());
|
||||||
pupdt.setInt(2, rs.getInt(1)); // i.I_BankStatement_ID
|
pupdt.setInt(2, rs.getInt(1)); // i.I_BankStatement_ID
|
||||||
pupdt.executeUpdate();
|
pupdt.executeUpdate();
|
||||||
no++;
|
no++;
|
||||||
|
@ -360,9 +361,9 @@ public class ImportBankStatement extends SvrProcess
|
||||||
commitEx();
|
commitEx();
|
||||||
|
|
||||||
//Import Bank Statement
|
//Import Bank Statement
|
||||||
sql = new StringBuffer("SELECT * FROM I_BankStatement"
|
sql = new StringBuilder("SELECT * FROM I_BankStatement")
|
||||||
+ " WHERE I_IsImported='N'"
|
.append(" WHERE I_IsImported='N'")
|
||||||
+ " ORDER BY C_BankAccount_ID, Name, EftStatementDate, EftStatementReference");
|
.append(" ORDER BY C_BankAccount_ID, Name, EftStatementDate, EftStatementReference");
|
||||||
|
|
||||||
MBankStatement statement = null;
|
MBankStatement statement = null;
|
||||||
MBankAccount account = null;
|
MBankAccount account = null;
|
||||||
|
@ -383,14 +384,16 @@ public class ImportBankStatement extends SvrProcess
|
||||||
{
|
{
|
||||||
account = MBankAccount.get (m_ctx, imp.getC_BankAccount_ID());
|
account = MBankAccount.get (m_ctx, imp.getC_BankAccount_ID());
|
||||||
statement = null;
|
statement = null;
|
||||||
log.info("New Statement, Account=" + account.getAccountNo());
|
msglog = new StringBuilder("New Statement, Account=").append(account.getAccountNo());
|
||||||
|
log.info(msglog.toString());
|
||||||
}
|
}
|
||||||
// Create a new Bank Statement for every account
|
// Create a new Bank Statement for every account
|
||||||
else if (account.getC_BankAccount_ID() != imp.getC_BankAccount_ID())
|
else if (account.getC_BankAccount_ID() != imp.getC_BankAccount_ID())
|
||||||
{
|
{
|
||||||
account = MBankAccount.get (m_ctx, imp.getC_BankAccount_ID());
|
account = MBankAccount.get (m_ctx, imp.getC_BankAccount_ID());
|
||||||
statement = null;
|
statement = null;
|
||||||
log.info("New Statement, Account=" + account.getAccountNo());
|
msglog = new StringBuilder("New Statement, Account=").append(account.getAccountNo());
|
||||||
|
log.info(msglog.toString());
|
||||||
}
|
}
|
||||||
// Create a new Bank Statement for every statement name
|
// Create a new Bank Statement for every statement name
|
||||||
else if ((statement.getName() != null) && (imp.getName() != null))
|
else if ((statement.getName() != null) && (imp.getName() != null))
|
||||||
|
@ -398,7 +401,8 @@ public class ImportBankStatement extends SvrProcess
|
||||||
if (!statement.getName().equals(imp.getName()))
|
if (!statement.getName().equals(imp.getName()))
|
||||||
{
|
{
|
||||||
statement = null;
|
statement = null;
|
||||||
log.info("New Statement, Statement Name=" + imp.getName());
|
msglog = new StringBuilder("New Statement, Statement Name=").append(imp.getName());
|
||||||
|
log.info(msglog.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create a new Bank Statement for every statement reference
|
// Create a new Bank Statement for every statement reference
|
||||||
|
@ -407,7 +411,8 @@ public class ImportBankStatement extends SvrProcess
|
||||||
if (!statement.getEftStatementReference().equals(imp.getEftStatementReference()))
|
if (!statement.getEftStatementReference().equals(imp.getEftStatementReference()))
|
||||||
{
|
{
|
||||||
statement = null;
|
statement = null;
|
||||||
log.info("New Statement, Statement Reference=" + imp.getEftStatementReference());
|
msglog = new StringBuilder("New Statement, Statement Reference=").append(imp.getEftStatementReference());
|
||||||
|
log.info(msglog.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create a new Bank Statement for every statement date
|
// Create a new Bank Statement for every statement date
|
||||||
|
@ -416,7 +421,8 @@ public class ImportBankStatement extends SvrProcess
|
||||||
if (!statement.getStatementDate().equals(imp.getStatementDate()))
|
if (!statement.getStatementDate().equals(imp.getStatementDate()))
|
||||||
{
|
{
|
||||||
statement = null;
|
statement = null;
|
||||||
log.info("New Statement, Statement Date=" + imp.getStatementDate());
|
msglog = new StringBuilder("New Statement, Statement Date=").append(imp.getStatementDate());
|
||||||
|
log.info(msglog.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,9 +519,9 @@ public class ImportBankStatement extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_BankStatement "
|
sql = new StringBuilder ("UPDATE I_BankStatement ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
//
|
//
|
||||||
|
|
|
@ -84,138 +84,139 @@ public class ImportConversionRate extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws Exception
|
protected String doIt() throws Exception
|
||||||
{
|
{
|
||||||
log.info("doIt - AD_Client_ID=" + p_AD_Client_ID
|
StringBuilder msglog = new StringBuilder("doIt - AD_Client_ID=").append(p_AD_Client_ID)
|
||||||
+ ",AD_Org_ID=" + p_AD_Org_ID
|
.append(",AD_Org_ID=").append(p_AD_Org_ID)
|
||||||
+ ",C_ConversionType_ID=" + p_C_ConversionType_ID
|
.append(",C_ConversionType_ID=").append(p_C_ConversionType_ID)
|
||||||
+ ",ValidFrom=" + p_ValidFrom
|
.append(",ValidFrom=").append(p_ValidFrom)
|
||||||
+ ",CreateReciprocalRate=" + p_CreateReciprocalRate);
|
.append(",CreateReciprocalRate=").append(p_CreateReciprocalRate);
|
||||||
|
log.info(msglog.toString());
|
||||||
//
|
//
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + p_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(p_AD_Client_ID);
|
||||||
// **** Prepare ****
|
// **** Prepare ****
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (p_DeleteOldImported)
|
if (p_DeleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_Conversion_Rate "
|
sql = new StringBuilder ("DELETE I_Conversion_Rate ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, Location, IsActive, Created/Updated
|
// Set Client, Org, Location, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append ("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append ("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID,").append (p_AD_Org_ID).append ("),");
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID,").append (p_AD_Org_ID).append ("),");
|
||||||
if (p_C_ConversionType_ID != 0)
|
if (p_C_ConversionType_ID != 0)
|
||||||
sql.append(" C_ConversionType_ID = COALESCE (C_ConversionType_ID,").append (p_C_ConversionType_ID).append ("),");
|
sql.append(" C_ConversionType_ID = COALESCE (C_ConversionType_ID,").append (p_C_ConversionType_ID).append ("),");
|
||||||
if (p_ValidFrom != null)
|
if (p_ValidFrom != null)
|
||||||
sql.append(" ValidFrom = COALESCE (ValidFrom,").append (DB.TO_DATE(p_ValidFrom)).append ("),");
|
sql.append(" ValidFrom = COALESCE (ValidFrom,").append (DB.TO_DATE(p_ValidFrom)).append ("),");
|
||||||
else
|
else
|
||||||
sql.append(" ValidFrom = COALESCE (ValidFrom,SysDate),");
|
sql.append(" ValidFrom = COALESCE (ValidFrom,SysDate),");
|
||||||
sql.append(" CreateReciprocalRate = COALESCE (CreateReciprocalRate,'").append (p_CreateReciprocalRate ? "Y" : "N").append ("'),"
|
sql.append(" CreateReciprocalRate = COALESCE (CreateReciprocalRate,'").append (p_CreateReciprocalRate ? "Y" : "N").append ("'),")
|
||||||
+ " IsActive = COALESCE (IsActive, 'Y'),"
|
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = ").append(getAD_User_ID()).append(","
|
.append(" UpdatedBy = ").append(getAD_User_ID()).append(",")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " Processed = 'N',"
|
.append(" Processed = 'N'," )
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info ("Reset =" + no);
|
log.info ("Reset =" + no);
|
||||||
|
|
||||||
// Org
|
// Org
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate o "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
|
||||||
+ "WHERE (AD_Org_ID IS NULL"
|
.append("WHERE (AD_Org_ID IS NULL")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Org =" + no);
|
log.warning ("Invalid Org =" + no);
|
||||||
|
|
||||||
// Conversion Type
|
// Conversion Type
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET C_ConversionType_ID = (SELECT C_ConversionType_ID FROM C_ConversionType c"
|
.append("SET C_ConversionType_ID = (SELECT C_ConversionType_ID FROM C_ConversionType c")
|
||||||
+ " WHERE c.Value=i.ConversionTypeValue AND c.AD_Client_ID IN (0,i.AD_Client_ID) AND c.IsActive='Y') "
|
.append(" WHERE c.Value=i.ConversionTypeValue AND c.AD_Client_ID IN (0,i.AD_Client_ID) AND c.IsActive='Y') ")
|
||||||
+ "WHERE C_ConversionType_ID IS NULL AND ConversionTypeValue IS NOT NULL"
|
.append("WHERE C_ConversionType_ID IS NULL AND ConversionTypeValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no > 0)
|
if (no > 0)
|
||||||
log.fine("Set ConversionType =" + no);
|
log.fine("Set ConversionType =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ConversionType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ConversionType, ' ")
|
||||||
+ "WHERE (C_ConversionType_ID IS NULL"
|
.append("WHERE (C_ConversionType_ID IS NULL")
|
||||||
+ " OR NOT EXISTS (SELECT * FROM C_ConversionType c "
|
.append(" OR NOT EXISTS (SELECT * FROM C_ConversionType c ")
|
||||||
+ "WHERE i.C_ConversionType_ID=c.C_ConversionType_ID AND c.IsActive='Y'"
|
.append("WHERE i.C_ConversionType_ID=c.C_ConversionType_ID AND c.IsActive='Y'")
|
||||||
+ " AND c.AD_Client_ID IN (0,i.AD_Client_ID)))"
|
.append(" AND c.AD_Client_ID IN (0,i.AD_Client_ID)))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid ConversionType =" + no);
|
log.warning ("Invalid ConversionType =" + no);
|
||||||
|
|
||||||
// Currency
|
// Currency
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET C_Currency_ID = (SELECT C_Currency_ID FROM C_Currency c"
|
.append("SET C_Currency_ID = (SELECT C_Currency_ID FROM C_Currency c")
|
||||||
+ " WHERE c.ISO_Code=i.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID) AND c.IsActive='Y') "
|
.append(" WHERE c.ISO_Code=i.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID) AND c.IsActive='Y') ")
|
||||||
+ "WHERE C_Currency_ID IS NULL AND ISO_Code IS NOT NULL"
|
.append("WHERE C_Currency_ID IS NULL AND ISO_Code IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no > 0)
|
if (no > 0)
|
||||||
log.fine("Set Currency =" + no);
|
log.fine("Set Currency =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency, ' ")
|
||||||
+ "WHERE (C_Currency_ID IS NULL"
|
.append("WHERE (C_Currency_ID IS NULL")
|
||||||
+ " OR NOT EXISTS (SELECT * FROM C_Currency c "
|
.append(" OR NOT EXISTS (SELECT * FROM C_Currency c ")
|
||||||
+ "WHERE i.C_Currency_ID=c.C_Currency_ID AND c.IsActive='Y'"
|
.append("WHERE i.C_Currency_ID=c.C_Currency_ID AND c.IsActive='Y'")
|
||||||
+ " AND c.AD_Client_ID IN (0,i.AD_Client_ID)))"
|
.append(" AND c.AD_Client_ID IN (0,i.AD_Client_ID)))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Currency =" + no);
|
log.warning ("Invalid Currency =" + no);
|
||||||
|
|
||||||
// Currency To
|
// Currency To
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET C_Currency_ID_To = (SELECT C_Currency_ID FROM C_Currency c"
|
.append("SET C_Currency_ID_To = (SELECT C_Currency_ID FROM C_Currency c")
|
||||||
+ " WHERE c.ISO_Code=i.ISO_Code_To AND c.AD_Client_ID IN (0,i.AD_Client_ID) AND c.IsActive='Y') "
|
.append(" WHERE c.ISO_Code=i.ISO_Code_To AND c.AD_Client_ID IN (0,i.AD_Client_ID) AND c.IsActive='Y') ")
|
||||||
+ "WHERE C_Currency_ID_To IS NULL AND ISO_Code_To IS NOT NULL"
|
.append("WHERE C_Currency_ID_To IS NULL AND ISO_Code_To IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no > 0)
|
if (no > 0)
|
||||||
log.fine("Set Currency To =" + no);
|
log.fine("Set Currency To =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency To, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency To, ' ")
|
||||||
+ "WHERE (C_Currency_ID_To IS NULL"
|
.append("WHERE (C_Currency_ID_To IS NULL")
|
||||||
+ " OR NOT EXISTS (SELECT * FROM C_Currency c "
|
.append(" OR NOT EXISTS (SELECT * FROM C_Currency c ")
|
||||||
+ "WHERE i.C_Currency_ID_To=c.C_Currency_ID AND c.IsActive='Y'"
|
.append("WHERE i.C_Currency_ID_To=c.C_Currency_ID AND c.IsActive='Y'")
|
||||||
+ " AND c.AD_Client_ID IN (0,i.AD_Client_ID)))"
|
.append(" AND c.AD_Client_ID IN (0,i.AD_Client_ID)))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Currency To =" + no);
|
log.warning ("Invalid Currency To =" + no);
|
||||||
|
|
||||||
// Rates
|
// Rates
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET MultiplyRate = 1 / DivideRate "
|
.append("SET MultiplyRate = 1 / DivideRate ")
|
||||||
+ "WHERE (MultiplyRate IS NULL OR MultiplyRate = 0) AND DivideRate IS NOT NULL AND DivideRate<>0"
|
.append("WHERE (MultiplyRate IS NULL OR MultiplyRate = 0) AND DivideRate IS NOT NULL AND DivideRate<>0")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no > 0)
|
if (no > 0)
|
||||||
log.fine("Set MultiplyRate =" + no);
|
log.fine("Set MultiplyRate =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET DivideRate = 1 / MultiplyRate "
|
.append("SET DivideRate = 1 / MultiplyRate ")
|
||||||
+ "WHERE (DivideRate IS NULL OR DivideRate = 0) AND MultiplyRate IS NOT NULL AND MultiplyRate<>0"
|
.append("WHERE (DivideRate IS NULL OR DivideRate = 0) AND MultiplyRate IS NOT NULL AND MultiplyRate<>0")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no > 0)
|
if (no > 0)
|
||||||
log.fine("Set DivideRate =" + no);
|
log.fine("Set DivideRate =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate i "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Rates, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Rates, ' ")
|
||||||
+ "WHERE (MultiplyRate IS NULL OR MultiplyRate = 0 OR DivideRate IS NULL OR DivideRate = 0)"
|
.append("WHERE (MultiplyRate IS NULL OR MultiplyRate = 0 OR DivideRate IS NULL OR DivideRate = 0)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Rates =" + no);
|
log.warning ("Invalid Rates =" + no);
|
||||||
|
@ -231,8 +232,8 @@ public class ImportConversionRate extends SvrProcess
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
int noInsert = 0;
|
int noInsert = 0;
|
||||||
sql = new StringBuffer ("SELECT * FROM I_Conversion_Rate "
|
sql = new StringBuilder ("SELECT * FROM I_Conversion_Rate ")
|
||||||
+ "WHERE I_IsImported='N'").append (clientCheck)
|
.append("WHERE I_IsImported='N'").append (clientCheck)
|
||||||
.append(" ORDER BY C_Currency_ID, C_Currency_ID_To, ValidFrom");
|
.append(" ORDER BY C_Currency_ID, C_Currency_ID_To, ValidFrom");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
|
@ -289,9 +290,9 @@ public class ImportConversionRate extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_Conversion_Rate "
|
sql = new StringBuilder ("UPDATE I_Conversion_Rate ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
//
|
//
|
||||||
|
|
|
@ -58,20 +58,25 @@ public class ImportDelete extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws Exception
|
protected String doIt() throws Exception
|
||||||
{
|
{
|
||||||
log.info("AD_Table_ID=" + p_AD_Table_ID);
|
StringBuilder msglog = new StringBuilder("AD_Table_ID=").append(p_AD_Table_ID);
|
||||||
|
log.info(msglog.toString());
|
||||||
// get Table Info
|
// get Table Info
|
||||||
MTable table = new MTable (getCtx(), p_AD_Table_ID, get_TrxName());
|
MTable table = new MTable (getCtx(), p_AD_Table_ID, get_TrxName());
|
||||||
if (table.get_ID() == 0)
|
if (table.get_ID() == 0){
|
||||||
throw new IllegalArgumentException ("No AD_Table_ID=" + p_AD_Table_ID);
|
StringBuilder msgexc = new StringBuilder("No AD_Table_ID=").append(p_AD_Table_ID);
|
||||||
|
throw new IllegalArgumentException (msgexc.toString());
|
||||||
|
}
|
||||||
String tableName = table.getTableName();
|
String tableName = table.getTableName();
|
||||||
if (!tableName.startsWith("I"))
|
if (!tableName.startsWith("I")){
|
||||||
throw new IllegalArgumentException ("Not an import table = " + tableName);
|
StringBuilder msgexc = new StringBuilder("Not an import table = ").append(tableName);
|
||||||
|
throw new IllegalArgumentException (msgexc.toString());
|
||||||
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
String sql = "DELETE FROM " + tableName + " WHERE AD_Client_ID=" + getAD_Client_ID();
|
StringBuilder sql = new StringBuilder("DELETE FROM ").append(tableName).append(" WHERE AD_Client_ID=").append(getAD_Client_ID());
|
||||||
int no = DB.executeUpdate(sql, get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
String msg = Msg.translate(getCtx(), tableName + "_ID") + " #" + no;
|
StringBuilder msg = new StringBuilder(Msg.translate(getCtx(), tableName + "_ID")).append(" #").append(no);
|
||||||
return msg;
|
return msg.toString();
|
||||||
} // ImportDelete
|
} // ImportDelete
|
||||||
|
|
||||||
} // ImportDelete
|
} // ImportDelete
|
||||||
|
|
|
@ -95,271 +95,272 @@ public class ImportGLJournal extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
log.info("IsValidateOnly=" + m_IsValidateOnly + ", IsImportOnlyNoErrors=" + m_IsImportOnlyNoErrors);
|
StringBuilder msglog = new StringBuilder("IsValidateOnly=").append(m_IsValidateOnly).append(", IsImportOnlyNoErrors=").append(m_IsImportOnlyNoErrors);
|
||||||
StringBuffer sql = null;
|
log.info(msglog.toString());
|
||||||
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||||
|
|
||||||
// **** Prepare ****
|
// **** Prepare ****
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (m_DeleteOldImported)
|
if (m_DeleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_GLJournal "
|
sql = new StringBuilder ("DELETE I_GLJournal ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set IsActive, Created/Updated
|
// Set IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal "
|
sql = new StringBuilder ("UPDATE I_GLJournal ")
|
||||||
+ "SET IsActive = COALESCE (IsActive, 'Y'),"
|
.append("SET IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info ("Reset=" + no);
|
log.info ("Reset=" + no);
|
||||||
|
|
||||||
// Set Client from Name
|
// Set Client from Name
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET AD_Client_ID=(SELECT c.AD_Client_ID FROM AD_Client c WHERE c.Value=i.ClientValue) "
|
.append("SET AD_Client_ID=(SELECT c.AD_Client_ID FROM AD_Client c WHERE c.Value=i.ClientValue) ")
|
||||||
+ "WHERE (AD_Client_ID IS NULL OR AD_Client_ID=0) AND ClientValue IS NOT NULL"
|
.append("WHERE (AD_Client_ID IS NULL OR AD_Client_ID=0) AND ClientValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'");
|
.append(" AND I_IsImported<>'Y'");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Client from Value=" + no);
|
log.fine("Set Client from Value=" + no);
|
||||||
|
|
||||||
// Set Default Client, Doc Org, AcctSchema, DatAcct
|
// Set Default Client, Doc Org, AcctSchema, DatAcct
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal "
|
sql = new StringBuilder ("UPDATE I_GLJournal ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (m_AD_Client_ID).append ("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID,").append (m_AD_Client_ID).append ("),")
|
||||||
+ " AD_OrgDoc_ID = COALESCE (AD_OrgDoc_ID,").append (m_AD_Org_ID).append ("),");
|
.append(" AD_OrgDoc_ID = COALESCE (AD_OrgDoc_ID,").append (m_AD_Org_ID).append ("),");
|
||||||
if (m_C_AcctSchema_ID != 0)
|
if (m_C_AcctSchema_ID != 0)
|
||||||
sql.append(" C_AcctSchema_ID = COALESCE (C_AcctSchema_ID,").append (m_C_AcctSchema_ID).append ("),");
|
sql.append(" C_AcctSchema_ID = COALESCE (C_AcctSchema_ID,").append (m_C_AcctSchema_ID).append ("),");
|
||||||
if (m_DateAcct != null)
|
if (m_DateAcct != null)
|
||||||
sql.append(" DateAcct = COALESCE (DateAcct,").append (DB.TO_DATE(m_DateAcct)).append ("),");
|
sql.append(" DateAcct = COALESCE (DateAcct,").append (DB.TO_DATE(m_DateAcct)).append ("),");
|
||||||
sql.append(" Updated = COALESCE (Updated, SysDate) "
|
sql.append(" Updated = COALESCE (Updated, SysDate) ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Client/DocOrg/Default=" + no);
|
log.fine("Client/DocOrg/Default=" + no);
|
||||||
|
|
||||||
// Error Doc Org
|
// Error Doc Org
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal o "
|
sql = new StringBuilder ("UPDATE I_GLJournal o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Doc Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Doc Org, '")
|
||||||
+ "WHERE (AD_OrgDoc_ID IS NULL OR AD_OrgDoc_ID=0"
|
.append("WHERE (AD_OrgDoc_ID IS NULL OR AD_OrgDoc_ID=0")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_OrgDoc_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_OrgDoc_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Doc Org=" + no);
|
log.warning ("Invalid Doc Org=" + no);
|
||||||
|
|
||||||
// Set AcctSchema
|
// Set AcctSchema
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_AcctSchema_ID=(SELECT a.C_AcctSchema_ID FROM C_AcctSchema a"
|
.append("SET C_AcctSchema_ID=(SELECT a.C_AcctSchema_ID FROM C_AcctSchema a")
|
||||||
+ " WHERE i.AcctSchemaName=a.Name AND i.AD_Client_ID=a.AD_Client_ID) "
|
.append(" WHERE i.AcctSchemaName=a.Name AND i.AD_Client_ID=a.AD_Client_ID) ")
|
||||||
+ "WHERE C_AcctSchema_ID IS NULL AND AcctSchemaName IS NOT NULL"
|
.append("WHERE C_AcctSchema_ID IS NULL AND AcctSchemaName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set AcctSchema from Name=" + no);
|
log.fine("Set AcctSchema from Name=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_AcctSchema_ID=(SELECT c.C_AcctSchema1_ID FROM AD_ClientInfo c WHERE c.AD_Client_ID=i.AD_Client_ID) "
|
.append("SET C_AcctSchema_ID=(SELECT c.C_AcctSchema1_ID FROM AD_ClientInfo c WHERE c.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE C_AcctSchema_ID IS NULL AND AcctSchemaName IS NULL"
|
.append("WHERE C_AcctSchema_ID IS NULL AND AcctSchemaName IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set AcctSchema from Client=" + no);
|
log.fine("Set AcctSchema from Client=" + no);
|
||||||
// Error AcctSchema
|
// Error AcctSchema
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid AcctSchema, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid AcctSchema, '")
|
||||||
+ "WHERE (C_AcctSchema_ID IS NULL OR C_AcctSchema_ID=0"
|
.append("WHERE (C_AcctSchema_ID IS NULL OR C_AcctSchema_ID=0")
|
||||||
+ " OR NOT EXISTS (SELECT * FROM C_AcctSchema a WHERE i.AD_Client_ID=a.AD_Client_ID))"
|
.append(" OR NOT EXISTS (SELECT * FROM C_AcctSchema a WHERE i.AD_Client_ID=a.AD_Client_ID))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid AcctSchema=" + no);
|
log.warning ("Invalid AcctSchema=" + no);
|
||||||
|
|
||||||
// Set DateAcct (mandatory)
|
// Set DateAcct (mandatory)
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET DateAcct=SysDate "
|
.append("SET DateAcct=SysDate ")
|
||||||
+ "WHERE DateAcct IS NULL"
|
.append("WHERE DateAcct IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set DateAcct=" + no);
|
log.fine("Set DateAcct=" + no);
|
||||||
|
|
||||||
// Document Type
|
// Document Type
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_DocType_ID=(SELECT d.C_DocType_ID FROM C_DocType d"
|
.append("SET C_DocType_ID=(SELECT d.C_DocType_ID FROM C_DocType d")
|
||||||
+ " WHERE d.Name=i.DocTypeName AND d.DocBaseType='GLJ' AND i.AD_Client_ID=d.AD_Client_ID) "
|
.append(" WHERE d.Name=i.DocTypeName AND d.DocBaseType='GLJ' AND i.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL"
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set DocType=" + no);
|
log.fine("Set DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocType, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocType, '")
|
||||||
+ "WHERE (C_DocType_ID IS NULL OR C_DocType_ID=0"
|
.append("WHERE (C_DocType_ID IS NULL OR C_DocType_ID=0")
|
||||||
+ " OR NOT EXISTS (SELECT * FROM C_DocType d WHERE i.AD_Client_ID=d.AD_Client_ID AND d.DocBaseType='GLJ'))"
|
.append(" OR NOT EXISTS (SELECT * FROM C_DocType d WHERE i.AD_Client_ID=d.AD_Client_ID AND d.DocBaseType='GLJ'))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid DocType=" + no);
|
log.warning ("Invalid DocType=" + no);
|
||||||
|
|
||||||
// GL Category
|
// GL Category
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET GL_Category_ID=(SELECT c.GL_Category_ID FROM GL_Category c"
|
.append("SET GL_Category_ID=(SELECT c.GL_Category_ID FROM GL_Category c")
|
||||||
+ " WHERE c.Name=i.CategoryName AND i.AD_Client_ID=c.AD_Client_ID) "
|
.append(" WHERE c.Name=i.CategoryName AND i.AD_Client_ID=c.AD_Client_ID) ")
|
||||||
+ "WHERE GL_Category_ID IS NULL AND CategoryName IS NOT NULL"
|
.append("WHERE GL_Category_ID IS NULL AND CategoryName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set DocType=" + no);
|
log.fine("Set DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Category, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Category, '")
|
||||||
+ "WHERE (GL_Category_ID IS NULL OR GL_Category_ID=0)"
|
.append("WHERE (GL_Category_ID IS NULL OR GL_Category_ID=0)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid GLCategory=" + no);
|
log.warning ("Invalid GLCategory=" + no);
|
||||||
|
|
||||||
// Set Currency
|
// Set Currency
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_Currency_ID=(SELECT c.C_Currency_ID FROM C_Currency c"
|
.append("SET C_Currency_ID=(SELECT c.C_Currency_ID FROM C_Currency c")
|
||||||
+ " WHERE c.ISO_Code=i.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) "
|
.append(" WHERE c.ISO_Code=i.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_Currency_ID IS NULL AND ISO_Code IS NOT NULL"
|
.append("WHERE C_Currency_ID IS NULL AND ISO_Code IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Currency from ISO=" + no);
|
log.fine("Set Currency from ISO=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_Currency_ID=(SELECT a.C_Currency_ID FROM C_AcctSchema a"
|
.append("SET C_Currency_ID=(SELECT a.C_Currency_ID FROM C_AcctSchema a")
|
||||||
+ " WHERE a.C_AcctSchema_ID=i.C_AcctSchema_ID AND a.AD_Client_ID=i.AD_Client_ID)"
|
.append(" WHERE a.C_AcctSchema_ID=i.C_AcctSchema_ID AND a.AD_Client_ID=i.AD_Client_ID)")
|
||||||
+ "WHERE C_Currency_ID IS NULL AND ISO_Code IS NULL"
|
.append("WHERE C_Currency_ID IS NULL AND ISO_Code IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default Currency=" + no);
|
log.fine("Set Default Currency=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency, '")
|
||||||
+ "WHERE (C_Currency_ID IS NULL OR C_Currency_ID=0)"
|
.append("WHERE (C_Currency_ID IS NULL OR C_Currency_ID=0)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Currency=" + no);
|
log.warning ("Invalid Currency=" + no);
|
||||||
|
|
||||||
// Set Conversion Type
|
// Set Conversion Type
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET ConversionTypeValue='S' "
|
.append("SET ConversionTypeValue='S' ")
|
||||||
+ "WHERE C_ConversionType_ID IS NULL AND ConversionTypeValue IS NULL"
|
.append("WHERE C_ConversionType_ID IS NULL AND ConversionTypeValue IS NULL")
|
||||||
+ " AND I_IsImported='N'").append (clientCheck);
|
.append(" AND I_IsImported='N'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set CurrencyType Value to Spot =" + no);
|
log.fine("Set CurrencyType Value to Spot =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_ConversionType_ID=(SELECT c.C_ConversionType_ID FROM C_ConversionType c"
|
.append("SET C_ConversionType_ID=(SELECT c.C_ConversionType_ID FROM C_ConversionType c")
|
||||||
+ " WHERE c.Value=i.ConversionTypeValue AND c.AD_Client_ID IN (0,i.AD_Client_ID)) "
|
.append(" WHERE c.Value=i.ConversionTypeValue AND c.AD_Client_ID IN (0,i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_ConversionType_ID IS NULL AND ConversionTypeValue IS NOT NULL"
|
.append("WHERE C_ConversionType_ID IS NULL AND ConversionTypeValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set CurrencyType from Value=" + no);
|
log.fine("Set CurrencyType from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CurrencyType, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CurrencyType, '")
|
||||||
+ "WHERE (C_ConversionType_ID IS NULL OR C_ConversionType_ID=0) AND ConversionTypeValue IS NOT NULL"
|
.append("WHERE (C_ConversionType_ID IS NULL OR C_ConversionType_ID=0) AND ConversionTypeValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid CurrencyTypeValue=" + no);
|
log.warning ("Invalid CurrencyTypeValue=" + no);
|
||||||
|
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No ConversionType, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No ConversionType, '")
|
||||||
+ "WHERE (C_ConversionType_ID IS NULL OR C_ConversionType_ID=0)"
|
.append("WHERE (C_ConversionType_ID IS NULL OR C_ConversionType_ID=0)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No CourrencyType=" + no);
|
log.warning ("No CourrencyType=" + no);
|
||||||
|
|
||||||
// Set/Overwrite Home Currency Rate
|
// Set/Overwrite Home Currency Rate
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET CurrencyRate=1"
|
.append("SET CurrencyRate=1")
|
||||||
+ "WHERE EXISTS (SELECT * FROM C_AcctSchema a"
|
.append("WHERE EXISTS (SELECT * FROM C_AcctSchema a")
|
||||||
+ " WHERE a.C_AcctSchema_ID=i.C_AcctSchema_ID AND a.C_Currency_ID=i.C_Currency_ID)"
|
.append(" WHERE a.C_AcctSchema_ID=i.C_AcctSchema_ID AND a.C_Currency_ID=i.C_Currency_ID)")
|
||||||
+ " AND C_Currency_ID IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND C_Currency_ID IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Home CurrencyRate=" + no);
|
log.fine("Set Home CurrencyRate=" + no);
|
||||||
// Set Currency Rate
|
// Set Currency Rate
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET CurrencyRate=(SELECT MAX(r.MultiplyRate) FROM C_Conversion_Rate r, C_AcctSchema s"
|
.append("SET CurrencyRate=(SELECT MAX(r.MultiplyRate) FROM C_Conversion_Rate r, C_AcctSchema s")
|
||||||
+ " WHERE s.C_AcctSchema_ID=i.C_AcctSchema_ID AND s.AD_Client_ID=i.AD_Client_ID"
|
.append(" WHERE s.C_AcctSchema_ID=i.C_AcctSchema_ID AND s.AD_Client_ID=i.AD_Client_ID")
|
||||||
+ " AND r.C_Currency_ID=i.C_Currency_ID AND r.C_Currency_ID_TO=s.C_Currency_ID"
|
.append(" AND r.C_Currency_ID=i.C_Currency_ID AND r.C_Currency_ID_TO=s.C_Currency_ID")
|
||||||
+ " AND r.AD_Client_ID=i.AD_Client_ID AND r.AD_Org_ID=i.AD_OrgDoc_ID"
|
.append(" AND r.AD_Client_ID=i.AD_Client_ID AND r.AD_Org_ID=i.AD_OrgDoc_ID")
|
||||||
+ " AND r.C_ConversionType_ID=i.C_ConversionType_ID"
|
.append(" AND r.C_ConversionType_ID=i.C_ConversionType_ID")
|
||||||
+ " AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo "
|
.append(" AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo ")
|
||||||
// ORDER BY ValidFrom DESC
|
// ORDER BY ValidFrom DESC
|
||||||
+ ") WHERE CurrencyRate IS NULL OR CurrencyRate=0 AND C_Currency_ID>0"
|
.append(") WHERE CurrencyRate IS NULL OR CurrencyRate=0 AND C_Currency_ID>0")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Org Rate=" + no);
|
log.fine("Set Org Rate=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET CurrencyRate=(SELECT MAX(r.MultiplyRate) FROM C_Conversion_Rate r, C_AcctSchema s"
|
.append("SET CurrencyRate=(SELECT MAX(r.MultiplyRate) FROM C_Conversion_Rate r, C_AcctSchema s")
|
||||||
+ " WHERE s.C_AcctSchema_ID=i.C_AcctSchema_ID AND s.AD_Client_ID=i.AD_Client_ID"
|
.append(" WHERE s.C_AcctSchema_ID=i.C_AcctSchema_ID AND s.AD_Client_ID=i.AD_Client_ID")
|
||||||
+ " AND r.C_Currency_ID=i.C_Currency_ID AND r.C_Currency_ID_TO=s.C_Currency_ID"
|
.append(" AND r.C_Currency_ID=i.C_Currency_ID AND r.C_Currency_ID_TO=s.C_Currency_ID")
|
||||||
+ " AND r.AD_Client_ID=i.AD_Client_ID"
|
.append(" AND r.AD_Client_ID=i.AD_Client_ID")
|
||||||
+ " AND r.C_ConversionType_ID=i.C_ConversionType_ID"
|
.append(" AND r.C_ConversionType_ID=i.C_ConversionType_ID")
|
||||||
+ " AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo "
|
.append(" AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo ")
|
||||||
// ORDER BY ValidFrom DESC
|
// ORDER BY ValidFrom DESC
|
||||||
+ ") WHERE CurrencyRate IS NULL OR CurrencyRate=0 AND C_Currency_ID>0"
|
.append(") WHERE CurrencyRate IS NULL OR CurrencyRate=0 AND C_Currency_ID>0")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Client Rate=" + no);
|
log.fine("Set Client Rate=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Rate, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Rate, '")
|
||||||
+ "WHERE CurrencyRate IS NULL OR CurrencyRate=0"
|
.append("WHERE CurrencyRate IS NULL OR CurrencyRate=0")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No Rate=" + no);
|
log.warning ("No Rate=" + no);
|
||||||
|
|
||||||
// Set Period
|
// Set Period
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_Period_ID=(SELECT MAX(p.C_Period_ID) FROM C_Period p"
|
.append("SET C_Period_ID=(SELECT MAX(p.C_Period_ID) FROM C_Period p")
|
||||||
+ " INNER JOIN C_Year y ON (y.C_Year_ID=p.C_Year_ID)"
|
.append(" INNER JOIN C_Year y ON (y.C_Year_ID=p.C_Year_ID)")
|
||||||
+ " INNER JOIN AD_ClientInfo c ON (c.C_Calendar_ID=y.C_Calendar_ID)"
|
.append(" INNER JOIN AD_ClientInfo c ON (c.C_Calendar_ID=y.C_Calendar_ID)")
|
||||||
+ " WHERE c.AD_Client_ID=i.AD_Client_ID"
|
.append(" WHERE c.AD_Client_ID=i.AD_Client_ID")
|
||||||
// globalqss - cruiz - Bug [ 1577712 ] Financial Period Bug
|
// globalqss - cruiz - Bug [ 1577712 ] Financial Period Bug
|
||||||
+ " AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S') "
|
.append(" AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S') ")
|
||||||
+ "WHERE C_Period_ID IS NULL"
|
.append("WHERE C_Period_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Period=" + no);
|
log.fine("Set Period=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Period, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Period, '")
|
||||||
+ "WHERE C_Period_ID IS NULL OR C_Period_ID NOT IN"
|
.append("WHERE C_Period_ID IS NULL OR C_Period_ID NOT IN")
|
||||||
+ "(SELECT C_Period_ID FROM C_Period p"
|
.append("(SELECT C_Period_ID FROM C_Period p")
|
||||||
+ " INNER JOIN C_Year y ON (y.C_Year_ID=p.C_Year_ID)"
|
.append(" INNER JOIN C_Year y ON (y.C_Year_ID=p.C_Year_ID)")
|
||||||
+ " INNER JOIN AD_ClientInfo c ON (c.C_Calendar_ID=y.C_Calendar_ID) "
|
.append(" INNER JOIN AD_ClientInfo c ON (c.C_Calendar_ID=y.C_Calendar_ID) ")
|
||||||
+ " WHERE c.AD_Client_ID=i.AD_Client_ID"
|
.append(" WHERE c.AD_Client_ID=i.AD_Client_ID")
|
||||||
// globalqss - cruiz - Bug [ 1577712 ] Financial Period Bug
|
// globalqss - cruiz - Bug [ 1577712 ] Financial Period Bug
|
||||||
+ " AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S')"
|
.append(" AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S')")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Period=" + no);
|
log.warning ("Invalid Period=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_ErrorMsg=I_ErrorMsg||'WARN=Period Closed, ' "
|
.append("SET I_ErrorMsg=I_ErrorMsg||'WARN=Period Closed, ' ")
|
||||||
+ "WHERE C_Period_ID IS NOT NULL AND NOT EXISTS"
|
.append("WHERE C_Period_ID IS NOT NULL AND NOT EXISTS")
|
||||||
+ " (SELECT * FROM C_PeriodControl pc WHERE pc.C_Period_ID=i.C_Period_ID AND DocBaseType='GLJ' AND PeriodStatus='O') "
|
.append(" (SELECT * FROM C_PeriodControl pc WHERE pc.C_Period_ID=i.C_Period_ID AND DocBaseType='GLJ' AND PeriodStatus='O') ")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Period Closed=" + no);
|
log.warning ("Period Closed=" + no);
|
||||||
|
|
||||||
// Posting Type
|
// Posting Type
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET PostingType='A' "
|
.append("SET PostingType='A' ")
|
||||||
+ "WHERE PostingType IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE PostingType IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Actual PostingType=" + no);
|
log.fine("Set Actual PostingType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid PostingType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid PostingType, ' ")
|
||||||
+ "WHERE PostingType IS NULL OR NOT EXISTS"
|
.append("WHERE PostingType IS NULL OR NOT EXISTS")
|
||||||
+ " (SELECT * FROM AD_Ref_List r WHERE r.AD_Reference_ID=125 AND i.PostingType=r.Value)"
|
.append(" (SELECT * FROM AD_Ref_List r WHERE r.AD_Reference_ID=125 AND i.PostingType=r.Value)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid PostingTypee=" + no);
|
log.warning ("Invalid PostingTypee=" + no);
|
||||||
|
@ -369,152 +370,152 @@ public class ImportGLJournal extends SvrProcess
|
||||||
// (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0)
|
// (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0)
|
||||||
|
|
||||||
// Set Org from Name (* is overwritten and default)
|
// Set Org from Name (* is overwritten and default)
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET AD_Org_ID=COALESCE((SELECT o.AD_Org_ID FROM AD_Org o"
|
.append("SET AD_Org_ID=COALESCE((SELECT o.AD_Org_ID FROM AD_Org o")
|
||||||
+ " WHERE o.Value=i.OrgValue AND o.IsSummary='N' AND i.AD_Client_ID=o.AD_Client_ID),AD_Org_ID) "
|
.append(" WHERE o.Value=i.OrgValue AND o.IsSummary='N' AND i.AD_Client_ID=o.AD_Client_ID),AD_Org_ID) ")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0) AND OrgValue IS NOT NULL"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0) AND OrgValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'");
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Org from Value=" + no);
|
log.fine("Set Org from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET AD_Org_ID=AD_OrgDoc_ID "
|
.append("SET AD_Org_ID=AD_OrgDoc_ID ")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0) AND OrgValue IS NULL AND AD_OrgDoc_ID IS NOT NULL AND AD_OrgDoc_ID<>0"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0) AND OrgValue IS NULL AND AD_OrgDoc_ID IS NOT NULL AND AD_OrgDoc_ID<>0")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Org from Doc Org=" + no);
|
log.fine("Set Org from Doc Org=" + no);
|
||||||
// Error Org
|
// Error Org
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal o "
|
sql = new StringBuilder ("UPDATE I_GLJournal o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Org=" + no);
|
log.warning ("Invalid Org=" + no);
|
||||||
|
|
||||||
// Set Account
|
// Set Account
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET Account_ID=(SELECT MAX(ev.C_ElementValue_ID) FROM C_ElementValue ev"
|
.append("SET Account_ID=(SELECT MAX(ev.C_ElementValue_ID) FROM C_ElementValue ev")
|
||||||
+ " INNER JOIN C_Element e ON (e.C_Element_ID=ev.C_Element_ID)"
|
.append(" INNER JOIN C_Element e ON (e.C_Element_ID=ev.C_Element_ID)")
|
||||||
+ " INNER JOIN C_AcctSchema_Element ase ON (e.C_Element_ID=ase.C_Element_ID AND ase.ElementType='AC')"
|
.append(" INNER JOIN C_AcctSchema_Element ase ON (e.C_Element_ID=ase.C_Element_ID AND ase.ElementType='AC')")
|
||||||
+ " WHERE ev.Value=i.AccountValue AND ev.IsSummary='N'"
|
.append(" WHERE ev.Value=i.AccountValue AND ev.IsSummary='N'")
|
||||||
+ " AND i.C_AcctSchema_ID=ase.C_AcctSchema_ID AND i.AD_Client_ID=ev.AD_Client_ID) "
|
.append(" AND i.C_AcctSchema_ID=ase.C_AcctSchema_ID AND i.AD_Client_ID=ev.AD_Client_ID) ")
|
||||||
+ "WHERE Account_ID IS NULL AND AccountValue IS NOT NULL"
|
.append("WHERE Account_ID IS NULL AND AccountValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Account from Value=" + no);
|
log.fine("Set Account from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Account, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Account, '")
|
||||||
+ "WHERE (Account_ID IS NULL OR Account_ID=0)"
|
.append("WHERE (Account_ID IS NULL OR Account_ID=0)")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Account=" + no);
|
log.warning ("Invalid Account=" + no);
|
||||||
|
|
||||||
// Set BPartner
|
// Set BPartner
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_BPartner_ID=(SELECT bp.C_BPartner_ID FROM C_BPartner bp"
|
.append("SET C_BPartner_ID=(SELECT bp.C_BPartner_ID FROM C_BPartner bp")
|
||||||
+ " WHERE bp.Value=i.BPartnerValue AND bp.IsSummary='N' AND i.AD_Client_ID=bp.AD_Client_ID) "
|
.append(" WHERE bp.Value=i.BPartnerValue AND bp.IsSummary='N' AND i.AD_Client_ID=bp.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BPartner from Value=" + no);
|
log.fine("Set BPartner from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid BPartner, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid BPartner, '")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid BPartner=" + no);
|
log.warning ("Invalid BPartner=" + no);
|
||||||
|
|
||||||
// Set Product
|
// Set Product
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(p.M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(p.M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE (p.Value=i.ProductValue OR p.UPC=i.UPC OR p.SKU=i.SKU)"
|
.append(" WHERE (p.Value=i.ProductValue OR p.UPC=i.UPC OR p.SKU=i.SKU)")
|
||||||
+ " AND p.IsSummary='N' AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" AND p.IsSummary='N' AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)"
|
.append("WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Product from Value=" + no);
|
log.fine("Set Product from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, '")
|
||||||
+ "WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)"
|
.append("WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Product=" + no);
|
log.warning ("Invalid Product=" + no);
|
||||||
|
|
||||||
// Set Project
|
// Set Project
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET C_Project_ID=(SELECT p.C_Project_ID FROM C_Project p"
|
.append("SET C_Project_ID=(SELECT p.C_Project_ID FROM C_Project p")
|
||||||
+ " WHERE p.Value=i.ProjectValue AND p.IsSummary='N' AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE p.Value=i.ProjectValue AND p.IsSummary='N' AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_Project_ID IS NULL AND ProjectValue IS NOT NULL"
|
.append("WHERE C_Project_ID IS NULL AND ProjectValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Project from Value=" + no);
|
log.fine("Set Project from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Project, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Project, '")
|
||||||
+ "WHERE C_Project_ID IS NULL AND ProjectValue IS NOT NULL"
|
.append("WHERE C_Project_ID IS NULL AND ProjectValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Project=" + no);
|
log.warning ("Invalid Project=" + no);
|
||||||
|
|
||||||
// Set TrxOrg
|
// Set TrxOrg
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET AD_OrgTrx_ID=(SELECT o.AD_Org_ID FROM AD_Org o"
|
.append("SET AD_OrgTrx_ID=(SELECT o.AD_Org_ID FROM AD_Org o")
|
||||||
+ " WHERE o.Value=i.OrgValue AND o.IsSummary='N' AND i.AD_Client_ID=o.AD_Client_ID) "
|
.append(" WHERE o.Value=i.OrgValue AND o.IsSummary='N' AND i.AD_Client_ID=o.AD_Client_ID) ")
|
||||||
+ "WHERE AD_OrgTrx_ID IS NULL AND OrgTrxValue IS NOT NULL"
|
.append("WHERE AD_OrgTrx_ID IS NULL AND OrgTrxValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set OrgTrx from Value=" + no);
|
log.fine("Set OrgTrx from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid OrgTrx, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid OrgTrx, '")
|
||||||
+ "WHERE AD_OrgTrx_ID IS NULL AND OrgTrxValue IS NOT NULL"
|
.append("WHERE AD_OrgTrx_ID IS NULL AND OrgTrxValue IS NOT NULL")
|
||||||
+ " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid OrgTrx=" + no);
|
log.warning ("Invalid OrgTrx=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Source Amounts
|
// Source Amounts
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal "
|
sql = new StringBuilder ("UPDATE I_GLJournal ")
|
||||||
+ "SET AmtSourceDr = 0 "
|
.append("SET AmtSourceDr = 0 ")
|
||||||
+ "WHERE AmtSourceDr IS NULL"
|
.append("WHERE AmtSourceDr IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set 0 Source Dr=" + no);
|
log.fine("Set 0 Source Dr=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal "
|
sql = new StringBuilder ("UPDATE I_GLJournal ")
|
||||||
+ "SET AmtSourceCr = 0 "
|
.append("SET AmtSourceCr = 0 ")
|
||||||
+ "WHERE AmtSourceCr IS NULL"
|
.append("WHERE AmtSourceCr IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set 0 Source Cr=" + no);
|
log.fine("Set 0 Source Cr=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_ErrorMsg=I_ErrorMsg||'WARN=Zero Source Balance, ' "
|
.append("SET I_ErrorMsg=I_ErrorMsg||'WARN=Zero Source Balance, ' ")
|
||||||
+ "WHERE (AmtSourceDr-AmtSourceCr)=0"
|
.append("WHERE (AmtSourceDr-AmtSourceCr)=0")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Zero Source Balance=" + no);
|
log.warning ("Zero Source Balance=" + no);
|
||||||
|
|
||||||
// Accounted Amounts (Only if No Error)
|
// Accounted Amounts (Only if No Error)
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal "
|
sql = new StringBuilder ("UPDATE I_GLJournal ")
|
||||||
+ "SET AmtAcctDr = ROUND(AmtSourceDr * CurrencyRate, 2) " // HARDCODED rounding
|
.append("SET AmtAcctDr = ROUND(AmtSourceDr * CurrencyRate, 2) ") // HARDCODED rounding
|
||||||
+ "WHERE AmtAcctDr IS NULL OR AmtAcctDr=0"
|
.append("WHERE AmtAcctDr IS NULL OR AmtAcctDr=0")
|
||||||
+ " AND I_IsImported='N'").append (clientCheck);
|
.append(" AND I_IsImported='N'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Calculate Acct Dr=" + no);
|
log.fine("Calculate Acct Dr=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal "
|
sql = new StringBuilder ("UPDATE I_GLJournal ")
|
||||||
+ "SET AmtAcctCr = ROUND(AmtSourceCr * CurrencyRate, 2) "
|
.append("SET AmtAcctCr = ROUND(AmtSourceCr * CurrencyRate, 2) ")
|
||||||
+ "WHERE AmtAcctCr IS NULL OR AmtAcctCr=0"
|
.append("WHERE AmtAcctCr IS NULL OR AmtAcctCr=0")
|
||||||
+ " AND I_IsImported='N'").append (clientCheck);
|
.append(" AND I_IsImported='N'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Calculate Acct Cr=" + no);
|
log.fine("Calculate Acct Cr=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal i "
|
sql = new StringBuilder ("UPDATE I_GLJournal i ")
|
||||||
+ "SET I_ErrorMsg=I_ErrorMsg||'WARN=Zero Acct Balance, ' "
|
.append("SET I_ErrorMsg=I_ErrorMsg||'WARN=Zero Acct Balance, ' ")
|
||||||
+ "WHERE (AmtSourceDr-AmtSourceCr)<>0 AND (AmtAcctDr-AmtAcctCr)=0"
|
.append("WHERE (AmtSourceDr-AmtSourceCr)<>0 AND (AmtAcctDr-AmtAcctCr)=0")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Zero Acct Balance=" + no);
|
log.warning ("Zero Acct Balance=" + no);
|
||||||
|
@ -533,9 +534,9 @@ public class ImportGLJournal extends SvrProcess
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// Get Balance
|
// Get Balance
|
||||||
sql = new StringBuffer ("SELECT SUM(AmtSourceDr)-SUM(AmtSourceCr), SUM(AmtAcctDr)-SUM(AmtAcctCr) "
|
sql = new StringBuilder ("SELECT SUM(AmtSourceDr)-SUM(AmtSourceCr), SUM(AmtAcctDr)-SUM(AmtAcctCr) ")
|
||||||
+ "FROM I_GLJournal "
|
.append("FROM I_GLJournal ")
|
||||||
+ "WHERE I_IsImported='N'").append (clientCheck);
|
.append("WHERE I_IsImported='N'").append (clientCheck);
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -548,8 +549,10 @@ public class ImportGLJournal extends SvrProcess
|
||||||
if (source != null && source.signum() == 0
|
if (source != null && source.signum() == 0
|
||||||
&& acct != null && acct.signum() == 0)
|
&& acct != null && acct.signum() == 0)
|
||||||
log.info ("Import Balance = 0");
|
log.info ("Import Balance = 0");
|
||||||
else
|
else{
|
||||||
log.warning("Balance Source=" + source + ", Acct=" + acct);
|
msglog = new StringBuilder("Balance Source=").append(source).append(", Acct=").append(acct);
|
||||||
|
log.warning(msglog.toString());
|
||||||
|
}
|
||||||
if (source != null)
|
if (source != null)
|
||||||
addLog (0, null, source, "@AmtSourceDr@ - @AmtSourceCr@");
|
addLog (0, null, source, "@AmtSourceDr@ - @AmtSourceCr@");
|
||||||
if (acct != null)
|
if (acct != null)
|
||||||
|
@ -585,10 +588,12 @@ public class ImportGLJournal extends SvrProcess
|
||||||
if (m_IsValidateOnly || m_IsImportOnlyNoErrors)
|
if (m_IsValidateOnly || m_IsImportOnlyNoErrors)
|
||||||
throw new Exception ("@Errors@=" + errors);
|
throw new Exception ("@Errors@=" + errors);
|
||||||
}
|
}
|
||||||
else if (m_IsValidateOnly)
|
else if (m_IsValidateOnly){
|
||||||
return "@Errors@=" + errors;
|
StringBuilder msgreturn = new StringBuilder("@Errors@=").append(errors);
|
||||||
|
return msgreturn.toString();
|
||||||
log.info("Validation Errors=" + errors);
|
}
|
||||||
|
msglog = new StringBuilder("Validation Errors=").append(errors);
|
||||||
|
log.info(msglog.toString());
|
||||||
// moved commit above to save error messages
|
// moved commit above to save error messages
|
||||||
// commit();
|
// commit();
|
||||||
|
|
||||||
|
@ -606,11 +611,11 @@ public class ImportGLJournal extends SvrProcess
|
||||||
boolean wasCreateNewBatch = false;
|
boolean wasCreateNewBatch = false;
|
||||||
|
|
||||||
// Go through Journal Records
|
// Go through Journal Records
|
||||||
sql = new StringBuffer ("SELECT * FROM I_GLJournal "
|
sql = new StringBuilder ("SELECT * FROM I_GLJournal ")
|
||||||
+ "WHERE I_IsImported='N'").append (clientCheck)
|
.append("WHERE I_IsImported='N'").append (clientCheck)
|
||||||
.append(" ORDER BY COALESCE(BatchDocumentNo, TO_NCHAR(I_GLJournal_ID)||' '), COALESCE(JournalDocumentNo, " +
|
.append(" ORDER BY COALESCE(BatchDocumentNo, TO_NCHAR(I_GLJournal_ID)||' '), COALESCE(JournalDocumentNo, ")
|
||||||
"TO_NCHAR(I_GLJournal_ID)||' '), C_AcctSchema_ID, PostingType, C_DocType_ID, GL_Category_ID, " +
|
.append("TO_NCHAR(I_GLJournal_ID)||' '), C_AcctSchema_ID, PostingType, C_DocType_ID, GL_Category_ID, ")
|
||||||
"C_Currency_ID, TRUNC(DateAcct), Line, I_GLJournal_ID");
|
.append("C_Currency_ID, TRUNC(DateAcct), Line, I_GLJournal_ID");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql.toString (), get_TrxName());
|
pstmt = DB.prepareStatement (sql.toString (), get_TrxName());
|
||||||
|
@ -647,13 +652,13 @@ public class ImportGLJournal extends SvrProcess
|
||||||
batch.setDocumentNo (imp.getBatchDocumentNo());
|
batch.setDocumentNo (imp.getBatchDocumentNo());
|
||||||
batch.setC_DocType_ID(imp.getC_DocType_ID());
|
batch.setC_DocType_ID(imp.getC_DocType_ID());
|
||||||
batch.setPostingType(imp.getPostingType());
|
batch.setPostingType(imp.getPostingType());
|
||||||
String description = imp.getBatchDescription();
|
StringBuilder description = new StringBuilder(imp.getBatchDescription());
|
||||||
if (description == null || description.length() == 0)
|
if (description == null || description.length() == 0)
|
||||||
description = "*Import-";
|
description = new StringBuilder("*Import-");
|
||||||
else
|
else
|
||||||
description += " *Import-";
|
description.append(" *Import-");
|
||||||
description += new Timestamp(System.currentTimeMillis());
|
description.append(new Timestamp(System.currentTimeMillis()));
|
||||||
batch.setDescription(description);
|
batch.setDescription(description.toString());
|
||||||
if (!batch.save())
|
if (!batch.save())
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "Batch not saved");
|
log.log(Level.SEVERE, "Batch not saved");
|
||||||
|
@ -795,9 +800,9 @@ public class ImportGLJournal extends SvrProcess
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_GLJournal "
|
sql = new StringBuilder ("UPDATE I_GLJournal ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
//
|
//
|
||||||
|
|
|
@ -68,67 +68,68 @@ public class ImportInOutConfirm extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt () throws Exception
|
protected String doIt () throws Exception
|
||||||
{
|
{
|
||||||
log.info("I_InOutLineConfirm_ID=" + p_I_InOutLineConfirm_ID);
|
StringBuilder msglog = new StringBuilder("I_InOutLineConfirm_ID=").append(p_I_InOutLineConfirm_ID);
|
||||||
StringBuffer sql = null;
|
log.info(msglog.toString());
|
||||||
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + p_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(p_AD_Client_ID);
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (p_DeleteOldImported)
|
if (p_DeleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_InOutLineConfirm "
|
sql = new StringBuilder ("DELETE I_InOutLineConfirm ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set IsActive, Created/Updated
|
// Set IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_InOutLineConfirm "
|
sql = new StringBuilder ("UPDATE I_InOutLineConfirm ")
|
||||||
+ "SET IsActive = COALESCE (IsActive, 'Y'),"
|
.append("SET IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info ("Reset=" + no);
|
log.info ("Reset=" + no);
|
||||||
|
|
||||||
// Set Client from Name
|
// Set Client from Name
|
||||||
sql = new StringBuffer ("UPDATE I_InOutLineConfirm i "
|
sql = new StringBuilder ("UPDATE I_InOutLineConfirm i ")
|
||||||
+ "SET AD_Client_ID=COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append (") "
|
.append("SET AD_Client_ID=COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append (") ")
|
||||||
+ "WHERE (AD_Client_ID IS NULL OR AD_Client_ID=0)"
|
.append("WHERE (AD_Client_ID IS NULL OR AD_Client_ID=0)")
|
||||||
+ " AND I_IsImported<>'Y'");
|
.append(" AND I_IsImported<>'Y'");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Client from Value=" + no);
|
log.fine("Set Client from Value=" + no);
|
||||||
|
|
||||||
// Error Confirmation Line
|
// Error Confirmation Line
|
||||||
sql = new StringBuffer ("UPDATE I_InOutLineConfirm i "
|
sql = new StringBuilder ("UPDATE I_InOutLineConfirm i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Confirmation Line, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Confirmation Line, '")
|
||||||
+ "WHERE (M_InOutLineConfirm_ID IS NULL OR M_InOutLineConfirm_ID=0"
|
.append("WHERE (M_InOutLineConfirm_ID IS NULL OR M_InOutLineConfirm_ID=0")
|
||||||
+ " OR NOT EXISTS (SELECT * FROM M_InOutLineConfirm c WHERE i.M_InOutLineConfirm_ID=c.M_InOutLineConfirm_ID))"
|
.append(" OR NOT EXISTS (SELECT * FROM M_InOutLineConfirm c WHERE i.M_InOutLineConfirm_ID=c.M_InOutLineConfirm_ID))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid InOutLineConfirm=" + no);
|
log.warning ("Invalid InOutLineConfirm=" + no);
|
||||||
|
|
||||||
// Error Confirmation No
|
// Error Confirmation No
|
||||||
sql = new StringBuffer ("UPDATE I_InOutLineConfirm i "
|
sql = new StringBuilder ("UPDATE I_InOutLineConfirm i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Missing Confirmation No, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Missing Confirmation No, '")
|
||||||
+ "WHERE (ConfirmationNo IS NULL OR ConfirmationNo='')"
|
.append("WHERE (ConfirmationNo IS NULL OR ConfirmationNo='')")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid ConfirmationNo=" + no);
|
log.warning ("Invalid ConfirmationNo=" + no);
|
||||||
|
|
||||||
// Qty
|
// Qty
|
||||||
sql = new StringBuffer ("UPDATE I_InOutLineConfirm i "
|
sql = new StringBuilder ("UPDATE I_InOutLineConfirm i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Target<>(Confirmed+Difference+Scrapped), ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Target<>(Confirmed+Difference+Scrapped), ' ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM M_InOutLineConfirm c "
|
.append("WHERE EXISTS (SELECT * FROM M_InOutLineConfirm c ")
|
||||||
+ "WHERE i.M_InOutLineConfirm_ID=c.M_InOutLineConfirm_ID"
|
.append("WHERE i.M_InOutLineConfirm_ID=c.M_InOutLineConfirm_ID")
|
||||||
+ " AND c.TargetQty<>(i.ConfirmedQty+i.ScrappedQty+i.DifferenceQty))"
|
.append(" AND c.TargetQty<>(i.ConfirmedQty+i.ScrappedQty+i.DifferenceQty))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Qty=" + no);
|
log.warning ("Invalid Qty=" + no);
|
||||||
|
@ -138,8 +139,8 @@ public class ImportInOutConfirm extends SvrProcess
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
sql = new StringBuffer ("SELECT * FROM I_InOutLineConfirm "
|
sql = new StringBuilder ("SELECT * FROM I_InOutLineConfirm ")
|
||||||
+ "WHERE I_IsImported='N'").append (clientCheck)
|
.append("WHERE I_IsImported='N'").append (clientCheck)
|
||||||
.append(" ORDER BY I_InOutLineConfirm_ID");
|
.append(" ORDER BY I_InOutLineConfirm_ID");
|
||||||
no = 0;
|
no = 0;
|
||||||
try
|
try
|
||||||
|
@ -193,8 +194,8 @@ public class ImportInOutConfirm extends SvrProcess
|
||||||
{
|
{
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
StringBuilder msgreturn = new StringBuilder("@Updated@ #").append(no);
|
||||||
return "@Updated@ #" + no;
|
return msgreturn.toString();
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
} // ImportInOutConfirm
|
} // ImportInOutConfirm
|
||||||
|
|
|
@ -112,7 +112,8 @@ public class ImportInventory extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
log.info("M_Locator_ID=" + p_M_Locator_ID + ",MovementDate=" + p_MovementDate);
|
StringBuilder msglog = new StringBuilder("M_Locator_ID=").append(p_M_Locator_ID).append(",MovementDate=").append(p_MovementDate);
|
||||||
|
log.info(msglog.toString());
|
||||||
|
|
||||||
if (p_UpdateCosting) {
|
if (p_UpdateCosting) {
|
||||||
if (p_C_AcctSchema_ID <= 0) {
|
if (p_C_AcctSchema_ID <= 0) {
|
||||||
|
@ -130,174 +131,174 @@ public class ImportInventory extends SvrProcess
|
||||||
acctSchema = MAcctSchema.get(getCtx(), p_C_AcctSchema_ID, get_TrxName());
|
acctSchema = MAcctSchema.get(getCtx(), p_C_AcctSchema_ID, get_TrxName());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + p_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(p_AD_Client_ID);
|
||||||
|
|
||||||
// **** Prepare ****
|
// **** Prepare ****
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (p_DeleteOldImported)
|
if (p_DeleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_Inventory "
|
sql = new StringBuilder ("DELETE I_Inventory ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.fine("Delete Old Imported=" + no);
|
log.fine("Delete Old Imported=" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, Location, IsActive, Created/Updated
|
// Set Client, Org, Location, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append ("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append ("),")
|
||||||
+ " AD_Org_ID = DECODE (NVL(AD_Org_ID),0,").append (p_AD_Org_ID).append (",AD_Org_ID),");
|
.append(" AD_Org_ID = DECODE (NVL(AD_Org_ID),0,").append (p_AD_Org_ID).append (",AD_Org_ID),");
|
||||||
if (p_MovementDate != null)
|
if (p_MovementDate != null)
|
||||||
sql.append(" MovementDate = COALESCE (MovementDate,").append (DB.TO_DATE(p_MovementDate)).append ("),");
|
sql.append(" MovementDate = COALESCE (MovementDate,").append (DB.TO_DATE(p_MovementDate)).append ("),");
|
||||||
sql.append(" IsActive = COALESCE (IsActive, 'Y'),"
|
sql.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " M_Warehouse_ID = NULL," // reset
|
.append(" M_Warehouse_ID = NULL,") // reset
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.info ("Reset=" + no);
|
log.info ("Reset=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory o "
|
sql = new StringBuilder ("UPDATE I_Inventory o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Org=" + no);
|
log.warning ("Invalid Org=" + no);
|
||||||
|
|
||||||
// Document Type
|
// Document Type
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory i "
|
sql = new StringBuilder ("UPDATE I_Inventory i ")
|
||||||
+ "SET C_DocType_ID=(SELECT d.C_DocType_ID FROM C_DocType d"
|
.append("SET C_DocType_ID=(SELECT d.C_DocType_ID FROM C_DocType d")
|
||||||
+ " WHERE d.Name=i.DocTypeName AND d.DocBaseType='MMI' AND i.AD_Client_ID=d.AD_Client_ID) "
|
.append(" WHERE d.Name=i.DocTypeName AND d.DocBaseType='MMI' AND i.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL"
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set DocType=" + no);
|
log.fine("Set DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory i "
|
sql = new StringBuilder ("UPDATE I_Inventory i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocType, ' ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL"
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid DocType=" + no);
|
log.warning ("Invalid DocType=" + no);
|
||||||
|
|
||||||
// Locator
|
// Locator
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory i "
|
sql = new StringBuilder ("UPDATE I_Inventory i ")
|
||||||
+ "SET M_Locator_ID=(SELECT MAX(M_Locator_ID) FROM M_Locator l"
|
.append("SET M_Locator_ID=(SELECT MAX(M_Locator_ID) FROM M_Locator l")
|
||||||
+ " WHERE i.LocatorValue=l.Value AND i.AD_Client_ID=l.AD_Client_ID) "
|
.append(" WHERE i.LocatorValue=l.Value AND i.AD_Client_ID=l.AD_Client_ID) ")
|
||||||
+ "WHERE M_Locator_ID IS NULL AND LocatorValue IS NOT NULL"
|
.append("WHERE M_Locator_ID IS NULL AND LocatorValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.fine("Set Locator from Value =" + no);
|
log.fine("Set Locator from Value =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory i "
|
sql = new StringBuilder ("UPDATE I_Inventory i ")
|
||||||
+ "SET M_Locator_ID=(SELECT MAX(M_Locator_ID) FROM M_Locator l"
|
.append("SET M_Locator_ID=(SELECT MAX(M_Locator_ID) FROM M_Locator l")
|
||||||
+ " WHERE i.X=l.X AND i.Y=l.Y AND i.Z=l.Z AND i.AD_Client_ID=l.AD_Client_ID) "
|
.append(" WHERE i.X=l.X AND i.Y=l.Y AND i.Z=l.Z AND i.AD_Client_ID=l.AD_Client_ID) ")
|
||||||
+ "WHERE M_Locator_ID IS NULL AND X IS NOT NULL AND Y IS NOT NULL AND Z IS NOT NULL"
|
.append("WHERE M_Locator_ID IS NULL AND X IS NOT NULL AND Y IS NOT NULL AND Z IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.fine("Set Locator from X,Y,Z =" + no);
|
log.fine("Set Locator from X,Y,Z =" + no);
|
||||||
if (p_M_Locator_ID != 0)
|
if (p_M_Locator_ID != 0)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET M_Locator_ID = ").append (p_M_Locator_ID).append (
|
.append("SET M_Locator_ID = ").append (p_M_Locator_ID)
|
||||||
" WHERE M_Locator_ID IS NULL"
|
.append (" WHERE M_Locator_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.fine("Set Locator from Parameter=" + no);
|
log.fine("Set Locator from Parameter=" + no);
|
||||||
}
|
}
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Location, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Location, ' ")
|
||||||
+ "WHERE M_Locator_ID IS NULL"
|
.append("WHERE M_Locator_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No Location=" + no);
|
log.warning ("No Location=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Set M_Warehouse_ID
|
// Set M_Warehouse_ID
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory i "
|
sql = new StringBuilder ("UPDATE I_Inventory i ")
|
||||||
+ "SET M_Warehouse_ID=(SELECT M_Warehouse_ID FROM M_Locator l WHERE i.M_Locator_ID=l.M_Locator_ID) "
|
.append("SET M_Warehouse_ID=(SELECT M_Warehouse_ID FROM M_Locator l WHERE i.M_Locator_ID=l.M_Locator_ID) ")
|
||||||
+ "WHERE M_Locator_ID IS NOT NULL"
|
.append("WHERE M_Locator_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.fine("Set Warehouse from Locator =" + no);
|
log.fine("Set Warehouse from Locator =" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Warehouse, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Warehouse, ' ")
|
||||||
+ "WHERE M_Warehouse_ID IS NULL"
|
.append("WHERE M_Warehouse_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No Warehouse=" + no);
|
log.warning ("No Warehouse=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Product
|
// Product
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory i "
|
sql = new StringBuilder ("UPDATE I_Inventory i ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE i.Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND Value IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND Value IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.fine("Set Product from Value=" + no);
|
log.fine("Set Product from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory i "
|
sql = new StringBuilder ("UPDATE I_Inventory i ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE i.UPC=p.UPC AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.UPC=p.UPC AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND UPC IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND UPC IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
log.fine("Set Product from UPC=" + no);
|
log.fine("Set Product from UPC=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Product, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Product, ' ")
|
||||||
+ "WHERE M_Product_ID IS NULL"
|
.append("WHERE M_Product_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No Product=" + no);
|
log.warning ("No Product=" + no);
|
||||||
|
|
||||||
// Charge
|
// Charge
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory o "
|
sql = new StringBuilder ("UPDATE I_Inventory o ")
|
||||||
+ "SET C_Charge_ID=(SELECT C_Charge_ID FROM C_Charge p"
|
.append("SET C_Charge_ID=(SELECT C_Charge_ID FROM C_Charge p")
|
||||||
+ " WHERE o.ChargeName=p.Name AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.ChargeName=p.Name AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_Charge_ID IS NULL AND ChargeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_Charge_ID IS NULL AND ChargeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Charge=" + no);
|
log.fine("Set Charge=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Charge, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Charge, ' ")
|
||||||
+ "WHERE C_Charge_ID IS NULL AND (ChargeName IS NOT NULL)"
|
.append("WHERE C_Charge_ID IS NULL AND (ChargeName IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Charge=" + no);
|
log.warning ("Invalid Charge=" + no);
|
||||||
|
|
||||||
// No QtyCount or QtyInternalUse
|
// No QtyCount or QtyInternalUse
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Qty Count or Internal Use, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Qty Count or Internal Use, ' ")
|
||||||
+ "WHERE QtyCount IS NULL AND QtyInternalUse IS NULL"
|
.append("WHERE QtyCount IS NULL AND QtyInternalUse IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No QtyCount or QtyInternalUse=" + no);
|
log.warning ("No QtyCount or QtyInternalUse=" + no);
|
||||||
|
|
||||||
// Excluding quantities
|
// Excluding quantities
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Excluding quantities, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Excluding quantities, ' ")
|
||||||
+ "WHERE NVL(QtyInternalUse,0)<>0 AND (NVL(QtyCount,0)<>0 OR NVL(QtyBook,0)<>0) "
|
.append("WHERE NVL(QtyInternalUse,0)<>0 AND (NVL(QtyCount,0)<>0 OR NVL(QtyBook,0)<>0) ")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Excluding quantities=" + no);
|
log.warning ("Excluding quantities=" + no);
|
||||||
|
|
||||||
// Required charge for internal use
|
// Required charge for internal use
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Required charge, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Required charge, ' ")
|
||||||
+ "WHERE NVL(QtyInternalUse,0)<>0 AND NVL(C_Charge_ID,0)=0 "
|
.append("WHERE NVL(QtyInternalUse,0)<>0 AND NVL(C_Charge_ID,0)=0 ")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
no = DB.executeUpdate (sql.toString (), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Required charge=" + no);
|
log.warning ("Required charge=" + no);
|
||||||
|
@ -312,8 +313,8 @@ public class ImportInventory extends SvrProcess
|
||||||
int noInsertLine = 0;
|
int noInsertLine = 0;
|
||||||
|
|
||||||
// Go through Inventory Records
|
// Go through Inventory Records
|
||||||
sql = new StringBuffer ("SELECT * FROM I_Inventory "
|
sql = new StringBuilder ("SELECT * FROM I_Inventory ")
|
||||||
+ "WHERE I_IsImported='N'").append (clientCheck)
|
.append("WHERE I_IsImported='N'").append (clientCheck)
|
||||||
.append(" ORDER BY M_Warehouse_ID, TRUNC(MovementDate), I_Inventory_ID");
|
.append(" ORDER BY M_Warehouse_ID, TRUNC(MovementDate), I_Inventory_ID");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -415,9 +416,9 @@ public class ImportInventory extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_Inventory "
|
sql = new StringBuilder ("UPDATE I_Inventory ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
//
|
//
|
||||||
|
|
|
@ -86,282 +86,282 @@ public class ImportInvoice extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||||
|
|
||||||
// **** Prepare ****
|
// **** Prepare ****
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (m_deleteOldImported)
|
if (m_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_Invoice "
|
sql = new StringBuilder ("DELETE I_Invoice ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IsActive, Created/Updated
|
// Set Client, Org, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (m_AD_Client_ID).append ("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID,").append (m_AD_Client_ID).append ("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID,").append (m_AD_Org_ID).append ("),"
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID,").append (m_AD_Org_ID).append ("),")
|
||||||
+ " IsActive = COALESCE (IsActive, 'Y'),"
|
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info ("Reset=" + no);
|
log.info ("Reset=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Org=" + no);
|
log.warning ("Invalid Org=" + no);
|
||||||
|
|
||||||
// Document Type - PO - SO
|
// Document Type - PO - SO
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName"
|
.append("SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName")
|
||||||
+ " AND d.DocBaseType IN ('API','APC') AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType IN ('API','APC') AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set PO DocType=" + no);
|
log.fine("Set PO DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName"
|
.append("SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName")
|
||||||
+ " AND d.DocBaseType IN ('ARI','ARC') AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType IN ('ARI','ARC') AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set SO DocType=" + no);
|
log.fine("Set SO DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName"
|
.append("SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName")
|
||||||
+ " AND d.DocBaseType IN ('API','ARI','APC','ARC') AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType IN ('API','ARI','APC','ARC') AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
//+ "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
//+ "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set DocType=" + no);
|
log.fine("Set DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocTypeName, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocTypeName, ' ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL"
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid DocTypeName=" + no);
|
log.warning ("Invalid DocTypeName=" + no);
|
||||||
// DocType Default
|
// DocType Default
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'"
|
.append("SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'")
|
||||||
+ " AND d.DocBaseType='API' AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType='API' AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set PO Default DocType=" + no);
|
log.fine("Set PO Default DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'"
|
.append("SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'")
|
||||||
+ " AND d.DocBaseType='ARI' AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType='ARI' AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set SO Default DocType=" + no);
|
log.fine("Set SO Default DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'"
|
.append("SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'")
|
||||||
+ " AND d.DocBaseType IN('ARI','API') AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType IN('ARI','API') AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set Default DocType=" + no);
|
log.fine("Set Default DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No DocType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No DocType, ' ")
|
||||||
+ "WHERE C_DocType_ID IS NULL"
|
.append("WHERE C_DocType_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No DocType=" + no);
|
log.warning ("No DocType=" + no);
|
||||||
|
|
||||||
// Set IsSOTrx
|
// Set IsSOTrx
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o SET IsSOTrx='Y' "
|
sql = new StringBuilder ("UPDATE I_Invoice o SET IsSOTrx='Y' ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='ARI' AND o.AD_Client_ID=d.AD_Client_ID)"
|
.append("WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='ARI' AND o.AD_Client_ID=d.AD_Client_ID)")
|
||||||
+ " AND C_DocType_ID IS NOT NULL"
|
.append(" AND C_DocType_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsSOTrx=Y=" + no);
|
log.fine("Set IsSOTrx=Y=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o SET IsSOTrx='N' "
|
sql = new StringBuilder ("UPDATE I_Invoice o SET IsSOTrx='N' ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='API' AND o.AD_Client_ID=d.AD_Client_ID)"
|
.append("WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='API' AND o.AD_Client_ID=d.AD_Client_ID)")
|
||||||
+ " AND C_DocType_ID IS NOT NULL"
|
.append(" AND C_DocType_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsSOTrx=N=" + no);
|
log.fine("Set IsSOTrx=N=" + no);
|
||||||
|
|
||||||
// Price List
|
// Price List
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'"
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'")
|
||||||
+ " AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default Currency PriceList=" + no);
|
log.fine("Set Default Currency PriceList=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'"
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'")
|
||||||
+ " AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default PriceList=" + no);
|
log.fine("Set Default PriceList=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p "
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p ")
|
||||||
+ " WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Currency PriceList=" + no);
|
log.fine("Set Currency PriceList=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p "
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p ")
|
||||||
+ " WHERE p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PriceList=" + no);
|
log.fine("Set PriceList=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PriceList, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PriceList, ' ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL"
|
.append("WHERE M_PriceList_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("No PriceList=" + no);
|
log.warning("No PriceList=" + no);
|
||||||
|
|
||||||
// Payment Term
|
// Payment Term
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_PaymentTerm_ID=(SELECT C_PaymentTerm_ID FROM C_PaymentTerm p"
|
.append("SET C_PaymentTerm_ID=(SELECT C_PaymentTerm_ID FROM C_PaymentTerm p")
|
||||||
+ " WHERE o.PaymentTermValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.PaymentTermValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_PaymentTerm_ID IS NULL AND PaymentTermValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_PaymentTerm_ID IS NULL AND PaymentTermValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PaymentTerm=" + no);
|
log.fine("Set PaymentTerm=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_PaymentTerm_ID=(SELECT MAX(C_PaymentTerm_ID) FROM C_PaymentTerm p"
|
.append("SET C_PaymentTerm_ID=(SELECT MAX(C_PaymentTerm_ID) FROM C_PaymentTerm p")
|
||||||
+ " WHERE p.IsDefault='Y' AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE p.IsDefault='Y' AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_PaymentTerm_ID IS NULL AND o.PaymentTermValue IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_PaymentTerm_ID IS NULL AND o.PaymentTermValue IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default PaymentTerm=" + no);
|
log.fine("Set Default PaymentTerm=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PaymentTerm, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PaymentTerm, ' ")
|
||||||
+ "WHERE C_PaymentTerm_ID IS NULL"
|
.append("WHERE C_PaymentTerm_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No PaymentTerm=" + no);
|
log.warning ("No PaymentTerm=" + no);
|
||||||
|
|
||||||
// globalqss - Add project and activity
|
// globalqss - Add project and activity
|
||||||
// Project
|
// Project
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_Project_ID=(SELECT C_Project_ID FROM C_Project p"
|
.append("SET C_Project_ID=(SELECT C_Project_ID FROM C_Project p")
|
||||||
+ " WHERE o.ProjectValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.ProjectValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_Project_ID IS NULL AND ProjectValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_Project_ID IS NULL AND ProjectValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Project=" + no);
|
log.fine("Set Project=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Project, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Project, ' ")
|
||||||
+ "WHERE C_Project_ID IS NULL AND (ProjectValue IS NOT NULL)"
|
.append("WHERE C_Project_ID IS NULL AND (ProjectValue IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Project=" + no);
|
log.warning ("Invalid Project=" + no);
|
||||||
// Activity
|
// Activity
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_Activity_ID=(SELECT C_Activity_ID FROM C_Activity p"
|
.append("SET C_Activity_ID=(SELECT C_Activity_ID FROM C_Activity p")
|
||||||
+ " WHERE o.ActivityValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.ActivityValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_Activity_ID IS NULL AND ActivityValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_Activity_ID IS NULL AND ActivityValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Activity=" + no);
|
log.fine("Set Activity=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Activity, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Activity, ' ")
|
||||||
+ "WHERE C_Activity_ID IS NULL AND (ActivityValue IS NOT NULL)"
|
.append("WHERE C_Activity_ID IS NULL AND (ActivityValue IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Activity=" + no);
|
log.warning ("Invalid Activity=" + no);
|
||||||
// globalqss - add charge
|
// globalqss - add charge
|
||||||
// Charge
|
// Charge
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_Charge_ID=(SELECT C_Charge_ID FROM C_Charge p"
|
.append("SET C_Charge_ID=(SELECT C_Charge_ID FROM C_Charge p")
|
||||||
+ " WHERE o.ChargeName=p.Name AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.ChargeName=p.Name AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_Charge_ID IS NULL AND ChargeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_Charge_ID IS NULL AND ChargeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Charge=" + no);
|
log.fine("Set Charge=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Charge, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Charge, ' ")
|
||||||
+ "WHERE C_Charge_ID IS NULL AND (ChargeName IS NOT NULL)"
|
.append("WHERE C_Charge_ID IS NULL AND (ChargeName IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Charge=" + no);
|
log.warning ("Invalid Charge=" + no);
|
||||||
//
|
//
|
||||||
|
|
||||||
// BP from EMail
|
// BP from EMail
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u"
|
.append("SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u")
|
||||||
+ " WHERE o.EMail=u.EMail AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) "
|
.append(" WHERE o.EMail=u.EMail AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND EMail IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND EMail IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP from EMail=" + no);
|
log.fine("Set BP from EMail=" + no);
|
||||||
// BP from ContactName
|
// BP from ContactName
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u"
|
.append("SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u")
|
||||||
+ " WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) "
|
.append(" WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND ContactName IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND ContactName IS NOT NULL")
|
||||||
+ " AND EXISTS (SELECT Name FROM AD_User u WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL GROUP BY Name HAVING COUNT(*)=1)"
|
.append(" AND EXISTS (SELECT Name FROM AD_User u WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL GROUP BY Name HAVING COUNT(*)=1)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP from ContactName=" + no);
|
log.fine("Set BP from ContactName=" + no);
|
||||||
// BP from Value
|
// BP from Value
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp"
|
.append("SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp")
|
||||||
+ " WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID) "
|
.append(" WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP from Value=" + no);
|
log.fine("Set BP from Value=" + no);
|
||||||
// Default BP
|
// Default BP
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_BPartner_ID=(SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo c"
|
.append("SET C_BPartner_ID=(SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo c")
|
||||||
+ " WHERE o.AD_Client_ID=c.AD_Client_ID) "
|
.append(" WHERE o.AD_Client_ID=c.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NULL AND Name IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NULL AND Name IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default BP=" + no);
|
log.fine("Set Default BP=" + no);
|
||||||
|
|
||||||
// Existing Location ? Exact Match
|
// Existing Location ? Exact Match
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID"
|
.append("SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID")
|
||||||
+ " FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)"
|
.append(" FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)")
|
||||||
+ " WHERE o.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=o.AD_Client_ID"
|
.append(" WHERE o.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=o.AD_Client_ID")
|
||||||
+ " AND DUMP(o.Address1)=DUMP(l.Address1) AND DUMP(o.Address2)=DUMP(l.Address2)"
|
.append(" AND DUMP(o.Address1)=DUMP(l.Address1) AND DUMP(o.Address2)=DUMP(l.Address2)")
|
||||||
+ " AND DUMP(o.City)=DUMP(l.City) AND DUMP(o.Postal)=DUMP(l.Postal)"
|
.append(" AND DUMP(o.City)=DUMP(l.City) AND DUMP(o.Postal)=DUMP(l.Postal)")
|
||||||
+ " AND o.C_Region_ID=l.C_Region_ID AND o.C_Country_ID=l.C_Country_ID) "
|
.append(" AND o.C_Region_ID=l.C_Region_ID AND o.C_Country_ID=l.C_Country_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append (clientCheck);
|
.append(" AND I_IsImported='N'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Found Location=" + no);
|
log.fine("Found Location=" + no);
|
||||||
// Set Location from BPartner
|
// Set Location from BPartner
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_BPartner_Location_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l"
|
.append("SET C_BPartner_Location_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l")
|
||||||
+ " WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID"
|
.append(" WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID")
|
||||||
+ " AND ((l.IsBillTo='Y' AND o.IsSOTrx='Y') OR o.IsSOTrx='N')"
|
.append(" AND ((l.IsBillTo='Y' AND o.IsSOTrx='Y') OR o.IsSOTrx='N')")
|
||||||
+ ") "
|
.append(") ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP Location from BP=" + no);
|
log.fine("Set BP Location from BP=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BP Location, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BP Location, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No BP Location=" + no);
|
log.warning ("No BP Location=" + no);
|
||||||
|
@ -376,102 +376,102 @@ public class ImportInvoice extends SvrProcess
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Country Default=" + no);
|
log.fine("Set Country Default=" + no);
|
||||||
**/
|
**/
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c"
|
.append("SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c")
|
||||||
+ " WHERE o.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, o.AD_Client_ID)) "
|
.append(" WHERE o.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, o.AD_Client_ID)) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL AND CountryCode IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL AND CountryCode IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Country=" + no);
|
log.fine("Set Country=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Country=" + no);
|
log.warning ("Invalid Country=" + no);
|
||||||
|
|
||||||
// Set Region
|
// Set Region
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "Set RegionName=(SELECT MAX(Name) FROM C_Region r"
|
.append("Set RegionName=(SELECT MAX(Name) FROM C_Region r")
|
||||||
+ " WHERE r.IsDefault='Y' AND r.C_Country_ID=o.C_Country_ID"
|
.append(" WHERE r.IsDefault='Y' AND r.C_Country_ID=o.C_Country_ID")
|
||||||
+ " AND r.AD_Client_ID IN (0, o.AD_Client_ID)) "
|
.append(" AND r.AD_Client_ID IN (0, o.AD_Client_ID)) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Region Default=" + no);
|
log.fine("Set Region Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r"
|
.append("Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r")
|
||||||
+ " WHERE r.Name=o.RegionName AND r.C_Country_ID=o.C_Country_ID"
|
.append(" WHERE r.Name=o.RegionName AND r.C_Country_ID=o.C_Country_ID")
|
||||||
+ " AND r.AD_Client_ID IN (0, o.AD_Client_ID)) "
|
.append(" AND r.AD_Client_ID IN (0, o.AD_Client_ID)) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Region=" + no);
|
log.fine("Set Region=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL "
|
.append("WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL ")
|
||||||
+ " AND EXISTS (SELECT * FROM C_Country c"
|
.append(" AND EXISTS (SELECT * FROM C_Country c")
|
||||||
+ " WHERE c.C_Country_ID=o.C_Country_ID AND c.HasRegion='Y')"
|
.append(" WHERE c.C_Country_ID=o.C_Country_ID AND c.HasRegion='Y')")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Region=" + no);
|
log.warning ("Invalid Region=" + no);
|
||||||
|
|
||||||
// Product
|
// Product
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Product from Value=" + no);
|
log.fine("Set Product from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND UPC IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND UPC IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Product from UPC=" + no);
|
log.fine("Set Product from UPC=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND SKU IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND SKU IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Product fom SKU=" + no);
|
log.fine("Set Product fom SKU=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)"
|
.append("WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Product=" + no);
|
log.warning ("Invalid Product=" + no);
|
||||||
|
|
||||||
// globalqss - charge and product are exclusive
|
// globalqss - charge and product are exclusive
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Product and Charge, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Product and Charge, ' ")
|
||||||
+ "WHERE M_Product_ID IS NOT NULL AND C_Charge_ID IS NOT NULL "
|
.append("WHERE M_Product_ID IS NOT NULL AND C_Charge_ID IS NOT NULL ")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Product and Charge exclusive=" + no);
|
log.warning ("Invalid Product and Charge exclusive=" + no);
|
||||||
|
|
||||||
// Tax
|
// Tax
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice o "
|
sql = new StringBuilder ("UPDATE I_Invoice o ")
|
||||||
+ "SET C_Tax_ID=(SELECT MAX(C_Tax_ID) FROM C_Tax t"
|
.append("SET C_Tax_ID=(SELECT MAX(C_Tax_ID) FROM C_Tax t")
|
||||||
+ " WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID) "
|
.append(" WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID) ")
|
||||||
+ "WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL"
|
.append("WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Tax=" + no);
|
log.fine("Set Tax=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Tax, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Tax, ' ")
|
||||||
+ "WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL"
|
.append("WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Tax=" + no);
|
log.warning ("Invalid Tax=" + no);
|
||||||
|
@ -481,8 +481,8 @@ public class ImportInvoice extends SvrProcess
|
||||||
// -- New BPartner ---------------------------------------------------
|
// -- New BPartner ---------------------------------------------------
|
||||||
|
|
||||||
// Go through Invoice Records w/o C_BPartner_ID
|
// Go through Invoice Records w/o C_BPartner_ID
|
||||||
sql = new StringBuffer ("SELECT * FROM I_Invoice "
|
sql = new StringBuilder ("SELECT * FROM I_Invoice ")
|
||||||
+ "WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck);
|
.append("WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||||
|
@ -601,10 +601,10 @@ public class ImportInvoice extends SvrProcess
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "CreateBP", e);
|
log.log(Level.SEVERE, "CreateBP", e);
|
||||||
}
|
}
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No BPartner=" + no);
|
log.warning ("No BPartner=" + no);
|
||||||
|
@ -617,8 +617,8 @@ public class ImportInvoice extends SvrProcess
|
||||||
int noInsertLine = 0;
|
int noInsertLine = 0;
|
||||||
|
|
||||||
// Go through Invoice Records w/o
|
// Go through Invoice Records w/o
|
||||||
sql = new StringBuffer ("SELECT * FROM I_Invoice "
|
sql = new StringBuilder ("SELECT * FROM I_Invoice ")
|
||||||
+ "WHERE I_IsImported='N'").append (clientCheck)
|
.append("WHERE I_IsImported='N'").append (clientCheck)
|
||||||
.append(" ORDER BY C_BPartner_ID, C_BPartner_Location_ID, I_Invoice_ID");
|
.append(" ORDER BY C_BPartner_ID, C_BPartner_Location_ID, I_Invoice_ID");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -760,9 +760,9 @@ public class ImportInvoice extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_Invoice "
|
sql = new StringBuilder ("UPDATE I_Invoice ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
//
|
//
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class ImportOrder extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID;
|
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID;
|
||||||
|
|
||||||
|
@ -97,272 +97,272 @@ public class ImportOrder extends SvrProcess
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (m_deleteOldImported)
|
if (m_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_Order "
|
sql = new StringBuilder ("DELETE I_Order ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IsActive, Created/Updated
|
// Set Client, Org, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (m_AD_Client_ID).append ("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID,").append (m_AD_Client_ID).append ("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID,").append (m_AD_Org_ID).append ("),"
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID,").append (m_AD_Org_ID).append ("),")
|
||||||
+ " IsActive = COALESCE (IsActive, 'Y'),"
|
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info ("Reset=" + no);
|
log.info ("Reset=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Org=" + no);
|
log.warning ("Invalid Org=" + no);
|
||||||
|
|
||||||
// Document Type - PO - SO
|
// Document Type - PO - SO
|
||||||
sql = new StringBuffer ("UPDATE I_Order o " // PO Document Type Name
|
sql = new StringBuilder ("UPDATE I_Order o ") // PO Document Type Name
|
||||||
+ "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName"
|
.append("SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName")
|
||||||
+ " AND d.DocBaseType='POO' AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType='POO' AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PO DocType=" + no);
|
log.fine("Set PO DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o " // SO Document Type Name
|
sql = new StringBuilder ("UPDATE I_Order o ") // SO Document Type Name
|
||||||
+ "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName"
|
.append("SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName")
|
||||||
+ " AND d.DocBaseType='SOO' AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType='SOO' AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set SO DocType=" + no);
|
log.fine("Set SO DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName"
|
.append("SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=o.DocTypeName")
|
||||||
+ " AND d.DocBaseType IN ('SOO','POO') AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType IN ('SOO','POO') AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
//+ "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
//+ "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set DocType=" + no);
|
log.fine("Set DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order " // Error Invalid Doc Type Name
|
sql = new StringBuilder ("UPDATE I_Order ") // Error Invalid Doc Type Name
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocTypeName, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocTypeName, ' ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL"
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid DocTypeName=" + no);
|
log.warning ("Invalid DocTypeName=" + no);
|
||||||
// DocType Default
|
// DocType Default
|
||||||
sql = new StringBuffer ("UPDATE I_Order o " // Default PO
|
sql = new StringBuilder ("UPDATE I_Order o ") // Default PO
|
||||||
+ "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'"
|
.append("SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'")
|
||||||
+ " AND d.DocBaseType='POO' AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType='POO' AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PO Default DocType=" + no);
|
log.fine("Set PO Default DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o " // Default SO
|
sql = new StringBuilder ("UPDATE I_Order o ") // Default SO
|
||||||
+ "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'"
|
.append("SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'")
|
||||||
+ " AND d.DocBaseType='SOO' AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType='SOO' AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set SO Default DocType=" + no);
|
log.fine("Set SO Default DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'"
|
.append("SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'")
|
||||||
+ " AND d.DocBaseType IN('SOO','POO') AND o.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType IN('SOO','POO') AND o.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default DocType=" + no);
|
log.fine("Set Default DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order " // No DocType
|
sql = new StringBuilder ("UPDATE I_Order ") // No DocType
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No DocType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No DocType, ' ")
|
||||||
+ "WHERE C_DocType_ID IS NULL"
|
.append("WHERE C_DocType_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No DocType=" + no);
|
log.warning ("No DocType=" + no);
|
||||||
|
|
||||||
// Set IsSOTrx
|
// Set IsSOTrx
|
||||||
sql = new StringBuffer ("UPDATE I_Order o SET IsSOTrx='Y' "
|
sql = new StringBuilder ("UPDATE I_Order o SET IsSOTrx='Y' ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='SOO' AND o.AD_Client_ID=d.AD_Client_ID)"
|
.append("WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='SOO' AND o.AD_Client_ID=d.AD_Client_ID)")
|
||||||
+ " AND C_DocType_ID IS NOT NULL"
|
.append(" AND C_DocType_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsSOTrx=Y=" + no);
|
log.fine("Set IsSOTrx=Y=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o SET IsSOTrx='N' "
|
sql = new StringBuilder ("UPDATE I_Order o SET IsSOTrx='N' ")
|
||||||
+ "WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='POO' AND o.AD_Client_ID=d.AD_Client_ID)"
|
.append("WHERE EXISTS (SELECT * FROM C_DocType d WHERE o.C_DocType_ID=d.C_DocType_ID AND d.DocBaseType='POO' AND o.AD_Client_ID=d.AD_Client_ID)")
|
||||||
+ " AND C_DocType_ID IS NOT NULL"
|
.append(" AND C_DocType_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsSOTrx=N=" + no);
|
log.fine("Set IsSOTrx=N=" + no);
|
||||||
|
|
||||||
// Price List
|
// Price List
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'"
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'")
|
||||||
+ " AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default Currency PriceList=" + no);
|
log.fine("Set Default Currency PriceList=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'"
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'")
|
||||||
+ " AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default PriceList=" + no);
|
log.fine("Set Default PriceList=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p "
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p ")
|
||||||
+ " WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Currency PriceList=" + no);
|
log.fine("Set Currency PriceList=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p "
|
.append("SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p ")
|
||||||
+ " WHERE p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PriceList=" + no);
|
log.fine("Set PriceList=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PriceList, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PriceList, ' ")
|
||||||
+ "WHERE M_PriceList_ID IS NULL"
|
.append("WHERE M_PriceList_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("No PriceList=" + no);
|
log.warning("No PriceList=" + no);
|
||||||
|
|
||||||
// @Trifon - Import Order Source
|
// @Trifon - Import Order Source
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_OrderSource_ID=(SELECT C_OrderSource_ID FROM C_OrderSource p"
|
.append("SET C_OrderSource_ID=(SELECT C_OrderSource_ID FROM C_OrderSource p")
|
||||||
+ " WHERE o.C_OrderSourceValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.C_OrderSourceValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_OrderSource_ID IS NULL AND C_OrderSourceValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_OrderSource_ID IS NULL AND C_OrderSourceValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Order Source=" + no);
|
log.fine("Set Order Source=" + no);
|
||||||
// Set proper error message
|
// Set proper error message
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Not Found Order Source, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Not Found Order Source, ' ")
|
||||||
+ "WHERE C_OrderSource_ID IS NULL AND C_OrderSourceValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_OrderSource_ID IS NULL AND C_OrderSourceValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("No OrderSource=" + no);
|
log.warning("No OrderSource=" + no);
|
||||||
|
|
||||||
// Payment Term
|
// Payment Term
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_PaymentTerm_ID=(SELECT C_PaymentTerm_ID FROM C_PaymentTerm p"
|
.append("SET C_PaymentTerm_ID=(SELECT C_PaymentTerm_ID FROM C_PaymentTerm p")
|
||||||
+ " WHERE o.PaymentTermValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.PaymentTermValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_PaymentTerm_ID IS NULL AND PaymentTermValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_PaymentTerm_ID IS NULL AND PaymentTermValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PaymentTerm=" + no);
|
log.fine("Set PaymentTerm=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_PaymentTerm_ID=(SELECT MAX(C_PaymentTerm_ID) FROM C_PaymentTerm p"
|
.append("SET C_PaymentTerm_ID=(SELECT MAX(C_PaymentTerm_ID) FROM C_PaymentTerm p")
|
||||||
+ " WHERE p.IsDefault='Y' AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE p.IsDefault='Y' AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_PaymentTerm_ID IS NULL AND o.PaymentTermValue IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_PaymentTerm_ID IS NULL AND o.PaymentTermValue IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default PaymentTerm=" + no);
|
log.fine("Set Default PaymentTerm=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PaymentTerm, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No PaymentTerm, ' ")
|
||||||
+ "WHERE C_PaymentTerm_ID IS NULL"
|
.append("WHERE C_PaymentTerm_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No PaymentTerm=" + no);
|
log.warning ("No PaymentTerm=" + no);
|
||||||
|
|
||||||
// Warehouse
|
// Warehouse
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_Warehouse_ID=(SELECT MAX(M_Warehouse_ID) FROM M_Warehouse w"
|
.append("SET M_Warehouse_ID=(SELECT MAX(M_Warehouse_ID) FROM M_Warehouse w")
|
||||||
+ " WHERE o.AD_Client_ID=w.AD_Client_ID AND o.AD_Org_ID=w.AD_Org_ID) "
|
.append(" WHERE o.AD_Client_ID=w.AD_Client_ID AND o.AD_Org_ID=w.AD_Org_ID) ")
|
||||||
+ "WHERE M_Warehouse_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE M_Warehouse_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName()); // Warehouse for Org
|
no = DB.executeUpdate(sql.toString(), get_TrxName()); // Warehouse for Org
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set Warehouse=" + no);
|
log.fine("Set Warehouse=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_Warehouse_ID=(SELECT M_Warehouse_ID FROM M_Warehouse w"
|
.append("SET M_Warehouse_ID=(SELECT M_Warehouse_ID FROM M_Warehouse w")
|
||||||
+ " WHERE o.AD_Client_ID=w.AD_Client_ID) "
|
.append(" WHERE o.AD_Client_ID=w.AD_Client_ID) ")
|
||||||
+ "WHERE M_Warehouse_ID IS NULL"
|
.append("WHERE M_Warehouse_ID IS NULL")
|
||||||
+ " AND EXISTS (SELECT AD_Client_ID FROM M_Warehouse w WHERE w.AD_Client_ID=o.AD_Client_ID GROUP BY AD_Client_ID HAVING COUNT(*)=1)"
|
.append(" AND EXISTS (SELECT AD_Client_ID FROM M_Warehouse w WHERE w.AD_Client_ID=o.AD_Client_ID GROUP BY AD_Client_ID HAVING COUNT(*)=1)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set Only Client Warehouse=" + no);
|
log.fine("Set Only Client Warehouse=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Warehouse, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Warehouse, ' ")
|
||||||
+ "WHERE M_Warehouse_ID IS NULL"
|
.append("WHERE M_Warehouse_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No Warehouse=" + no);
|
log.warning ("No Warehouse=" + no);
|
||||||
|
|
||||||
// BP from EMail
|
// BP from EMail
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u"
|
.append("SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u")
|
||||||
+ " WHERE o.EMail=u.EMail AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) "
|
.append(" WHERE o.EMail=u.EMail AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND EMail IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND EMail IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP from EMail=" + no);
|
log.fine("Set BP from EMail=" + no);
|
||||||
// BP from ContactName
|
// BP from ContactName
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u"
|
.append("SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u")
|
||||||
+ " WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) "
|
.append(" WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND ContactName IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND ContactName IS NOT NULL")
|
||||||
+ " AND EXISTS (SELECT Name FROM AD_User u WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL GROUP BY Name HAVING COUNT(*)=1)"
|
.append(" AND EXISTS (SELECT Name FROM AD_User u WHERE o.ContactName=u.Name AND o.AD_Client_ID=u.AD_Client_ID AND u.C_BPartner_ID IS NOT NULL GROUP BY Name HAVING COUNT(*)=1)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP from ContactName=" + no);
|
log.fine("Set BP from ContactName=" + no);
|
||||||
// BP from Value
|
// BP from Value
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp"
|
.append("SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp")
|
||||||
+ " WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID) "
|
.append(" WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP from Value=" + no);
|
log.fine("Set BP from Value=" + no);
|
||||||
// Default BP
|
// Default BP
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_BPartner_ID=(SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo c"
|
.append("SET C_BPartner_ID=(SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo c")
|
||||||
+ " WHERE o.AD_Client_ID=c.AD_Client_ID) "
|
.append(" WHERE o.AD_Client_ID=c.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NULL AND Name IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NULL AND Name IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Default BP=" + no);
|
log.fine("Set Default BP=" + no);
|
||||||
|
|
||||||
// Existing Location ? Exact Match
|
// Existing Location ? Exact Match
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET (BillTo_ID,C_BPartner_Location_ID)=(SELECT C_BPartner_Location_ID,C_BPartner_Location_ID"
|
.append("SET (BillTo_ID,C_BPartner_Location_ID)=(SELECT C_BPartner_Location_ID,C_BPartner_Location_ID")
|
||||||
+ " FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)"
|
.append(" FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)")
|
||||||
+ " WHERE o.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=o.AD_Client_ID"
|
.append(" WHERE o.C_BPartner_ID=bpl.C_BPartner_ID AND bpl.AD_Client_ID=o.AD_Client_ID")
|
||||||
+ " AND DUMP(o.Address1)=DUMP(l.Address1) AND DUMP(o.Address2)=DUMP(l.Address2)"
|
.append(" AND DUMP(o.Address1)=DUMP(l.Address1) AND DUMP(o.Address2)=DUMP(l.Address2)")
|
||||||
+ " AND DUMP(o.City)=DUMP(l.City) AND DUMP(o.Postal)=DUMP(l.Postal)"
|
.append(" AND DUMP(o.City)=DUMP(l.City) AND DUMP(o.Postal)=DUMP(l.Postal)")
|
||||||
+ " AND o.C_Region_ID=l.C_Region_ID AND o.C_Country_ID=l.C_Country_ID) "
|
.append(" AND o.C_Region_ID=l.C_Region_ID AND o.C_Country_ID=l.C_Country_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append (clientCheck);
|
.append(" AND I_IsImported='N'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Found Location=" + no);
|
log.fine("Found Location=" + no);
|
||||||
// Set Bill Location from BPartner
|
// Set Bill Location from BPartner
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET BillTo_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l"
|
.append("SET BillTo_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l")
|
||||||
+ " WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID"
|
.append(" WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID")
|
||||||
+ " AND ((l.IsBillTo='Y' AND o.IsSOTrx='Y') OR (l.IsPayFrom='Y' AND o.IsSOTrx='N'))"
|
.append(" AND ((l.IsBillTo='Y' AND o.IsSOTrx='Y') OR (l.IsPayFrom='Y' AND o.IsSOTrx='N'))")
|
||||||
+ ") "
|
.append(") ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND BillTo_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND BillTo_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP BillTo from BP=" + no);
|
log.fine("Set BP BillTo from BP=" + no);
|
||||||
// Set Location from BPartner
|
// Set Location from BPartner
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_BPartner_Location_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l"
|
.append("SET C_BPartner_Location_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l")
|
||||||
+ " WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID"
|
.append(" WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID")
|
||||||
+ " AND ((l.IsShipTo='Y' AND o.IsSOTrx='Y') OR o.IsSOTrx='N')"
|
.append(" AND ((l.IsShipTo='Y' AND o.IsSOTrx='Y') OR o.IsSOTrx='N')")
|
||||||
+ ") "
|
.append(") ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set BP Location from BP=" + no);
|
log.fine("Set BP Location from BP=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BP Location, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BP Location, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND (BillTo_ID IS NULL OR C_BPartner_Location_ID IS NULL)"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND (BillTo_ID IS NULL OR C_BPartner_Location_ID IS NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No BP Location=" + no);
|
log.warning ("No BP Location=" + no);
|
||||||
|
@ -377,117 +377,117 @@ public class ImportOrder extends SvrProcess
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Country Default=" + no);
|
log.fine("Set Country Default=" + no);
|
||||||
**/
|
**/
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c"
|
.append("SET C_Country_ID=(SELECT C_Country_ID FROM C_Country c")
|
||||||
+ " WHERE o.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, o.AD_Client_ID)) "
|
.append(" WHERE o.CountryCode=c.CountryCode AND c.AD_Client_ID IN (0, o.AD_Client_ID)) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL AND CountryCode IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL AND CountryCode IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Country=" + no);
|
log.fine("Set Country=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Country_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Country=" + no);
|
log.warning ("Invalid Country=" + no);
|
||||||
|
|
||||||
// Set Region
|
// Set Region
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "Set RegionName=(SELECT MAX(Name) FROM C_Region r"
|
.append("Set RegionName=(SELECT MAX(Name) FROM C_Region r")
|
||||||
+ " WHERE r.IsDefault='Y' AND r.C_Country_ID=o.C_Country_ID"
|
.append(" WHERE r.IsDefault='Y' AND r.C_Country_ID=o.C_Country_ID")
|
||||||
+ " AND r.AD_Client_ID IN (0, o.AD_Client_ID)) "
|
.append(" AND r.AD_Client_ID IN (0, o.AD_Client_ID)) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Region Default=" + no);
|
log.fine("Set Region Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r"
|
.append("Set C_Region_ID=(SELECT C_Region_ID FROM C_Region r")
|
||||||
+ " WHERE r.Name=o.RegionName AND r.C_Country_ID=o.C_Country_ID"
|
.append(" WHERE r.Name=o.RegionName AND r.C_Country_ID=o.C_Country_ID")
|
||||||
+ " AND r.AD_Client_ID IN (0, o.AD_Client_ID)) "
|
.append(" AND r.AD_Client_ID IN (0, o.AD_Client_ID)) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Region=" + no);
|
log.fine("Set Region=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL "
|
.append("WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL ")
|
||||||
+ " AND EXISTS (SELECT * FROM C_Country c"
|
.append(" AND EXISTS (SELECT * FROM C_Country c")
|
||||||
+ " WHERE c.C_Country_ID=o.C_Country_ID AND c.HasRegion='Y')"
|
.append(" WHERE c.C_Country_ID=o.C_Country_ID AND c.HasRegion='Y')")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Region=" + no);
|
log.warning ("Invalid Region=" + no);
|
||||||
|
|
||||||
// Product
|
// Product
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Product from Value=" + no);
|
log.fine("Set Product from Value=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND UPC IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND UPC IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Product from UPC=" + no);
|
log.fine("Set Product from UPC=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
|
||||||
+ " WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND SKU IS NOT NULL"
|
.append("WHERE M_Product_ID IS NULL AND SKU IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Product fom SKU=" + no);
|
log.fine("Set Product fom SKU=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' ")
|
||||||
+ "WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)"
|
.append("WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Product=" + no);
|
log.warning ("Invalid Product=" + no);
|
||||||
|
|
||||||
// Charge
|
// Charge
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_Charge_ID=(SELECT C_Charge_ID FROM C_Charge c"
|
.append("SET C_Charge_ID=(SELECT C_Charge_ID FROM C_Charge c")
|
||||||
+ " WHERE o.ChargeName=c.Name AND o.AD_Client_ID=c.AD_Client_ID) "
|
.append(" WHERE o.ChargeName=c.Name AND o.AD_Client_ID=c.AD_Client_ID) ")
|
||||||
+ "WHERE C_Charge_ID IS NULL AND ChargeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_Charge_ID IS NULL AND ChargeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Charge=" + no);
|
log.fine("Set Charge=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Charge, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Charge, ' ")
|
||||||
+ "WHERE C_Charge_ID IS NULL AND (ChargeName IS NOT NULL)"
|
.append("WHERE C_Charge_ID IS NULL AND (ChargeName IS NOT NULL)")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Charge=" + no);
|
log.warning ("Invalid Charge=" + no);
|
||||||
//
|
//
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Product and Charge, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Product and Charge, ' ")
|
||||||
+ "WHERE M_Product_ID IS NOT NULL AND C_Charge_ID IS NOT NULL "
|
.append("WHERE M_Product_ID IS NOT NULL AND C_Charge_ID IS NOT NULL ")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Product and Charge exclusive=" + no);
|
log.warning ("Invalid Product and Charge exclusive=" + no);
|
||||||
|
|
||||||
// Tax
|
// Tax
|
||||||
sql = new StringBuffer ("UPDATE I_Order o "
|
sql = new StringBuilder ("UPDATE I_Order o ")
|
||||||
+ "SET C_Tax_ID=(SELECT MAX(C_Tax_ID) FROM C_Tax t"
|
.append("SET C_Tax_ID=(SELECT MAX(C_Tax_ID) FROM C_Tax t")
|
||||||
+ " WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID) "
|
.append(" WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID) ")
|
||||||
+ "WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL"
|
.append("WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Tax=" + no);
|
log.fine("Set Tax=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Tax, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Tax, ' ")
|
||||||
+ "WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL"
|
.append("WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Tax=" + no);
|
log.warning ("Invalid Tax=" + no);
|
||||||
|
@ -497,8 +497,8 @@ public class ImportOrder extends SvrProcess
|
||||||
// -- New BPartner ---------------------------------------------------
|
// -- New BPartner ---------------------------------------------------
|
||||||
|
|
||||||
// Go through Order Records w/o C_BPartner_ID
|
// Go through Order Records w/o C_BPartner_ID
|
||||||
sql = new StringBuffer ("SELECT * FROM I_Order "
|
sql = new StringBuilder ("SELECT * FROM I_Order ")
|
||||||
+ "WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck);
|
.append("WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||||
|
@ -618,10 +618,10 @@ public class ImportOrder extends SvrProcess
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "BP - " + sql.toString(), e);
|
log.log(Level.SEVERE, "BP - " + sql.toString(), e);
|
||||||
}
|
}
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No BPartner=" + no);
|
log.warning ("No BPartner=" + no);
|
||||||
|
@ -634,8 +634,8 @@ public class ImportOrder extends SvrProcess
|
||||||
int noInsertLine = 0;
|
int noInsertLine = 0;
|
||||||
|
|
||||||
// Go through Order Records w/o
|
// Go through Order Records w/o
|
||||||
sql = new StringBuffer ("SELECT * FROM I_Order "
|
sql = new StringBuilder ("SELECT * FROM I_Order ")
|
||||||
+ "WHERE I_IsImported='N'").append (clientCheck)
|
.append("WHERE I_IsImported='N'").append (clientCheck)
|
||||||
.append(" ORDER BY C_BPartner_ID, BillTo_ID, C_BPartner_Location_ID, I_Order_ID");
|
.append(" ORDER BY C_BPartner_ID, BillTo_ID, C_BPartner_Location_ID, I_Order_ID");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -788,15 +788,16 @@ public class ImportOrder extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_Order "
|
sql = new StringBuilder ("UPDATE I_Order ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
//
|
//
|
||||||
addLog (0, null, new BigDecimal (noInsert), "@C_Order_ID@: @Inserted@");
|
addLog (0, null, new BigDecimal (noInsert), "@C_Order_ID@: @Inserted@");
|
||||||
addLog (0, null, new BigDecimal (noInsertLine), "@C_OrderLine_ID@: @Inserted@");
|
addLog (0, null, new BigDecimal (noInsertLine), "@C_OrderLine_ID@: @Inserted@");
|
||||||
return "#" + noInsert + "/" + noInsertLine;
|
StringBuilder msgreturn = new StringBuilder("#").append(noInsert).append("/").append(noInsertLine);
|
||||||
|
return msgreturn.toString();
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
} // ImportOrder
|
} // ImportOrder
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class ImportPayment extends SvrProcess
|
||||||
p_AD_Org_ID = ba.getAD_Org_ID();
|
p_AD_Org_ID = ba.getAD_Org_ID();
|
||||||
log.info("AD_Org_ID=" + p_AD_Org_ID);
|
log.info("AD_Org_ID=" + p_AD_Org_ID);
|
||||||
|
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + ba.getAD_Client_ID();
|
String clientCheck = " AND AD_Client_ID=" + ba.getAD_Client_ID();
|
||||||
|
|
||||||
|
@ -99,307 +99,307 @@ public class ImportPayment extends SvrProcess
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (p_deleteOldImported)
|
if (p_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_Payment "
|
sql = new StringBuilder ("DELETE I_Payment ")
|
||||||
+ "WHERE I_IsImported='Y'").append (clientCheck);
|
.append("WHERE I_IsImported='Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IsActive, Created/Updated
|
// Set Client, Org, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_Payment "
|
sql = new StringBuilder ("UPDATE I_Payment ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (ba.getAD_Client_ID()).append ("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID,").append (ba.getAD_Client_ID()).append ("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID,").append (p_AD_Org_ID).append ("),");
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID,").append (p_AD_Org_ID).append ("),");
|
||||||
sql.append(" IsActive = COALESCE (IsActive, 'Y'),"
|
sql.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL OR AD_Client_ID IS NULL OR AD_Org_ID IS NULL OR AD_Client_ID=0 OR AD_Org_ID=0");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL OR AD_Client_ID IS NULL OR AD_Org_ID IS NULL OR AD_Client_ID=0 OR AD_Org_ID=0");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info ("Reset=" + no);
|
log.info ("Reset=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_Payment o "
|
sql = new StringBuilder ("UPDATE I_Payment o ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '"
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
|
||||||
+ "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0"
|
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0")
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))"
|
.append(" OR EXISTS (SELECT * FROM AD_Org oo WHERE o.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid Org=" + no);
|
log.warning ("Invalid Org=" + no);
|
||||||
|
|
||||||
// Set Bank Account
|
// Set Bank Account
|
||||||
sql = new StringBuffer("UPDATE I_Payment i "
|
sql = new StringBuilder("UPDATE I_Payment i ")
|
||||||
+ "SET C_BankAccount_ID="
|
.append("SET C_BankAccount_ID=")
|
||||||
+ "( "
|
.append("( ")
|
||||||
+ " SELECT C_BankAccount_ID "
|
.append(" SELECT C_BankAccount_ID ")
|
||||||
+ " FROM C_BankAccount a, C_Bank b "
|
.append(" FROM C_BankAccount a, C_Bank b ")
|
||||||
+ " WHERE b.IsOwnBank='Y' "
|
.append(" WHERE b.IsOwnBank='Y' ")
|
||||||
+ " AND a.AD_Client_ID=i.AD_Client_ID "
|
.append(" AND a.AD_Client_ID=i.AD_Client_ID ")
|
||||||
+ " AND a.C_Bank_ID=b.C_Bank_ID "
|
.append(" AND a.C_Bank_ID=b.C_Bank_ID ")
|
||||||
+ " AND a.AccountNo=i.BankAccountNo "
|
.append(" AND a.AccountNo=i.BankAccountNo ")
|
||||||
+ " AND b.RoutingNo=i.RoutingNo "
|
.append(" AND b.RoutingNo=i.RoutingNo ")
|
||||||
+ " OR b.SwiftCode=i.RoutingNo "
|
.append(" OR b.SwiftCode=i.RoutingNo ")
|
||||||
+ ") "
|
.append(") ")
|
||||||
+ "WHERE i.C_BankAccount_ID IS NULL "
|
.append("WHERE i.C_BankAccount_ID IS NULL ")
|
||||||
+ "AND i.I_IsImported<>'Y' "
|
.append("AND i.I_IsImported<>'Y' ")
|
||||||
+ "OR i.I_IsImported IS NULL").append(clientCheck);
|
.append("OR i.I_IsImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Bank Account (With Routing No)=" + no);
|
log.info("Bank Account (With Routing No)=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_Payment i "
|
sql = new StringBuilder("UPDATE I_Payment i ")
|
||||||
+ "SET C_BankAccount_ID="
|
.append("SET C_BankAccount_ID=")
|
||||||
+ "( "
|
.append("( ")
|
||||||
+ " SELECT C_BankAccount_ID "
|
.append(" SELECT C_BankAccount_ID ")
|
||||||
+ " FROM C_BankAccount a, C_Bank b "
|
.append(" FROM C_BankAccount a, C_Bank b ")
|
||||||
+ " WHERE b.IsOwnBank='Y' "
|
.append(" WHERE b.IsOwnBank='Y' ")
|
||||||
+ " AND a.C_Bank_ID=b.C_Bank_ID "
|
.append(" AND a.C_Bank_ID=b.C_Bank_ID ")
|
||||||
+ " AND a.AccountNo=i.BankAccountNo "
|
.append(" AND a.AccountNo=i.BankAccountNo ")
|
||||||
+ " AND a.AD_Client_ID=i.AD_Client_ID "
|
.append(" AND a.AD_Client_ID=i.AD_Client_ID ")
|
||||||
+ ") "
|
.append(") ")
|
||||||
+ "WHERE i.C_BankAccount_ID IS NULL "
|
.append("WHERE i.C_BankAccount_ID IS NULL ")
|
||||||
+ "AND i.I_isImported<>'Y' "
|
.append("AND i.I_isImported<>'Y' ")
|
||||||
+ "OR i.I_isImported IS NULL").append(clientCheck);
|
.append("OR i.I_isImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Bank Account (Without Routing No)=" + no);
|
log.info("Bank Account (Without Routing No)=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_Payment i "
|
sql = new StringBuilder("UPDATE I_Payment i ")
|
||||||
+ "SET C_BankAccount_ID=(SELECT C_BankAccount_ID FROM C_BankAccount a WHERE a.C_BankAccount_ID=").append(p_C_BankAccount_ID);
|
.append("SET C_BankAccount_ID=(SELECT C_BankAccount_ID FROM C_BankAccount a WHERE a.C_BankAccount_ID=").append(p_C_BankAccount_ID);
|
||||||
sql.append(" and a.AD_Client_ID=i.AD_Client_ID) "
|
sql.append(" and a.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE i.C_BankAccount_ID IS NULL "
|
.append("WHERE i.C_BankAccount_ID IS NULL ")
|
||||||
+ "AND i.BankAccountNo IS NULL "
|
.append("AND i.BankAccountNo IS NULL ")
|
||||||
+ "AND i.I_isImported<>'Y' "
|
.append("AND i.I_isImported<>'Y' ")
|
||||||
+ "OR i.I_isImported IS NULL").append(clientCheck);
|
.append("OR i.I_isImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Bank Account=" + no);
|
log.info("Bank Account=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET I_isImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Bank Account, ' "
|
.append("SET I_isImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Bank Account, ' ")
|
||||||
+ "WHERE C_BankAccount_ID IS NULL "
|
.append("WHERE C_BankAccount_ID IS NULL ")
|
||||||
+ "AND I_isImported<>'Y' "
|
.append("AND I_isImported<>'Y' ")
|
||||||
+ "OR I_isImported IS NULL").append(clientCheck);
|
.append("OR I_isImported IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid Bank Account=" + no);
|
log.warning("Invalid Bank Account=" + no);
|
||||||
|
|
||||||
// Set Currency
|
// Set Currency
|
||||||
sql = new StringBuffer ("UPDATE I_Payment i "
|
sql = new StringBuilder ("UPDATE I_Payment i ")
|
||||||
+ "SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c"
|
.append("SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c")
|
||||||
+ " WHERE i.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) "
|
.append(" WHERE i.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_Currency_ID IS NULL"
|
.append("WHERE C_Currency_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Set Currency=" + no);
|
log.info("Set Currency=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_Payment i "
|
sql = new StringBuilder("UPDATE I_Payment i ")
|
||||||
+ "SET C_Currency_ID=(SELECT C_Currency_ID FROM C_BankAccount WHERE C_BankAccount_ID=i.C_BankAccount_ID) "
|
.append("SET C_Currency_ID=(SELECT C_Currency_ID FROM C_BankAccount WHERE C_BankAccount_ID=i.C_BankAccount_ID) ")
|
||||||
+ "WHERE i.C_Currency_ID IS NULL "
|
.append("WHERE i.C_Currency_ID IS NULL ")
|
||||||
+ "AND i.ISO_Code IS NULL").append(clientCheck);
|
.append("AND i.ISO_Code IS NULL").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Set Currency=" + no);
|
log.info("Set Currency=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Payment "
|
sql = new StringBuilder ("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Currency,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Currency,' ")
|
||||||
+ "WHERE C_Currency_ID IS NULL "
|
.append("WHERE C_Currency_ID IS NULL ")
|
||||||
+ "AND I_IsImported<>'E' "
|
.append("AND I_IsImported<>'E' ")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("No Currency=" + no);
|
log.warning("No Currency=" + no);
|
||||||
|
|
||||||
// Set Amount
|
// Set Amount
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET ChargeAmt=0 "
|
.append("SET ChargeAmt=0 ")
|
||||||
+ "WHERE ChargeAmt IS NULL "
|
.append("WHERE ChargeAmt IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Charge Amount=" + no);
|
log.info("Charge Amount=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET TaxAmt=0 "
|
.append("SET TaxAmt=0 ")
|
||||||
+ "WHERE TaxAmt IS NULL "
|
.append("WHERE TaxAmt IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Tax Amount=" + no);
|
log.info("Tax Amount=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET WriteOffAmt=0 "
|
.append("SET WriteOffAmt=0 ")
|
||||||
+ "WHERE WriteOffAmt IS NULL "
|
.append("WHERE WriteOffAmt IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("WriteOff Amount=" + no);
|
log.info("WriteOff Amount=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET DiscountAmt=0 "
|
.append("SET DiscountAmt=0 ")
|
||||||
+ "WHERE DiscountAmt IS NULL "
|
.append("WHERE DiscountAmt IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Discount Amount=" + no);
|
log.info("Discount Amount=" + no);
|
||||||
//
|
//
|
||||||
|
|
||||||
// Set Date
|
// Set Date
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET DateTrx=Created "
|
.append("SET DateTrx=Created ")
|
||||||
+ "WHERE DateTrx IS NULL "
|
.append("WHERE DateTrx IS NULL ")
|
||||||
+ "AND I_isImported<>'Y'").append(clientCheck);
|
.append("AND I_isImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Trx Date=" + no);
|
log.info("Trx Date=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET DateAcct=DateTrx "
|
.append("SET DateAcct=DateTrx ")
|
||||||
+ "WHERE DateAcct IS NULL "
|
.append("WHERE DateAcct IS NULL ")
|
||||||
+ "AND I_isImported<>'Y'").append(clientCheck);
|
.append("AND I_isImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Acct Date=" + no);
|
log.info("Acct Date=" + no);
|
||||||
|
|
||||||
// Invoice
|
// Invoice
|
||||||
sql = new StringBuffer ("UPDATE I_Payment i "
|
sql = new StringBuilder ("UPDATE I_Payment i ")
|
||||||
+ "SET C_Invoice_ID=(SELECT MAX(C_Invoice_ID) FROM C_Invoice ii"
|
.append("SET C_Invoice_ID=(SELECT MAX(C_Invoice_ID) FROM C_Invoice ii")
|
||||||
+ " WHERE i.InvoiceDocumentNo=ii.DocumentNo AND i.AD_Client_ID=ii.AD_Client_ID) "
|
.append(" WHERE i.InvoiceDocumentNo=ii.DocumentNo AND i.AD_Client_ID=ii.AD_Client_ID) ")
|
||||||
+ "WHERE C_Invoice_ID IS NULL AND InvoiceDocumentNo IS NOT NULL"
|
.append("WHERE C_Invoice_ID IS NULL AND InvoiceDocumentNo IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set Invoice from DocumentNo=" + no);
|
log.fine("Set Invoice from DocumentNo=" + no);
|
||||||
|
|
||||||
// BPartner
|
// BPartner
|
||||||
sql = new StringBuffer ("UPDATE I_Payment i "
|
sql = new StringBuilder ("UPDATE I_Payment i ")
|
||||||
+ "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp"
|
.append("SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp")
|
||||||
+ " WHERE i.BPartnerValue=bp.Value AND i.AD_Client_ID=bp.AD_Client_ID) "
|
.append(" WHERE i.BPartnerValue=bp.Value AND i.AD_Client_ID=bp.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set BP from Value=" + no);
|
log.fine("Set BP from Value=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_Payment i "
|
sql = new StringBuilder ("UPDATE I_Payment i ")
|
||||||
+ "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_Invoice ii"
|
.append("SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_Invoice ii")
|
||||||
+ " WHERE i.C_Invoice_ID=ii.C_Invoice_ID AND i.AD_Client_ID=ii.AD_Client_ID) "
|
.append(" WHERE i.C_Invoice_ID=ii.C_Invoice_ID AND i.AD_Client_ID=ii.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND C_Invoice_ID IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND C_Invoice_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set BP from Invoice=" + no);
|
log.fine("Set BP from Invoice=" + no);
|
||||||
|
|
||||||
sql = new StringBuffer ("UPDATE I_Payment "
|
sql = new StringBuilder ("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner,' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL "
|
.append("WHERE C_BPartner_ID IS NULL ")
|
||||||
+ "AND I_IsImported<>'E' "
|
.append("AND I_IsImported<>'E' ")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("No BPartner=" + no);
|
log.warning("No BPartner=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Check Payment<->Invoice combination
|
// Check Payment<->Invoice combination
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->Invoice, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->Invoice, ' ")
|
||||||
+ "WHERE I_Payment_ID IN "
|
.append("WHERE I_Payment_ID IN ")
|
||||||
+ "(SELECT I_Payment_ID "
|
.append("(SELECT I_Payment_ID ")
|
||||||
+ "FROM I_Payment i"
|
.append("FROM I_Payment i")
|
||||||
+ " INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) "
|
.append(" INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) ")
|
||||||
+ "WHERE i.C_Invoice_ID IS NOT NULL "
|
.append("WHERE i.C_Invoice_ID IS NOT NULL ")
|
||||||
+ " AND p.C_Invoice_ID IS NOT NULL "
|
.append(" AND p.C_Invoice_ID IS NOT NULL ")
|
||||||
+ " AND p.C_Invoice_ID<>i.C_Invoice_ID) ")
|
.append(" AND p.C_Invoice_ID<>i.C_Invoice_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Payment<->Invoice Mismatch=" + no);
|
log.info("Payment<->Invoice Mismatch=" + no);
|
||||||
|
|
||||||
// Check Payment<->BPartner combination
|
// Check Payment<->BPartner combination
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Payment<->BPartner, ' ")
|
||||||
+ "WHERE I_Payment_ID IN "
|
.append("WHERE I_Payment_ID IN ")
|
||||||
+ "(SELECT I_Payment_ID "
|
.append("(SELECT I_Payment_ID ")
|
||||||
+ "FROM I_Payment i"
|
.append("FROM I_Payment i")
|
||||||
+ " INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) "
|
.append(" INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) ")
|
||||||
+ "WHERE i.C_BPartner_ID IS NOT NULL "
|
.append("WHERE i.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND p.C_BPartner_ID IS NOT NULL "
|
.append(" AND p.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND p.C_BPartner_ID<>i.C_BPartner_ID) ")
|
.append(" AND p.C_BPartner_ID<>i.C_BPartner_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Payment<->BPartner Mismatch=" + no);
|
log.info("Payment<->BPartner Mismatch=" + no);
|
||||||
|
|
||||||
// Check Invoice<->BPartner combination
|
// Check Invoice<->BPartner combination
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice<->BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice<->BPartner, ' ")
|
||||||
+ "WHERE I_Payment_ID IN "
|
.append("WHERE I_Payment_ID IN ")
|
||||||
+ "(SELECT I_Payment_ID "
|
.append("(SELECT I_Payment_ID ")
|
||||||
+ "FROM I_Payment i"
|
.append("FROM I_Payment i")
|
||||||
+ " INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID) "
|
.append(" INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID) ")
|
||||||
+ "WHERE i.C_BPartner_ID IS NOT NULL "
|
.append("WHERE i.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND v.C_BPartner_ID IS NOT NULL "
|
.append(" AND v.C_BPartner_ID IS NOT NULL ")
|
||||||
+ " AND v.C_BPartner_ID<>i.C_BPartner_ID) ")
|
.append(" AND v.C_BPartner_ID<>i.C_BPartner_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Invoice<->BPartner Mismatch=" + no);
|
log.info("Invoice<->BPartner Mismatch=" + no);
|
||||||
|
|
||||||
// Check Invoice.BPartner<->Payment.BPartner combination
|
// Check Invoice.BPartner<->Payment.BPartner combination
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice.BPartner<->Payment.BPartner, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Err=Invalid Invoice.BPartner<->Payment.BPartner, ' ")
|
||||||
+ "WHERE I_Payment_ID IN "
|
.append("WHERE I_Payment_ID IN ")
|
||||||
+ "(SELECT I_Payment_ID "
|
.append("(SELECT I_Payment_ID ")
|
||||||
+ "FROM I_Payment i"
|
.append("FROM I_Payment i")
|
||||||
+ " INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID)"
|
.append(" INNER JOIN C_Invoice v ON (i.C_Invoice_ID=v.C_Invoice_ID)")
|
||||||
+ " INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) "
|
.append(" INNER JOIN C_Payment p ON (i.C_Payment_ID=p.C_Payment_ID) ")
|
||||||
+ "WHERE p.C_Invoice_ID<>v.C_Invoice_ID"
|
.append("WHERE p.C_Invoice_ID<>v.C_Invoice_ID")
|
||||||
+ " AND v.C_BPartner_ID<>p.C_BPartner_ID) ")
|
.append(" AND v.C_BPartner_ID<>p.C_BPartner_ID) ")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("Invoice.BPartner<->Payment.BPartner Mismatch=" + no);
|
log.info("Invoice.BPartner<->Payment.BPartner Mismatch=" + no);
|
||||||
|
|
||||||
// TrxType
|
// TrxType
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET TrxType='S' " // MPayment.TRXTYPE_Sales
|
.append("SET TrxType='S' ") // MPayment.TRXTYPE_Sales
|
||||||
+ "WHERE TrxType IS NULL "
|
.append("WHERE TrxType IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("TrxType Default=" + no);
|
log.info("TrxType Default=" + no);
|
||||||
|
|
||||||
// TenderType
|
// TenderType
|
||||||
sql = new StringBuffer("UPDATE I_Payment "
|
sql = new StringBuilder("UPDATE I_Payment ")
|
||||||
+ "SET TenderType='K' " // MPayment.TENDERTYPE_Check
|
.append("SET TenderType='K' ") // MPayment.TENDERTYPE_Check
|
||||||
+ "WHERE TenderType IS NULL "
|
.append("WHERE TenderType IS NULL ")
|
||||||
+ "AND I_IsImported<>'Y'").append(clientCheck);
|
.append("AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.info("TenderType Default=" + no);
|
log.info("TenderType Default=" + no);
|
||||||
|
|
||||||
// Document Type
|
// Document Type
|
||||||
sql = new StringBuffer ("UPDATE I_Payment i "
|
sql = new StringBuilder ("UPDATE I_Payment i ")
|
||||||
+ "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=i.DocTypeName"
|
.append("SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.Name=i.DocTypeName")
|
||||||
+ " AND d.DocBaseType IN ('ARR','APP') AND i.AD_Client_ID=d.AD_Client_ID) "
|
.append(" AND d.DocBaseType IN ('ARR','APP') AND i.AD_Client_ID=d.AD_Client_ID) ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine("Set DocType=" + no);
|
log.fine("Set DocType=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Payment "
|
sql = new StringBuilder ("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocTypeName, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid DocTypeName, ' ")
|
||||||
+ "WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL"
|
.append("WHERE C_DocType_ID IS NULL AND DocTypeName IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("Invalid DocTypeName=" + no);
|
log.warning ("Invalid DocTypeName=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Payment "
|
sql = new StringBuilder ("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No DocType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No DocType, ' ")
|
||||||
+ "WHERE C_DocType_ID IS NULL"
|
.append("WHERE C_DocType_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append (clientCheck);
|
.append(" AND I_IsImported<>'Y'").append (clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning ("No DocType=" + no);
|
log.warning ("No DocType=" + no);
|
||||||
|
@ -407,9 +407,9 @@ public class ImportPayment extends SvrProcess
|
||||||
commitEx();
|
commitEx();
|
||||||
|
|
||||||
//Import Bank Statement
|
//Import Bank Statement
|
||||||
sql = new StringBuffer("SELECT * FROM I_Payment"
|
sql = new StringBuilder("SELECT * FROM I_Payment")
|
||||||
+ " WHERE I_IsImported='N'"
|
.append(" WHERE I_IsImported='N'")
|
||||||
+ " ORDER BY C_BankAccount_ID, CheckNo, DateTrx, R_AuthCode");
|
.append(" ORDER BY C_BankAccount_ID, CheckNo, DateTrx, R_AuthCode");
|
||||||
|
|
||||||
MBankAccount account = null;
|
MBankAccount account = null;
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
@ -526,9 +526,9 @@ public class ImportPayment extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_Payment "
|
sql = new StringBuilder ("UPDATE I_Payment ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
//
|
//
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = getWhereClause();
|
String clientCheck = getWhereClause();
|
||||||
|
|
||||||
|
@ -92,43 +92,43 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (m_deleteOldImported)
|
if (m_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_Product "
|
sql = new StringBuilder ("DELETE I_Product ")
|
||||||
+ "WHERE I_IsImported='Y'").append(clientCheck);
|
.append("WHERE I_IsImported='Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Delete Old Imported =" + no);
|
log.info("Delete Old Imported =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IaActive, Created/Updated, ProductType
|
// Set Client, Org, IaActive, Created/Updated, ProductType
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID, 0),"
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
|
||||||
+ " IsActive = COALESCE (IsActive, 'Y'),"
|
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " ProductType = COALESCE (ProductType, 'I'),"
|
.append(" ProductType = COALESCE (ProductType, 'I'),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Reset=" + no);
|
log.info("Reset=" + no);
|
||||||
|
|
||||||
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_BEFORE_VALIDATE);
|
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_BEFORE_VALIDATE);
|
||||||
|
|
||||||
// Set Optional BPartner
|
// Set Optional BPartner
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p"
|
.append("SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p")
|
||||||
+ " WHERE i.BPartner_Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.BPartner_Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL"
|
.append("WHERE C_BPartner_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("BPartner=" + no);
|
log.info("BPartner=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid BPartner,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid BPartner,' ")
|
||||||
+ "WHERE C_BPartner_ID IS NULL AND BPartner_Value IS NOT NULL"
|
.append("WHERE C_BPartner_ID IS NULL AND BPartner_Value IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid BPartner=" + no);
|
log.warning("Invalid BPartner=" + no);
|
||||||
|
@ -136,48 +136,48 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
|
|
||||||
// **** Find Product
|
// **** Find Product
|
||||||
// EAN/UPC
|
// EAN/UPC
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p")
|
||||||
+ " WHERE i.UPC=p.UPC AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.UPC=p.UPC AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL"
|
.append("WHERE M_Product_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Product Existing UPC=" + no);
|
log.info("Product Existing UPC=" + no);
|
||||||
|
|
||||||
// Value
|
// Value
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p"
|
.append("SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p")
|
||||||
+ " WHERE i.Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL"
|
.append("WHERE M_Product_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Product Existing Value=" + no);
|
log.info("Product Existing Value=" + no);
|
||||||
|
|
||||||
// BP ProdNo
|
// BP ProdNo
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product_po p"
|
.append("SET M_Product_ID=(SELECT M_Product_ID FROM M_Product_po p")
|
||||||
+ " WHERE i.C_BPartner_ID=p.C_BPartner_ID"
|
.append(" WHERE i.C_BPartner_ID=p.C_BPartner_ID")
|
||||||
+ " AND i.VendorProductNo=p.VendorProductNo AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" AND i.VendorProductNo=p.VendorProductNo AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NULL"
|
.append("WHERE M_Product_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Product Existing Vendor ProductNo=" + no);
|
log.info("Product Existing Vendor ProductNo=" + no);
|
||||||
|
|
||||||
// Set Product Category
|
// Set Product Category
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET ProductCategory_Value=(SELECT MAX(Value) FROM M_Product_Category"
|
.append("SET ProductCategory_Value=(SELECT MAX(Value) FROM M_Product_Category")
|
||||||
+ " WHERE IsDefault='Y' AND AD_Client_ID=").append(m_AD_Client_ID).append(") "
|
.append(" WHERE IsDefault='Y' AND AD_Client_ID=").append(m_AD_Client_ID).append(") ")
|
||||||
+ "WHERE ProductCategory_Value IS NULL AND M_Product_Category_ID IS NULL"
|
.append("WHERE ProductCategory_Value IS NULL AND M_Product_Category_ID IS NULL")
|
||||||
+ " AND M_Product_ID IS NULL" // set category only if product not found
|
.append(" AND M_Product_ID IS NULL") // set category only if product not found
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Category Default Value=" + no);
|
log.fine("Set Category Default Value=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET M_Product_Category_ID=(SELECT M_Product_Category_ID FROM M_Product_Category c"
|
.append("SET M_Product_Category_ID=(SELECT M_Product_Category_ID FROM M_Product_Category c")
|
||||||
+ " WHERE i.ProductCategory_Value=c.Value AND i.AD_Client_ID=c.AD_Client_ID) "
|
.append(" WHERE i.ProductCategory_Value=c.Value AND i.AD_Client_ID=c.AD_Client_ID) ")
|
||||||
+ "WHERE ProductCategory_Value IS NOT NULL AND M_Product_Category_ID IS NULL"
|
.append("WHERE ProductCategory_Value IS NOT NULL AND M_Product_Category_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Set Category=" + no);
|
log.info("Set Category=" + no);
|
||||||
|
|
||||||
|
@ -188,12 +188,12 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
"Discontinued","DiscontinuedBy","DiscontinuedAt","ImageURL","DescriptionURL"};
|
"Discontinued","DiscontinuedBy","DiscontinuedAt","ImageURL","DescriptionURL"};
|
||||||
for (int i = 0; i < strFields.length; i++)
|
for (int i = 0; i < strFields.length; i++)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET ").append(strFields[i]).append(" = (SELECT ").append(strFields[i]).append(" FROM M_Product p"
|
.append("SET ").append(strFields[i]).append(" = (SELECT ").append(strFields[i]).append(" FROM M_Product p")
|
||||||
+ " WHERE i.M_Product_ID=p.M_Product_ID AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.M_Product_ID=p.M_Product_ID AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NOT NULL"
|
.append("WHERE M_Product_ID IS NOT NULL")
|
||||||
+ " AND ").append(strFields[i]).append(" IS NULL"
|
.append(" AND ").append(strFields[i]).append(" IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine(strFields[i] + " - default from existing Product=" + no);
|
log.fine(strFields[i] + " - default from existing Product=" + no);
|
||||||
|
@ -202,12 +202,12 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
"Volume","Weight","ShelfWidth","ShelfHeight","ShelfDepth","UnitsPerPallet"};
|
"Volume","Weight","ShelfWidth","ShelfHeight","ShelfDepth","UnitsPerPallet"};
|
||||||
for (int i = 0; i < numFields.length; i++)
|
for (int i = 0; i < numFields.length; i++)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_PRODUCT i "
|
sql = new StringBuilder ("UPDATE I_PRODUCT i ")
|
||||||
+ "SET ").append(numFields[i]).append(" = (SELECT ").append(numFields[i]).append(" FROM M_Product p"
|
.append("SET ").append(numFields[i]).append(" = (SELECT ").append(numFields[i]).append(" FROM M_Product p")
|
||||||
+ " WHERE i.M_Product_ID=p.M_Product_ID AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.M_Product_ID=p.M_Product_ID AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NOT NULL"
|
.append("WHERE M_Product_ID IS NOT NULL")
|
||||||
+ " AND (").append(numFields[i]).append(" IS NULL OR ").append(numFields[i]).append("=0)"
|
.append(" AND (").append(numFields[i]).append(" IS NULL OR ").append(numFields[i]).append("=0)")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine(numFields[i] + " default from existing Product=" + no);
|
log.fine(numFields[i] + " default from existing Product=" + no);
|
||||||
|
@ -219,13 +219,13 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
"Discontinued","DiscontinuedBy", "DiscontinuedAt"};
|
"Discontinued","DiscontinuedBy", "DiscontinuedAt"};
|
||||||
for (int i = 0; i < strFieldsPO.length; i++)
|
for (int i = 0; i < strFieldsPO.length; i++)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_PRODUCT i "
|
sql = new StringBuilder ("UPDATE I_PRODUCT i ")
|
||||||
+ "SET ").append(strFieldsPO[i]).append(" = (SELECT ").append(strFieldsPO[i])
|
.append("SET ").append(strFieldsPO[i]).append(" = (SELECT ").append(strFieldsPO[i])
|
||||||
.append(" FROM M_Product_PO p"
|
.append(" FROM M_Product_PO p")
|
||||||
+ " WHERE i.M_Product_ID=p.M_Product_ID AND i.C_BPartner_ID=p.C_BPartner_ID AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.M_Product_ID=p.M_Product_ID AND i.C_BPartner_ID=p.C_BPartner_ID AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NOT NULL AND C_BPartner_ID IS NOT NULL"
|
.append("WHERE M_Product_ID IS NOT NULL AND C_BPartner_ID IS NOT NULL")
|
||||||
+ " AND ").append(strFieldsPO[i]).append(" IS NULL"
|
.append(" AND ").append(strFieldsPO[i]).append(" IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine(strFieldsPO[i] + " default from existing Product PO=" + no);
|
log.fine(strFieldsPO[i] + " default from existing Product PO=" + no);
|
||||||
|
@ -235,111 +235,111 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
"Order_Min","Order_Pack","CostPerOrder","DeliveryTime_Promised"};
|
"Order_Min","Order_Pack","CostPerOrder","DeliveryTime_Promised"};
|
||||||
for (int i = 0; i < numFieldsPO.length; i++)
|
for (int i = 0; i < numFieldsPO.length; i++)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_PRODUCT i "
|
sql = new StringBuilder ("UPDATE I_PRODUCT i ")
|
||||||
+ "SET ").append(numFieldsPO[i]).append(" = (SELECT ").append(numFieldsPO[i])
|
.append("SET ").append(numFieldsPO[i]).append(" = (SELECT ").append(numFieldsPO[i])
|
||||||
.append(" FROM M_Product_PO p"
|
.append(" FROM M_Product_PO p")
|
||||||
+ " WHERE i.M_Product_ID=p.M_Product_ID AND i.C_BPartner_ID=p.C_BPartner_ID AND i.AD_Client_ID=p.AD_Client_ID) "
|
.append(" WHERE i.M_Product_ID=p.M_Product_ID AND i.C_BPartner_ID=p.C_BPartner_ID AND i.AD_Client_ID=p.AD_Client_ID) ")
|
||||||
+ "WHERE M_Product_ID IS NOT NULL AND C_BPartner_ID IS NOT NULL"
|
.append("WHERE M_Product_ID IS NOT NULL AND C_BPartner_ID IS NOT NULL")
|
||||||
+ " AND (").append(numFieldsPO[i]).append(" IS NULL OR ").append(numFieldsPO[i]).append("=0)"
|
.append(" AND (").append(numFieldsPO[i]).append(" IS NULL OR ").append(numFieldsPO[i]).append("=0)")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.fine(numFieldsPO[i] + " default from existing Product PO=" + no);
|
log.fine(numFieldsPO[i] + " default from existing Product PO=" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid Category
|
// Invalid Category
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ProdCategory,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ProdCategory,' ")
|
||||||
+ "WHERE M_Product_Category_ID IS NULL"
|
.append("WHERE M_Product_Category_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid Category=" + no);
|
log.warning("Invalid Category=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Set UOM (System/own)
|
// Set UOM (System/own)
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET X12DE355 = "
|
.append("SET X12DE355 = ")
|
||||||
+ "(SELECT MAX(X12DE355) FROM C_UOM u WHERE u.IsDefault='Y' AND u.AD_Client_ID IN (0,i.AD_Client_ID)) "
|
.append("(SELECT MAX(X12DE355) FROM C_UOM u WHERE u.IsDefault='Y' AND u.AD_Client_ID IN (0,i.AD_Client_ID)) ")
|
||||||
+ "WHERE X12DE355 IS NULL AND C_UOM_ID IS NULL"
|
.append("WHERE X12DE355 IS NULL AND C_UOM_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set UOM Default=" + no);
|
log.fine("Set UOM Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET C_UOM_ID = (SELECT C_UOM_ID FROM C_UOM u WHERE u.X12DE355=i.X12DE355 AND u.AD_Client_ID IN (0,i.AD_Client_ID)) "
|
.append("SET C_UOM_ID = (SELECT C_UOM_ID FROM C_UOM u WHERE u.X12DE355=i.X12DE355 AND u.AD_Client_ID IN (0,i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_UOM_ID IS NULL"
|
.append("WHERE C_UOM_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Set UOM=" + no);
|
log.info("Set UOM=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid UOM, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid UOM, ' ")
|
||||||
+ "WHERE C_UOM_ID IS NULL"
|
.append("WHERE C_UOM_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid UOM=" + no);
|
log.warning("Invalid UOM=" + no);
|
||||||
|
|
||||||
|
|
||||||
// Set Currency
|
// Set Currency
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET ISO_Code=(SELECT ISO_Code FROM C_Currency c"
|
.append("SET ISO_Code=(SELECT ISO_Code FROM C_Currency c")
|
||||||
+ " INNER JOIN C_AcctSchema a ON (a.C_Currency_ID=c.C_Currency_ID)"
|
.append(" INNER JOIN C_AcctSchema a ON (a.C_Currency_ID=c.C_Currency_ID)")
|
||||||
+ " INNER JOIN AD_ClientInfo ci ON (a.C_AcctSchema_ID=ci.C_AcctSchema1_ID)"
|
.append(" INNER JOIN AD_ClientInfo ci ON (a.C_AcctSchema_ID=ci.C_AcctSchema1_ID)")
|
||||||
+ " WHERE ci.AD_Client_ID=i.AD_Client_ID) "
|
.append(" WHERE ci.AD_Client_ID=i.AD_Client_ID) ")
|
||||||
+ "WHERE C_Currency_ID IS NULL AND ISO_Code IS NULL"
|
.append("WHERE C_Currency_ID IS NULL AND ISO_Code IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set Currency Default=" + no);
|
log.fine("Set Currency Default=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c"
|
.append("SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c")
|
||||||
+ " WHERE i.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) "
|
.append(" WHERE i.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) ")
|
||||||
+ "WHERE C_Currency_ID IS NULL"
|
.append("WHERE C_Currency_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("doIt- Set Currency=" + no);
|
log.info("doIt- Set Currency=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Currency,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Currency,' ")
|
||||||
+ "WHERE C_Currency_ID IS NULL"
|
.append("WHERE C_Currency_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid Currency=" + no);
|
log.warning("Invalid Currency=" + no);
|
||||||
|
|
||||||
// Verify ProductType
|
// Verify ProductType
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ProductType,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ProductType,' ")
|
||||||
+ "WHERE ProductType NOT IN ('E','I','R','S')"
|
.append("WHERE ProductType NOT IN ('E','I','R','S')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Invalid ProductType=" + no);
|
log.warning("Invalid ProductType=" + no);
|
||||||
|
|
||||||
// Unique UPC/Value
|
// Unique UPC/Value
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Value not unique,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Value not unique,' ")
|
||||||
+ "WHERE I_IsImported<>'Y'"
|
.append("WHERE I_IsImported<>'Y'")
|
||||||
+ " AND Value IN (SELECT Value FROM I_Product ii WHERE i.AD_Client_ID=ii.AD_Client_ID GROUP BY Value HAVING COUNT(*) > 1)").append(clientCheck);
|
.append(" AND Value IN (SELECT Value FROM I_Product ii WHERE i.AD_Client_ID=ii.AD_Client_ID GROUP BY Value HAVING COUNT(*) > 1)").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Not Unique Value=" + no);
|
log.warning("Not Unique Value=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=UPC not unique,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=UPC not unique,' ")
|
||||||
+ "WHERE I_IsImported<>'Y'"
|
.append("WHERE I_IsImported<>'Y'")
|
||||||
+ " AND UPC IN (SELECT UPC FROM I_Product ii WHERE i.AD_Client_ID=ii.AD_Client_ID GROUP BY UPC HAVING COUNT(*) > 1)").append(clientCheck);
|
.append(" AND UPC IN (SELECT UPC FROM I_Product ii WHERE i.AD_Client_ID=ii.AD_Client_ID GROUP BY UPC HAVING COUNT(*) > 1)").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("Not Unique UPC=" + no);
|
log.warning("Not Unique UPC=" + no);
|
||||||
|
|
||||||
// Mandatory Value
|
// Mandatory Value
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Mandatory Value,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Mandatory Value,' ")
|
||||||
+ "WHERE Value IS NULL"
|
.append("WHERE Value IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
log.warning("No Mandatory Value=" + no);
|
log.warning("No Mandatory Value=" + no);
|
||||||
|
@ -351,19 +351,19 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
// + " AND VendorProductNo IS NULL AND (C_BPartner_ID IS NOT NULL OR BPartner_Value IS NOT NULL)").append(clientCheck);
|
// + " AND VendorProductNo IS NULL AND (C_BPartner_ID IS NOT NULL OR BPartner_Value IS NOT NULL)").append(clientCheck);
|
||||||
// no = DB.executeUpdate(sql.toString(), get_TrxName());
|
// no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
// log.info(log.l3_Util, "No Mandatory VendorProductNo=" + no);
|
// log.info(log.l3_Util, "No Mandatory VendorProductNo=" + no);
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET VendorProductNo=Value "
|
.append("SET VendorProductNo=Value ")
|
||||||
+ "WHERE C_BPartner_ID IS NOT NULL AND VendorProductNo IS NULL"
|
.append("WHERE C_BPartner_ID IS NOT NULL AND VendorProductNo IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("VendorProductNo Set to Value=" + no);
|
log.info("VendorProductNo Set to Value=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_Product i "
|
sql = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=VendorProductNo not unique,' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=VendorProductNo not unique,' ")
|
||||||
+ "WHERE I_IsImported<>'Y'"
|
.append("WHERE I_IsImported<>'Y'")
|
||||||
+ " AND C_BPartner_ID IS NOT NULL"
|
.append(" AND C_BPartner_ID IS NOT NULL")
|
||||||
+ " AND (C_BPartner_ID, VendorProductNo) IN "
|
.append(" AND (C_BPartner_ID, VendorProductNo) IN ")
|
||||||
+ " (SELECT C_BPartner_ID, VendorProductNo FROM I_Product ii WHERE i.AD_Client_ID=ii.AD_Client_ID GROUP BY C_BPartner_ID, VendorProductNo HAVING COUNT(*) > 1)")
|
.append(" (SELECT C_BPartner_ID, VendorProductNo FROM I_Product ii WHERE i.AD_Client_ID=ii.AD_Client_ID GROUP BY C_BPartner_ID, VendorProductNo HAVING COUNT(*) > 1)")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
if (no != 0)
|
if (no != 0)
|
||||||
|
@ -373,8 +373,8 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
int C_TaxCategory_ID = 0;
|
int C_TaxCategory_ID = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement
|
StringBuilder dbpst = new StringBuilder("SELECT C_TaxCategory_ID FROM C_TaxCategory WHERE IsDefault='Y'").append(clientCheck);
|
||||||
("SELECT C_TaxCategory_ID FROM C_TaxCategory WHERE IsDefault='Y'" + clientCheck, get_TrxName());
|
PreparedStatement pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
C_TaxCategory_ID = rs.getInt(1);
|
C_TaxCategory_ID = rs.getInt(1);
|
||||||
|
@ -399,7 +399,7 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
|
|
||||||
// Go through Records
|
// Go through Records
|
||||||
log.fine("start inserting/updating ...");
|
log.fine("start inserting/updating ...");
|
||||||
sql = new StringBuffer ("SELECT * FROM I_Product WHERE I_IsImported='N'")
|
sql = new StringBuilder ("SELECT * FROM I_Product WHERE I_IsImported='N'")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -504,8 +504,8 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuffer sql0 = new StringBuffer ("UPDATE I_Product i "
|
StringBuilder sql0 = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Product failed"))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Product failed"))
|
||||||
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
||||||
DB.executeUpdate(sql0.toString(), get_TrxName());
|
DB.executeUpdate(sql0.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -513,19 +513,19 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
}
|
}
|
||||||
else // Update Product
|
else // Update Product
|
||||||
{
|
{
|
||||||
String sqlt = "UPDATE M_PRODUCT "
|
StringBuilder sqlt = new StringBuilder("UPDATE M_PRODUCT ")
|
||||||
+ "SET (Value,Name,Description,DocumentNote,Help,"
|
.append("SET (Value,Name,Description,DocumentNote,Help,")
|
||||||
+ "UPC,SKU,C_UOM_ID,M_Product_Category_ID,Classification,ProductType,"
|
.append("UPC,SKU,C_UOM_ID,M_Product_Category_ID,Classification,ProductType,")
|
||||||
+ "Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet,"
|
.append("Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet,")
|
||||||
+ "Discontinued,DiscontinuedBy, DiscontinuedAt, Updated,UpdatedBy)= "
|
.append("Discontinued,DiscontinuedBy, DiscontinuedAt, Updated,UpdatedBy)= ")
|
||||||
+ "(SELECT Value,Name,Description,DocumentNote,Help,"
|
.append("(SELECT Value,Name,Description,DocumentNote,Help,")
|
||||||
+ "UPC,SKU,C_UOM_ID,M_Product_Category_ID,Classification,ProductType,"
|
.append("UPC,SKU,C_UOM_ID,M_Product_Category_ID,Classification,ProductType,")
|
||||||
+ "Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet,"
|
.append("Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet,")
|
||||||
+ "Discontinued,DiscontinuedBy, DiscontinuedAt, SysDate,UpdatedBy"
|
.append("Discontinued,DiscontinuedBy, DiscontinuedAt, SysDate,UpdatedBy")
|
||||||
+ " FROM I_Product WHERE I_Product_ID="+I_Product_ID+") "
|
.append(" FROM I_Product WHERE I_Product_ID=").append(I_Product_ID).append(") ")
|
||||||
+ "WHERE M_Product_ID="+M_Product_ID;
|
.append("WHERE M_Product_ID=").append(M_Product_ID);
|
||||||
PreparedStatement pstmt_updateProduct = DB.prepareStatement
|
PreparedStatement pstmt_updateProduct = DB.prepareStatement
|
||||||
(sqlt, get_TrxName());
|
(sqlt.toString(), get_TrxName());
|
||||||
|
|
||||||
//jz pstmt_updateProduct.setInt(1, I_Product_ID);
|
//jz pstmt_updateProduct.setInt(1, I_Product_ID);
|
||||||
// pstmt_updateProduct.setInt(2, M_Product_ID);
|
// pstmt_updateProduct.setInt(2, M_Product_ID);
|
||||||
|
@ -538,8 +538,8 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
catch (SQLException ex)
|
catch (SQLException ex)
|
||||||
{
|
{
|
||||||
log.warning("Update Product - " + ex.toString());
|
log.warning("Update Product - " + ex.toString());
|
||||||
StringBuffer sql0 = new StringBuffer ("UPDATE I_Product i "
|
StringBuilder sql0 = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update Product: " + ex.toString()))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update Product: " + ex.toString()))
|
||||||
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
||||||
DB.executeUpdate(sql0.toString(), get_TrxName());
|
DB.executeUpdate(sql0.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -554,22 +554,22 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
// If Product existed, Try to Update first
|
// If Product existed, Try to Update first
|
||||||
if (!newProduct)
|
if (!newProduct)
|
||||||
{
|
{
|
||||||
String sqlt = "UPDATE M_Product_PO "
|
StringBuilder sqlt = new StringBuilder("UPDATE M_Product_PO ")
|
||||||
+ "SET (IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC,"
|
.append("SET (IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC,")
|
||||||
+ "PriceList,PricePO,RoyaltyAmt,PriceEffective,"
|
.append("PriceList,PricePO,RoyaltyAmt,PriceEffective,")
|
||||||
+ "VendorProductNo,VendorCategory,Manufacturer,"
|
.append("VendorProductNo,VendorCategory,Manufacturer,")
|
||||||
+ "Discontinued,DiscontinuedBy, DiscontinuedAt, Order_Min,Order_Pack,"
|
.append("Discontinued,DiscontinuedBy, DiscontinuedAt, Order_Min,Order_Pack,")
|
||||||
+ "CostPerOrder,DeliveryTime_Promised,Updated,UpdatedBy)= "
|
.append("CostPerOrder,DeliveryTime_Promised,Updated,UpdatedBy)= ")
|
||||||
+ "(SELECT CAST('Y' AS CHAR),C_UOM_ID,C_Currency_ID,UPC," //jz fix EDB unknown datatype error
|
.append("(SELECT CAST('Y' AS CHAR),C_UOM_ID,C_Currency_ID,UPC,") //jz fix EDB unknown datatype error
|
||||||
+ "PriceList,PricePO,RoyaltyAmt,PriceEffective,"
|
.append("PriceList,PricePO,RoyaltyAmt,PriceEffective,")
|
||||||
+ "VendorProductNo,VendorCategory,Manufacturer,"
|
.append("VendorProductNo,VendorCategory,Manufacturer,")
|
||||||
+ "Discontinued,DiscontinuedBy, DiscontinuedAt, Order_Min,Order_Pack,"
|
.append("Discontinued,DiscontinuedBy, DiscontinuedAt, Order_Min,Order_Pack,")
|
||||||
+ "CostPerOrder,DeliveryTime_Promised,SysDate,UpdatedBy"
|
.append("CostPerOrder,DeliveryTime_Promised,SysDate,UpdatedBy")
|
||||||
+ " FROM I_Product"
|
.append(" FROM I_Product")
|
||||||
+ " WHERE I_Product_ID="+I_Product_ID+") "
|
.append(" WHERE I_Product_ID=").append(I_Product_ID).append(") ")
|
||||||
+ "WHERE M_Product_ID="+M_Product_ID+" AND C_BPartner_ID="+C_BPartner_ID;
|
.append("WHERE M_Product_ID=").append(M_Product_ID).append(" AND C_BPartner_ID=").append(C_BPartner_ID);
|
||||||
PreparedStatement pstmt_updateProductPO = DB.prepareStatement
|
PreparedStatement pstmt_updateProductPO = DB.prepareStatement
|
||||||
(sqlt, get_TrxName());
|
(sqlt.toString(), get_TrxName());
|
||||||
//jz pstmt_updateProductPO.setInt(1, I_Product_ID);
|
//jz pstmt_updateProductPO.setInt(1, I_Product_ID);
|
||||||
// pstmt_updateProductPO.setInt(2, M_Product_ID);
|
// pstmt_updateProductPO.setInt(2, M_Product_ID);
|
||||||
// pstmt_updateProductPO.setInt(3, C_BPartner_ID);
|
// pstmt_updateProductPO.setInt(3, C_BPartner_ID);
|
||||||
|
@ -584,8 +584,8 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
log.warning("Update Product_PO - " + ex.toString());
|
log.warning("Update Product_PO - " + ex.toString());
|
||||||
noUpdate--;
|
noUpdate--;
|
||||||
rollback();
|
rollback();
|
||||||
StringBuffer sql0 = new StringBuffer ("UPDATE I_Product i "
|
StringBuilder sql0 = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update Product_PO: " + ex.toString()))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update Product_PO: " + ex.toString()))
|
||||||
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
||||||
DB.executeUpdate(sql0.toString(), get_TrxName());
|
DB.executeUpdate(sql0.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -608,8 +608,8 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
log.warning("Insert Product_PO - " + ex.toString());
|
log.warning("Insert Product_PO - " + ex.toString());
|
||||||
noInsert--; // assume that product also did not exist
|
noInsert--; // assume that product also did not exist
|
||||||
rollback();
|
rollback();
|
||||||
StringBuffer sql0 = new StringBuffer ("UPDATE I_Product i "
|
StringBuilder sql0 = new StringBuilder ("UPDATE I_Product i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Product_PO: " + ex.toString()))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Product_PO: " + ex.toString()))
|
||||||
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
.append("WHERE I_Product_ID=").append(I_Product_ID);
|
||||||
DB.executeUpdate(sql0.toString(), get_TrxName());
|
DB.executeUpdate(sql0.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -659,9 +659,9 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_Product "
|
sql = new StringBuilder ("UPDATE I_Product ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
addLog (0, null, new BigDecimal (noInsert), "@M_Product_ID@: @Inserted@");
|
addLog (0, null, new BigDecimal (noInsert), "@M_Product_ID@: @Inserted@");
|
||||||
|
@ -680,7 +680,8 @@ public class ImportProduct extends SvrProcess implements ImportProcess
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWhereClause() {
|
public String getWhereClause() {
|
||||||
return " AND AD_Client_ID=" + m_AD_Client_ID;
|
StringBuilder msgreturn = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||||
|
return msgreturn.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // ImportProduct
|
} // ImportProduct
|
||||||
|
|
|
@ -76,181 +76,181 @@ public class ImportReportLine extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws java.lang.Exception
|
protected String doIt() throws java.lang.Exception
|
||||||
{
|
{
|
||||||
StringBuffer sql = null;
|
StringBuilder sql = null;
|
||||||
int no = 0;
|
int no = 0;
|
||||||
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID;
|
StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
|
||||||
|
|
||||||
// **** Prepare ****
|
// **** Prepare ****
|
||||||
|
|
||||||
// Delete Old Imported
|
// Delete Old Imported
|
||||||
if (m_deleteOldImported)
|
if (m_deleteOldImported)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("DELETE I_ReportLine "
|
sql = new StringBuilder ("DELETE I_ReportLine ")
|
||||||
+ "WHERE I_IsImported='Y'").append(clientCheck);
|
.append("WHERE I_IsImported='Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Delete Old Impored =" + no);
|
log.fine("Delete Old Impored =" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Client, Org, IsActive, Created/Updated
|
// Set Client, Org, IsActive, Created/Updated
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),"
|
.append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
|
||||||
+ " AD_Org_ID = COALESCE (AD_Org_ID, 0),"
|
.append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
|
||||||
+ " IsActive = COALESCE (IsActive, 'Y'),"
|
.append(" IsActive = COALESCE (IsActive, 'Y'),")
|
||||||
+ " Created = COALESCE (Created, SysDate),"
|
.append(" Created = COALESCE (Created, SysDate),")
|
||||||
+ " CreatedBy = COALESCE (CreatedBy, 0),"
|
.append(" CreatedBy = COALESCE (CreatedBy, 0),")
|
||||||
+ " Updated = COALESCE (Updated, SysDate),"
|
.append(" Updated = COALESCE (Updated, SysDate),")
|
||||||
+ " UpdatedBy = COALESCE (UpdatedBy, 0),"
|
.append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
|
||||||
+ " I_ErrorMsg = ' ',"
|
.append(" I_ErrorMsg = ' ',")
|
||||||
+ " I_IsImported = 'N' "
|
.append(" I_IsImported = 'N' ")
|
||||||
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
.append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Reset=" + no);
|
log.fine("Reset=" + no);
|
||||||
|
|
||||||
// ReportLineSetName (Default)
|
// ReportLineSetName (Default)
|
||||||
if (m_PA_ReportLineSet_ID != 0)
|
if (m_PA_ReportLineSet_ID != 0)
|
||||||
{
|
{
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET ReportLineSetName=(SELECT Name FROM PA_ReportLineSet r"
|
.append("SET ReportLineSetName=(SELECT Name FROM PA_ReportLineSet r")
|
||||||
+ " WHERE PA_ReportLineSet_ID=").append(m_PA_ReportLineSet_ID).append(" AND i.AD_Client_ID=r.AD_Client_ID) "
|
.append(" WHERE PA_ReportLineSet_ID=").append(m_PA_ReportLineSet_ID).append(" AND i.AD_Client_ID=r.AD_Client_ID) ")
|
||||||
+ "WHERE ReportLineSetName IS NULL AND PA_ReportLineSet_ID IS NULL"
|
.append("WHERE ReportLineSetName IS NULL AND PA_ReportLineSet_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set ReportLineSetName Default=" + no);
|
log.fine("Set ReportLineSetName Default=" + no);
|
||||||
}
|
}
|
||||||
// Set PA_ReportLineSet_ID
|
// Set PA_ReportLineSet_ID
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET PA_ReportLineSet_ID=(SELECT PA_ReportLineSet_ID FROM PA_ReportLineSet r"
|
.append("SET PA_ReportLineSet_ID=(SELECT PA_ReportLineSet_ID FROM PA_ReportLineSet r")
|
||||||
+ " WHERE i.ReportLineSetName=r.Name AND i.AD_Client_ID=r.AD_Client_ID) "
|
.append(" WHERE i.ReportLineSetName=r.Name AND i.AD_Client_ID=r.AD_Client_ID) ")
|
||||||
+ "WHERE PA_ReportLineSet_ID IS NULL"
|
.append("WHERE PA_ReportLineSet_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PA_ReportLineSet_ID=" + no);
|
log.fine("Set PA_ReportLineSet_ID=" + no);
|
||||||
//
|
//
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ReportLineSet, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ReportLineSet, ' ")
|
||||||
+ "WHERE PA_ReportLineSet_ID IS NULL"
|
.append("WHERE PA_ReportLineSet_ID IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid ReportLineSet=" + no);
|
log.config("Invalid ReportLineSet=" + no);
|
||||||
|
|
||||||
// Ignore if there is no Report Line Name or ID
|
// Ignore if there is no Report Line Name or ID
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Ignored=NoLineName, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Ignored=NoLineName, ' ")
|
||||||
+ "WHERE PA_ReportLine_ID IS NULL AND Name IS NULL"
|
.append("WHERE PA_ReportLine_ID IS NULL AND Name IS NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid LineName=" + no);
|
log.config("Invalid LineName=" + no);
|
||||||
|
|
||||||
// Validate ElementValue
|
// Validate ElementValue
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET C_ElementValue_ID=(SELECT C_ElementValue_ID FROM C_ElementValue e"
|
.append("SET C_ElementValue_ID=(SELECT C_ElementValue_ID FROM C_ElementValue e")
|
||||||
+ " WHERE i.ElementValue=e.Value AND i.AD_Client_ID=e.AD_Client_ID) "
|
.append(" WHERE i.ElementValue=e.Value AND i.AD_Client_ID=e.AD_Client_ID) ")
|
||||||
+ "WHERE C_ElementValue_ID IS NULL AND ElementValue IS NOT NULL"
|
.append("WHERE C_ElementValue_ID IS NULL AND ElementValue IS NOT NULL")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set C_ElementValue_ID=" + no);
|
log.fine("Set C_ElementValue_ID=" + no);
|
||||||
|
|
||||||
// Validate C_ElementValue_ID
|
// Validate C_ElementValue_ID
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ElementValue, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ElementValue, ' ")
|
||||||
+ "WHERE C_ElementValue_ID IS NULL AND LineType<>'C'" // MReportLine.LINETYPE_Calculation
|
.append("WHERE C_ElementValue_ID IS NULL AND LineType<>'C'") // MReportLine.LINETYPE_Calculation
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid AccountType=" + no);
|
log.config("Invalid AccountType=" + no);
|
||||||
|
|
||||||
// Set SeqNo
|
// Set SeqNo
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET SeqNo=I_ReportLine_ID "
|
.append("SET SeqNo=I_ReportLine_ID ")
|
||||||
+ "WHERE SeqNo IS NULL"
|
.append("WHERE SeqNo IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set SeqNo Default=" + no);
|
log.fine("Set SeqNo Default=" + no);
|
||||||
|
|
||||||
// Copy/Sync from first Row of Line
|
// Copy/Sync from first Row of Line
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET (Description, SeqNo, IsSummary, IsPrinted, LineType, CalculationType, AmountType, PAAmountType, PAPeriodType, PostingType)="
|
.append("SET (Description, SeqNo, IsSummary, IsPrinted, LineType, CalculationType, AmountType, PAAmountType, PAPeriodType, PostingType)=")
|
||||||
+ " (SELECT Description, SeqNo, IsSummary, IsPrinted, LineType, CalculationType, AmountType, PAAmountType, PAPeriodType, PostingType"
|
.append(" (SELECT Description, SeqNo, IsSummary, IsPrinted, LineType, CalculationType, AmountType, PAAmountType, PAPeriodType, PostingType")
|
||||||
+ " FROM I_ReportLine ii WHERE i.Name=ii.Name AND i.PA_ReportLineSet_ID=ii.PA_ReportLineSet_ID"
|
.append(" FROM I_ReportLine ii WHERE i.Name=ii.Name AND i.PA_ReportLineSet_ID=ii.PA_ReportLineSet_ID")
|
||||||
+ " AND ii.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
|
.append(" AND ii.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii")
|
||||||
+ " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID)) "
|
.append(" WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID)) ")
|
||||||
+ "WHERE EXISTS (SELECT *"
|
.append("WHERE EXISTS (SELECT *")
|
||||||
+ " FROM I_ReportLine ii WHERE i.Name=ii.Name AND i.PA_ReportLineSet_ID=ii.PA_ReportLineSet_ID"
|
.append(" FROM I_ReportLine ii WHERE i.Name=ii.Name AND i.PA_ReportLineSet_ID=ii.PA_ReportLineSet_ID")
|
||||||
+ " AND ii.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
|
.append(" AND ii.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii")
|
||||||
+ " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID))"
|
.append(" WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID))")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck); // not if previous error
|
.append(" AND I_IsImported='N'").append(clientCheck); // not if previous error
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Sync from first Row of Line=" + no);
|
log.fine("Sync from first Row of Line=" + no);
|
||||||
|
|
||||||
// Validate IsSummary - (N) Y
|
// Validate IsSummary - (N) Y
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET IsSummary='N' "
|
.append("SET IsSummary='N' ")
|
||||||
+ "WHERE IsSummary IS NULL OR IsSummary NOT IN ('Y','N')"
|
.append("WHERE IsSummary IS NULL OR IsSummary NOT IN ('Y','N')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsSummary Default=" + no);
|
log.fine("Set IsSummary Default=" + no);
|
||||||
|
|
||||||
// Validate IsPrinted - (Y) N
|
// Validate IsPrinted - (Y) N
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET IsPrinted='Y' "
|
.append("SET IsPrinted='Y' ")
|
||||||
+ "WHERE IsPrinted IS NULL OR IsPrinted NOT IN ('Y','N')"
|
.append("WHERE IsPrinted IS NULL OR IsPrinted NOT IN ('Y','N')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set IsPrinted Default=" + no);
|
log.fine("Set IsPrinted Default=" + no);
|
||||||
|
|
||||||
// Validate Line Type - (S) C
|
// Validate Line Type - (S) C
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET LineType='S' "
|
.append("SET LineType='S' ")
|
||||||
+ "WHERE LineType IS NULL OR LineType NOT IN ('S','C')"
|
.append("WHERE LineType IS NULL OR LineType NOT IN ('S','C')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set LineType Default=" + no);
|
log.fine("Set LineType Default=" + no);
|
||||||
|
|
||||||
// Validate Optional Calculation Type - A P R S
|
// Validate Optional Calculation Type - A P R S
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CalculationType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CalculationType, ' ")
|
||||||
+ "WHERE CalculationType IS NOT NULL AND CalculationType NOT IN ('A','P','R','S')"
|
.append("WHERE CalculationType IS NOT NULL AND CalculationType NOT IN ('A','P','R','S')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid CalculationType=" + no);
|
log.config("Invalid CalculationType=" + no);
|
||||||
|
|
||||||
// Convert Optional Amount Type to PAAmount Type and PAPeriodType
|
// Convert Optional Amount Type to PAAmount Type and PAPeriodType
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET PAAmountType = substr(AmountType,1,1), PAPeriodType = substr(AmountType,1,2) "
|
.append("SET PAAmountType = substr(AmountType,1,1), PAPeriodType = substr(AmountType,1,2) ")
|
||||||
+ "WHERE AmountType IS NOT NULL AND (PAAmountType IS NULL OR PAPeriodType IS NULL) "
|
.append("WHERE AmountType IS NOT NULL AND (PAAmountType IS NULL OR PAPeriodType IS NULL) ")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Converted AmountType=" + no);
|
log.config("Converted AmountType=" + no);
|
||||||
|
|
||||||
// Validate Optional Amount Type -
|
// Validate Optional Amount Type -
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid PAAmountType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid PAAmountType, ' ")
|
||||||
+ "WHERE PAAmountType IS NOT NULL AND UPPER(AmountType) NOT IN ('B','C','D','Q','S','R')"
|
.append("WHERE PAAmountType IS NOT NULL AND UPPER(AmountType) NOT IN ('B','C','D','Q','S','R')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid AmountType=" + no);
|
log.config("Invalid AmountType=" + no);
|
||||||
|
|
||||||
// Validate Optional Period Type -
|
// Validate Optional Period Type -
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid PAPeriodType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid PAPeriodType, ' ")
|
||||||
+ "WHERE PAPeriodType IS NOT NULL AND UPPER(AmountType) NOT IN ('P','Y','T','N')"
|
.append("WHERE PAPeriodType IS NOT NULL AND UPPER(AmountType) NOT IN ('P','Y','T','N')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid PeriodType=" + no);
|
log.config("Invalid PeriodType=" + no);
|
||||||
|
|
||||||
// Validate Optional Posting Type - A B E S R
|
// Validate Optional Posting Type - A B E S R
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CalculationType, ' "
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CalculationType, ' ")
|
||||||
+ "WHERE PostingType IS NOT NULL AND PostingType NOT IN ('A','B','E','S','R')"
|
.append("WHERE PostingType IS NOT NULL AND PostingType NOT IN ('A','B','E','S','R')")
|
||||||
+ " AND I_IsImported<>'Y'").append(clientCheck);
|
.append(" AND I_IsImported<>'Y'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Invalid PostingType=" + no);
|
log.config("Invalid PostingType=" + no);
|
||||||
|
|
||||||
// Set PA_ReportLine_ID
|
// Set PA_ReportLine_ID
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET PA_ReportLine_ID=(SELECT MAX(PA_ReportLine_ID) FROM PA_ReportLine r"
|
.append("SET PA_ReportLine_ID=(SELECT MAX(PA_ReportLine_ID) FROM PA_ReportLine r")
|
||||||
+ " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID) "
|
.append(" WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID) ")
|
||||||
+ "WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL"
|
.append("WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PA_ReportLine_ID=" + no);
|
log.fine("Set PA_ReportLine_ID=" + no);
|
||||||
|
|
||||||
|
@ -261,29 +261,29 @@ public class ImportReportLine extends SvrProcess
|
||||||
int noUpdateLine = 0;
|
int noUpdateLine = 0;
|
||||||
|
|
||||||
// **** Create Missing ReportLines
|
// **** Create Missing ReportLines
|
||||||
sql = new StringBuffer ("SELECT DISTINCT PA_ReportLineSet_ID, Name "
|
sql = new StringBuilder ("SELECT DISTINCT PA_ReportLineSet_ID, Name ")
|
||||||
+ "FROM I_ReportLine "
|
.append("FROM I_ReportLine ")
|
||||||
+ "WHERE I_IsImported='N' AND PA_ReportLine_ID IS NULL"
|
.append("WHERE I_IsImported='N' AND PA_ReportLine_ID IS NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Insert ReportLine
|
// Insert ReportLine
|
||||||
PreparedStatement pstmt_insertLine = DB.prepareStatement
|
StringBuilder dbpst = new StringBuilder("INSERT INTO PA_ReportLine ")
|
||||||
("INSERT INTO PA_ReportLine "
|
.append("(PA_ReportLine_ID,PA_ReportLineSet_ID,")
|
||||||
+ "(PA_ReportLine_ID,PA_ReportLineSet_ID,"
|
.append("AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,")
|
||||||
+ "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
|
.append("Name,SeqNo,IsPrinted,IsSummary,LineType)")
|
||||||
+ "Name,SeqNo,IsPrinted,IsSummary,LineType)"
|
.append("SELECT ?,PA_ReportLineSet_ID,")
|
||||||
+ "SELECT ?,PA_ReportLineSet_ID,"
|
.append("AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy,")
|
||||||
+ "AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy,"
|
.append("Name,SeqNo,IsPrinted,IsSummary,LineType ")
|
||||||
+ "Name,SeqNo,IsPrinted,IsSummary,LineType "
|
//jz + "FROM I_ReportLine "
|
||||||
//jz + "FROM I_ReportLine "
|
// + "WHERE PA_ReportLineSet_ID=? AND Name=? AND ROWNUM=1" // #2..3
|
||||||
// + "WHERE PA_ReportLineSet_ID=? AND Name=? AND ROWNUM=1" // #2..3
|
.append("FROM I_ReportLine ")
|
||||||
+ "FROM I_ReportLine "
|
.append("WHERE I_ReportLine_ID=(SELECT MAX(I_ReportLine_ID) ")
|
||||||
+ "WHERE I_ReportLine_ID=(SELECT MAX(I_ReportLine_ID) "
|
.append("FROM I_ReportLine ")
|
||||||
+ "FROM I_ReportLine "
|
.append("WHERE PA_ReportLineSet_ID=? AND Name=? ") // #2..3
|
||||||
+ "WHERE PA_ReportLineSet_ID=? AND Name=? " // #2..3
|
//jz + clientCheck, get_TrxName());
|
||||||
//jz + clientCheck, get_TrxName());
|
.append(clientCheck).append(")");
|
||||||
+ clientCheck + ")", get_TrxName());
|
PreparedStatement pstmt_insertLine = DB.prepareStatement(dbpst.toString(), get_TrxName());
|
||||||
|
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
@ -322,25 +322,25 @@ public class ImportReportLine extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set PA_ReportLine_ID (for newly created)
|
// Set PA_ReportLine_ID (for newly created)
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET PA_ReportLine_ID=(SELECT MAX(PA_ReportLine_ID) FROM PA_ReportLine r"
|
.append("SET PA_ReportLine_ID=(SELECT MAX(PA_ReportLine_ID) FROM PA_ReportLine r")
|
||||||
+ " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID) "
|
.append(" WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID) ")
|
||||||
+ "WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL"
|
.append("WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("Set PA_ReportLine_ID=" + no);
|
log.fine("Set PA_ReportLine_ID=" + no);
|
||||||
|
|
||||||
// **** Update ReportLine
|
// **** Update ReportLine
|
||||||
sql = new StringBuffer ("UPDATE PA_ReportLine r "
|
sql = new StringBuilder ("UPDATE PA_ReportLine r ")
|
||||||
+ "SET (Description,SeqNo,IsSummary,IsPrinted,LineType,CalculationType,AmountType,PAAmountType,PAPeriodType,PostingType,Updated,UpdatedBy)="
|
.append("SET (Description,SeqNo,IsSummary,IsPrinted,LineType,CalculationType,AmountType,PAAmountType,PAPeriodType,PostingType,Updated,UpdatedBy)=")
|
||||||
+ " (SELECT Description,SeqNo,IsSummary,IsPrinted,LineType,CalculationType,AmountType,PAAmountType,PAPeriodType,PostingType,SysDate,UpdatedBy"
|
.append(" (SELECT Description,SeqNo,IsSummary,IsPrinted,LineType,CalculationType,AmountType,PAAmountType,PAPeriodType,PostingType,SysDate,UpdatedBy")
|
||||||
+ " FROM I_ReportLine i WHERE r.Name=i.Name AND r.PA_ReportLineSet_ID=i.PA_ReportLineSet_ID"
|
.append(" FROM I_ReportLine i WHERE r.Name=i.Name AND r.PA_ReportLineSet_ID=i.PA_ReportLineSet_ID")
|
||||||
+ " AND i.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
|
.append(" AND i.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii")
|
||||||
+ " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID)) "
|
.append(" WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID)) ")
|
||||||
+ "WHERE EXISTS (SELECT *"
|
.append("WHERE EXISTS (SELECT *")
|
||||||
+ " FROM I_ReportLine i WHERE r.Name=i.Name AND r.PA_ReportLineSet_ID=i.PA_ReportLineSet_ID"
|
.append(" FROM I_ReportLine i WHERE r.Name=i.Name AND r.PA_ReportLineSet_ID=i.PA_ReportLineSet_ID")
|
||||||
+ " AND i.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
|
.append(" AND i.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii")
|
||||||
+ " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID AND i.I_IsImported='N'))")
|
.append(" WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID AND i.I_IsImported='N'))")
|
||||||
.append(clientCheck);
|
.append(clientCheck);
|
||||||
noUpdateLine = DB.executeUpdate(sql.toString(), get_TrxName());
|
noUpdateLine = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.config("Update PA_ReportLine=" + noUpdateLine);
|
log.config("Update PA_ReportLine=" + noUpdateLine);
|
||||||
|
@ -351,26 +351,26 @@ public class ImportReportLine extends SvrProcess
|
||||||
int noUpdateSource = 0;
|
int noUpdateSource = 0;
|
||||||
|
|
||||||
// **** Create ReportSource
|
// **** Create ReportSource
|
||||||
sql = new StringBuffer ("SELECT I_ReportLine_ID, PA_ReportSource_ID "
|
sql = new StringBuilder ("SELECT I_ReportLine_ID, PA_ReportSource_ID ")
|
||||||
+ "FROM I_ReportLine "
|
.append("FROM I_ReportLine ")
|
||||||
+ "WHERE PA_ReportLine_ID IS NOT NULL"
|
.append("WHERE PA_ReportLine_ID IS NOT NULL")
|
||||||
+ " AND I_IsImported='N'").append(clientCheck);
|
.append(" AND I_IsImported='N'").append(clientCheck);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Insert ReportSource
|
// Insert ReportSource
|
||||||
PreparedStatement pstmt_insertSource = DB.prepareStatement
|
StringBuilder dbpst = new StringBuilder("INSERT INTO PA_ReportSource ")
|
||||||
("INSERT INTO PA_ReportSource "
|
.append("(PA_ReportSource_ID,")
|
||||||
+ "(PA_ReportSource_ID,"
|
.append("AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,")
|
||||||
+ "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
|
.append("PA_ReportLine_ID,ElementType,C_ElementValue_ID) ")
|
||||||
+ "PA_ReportLine_ID,ElementType,C_ElementValue_ID) "
|
.append("SELECT ?,")
|
||||||
+ "SELECT ?,"
|
.append("AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy,")
|
||||||
+ "AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy,"
|
.append("PA_ReportLine_ID,'AC',C_ElementValue_ID ")
|
||||||
+ "PA_ReportLine_ID,'AC',C_ElementValue_ID "
|
.append("FROM I_ReportLine ")
|
||||||
+ "FROM I_ReportLine "
|
.append("WHERE I_ReportLine_ID=?")
|
||||||
+ "WHERE I_ReportLine_ID=?"
|
.append(" AND I_IsImported='N'")
|
||||||
+ " AND I_IsImported='N'"
|
.append(clientCheck);
|
||||||
+ clientCheck, get_TrxName());
|
PreparedStatement pstmt_insertSource = DB.prepareStatement(dbpst.toString(), get_TrxName());
|
||||||
|
|
||||||
// Update ReportSource
|
// Update ReportSource
|
||||||
//jz
|
//jz
|
||||||
|
@ -387,11 +387,11 @@ public class ImportReportLine extends SvrProcess
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Delete ReportSource - afalcone 22/02/2007 - F.R. [ 1642250 ] Import ReportLine / Very Slow Reports
|
// Delete ReportSource - afalcone 22/02/2007 - F.R. [ 1642250 ] Import ReportLine / Very Slow Reports
|
||||||
PreparedStatement pstmt_deleteSource = DB.prepareStatement
|
dbpst = new StringBuilder("DELETE FROM PA_ReportSource ")
|
||||||
("DELETE FROM PA_ReportSource "
|
.append("WHERE C_ElementValue_ID IS NULL")
|
||||||
+ "WHERE C_ElementValue_ID IS NULL"
|
.append(" AND PA_ReportSource_ID=?")
|
||||||
+ " AND PA_ReportSource_ID=?"
|
.append(clientCheck);
|
||||||
+ clientCheck, get_TrxName());
|
PreparedStatement pstmt_deleteSource = DB.prepareStatement(dbpst.toString(), get_TrxName());
|
||||||
//End afalcone 22/02/2007 - F.R. [ 1642250 ] Import ReportLine / Very Slow Reports
|
//End afalcone 22/02/2007 - F.R. [ 1642250 ] Import ReportLine / Very Slow Reports
|
||||||
|
|
||||||
// Set Imported = Y
|
// Set Imported = Y
|
||||||
|
@ -424,8 +424,8 @@ public class ImportReportLine extends SvrProcess
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.finest("Insert ReportSource - " + ex.toString());
|
log.finest("Insert ReportSource - " + ex.toString());
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert ElementSource: " + ex.toString()))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert ElementSource: " + ex.toString()))
|
||||||
.append("WHERE I_ReportLine_ID=").append(I_ReportLine_ID);
|
.append("WHERE I_ReportLine_ID=").append(I_ReportLine_ID);
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -434,15 +434,15 @@ public class ImportReportLine extends SvrProcess
|
||||||
else // update Report Source
|
else // update Report Source
|
||||||
{
|
{
|
||||||
//jz
|
//jz
|
||||||
String sqlt="UPDATE PA_ReportSource "
|
StringBuilder sqlt= new StringBuilder("UPDATE PA_ReportSource ")
|
||||||
+ "SET (ElementType,C_ElementValue_ID,Updated,UpdatedBy)="
|
.append("SET (ElementType,C_ElementValue_ID,Updated,UpdatedBy)=")
|
||||||
+ " (SELECT CAST('AC' AS CHAR(2)),C_ElementValue_ID,SysDate,UpdatedBy" //jz
|
.append(" (SELECT CAST('AC' AS CHAR(2)),C_ElementValue_ID,SysDate,UpdatedBy") //jz
|
||||||
+ " FROM I_ReportLine"
|
.append(" FROM I_ReportLine")
|
||||||
+ " WHERE I_ReportLine_ID=" + I_ReportLine_ID + ") "
|
.append(" WHERE I_ReportLine_ID=").append(I_ReportLine_ID).append(") ")
|
||||||
+ "WHERE PA_ReportSource_ID="+PA_ReportSource_ID+" "
|
.append("WHERE PA_ReportSource_ID=").append(PA_ReportSource_ID).append(" ")
|
||||||
+ clientCheck;
|
.append(clientCheck);
|
||||||
PreparedStatement pstmt_updateSource = DB.prepareStatement
|
PreparedStatement pstmt_updateSource = DB.prepareStatement
|
||||||
(sqlt, get_TrxName());
|
(sqlt.toString(), get_TrxName());
|
||||||
//pstmt_updateSource.setInt(1, I_ReportLine_ID);
|
//pstmt_updateSource.setInt(1, I_ReportLine_ID);
|
||||||
//pstmt_updateSource.setInt(2, PA_ReportSource_ID);
|
//pstmt_updateSource.setInt(2, PA_ReportSource_ID);
|
||||||
try
|
try
|
||||||
|
@ -455,8 +455,8 @@ public class ImportReportLine extends SvrProcess
|
||||||
catch (SQLException ex)
|
catch (SQLException ex)
|
||||||
{
|
{
|
||||||
log.finest( "Update ReportSource - " + ex.toString());
|
log.finest( "Update ReportSource - " + ex.toString());
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine i "
|
sql = new StringBuilder ("UPDATE I_ReportLine i ")
|
||||||
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update ElementSource: " + ex.toString()))
|
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update ElementSource: " + ex.toString()))
|
||||||
.append("WHERE I_ReportLine_ID=").append(I_ReportLine_ID);
|
.append("WHERE I_ReportLine_ID=").append(I_ReportLine_ID);
|
||||||
DB.executeUpdate(sql.toString(), get_TrxName());
|
DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -494,9 +494,9 @@ public class ImportReportLine extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Error to indicator to not imported
|
// Set Error to indicator to not imported
|
||||||
sql = new StringBuffer ("UPDATE I_ReportLine "
|
sql = new StringBuilder ("UPDATE I_ReportLine ")
|
||||||
+ "SET I_IsImported='N', Updated=SysDate "
|
.append("SET I_IsImported='N', Updated=SysDate ")
|
||||||
+ "WHERE I_IsImported<>'Y'").append(clientCheck);
|
.append("WHERE I_IsImported<>'Y'").append(clientCheck);
|
||||||
|
|
||||||
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
addLog (0, null, new BigDecimal (no), "@Errors@");
|
addLog (0, null, new BigDecimal (no), "@Errors@");
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class InOutGenerate extends SvrProcess
|
||||||
private int m_lastC_BPartner_Location_ID = -1;
|
private int m_lastC_BPartner_Location_ID = -1;
|
||||||
|
|
||||||
/** The Query sql */
|
/** The Query sql */
|
||||||
private String m_sql = null;
|
private StringBuffer m_sql = null;
|
||||||
|
|
||||||
|
|
||||||
/** Storages temp space */
|
/** Storages temp space */
|
||||||
|
@ -147,38 +147,38 @@ public class InOutGenerate extends SvrProcess
|
||||||
|
|
||||||
if (p_Selection) // VInOutGen
|
if (p_Selection) // VInOutGen
|
||||||
{
|
{
|
||||||
m_sql = "SELECT C_Order.* FROM C_Order, T_Selection "
|
m_sql = new StringBuffer("SELECT C_Order.* FROM C_Order, T_Selection ")
|
||||||
+ "WHERE C_Order.DocStatus='CO' AND C_Order.IsSOTrx='Y' AND C_Order.AD_Client_ID=? "
|
.append("WHERE C_Order.DocStatus='CO' AND C_Order.IsSOTrx='Y' AND C_Order.AD_Client_ID=? ")
|
||||||
+ "AND C_Order.C_Order_ID = T_Selection.T_Selection_ID "
|
.append("AND C_Order.C_Order_ID = T_Selection.T_Selection_ID ")
|
||||||
+ "AND T_Selection.AD_PInstance_ID=? ";
|
.append("AND T_Selection.AD_PInstance_ID=? ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sql = "SELECT * FROM C_Order o "
|
m_sql = new StringBuffer("SELECT * FROM C_Order o ")
|
||||||
+ "WHERE DocStatus='CO' AND IsSOTrx='Y'"
|
.append("WHERE DocStatus='CO' AND IsSOTrx='Y'")
|
||||||
// No Offer,POS
|
// No Offer,POS
|
||||||
+ " AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType "
|
.append(" AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType ")
|
||||||
+ "WHERE DocBaseType='SOO' AND DocSubTypeSO NOT IN ('ON','OB','WR'))"
|
.append("WHERE DocBaseType='SOO' AND DocSubTypeSO NOT IN ('ON','OB','WR'))")
|
||||||
+ " AND o.IsDropShip='N'"
|
.append(" AND o.IsDropShip='N'")
|
||||||
// No Manual
|
// No Manual
|
||||||
+ " AND o.DeliveryRule<>'M'"
|
.append(" AND o.DeliveryRule<>'M'")
|
||||||
// Open Order Lines with Warehouse
|
// Open Order Lines with Warehouse
|
||||||
+ " AND EXISTS (SELECT * FROM C_OrderLine ol "
|
.append(" AND EXISTS (SELECT * FROM C_OrderLine ol ")
|
||||||
+ "WHERE ol.M_Warehouse_ID=?"; // #1
|
.append("WHERE ol.M_Warehouse_ID=?"); // #1
|
||||||
if (p_DatePromised != null)
|
if (p_DatePromised != null)
|
||||||
m_sql += " AND TRUNC(ol.DatePromised)<=?"; // #2
|
m_sql.append(" AND TRUNC(ol.DatePromised)<=?"); // #2
|
||||||
m_sql += " AND o.C_Order_ID=ol.C_Order_ID AND ol.QtyOrdered<>ol.QtyDelivered)";
|
m_sql.append(" AND o.C_Order_ID=ol.C_Order_ID AND ol.QtyOrdered<>ol.QtyDelivered)");
|
||||||
//
|
//
|
||||||
if (p_C_BPartner_ID != 0)
|
if (p_C_BPartner_ID != 0)
|
||||||
m_sql += " AND o.C_BPartner_ID=?"; // #3
|
m_sql.append(" AND o.C_BPartner_ID=?"); // #3
|
||||||
}
|
}
|
||||||
m_sql += " ORDER BY M_Warehouse_ID, PriorityRule, M_Shipper_ID, C_BPartner_ID, C_BPartner_Location_ID, C_Order_ID";
|
m_sql.append(" ORDER BY M_Warehouse_ID, PriorityRule, M_Shipper_ID, C_BPartner_ID, C_BPartner_Location_ID, C_Order_ID");
|
||||||
// m_sql += " FOR UPDATE";
|
// m_sql += " FOR UPDATE";
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (m_sql, get_TrxName());
|
pstmt = DB.prepareStatement (m_sql.toString(), get_TrxName());
|
||||||
int index = 1;
|
int index = 1;
|
||||||
if (p_Selection)
|
if (p_Selection)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ public class InOutGenerate extends SvrProcess
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, m_sql, e);
|
log.log(Level.SEVERE, m_sql.toString(), e);
|
||||||
}
|
}
|
||||||
return generate(pstmt);
|
return generate(pstmt);
|
||||||
} // doIt
|
} // doIt
|
||||||
|
@ -228,23 +228,23 @@ public class InOutGenerate extends SvrProcess
|
||||||
Timestamp minGuaranteeDate = m_movementDate;
|
Timestamp minGuaranteeDate = m_movementDate;
|
||||||
boolean completeOrder = MOrder.DELIVERYRULE_CompleteOrder.equals(order.getDeliveryRule());
|
boolean completeOrder = MOrder.DELIVERYRULE_CompleteOrder.equals(order.getDeliveryRule());
|
||||||
// OrderLine WHERE
|
// OrderLine WHERE
|
||||||
String where = " AND M_Warehouse_ID=" + p_M_Warehouse_ID;
|
StringBuilder where = new StringBuilder(" AND M_Warehouse_ID=").append(p_M_Warehouse_ID);
|
||||||
if (p_DatePromised != null)
|
if (p_DatePromised != null)
|
||||||
where += " AND (TRUNC(DatePromised)<=" + DB.TO_DATE(p_DatePromised, true)
|
where.append(" AND (TRUNC(DatePromised)<=").append(DB.TO_DATE(p_DatePromised, true))
|
||||||
+ " OR DatePromised IS NULL)";
|
.append(" OR DatePromised IS NULL)");
|
||||||
// Exclude Auto Delivery if not Force
|
// Exclude Auto Delivery if not Force
|
||||||
if (!MOrder.DELIVERYRULE_Force.equals(order.getDeliveryRule()))
|
if (!MOrder.DELIVERYRULE_Force.equals(order.getDeliveryRule()))
|
||||||
where += " AND (C_OrderLine.M_Product_ID IS NULL"
|
where.append(" AND (C_OrderLine.M_Product_ID IS NULL")
|
||||||
+ " OR EXISTS (SELECT * FROM M_Product p "
|
.append(" OR EXISTS (SELECT * FROM M_Product p ")
|
||||||
+ "WHERE C_OrderLine.M_Product_ID=p.M_Product_ID"
|
.append("WHERE C_OrderLine.M_Product_ID=p.M_Product_ID")
|
||||||
+ " AND IsExcludeAutoDelivery='N'))";
|
.append(" AND IsExcludeAutoDelivery='N'))");
|
||||||
// Exclude Unconfirmed
|
// Exclude Unconfirmed
|
||||||
if (!p_IsUnconfirmedInOut)
|
if (!p_IsUnconfirmedInOut)
|
||||||
where += " AND NOT EXISTS (SELECT * FROM M_InOutLine iol"
|
where.append(" AND NOT EXISTS (SELECT * FROM M_InOutLine iol")
|
||||||
+ " INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID) "
|
.append(" INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID) ")
|
||||||
+ "WHERE iol.C_OrderLine_ID=C_OrderLine.C_OrderLine_ID AND io.DocStatus IN ('IP','WC'))";
|
.append("WHERE iol.C_OrderLine_ID=C_OrderLine.C_OrderLine_ID AND io.DocStatus IN ('IP','WC'))");
|
||||||
// Deadlock Prevention - Order by M_Product_ID
|
// Deadlock Prevention - Order by M_Product_ID
|
||||||
MOrderLine[] lines = order.getLines (where, "C_BPartner_Location_ID, M_Product_ID");
|
MOrderLine[] lines = order.getLines (where.toString(), "C_BPartner_Location_ID, M_Product_ID");
|
||||||
for (int i = 0; i < lines.length; i++)
|
for (int i = 0; i < lines.length; i++)
|
||||||
{
|
{
|
||||||
MOrderLine line = lines[i];
|
MOrderLine line = lines[i];
|
||||||
|
@ -272,18 +272,18 @@ public class InOutGenerate extends SvrProcess
|
||||||
line.getC_OrderLine_ID(), where2, null);
|
line.getC_OrderLine_ID(), where2, null);
|
||||||
for (int j = 0; j < iols.length; j++)
|
for (int j = 0; j < iols.length; j++)
|
||||||
unconfirmedShippedQty = unconfirmedShippedQty.add(iols[j].getMovementQty());
|
unconfirmedShippedQty = unconfirmedShippedQty.add(iols[j].getMovementQty());
|
||||||
String logInfo = "Unconfirmed Qty=" + unconfirmedShippedQty
|
StringBuilder logInfo = new StringBuilder("Unconfirmed Qty=").append(unconfirmedShippedQty)
|
||||||
+ " - ToDeliver=" + toDeliver + "->";
|
.append(" - ToDeliver=").append(toDeliver).append("->");
|
||||||
toDeliver = toDeliver.subtract(unconfirmedShippedQty);
|
toDeliver = toDeliver.subtract(unconfirmedShippedQty);
|
||||||
logInfo += toDeliver;
|
logInfo.append(toDeliver);
|
||||||
if (toDeliver.signum() < 0)
|
if (toDeliver.signum() < 0)
|
||||||
{
|
{
|
||||||
toDeliver = Env.ZERO;
|
toDeliver = Env.ZERO;
|
||||||
logInfo += " (set to 0)";
|
logInfo.append(" (set to 0)");
|
||||||
}
|
}
|
||||||
// Adjust On Hand
|
// Adjust On Hand
|
||||||
onHand = onHand.subtract(unconfirmedShippedQty);
|
onHand = onHand.subtract(unconfirmedShippedQty);
|
||||||
log.fine(logInfo);
|
log.fine(logInfo.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comments & lines w/o product & services
|
// Comments & lines w/o product & services
|
||||||
|
@ -397,7 +397,7 @@ public class InOutGenerate extends SvrProcess
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, m_sql, e);
|
log.log(Level.SEVERE, m_sql.toString(), e);
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -410,7 +410,8 @@ public class InOutGenerate extends SvrProcess
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
completeShipment();
|
completeShipment();
|
||||||
return "@Created@ = " + m_created;
|
StringBuilder msgreturn = new StringBuilder("@Created@ = ").append(m_created);
|
||||||
|
return msgreturn.toString();
|
||||||
} // generate
|
} // generate
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,16 +119,16 @@ public class InventoryCountCreate extends SvrProcess
|
||||||
if (p_DeleteOld)
|
if (p_DeleteOld)
|
||||||
{
|
{
|
||||||
//Added Line by armen
|
//Added Line by armen
|
||||||
String sql1 = "DELETE FROM M_InventoryLineMA ma WHERE EXISTS "
|
StringBuilder sql1 = new StringBuilder("DELETE FROM M_InventoryLineMA ma WHERE EXISTS ")
|
||||||
+ "(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID"
|
.append("(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID")
|
||||||
+ " AND Processed='N' AND M_Inventory_ID=" + p_M_Inventory_ID + ")";
|
.append(" AND Processed='N' AND M_Inventory_ID=").append(p_M_Inventory_ID).append(")");
|
||||||
int no1 = DB.executeUpdate(sql1, get_TrxName());
|
int no1 = DB.executeUpdate(sql1.toString(), get_TrxName());
|
||||||
log.fine("doIt - Deleted MA #" + no1);
|
log.fine("doIt - Deleted MA #" + no1);
|
||||||
//End of Added Line
|
//End of Added Line
|
||||||
|
|
||||||
String sql = "DELETE M_InventoryLine WHERE Processed='N' "
|
StringBuilder sql = new StringBuilder("DELETE M_InventoryLine WHERE Processed='N' ")
|
||||||
+ "AND M_Inventory_ID=" + p_M_Inventory_ID;
|
.append("AND M_Inventory_ID=").append(p_M_Inventory_ID);
|
||||||
int no = DB.executeUpdate(sql, get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.fine("doIt - Deleted #" + no);
|
log.fine("doIt - Deleted #" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,15 +257,16 @@ public class InventoryCountCreate extends SvrProcess
|
||||||
// Set Count to Zero
|
// Set Count to Zero
|
||||||
if (p_InventoryCountSetZero)
|
if (p_InventoryCountSetZero)
|
||||||
{
|
{
|
||||||
String sql1 = "UPDATE M_InventoryLine l "
|
StringBuilder sql1 = new StringBuilder("UPDATE M_InventoryLine l ")
|
||||||
+ "SET QtyCount=0 "
|
.append("SET QtyCount=0 ")
|
||||||
+ "WHERE M_Inventory_ID=" + p_M_Inventory_ID;
|
.append("WHERE M_Inventory_ID=").append(p_M_Inventory_ID);
|
||||||
int no = DB.executeUpdate(sql1, get_TrxName());
|
int no = DB.executeUpdate(sql1.toString(), get_TrxName());
|
||||||
log.info("Set Cont to Zero=" + no);
|
log.info("Set Cont to Zero=" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return "@M_InventoryLine_ID@ - #" + count;
|
StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append(count);
|
||||||
|
return msgreturn.toString();
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -350,7 +351,7 @@ public class InventoryCountCreate extends SvrProcess
|
||||||
private String getSubCategoryWhereClause(int productCategoryId) throws SQLException, AdempiereSystemError{
|
private String getSubCategoryWhereClause(int productCategoryId) throws SQLException, AdempiereSystemError{
|
||||||
//if a node with this id is found later in the search we have a loop in the tree
|
//if a node with this id is found later in the search we have a loop in the tree
|
||||||
int subTreeRootParentId = 0;
|
int subTreeRootParentId = 0;
|
||||||
String retString = " ";
|
StringBuilder retString = new StringBuilder();
|
||||||
String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category";
|
String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category";
|
||||||
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
|
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
|
||||||
Statement stmt = DB.createStatement();
|
Statement stmt = DB.createStatement();
|
||||||
|
@ -361,10 +362,10 @@ public class InventoryCountCreate extends SvrProcess
|
||||||
}
|
}
|
||||||
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
|
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
|
||||||
}
|
}
|
||||||
retString += getSubCategoriesString(productCategoryId, categories, subTreeRootParentId);
|
retString.append(getSubCategoriesString(productCategoryId, categories, subTreeRootParentId));
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
return retString;
|
return retString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -389,7 +390,8 @@ public class InventoryCountCreate extends SvrProcess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.fine(ret.toString());
|
log.fine(ret.toString());
|
||||||
return ret.toString() + productCategoryId;
|
StringBuilder msgreturn = new StringBuilder(ret).append(productCategoryId);
|
||||||
|
return msgreturn.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,34 +75,34 @@ public class InventoryCountUpdate extends SvrProcess
|
||||||
throw new AdempiereSystemError ("Not found: M_Inventory_ID=" + p_M_Inventory_ID);
|
throw new AdempiereSystemError ("Not found: M_Inventory_ID=" + p_M_Inventory_ID);
|
||||||
|
|
||||||
// Multiple Lines for one item
|
// Multiple Lines for one item
|
||||||
String sql = "UPDATE M_InventoryLine SET IsActive='N' "
|
StringBuilder sql = new StringBuilder("UPDATE M_InventoryLine SET IsActive='N' ")
|
||||||
+ "WHERE M_Inventory_ID=" + p_M_Inventory_ID
|
.append("WHERE M_Inventory_ID=").append(p_M_Inventory_ID)
|
||||||
+ " AND (M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID) IN "
|
.append(" AND (M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID) IN ")
|
||||||
+ "(SELECT M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
|
.append("(SELECT M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID ")
|
||||||
+ "FROM M_InventoryLine "
|
.append("FROM M_InventoryLine ")
|
||||||
+ "WHERE M_Inventory_ID=" + p_M_Inventory_ID
|
.append("WHERE M_Inventory_ID=").append(p_M_Inventory_ID)
|
||||||
+ " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
|
.append(" GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID ")
|
||||||
+ "HAVING COUNT(*) > 1)";
|
.append("HAVING COUNT(*) > 1)");
|
||||||
int multiple = DB.executeUpdate(sql, get_TrxName());
|
int multiple = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Multiple=" + multiple);
|
log.info("Multiple=" + multiple);
|
||||||
|
|
||||||
int delMA = MInventoryLineMA.deleteInventoryMA(p_M_Inventory_ID, get_TrxName());
|
int delMA = MInventoryLineMA.deleteInventoryMA(p_M_Inventory_ID, get_TrxName());
|
||||||
log.info("DeletedMA=" + delMA);
|
log.info("DeletedMA=" + delMA);
|
||||||
|
|
||||||
// ASI
|
// ASI
|
||||||
sql = "UPDATE M_InventoryLine l "
|
sql = new StringBuilder("UPDATE M_InventoryLine l ")
|
||||||
+ "SET (QtyBook,QtyCount) = "
|
.append("SET (QtyBook,QtyCount) = ")
|
||||||
+ "(SELECT QtyOnHand,QtyOnHand FROM M_Storage s "
|
.append("(SELECT QtyOnHand,QtyOnHand FROM M_Storage s ")
|
||||||
+ "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
|
.append("WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID")
|
||||||
+ " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),"
|
.append(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),")
|
||||||
+ " Updated=SysDate,"
|
.append(" Updated=SysDate,")
|
||||||
+ " UpdatedBy=" + getAD_User_ID()
|
.append(" UpdatedBy=").append(getAD_User_ID())
|
||||||
//
|
//
|
||||||
+ " WHERE M_Inventory_ID=" + p_M_Inventory_ID
|
.append(" WHERE M_Inventory_ID=").append(p_M_Inventory_ID)
|
||||||
+ " AND EXISTS (SELECT * FROM M_Storage s "
|
.append(" AND EXISTS (SELECT * FROM M_Storage s ")
|
||||||
+ "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
|
.append("WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID")
|
||||||
+ " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)";
|
.append(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)");
|
||||||
int no = DB.executeUpdate(sql, get_TrxName());
|
int no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Update with ASI=" + no);
|
log.info("Update with ASI=" + no);
|
||||||
|
|
||||||
// No ASI
|
// No ASI
|
||||||
|
@ -111,17 +111,19 @@ public class InventoryCountUpdate extends SvrProcess
|
||||||
// Set Count to Zero
|
// Set Count to Zero
|
||||||
if (p_InventoryCountSetZero)
|
if (p_InventoryCountSetZero)
|
||||||
{
|
{
|
||||||
sql = "UPDATE M_InventoryLine l "
|
sql = new StringBuilder("UPDATE M_InventoryLine l ")
|
||||||
+ "SET QtyCount=0 "
|
.append("SET QtyCount=0 ")
|
||||||
+ "WHERE M_Inventory_ID=" + p_M_Inventory_ID;
|
.append("WHERE M_Inventory_ID=").append(p_M_Inventory_ID);
|
||||||
no = DB.executeUpdate(sql, get_TrxName());
|
no = DB.executeUpdate(sql.toString(), get_TrxName());
|
||||||
log.info("Set Count to Zero=" + no);
|
log.info("Set Count to Zero=" + no);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multiple > 0)
|
if (multiple > 0){
|
||||||
return "@M_InventoryLine_ID@ - #" + (no + noMA) + " --> @InventoryProductMultiple@";
|
StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append((no + noMA)).append(" --> @InventoryProductMultiple@");
|
||||||
|
return msgreturn.toString();
|
||||||
return "@M_InventoryLine_ID@ - #" + no;
|
}
|
||||||
|
StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append(no);
|
||||||
|
return msgreturn.toString();
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue