Search in sources :

Example 11 with TransactionDetailRow

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

the class TransactionRowDvBuilder method buildTransactionRows.

@Override
void buildTransactionRows(ResultSet rs, PreparedStatement insertStatement, T summary) throws SQLException {
    DvSourceRow dvRow = summary.dvRow;
    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(dvRow.payeeDetailDocumentNumber.index);
        financialObjectCode = rs.getString(dvRow.financialObjectCode.index);
        netPaymentAmount = rs.getBigDecimal(dvRow.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. Otherwise, negate it if it's a debit amount.
        if (netPaymentAmount == null) {
            netPaymentAmount = summary.zeroAmount;
        } else if (KFSConstants.GL_DEBIT_CODE.equals(rs.getString(dvRow.debitCreditCode.index))) {
            netPaymentAmount = netPaymentAmount.negate();
        }
        // Perform extra 1099-specific or 1042S-specific setup as needed.
        doTaxSpecificRowSetup(rs, insertStatement, financialObjectCode, summary);
        /*
             * Prepare to insert another transaction detail row.
             * 
             * NOTE: We temporarily store the payment method code in the doc title slot,
             * to be processed and replaced on the next pass.
             * 
             * 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
             * PMT_DT (if the row represents a Foreign Draft or Wire Transfer)
             * VENDOR_TAX_NBR (if null, in which case it should be set to an auto-generated value)
             * DV_CHK_STUB_TXT (if it contains non-printable characters, in which case they should be removed)
             */
        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, DisbursementVoucherConstants.DOCUMENT_TYPE_CODE);
        insertStatement.setInt(detailRow.financialDocumentLineNumber.index - offset, rs.getInt(dvRow.accountingLineSequenceNumber.index));
        insertStatement.setString(detailRow.finObjectCode.index - offset, financialObjectCode);
        insertStatement.setBigDecimal(detailRow.netPaymentAmount.index - offset, netPaymentAmount);
        insertStatement.setString(detailRow.documentTitle.index - offset, rs.getString(dvRow.documentDisbVchrPaymentMethodCode.index));
        insertStatement.setString(detailRow.vendorTaxNumber.index - offset, rs.getString(dvRow.vendorTaxNumber.index));
        insertStatement.setString(detailRow.dvCheckStubText.index - offset, rs.getString(dvRow.disbVchrCheckStubText.index));
        insertStatement.setString(detailRow.payeeId.index - offset, rs.getString(dvRow.disbVchrPayeeIdNumber.index));
        insertStatement.setString(detailRow.vendorTypeCode.index - offset, rs.getString(dvRow.vendorTypeCode.index));
        insertStatement.setString(detailRow.vendorOwnershipCode.index - offset, rs.getString(dvRow.vendorOwnershipCode.index));
        insertStatement.setString(detailRow.vendorOwnershipCategoryCode.index - offset, rs.getString(dvRow.vendorOwnershipCategoryCode.index));
        insertStatement.setString(detailRow.vendorForeignIndicator.index - offset, rs.getString(dvRow.vendorForeignInd.index));
        insertStatement.setString(detailRow.nraPaymentIndicator.index - offset, rs.getString(dvRow.disbVchrAlienPaymentCode.index));
        insertStatement.setDate(detailRow.paymentDate.index - offset, rs.getDate(dvRow.paidDate.index));
        insertStatement.setString(detailRow.paymentPayeeName.index - offset, rs.getString(dvRow.disbVchrPayeePersonName.index));
        insertStatement.setString(detailRow.incomeClassCode.index - offset, rs.getString(dvRow.incomeClassCode.index));
        insertStatement.setString(detailRow.incomeTaxTreatyExemptIndicator.index - offset, rs.getString(dvRow.incomeTaxTreatyExemptCode.index));
        insertStatement.setString(detailRow.foreignSourceIncomeIndicator.index - offset, rs.getString(dvRow.foreignSourceIncomeCode.index));
        insertStatement.setBigDecimal(detailRow.federalIncomeTaxPercent.index - offset, rs.getBigDecimal(dvRow.federalIncomeTaxPercent.index));
        insertStatement.setString(detailRow.paymentDescription.index - offset, rs.getString(dvRow.financialDocumentLineDescription.index));
        insertStatement.setString(detailRow.paymentLine1Address.index - offset, rs.getString(dvRow.disbVchrPayeeLine1Addr.index));
        insertStatement.setString(detailRow.paymentCountryName.index - offset, rs.getString(dvRow.disbVchrPayeeCountryCode.index));
        insertStatement.setString(detailRow.chartCode.index - offset, rs.getString(dvRow.chartOfAccountsCode.index));
        insertStatement.setString(detailRow.accountNumber.index - offset, rs.getString(dvRow.accountNumber.index));
        insertStatement.setString(detailRow.paymentReasonCode.index - offset, rs.getString(dvRow.disbVchrPaymentReasonCode.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 : DvSourceRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.DvSourceRow) TransactionDetailRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow) BigDecimal(java.math.BigDecimal) HashSet(java.util.HashSet)

Example 12 with TransactionDetailRow

use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow 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)

Example 13 with TransactionDetailRow

use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow 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

TransactionDetailRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow)13 HashSet (java.util.HashSet)5 DerivedValuesRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.DerivedValuesRow)4 BigDecimal (java.math.BigDecimal)3 Document (org.kuali.rice.kew.api.document.Document)3 ArrayList (java.util.ArrayList)2 Pattern (java.util.regex.Pattern)2 DocumentStatus (org.kuali.rice.kew.api.document.DocumentStatus)2 DvSourceRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.DvSourceRow)1 PRNCSourceRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PRNCSourceRow)1 PdpSourceRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.PdpSourceRow)1 GeneralSecurityException (java.security.GeneralSecurityException)1 Matcher (java.util.regex.Matcher)1 EncryptionService (org.kuali.rice.core.api.encryption.EncryptionService)1