1 14 package org.compiere.acct; 15 16 import java.math.*; 17 import java.util.*; 18 import java.sql.*; 19 20 import org.compiere.util.*; 21 import org.compiere.model.*; 22 23 32 public class Doc_Movement extends Doc 33 { 34 38 public Doc_Movement (int AD_Client_ID) 39 { 40 super (AD_Client_ID); 41 } 43 47 public int getAD_Table_ID() 48 { 49 return 323; 50 } 52 56 public String getTableName() 57 { 58 return "M_Movement"; 59 } 61 66 protected boolean loadDocumentDetails(ResultSet rs) 67 { 68 p_vo.DocumentType = DocVO.DOCTYPE_MatMovement; 69 p_vo.C_Currency_ID = NO_CURRENCY; 70 try 71 { 72 p_vo.DateDoc = rs.getTimestamp("MovementDate"); 73 } 74 catch (SQLException e) 75 { 76 log.debug("loadDocumentDetails", e); 77 } 78 loadDocumentType(); p_lines = loadLines(); 81 log.debug("Lines=" + p_lines.length); 82 return true; 83 } 85 89 private DocLine[] loadLines() 90 { 91 ArrayList list = new ArrayList(); 92 String sql = "SELECT * FROM M_MovementLine WHERE M_Movement_ID=? ORDER BY Line"; 93 try 94 { 95 PreparedStatement pstmt = DB.prepareStatement(sql); 96 pstmt.setInt(1, p_vo.Record_ID); 97 ResultSet rs = pstmt.executeQuery(); 98 while (rs.next()) 100 { 101 int Line_ID = rs.getInt("M_MovementLine_ID"); 102 DocLine_Material docLine = new DocLine_Material (p_vo.DocumentType, p_vo.Record_ID, Line_ID); 103 docLine.loadAttributes(rs, p_vo); 104 docLine.setQty(rs.getBigDecimal("MovementQty")); 105 docLine.setM_Locator_ID (rs.getInt("M_Locator_ID")); 106 docLine.setM_LocatorTo_ID (rs.getInt("M_LocatorTo_ID")); 107 log.debug(docLine.toString()); 109 list.add (docLine); 110 } 111 rs.close(); 113 pstmt.close(); 114 } 115 catch (SQLException e) 116 { 117 log.error ("loadLines", e); 118 } 119 120 DocLine[] dl = new DocLine[list.size()]; 122 list.toArray(dl); 123 return dl; 124 } 126 130 public BigDecimal getBalance() 131 { 132 BigDecimal retValue = Env.ZERO; 133 return retValue; 134 } 136 147 public Fact createFact(AcctSchema as) 148 { 149 p_vo.C_Currency_ID = as.getC_Currency_ID(); 150 Fact fact = new Fact(this, as, Fact.POST_Actual); 152 153 FactLine dr = null; 155 FactLine cr = null; 156 157 for (int i = 0; i < p_lines.length; i++) 158 { 159 DocLine_Material line = (DocLine_Material)p_lines[i]; 160 BigDecimal costs = line.getProductCosts(as); 161 dr = fact.createLine(line, 163 line.getAccount(ProductInfo.ACCTTYPE_P_Asset, as), 164 as.getC_Currency_ID(), costs.negate()); dr.setM_Locator_ID(line.getM_Locator_ID()); 166 cr = fact.createLine(line, 168 line.getAccount(ProductInfo.ACCTTYPE_P_Asset, as), 169 as.getC_Currency_ID(), costs); cr.setM_Locator_ID(line.getM_LocatorTo_ID()); 171 } 172 173 return fact; 174 } 176 } | Popular Tags |