src/Finance/Domain/Entity/PaymentAllocation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Finance\Domain\Entity;
  3. use App\Finance\Domain\Repository\PaymentAllocationRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Entity(repositoryClass: PaymentAllocationRepository::class)]
  8. #[ORM\Table(name: 'payment_allocations')]
  9. #[ORM\Index(columns: ['cash_payment_id'], name: 'idx_cash_payment_id')]
  10. #[ORM\Index(columns: ['student_fee_id'], name: 'idx_student_fee_id')]
  11. class PaymentAllocation
  12. {
  13. #[ORM\Id]
  14. #[ORM\GeneratedValue]
  15. #[ORM\Column(type: Types::INTEGER)]
  16. private ?int $id = null;
  17. #[ORM\ManyToOne(targetEntity: CashPayment::class)]
  18. #[ORM\JoinColumn(nullable: false)]
  19. private CashPayment $cashPayment;
  20. #[ORM\ManyToOne(targetEntity: StudentFee::class)]
  21. #[ORM\JoinColumn(nullable: false)]
  22. private StudentFee $studentFee;
  23. #[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]
  24. #[Assert\NotNull]
  25. #[Assert\Positive]
  26. private string $allocatedAmount;
  27. #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
  28. private \DateTimeImmutable $createdAt;
  29. public function __construct()
  30. {
  31. $this->createdAt = new \DateTimeImmutable();
  32. }
  33. public function getId(): ?int
  34. {
  35. return $this->id;
  36. }
  37. public function getCashPayment(): CashPayment
  38. {
  39. return $this->cashPayment;
  40. }
  41. public function setCashPayment(CashPayment $cashPayment): self
  42. {
  43. $this->cashPayment = $cashPayment;
  44. return $this;
  45. }
  46. public function getStudentFee(): StudentFee
  47. {
  48. return $this->studentFee;
  49. }
  50. public function setStudentFee(StudentFee $studentFee): self
  51. {
  52. $this->studentFee = $studentFee;
  53. return $this;
  54. }
  55. public function getAllocatedAmount(): string
  56. {
  57. return $this->allocatedAmount;
  58. }
  59. public function setAllocatedAmount(string $allocatedAmount): self
  60. {
  61. $this->allocatedAmount = $allocatedAmount;
  62. return $this;
  63. }
  64. public function getCreatedAt(): \DateTimeImmutable
  65. {
  66. return $this->createdAt;
  67. }
  68. // Optional: helper methods pour récupérer juste les IDs
  69. public function getCashPaymentId(): int
  70. {
  71. return $this->cashPayment->getId();
  72. }
  73. public function getStudentFeeId(): int
  74. {
  75. return $this->studentFee->getId();
  76. }
  77. }