Search in sources :

Example 1 with TaxOutputDefinition

use of edu.cornell.kfs.tax.batch.TaxOutputDefinition in project cu-kfs by CU-CommunityApps.

the class TaxProcessingDaoJdbc method doTaxProcessing.

@Override
public void doTaxProcessing(String taxType, int reportYear, java.sql.Date startDate, java.sql.Date endDate, boolean vendorForeign, java.util.Date processingStartDate) {
    List<EnumMap<TaxStatType, Integer>> stats;
    TaxProcessingService taxProcessingService = SpringContext.getBean(TaxProcessingService.class);
    TaxOutputDefinition tempDefinition;
    if (CUTaxConstants.TAX_TYPE_1099.equals(taxType)) {
        // Perform 1099 tax processing.
        Transaction1099Summary summary = new Transaction1099Summary(reportYear, startDate, endDate, vendorForeign, taxProcessingService.getDataDefinition(CUTaxKeyConstants.TAX_TABLE_1099_PREFIX, reportYear).getDataRowsAsMap());
        // Delete any previously-generated rows for the current year and tax type.
        getJdbcTemplate().update(TaxSqlUtils.getTransactionDetailDeleteSql(taxType, summary.transactionDetailRow), Integer.valueOf(reportYear));
        // Create new transaction rows, retrieving summary statistics as needed.
        stats = createTransactionRows(summary, Arrays.<Class<? extends TransactionRowBuilder<Transaction1099Summary>>>asList(TransactionRowPdpBuilder.For1099.class, TransactionRowDvBuilder.For1099.class, TransactionRowPRNCBuilder.For1099.class));
        // Create 1099 output data from the transaction rows and send it to the file(s), retrieving summary statistics as needed.
        tempDefinition = taxProcessingService.getOutputDefinition(CUTaxKeyConstants.TAX_FORMAT_1099_PREFIX, reportYear);
        stats.add(processTransactionRows(processingStartDate, summary, TransactionRow1099Processor.class, tempDefinition));
        // Print the transaction row data to another file.
        tempDefinition = taxProcessingService.getOutputDefinition(CUTaxKeyConstants.TAX_FORMAT_1099_PREFIX + CUTaxKeyConstants.TAX_FORMAT_SUMMARY_SUFFIX, reportYear);
        processTransactionRows(processingStartDate, summary, TransactionRowPrintProcessor.For1099.class, tempDefinition);
    } else if (CUTaxConstants.TAX_TYPE_1042S.equals(taxType)) {
        // Perform 1042S tax processing.
        Transaction1042SSummary summary = new Transaction1042SSummary(reportYear, startDate, endDate, vendorForeign, taxProcessingService.getDataDefinition(CUTaxKeyConstants.TAX_TABLE_1042S_PREFIX, reportYear).getDataRowsAsMap());
        // Delete any previously-generated rows for the current year and tax type.
        getJdbcTemplate().update(TaxSqlUtils.getTransactionDetailDeleteSql(taxType, summary.transactionDetailRow), Integer.valueOf(reportYear));
        // Create new transaction rows, retrieving summary statistics as needed.
        stats = createTransactionRows(summary, Arrays.<Class<? extends TransactionRowBuilder<Transaction1042SSummary>>>asList(TransactionRowPdpBuilder.For1042S.class, TransactionRowDvBuilder.For1042S.class, TransactionRowPRNCBuilder.For1042S.class));
        // Create 1042S output data from the transaction rows and send it to the file(s), retrieving summary statistics as needed.
        tempDefinition = taxProcessingService.getOutputDefinition(CUTaxKeyConstants.TAX_FORMAT_1042S_PREFIX, reportYear);
        stats.add(processTransactionRows(processingStartDate, summary, TransactionRow1042SProcessor.class, tempDefinition));
        // Print the transaction row data to another file.
        tempDefinition = taxProcessingService.getOutputDefinition(CUTaxKeyConstants.TAX_FORMAT_1042S_PREFIX + CUTaxKeyConstants.TAX_FORMAT_SUMMARY_SUFFIX, reportYear);
        processTransactionRows(processingStartDate, summary, TransactionRowPrintProcessor.For1042S.class, tempDefinition);
    } else {
        // Invalid tax processing type was given.
        throw new IllegalArgumentException("Unrecognized tax type");
    }
    // Print the statistics.
    printStatistics(stats);
}
Also used : TaxProcessingService(edu.cornell.kfs.tax.service.TaxProcessingService) TaxOutputDefinition(edu.cornell.kfs.tax.batch.TaxOutputDefinition) EnumMap(java.util.EnumMap)

Aggregations

TaxOutputDefinition (edu.cornell.kfs.tax.batch.TaxOutputDefinition)1 TaxProcessingService (edu.cornell.kfs.tax.service.TaxProcessingService)1 EnumMap (java.util.EnumMap)1