<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\InventoryPriceRepository")
 * @ORM\Table(name="inventory_price")
 * @ORM\HasLifecycleCallbacks()
 */

class InventoryPriceEntity
{
    /**
     * @ORM\Column(type="bigint")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="quantity", type="decimal", precision=12, scale=2)
     */
    protected $quantity;

    /**
     * @ORM\Column(name="quantity_accounted", type="decimal", precision=12, scale=2)
     */
    protected $quantityAccounted;

    /**
     * @ORM\Column(name="price", type="decimal", precision=12, scale=2)
     */
    protected $price;

    /**
     * @ORM\Column(name="source", type="string")
     */
    protected $source;

    /**
     * @ORM\Column(name="created_by", type="string", length=50)
     */
    protected $createdBy;

    /**
     * @ORM\Column(name="created_at", type="datetime")
     */
    protected $createdAt;

    /**
     * @ORM\Column(name="updated_by", type="string", length=50)
     */
    protected $updatedBy;

    /**
     * @ORM\Column(name="updated_at", type="datetime")
     */
    protected $updatedAt;

    /**
     * @ORM\ManyToOne(targetEntity="InventoryEntity", inversedBy="inventoryPrices")
     * @ORM\JoinColumn(name="inventory_id", referencedColumnName="id")
     */
    protected $inventory;

    /**
     * @ORM\ManyToOne(targetEntity="PurchaseOrderBreakdownItemDeliveryEntity", inversedBy="inventoryPrices")
     * @ORM\JoinColumn(name="purchase_order_breakdown_item_delivery_id", referencedColumnName="id")
     */
    protected $purchaseOrderBreakdownItemDelivery;

//    /**
//     * @ORM\ManyToOne(targetEntity="TransmittalItemDeliveryEntity", inversedBy="inventoryPrices")
//     * @ORM\JoinColumn(name="transmittal_item_delivery_id", referencedColumnName="id")
//     */
//    protected $transmittalItemDelivery;

    /**
     * @ORM\ManyToOne(targetEntity="AddInventoryItemEntity", inversedBy="inventoryPrices")
     * @ORM\JoinColumn(name="add_inventory_item_id", referencedColumnName="id")
     */
    protected $addInventoryItem;

    /**
     * @ORM\ManyToOne(targetEntity="ConvertInventoryItemBiEntity", inversedBy="inventoryPrices")
     * @ORM\JoinColumn(name="convert_inventory_item_bi_id", referencedColumnName="id")
     */
    protected $convertInventoryItemBi;

    /**
     * @ORM\ManyToOne(targetEntity="TransferInventoryItemEntity", inversedBy="inventoryPrices")
     * @ORM\JoinColumn(name="transfer_inventory_item_id", referencedColumnName="id")
     */
    protected $transferInventoryItem;

