Search in sources :

Example 1 with PaymentNoteText

use of org.kuali.kfs.pdp.businessobject.PaymentNoteText in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherPaymentMaintenanceServiceImpl method updatePaymentDetail.

private void updatePaymentDetail(Integer paymentDetailId, String noteText) {
    Map<String, Integer> primaryKeys = new HashMap<String, Integer>();
    primaryKeys.put(PdpPropertyConstants.PaymentDetail.PAYMENT_ID, paymentDetailId);
    PaymentDetail pd = this.businessObjectService.findByPrimaryKey(PaymentDetail.class, primaryKeys);
    if (pd != null) {
        pd.setPrimaryCancelledPayment(Boolean.TRUE);
        PaymentNoteText payNoteText = new PaymentNoteText();
        payNoteText.setCustomerNoteLineNbr(new KualiInteger(pd.getNotes().size() + 1));
        payNoteText.setCustomerNoteText(noteText);
        pd.addNote(payNoteText);
        this.businessObjectService.save(pd);
    } else {
        LOG.error("updatePaymentDetail() Unable to retieve payment detail with an ID of " + paymentDetailId);
    }
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) HashMap(java.util.HashMap) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) PaymentNoteText(org.kuali.kfs.pdp.businessobject.PaymentNoteText) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger)

Example 2 with PaymentNoteText

use of org.kuali.kfs.pdp.businessobject.PaymentNoteText in project cu-kfs by CU-CommunityApps.

the class CuExtractPaymentServiceImpl method writeExtractCheckFile.

