<?php

namespace RxConnexionBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\MaxDepth;
use RxConnexionBundle\Entity\Base\BaseEntity;

/**
 * PatientBillingInventoryEntity
 *
 * @ORM\Table(name="patient_billing_inventory")
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\PatientBillingInventoryEntityRepository")
 */
class PatientBillingInventoryEntity extends BaseEntity
{

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\PatientBillingEntity", inversedBy="patientBillingInventories")
     * @ORM\JoinColumn(name="patient_billing_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $patientBilling;

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\ItemEntity", inversedBy="patientBillingInventories")
     * @ORM\JoinColumn(name="item_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $item;

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\InventoryEntity", inversedBy="patientBillingInventories")
     * @ORM\JoinColumn(name="inventory_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $inventory;

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\InventorySerialNoEntity", inversedBy="patientBillingInventories")
     * @ORM\JoinColumn(name="inventory_serial_no_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $inventorySerialNo;

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\PatientBillingInventoryEntity", inversedBy="patientBillingInventories")
     * @ORM\JoinColumn(name="patient_billing_inventory_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $patientBillingInventory;

    /**
     * @ORM\Column(name="serial_no", type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $serialNo;

    /**
     * @ORM\Column(name="quantity", type="integer", nullable=true)
     * @Groups("forAudit")
     */
    protected $quantity;

	/**
	 * @ORM\Column(name="sold_value", type="decimal", precision=12, scale=2, nullable=true)
	 * @Groups("forAudit")
	 */
	protected $soldValue;

    /**
     * @ORM\OneToMany(targetEntity="InventoryMovementEntity", mappedBy="patientBillingInventory", cascade={"remove"})
     */
    protected $inventoryMovements;


    /**
     * @ORM\OneToMany(targetEntity="RxConnexionBundle\Entity\InventorySerialNoEntity", mappedBy="patientBillingInventory")
    */
    protected $inventorySerialNos;


    /**
     * @ORM\OneToMany(targetEntity="RxConnexionBundle\Entity\PatientBillingInventoryEntity", mappedBy="patientBillingInventory")
    */
    protected $patientBillingInventories;


    /**
     * Get serialNoToArray
     */
    public function getSerialNoToArray()
    {
        return json_decode($this->getSerialNo());
    }




    /**
     * Set serialNo
     *
     * @param string $serialNo
     *
     * @return PatientBillingInventoryEntity
     */
    public function setSerialNo($serialNo)
    {
        $this->serialNo = $serialNo;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set patientBilling
     *
     * @param \RxConnexionBundle\Entity\PatientBillingEntity $patientBilling
     *
     * @return PatientBillingInventoryEntity
     */
    public function setPatientBilling(\RxConnexionBundle\Entity\PatientBillingEntity $patientBilling = null)
    {
        $this->patientBilling = $patientBilling;

        return $this;
    }

    /**
     * Get patientBilling
     *
     * @return \RxConnexionBundle\Entity\PatientBillingEntity
     */
    public function getPatientBilling()
    {
        return $this->patientBilling;
    }

    /**
     * Set inventory
     *
     * @param \RxConnexionBundle\Entity\InventoryEntity $inventory
     *
     * @return PatientBillingInventoryEntity
     */
    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 inventorySerialNo
     *
     * @param \RxConnexionBundle\Entity\InventorySerialNoEntity $inventorySerialNo
     *
     * @return PatientBillingInventoryEntity
     */
    public function setInventorySerialNo(\RxConnexionBundle\Entity\InventorySerialNoEntity $inventorySerialNo = null)
    {
        $this->inventorySerialNo = $inventorySerialNo;

        return $this;
    }

    /**
     * Get inventorySerialNo
     *
     * @return \RxConnexionBundle\Entity\InventorySerialNoEntity
     */
    public function getInventorySerialNo()
    {
        return $this->inventorySerialNo;
    }

    /**
     * Set item
     *
     * @param \RxConnexionBundle\Entity\ItemEntity $item
     *
     * @return PatientBillingInventoryEntity
     */
    public function setItem(\RxConnexionBundle\Entity\ItemEntity $item = null)
    {
        $this->item = $item;

        return $this;
    }

    /**
     * Get item
     *
     * @return \RxConnexionBundle\Entity\ItemEntity
     */
    public function getItem()
    {
        return $this->item;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->inventoryMovements = new \Doctrine\Common\Collections\ArrayCollection();
        $this->inventorySerialNos = new \Doctrine\Common\Collections\ArrayCollection();
        $this->patientBillingInventories = new \Doctrine\Common\Collections\ArrayCollection();

    }

    /**
     * Add inventoryMovement
     *
     * @param \RxConnexionBundle\Entity\InventoryMovementEntity $inventoryMovement
     *
     * @return PatientBillingInventoryEntity
     */
    public function addInventoryMovement(\RxConnexionBundle\Entity\InventoryMovementEntity $inventoryMovement)
    {
        $this->inventoryMovements[] = $inventoryMovement;

        return $this;
    }

    /**
     * Remove inventoryMovement
     *
     * @param \RxConnexionBundle\Entity\InventoryMovementEntity $inventoryMovement
     */
    public function removeInventoryMovement(\RxConnexionBundle\Entity\InventoryMovementEntity $inventoryMovement)
    {
        $this->inventoryMovements->removeElement($inventoryMovement);
    }

    /**
     * Get inventoryMovements
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getInventoryMovements()
    {
        return $this->inventoryMovements;
    }

    /**
     * Add inventorySerialNo
     *
     * @param \RxConnexionBundle\Entity\InventorySerialNoEntity $inventorySerialNo
     *
     * @return PatientBillingInventoryEntity
     */
    public function addInventorySerialNo(\RxConnexionBundle\Entity\InventorySerialNoEntity $inventorySerialNo)
    {
        $this->inventorySerialNos[] = $inventorySerialNo;

        return $this;
    }

    /**
     * Remove inventorySerialNo
     *
     * @param \RxConnexionBundle\Entity\InventorySerialNoEntity $inventorySerialNo
     */
    public function removeInventorySerialNo(\RxConnexionBundle\Entity\InventorySerialNoEntity $inventorySerialNo)
    {
        $this->inventorySerialNos->removeElement($inventorySerialNo);
    }

    /**
     * Get inventorySerialNos
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getInventorySerialNos()
    {
        return $this->inventorySerialNos;
    }

    /**
     * Set soldValue
     *
     * @param string $soldValue
     *
     * @return PatientBillingInventoryEntity
     */
    public function setSoldValue($soldValue)
    {
        $this->soldValue = $soldValue;

        return $this;
    }

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

    /**
     * Set patientBillingInventory
     *
     * @param \RxConnexionBundle\Entity\PatientBillingInventoryEntity $patientBillingInventory
     *
     * @return PatientBillingInventoryEntity
     */
    public function setPatientBillingInventory(\RxConnexionBundle\Entity\PatientBillingInventoryEntity $patientBillingInventory = null)
    {
        $this->patientBillingInventory = $patientBillingInventory;

        return $this;
    }

    /**
     * Get patientBillingInventory
     *
     * @return \RxConnexionBundle\Entity\PatientBillingInventoryEntity
     */
    public function getPatientBillingInventory()
    {
        return $this->patientBillingInventory;
    }

    /**
     * Add patientBillingInventory
     *
     * @param \RxConnexionBundle\Entity\PatientBillingInventoryEntity $patientBillingInventory
     *
     * @return PatientBillingInventoryEntity
     */
    public function addPatientBillingInventory(\RxConnexionBundle\Entity\PatientBillingInventoryEntity $patientBillingInventory)
    {
        $this->patientBillingInventories[] = $patientBillingInventory;

        return $this;
    }

    /**
     * Remove patientBillingInventory
     *
     * @param \RxConnexionBundle\Entity\PatientBillingInventoryEntity $patientBillingInventory
     */
    public function removePatientBillingInventory(\RxConnexionBundle\Entity\PatientBillingInventoryEntity $patientBillingInventory)
    {
        $this->patientBillingInventories->removeElement($patientBillingInventory);
    }

    /**
     * Get patientBillingInventories
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getPatientBillingInventories()
    {
        return $this->patientBillingInventories;
    }
}
