BF [2274170] Inbound Charges for AP
This commit is contained in:
parent
ef19193398
commit
243bb7b7de
|
@ -20,7 +20,6 @@ import java.util.logging.Level;
|
|||
import org.compiere.model.X_C_Invoice;
|
||||
import org.compiere.model.X_C_InvoiceLine;
|
||||
import org.compiere.model.X_M_Product;
|
||||
import org.compiere.model.X_M_Product_Category;
|
||||
import org.compiere.model.X_C_BPartner;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.util.DB;
|
||||
|
@ -73,20 +72,26 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
int uselifeyears = 0;
|
||||
int C_Period_ID=0;
|
||||
int invoiceAcct=0;
|
||||
|
||||
String sql =" SELECT * FROM C_InvoiceLine WHERE A_Processed is null and AD_Client_ID = ?"
|
||||
//Yvonne: add in recordInsertedCount
|
||||
int recordInsertedCount = 0;
|
||||
//Yvonne: changed A_Processed is null to A_Processed='N'
|
||||
String sql =" SELECT * FROM C_InvoiceLine WHERE A_Processed='N' and AD_Client_ID = ?"
|
||||
+ " and A_CreateAsset = 'Y' and Processed = 'Y'";
|
||||
|
||||
log.info("sql"+sql+p_client);
|
||||
PreparedStatement pstmt = null;
|
||||
pstmt = DB.prepareStatement(sql,get_TrxName());
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt.setInt(1, p_client);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
int i=0;
|
||||
|
||||
while (rs.next()){
|
||||
i=i+1;
|
||||
log.info("here is the counter "+i);
|
||||
X_A_Asset asset = new X_A_Asset (getCtx(), rs.getInt("A_Asset_ID"), get_TrxName());
|
||||
|
||||
X_C_Invoice Invoice = new X_C_Invoice (getCtx(), rs.getInt("C_Invoice_ID"), get_TrxName());
|
||||
X_C_InvoiceLine InvoiceLine = new X_C_InvoiceLine (getCtx(), rs, get_TrxName());
|
||||
X_M_Product product = new X_M_Product (getCtx(), InvoiceLine.getM_Product_ID(), get_TrxName());
|
||||
|
@ -193,6 +198,7 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
assetacct.setA_Depreciation_Table_Header_ID(assetgrpacct.getA_Depreciation_Table_Header_ID());
|
||||
assetacct.setA_Depreciation_Variable_Perc(assetgrpacct.getA_Depreciation_Variable_Perc());
|
||||
assetacct.setProcessing(false);
|
||||
assetacct.getAD_Client_ID();
|
||||
assetacct.save();
|
||||
|
||||
MAssetChange change = new MAssetChange (getCtx(), 0, get_TrxName());
|
||||
|
@ -298,8 +304,7 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
ResultSet rs4 = pstmt4.executeQuery();
|
||||
if (rs4.next())
|
||||
C_Period_ID = rs4.getInt(1);
|
||||
rs4.close();
|
||||
pstmt4.close();
|
||||
DB.close(rs4, pstmt4);
|
||||
pstmt4 = null;
|
||||
}
|
||||
catch (SQLException e)
|
||||
|
@ -369,6 +374,7 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
depexp2.setA_Period(C_Period_ID);
|
||||
depexp2.setA_Entry_Type("NEW");
|
||||
depexp2.save();
|
||||
recordInsertedCount++;
|
||||
|
||||
X_A_Depreciation_Exp depexp3 = new X_A_Depreciation_Exp (getCtx(), 0, get_TrxName());
|
||||
depexp3.setPostingType(assetacct.getPostingType());
|
||||
|
@ -381,6 +387,7 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
depexp3.setA_Period(C_Period_ID);
|
||||
depexp3.setA_Entry_Type("NEW");
|
||||
depexp3.save();
|
||||
recordInsertedCount++;
|
||||
|
||||
//Determine if tax adjustment is necessary
|
||||
if (InvoiceLine.getTaxAmt().compareTo(new BigDecimal (0))!=0){
|
||||
|
@ -398,6 +405,8 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
depexp4.setA_Period(C_Period_ID);
|
||||
depexp4.setA_Entry_Type("NEW");
|
||||
depexp4.save();
|
||||
recordInsertedCount++;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -405,11 +414,11 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
sql2 ="SELECT * FROM A_Depreciation_Workfile WHERE A_Asset_ID = ? and PostingType = ?";
|
||||
PreparedStatement pstmt2 = null;
|
||||
pstmt2 = DB.prepareStatement(sql2,get_TrxName());
|
||||
|
||||
ResultSet rs3 = null;
|
||||
try {
|
||||
pstmt2.setInt(1, asset.getA_Asset_ID());
|
||||
pstmt2.setString(2, assetgrpacct.getPostingType());
|
||||
ResultSet rs3 = pstmt2.executeQuery();
|
||||
rs3 = pstmt2.executeQuery();
|
||||
while (rs3.next()){
|
||||
X_A_Depreciation_Workfile assetwk = new X_A_Depreciation_Workfile (getCtx(), rs3, get_TrxName());
|
||||
assetwk.setA_Asset_ID(asset.getA_Asset_ID());
|
||||
|
@ -468,6 +477,7 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
depexp2.setA_Period(C_Period_ID);
|
||||
depexp2.setA_Entry_Type("NEW");
|
||||
depexp2.save();
|
||||
recordInsertedCount++;
|
||||
|
||||
X_A_Depreciation_Exp depexp3 = new X_A_Depreciation_Exp (getCtx(), 0, get_TrxName());
|
||||
depexp3.setPostingType(assetacct.getPostingType());
|
||||
|
@ -480,6 +490,7 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
depexp3.setA_Period(C_Period_ID);
|
||||
depexp3.setA_Entry_Type("NEW");
|
||||
depexp3.save();
|
||||
recordInsertedCount++;
|
||||
|
||||
//Determine if tax adjustment is necessary
|
||||
if (InvoiceLine.getTaxAmt().compareTo(new BigDecimal (0))!=0){
|
||||
|
@ -497,13 +508,10 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
depexp4.setA_Period(C_Period_ID);
|
||||
depexp4.setA_Entry_Type("NEW");
|
||||
depexp4.save();
|
||||
recordInsertedCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rs3.close();
|
||||
pstmt2.close();
|
||||
pstmt2 = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -511,21 +519,14 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pstmt2 != null)
|
||||
pstmt2.close ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
DB.close(rs3, pstmt2);
|
||||
pstmt2 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
rs2.close();
|
||||
pstmt1.close();
|
||||
DB.close(rs2, pstmt1);
|
||||
pstmt1 = null;
|
||||
}
|
||||
else if (rs.getString("A_CapvsExp").equals("Exp"))
|
||||
|
@ -558,9 +559,7 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
InvoiceLine.set_ValueOfColumn(I_CustomColumn.A_Processed, Boolean.TRUE);
|
||||
InvoiceLine.save();
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -568,17 +567,18 @@ public class CreateInvoicedAsset extends SvrProcess
|
|||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
DB.close(rs, pstmt);
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
return "";
|
||||
if (recordInsertedCount > 0)
|
||||
{
|
||||
return recordInsertedCount + " record(s) inserted.";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Zero record inserted.";
|
||||
}
|
||||
} // doIt
|
||||
|
||||
/**
|
||||
|
|
|
@ -125,7 +125,7 @@ public class MAssetAcct extends X_A_Asset_Acct {
|
|||
|
||||
} else {
|
||||
X_A_Asset_Acct assetacct = new X_A_Asset_Acct(getCtx(),
|
||||
p_actasset_ID, null);
|
||||
p_actasset_ID, this.get_TrxName());
|
||||
assetacct.setPostingType(getPostingType());
|
||||
assetacct.setA_Split_Percent(getA_Split_Percent());
|
||||
assetacct.setA_Depreciation_Conv_ID(getA_Depreciation_Conv_ID());
|
||||
|
|
Loading…
Reference in New Issue