@Override
protected void writeExtractCheckFile(PaymentStatus extractedStatus, PaymentProcess p, String filename, Integer processId) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date processDate = dateTimeService.getCurrentDate();
    BufferedWriter os = null;
    BufferedWriter osI = null;
    boolean wroteImmediateHeaderRecords = false;
    boolean wroteCheckHeaderRecords = false;
    String immediateFilename = filename.replace("check", "check_immediate");
    String checkFilename = filename;
    boolean first = true;
    boolean isImmediate = false;
    // customer profile, then change the filename to append the RP-Upload prefix.
    if (isResearchParticipantExtractFile(processId)) {
        String checkFilePrefix = this.kualiConfigurationService.getPropertyValueAsString(PdpKeyConstants.ExtractPayment.CHECK_FILENAME);
        checkFilePrefix = MessageFormat.format(checkFilePrefix, new Object[] { null });
        checkFilePrefix = PdpConstants.RESEARCH_PARTICIPANT_FILE_PREFIX + KFSConstants.DASH + checkFilePrefix;
        filename = getOutputFile(checkFilePrefix, processDate);
    }
    try {
        List<String> notificationEmailAddresses = this.getBankPaymentFileNotificationEmailAddresses();
        writeExtractCheckFileMellonBankFastTrack(extractedStatus, p, filename, processId, notificationEmailAddresses);
        List<String> bankCodes = paymentGroupService.getDistinctBankCodesForProcessAndType(processId, PdpConstants.DisbursementTypeCodes.CHECK);
        for (String bankCode : bankCodes) {
            List<Integer> disbNbrs = paymentGroupService.getDisbursementNumbersByDisbursementTypeAndBankCode(processId, PdpConstants.DisbursementTypeCodes.CHECK, bankCode);
            for (Iterator<Integer> iter = disbNbrs.iterator(); iter.hasNext(); ) {
                Integer disbursementNbr = iter.next();
                first = true;
                KualiDecimal totalNetAmount = new KualiDecimal(0);
                // this seems wasteful, but since the total net amount is needed on the first payment detail...it's needed
                Iterator<PaymentDetail> i2 = paymentDetailService.getByDisbursementNumber(disbursementNbr, processId, PdpConstants.DisbursementTypeCodes.CHECK, bankCode);
                while (i2.hasNext()) {
                    PaymentDetail pd = i2.next();
                    totalNetAmount = totalNetAmount.add(pd.getNetPaymentAmount());
                }
                List<KualiInteger> paymentGroupIdsSaved = new ArrayList<KualiInteger>();
                Iterator<PaymentDetail> paymentDetails = paymentDetailService.getByDisbursementNumber(disbursementNbr, processId, PdpConstants.DisbursementTypeCodes.CHECK, bankCode);
                while (paymentDetails.hasNext()) {
                    PaymentDetail detail = paymentDetails.next();
                    PaymentGroup group = detail.getPaymentGroup();
                    if (!testMode) {
                        if (!paymentGroupIdsSaved.contains(group.getId())) {
                            group.setDisbursementDate(new java.sql.Date(processDate.getTime()));
                            group.setPaymentStatus(extractedStatus);
                            this.businessObjectService.save(group);
                            paymentGroupIdsSaved.add(group.getId());
                        }
                    }
                    isImmediate = group.getProcessImmediate();
                    if (first && !isImmediate) {
                        if (!wroteCheckHeaderRecords) {
                            os = new BufferedWriter(new FileWriter(checkFilename));
                            os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
                            writeOpenTagAttribute(os, 0, "checks", "processId", processId.toString(), "campusCode", p.getCampusCode());
                            wroteCheckHeaderRecords = true;
                        }
                        writeOpenTagAttribute(os, 2, "check", "disbursementNbr", group.getDisbursementNbr().toString());
                        // Write check level information
                        writeBank(os, 4, group.getBank());
                        writeTag(os, 4, "disbursementDate", sdf.format(processDate));
                        writeTag(os, 4, "netAmount", totalNetAmount.toString());
                        writePayee(os, 4, group);
                        writeTag(os, 4, "campusAddressIndicator", group.getCampusAddress().booleanValue() ? "Y" : "N");
                        writeTag(os, 4, "attachmentIndicator", group.getPymtAttachment().booleanValue() ? "Y" : "N");
                        writeTag(os, 4, "specialHandlingIndicator", group.getPymtSpecialHandling().booleanValue() ? "Y" : "N");
                        writeTag(os, 4, "immediatePaymentIndicator", group.getProcessImmediate().booleanValue() ? "Y" : "N");
                        writeTag(os, 4, "customerUnivNbr", group.getCustomerInstitutionNumber());
                        writeTag(os, 4, "paymentDate", sdf.format(group.getPaymentDate()));
                        // Write customer profile information
                        CustomerProfile cp = group.getBatch().getCustomerProfile();
                        writeCustomerProfile(os, 4, cp);
                        writeOpenTag(os, 4, "payments");
                        first = false;
                    }
                    if (first && isImmediate) {
                        if (!wroteImmediateHeaderRecords) {
                            osI = new BufferedWriter(new FileWriter(immediateFilename));
                            osI.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
                            writeOpenTagAttribute(osI, 0, "checks", "processId", processId.toString(), "campusCode", p.getCampusCode());
                            wroteImmediateHeaderRecords = true;
                        }
                        writeOpenTagAttribute(osI, 2, "check", "disbursementNbr", group.getDisbursementNbr().toString());
                        // Write check level information
                        writeBank(osI, 4, group.getBank());
                        writeTag(osI, 4, "disbursementDate", sdf.format(processDate));
                        writeTag(osI, 4, "netAmount", totalNetAmount.toString());
                        writePayee(osI, 4, group);
                        writeTag(osI, 4, "campusAddressIndicator", group.getCampusAddress().booleanValue() ? "Y" : "N");
                        writeTag(osI, 4, "attachmentIndicator", group.getPymtAttachment().booleanValue() ? "Y" : "N");
                        writeTag(osI, 4, "specialHandlingIndicator", group.getPymtSpecialHandling().booleanValue() ? "Y" : "N");
                        writeTag(osI, 4, "immediatePaymentIndicator", group.getProcessImmediate().booleanValue() ? "Y" : "N");
                        writeTag(osI, 4, "customerUnivNbr", group.getCustomerInstitutionNumber());
                        writeTag(osI, 4, "paymentDate", sdf.format(group.getPaymentDate()));
                        // Write customer profile information
                        CustomerProfile cp = group.getBatch().getCustomerProfile();
                        writeCustomerProfile(osI, 4, cp);
                        writeOpenTag(osI, 4, "payments");
                        first = false;
                    }
                    if (!isImmediate && wroteCheckHeaderRecords) {
                        writeOpenTag(os, 6, "payment");
                        writeTag(os, 8, "purchaseOrderNbr", detail.getPurchaseOrderNbr());
                        writeTag(os, 8, "invoiceNbr", detail.getInvoiceNbr());
                        writeTag(os, 8, "requisitionNbr", detail.getRequisitionNbr());
                        writeTag(os, 8, "custPaymentDocNbr", detail.getCustPaymentDocNbr());
                        writeTag(os, 8, "invoiceDate", sdf.format(detail.getInvoiceDate()));
                        writeTag(os, 8, "origInvoiceAmount", detail.getOrigInvoiceAmount().toString());
                        writeTag(os, 8, "netPaymentAmount", detail.getNetPaymentAmount().toString());
                        writeTag(os, 8, "invTotDiscountAmount", detail.getInvTotDiscountAmount().toString());
                        writeTag(os, 8, "invTotShipAmount", detail.getInvTotShipAmount().toString());
                        writeTag(os, 8, "invTotOtherDebitAmount", detail.getInvTotOtherDebitAmount().toString());
                        writeTag(os, 8, "invTotOtherCreditAmount", detail.getInvTotOtherCreditAmount().toString());
                        writeOpenTag(os, 8, "notes");
                        for (Iterator ix = detail.getNotes().iterator(); ix.hasNext(); ) {
                            PaymentNoteText note = (PaymentNoteText) ix.next();
                            writeTag(os, 10, "note", note.getCustomerNoteText());
                        }
                        writeCloseTag(os, 8, "notes");
                        writeCloseTag(os, 6, "payment");
                    }
                    if (isImmediate && wroteImmediateHeaderRecords) {
                        writeOpenTag(osI, 6, "payment");
                        writeTag(osI, 8, "purchaseOrderNbr", detail.getPurchaseOrderNbr());
                        writeTag(osI, 8, "invoiceNbr", detail.getInvoiceNbr());
                        writeTag(osI, 8, "requisitionNbr", detail.getRequisitionNbr());
                        writeTag(osI, 8, "custPaymentDocNbr", detail.getCustPaymentDocNbr());
                        writeTag(osI, 8, "invoiceDate", sdf.format(detail.getInvoiceDate()));
                        writeTag(osI, 8, "origInvoiceAmount", detail.getOrigInvoiceAmount().toString());
                        writeTag(osI, 8, "netPaymentAmount", detail.getNetPaymentAmount().toString());
                        writeTag(osI, 8, "invTotDiscountAmount", detail.getInvTotDiscountAmount().toString());
                        writeTag(osI, 8, "invTotShipAmount", detail.getInvTotShipAmount().toString());
                        writeTag(osI, 8, "invTotOtherDebitAmount", detail.getInvTotOtherDebitAmount().toString());
                        writeTag(osI, 8, "invTotOtherCreditAmount", detail.getInvTotOtherCreditAmount().toString());
                        writeOpenTag(osI, 8, "notes");
                        for (Iterator ix = detail.getNotes().iterator(); ix.hasNext(); ) {
                            PaymentNoteText note = (PaymentNoteText) ix.next();
                            writeTag(osI, 10, "note", note.getCustomerNoteText());
                        }
                        writeCloseTag(osI, 8, "notes");
                        writeCloseTag(osI, 6, "payment");
                    }
                }
                if (wroteCheckHeaderRecords && !isImmediate) {
                    writeCloseTag(os, 4, "payments");
                    writeCloseTag(os, 2, "check");
                }
                if (wroteImmediateHeaderRecords && isImmediate) {
                    writeCloseTag(osI, 4, "payments");
                    writeCloseTag(osI, 2, "check");
                }
            }
        }
    } catch (IOException ie) {
        LOG.error("extractChecks() Problem reading file:  " + filename, ie);
        throw new IllegalArgumentException("Error writing to output file: " + ie.getMessage());
    } finally {
        // Close file
        if (os != null) {
            try {
                writeCloseTag(os, 0, "checks");
                os.close();
                // An XML file containing these records are NEVER sent to anyone at this time.
                renameFile(checkFilename, checkFilename + ".NOT_USED");
                createDoneFile(checkFilename + ".NOT_USED");
            } catch (IOException ie) {
            // Not much we can do now
            }
        }
        if (osI != null) {
            try {
                writeCloseTag(osI, 0, "checks");
                osI.close();
                // An XML file containing these records are ONLY used for local check printing.
                renameFile(immediateFilename, immediateFilename + ".READY");
                createDoneFile(immediateFilename + ".READY");
            } catch (IOException ie) {
                // Not much we can do now
                LOG.error("IOException encountered in writeExtractCheckFile.  Message is: " + ie.getMessage());
            }
        }
    }
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) BufferedWriter(java.io.BufferedWriter) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) PaymentNoteText(org.kuali.kfs.pdp.businessobject.PaymentNoteText) Iterator(java.util.Iterator) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) IOException(java.io.IOException) Date(java.util.Date) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with PaymentNoteText

