use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow in project cu-kfs by CU-CommunityApps.
the class TransactionRowPRNCBuilder method updateTransactionRowsFromWorkflowDocuments.
@Override
void updateTransactionRowsFromWorkflowDocuments(ResultSet rs, T summary) throws SQLException {
TransactionDetailRow detailRow = summary.transactionDetailRow;
String documentId;
String initiatorPrincipalId;
String initiatorPrincipalName;
String paymentMethodCode;
String vendorTaxNumber;
java.sql.Date dateFinalized;
Document document;
DocumentStatus documentStatus = null;
boolean processCurrentRow;
boolean useDateFinalized;
java.sql.Date startDate = summary.getStartDate();
java.sql.Date endDate = summary.getEndDate();
// Update or remove rows as needed.
while (rs.next()) {
String documentType = rs.getString(detailRow.documentType.index);
// Retrieve payment method, which is temporarily stored in the doc title field.
paymentMethodCode = rs.getString(detailRow.documentTitle.index);
if (isPaymentRequestDocument(documentType) && isForeignOrWireTransferPaymentMethod(summary, paymentMethodCode)) {
// Initialized minimal variables for current row.
processCurrentRow = true;
documentId = rs.getString(detailRow.documentNumber.index);
initiatorPrincipalId = null;
documentStatus = null;
dateFinalized = null;
useDateFinalized = false;
// Retrieve document info.
document = getWorkflowDocumentForTaxRow(documentId, summary);
if (document != null) {
initiatorPrincipalId = document.getInitiatorPrincipalId();
documentStatus = document.getStatus();
if (document.getDateFinalized() != null) {
dateFinalized = new java.sql.Date(document.getDateFinalized().getMillis());
}
}
// Depending on payment method, verify that the PRNC has indeed been finalized during the given time period.
if (summary.foreignDraftCode.equals(paymentMethodCode) || summary.wireTransferCode.equals(paymentMethodCode)) {
// If a Foreign Draft or Wire Transfer, check the doc finalization date and status.
if (DocumentStatus.FINAL.equals(documentStatus) && dateFinalized != null && dateFinalized.compareTo(startDate) >= 0 && dateFinalized.compareTo(endDate) <= 0) {
// If finalized during the current reporting period, then increment counters accordingly and use finalize date as payment date.
useDateFinalized = true;
if (summary.foreignDraftCode.equals(paymentMethodCode)) {
numForeignDraftsSelected++;
} else if (summary.wireTransferCode.equals(paymentMethodCode)) {
numWireTransfersSelected++;
}
} else {
// If not finalized or if in the wrong reporting period, then skip the current PRNC data row.
if (summary.foreignDraftCode.equals(paymentMethodCode)) {
numForeignDraftsIgnored++;
} else if (summary.wireTransferCode.equals(paymentMethodCode)) {
numWireTransfersIgnored++;
}
// Skip any further processing for the current row.
processCurrentRow = false;
}
}
if (processCurrentRow) {
// Finish initialization.
vendorTaxNumber = rs.getString(detailRow.vendorTaxNumber.index);
// Check for null objects as needed, and get the initiator's principal name.
initiatorPrincipalName = checkForEntityAndAccountAndOrgExistence(initiatorPrincipalId, rs.getString(detailRow.chartCode.index), rs.getString(detailRow.accountNumber.index), summary);
// If vendor tax number is blank, then replace with a generated value accordingly.
if (StringUtils.isBlank(vendorTaxNumber)) {
vendorTaxNumber = getReplacementVendorTaxNumber(rs.getString(detailRow.payeeId.index), summary);
rs.updateString(detailRow.vendorTaxNumber.index, vendorTaxNumber);
}
// Do tax-type-specific updates.
doTaxSpecificSecondPassRowSetup(rs, summary);
// Update other fields as needed.
if (StringUtils.isBlank(documentId)) {
rs.updateString(detailRow.documentNumber.index, CUTaxConstants.DOC_ID_ZERO);
}
rs.updateString(detailRow.documentTitle.index, (document != null && StringUtils.isNotBlank(document.getTitle())) ? document.getTitle() : CUTaxConstants.DOC_TITLE_IF_NOT_FOUND);
rs.updateString(detailRow.initiatorNetId.index, StringUtils.isNotBlank(initiatorPrincipalName) ? initiatorPrincipalName : CUTaxConstants.NETID_IF_NOT_FOUND);
if (useDateFinalized) {
rs.updateDate(detailRow.paymentDate.index, dateFinalized);
}
// Update the transaction row.
rs.updateRow();
} else {
// If a Foreign Draft or Wire Transfer that wasn't finalized or was in the wrong reporting period, then delete the row.
rs.deleteRow();
}
}
}
}
use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow in project cu-kfs by CU-CommunityApps.
the class TransactionRowPdpBuilder method updateTransactionRowsFromWorkflowDocuments.
@Override
void updateTransactionRowsFromWorkflowDocuments(ResultSet rs, T summary) throws SQLException {
TransactionDetailRow detailRow = summary.transactionDetailRow;
String documentId;
String initiatorPrincipalId;
String initiatorPrincipalName;
String vendorTaxNumber;
Document document;
// Perform row updates as needed.
while (rs.next()) {
// Only update PDP-related rows.
if (!DisbursementVoucherConstants.DOCUMENT_TYPE_CODE.equals(rs.getString(detailRow.documentType.index))) {
// Initialize variables.
documentId = rs.getString(detailRow.documentNumber.index);
initiatorPrincipalId = null;
vendorTaxNumber = rs.getString(detailRow.vendorTaxNumber.index);
// Retrieve document info.
document = getWorkflowDocumentForTaxRow(documentId, summary);
if (document != null) {
initiatorPrincipalId = document.getInitiatorPrincipalId();
}
// Check for null objects as needed, and get the initiator's principal name. (NOTE: Uses temp chart from doc title field.)
initiatorPrincipalName = checkForEntityAndAccountAndOrgExistence(initiatorPrincipalId, rs.getString(detailRow.documentTitle.index), rs.getString(detailRow.accountNumber.index), summary);
// If vendor tax number is blank, then replace with a generated value accordingly.
if (StringUtils.isBlank(vendorTaxNumber)) {
vendorTaxNumber = getReplacementVendorTaxNumber(rs.getString(detailRow.payeeId.index), summary);
rs.updateString(detailRow.vendorTaxNumber.index, vendorTaxNumber);
}
// Do tax-type-specific updates.
doTaxSpecificSecondPassRowSetup(rs, summary);
// Update other fields as needed.
if (StringUtils.isBlank(documentId)) {
rs.updateString(detailRow.documentNumber.index, CUTaxConstants.DOC_ID_ZERO);
}
rs.updateString(detailRow.documentTitle.index, (document != null && StringUtils.isNotBlank(document.getTitle())) ? document.getTitle() : CUTaxConstants.DOC_TITLE_IF_NOT_FOUND);
rs.updateString(detailRow.initiatorNetId.index, StringUtils.isNotBlank(initiatorPrincipalName) ? initiatorPrincipalName : CUTaxConstants.NETID_IF_NOT_FOUND);
// Update the current row.
rs.updateRow();
}
}
}
use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow in project cu-kfs by CU-CommunityApps.
the class TransactionRowPrintProcessor method processTaxRows.
@Override
void processTaxRows(ResultSet rs, T summary) throws SQLException, IOException {
// Perform initialization as needed.
TransactionDetailRow detailRow = summary.transactionDetailRow;
Pattern whitespacePattern = Pattern.compile("\\p{Space}");
EncryptionService encryptionService = CoreApiServiceLocator.getEncryptionService();
rsTransactionDetail = rs;
if (summary.scrubbedOutput) {
ssnP.value = CUTaxConstants.MASKED_VALUE_9_CHARS;
}
LOG.info("Starting raw transaction row printing to file...");
// Print the header.
resetBuffer(HEADER_BUFFER_INDEX);
appendPieces(HEADER_BUFFER_INDEX);
writeBufferToOutput(HEADER_BUFFER_INDEX, 0);
// Print the data for each row to the file.
while (rsTransactionDetail.next()) {
// Prepare the tax number.
if (!summary.scrubbedOutput) {
try {
ssnP.value = encryptionService.decrypt(rsTransactionDetail.getString(detailRow.vendorTaxNumber.index));
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
}
// Prepare the whitespace-replaced-with-spaces DV check stub text.
dvCheckStubTextP.value = rsTransactionDetail.getString(detailRow.dvCheckStubText.index);
if (StringUtils.isNotBlank(dvCheckStubTextP.value)) {
dvCheckStubTextP.value = whitespacePattern.matcher(dvCheckStubTextP.value).replaceAll(KRADConstants.BLANK_SPACE);
}
// Do the printing.
resetBuffer(DETAIL_ROW_BUFFER_INDEX);
appendPieces(DETAIL_ROW_BUFFER_INDEX);
writeBufferToOutput(DETAIL_ROW_BUFFER_INDEX, 0);
}
LOG.info("Finished raw transaction row printing to file.");
}
use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow in project cu-kfs by CU-CommunityApps.
the class TransactionRow1042SProcessor method setComplexPieces.
@Override
void setComplexPieces(Map<String, RecordPiece> complexPieces, Transaction1042SSummary summary) {
TransactionDetailRow detailRow = summary.transactionDetailRow;
DerivedValuesRow derivedValues = summary.derivedValues;
List<RecordPiece1042SString> stringPieces = new ArrayList<RecordPiece1042SString>();
List<RecordPiece1042SInt> intPieces = new ArrayList<RecordPiece1042SInt>();
List<RecordPiece1042SBigDecimal> bigDecimalPieces = new ArrayList<RecordPiece1042SBigDecimal>();
List<RecordPiece1042SDate> datePieces = new ArrayList<RecordPiece1042SDate>();
// retrieve the "piece" objects corresponding to all the given transaction detail fields.
for (TaxTableField detailField : summary.transactionDetailRow.orderedFields) {
RecordPiece detailPiece = complexPieces.get(detailField.propertyName);
if (detailPiece != null) {
switch(detailField.jdbcType) {
case java.sql.Types.DECIMAL:
bigDecimalPieces.add((RecordPiece1042SBigDecimal) detailPiece);
break;
case java.sql.Types.INTEGER:
intPieces.add((RecordPiece1042SInt) detailPiece);
break;
case java.sql.Types.VARCHAR:
stringPieces.add((RecordPiece1042SString) detailPiece);
break;
case java.sql.Types.DATE:
datePieces.add((RecordPiece1042SDate) detailPiece);
break;
default:
throw new IllegalStateException("Found unsupported detail field JDBC type: " + Integer.toString(detailField.jdbcType));
}
}
}
// Setup the transaction detail "piece" arrays.
detailStrings = stringPieces.toArray(new RecordPiece1042SString[stringPieces.size()]);
detailInts = intPieces.toArray(new RecordPiece1042SInt[intPieces.size()]);
detailBigDecimals = bigDecimalPieces.toArray(new RecordPiece1042SBigDecimal[bigDecimalPieces.size()]);
detailDates = datePieces.toArray(new RecordPiece1042SDate[datePieces.size()]);
// Retrieve the various detail "pieces" that will be needed for the processing.
rowIdP = (RecordPiece1042SString) complexPieces.get(detailRow.transactionDetailId.propertyName);
docNumberP = (RecordPiece1042SString) complexPieces.get(detailRow.documentNumber.propertyName);
docTypeP = (RecordPiece1042SString) complexPieces.get(detailRow.documentType.propertyName);
docLineNumberP = (RecordPiece1042SInt) complexPieces.get(detailRow.financialDocumentLineNumber.propertyName);
objectCodeP = (RecordPiece1042SString) complexPieces.get(detailRow.finObjectCode.propertyName);
paymentAmountP = (RecordPiece1042SBigDecimal) complexPieces.get(detailRow.netPaymentAmount.propertyName);
taxIdP = (RecordPiece1042SString) complexPieces.get(detailRow.vendorTaxNumber.propertyName);
incomeCodeP = (RecordPiece1042SString) complexPieces.get(detailRow.incomeCode.propertyName);
incomeCodeSubTypeP = (RecordPiece1042SString) complexPieces.get(detailRow.incomeCodeSubType.propertyName);
dvCheckStubTextP = (RecordPiece1042SString) complexPieces.get(detailRow.dvCheckStubText.propertyName);
payeeIdP = (RecordPiece1042SString) complexPieces.get(detailRow.payeeId.propertyName);
vendorOwnershipCodeP = (RecordPiece1042SString) complexPieces.get(detailRow.vendorOwnershipCode.propertyName);
paymentDateP = (RecordPiece1042SDate) complexPieces.get(detailRow.paymentDate.propertyName);
taxTreatyExemptIncomeYesNoP = (RecordPiece1042SString) complexPieces.get(detailRow.incomeTaxTreatyExemptIndicator.propertyName);
foreignSourceIncomeYesNoP = (RecordPiece1042SString) complexPieces.get(detailRow.foreignSourceIncomeIndicator.propertyName);
fedIncomeTaxPctP = (RecordPiece1042SBigDecimal) complexPieces.get(detailRow.federalIncomeTaxPercent.propertyName);
paymentAddressLine1P = (RecordPiece1042SString) complexPieces.get(detailRow.paymentLine1Address.propertyName);
chartCodeP = (RecordPiece1042SString) complexPieces.get(detailRow.chartCode.propertyName);
accountNumberP = (RecordPiece1042SString) complexPieces.get(detailRow.accountNumber.propertyName);
paymentReasonCodeP = (RecordPiece1042SString) complexPieces.get(detailRow.paymentReasonCode.propertyName);
// Retrieve the various derived "pieces" that will be needed for the processing.
vendorLastNameP = (RecordPiece1042SString) complexPieces.get(derivedValues.vendorLastName.propertyName);
vendorFirstNameP = (RecordPiece1042SString) complexPieces.get(derivedValues.vendorFirstName.propertyName);
vendorEmailAddressP = (RecordPiece1042SString) complexPieces.get(derivedValues.vendorEmailAddress.propertyName);
vendorUSAddressLine1P = (RecordPiece1042SString) complexPieces.get(derivedValues.vendorUSAddressLine1.propertyName);
vendorForeignAddressLine1P = (RecordPiece1042SString) complexPieces.get(derivedValues.vendorForeignAddressLine1.propertyName);
formattedSSNValueP = (RecordPiece1042SString) complexPieces.get(derivedValues.ssn.propertyName);
formattedITINValueP = (RecordPiece1042SString) complexPieces.get(derivedValues.itin.propertyName);
chapter3StatusCodeP = (RecordPiece1042SString) complexPieces.get(derivedValues.chapter3StatusCode.propertyName);
chapter3ExemptionCodeP = (RecordPiece1042SString) complexPieces.get(derivedValues.chapter3ExemptionCode.propertyName);
chapter4ExemptionCodeP = (RecordPiece1042SString) complexPieces.get(derivedValues.chapter4ExemptionCode.propertyName);
incomeCodeForOutputP = (RecordPiece1042SString) complexPieces.get(derivedValues.incomeCode.propertyName);
taxEINValueP = (RecordPiece1042SString) complexPieces.get(derivedValues.ein.propertyName);
chapter3TaxRateP = (RecordPiece1042SBigDecimal) complexPieces.get(derivedValues.chapter3TaxRate.propertyName);
grossAmountP = (RecordPiece1042SBigDecimal) complexPieces.get(derivedValues.grossAmount.propertyName);
ftwAmountP = (RecordPiece1042SBigDecimal) complexPieces.get(derivedValues.fedTaxWithheldAmount.propertyName);
ftwAmountP.negateStringValue = true;
sitwAmountP = (RecordPiece1042SBigDecimal) complexPieces.get(derivedValues.stateIncomeTaxWithheldAmount.propertyName);
sitwAmountP.negateStringValue = true;
stateCodeP = (RecordPiece1042SString) complexPieces.get(derivedValues.stateCode.propertyName);
endDateP = (RecordPiece1042SDate) complexPieces.get(derivedValues.endDate.propertyName);
}
use of edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow in project cu-kfs by CU-CommunityApps.
the class TransactionRow1099Processor method setComplexPieces.
@Override
void setComplexPieces(Map<String, RecordPiece> complexPieces, Transaction1099Summary summary) {
TransactionDetailRow detailRow = summary.transactionDetailRow;
DerivedValuesRow derivedValues = summary.derivedValues;
List<RecordPiece1099String> stringPieces = new ArrayList<RecordPiece1099String>();
List<RecordPiece1099Int> intPieces = new ArrayList<RecordPiece1099Int>();
List<RecordPiece1099BigDecimal> bigDecimalPieces = new ArrayList<RecordPiece1099BigDecimal>();
List<RecordPiece1099Date> datePieces = new ArrayList<RecordPiece1099Date>();
// retrieve the "piece" objects corresponding to all the given transaction detail fields.
for (TaxTableField detailField : summary.transactionDetailRow.orderedFields) {
RecordPiece detailPiece = complexPieces.get(detailField.propertyName);
if (detailPiece != null) {
switch(detailField.jdbcType) {
case java.sql.Types.DECIMAL:
bigDecimalPieces.add((RecordPiece1099BigDecimal) detailPiece);
break;
case java.sql.Types.INTEGER:
intPieces.add((RecordPiece1099Int) detailPiece);
break;
case java.sql.Types.VARCHAR:
stringPieces.add((RecordPiece1099String) detailPiece);
break;
case java.sql.Types.DATE:
datePieces.add((RecordPiece1099Date) detailPiece);
break;
default:
throw new IllegalStateException("Found unsupported detail field JDBC type: " + Integer.toString(detailField.jdbcType));
}
}
}
// Setup the transaction detail "piece" arrays.
detailStrings = stringPieces.toArray(new RecordPiece1099String[stringPieces.size()]);
detailInts = intPieces.toArray(new RecordPiece1099Int[intPieces.size()]);
detailBigDecimals = bigDecimalPieces.toArray(new RecordPiece1099BigDecimal[bigDecimalPieces.size()]);
detailDates = datePieces.toArray(new RecordPiece1099Date[datePieces.size()]);
// Retrieve the various detail "pieces" that will be needed for the processing.
rowIdP = (RecordPiece1099String) complexPieces.get(detailRow.transactionDetailId.propertyName);
docNumberP = (RecordPiece1099String) complexPieces.get(detailRow.documentNumber.propertyName);
docTypeP = (RecordPiece1099String) complexPieces.get(detailRow.documentType.propertyName);
docTitleP = (RecordPiece1099String) complexPieces.get(detailRow.documentTitle.propertyName);
docLineNumberP = (RecordPiece1099Int) complexPieces.get(detailRow.financialDocumentLineNumber.propertyName);
objectCodeP = (RecordPiece1099String) complexPieces.get(detailRow.finObjectCode.propertyName);
paymentAmountP = (RecordPiece1099BigDecimal) complexPieces.get(detailRow.netPaymentAmount.propertyName);
taxIdP = (RecordPiece1099String) complexPieces.get(detailRow.vendorTaxNumber.propertyName);
dvCheckStubTextP = (RecordPiece1099String) complexPieces.get(detailRow.dvCheckStubText.propertyName);
payeeIdP = (RecordPiece1099String) complexPieces.get(detailRow.payeeId.propertyName);
vendorNameP = (RecordPiece1099String) complexPieces.get(detailRow.vendorName.propertyName);
parentVendorNameP = (RecordPiece1099String) complexPieces.get(detailRow.parentVendorName.propertyName);
paymentDateP = (RecordPiece1099Date) complexPieces.get(detailRow.paymentDate.propertyName);
paymentAddressLine1P = (RecordPiece1099String) complexPieces.get(detailRow.paymentLine1Address.propertyName);
chartCodeP = (RecordPiece1099String) complexPieces.get(detailRow.chartCode.propertyName);
accountNumberP = (RecordPiece1099String) complexPieces.get(detailRow.accountNumber.propertyName);
initiatorNetIdP = (RecordPiece1099String) complexPieces.get(detailRow.initiatorNetId.propertyName);
paymentReasonCodeP = (RecordPiece1099String) complexPieces.get(detailRow.paymentReasonCode.propertyName);
// Retrieve the various derived "pieces" that will be needed for the processing.
vendorEmailAddressP = (RecordPiece1099String) complexPieces.get(derivedValues.vendorEmailAddress.propertyName);
vendorAddressLine1P = (RecordPiece1099String) complexPieces.get(derivedValues.vendorAnyAddressLine1.propertyName);
vendorNumbersOnlyZipCodeP = (RecordPiece1099String) complexPieces.get(derivedValues.vendorZipCodeNumOnly.propertyName);
outputTaxIdP = (RecordPiece1099String) complexPieces.get(derivedValues.ssn.propertyName);
tabSiteIdP = (RecordPiece1099String) complexPieces.get(derivedValues.tabSiteId.propertyName);
box1P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box1.propertyName);
box2P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box2.propertyName);
box3P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box3.propertyName);
box4P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box4.propertyName);
box5P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box5.propertyName);
box6P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box6.propertyName);
box7P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box7.propertyName);
box8P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box8.propertyName);
box10P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box10.propertyName);
box11P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box11.propertyName);
box12P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box12.propertyName);
box13P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box13.propertyName);
box14P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box14.propertyName);
box15aP = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box15a.propertyName);
box15bP = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box15b.propertyName);
box16P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box16.propertyName);
box18P = (RecordPiece1099BigDecimal) complexPieces.get(derivedValues.box18.propertyName);
// Populate tax box field map.
boxesMap = new HashMap<TaxTableField, RecordPiece1099BigDecimal>();
boxesMap.put(box1P.tableField, box1P);
boxesMap.put(box2P.tableField, box2P);
boxesMap.put(box3P.tableField, box3P);
boxesMap.put(box4P.tableField, box4P);
boxesMap.put(box5P.tableField, box5P);
boxesMap.put(box6P.tableField, box6P);
boxesMap.put(box7P.tableField, box7P);
boxesMap.put(box8P.tableField, box8P);
boxesMap.put(box10P.tableField, box10P);
boxesMap.put(box11P.tableField, box11P);
boxesMap.put(box12P.tableField, box12P);
boxesMap.put(box13P.tableField, box13P);
boxesMap.put(box14P.tableField, box14P);
boxesMap.put(box15aP.tableField, box15aP);
boxesMap.put(box15bP.tableField, box15bP);
boxesMap.put(box16P.tableField, box16P);
boxesMap.put(box18P.tableField, box18P);
}
Aggregations