From f3f01fe83ce1c7ce4fe1ca3e06b40397a4eec6e4 Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Thu, 11 Apr 2024 12:39:38 +0200 Subject: [PATCH] Relate AccountingStatements to AccountingTransactions --- src/Entity/AccountingStatement.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Entity/AccountingStatement.php b/src/Entity/AccountingStatement.php index 4263cc7..4c3e121 100644 --- a/src/Entity/AccountingStatement.php +++ b/src/Entity/AccountingStatement.php @@ -4,14 +4,13 @@ namespace App\Entity; use ApiPlatform\Metadata as API; use App\Repository\AccountingStatementRepository; -use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** * An AccountingStatement represents a change in the balance of an Accounting.\ * \ - * When money is received, an statement holds it as available. - * When money is issued, an statement draws available money from previous statements.\ + * When money is received, an Statement holds it as available. + * When money is issued, an Statement draws available money from previous statements.\ * \ * The sum of available money in the statements is the available money at that Accounting. */ @@ -25,19 +24,26 @@ class AccountingStatement private ?int $id = null; /** - * The money held in this statement. + * The money held in this Statement. */ #[ORM\Embedded(class: Money::class)] private ?Money $money = null; /** - * The direction of this statement.\ + * The direction of this Statement.\ * `incoming` means the transaction was received and the money is available.\ * `outgoing` means the transaction was issued and the money is an expenditure. */ #[ORM\Column()] private ?AccountingStatementDirection $direction = null; + /** + * The Transaction represented in this Statement. + */ + #[ORM\OneToOne(cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(nullable: false)] + private ?AccountingTransaction $transaction = null; + public function getId(): ?int { return $this->id; @@ -66,4 +72,16 @@ class AccountingStatement return $this; } + + public function getTransaction(): ?AccountingTransaction + { + return $this->transaction; + } + + public function setTransaction(AccountingTransaction $transaction): static + { + $this->transaction = $transaction; + + return $this; + } }