package com.arrebol.taxiservicios.wrapper;

import com.arrebol.taxiservicios.model.catalog.Product;
import com.arrebol.taxiservicios.model.stocktaking.ServiceOrderHasProduct;
import java.io.Serializable;

/**
 *
 * @author Carlos Janitzio Zavala Lopez
 */
public class ProductWrapper implements Serializable {

    private static final long serialVersionUID = 7880817232023414616L;

    public void wrapper(Product product) {
        productId = product.getId();
        name = product.getName();
        amount = product.getAmount();
        utility = product.getUtility();
        price = (((double)product.getUtility() / 100d) * product.getAmount()) + product.getAmount();
        total = price * quantity;
    }

    /**
     *
     * @param product
     * @param code
     * @param brand
     */
    public void wrapper(Product product, String code, String brand) {
        productId = product.getId();
        name = brand + " - " + code + " - " + product.getName();
        amount = product.getAmount();
        utility = product.getUtility();
        price = product.getAmount();
        total = price * quantity;
    }
    
    public void wrapper(Product product, String code, String brand, boolean valor) {
        productId = product.getId();
        name = brand + " - " + code + " - " + product.getName();
        amount = product.getAmount2();
        utility = product.getUtility2();
        price = product.getAmount2();
        total = price * quantity;
    }

    private String id;
    private String productId;
    private String name;
    private Double amount;
    private Double utility;
    private Integer quantity;
    private Double price;
    private Double total;

    public ProductWrapper() {
    }

    public ProductWrapper(ServiceOrderHasProduct orderHasProduct) {
        productId = orderHasProduct.getProduct().getId();
        name = orderHasProduct.getProduct().getBrand().getName() +" - " + orderHasProduct.getProduct().getCode() + " - " + orderHasProduct.getProduct().getName();
        amount = orderHasProduct.getProduct().getAmount();
        utility = orderHasProduct.getProduct().getUtility();
        quantity = orderHasProduct.getQuantity();
        total = Double.valueOf(orderHasProduct.getTotal());
        price = Double.valueOf(orderHasProduct.getPrice());
    }

    public ProductWrapper(String id) {
        this.id = id;
    }

    public ProductWrapper(Product product) {
        productId = product.getId();
        name = product.getName();
        amount = product.getAmount();
        utility = product.getUtility();
        quantity = product.getQuantity();
        total = product.getUtility() / 100
                * product.getAmount()
                + product.getAmount();
    }

    /**
     *
     * @param product
     * @param code
     * @param brand
     */
    public ProductWrapper(Product product, String code, String brand) {
        productId = product.getId();
        name = brand + " - " + code + " - " + product.getName();
        amount = product.getAmount();
        utility = product.getUtility();
        quantity = product.getQuantity();
        total = product.getUtility() / 100
                * product.getAmount()
                + product.getAmount();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getAmount() {
        return amount;
    }

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

    public Double getUtility() {
        return utility;
    }

    public void setUtility(Double utility) {
        this.utility = utility;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "ProductWrapper{" + "id=" + id + ", productId=" + productId + ", name=" + name + ", amount=" + amount + ", utility=" + utility + ", quantity=" + quantity + ", price=" + price + ", total=" + total + '}';
    }

}
