parent
37d6304428
commit
0db90f7bb6
|
|
@ -24,14 +24,14 @@ import java.sql.Timestamp;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.exceptions.DBException;
|
import org.adempiere.exceptions.DBException;
|
||||||
|
import org.compiere.model.MAging;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
|
import org.compiere.print.ReportEngine;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.TimeUtil;
|
import org.compiere.util.TimeUtil;
|
||||||
|
|
||||||
import andromedia.midsuit.model.MID_Aging;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoice Aging Report.
|
* Invoice Aging Report.
|
||||||
* Based on RV_Aging.
|
* Based on RV_Aging.
|
||||||
|
|
@ -56,7 +56,6 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
private boolean p_IsListInvoices = false;
|
private boolean p_IsListInvoices = false;
|
||||||
/** Number of days between today and statement date */
|
/** Number of days between today and statement date */
|
||||||
private int m_statementOffset = 0;
|
private int m_statementOffset = 0;
|
||||||
private String m_DocBaseType = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare - e.g., get Parameters.
|
* Prepare - e.g., get Parameters.
|
||||||
|
|
@ -85,8 +84,6 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
p_C_BPartner_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
p_C_BPartner_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
else if (name.equals("IsListInvoices"))
|
else if (name.equals("IsListInvoices"))
|
||||||
p_IsListInvoices = "Y".equals(para[i].getParameter());
|
p_IsListInvoices = "Y".equals(para[i].getParameter());
|
||||||
else if (name.equals("DocBaseType"))
|
|
||||||
m_DocBaseType = (String)para[i].getParameterAsString();
|
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +139,6 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sql.append(",oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID "); // 14..17
|
sql.append(",oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID "); // 14..17
|
||||||
sql.append(",alo.UnallocatedPayment ");
|
|
||||||
if (!p_DateAcct)//FR 1933937
|
if (!p_DateAcct)//FR 1933937
|
||||||
{
|
{
|
||||||
sql.append(" FROM RV_OpenItem oi");
|
sql.append(" FROM RV_OpenItem oi");
|
||||||
|
|
@ -153,16 +149,6 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.append(" INNER JOIN C_BPartner bp ON (oi.C_BPartner_ID=bp.C_BPartner_ID) "
|
sql.append(" INNER JOIN C_BPartner bp ON (oi.C_BPartner_ID=bp.C_BPartner_ID) "
|
||||||
+ "LEFT JOIN C_DocType dt ON (dt.C_DocType_ID=oi.C_DocType_ID) "
|
|
||||||
+ "LEFT JOIN (select c_bpartner_id, " +
|
|
||||||
"sum(payment) as UnallocatedPayment " +
|
|
||||||
"FROM " +
|
|
||||||
"(SELECT p.c_bpartner_id, " +
|
|
||||||
"p.payamt + (coalesce(sum(al.amount),0)) as payment " +
|
|
||||||
"FROM C_Payment p " +
|
|
||||||
"left join c_allocationline al on al.c_payment_id = p.c_payment_id " +
|
|
||||||
"group by p.c_bpartner_id, payamt) allo " +
|
|
||||||
"group by c_bpartner_id) alo ON alo.C_BPartner_ID = oi.C_BPartner_ID "
|
|
||||||
+ "WHERE oi.ISSoTrx=").append(p_IsSOTrx ? "'Y'" : "'N'");
|
+ "WHERE oi.ISSoTrx=").append(p_IsSOTrx ? "'Y'" : "'N'");
|
||||||
if (p_C_BPartner_ID > 0)
|
if (p_C_BPartner_ID > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -181,21 +167,19 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
{
|
{
|
||||||
sql.append(" AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,"+dateacct+") <> 0 ");
|
sql.append(" AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,"+dateacct+") <> 0 ");
|
||||||
}
|
}
|
||||||
if (m_DocBaseType!=null) {
|
|
||||||
sql.append(" AND dt.DocBaseType='").append(m_DocBaseType).append("'");
|
|
||||||
}
|
|
||||||
|
|
||||||
sql.append(" ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID");
|
sql.append(" ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID");
|
||||||
|
|
||||||
if (log.isLoggable(Level.FINEST)) log.finest(sql.toString());
|
if (log.isLoggable(Level.FINEST)) log.finest(sql.toString());
|
||||||
String finalSql = MRole.getDefault(getCtx(), false).addAccessSQL(
|
// String finalSql = MRole.getDefault(getCtx(), false).addAccessSQL(
|
||||||
sql.toString(), "oi", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
// sql.toString(), "oi", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||||
|
String finalSql = sql.toString();
|
||||||
log.finer(finalSql);
|
log.finer(finalSql);
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
//
|
//
|
||||||
MID_Aging aging = null;
|
MAging aging = null;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
int AD_PInstance_ID = getAD_PInstance_ID();
|
int AD_PInstance_ID = getAD_PInstance_ID();
|
||||||
|
|
@ -228,11 +212,8 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
int C_Campaign_ID = p_IsListInvoices ? rs.getInt(15) : 0;
|
int C_Campaign_ID = p_IsListInvoices ? rs.getInt(15) : 0;
|
||||||
int C_Project_ID = p_IsListInvoices ? rs.getInt(16) : 0;
|
int C_Project_ID = p_IsListInvoices ? rs.getInt(16) : 0;
|
||||||
int AD_Org_ID = rs.getInt(17);
|
int AD_Org_ID = rs.getInt(17);
|
||||||
BigDecimal UnallocatedPayment = rs.getBigDecimal(18);
|
|
||||||
|
|
||||||
rows++;
|
rows++;
|
||||||
|
|
||||||
aging.add (DueDate, DaysDue, GrandTotal, OpenAmt, UnallocatedPayment);
|
|
||||||
// New Aging Row
|
// New Aging Row
|
||||||
if (aging == null // Key
|
if (aging == null // Key
|
||||||
|| AD_PInstance_ID != aging.getAD_PInstance_ID()
|
|| AD_PInstance_ID != aging.getAD_PInstance_ID()
|
||||||
|
|
@ -246,7 +227,7 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
aging.saveEx();
|
aging.saveEx();
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("#" + ++counter + " - " + aging);
|
if (log.isLoggable(Level.FINE)) log.fine("#" + ++counter + " - " + aging);
|
||||||
}
|
}
|
||||||
aging = new MID_Aging (getCtx(), AD_PInstance_ID, p_StatementDate,
|
aging = new MAging (getCtx(), AD_PInstance_ID, p_StatementDate,
|
||||||
C_BPartner_ID, C_Currency_ID,
|
C_BPartner_ID, C_Currency_ID,
|
||||||
C_Invoice_ID, C_InvoicePaySchedule_ID,
|
C_Invoice_ID, C_InvoicePaySchedule_ID,
|
||||||
C_BP_Group_ID, AD_Org_ID, DueDate, IsSOTrx, get_TrxName());
|
C_BP_Group_ID, AD_Org_ID, DueDate, IsSOTrx, get_TrxName());
|
||||||
|
|
@ -256,7 +237,7 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
aging.setDateAcct(p_DateAcct);
|
aging.setDateAcct(p_DateAcct);
|
||||||
}
|
}
|
||||||
// Fill Buckets
|
// Fill Buckets
|
||||||
|
aging.add (DueDate, DaysDue, GrandTotal, OpenAmt);
|
||||||
}
|
}
|
||||||
if (aging != null)
|
if (aging != null)
|
||||||
{
|
{
|
||||||
|
|
@ -277,6 +258,7 @@ public class MID_ProcessRVAging extends SvrProcess
|
||||||
//
|
//
|
||||||
if (log.isLoggable(Level.INFO)) log.info("#" + counter + " - rows=" + rows);
|
if (log.isLoggable(Level.INFO)) log.info("#" + counter + " - rows=" + rows);
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
} // Aging
|
} // Aging
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue