/*
 * ICESOFT COMMERCIAL SOURCE CODE LICENSE V 1.1
 *
 * The contents of this file are subject to the ICEsoft Commercial Source
 * Code License Agreement V1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the
 * License at
 * http://www.icesoft.com/license/commercial-source-v1.1.html
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations under
 * the License.
 *
 * Copyright 2009-2015 ICEsoft Technologies Canada, Corp. All Rights Reserved.
 */
package com.icesoft.faces.facelets.example.expandabletable;

import java.io.Serializable;
import java.util.GregorianCalendar;

/**
 * <p>The <code>SalesRecord</code> class contains the base information for an
 * inventory entry in a data table.  This class is meant to represent a model
 * and should only contain base inventory data</p>
 * <p/>
 * <p>The class instance variables are a direct map from the original ascii
 * expandable table specification. </p>
 */
public class SalesRecord implements Serializable {

    // simple list of sales records.
    protected String description = "";
    protected GregorianCalendar date;
    protected int quantity;
    protected double price;


    /**
     * Gets the description of the record.
     *
     * @return description of the record
     */
    public String getDescription() {
        return description;
    }

    /**
     * Sets the description of the record.
     *
     * @param description of the record
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * Returns the sales record date in dd/mm/yyy format.
     *
     * @return date sales record date
     */
    public String getDate() {
        return date.get(GregorianCalendar.DAY_OF_MONTH) + "/" +
                date.get(GregorianCalendar.MONTH) + "/" +
                date.get(GregorianCalendar.YEAR);
    }

    /**
     * Sets the date of the Calendar.
     *
     * @param date sales record date
     */
    public void setDate(GregorianCalendar date) {
        this.date = date;
    }

    /**
     * Gets the quantity associated with this <code>SalesRecord</code>.
     *
     * @return quantity the quantity associated with this <code>SalesRecord</code>
     */
    public int getQuantity() {
        return quantity;
    }

    /**
     * Sets the quantity associated with this <code>SalesRecord</code>..
     *
     * @param quantity the quantity associated with this <code>SalesRecord</code>
     */
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    /**
     * Returns the unit price of this sales record.
     *
     * @return price unit price.
     */
    public double getPrice() {
        return price;
    }

    /**
     * Sets the unit price of this sales record.
     *
     * @param price unit price
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * Return the calculated total of this sales record, price * quantity.
     *
     * @return total dollar amount of price * quantity.
     */
    public double getTotal() {
        return price * quantity;
    }
}