use of org.kuali.kfs.pdp.businessobject.PaymentNoteText in project cu-kfs by CU-CommunityApps.

the class CuExtractPaymentServiceImpl method writePaymentDetailToAchFile.

/*
     * New method created due to refactoring the code from ExtractPaymentServiceImpl and AchBundlerExtractPaymnetServiceImpl
     */
protected void writePaymentDetailToAchFile(BufferedWriter os, PaymentGroup paymentGroup, PaymentDetail paymentDetail, Map<String, Integer> unitCounts, Map<String, KualiDecimal> unitTotals, SimpleDateFormat sdf) throws IOException {
    try {
        writeOpenTag(os, 6, "payment");
        // Write detail info
        writeTag(os, 8, "purchaseOrderNbr", paymentDetail.getPurchaseOrderNbr());
        writeTag(os, 8, "invoiceNbr", paymentDetail.getInvoiceNbr());
        writeTag(os, 8, "requisitionNbr", paymentDetail.getRequisitionNbr());
        writeTag(os, 8, "custPaymentDocNbr", paymentDetail.getCustPaymentDocNbr());
        writeTag(os, 8, "invoiceDate", sdf.format(paymentDetail.getInvoiceDate()));
        writeTag(os, 8, "origInvoiceAmount", paymentDetail.getOrigInvoiceAmount().toString());
        writeTag(os, 8, "netPaymentAmount", paymentDetail.getNetPaymentAmount().toString());
        writeTag(os, 8, "invTotDiscountAmount", paymentDetail.getInvTotDiscountAmount().toString());
        writeTag(os, 8, "invTotShipAmount", paymentDetail.getInvTotShipAmount().toString());
        writeTag(os, 8, "invTotOtherDebitAmount", paymentDetail.getInvTotOtherDebitAmount().toString());
        writeTag(os, 8, "invTotOtherCreditAmount", paymentDetail.getInvTotOtherCreditAmount().toString());
        writeOpenTag(os, 8, "notes");
        for (Iterator i = paymentDetail.getNotes().iterator(); i.hasNext(); ) {
            PaymentNoteText note = (PaymentNoteText) i.next();
            writeTag(os, 10, "note", updateNoteLine(escapeString(note.getCustomerNoteText())));
        }
        writeCloseTag(os, 8, "notes");
        writeCloseTag(os, 6, "payment");
        String unit = paymentGroup.getBatch().getCustomerProfile().getChartCode() + "-" + paymentGroup.getBatch().getCustomerProfile().getUnitCode() + "-" + paymentGroup.getBatch().getCustomerProfile().getSubUnitCode();
        Integer count = 1;
        if (unitCounts.containsKey(unit)) {
            count = 1 + unitCounts.get(unit);
        }
        unitCounts.put(unit, count);
        KualiDecimal unitTotal = paymentDetail.getNetPaymentAmount();
        if (unitTotals.containsKey(unit)) {
            unitTotal = paymentDetail.getNetPaymentAmount().add(unitTotals.get(unit));
        }
        unitTotals.put(unit, unitTotal);
    } catch (IOException ioe) {
        LOG.error("writePaymentDetailToAchFile(): Problem writing to file - IOException caught and rethrown.");
        throw ioe;
    }
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) PaymentNoteText(org.kuali.kfs.pdp.businessobject.PaymentNoteText) Iterator(java.util.Iterator) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) IOException(java.io.IOException)

