<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use RxConnexionBundle\Entity\Base\BaseEntity;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\MaxDepth;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\PatientBillingFinancingPaymentDetailRepository")
 * @ORM\Table(name="patient_billing_financing_payment_detail")
 */

class PatientBillingFinancingPaymentDetailEntity extends BaseEntity
{
    const PAYMENT_PLAN_TYPE_RENT_TO_OWN = 'Rent to Own';
    const PAYMENT_PLAN_TYPE_LONG_TERM_RENTAL = 'Long Term Rental';
    const PAYMENT_PLAN_TYPE_WARRANTY = 'Warranty';

    /**
     * @ORM\OneToOne(targetEntity="PatientBillingEntity", inversedBy="patientBillingFinancingPaymentDetail")
     * @ORM\JoinColumn(name="patient_billing_id", referencedColumnName="id")
     * @Groups("forAudit")
     */
    protected $patientBilling;

    /**
     * @ORM\Column(name="payment_plan_type", type="string", length=20, nullable=true)
     */
    protected $paymentPlanType;

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

    /**
     * @ORM\Column(name="payment_day", type="integer")
     */
    protected $paymentDay;

    /**
     * @ORM\Column(name="start_date", type="datetime")
     * @Groups("forAudit")
     */
    protected $startDate;

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

    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;



    public function __construct()
    {
    }

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 0;
    }

    /**
     * Set updatedAt
     *
     * @ORM\PreUpdate
     */
    public function setUpdatedAtValue()
    {
        parent::setUpdatedAtValue();
    }



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

    /**
     * Get startDateAsString
     *
     * @return string
     */
    public function getStartDateAsString() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->startDate) ? date('m/d/Y', strtotime($dttst->transform($this->startDate))) : '';
    }

    /**
     * Get endDateAsString
     *
     * @return string
     */
    public function getEndDateAsString() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->endDate) ? date('m/d/Y', strtotime($dttst->transform($this->endDate))) : '';
    }
    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/




    /**
     * Set amount
     *
     * @param string $amount
     *
     * @return PatientBillingFinancingPaymentDetailEntity
     */
    public function setAmount($amount)
    {
        $this->amount = $amount;

        return $this;
    }

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

    /**
     * Set paymentDay
     *
     * @param integer $paymentDay
     *
     * @return PatientBillingFinancingPaymentDetailEntity
     */
    public function setPaymentDay($paymentDay)
    {
        $this->paymentDay = $paymentDay;

        return $this;
    }

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

    /**
     * Set startDate
     *
     * @param \DateTime $startDate
     *
     * @return PatientBillingFinancingPaymentDetailEntity
     */
    public function setStartDate($startDate)
    {
        $this->startDate = empty($startDate) ? null : new \DateTime($startDate);

        return $this;
    }

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

    /**
     * Set endDate
     *
     * @param \DateTime $endDate
     *
     * @return PatientBillingFinancingPaymentDetailEntity
     */
    public function setEndDate($endDate)
    {
        $this->endDate = empty($endDate) ? null : new \DateTime($endDate);

        return $this;
    }

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

    /**
     * Set isDeleted
     *
     * @param boolean $isDeleted
     *
     * @return PatientBillingFinancingPaymentDetailEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

    /**
     * Get isDeleted
     *
     * @return boolean
     */
    public function getIsDeleted()
    {
        return $this->isDeleted;
    }

    /**
     * Set patientBilling
     *
     * @param \RxConnexionBundle\Entity\PatientBillingEntity $patientBilling
     *
     * @return PatientBillingFinancingPaymentDetailEntity
     */
    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 paymentPlanType
     *
     * @param string $paymentPlanType
     *
     * @return PatientBillingFinancingPaymentDetailEntity
     */
    public function setPaymentPlanType($paymentPlanType)
    {
        $this->paymentPlanType = $paymentPlanType;

        return $this;
    }

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