    /**
     * @ORM\ManyToOne(targetEntity="TransferInventoryItemDeliveryEntity", inversedBy="inventoryPrices")
     * @ORM\JoinColumn(name="transfer_inventory_item_id", referencedColumnName="id")
     */
    protected $transferInventoryItemDelivery;
//
//    /**
//     * @ORM\ManyToOne(targetEntity="SalesOrderReturnItemEntity", inversedBy="inventoryPrices")
//     * @ORM\JoinColumn(name="sales_order_return_item_id", referencedColumnName="id")
//     */
//    protected $salesOrderReturnItem;
//
//    /**
//     * @ORM\ManyToOne(targetEntity="JobOrderInventoryEntity", inversedBy="inventoryPrices")
//     * @ORM\JoinColumn(name="job_order_inventory_id", referencedColumnName="id")
//     */
//    protected $jobOrderInventory;

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        $this->createdBy = isSet($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
        $this->createdAt = new \DateTime();
        $this->updatedBy = isSet($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
        $this->updatedAt = new \DateTime();
        $this->quantityAccounted = 0.00;
    }

    /**
     * Set updatedAt
     *
     * @ORM\PreUpdate
     */
    public function setUpdatedAtValue()
    {
        $this->updatedBy = $_COOKIE['username'];
        $this->updatedAt = new \DateTime();
    }

    public function __construct($data=null)
    {
        if(!is_null($data)) {
            $this->id = $data->getId();
            $this->quantity = $data->getQuantity();
            $this->quantityAccounted = $data->getQuantityAccounted();
            $this->price = $data->getPrice();
            $this->source = $data->getSource();
            $this->inventory = $data->getInventory();
//            $this->purchaseOrderBreakdownItemDelivery = $data->getPurchaseOrderBreakdownItemDelivery();
//            $this->transmittalItemDelivery = $data->getTransmittalItemDelivery();
            $this->addInventoryItem = $data->getAddInventoryItem();
//            $this->convertInventoryItemBi = $data->getConvertInventoryItemBi();
//            $this->transferInventoryItem = $data->getTransferInventoryItem();
//            $this->transferInventoryItemDelivery = $data->getTransferInventoryItemDelivery();
//            $this->salesOrderReturnItem = $data->getSalesOrderReturnItem();
//            $this->jobOrderInventory = $data->getJobOrderInventory();
        }
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					User Defined Setters and Getters													  */
    /*--------------------------------------------------------------------------------------------------------*/

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/


    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set quantity
     *
     * @param string $quantity
     *
     * @return InventoryPriceEntity
     */
    public function setQuantity($quantity)
    {
        $this->quantity = str_replace(',', '', $quantity);

        return $this;
    }

    /**
     * Get quantity
     *
     * @return string
     */
    public function getQuantity()
    {
        return $this->quantity;
    }

    /**
     * Set quantityAccounted
     *
     * @param string $quantityAccounted
     *
     * @return InventoryPriceEntity
     */
    public function setQuantityAccounted($quantityAccounted)
    {
        $this->quantityAccounted = $quantityAccounted;

        return $this;
    }

    /**
     * Get quantityAccounted
     *
     * @return string
     */
    public function getQuantityAccounted()
    {
        return $this->quantityAccounted;
    }

    /**
     * Set price
     *
     * @param string $price
     *
     * @return InventoryPriceEntity
     */
    public function setPrice($price)
    {
        $this->price = $price;

        return $this;
    }

    /**
     * Get price
     *
     * @return string
     */
    public function getPrice()
    {
        return $this->price;
    }

    /**
     * Set source
     *
     * @param string $source
     *
     * @return InventoryPriceEntity
     */
    public function setSource($source)
    {
        $this->source = $source;

        return $this;
    }

    /**
     * Get source
     *
     * @return string
     */
    public function getSource()
    {
        return $this->source;
    }

    /**
     * Set createdBy
     *
     * @param string $createdBy
     *
     * @return InventoryPriceEntity
     */
    public function setCreatedBy($createdBy)
    {
        $this->createdBy = $createdBy;

        return $this;
    }

    /**
     * Get createdBy
     *
     * @return string
     */
    public function getCreatedBy()
    {
        return $this->createdBy;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return InventoryPriceEntity
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set updatedBy
     *
     * @param string $updatedBy
     *
     * @return InventoryPriceEntity
     */
    public function setUpdatedBy($updatedBy)
    {
        $this->updatedBy = $updatedBy;

        return $this;
    }

    /**
     * Get updatedBy
     *
     * @return string
     */
    public function getUpdatedBy()
    {
        return $this->updatedBy;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     *
     * @return InventoryPriceEntity
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * Set inventory
     *
     * @param \RxConnexionBundle\Entity\InventoryEntity $inventory
     *
     * @return InventoryPriceEntity
     */
    public function setInventory(\RxConnexionBundle\Entity\InventoryEntity $inventory = null)
    {
        $this->inventory = $inventory;

        return $this;
    }

    /**
     * Get inventory
     *
     * @return \RxConnexionBundle\Entity\InventoryEntity
     */
    public function getInventory()
    {
        return $this->inventory;
    }

    /**
     * Set addInventoryItem
     *
     * @param \RxConnexionBundle\Entity\AddInventoryItemEntity $addInventoryItem
     *
     * @return InventoryPriceEntity
     */
    public function setAddInventoryItem(\RxConnexionBundle\Entity\AddInventoryItemEntity $addInventoryItem = null)
    {
        $this->addInventoryItem = $addInventoryItem;

        return $this;
    }

    /**
     * Get addInventoryItem
     *
     * @return \RxConnexionBundle\Entity\AddInventoryItemEntity
     */
    public function getAddInventoryItem()
    {
        return $this->addInventoryItem;
    }

    /**
     * Set transferInventoryItem
     *
     * @param \RxConnexionBundle\Entity\TransferInventoryItemEntity $transferInventoryItem
     *
     * @return InventoryPriceEntity
     */
    public function setTransferInventoryItem(\RxConnexionBundle\Entity\TransferInventoryItemEntity $transferInventoryItem = null)
    {
        $this->transferInventoryItem = $transferInventoryItem;

        return $this;
    }

    /**
     * Get transferInventoryItem
     *
     * @return \RxConnexionBundle\Entity\TransferInventoryItemEntity
     */
    public function getTransferInventoryItem()
    {
        return $this->transferInventoryItem;
    }

    /**
     * Set purchaseOrderBreakdownItemDelivery
     *
     * @param \RxConnexionBundle\Entity\PurchaseOrderBreakdownItemDeliveryEntity $purchaseOrderBreakdownItemDelivery
     *
     * @return InventoryPriceEntity
     */
    public function setPurchaseOrderBreakdownItemDelivery(\RxConnexionBundle\Entity\PurchaseOrderBreakdownItemDeliveryEntity $purchaseOrderBreakdownItemDelivery = null)
    {
        $this->purchaseOrderBreakdownItemDelivery = $purchaseOrderBreakdownItemDelivery;

        return $this;
    }

    /**
     * Get purchaseOrderBreakdownItemDelivery
     *
     * @return \RxConnexionBundle\Entity\PurchaseOrderBreakdownItemDeliveryEntity
     */
    public function getPurchaseOrderBreakdownItemDelivery()
    {
        return $this->purchaseOrderBreakdownItemDelivery;
    }

    /**
     * Set convertInventoryItemBi
     *
     * @param \RxConnexionBundle\Entity\ConvertInventoryItemBiEntity $convertInventoryItemBi
     *
     * @return InventoryPriceEntity
     */
    public function setConvertInventoryItemBi(\RxConnexionBundle\Entity\ConvertInventoryItemBiEntity $convertInventoryItemBi = null)
    {
        $this->convertInventoryItemBi = $convertInventoryItemBi;

        return $this;
    }

    /**
     * Get convertInventoryItemBi
     *
     * @return \RxConnexionBundle\Entity\ConvertInventoryItemBiEntity
     */
    public function getConvertInventoryItemBi()
    {
        return $this->convertInventoryItemBi;
    }

    /**
     * Set transferInventoryItemDelivery
     *
     * @param \RxConnexionBundle\Entity\TransferInventoryItemDeliveryEntity $transferInventoryItemDelivery
     *
     * @return InventoryPriceEntity
     */
    public function setTransferInventoryItemDelivery(\RxConnexionBundle\Entity\TransferInventoryItemDeliveryEntity $transferInventoryItemDelivery = null)
    {
        $this->transferInventoryItemDelivery = $transferInventoryItemDelivery;

        return $this;
    }

    /**
     * Get transferInventoryItemDelivery
     *
     * @return \RxConnexionBundle\Entity\TransferInventoryItemDeliveryEntity
     */
    public function getTransferInventoryItemDelivery()
    {
        return $this->transferInventoryItemDelivery;
    }
}
