private final I_C_TaxDeclarationLine newTaxDeclarationLine() { final I_C_TaxDeclaration taxDeclaration = getC_TaxDeclaration(); final I_C_TaxDeclarationLine taxDeclarationLine = InterfaceWrapperHelper.create( getCtx(), I_C_TaxDeclarationLine.class, ITrx.TRXNAME_ThreadInherited); taxDeclarationLine.setAD_Org_ID(taxDeclaration.getAD_Org_ID()); taxDeclarationLine.setC_TaxDeclaration(taxDeclaration); return taxDeclarationLine; }
private final Iterator<I_GL_JournalLine> retrieveGLJournalLines() { final I_C_TaxDeclaration taxDeclaration = getC_TaxDeclaration(); final IQuery<I_C_TaxDeclarationLine> existingTaxDeclarationLinesQuery = createQueryBuilder(I_C_TaxDeclarationLine.class).create(); final ICompositeQueryFilter<I_GL_JournalLine> taxAccountableFilter = queryBL .createCompositeQueryFilter(I_GL_JournalLine.class) .setJoinOr() .addEqualsFilter(I_GL_JournalLine.COLUMN_DR_AutoTaxAccount, true) .addEqualsFilter(I_GL_JournalLine.COLUMN_CR_AutoTaxAccount, true); final IQueryBuilder<I_GL_JournalLine> queryBuilder = createQueryBuilder(I_GL_JournalLine.class) // // Only invoices from reporting interval .addBetweenFilter( I_GL_JournalLine.COLUMN_DateAcct, taxDeclaration.getDateFrom(), taxDeclaration.getDateTo(), DateTruncQueryFilterModifier.DAY) // // Only those which are processed .addEqualsFilter(I_GL_JournalLine.COLUMN_Processed, true) // // Only those which are about taxes .filter(taxAccountableFilter) // // Only those which were not already included in other tax declaration .addNotInSubQueryFilter( I_GL_JournalLine.COLUMN_GL_JournalLine_ID, I_C_TaxDeclarationLine.COLUMN_GL_JournalLine_ID, existingTaxDeclarationLinesQuery) // ; queryBuilder .orderBy() .addColumn(I_GL_JournalLine.COLUMN_DateAcct) .addColumn(I_GL_JournalLine.COLUMN_GL_JournalLine_ID); // to have a predictable order return queryBuilder .create() // guaranteed because we are inserting in C_TaxDeclarationLine and in our query we check to // not have the record already there .setOption(IQuery.OPTION_GuaranteedIteratorRequired, true) // .iterate(I_GL_JournalLine.class); }