|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Application\Model; |
|
6
|
|
|
|
|
7
|
|
|
use Application\Traits\HasName; |
|
8
|
|
|
use Application\Traits\HasRemarks; |
|
9
|
|
|
use Cake\Chronos\Date; |
|
10
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
11
|
|
|
use GraphQL\Doctrine\Annotation as API; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* A single line of accounting transaction |
|
15
|
|
|
* |
|
16
|
|
|
* @ORM\Entity(repositoryClass="Application\Repository\TransactionLineRepository") |
|
17
|
|
|
*/ |
|
18
|
|
|
class TransactionLine extends AbstractModel |
|
19
|
|
|
{ |
|
20
|
|
|
use HasName; |
|
21
|
|
|
use HasRemarks; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var Transaction |
|
25
|
|
|
* |
|
26
|
|
|
* @ORM\ManyToOne(targetEntity="Transaction", inversedBy="transactionLines") |
|
27
|
|
|
* @ORM\JoinColumns({ |
|
28
|
|
|
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE") |
|
29
|
|
|
* }) |
|
30
|
|
|
*/ |
|
31
|
|
|
private $transaction; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var null|Account |
|
35
|
|
|
* |
|
36
|
|
|
* @ORM\ManyToOne(targetEntity="Account") |
|
37
|
|
|
* @ORM\JoinColumns({ |
|
38
|
|
|
* @ORM\JoinColumn(nullable=true, onDelete="RESTRICT") |
|
39
|
|
|
* }) |
|
40
|
|
|
*/ |
|
41
|
|
|
private $debit; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var null|Account |
|
45
|
|
|
* |
|
46
|
|
|
* @ORM\ManyToOne(targetEntity="Account") |
|
47
|
|
|
* @ORM\JoinColumns({ |
|
48
|
|
|
* @ORM\JoinColumn(nullable=true, onDelete="RESTRICT") |
|
49
|
|
|
* }) |
|
50
|
|
|
*/ |
|
51
|
|
|
private $credit; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var null|Bookable |
|
55
|
|
|
* |
|
56
|
|
|
* @ORM\ManyToOne(targetEntity="Bookable") |
|
57
|
|
|
* @ORM\JoinColumns({ |
|
58
|
|
|
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL") |
|
59
|
|
|
* }) |
|
60
|
|
|
*/ |
|
61
|
|
|
private $bookable; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var string |
|
65
|
|
|
* |
|
66
|
|
|
* @ORM\Column(type="decimal", precision=7, scale=2) |
|
67
|
|
|
*/ |
|
68
|
|
|
private $balance; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @var Date |
|
72
|
|
|
* @ORM\Column(name="transactionDate", type="date") |
|
73
|
|
|
*/ |
|
74
|
|
|
private $transactionDate; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @var null|TransactionTag |
|
78
|
|
|
* |
|
79
|
|
|
* @ORM\ManyToOne(targetEntity="TransactionTag") |
|
80
|
|
|
* @ORM\JoinColumns({ |
|
81
|
|
|
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL") |
|
82
|
|
|
* }) |
|
83
|
|
|
*/ |
|
84
|
|
|
private $transactionTag; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @var bool |
|
88
|
|
|
* |
|
89
|
|
|
* @ORM\Column(type="boolean", options={"default" = 0}) |
|
90
|
|
|
*/ |
|
91
|
|
|
private $isReconciled = false; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @API\Exclude |
|
95
|
|
|
* |
|
96
|
|
|
* @param Transaction $transaction |
|
97
|
|
|
*/ |
|
98
|
8 |
|
public function setTransaction(Transaction $transaction): void |
|
99
|
|
|
{ |
|
100
|
8 |
|
if ($this->transaction) { |
|
101
|
|
|
$this->transaction->transactionLineRemoved($this); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
8 |
|
$this->transaction = $transaction; |
|
105
|
8 |
|
$transaction->transactionLineAdded($this); |
|
106
|
8 |
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @return Transaction |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getTransaction(): Transaction |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->transaction; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Set debit account |
|
118
|
|
|
* |
|
119
|
|
|
* @param null|Account $account |
|
120
|
|
|
*/ |
|
121
|
7 |
|
public function setDebit(?Account $account): void |
|
122
|
|
|
{ |
|
123
|
7 |
|
$this->debit = $account; |
|
124
|
7 |
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Get debit account |
|
128
|
|
|
* |
|
129
|
|
|
* @return null|Account |
|
130
|
|
|
*/ |
|
131
|
7 |
|
public function getDebit(): ?Account |
|
132
|
|
|
{ |
|
133
|
7 |
|
return $this->debit; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Set credit account |
|
138
|
|
|
* |
|
139
|
|
|
* @param null|Account $account |
|
140
|
|
|
*/ |
|
141
|
8 |
|
public function setCredit(?Account $account): void |
|
142
|
|
|
{ |
|
143
|
8 |
|
$this->credit = $account; |
|
144
|
8 |
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Get credit account |
|
148
|
|
|
* |
|
149
|
|
|
* @return null|Account |
|
150
|
|
|
*/ |
|
151
|
6 |
|
public function getCredit(): ?Account |
|
152
|
|
|
{ |
|
153
|
6 |
|
return $this->credit; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Get related equipment or service |
|
158
|
|
|
* |
|
159
|
|
|
* @return null|Bookable |
|
160
|
|
|
*/ |
|
161
|
|
|
public function getBookable(): ?Bookable |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->bookable; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Set related equipment or service |
|
168
|
|
|
* |
|
169
|
|
|
* @param null|Bookable $bookable |
|
170
|
|
|
*/ |
|
171
|
2 |
|
public function setBookable(?Bookable $bookable): void |
|
172
|
|
|
{ |
|
173
|
2 |
|
$this->bookable = $bookable; |
|
174
|
2 |
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Set balance |
|
178
|
|
|
* |
|
179
|
|
|
* @param string $balance |
|
180
|
|
|
*/ |
|
181
|
9 |
|
public function setBalance(string $balance): void |
|
182
|
|
|
{ |
|
183
|
9 |
|
$this->balance = $balance; |
|
184
|
9 |
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @return string |
|
188
|
|
|
*/ |
|
189
|
4 |
|
public function getBalance(): string |
|
190
|
|
|
{ |
|
191
|
4 |
|
return $this->balance; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* Set date of transaction |
|
196
|
|
|
* |
|
197
|
|
|
* @param Date $transactionDate |
|
198
|
|
|
*/ |
|
199
|
9 |
|
public function setTransactionDate(Date $transactionDate): void |
|
200
|
|
|
{ |
|
201
|
9 |
|
$this->transactionDate = $transactionDate; |
|
202
|
9 |
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* Get date of transaction |
|
206
|
|
|
* |
|
207
|
|
|
* @return Date |
|
208
|
|
|
*/ |
|
209
|
|
|
public function getTransactionDate(): Date |
|
210
|
|
|
{ |
|
211
|
|
|
return $this->transactionDate; |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
/** |
|
215
|
|
|
* Set transaction tag |
|
216
|
|
|
* |
|
217
|
|
|
* @param null|TransactionTag $transactionTag |
|
218
|
|
|
*/ |
|
219
|
|
|
public function setTransactionTag(?TransactionTag $transactionTag): void |
|
220
|
|
|
{ |
|
221
|
|
|
$this->transactionTag = $transactionTag; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Get transaction tag |
|
226
|
|
|
* |
|
227
|
|
|
* @return null|TransactionTag |
|
228
|
|
|
*/ |
|
229
|
|
|
public function getTransactionTag(): ?TransactionTag |
|
230
|
|
|
{ |
|
231
|
|
|
return $this->transactionTag; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* Whether this line of transaction was reconciled (e.g. from a bank statement) |
|
236
|
|
|
* |
|
237
|
|
|
* @return bool |
|
238
|
|
|
*/ |
|
239
|
|
|
public function isReconciled(): bool |
|
240
|
|
|
{ |
|
241
|
|
|
return $this->isReconciled; |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* Whether this line of transaction was reconciled (e.g. from a bank statement) |
|
246
|
|
|
* |
|
247
|
|
|
* @param bool $isReconciled |
|
248
|
|
|
*/ |
|
249
|
3 |
|
public function setIsReconciled(bool $isReconciled): void |
|
250
|
|
|
{ |
|
251
|
3 |
|
$this->isReconciled = $isReconciled; |
|
252
|
3 |
|
} |
|
253
|
|
|
} |
|
254
|
|
|
|