Search in sources :

Example 1 with PRNCSourceRow

use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PRNCSourceRow in project cu-kfs by CU-CommunityApps.

the class TransactionRowPRNCBuilder method getSqlForSelect.

@Override
String getSqlForSelect(T summary) {
    StringBuilder fullSql = new StringBuilder(GETTER_BUILDER_SIZE);
    PRNCSourceRow prncRow = summary.prncRow;
    // Build the query.
    TaxSqlUtils.appendQuery(fullSql, SqlText.SELECT, prncRow.orderedFields, SqlText.FROM, prncRow.tables, SqlText.WHERE, prncRow.paymentMethodCode, SqlText.IN, "('F','W')", SqlText.AND, TaxSqlUtils.getInListCriteria(prncRow.preqDocumentNumber, finalizedPRNCDocuments.size(), true, true), SqlText.AND, prncRow.universityDate, SqlText.EQUALS, SqlText.PARAMETER, // Add doc number criteria.
    SqlText.AND, prncRow.preqPurapDocumentIdentifier, SqlText.EQUALS, prncRow.purapDocumentIdentifier, SqlText.AND, prncRow.itemIdentifier, SqlText.EQUALS, prncRow.accountItemIdentifier, // Add various IS NOT NULL criteria.
    SqlText.AND, prncRow.preqPurapDocumentIdentifier, SqlText.IS_NOT_NULL, SqlText.AND, prncRow.itemIdentifier, SqlText.IS_NOT_NULL, SqlText.AND, prncRow.accountIdentifier, SqlText.IS_NOT_NULL, // And vendor criteria and tax-type-specific criteria.
    SqlText.AND, prncRow.preqVendorHeaderGeneratedIdentifier, SqlText.EQUALS, prncRow.vendorHeaderGeneratedId, getTaxTypeSpecificConditionForSelect(summary), SqlText.AND, prncRow.vendorForeignInd, SqlText.EQUALS, SqlText.PARAMETER, // Build the ORDER BY clause.
    SqlText.ORDER_BY, new Object[][] { { prncRow.vendorTaxNumber }, { prncRow.preqDocumentNumber }, { prncRow.accountItemIdentifier }, { prncRow.accountIdentifier } });
    // Log and return the full query.
    if (LOG.isDebugEnabled()) {
        LOG.debug("Final PRNC selection query: " + fullSql.toString());
    }
    return fullSql.toString();
}
Also used : PRNCSourceRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PRNCSourceRow)

Example 2 with PRNCSourceRow

use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PRNCSourceRow in project cu-kfs by CU-CommunityApps.

the class TransactionRowPRNCBuilder method buildTransactionRows.

@Override
void buildTransactionRows(ResultSet rs, PreparedStatement insertStatement, T summary) throws SQLException {
    PRNCSourceRow prncRow = summary.prncRow;
    TransactionDetailRow detailRow = summary.transactionDetailRow;
    int offset = detailRow.insertOffset;
    Set<String> docIds = new HashSet<String>();
    String documentId;
    String financialObjectCode;
    BigDecimal netPaymentAmount;
    int currentBatchSize = 0;
    while (rs.next()) {
        // Initialize variables for current row.
        documentId = rs.getString(prncRow.preqDocumentNumber.index);
        financialObjectCode = rs.getString(prncRow.financialObjectCode.index);
        netPaymentAmount = rs.getBigDecimal(prncRow.amount.index);
        // Add doc ID to map if non-blank.
        if (StringUtils.isNotBlank(documentId)) {
            docIds.add(documentId);
        }
        // If net payment amount is null, then set to zero
        if (netPaymentAmount == null) {
            netPaymentAmount = summary.zeroAmount;
        }
        // Perform extra 1099-specific or 1042S-specific setup as needed.
        doTaxSpecificRowSetup(rs, insertStatement, financialObjectCode, summary);
        insertStatement.setInt(detailRow.reportYear.index - offset, summary.reportYear);
        insertStatement.setString(detailRow.documentNumber.index - offset, StringUtils.isNotBlank(documentId) ? documentId : null);
        insertStatement.setString(detailRow.documentType.index - offset, PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT);
        insertStatement.setInt(detailRow.financialDocumentLineNumber.index - offset, rs.getInt(prncRow.accountIdentifier.index));
        insertStatement.setString(detailRow.finObjectCode.index - offset, financialObjectCode);
        insertStatement.setBigDecimal(detailRow.netPaymentAmount.index - offset, netPaymentAmount);
        insertStatement.setString(detailRow.documentTitle.index - offset, rs.getString(prncRow.paymentMethodCode.index));
        insertStatement.setString(detailRow.incomeClassCode.index - offset, rs.getString(prncRow.taxClassificationCode.index));
        insertStatement.setString(detailRow.vendorTaxNumber.index - offset, rs.getString(prncRow.vendorTaxNumber.index));
        insertStatement.setString(detailRow.payeeId.index - offset, rs.getString(prncRow.preqVendorHeaderGeneratedIdentifier.index) + "-" + rs.getString(prncRow.preqVendorDetailAssignedIdentifier.index));
        insertStatement.setString(detailRow.vendorTypeCode.index - offset, rs.getString(prncRow.vendorTypeCode.index));
        insertStatement.setString(detailRow.vendorOwnershipCode.index - offset, rs.getString(prncRow.vendorOwnershipCode.index));
        insertStatement.setString(detailRow.vendorOwnershipCategoryCode.index - offset, rs.getString(prncRow.vendorOwnershipCategoryCode.index));
        insertStatement.setString(detailRow.vendorForeignIndicator.index - offset, rs.getString(prncRow.vendorForeignInd.index));
        insertStatement.setString(detailRow.nraPaymentIndicator.index - offset, rs.getString(prncRow.vendorForeignInd.index));
        insertStatement.setString(detailRow.chartCode.index - offset, rs.getString(prncRow.chartOfAccountsCode.index));
        insertStatement.setString(detailRow.accountNumber.index - offset, rs.getString(prncRow.accountNumber.index));
        insertStatement.setString(detailRow.paymentPayeeName.index - offset, rs.getString(prncRow.preqVendorName.index));
        insertStatement.setString(detailRow.paymentLine1Address.index - offset, rs.getString(prncRow.vendorLine1Address.index));
        insertStatement.setString(detailRow.paymentCountryName.index - offset, rs.getString(prncRow.vendorCountryCode.index));
        insertNullsForTransactionRow(insertStatement, detailRow, offset);
        // Add to batch, and execute batch if needed.
        insertStatement.addBatch();
        currentBatchSize++;
        if (currentBatchSize == CUTaxConstants.INSERT_BATCH_SIZE) {
            insertStatement.executeBatch();
            currentBatchSize = 0;
        }
    }
    // Execute any remaining insertions that were not included in a prior batch.
    if (currentBatchSize > 0) {
        insertStatement.executeBatch();
    }
    // Prepare collected docIds for next processing iteration.
    prepareForSecondPass(summary, docIds);
}
Also used : TransactionDetailRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow) PRNCSourceRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PRNCSourceRow) BigDecimal(java.math.BigDecimal) HashSet(java.util.HashSet)

Aggregations

PRNCSourceRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PRNCSourceRow)2 TransactionDetailRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow)1 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1