<?php

namespace AppBundle\Entity\Billing;

use AppBundle\Entity\AccessAndFunction\Access;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use AppBundle\Validator\Constraints\Billing as OpentalentAssert;

/**
 * Paramètres de facturation pour un Access
 *
 * @Iri("http://schema.org/AccessBilling")
 * @OpentalentAssert\CustomerId
 */
#[ORM\Entity(repositoryClass: 'AppBundle\Entity\Billing\Repository\AccessBillingRepository')]
class AccessBilling
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['accessbilling', 'access_mass', 'access_details', 'access_details_accessbilling', 'student_registration', 'student_registration_guardians', 'accesses_list', 'student_list', 'guardians_list', 'adherent_list', 'personnels_list', 'payer_list', 'accessbilling_edit', 'sepa_debit_mandate', 'fusion_accesses', 'online_registration_access_details', 'account_balance_reimbursements', 'billpayment_list'])]
    private $id;
    /**
     * @var Access
     */
    #[Assert\Valid]
    #[ORM\OneToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'accessBilling', cascade: ['persist'], fetch: 'EAGER')]
    #[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
    #[Groups(['accessbilling', 'billpayment_list_accessbillingaccountbalancereimbursement'])]
    private $access;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling'])]
    private $customerId;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\PaymentChoiceEnum', 'toArray'])]
    #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'bill_list_access', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'online_registration_access_details_accessbilling', 'build_bills_billlines', 'build_bills_access'])]
    private $paymentChoice;
    /**
     * @var FamilyQuotient
     */
    #[Assert\Valid]
    #[ORM\ManyToOne(targetEntity: 'FamilyQuotient', cascade: ['persist'], inversedBy: 'accessBilling')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_accessbilling', 'access_mass_accessbilling', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'fusion_accesses_accessbilling', 'student_list_accessbilling'])]
    private $familyQuotient;
    /**
     * @var ResidenceArea
     */
    #[Assert\Valid]
    #[ORM\ManyToOne(targetEntity: 'ResidenceArea', cascade: ['persist'], inversedBy: 'accessBilling')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    #[Groups(['accessbilling', 'access_details_accessbilling', 'access_mass_accessbilling', 'student_registration_accessbilling', 'accesses_list_accessbilling', 'student_list_accessbilling', 'guardians_list_accessbilling', 'adherent_list_accessbilling', 'personnels_list_accessbilling', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'fusion_accesses_accessbilling', 'online_registration_access_details_accessbilling'])]
    private $residenceArea;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\PeriodicityPaymentEnum', 'toArray'])]
    #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'sepa_debit_mandate_accessbilling'])]
    private $periodicityPayment;
    /**
     * @var ArrayCollection<Billpayment>
     */
    #[ORM\OneToMany(targetEntity: 'BillPayment', mappedBy: 'accessBilling', cascade: ['persist'], orphanRemoval: true)]
    #[Groups(['accessbilling_billpayment'])]
    private $billDetachedPayments;
    /**
     * @var ArrayCollection<BillDebitBalance>
     */
    #[ORM\OneToMany(targetEntity: 'BillDebitBalance', mappedBy: 'accessBilling', cascade: ['persist'], orphanRemoval: true)]
    #[Groups(['accessbilling_billdebitbalance'])]
    private $billDebitBalances;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', options: ['default' => 'APPLY_ADHESION'])]
    #[Assert\Type(type: 'string')]
    #[Assert\NotNull]
    #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\AdhesionChoiceEnum', 'toArray'])]
    #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'accessbilling_edit_accessbilling'])]
    private $adhesionChoice = "APPLY_ADHESION";
    /**
     * @var float
     */
    #[ORM\Column(type: 'float', nullable: true)]
    #[Assert\Type(type: 'float')]
    #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'accessbilling_edit_accessbilling'])]
    private $adhesionAmount;
    /**
     * @var float
     */
    #[ORM\Column(type: 'float', nullable: true, options: ['default' => '0.0'])]
    #[Assert\Type(type: 'float')]
    #[Groups(['accessbilling', 'payer_list_accessbilling'])]
    private $accountBalance = 0.0;
    /**
     * @var \DateTime
     */
    #[ORM\Column(type: 'date', nullable: true)]
    #[Assert\Date]
    #[Groups(['accessbilling'])]
    private $accountBalanceUpdateDate;
    /**
     * @var float
     */
    #[ORM\Column(type: 'float', nullable: true, options: ['default' => '0.0'])]
    #[Assert\Type(type: 'float')]
    #[Groups(['accessbilling'])]
    private $reportPaymentsAmount = 0.0;
    /**
     * @var ArrayCollection<Billpayment>
     */
    #[ORM\OneToMany(targetEntity: 'BillPayment', mappedBy: 'accessBillingAccountBalanceReimbursement', cascade: ['persist'], orphanRemoval: true)]
    #[Groups(['accessbilling_accountbalancereimbursements', 'account_balance_reimbursements_accessbilling'])]
    private $accountBalanceReimbursements;
    /**
     * The constructor
     */
    public function __construct() {
        $this->billDetachedPayments = new ArrayCollection();
        $this->billDebitBalances = new ArrayCollection();
        $this->accountBalanceReimbursements = new ArrayCollection();
    }
    /**
     * Sets id.
     *
     * @param int $id
     *
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
    /**
     * Gets id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Set customerId
     *
     * @param string $customerId
     *
     * @return AccessBilling
     */
    public function setCustomerId($customerId = null)
    {
        if(empty($customerId))
            $customerId = null;
        $this->customerId = $customerId;

        return $this;
    }
    /**
     * Get customerId
     *
     * @return string
     */
    public function getCustomerId()
    {
        return $this->customerId;
    }
    /**
     * Set paymentChoice
     *
     * @param string $paymentChoice
     *
     * @return AccessBilling
     */
    public function setPaymentChoice($paymentChoice)
    {
        $this->paymentChoice = $paymentChoice;

        return $this;
    }
    /**
     * Get paymentChoice
     *
     * @return string
     */
    public function getPaymentChoice()
    {
        return $this->paymentChoice;
    }
    /**
     * Set familyQuotient
     *
     * @param \AppBundle\Entity\Billing\FamilyQuotient $familyQuotient
     *
     * @return AccessBilling
     */
    public function setFamilyQuotient(\AppBundle\Entity\Billing\FamilyQuotient $familyQuotient = null)
    {
        $this->familyQuotient = $familyQuotient;

        return $this;
    }
    /**
     * Get familyQuotient
     *
     * @return \AppBundle\Entity\Billing\FamilyQuotient
     */
    public function getFamilyQuotient()
    {
        return $this->familyQuotient;
    }
    /**
     * Set residenceArea
     *
     * @param \AppBundle\Entity\Billing\ResidenceArea $residenceArea
     *
     * @return AccessBilling
     */
    public function setResidenceArea(\AppBundle\Entity\Billing\ResidenceArea $residenceArea = null)
    {
        $this->residenceArea = $residenceArea;

        return $this;
    }
    /**
     * Get residenceArea
     *
     * @return \AppBundle\Entity\Billing\ResidenceArea
     */
    public function getResidenceArea()
    {
        return $this->residenceArea;
    }
    /**
     * Set access
     *
     * @param \AppBundle\Entity\AccessAndFunction\Access $access
     *
     * @return AccessBilling
     */
    public function setAccess(\AppBundle\Entity\AccessAndFunction\Access $access = null)
    {
        $this->access = $access;

        return $this;
    }
    /**
     * Get access
     *
     * @return \AppBundle\Entity\AccessAndFunction\Access
     */
    public function getAccess()
    {
        return $this->access;
    }
    /**
     * Set periodicityPayment
     *
     * @param string $periodicityPayment
     *
     * @return AccessBilling
     */
    public function setPeriodicityPayment($periodicityPayment)
    {
        $this->periodicityPayment = $periodicityPayment;

        return $this;
    }
    /**
     * Get periodicityPayment
     *
     * @return string
     */
    public function getPeriodicityPayment()
    {
        return $this->periodicityPayment;
    }
    /**
     * Add billDetachedPayment
     *
     * @param \AppBundle\Entity\Billing\BillPayment $billDetachedPayment
     *
     * @return AccessBilling
     */
    public function addBillDetachedPayment(\AppBundle\Entity\Billing\BillPayment $billDetachedPayment)
    {
        $billDetachedPayment->setAccessBilling($this);
        $this->billDetachedPayments[] = $billDetachedPayment;

        return $this;
    }
    /**
     * Remove billDetachedPayment
     *
     * @param \AppBundle\Entity\Billing\BillPayment $billDetachedPayment
     */
    public function removeBillDetachedPayment(\AppBundle\Entity\Billing\BillPayment $billDetachedPayment)
    {
        $this->billDetachedPayments->removeElement($billDetachedPayment);
    }
    /**
     * Get billDetachedPayments
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getBillDetachedPayments()
    {
        return $this->billDetachedPayments;
    }
    /**
     * Add billDebitBalance
     *
     * @param \AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance
     *
     * @return AccessBilling
     */
    public function addBillDebitBalance(\AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance)
    {
        $billDebitBalance->setAccessBilling($this);
        $this->billDebitBalances[] = $billDebitBalance;

        return $this;
    }
    /**
     * Remove billDebitBalance
     *
     * @param \AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance
     */
    public function removeBillDebitBalance(\AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance)
    {
        $this->billDebitBalances->removeElement($billDebitBalance);
    }
    /**
     * Get billDebitBalances
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getBillDebitBalances()
    {
        return $this->billDebitBalances;
    }
    /**
     * Set adhesionChoice
     *
     * @param string $adhesionChoice
     *
     * @return AccessBilling
     */
    public function setAdhesionChoice($adhesionChoice)
    {
        $this->adhesionChoice = $adhesionChoice;

        return $this;
    }
    /**
     * Get adhesionChoice
     *
     * @return string
     */
    public function getAdhesionChoice()
    {
        return $this->adhesionChoice;
    }
    /**
     * Set adhesionAmount
     *
     * @param float $adhesionAmount
     *
     * @return AccessBilling
     */
    public function setAdhesionAmount($adhesionAmount)
    {
        $this->adhesionAmount = floatval($adhesionAmount);

        return $this;
    }
    /**
     * Get adhesionAmount
     *
     * @return float
     */
    public function getAdhesionAmount()
    {
        return $this->adhesionAmount;
    }
    /**
     * Set accountBalance
     *
     * @param float $accountBalance
     *
     * @return AccessBilling
     */
    public function setAccountBalance($accountBalance)
    {
        $this->accountBalance = $accountBalance;

        return $this;
    }
    /**
     * Get accountBalance
     *
     * @return float
     */
    public function getAccountBalance()
    {
        return $this->accountBalance;
    }
    /**
     * Set accountBalanceUpdateDate
     *
     * @param \DateTime $accountBalanceUpdateDate
     *
     * @return AccessBilling
     */
    public function setAccountBalanceUpdateDate($accountBalanceUpdateDate)
    {
        $this->accountBalanceUpdateDate = $accountBalanceUpdateDate;

        return $this;
    }
    /**
     * Get accountBalanceUpdateDate
     *
     * @return \DateTime
     */
    public function getAccountBalanceUpdateDate()
    {
        return $this->accountBalanceUpdateDate;
    }
    /**
     * Set reportPaymentsAmount
     *
     * @param float $reportPaymentsAmount
     *
     * @return AccessBilling
     */
    public function setReportPaymentsAmount($reportPaymentsAmount)
    {
        $this->reportPaymentsAmount = $reportPaymentsAmount;

        return $this;
    }
    /**
     * Get reportPaymentsAmount
     *
     * @return float
     */
    public function getReportPaymentsAmount()
    {
        return $this->reportPaymentsAmount;
    }
    /**
     * Add accountBalanceReimbursement
     *
     * @param \AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement
     *
     * @return AccessBilling
     */
    public function addAccountBalanceReimbursement(\AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement)
    {
        $accountBalanceReimbursement->setAccessBillingAccountBalanceReimbursement($this);
        $this->accountBalanceReimbursements[] = $accountBalanceReimbursement;

        return $this;
    }
    /**
     * Remove accountBalanceReimbursement
     *
     * @param \AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement
     */
    public function removeAccountBalanceReimbursement(\AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement)
    {
        $this->accountBalanceReimbursements->removeElement($accountBalanceReimbursement);
    }
    /**
     * Get accountBalanceReimbursements
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getAccountBalanceReimbursements()
    {
        return $this->accountBalanceReimbursements;
    }
}
