/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package object.billmanager;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Date;
import object.itemmanager.ProductApp;
import object.itemmanager.Size;

/**
 *
 * @author Administrator
 */
public class BillItem extends Bill {

    private int idBillItem;
    private ProductApp productApp;
    private Size size;
    private int amount;
    private String note;

    public BillItem(int idBillItem, ProductApp productApp, Size size, int amount, String note) {
        this.idBillItem = idBillItem;
        this.productApp = productApp;
        this.size = size;
        this.amount = amount;
        this.note = note;
    }

    public BillItem(int idBillItem, ProductApp productApp, Size size, int amount, String note, int Id, Date date) {
        super(Id, date);
        this.idBillItem = idBillItem;
        this.productApp = productApp;
        this.size = size;
        this.amount = amount;
        this.note = note;
    }

    public BillItem(int idBillItem, ProductApp productApp, Size size, int amount, String note, int Id, Date date, String idTable, String nameTable, ArrayList<BillItem> alBillItems, Color colorTable) {
        super(Id, date, idTable, nameTable, alBillItems, colorTable);
        this.idBillItem = idBillItem;
        this.productApp = productApp;
        this.size = size;
        this.amount = amount;
        this.note = note;
    }

    public BillItem(int idBillItem, ProductApp productApp, Size size, int amount, String note, int Id, Date date, String idTable, String nameTable, ArrayList<BillItem> alBillItems, Color colorTable, String idFloor, String nameFloor) {
        super(Id, date, idTable, nameTable, alBillItems, colorTable, idFloor, nameFloor);
        this.idBillItem = idBillItem;
        this.productApp = productApp;
        this.size = size;
        this.amount = amount;
        this.note = note;
    }

    public BillItem() {
    }

    public int getIdBillItem() {
        return idBillItem;
    }

    public void setIdBillItem(int idBillItem) {
        this.idBillItem = idBillItem;
    }

    public ProductApp getProductApp() {
        return productApp;
    }

    public void setProductApp(ProductApp productApp) {
        this.productApp = productApp;
    }

    public Size getSize() {
        return size;
    }

    public void setSize(Size size) {
        this.size = size;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @Override
    public double getTotalMoney() {
        int total = productApp.getPriceSP() * amount;
        double add = 0;
        if (size != null) {
            add = total * size.getPercent();
        }
        return total + add;
    }

    @Override
    public String toString() {
        return "BillItem{" + "idBillItem=" + idBillItem + ", productApp=" + productApp + ", size=" + size + ", amount=" + amount + ", totalMoney=" + getTotalMoney() + ", note=" + note + '}';
    }

    @Override
    public String[] toArray() {
        return new String[]{productApp.getId(), productApp.getName(), productApp.getIdSP(), productApp.getNameSP(), productApp.getPriceSP() + "", getAmount() + "", size.getName(), getTotalMoney() + "", note};
    }

    public String[] toArrayCTHD() {
        return new String[]{super.getId() + "", idBillItem + "", productApp.getIdSP(), productApp.getNameSP(), size.getName(), amount + "", super.getTotalMoney() + "", note};
    }
}
