com.sfs.whichdoctor.beans.TransactionSummaryBean.java Source code

Java tutorial

Introduction

Here is the source code for com.sfs.whichdoctor.beans.TransactionSummaryBean.java

Source

/*******************************************************************************
 * Copyright (c) 2009 David Harrison.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl-3.0.html
 *
 * Contributors:
 *     David Harrison - initial API and implementation
 ******************************************************************************/
package com.sfs.whichdoctor.beans;

import com.sfs.Formatter;

import java.util.Date;

import org.apache.commons.lang.StringUtils;

/**
 * The Class TransactionSummaryBean.
 *
 * @author David Harrison 30th May 2003 Modified 9th April 2005
 */
public class TransactionSummaryBean extends WhichDoctorBean {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /** The summary id. */
    private int summaryId;

    /** The abbreviation. */
    private String abbreviation;

    /** The number. */
    private String number;

    /** The type. */
    private String type;

    /** The financial type. */
    private String financialType;

    /** The security. */
    private String security;

    /** The category. */
    private String category;

    /** The person id. */
    private int personId;

    /** The organisation id. */
    private int organisationId;

    /** The person. */
    private PersonBean person;

    /** The organisation. */
    private OrganisationBean organisation;

    /** The value. */
    private double value;

    /** The net value. */
    private double netValue;

    /** The issued. */
    private Date issued;

    /** The cancelled. */
    private boolean cancelled;

    /** The total. */
    private double total;

    /**
     * Sets the summary id.
     *
     * @param summaryIdVal the new summary id
     */
    public final void setSummaryId(final int summaryIdVal) {
        this.summaryId = summaryIdVal;
    }

    /**
     * Gets the summary id.
     *
     * @return the summary id
     */
    public final int getSummaryId() {
        return this.summaryId;
    }

    /**
     * Sets the abbreviation.
     *
     * @param abbreviationVal the new abbreviation
     */
    public final void setAbbreviation(final String abbreviationVal) {
        this.abbreviation = abbreviationVal;
    }

    /**
     * Gets the abbreviation.
     *
     * @return the abbreviation
     */
    public final String getAbbreviation() {
        return this.abbreviation;
    }

    /**
     * Sets the number.
     *
     * @param numberVal the new number
     */
    public final void setNumber(final String numberVal) {
        this.number = numberVal;
    }

    /**
     * Gets the number.
     *
     * @return the number
     */
    public final String getNumber() {
        return this.number;
    }

    /**
     * Sets the type.
     *
     * @param typeVal the new type
     */
    public final void setType(final String typeVal) {
        this.type = typeVal;
    }

    /**
     * Gets the type.
     *
     * @return the type
     */
    public final String getType() {
        return this.type;
    }

    /**
     * Sets the financial type.
     *
     * @param financialTypeVal the new financial type
     */
    public final void setFinancialType(final String financialTypeVal) {
        this.financialType = financialTypeVal;
    }

    /**
     * Gets the financial type.
     *
     * @return the financial type
     */
    public final String getFinancialType() {
        return this.financialType;
    }

    /**
     * Sets the security.
     *
     * @param securityVal the new security
     */
    public final void setSecurity(final String securityVal) {
        this.security = securityVal;
    }

    /**
     * Gets the security.
     *
     * @return the security
     */
    public final String getSecurity() {
        return this.security;
    }

    /**
     * Sets the category.
     *
     * @param categoryVal the new category
     */
    public final void setCategory(final String categoryVal) {
        this.category = categoryVal;
    }

    /**
     * Gets the category.
     *
     * @return the category
     */
    public final String getCategory() {
        return this.category;
    }

    /**
     * Sets the person id.
     *
     * @param personIdVal the new person id
     */
    public final void setPersonId(final int personIdVal) {
        this.personId = personIdVal;
    }

    /**
     * Gets the person id.
     *
     * @return the person id
     */
    public final int getPersonId() {
        return this.personId;
    }

    /**
     * Sets the organisation id.
     *
     * @param organisationIdVal the new organisation id
     */
    public final void setOrganisationId(final int organisationIdVal) {
        this.organisationId = organisationIdVal;
    }

    /**
     * Gets the organisation id.
     *
     * @return the organisation id
     */
    public final int getOrganisationId() {
        return this.organisationId;
    }

    /**
     * Sets the person.
     *
     * @param personRef the new person
     */
    public final void setPerson(final PersonBean personRef) {
        this.person = personRef;
    }

    /**
     * Gets the person.
     *
     * @return the person
     */
    public final PersonBean getPerson() {
        return this.person;
    }

    /**
     * Sets the organisation.
     *
     * @param organisationRef the new organisation
     */
    public final void setOrganisation(final OrganisationBean organisationRef) {
        this.organisation = organisationRef;
    }