Example 4 with PaymentNoteText

use of org.kuali.kfs.pdp.businessobject.PaymentNoteText in project cu-kfs by CU-CommunityApps.

the class CuPdpEmailServiceImpl method createAdviceMessagePaymentDetail.

/**
 * KFSPTS-1460: New method. Create a formatted payment detail line for the ACH advice.
 */
private String createAdviceMessagePaymentDetail(PaymentGroup paymentGroup, PaymentDetail paymentDetail, boolean adviceIsForDV, boolean shouldBundleAchPayments) {
    LOG.debug("createAdviceMessagePaymentDetail() starting");
    Formatter moneyFormatter = new CurrencyFormatter();
    Formatter dateFormatter = new DateFormatter();
    Formatter integerFormatter = new IntegerFormatter();
    String invoiceNbr = "";
    if (StringUtils.isNotBlank(paymentDetail.getInvoiceNbr())) {
        invoiceNbr = paymentDetail.getInvoiceNbr();
    }
    String poNbr = "";
    if (StringUtils.isNotBlank(paymentDetail.getPurchaseOrderNbr())) {
        poNbr = paymentDetail.getPurchaseOrderNbr();
    }
    String invoiceDate = "";
    if (paymentDetail.getInvoiceDate() != null) {
        invoiceDate = (String) dateFormatter.formatForPresentation(paymentDetail.getInvoiceDate());
    }
    String sourceDocNbr = "";
    if (StringUtils.isNotBlank(paymentDetail.getCustPaymentDocNbr())) {
        sourceDocNbr = paymentDetail.getCustPaymentDocNbr();
    }
    String payDate = "";
    if (paymentGroup.getPaymentDate() != null) {
        payDate = (String) dateFormatter.formatForPresentation(paymentGroup.getPaymentDate());
    }
    String disbNbr = "";
    if (paymentGroup.getDisbursementNbr() != null) {
        disbNbr = (String) integerFormatter.formatForPresentation(paymentGroup.getDisbursementNbr());
    }
    String disbDate = "";
    if (paymentGroup.getDisbursementDate() != null) {
        disbDate = (String) dateFormatter.formatForPresentation(paymentGroup.getDisbursementDate());
    }
    String originalInvoiceAmount = "";
    if (paymentDetail.getOrigInvoiceAmount() != null) {
        String amount = (String) moneyFormatter.formatForPresentation(paymentDetail.getOrigInvoiceAmount());
        originalInvoiceAmount = StringUtils.remove(amount, KFSConstants.COMMA);
    }
    String invoiceTotalDiscount = "";
    if (paymentDetail.getInvTotDiscountAmount() != null) {
        String amount = (String) moneyFormatter.formatForPresentation(paymentDetail.getInvTotDiscountAmount());
        invoiceTotalDiscount = StringUtils.remove(amount, KFSConstants.COMMA);
    }
    String netPayAmount = "";
    if (paymentDetail.getNetPaymentAmount() != null) {
        String amount = (String) moneyFormatter.formatForPresentation(paymentDetail.getNetPaymentAmount());
        netPayAmount = StringUtils.remove(amount, KFSConstants.COMMA);
    }
    // there are three types of formats that need to be created: DV (same format for both bundled and non), PREQ-bundled, PREQ-non-bundled
    StringBuffer formattedPaymentDetail = new StringBuffer();
    if (adviceIsForDV) {
        // DV payment detail gets put in message body, format for that
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_SOURCE_DOCUMENT_NUMBER, sourceDocNbr));
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_NET_PAYMENT_AMOUNT, netPayAmount));
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_ORIGINAL_INVOICE_AMOUNT, originalInvoiceAmount));
        // print payment notes
        formattedPaymentDetail.append(KFSConstants.NEWLINE);
        for (PaymentNoteText paymentNoteText : paymentDetail.getNotes()) {
            formattedPaymentDetail.append(paymentNoteText.getCustomerNoteText() + KFSConstants.NEWLINE);
        }
        if (paymentDetail.getNotes().isEmpty()) {
            formattedPaymentDetail.append(getMessage(PdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_NONOTES));
        }
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_SEPARATOR));
    } else if (shouldBundleAchPayments) {
        // PREQ payment detail gets put in attachment
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_ATTACHMENT_PAYMENT_TABLE_ITEM_LINE, invoiceNbr, poNbr, invoiceDate, sourceDocNbr, payDate, disbNbr, disbDate, originalInvoiceAmount, invoiceTotalDiscount, netPayAmount));
    } else {
        // PREQ payment detail gets put in message body	(used for BOTH non-bundled adviced and the first N payment details of bundled advices
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_INVOICE_NUMBER, invoiceNbr));
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PURCHASE_ORDER_NUMBER, poNbr));
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_SOURCE_DOCUMENT_NUMBER, sourceDocNbr));
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_NET_PAYMENT_AMOUNT, netPayAmount));
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_ORIGINAL_INVOICE_AMOUNT, originalInvoiceAmount));
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_TOTAL_DISCOUNT_AMOUNT, invoiceTotalDiscount));
        // print payment notes
        formattedPaymentDetail.append(KFSConstants.NEWLINE);
        for (PaymentNoteText paymentNoteText : paymentDetail.getNotes()) {
            formattedPaymentDetail.append(paymentNoteText.getCustomerNoteText() + KFSConstants.NEWLINE);
        }
        if (paymentDetail.getNotes().isEmpty()) {
            formattedPaymentDetail.append(getMessage(PdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_NONOTES));
        }
        formattedPaymentDetail.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_SEPARATOR));
    }
    return formattedPaymentDetail.toString();
}
Also used : PaymentNoteText(org.kuali.kfs.pdp.businessobject.PaymentNoteText) IntegerFormatter(org.kuali.rice.core.web.format.IntegerFormatter) DateFormatter(org.kuali.rice.core.web.format.DateFormatter) Formatter(org.kuali.rice.core.web.format.Formatter) CurrencyFormatter(org.kuali.rice.core.web.format.CurrencyFormatter) DateFormatter(org.kuali.rice.core.web.format.DateFormatter) CurrencyFormatter(org.kuali.rice.core.web.format.CurrencyFormatter) IntegerFormatter(org.kuali.rice.core.web.format.IntegerFormatter)

