Search in sources :

Example 1 with PdpSourceRow

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

the class TransactionRowPdpBuilder method getSqlForSelect.

@Override
String getSqlForSelect(T summary) {
    StringBuilder fullSql = new StringBuilder(GETTER_BUILDER_SIZE);
    PdpSourceRow pdpRow = summary.pdpRow;
    // Build the query.
    TaxSqlUtils.appendQuery(fullSql, SqlText.SELECT, pdpRow.orderedFields, SqlText.FROM, pdpRow.tables, SqlText.WHERE, // Limit results to those whose disbursement dates are within the given time period.
    pdpRow.disbursementDate, SqlText.BETWEEN, SqlText.PARAMETER, SqlText.AND, SqlText.PARAMETER, // Connect by customer IDs, and do not include results whose customers are in the IT-KUAL-DV chart-unit-subUnit combo.
    SqlText.AND, pdpRow.summaryCustomerId, SqlText.EQUALS, pdpRow.customerId, SqlText.AND, SqlText.NOT, SqlText.PAREN_OPEN, pdpRow.customerChartCode, SqlText.EQUALS, "'IT'", SqlText.AND, pdpRow.unitCode, SqlText.EQUALS, "'KUAL'", SqlText.AND, pdpRow.subUnitCode, SqlText.EQUALS, "'DV'", SqlText.PAREN_CLOSE, // Connect by process IDs, and make sure the payment groups' disbursement numbers are within the ranges of the matching summaries.
    SqlText.AND, pdpRow.summaryProcessId, SqlText.EQUALS, pdpRow.paymentGroupProcessId, SqlText.AND, pdpRow.disbursementNbr, SqlText.BETWEEN, pdpRow.beginDisbursementNbr, SqlText.AND, pdpRow.endDisbursementNbr, // Add other key-matching, vendor-related, and tax-type-specific criteria.
    SqlText.AND, pdpRow.payeeIdTypeCode, SqlText.EQUALS, "'V'", SqlText.AND, pdpRow.paymentGroupId, SqlText.EQUALS, pdpRow.paymentDetailPaymentGroupId, SqlText.AND, pdpRow.accountDetailPaymentDetailId, SqlText.EQUALS, pdpRow.paymentDetailId, SqlText.AND, TaxSqlUtils.getPayeeIdToVendorHeaderIdCriteria(pdpRow.payeeId, pdpRow.vendorHeaderGeneratedId), getTaxTypeSpecificConditionForSelect(summary), SqlText.AND, pdpRow.vendorForeignInd, SqlText.EQUALS, SqlText.PARAMETER, SqlText.AND, pdpRow.preqDocumentNumber, SqlText.CONDITIONAL_EQUALS_JOIN, pdpRow.custPaymentDocNbr, SqlText.AND, pdpRow.dvDocumentNumber, SqlText.CONDITIONAL_EQUALS_JOIN, pdpRow.custPaymentDocNbr, SqlText.AND, pdpRow.nraDocumentNumber, SqlText.CONDITIONAL_EQUALS_JOIN, pdpRow.dvDocumentNumber, // Build the ORDER BY clause.
    SqlText.ORDER_BY, new Object[][] { { pdpRow.vendorTaxNumber }, { pdpRow.summaryLastUpdatedTimestamp }, { pdpRow.summaryId } });
    // Log and return the full query.
    if (LOG.isDebugEnabled()) {
        LOG.debug("Final PDP selection query: " + fullSql.toString());
    }
    return fullSql.toString();
}
Also used : PdpSourceRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PdpSourceRow)

Example 2 with PdpSourceRow

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

the class TransactionRowPdpBuilder method buildTransactionRows.