    /**
     * Gets the organisation.
     *
     * @return the organisation
     */
    public final OrganisationBean getOrganisation() {
        return this.organisation;
    }

    /**
     * Sets the value.
     *
     * @param val the new value
     */
    public final void setValue(final double val) {
        this.value = Formatter.round(val, 2);
    }

    /**
     * Gets the value.
     *
     * @return the value
     */
    public final double getValue() {
        return Formatter.round(this.value, 2);
    }

    /**
     * Sets the net value.
     *
     * @param netVal the new net value
     */
    public final void setNetValue(final double netVal) {
        this.netValue = Formatter.round(netVal, 2);
    }

    /**
     * Gets the net value.
     *
     * @return the net value
     */
    public final double getNetValue() {
        return Formatter.round(this.netValue, 2);
    }

    /**
     * Gets the GST value.
     *
     * @return the GST value
     */
    public final double getGSTValue() {
        return Formatter.round(this.getNetValue() - this.getValue(), 2);
    }

    /**
     * Sets the issued.
     *
     * @param issuedVal the new issued
     */
    public final void setIssued(final Date issuedVal) {
        if (issuedVal != null) {
            this.issued = new Date(issuedVal.getTime());
        }
    }

    /**
     * Gets the issued.
     *
     * @return the issued
     */
    public final Date getIssued() {
        return this.issued;
    }

    /**
     * Sets the cancelled.
     *
     * @param cancelledVal the new cancelled
     */
    public final void setCancelled(final boolean cancelledVal) {
        this.cancelled = cancelledVal;
    }

    /**
     * Gets the cancelled.
     *
     * @return the cancelled
     */
    public final boolean getCancelled() {
        return this.cancelled;
    }

    /**
     * Sets the total.
     *
     * @param totalVal the new total
     */
    public final void setTotal(final double totalVal) {
        this.total = Formatter.round(totalVal, 2);
    }

    /**
     * Gets the total.
     *
     * @return the total
     */
    public final double getTotal() {
        return Formatter.round(this.total, 2);
    }

    /**
     * Gets the controller.
     *
     * @return the controller
     */
    public final String getController() {
        String controller = "";
        if (StringUtils.equalsIgnoreCase(this.getCategory(), "Debit")) {
            controller = "debits";
        }
        if (StringUtils.equalsIgnoreCase(this.getCategory(), "Credit")) {
            controller = "credits";
        }
        if (StringUtils.equalsIgnoreCase(this.getCategory(), "Receipt")) {
            controller = "receipts";
        }
        return controller;
    }

    /**
     * Gets the display type.
     *
     * @return the display type
     */
    public final String getDisplayType() {
        String displayType = "";
        if (StringUtils.equalsIgnoreCase(this.getCategory(), "Debit")) {
            displayType = this.getFinancialType();
        }
        if (StringUtils.equalsIgnoreCase(this.getCategory(), "Credit")) {
            displayType = "Creditnote";
            if (StringUtils.equalsIgnoreCase(this.getFinancialType(), "Cash")) {
                displayType = "Reimbursement";
            }
            if (StringUtils.equalsIgnoreCase(this.getFinancialType(), "Refund")) {
                displayType = "Refund";
            }
        }
        if (StringUtils.equalsIgnoreCase(this.getCategory(), "Receipt")) {
            displayType = "Credit Receipt";
            if (StringUtils.equalsIgnoreCase(this.getFinancialType(), "Cash")) {
                displayType = "Cash Receipt";
            }
            if (StringUtils.equalsIgnoreCase(this.getFinancialType(), "Cheque")) {
                displayType = "Cheque Receipt";
            }
            if (StringUtils.equalsIgnoreCase(this.getFinancialType(), "Previous")) {
                displayType = "Previous Payment";
            }
        }
        return displayType;
    }

    /**
     * Gets the debit value.
     *
     * @return the debit value
     */
    public final double getDebit() {
        double debitValue = this.netValue;

        if (debitValue != 0 && this.getCredit() != 0) {
            debitValue = 0;
        }
        return debitValue;
    }

    /**
     * Gets the credit value.
     *
     * @return the credit value
     */
    public final double getCredit() {
        double creditValue = 0;

        if (StringUtils.endsWithIgnoreCase(this.category, "Receipt")) {
            creditValue = this.netValue;
        }
        if (StringUtils.endsWithIgnoreCase(this.category, "Credit")
                && !StringUtils.endsWithIgnoreCase(this.financialType, "Cash")) {
            // Not a "Credit" of financial type "Cash" - has a credit value
            creditValue = this.netValue;
        }
        return creditValue;
    }
}