Example 5 with PaymentNoteText

use of org.kuali.kfs.pdp.businessobject.PaymentNoteText in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherExtractionHelperServiceImpl method buildPaymentDetail.

protected PaymentDetail buildPaymentDetail(DisbursementVoucherDocument document, Date processRunDate) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("buildPaymentDetail() started");
    }
    final String maxNoteLinesParam = getParameterService().getParameterValueAsString(KfsParameterConstants.PRE_DISBURSEMENT_ALL.class, PdpParameterConstants.MAX_NOTE_LINES);
    int maxNoteLines;
    try {
        maxNoteLines = Integer.parseInt(maxNoteLinesParam);
    } catch (NumberFormatException nfe) {
        throw new IllegalArgumentException("Invalid Max Notes Lines parameter, value: " + maxNoteLinesParam + " cannot be converted to an integer");
    }
    PaymentDetail pd = new PaymentDetail();
    if (StringUtils.isNotEmpty(document.getDocumentHeader().getOrganizationDocumentNumber())) {
        pd.setOrganizationDocNbr(document.getDocumentHeader().getOrganizationDocumentNumber());
    }
    pd.setCustPaymentDocNbr(document.getDocumentNumber());
    pd.setInvoiceDate(new java.sql.Date(processRunDate.getTime()));
    pd.setOrigInvoiceAmount(document.getDisbVchrCheckTotalAmount());
    pd.setInvTotDiscountAmount(KualiDecimal.ZERO);
    pd.setInvTotOtherCreditAmount(KualiDecimal.ZERO);
    pd.setInvTotOtherDebitAmount(KualiDecimal.ZERO);
    pd.setInvTotShipAmount(KualiDecimal.ZERO);
    pd.setNetPaymentAmount(document.getDisbVchrCheckTotalAmount());
    pd.setPrimaryCancelledPayment(Boolean.FALSE);
    pd.setFinancialDocumentTypeCode(DisbursementVoucherConstants.DOCUMENT_TYPE_CHECKACH);
    pd.setFinancialSystemOriginCode(KFSConstants.ORIGIN_CODE_KUALI);
    // Handle accounts
    for (SourceAccountingLine sal : (List<? extends SourceAccountingLine>) document.getSourceAccountingLines()) {
        PaymentAccountDetail pad = new PaymentAccountDetail();
        pad.setFinChartCode(sal.getChartOfAccountsCode());
        pad.setAccountNbr(sal.getAccountNumber());
        if (StringUtils.isNotEmpty(sal.getSubAccountNumber())) {
            pad.setSubAccountNbr(sal.getSubAccountNumber());
        } else {
            pad.setSubAccountNbr(KFSConstants.getDashSubAccountNumber());
        }
        pad.setFinObjectCode(sal.getFinancialObjectCode());
        if (StringUtils.isNotEmpty(sal.getFinancialSubObjectCode())) {
            pad.setFinSubObjectCode(sal.getFinancialSubObjectCode());
        } else {
            pad.setFinSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        }
        if (StringUtils.isNotEmpty(sal.getOrganizationReferenceId())) {
            pad.setOrgReferenceId(sal.getOrganizationReferenceId());
        }
        if (StringUtils.isNotEmpty(sal.getProjectCode())) {
            pad.setProjectCode(sal.getProjectCode());
        } else {
            pad.setProjectCode(KFSConstants.getDashProjectCode());
        }
        pad.setAccountNetAmount(sal.getAmount());
        pd.addAccountDetail(pad);
    }
    // Handle notes
    DisbursementVoucherPayeeDetail dvpd = document.getDvPayeeDetail();
    int line = 0;
    PaymentNoteText pnt = new PaymentNoteText();
    pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
    pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_PREPARER + document.getDisbVchrContactPersonName() + " " + document.getDisbVchrContactPhoneNumber());
    pd.addNote(pnt);
    String dvSpecialHandlingPersonName = null;
    String dvSpecialHandlingLine1Address = null;
    String dvSpecialHandlingLine2Address = null;
    String dvSpecialHandlingCity = null;
    String dvSpecialHandlingState = null;
    String dvSpecialHandlingZip = null;
    dvSpecialHandlingPersonName = dvpd.getDisbVchrSpecialHandlingPersonName();
    dvSpecialHandlingLine1Address = dvpd.getDisbVchrSpecialHandlingLine1Addr();
    dvSpecialHandlingLine2Address = dvpd.getDisbVchrSpecialHandlingLine2Addr();
    dvSpecialHandlingCity = dvpd.getDisbVchrSpecialHandlingCityName();
    dvSpecialHandlingState = dvpd.getDisbVchrSpecialHandlingStateCode();
    dvSpecialHandlingZip = dvpd.getDisbVchrSpecialHandlingZipCode();
    if (StringUtils.isNotEmpty(dvSpecialHandlingPersonName)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Send Check To: " + dvSpecialHandlingPersonName);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling person name note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(dvSpecialHandlingLine1Address)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS1 + dvSpecialHandlingLine1Address);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling address 1 note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(dvSpecialHandlingLine2Address)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS2 + dvSpecialHandlingLine2Address);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling address 2 note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(dvSpecialHandlingCity)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS3 + dvSpecialHandlingCity + ", " + dvSpecialHandlingState + " " + dvSpecialHandlingZip);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling city note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (document.isDisbVchrAttachmentCode()) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Attachment Included");
        if (LOG.isDebugEnabled()) {
            LOG.debug("create attachment note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    String paymentReasonCode = dvpd.getDisbVchrPaymentReasonCode();
    if (/*REFACTORME*/
    getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.NONEMPLOYEE_TRAVEL_PAY_REASONS_PARM_NM, paymentReasonCode).evaluationSucceeds()) {
        DisbursementVoucherNonEmployeeTravel dvnet = document.getDvNonEmployeeTravel();
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Reimbursement associated with " + dvnet.getDisbVchrServicePerformedDesc());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("The total per diem amount for your daily expenses is " + dvnet.getDisbVchrPerdiemActualAmount());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
        if (dvnet.getDisbVchrPersonalCarAmount() != null && dvnet.getDisbVchrPersonalCarAmount().compareTo(KualiDecimal.ZERO) != 0) {
            pnt = new PaymentNoteText();
            pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
            pnt.setCustomerNoteText("The total dollar amount for your vehicle mileage is " + dvnet.getDisbVchrPersonalCarAmount());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Creating non employee travel vehicle note: " + pnt.getCustomerNoteText());
            }
            pd.addNote(pnt);
            for (DisbursementVoucherNonEmployeeExpense exp : (List<DisbursementVoucherNonEmployeeExpense>) dvnet.getDvNonEmployeeExpenses()) {
                if (line < (maxNoteLines - 8)) {
                    pnt = new PaymentNoteText();
                    pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
                    pnt.setCustomerNoteText(exp.getDisbVchrExpenseCompanyName() + " " + exp.getDisbVchrExpenseAmount());
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Creating non employee travel expense note: " + pnt.getCustomerNoteText());
                    }
                    pd.addNote(pnt);
                }
            }
        }
    } else if (/*REFACTORME*/
    getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PREPAID_TRAVEL_PAYMENT_REASONS_PARM_NM, paymentReasonCode).evaluationSucceeds()) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Payment is for the following individuals/charges:");
        pd.addNote(pnt);
        if (LOG.isDebugEnabled()) {
            LOG.info("Creating prepaid travel note note: " + pnt.getCustomerNoteText());
        }
        DisbursementVoucherPreConferenceDetail dvpcd = document.getDvPreConferenceDetail();
        for (DisbursementVoucherPreConferenceRegistrant dvpcr : (List<DisbursementVoucherPreConferenceRegistrant>) dvpcd.getDvPreConferenceRegistrants()) {
            if (line < (maxNoteLines - 8)) {
                pnt = new PaymentNoteText();
                pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
                pnt.setCustomerNoteText(dvpcr.getDvConferenceRegistrantName() + " " + dvpcr.getDisbVchrExpenseAmount());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Creating pre-paid conference registrants note: " + pnt.getCustomerNoteText());
                }
                pd.addNote(pnt);
            }
        }
    }
    // Get the original, raw form, note text from the DV document.
    final String text = document.getDisbVchrCheckStubText();
    if (!StringUtils.isBlank(text)) {
        pd.addNotes(getPaymentSourceHelperService().buildNotesForCheckStubText(text, line));
    }
    return pd;
}
Also used : DisbursementVoucherNonEmployeeTravel(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel) DisbursementVoucherPreConferenceDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceDetail) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) DisbursementVoucherNonEmployeeExpense(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense) DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) CuDisbursementVoucherPayeeDetail(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) DisbursementVoucherPreConferenceRegistrant(org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceRegistrant) Date(java.sql.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) PaymentNoteText(org.kuali.kfs.pdp.businessobject.PaymentNoteText) ArrayList(java.util.ArrayList) List(java.util.List) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) PaymentAccountDetail(org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)

Aggregations

PaymentNoteText (org.kuali.kfs.pdp.businessobject.PaymentNoteText)8 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)7 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)3 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Iterator (java.util.Iterator)2 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)2 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)2 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)2 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)1 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)1 Date (java.sql.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1