2 * Copyright (C) 2016 - 2022 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jfinancials.beans.helper.receipt;
19 import java.text.DateFormat;
20 import javax.faces.view.ViewScoped;
21 import javax.inject.Named;
22 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
23 import org.mxchange.jfinancials.model.receipt.BillableReceipt;
26 * A receipt helper for beans
28 * @author Roland Häder<roland@mxchange.org>
30 @Named ("receiptBeanHelper")
32 public class FinancialsWebViewReceiptHelperBean extends BaseFinancialsBean implements FinancialsWebViewReceiptHelperController {
37 private static final long serialVersionUID = 17_258_793_567_145_811L;
42 public FinancialsWebViewReceiptHelperBean () {
43 // Call super constructor
48 * Returns the receipt number and more. If null is provided, an empty string
51 * @param receipt Receipt instance
52 * @param showReceiptPaymentType Whether the payment type should be shown
54 * @return Receipt number and more
56 public String renderReceipt (final BillableReceipt receipt, final Boolean showReceiptPaymentType) {
57 // Default is empty string, so let's get started
58 final StringBuilder sb = new StringBuilder(50);
61 if (receipt instanceof BillableReceipt) {
63 sb.append(this.getMessageFromBundle("RECEIPT_ISSUED")).append(" "); //NOI18N
64 sb.append(DateFormat.getInstance().format(receipt.getReceiptIssued()));
66 // Is payment type to be shown?
67 if (showReceiptPaymentType) {
69 sb.append(", ").append(this.getMessageFromBundle("PAYMENT_TYPE")).append(" "); //NOI18N
70 sb.append(this.getMessageFromBundle(receipt.getReceiptPaymentType().getMessageKey()));
73 // Is receipt number included?
74 if (receipt.getReceiptNumber() != null) {
76 sb.append(", ").append(this.getMessageFromBundle("RECEIPT_NUMBER")).append(" "); //NOI18N
77 sb.append(receipt.getReceiptNumber());
80 // Add company's short name
81 sb.append(" ("); //NOI18N
82 sb.append(receipt.getReceiptBranchOffice().getBranchCompany().getCompanyShortName());
83 sb.append(")"); //NOI18N