use of org.compiere.model.MTaxDeclarationAcct in project adempiere by adempiere.
the class TaxDeclarationCreate method create.
// doIt
/**
* Create Data
* @param invoice invoice
*/
private void create(MInvoice invoice) {
/** Lines **
MInvoiceLine[] lines = invoice.getLines();
for (int i = 0; i < lines.length; i++)
{
MInvoiceLine line = lines[i];
if (line.isDescription())
continue;
//
MTaxDeclarationLine tdl = new MTaxDeclarationLine (m_td, invoice, line);
tdl.setLine((m_noLines+1) * 10);
if (tdl.save())
m_noLines++;
}
/** **/
/** Invoice Tax **/
MInvoiceTax[] taxes = invoice.getTaxes(false);
for (int i = 0; i < taxes.length; i++) {
MInvoiceTax tLine = taxes[i];
//
MTaxDeclarationLine tdl = new MTaxDeclarationLine(m_td, invoice, tLine);
tdl.setLine((m_noLines + 1) * 10);
if (tdl.save())
m_noLines++;
}
/** **/
/** Acct **/
String sql = "SELECT * FROM Fact_Acct WHERE AD_Table_ID=? AND Record_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, MInvoice.Table_ID);
pstmt.setInt(2, invoice.getC_Invoice_ID());
rs = pstmt.executeQuery();
while (rs.next()) {
// no lock
MFactAcct fact = new MFactAcct(getCtx(), rs, null);
MTaxDeclarationAcct tda = new MTaxDeclarationAcct(m_td, fact);
tda.setLine((m_noAccts + 1) * 10);
if (tda.save())
m_noAccts++;
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
/** **/
}
Aggregations