@Override
void buildTransactionRows(ResultSet rs, PreparedStatement insertStatement, T summary) throws SQLException {
    PdpSourceRow pdpRow = summary.pdpRow;
    TransactionDetailRow detailRow = summary.transactionDetailRow;
    int offset = detailRow.insertOffset;
    String documentId;
    String financialObjectCode;
    BigDecimal netPaymentAmount;
    Set<String> docIds = new HashSet<String>();
    int currentBatchSize = 0;
    while (rs.next()) {
        // Perform initialization.
        documentId = rs.getString(pdpRow.custPaymentDocNbr.index);
        financialObjectCode = rs.getString(pdpRow.finObjectCode.index);
        netPaymentAmount = rs.getBigDecimal(pdpRow.accountNetAmount.index);
        // Add docId 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);
        /*
             * Prepare to insert another transaction detail row.
             * 
             * NOTE: To prepare for the second pass, the chart code from CPT_FIN_COA_CD
             * will be temporarily stored in the DOC_TITLE field.
             * 
             * NOTE: It is expected that subclasses use the "doTaxSpecificRowSetup"
             * method to populate the following prepared statement arguments:
             * 
             * INCOME_CODE
             * INCOME_CODE_SUB_TYPE
             * FORM_1099_BOX
             * FORM_1099_OVERRIDDEN_BOX
             * FORM_1042S_BOX
             * FORM_1042S_OVERRIDDEN_BOX
             * 
             * In addition, it is expected that updateTransactionRowsFromWorkflowDocuments()
             * will update the following fields after they've been set by this method:
             * 
             * FDOC_NBR (if null, in which case it should be set to "0" or some other constant)
             * DOC_TITLE
             * INITIATOR_NETID
             * VENDOR_TAX_NBR (if null, in which case it should be set to an auto-generated value)
             */
        String documentType = rs.getString(pdpRow.financialDocumentTypeCode.index);
        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, documentType);
        insertStatement.setInt(detailRow.financialDocumentLineNumber.index - offset, rs.getInt(pdpRow.accountDetailId.index));
        insertStatement.setString(detailRow.finObjectCode.index - offset, financialObjectCode);
        insertStatement.setBigDecimal(detailRow.netPaymentAmount.index - offset, netPaymentAmount);
        insertStatement.setString(detailRow.documentTitle.index - offset, rs.getString(pdpRow.customerChartCode.index));
        insertStatement.setString(detailRow.vendorTaxNumber.index - offset, rs.getString(pdpRow.vendorTaxNumber.index));
        insertStatement.setString(detailRow.payeeId.index - offset, rs.getString(pdpRow.payeeId.index));
        insertStatement.setString(detailRow.vendorTypeCode.index - offset, rs.getString(pdpRow.vendorTypeCode.index));
        insertStatement.setString(detailRow.vendorOwnershipCode.index - offset, rs.getString(pdpRow.vendorOwnershipCode.index));
        insertStatement.setString(detailRow.vendorOwnershipCategoryCode.index - offset, rs.getString(pdpRow.vendorOwnershipCategoryCode.index));
        insertStatement.setString(detailRow.vendorForeignIndicator.index - offset, rs.getString(pdpRow.vendorForeignInd.index));
        insertStatement.setString(detailRow.nraPaymentIndicator.index - offset, rs.getString(pdpRow.nraPayment.index));
        insertStatement.setDate(detailRow.paymentDate.index - offset, rs.getDate(pdpRow.disbursementDate.index));
        insertStatement.setString(detailRow.paymentPayeeName.index - offset, rs.getString(pdpRow.payeeName.index));
        insertStatement.setString(detailRow.paymentDescription.index - offset, rs.getString(pdpRow.achPaymentDescription.index));
        insertStatement.setString(detailRow.paymentLine1Address.index - offset, rs.getString(pdpRow.line1Address.index));
        insertStatement.setString(detailRow.paymentCountryName.index - offset, rs.getString(pdpRow.country.index));
        // ?
        insertStatement.setString(detailRow.chartCode.index - offset, rs.getString(pdpRow.accountDetailFinChartCode.index));
        insertStatement.setString(detailRow.accountNumber.index - offset, rs.getString(pdpRow.accountNbr.index));
        insertStatement.setString(detailRow.incomeClassCode.index - offset, findincomeClassCode(rs, pdpRow, documentType));
        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 : PdpSourceRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PdpSourceRow) TransactionDetailRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow) BigDecimal(java.math.BigDecimal) HashSet(java.util.HashSet)

Aggregations

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