Search in sources :

Example 1 with DateFormatter

use of org.kuali.rice.core.web.format.DateFormatter 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)

Aggregations

PaymentNoteText (org.kuali.kfs.pdp.businessobject.PaymentNoteText)1 CurrencyFormatter (org.kuali.rice.core.web.format.CurrencyFormatter)1 DateFormatter (org.kuali.rice.core.web.format.DateFormatter)1 Formatter (org.kuali.rice.core.web.format.Formatter)1 IntegerFormatter (org.kuali.rice.core.web.format.IntegerFormatter)1