<?php
declare(strict_types=1);

namespace App\Entity\Billing;

use App\Entity\Core\Tagg;
//use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
 * Classe ... qui ...
 */
//#[Auditable]
#[ORM\Entity]
class BillPayment
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billPayments')]
    #[ORM\JoinColumn(nullable: true)]
    private BillAccounting $bill;

    #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billDetachedPayments')]
    #[ORM\JoinColumn(nullable: true)]
    private AccessBilling $accessBilling;

    #[ORM\OneToMany(mappedBy: 'billPayment',targetEntity: BillDebitBalance::class,  cascade: ['persist'], orphanRemoval: true)]
    #[ORM\JoinColumn(nullable: true)]
    private Collection $billDebitBalances;

    #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'accountBalanceReimbursements')]
    #[ORM\JoinColumn(nullable: true)]
    private AccessBilling $accessBillingAccountBalanceReimbursement;

    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'payments', cascade: ['persist'])]
    #[ORM\JoinTable(name: 'tag_billPayment')]
    #[ORM\JoinColumn(name: 'billPayment_id', referencedColumnName: 'id')]
    #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
    private Collection $tags;

    public function __construct()
    {
        $this->billDebitBalances = new ArrayCollection();
        $this->tags = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getBill(): ?BillAccounting
    {
        return $this->bill;
    }

    public function setBill(?BillAccounting $bill): self
    {
        $this->bill = $bill;

        return $this;
    }

    public function getAccessBilling(): ?AccessBilling
    {
        return $this->accessBilling;
    }

    public function setAccessBilling(?AccessBilling $accessBilling): self
    {
        $this->accessBilling = $accessBilling;

        return $this;
    }

    /**
     * @return Collection<int, BillDebitBalance>
     */
    public function getBillDebitBalances(): Collection
    {
        return $this->billDebitBalances;
    }

    public function addBillDebitBalance(BillDebitBalance $billDebitBalance): self
    {
        if (!$this->billDebitBalances->contains($billDebitBalance)) {
            $this->billDebitBalances[] = $billDebitBalance;
            $billDebitBalance->setBillPayment($this);
        }

        return $this;
    }

    public function removeBillDebitBalance(BillDebitBalance $billDebitBalance): self
    {
        if ($this->billDebitBalances->removeElement($billDebitBalance)) {
            // set the owning side to null (unless already changed)
            if ($billDebitBalance->getBillPayment() === $this) {
                $billDebitBalance->setBillPayment(null);
            }
        }

        return $this;
    }

    public function getAccessBillingAccountBalanceReimbursement(): ?AccessBilling
    {
        return $this->accessBillingAccountBalanceReimbursement;
    }

    public function setAccessBillingAccountBalanceReimbursement(?AccessBilling $accessBillingAccountBalanceReimbursement): self
    {
        $this->accessBillingAccountBalanceReimbursement = $accessBillingAccountBalanceReimbursement;

        return $this;
    }

    /**
     * @return Collection<int, Tagg>
     */
    public function getTags(): Collection
    {
        return $this->tags;
    }

    public function addTag(Tagg $tag): self
    {
        if (!$this->tags->contains($tag)) {
            $this->tags[] = $tag;
        }

        return $this;
    }

    public function removeTag(Tagg $tag): self
    {
        $this->tags->removeElement($tag);

        return $this;
    }
}