Search in sources :

Example 1 with MTaxDeclarationLine

use of org.compiere.model.MTaxDeclarationLine 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;
    }
/** **/
}
Also used : MTaxDeclarationAcct(org.compiere.model.MTaxDeclarationAcct) ResultSet(java.sql.ResultSet) MFactAcct(org.compiere.model.MFactAcct) PreparedStatement(java.sql.PreparedStatement) MInvoiceTax(org.compiere.model.MInvoiceTax) MTaxDeclarationLine(org.compiere.model.MTaxDeclarationLine)

Aggregations

PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 MFactAcct (org.compiere.model.MFactAcct)1 MInvoiceTax (org.compiere.model.MInvoiceTax)1 MTaxDeclarationAcct (org.compiere.model.MTaxDeclarationAcct)1 MTaxDeclarationLine (org.compiere.model.MTaxDeclarationLine)1