Search in sources :

Example 1 with CurrencyFormatter

use of org.kuali.rice.core.web.format.CurrencyFormatter in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocumentBatchServiceImpl method populateBatchSummaryLine.

/**
 * Creates and populates a batch summary line for the disbursement voucher document
 *
 * @param disbursementVoucherDocument batch disbursement voucher document
 * @param MessageMap MessageMap containing errors encountered while populating document
 * @return PurchaseOrderBatchSummaryLine
 */
protected DisbursementVoucherBatchSummaryLine populateBatchSummaryLine(DisbursementVoucherDocument disbursementVoucherDocument, MessageMap MessageMap) {
    DisbursementVoucherBatchSummaryLine batchSummaryLine = new DisbursementVoucherBatchSummaryLine();
    DisbursementVoucherPayeeDetail dvPayeeDetail = disbursementVoucherDocument.getDvPayeeDetail();
    // dvPayeeDetail.refresh();
    Date currentDate = dateTimeService.getCurrentDate();
    batchSummaryLine.setDisbVchrCreateDate(dateTimeService.toDateString(currentDate));
    batchSummaryLine.setDisbVchrPayeeId(dvPayeeDetail.getDisbVchrPayeeIdNumber() + " (" + dvPayeeDetail.getDisbVchrPayeePersonName() + " )");
    if (disbursementVoucherDocument.getDisbVchrCheckTotalAmount() != null) {
        String totalDollarAmount = (String) (new CurrencyFormatter()).formatForPresentation(disbursementVoucherDocument.getDisbVchrCheckTotalAmount());
        batchSummaryLine.setDisbVchrAmount(totalDollarAmount);
    }
    if (disbursementVoucherDocument.getDisbursementVoucherDueDate() != null) {
        batchSummaryLine.setDisbursementVoucherDueDate(disbursementVoucherDocument.getDisbursementVoucherDueDate().toString());
    }
    if (ObjectUtils.isNotNull(dvPayeeDetail.getDisbVchrPaymentReason())) {
        String paymentReasonDescription = dvPayeeDetail.getDisbVchrPaymentReason().getDescription();
        if (paymentReasonDescription.length() >= 50) {
            paymentReasonDescription = paymentReasonDescription.substring(0, 49);
        }
        batchSummaryLine.setDisbVchrPaymentReason(dvPayeeDetail.getDisbVchrPaymentReasonCode() + "-" + paymentReasonDescription);
    }
    batchSummaryLine.setAuditMessage(batchFeedHelperService.getAuditMessage(FPKeyConstants.MESSAGE_AUDIT_DV_SUCCESSFULLY_GENERATED, disbursementVoucherDocument.getDocumentNumber(), MessageMap));
    return batchSummaryLine;
}
Also used : DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) CurrencyFormatter(org.kuali.rice.core.web.format.CurrencyFormatter) DisbursementVoucherBatchSummaryLine(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine) Date(java.util.Date)

Example 2 with CurrencyFormatter

use of org.kuali.rice.core.web.format.CurrencyFormatter 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 3 with CurrencyFormatter

use of org.kuali.rice.core.web.format.CurrencyFormatter in project cu-kfs by CU-CommunityApps.

the class CuPdpEmailServiceImpl method createAdviceMessageBody.

/**
 * KFSPTS-1460: New method. Created from code in sendAchAdviceEmail and new code.
 * All content in the body of the email message is created in this method regardless
 * of the number of payment details for the payment group.
 */
private StringBuffer createAdviceMessageBody(PaymentGroup paymentGroup, CustomerProfile customer, KualiDecimal netPaymentAmount, Integer numPayments) {
    LOG.debug("createAdviceMessageBody() starting");
    // formatter for payment amounts
    Formatter moneyFormatter = new CurrencyFormatter();
    Formatter integerFormatter = new IntegerFormatter();
    String payeeName = "";
    if (paymentGroup.getPayeeName() != null) {
        payeeName = paymentGroup.getPayeeName();
    }
    String paymentDescription = "";
    if (customer.getAchPaymentDescription() != null) {
        paymentDescription = customer.getAchPaymentDescription();
    }
    StringBuffer body = new StringBuffer();
    body.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_TO, payeeName));
    body.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_FROM, paymentDescription));
    // get bank name to which the payment is being transferred
    String bankName = "";
    ACHBank achBank = achBankService.getByPrimaryId(paymentGroup.getAchBankRoutingNbr());
    if (achBank == null) {
        LOG.error("Bank cound not be found for routing number " + paymentGroup.getAchBankRoutingNbr());
    } else {
        bankName = achBank.getBankName();
    }
    String disbNbr = "";
    if (paymentGroup.getDisbursementNbr() != null) {
        disbNbr = (String) integerFormatter.formatForPresentation(paymentGroup.getDisbursementNbr());
    }
    // verbiage stating bank, net amount, and disb num that was sent
    body.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_BANK_AMOUNT, bankName, moneyFormatter.formatForPresentation(netPaymentAmount), disbNbr));
    // verbiage stating when the deposit should be expected
    body.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_DEPOSIT_DAYS));
    // verbiage stating the number of payments the net deposit was for
    body.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_DEPOSIT_NUM_PAYMENTS, integerFormatter.formatForPresentation(numPayments.toString())));
    return body;
}
Also used : 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) CurrencyFormatter(org.kuali.rice.core.web.format.CurrencyFormatter) IntegerFormatter(org.kuali.rice.core.web.format.IntegerFormatter) ACHBank(org.kuali.kfs.pdp.businessobject.ACHBank)

Aggregations

CurrencyFormatter (org.kuali.rice.core.web.format.CurrencyFormatter)3 DateFormatter (org.kuali.rice.core.web.format.DateFormatter)2 Formatter (org.kuali.rice.core.web.format.Formatter)2 IntegerFormatter (org.kuali.rice.core.web.format.IntegerFormatter)2 DisbursementVoucherBatchSummaryLine (com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine)1 Date (java.util.Date)1 DisbursementVoucherPayeeDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail)1 ACHBank (org.kuali.kfs.pdp.businessobject.ACHBank)1 PaymentNoteText (org.kuali.kfs.pdp.businessobject.PaymentNoteText)1