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\Chronos; |
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="RESTRICT") |
29
|
|
|
* }) |
30
|
|
|
*/ |
31
|
|
|
private $transaction; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var null|Account |
35
|
|
|
* |
36
|
|
|
* @ORM\ManyToOne(targetEntity="Account", inversedBy="debitTransactionLines") |
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", inversedBy="creditTransactionLines") |
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=10, scale=2, options={"unsigned" = true}) |
67
|
|
|
*/ |
68
|
|
|
private $balance; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var Chronos |
72
|
|
|
* @ORM\Column(type="datetime") |
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
|
|
|
* This store the value of CAMT 054 `<AcctSvcrRef>` element that should |
95
|
|
|
* hopefully be a universally unique transaction identifier. |
96
|
|
|
* |
97
|
|
|
* An absence of value means the line was not imported. |
98
|
|
|
* |
99
|
|
|
* @var null|string |
100
|
|
|
* @ORM\Column(type="string", length=35, nullable=true, unique=true) |
101
|
|
|
*/ |
102
|
|
|
private $importedId; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Set importedId |
106
|
|
|
* |
107
|
|
|
* @API\Exclude |
108
|
|
|
* |
109
|
|
|
* @param string $importedId |
110
|
|
|
*/ |
111
|
3 |
|
public function setImportedId(string $importedId): void |
112
|
|
|
{ |
113
|
3 |
|
$this->importedId = $importedId; |
114
|
3 |
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get importedId |
118
|
|
|
* |
119
|
|
|
* @return null|string |
120
|
|
|
*/ |
121
|
2 |
|
public function getImportedId(): string |
122
|
|
|
{ |
123
|
2 |
|
return $this->importedId; |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @API\Exclude |
128
|
|
|
* |
129
|
|
|
* @param Transaction $transaction |
130
|
|
|
*/ |
131
|
16 |
|
public function setTransaction(Transaction $transaction): void |
132
|
|
|
{ |
133
|
16 |
|
if ($this->transaction) { |
134
|
1 |
|
$this->transaction->transactionLineRemoved($this); |
135
|
|
|
} |
136
|
|
|
|
137
|
16 |
|
$this->transaction = $transaction; |
138
|
16 |
|
$transaction->transactionLineAdded($this); |
139
|
16 |
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return Transaction |
143
|
|
|
*/ |
144
|
4 |
|
public function getTransaction(): Transaction |
145
|
|
|
{ |
146
|
4 |
|
return $this->transaction; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Set debit account |
151
|
|
|
* |
152
|
|
|
* @param null|Account $account |
153
|
|
|
*/ |
154
|
16 |
|
public function setDebit(?Account $account): void |
155
|
|
|
{ |
156
|
16 |
|
if ($this->debit) { |
157
|
1 |
|
$this->debit->debitTransactionLineRemoved($this); |
158
|
|
|
} |
159
|
|
|
|
160
|
16 |
|
$this->debit = $account; |
161
|
|
|
|
162
|
16 |
|
if ($this->debit) { |
163
|
14 |
|
$this->debit->debitTransactionLineAdded($this); |
164
|
|
|
} |
165
|
16 |
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Get debit account |
169
|
|
|
* |
170
|
|
|
* @return null|Account |
171
|
|
|
*/ |
172
|
14 |
|
public function getDebit(): ?Account |
173
|
|
|
{ |
174
|
14 |
|
return $this->debit; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Set credit account |
179
|
|
|
* |
180
|
|
|
* @param null|Account $account |
181
|
|
|
*/ |
182
|
16 |
|
public function setCredit(?Account $account): void |
183
|
|
|
{ |
184
|
16 |
|
if ($this->credit) { |
185
|
1 |
|
$this->credit->creditTransactionLineRemoved($this); |
186
|
|
|
} |
187
|
|
|
|
188
|
16 |
|
$this->credit = $account; |
189
|
|
|
|
190
|
16 |
|
if ($this->credit) { |
191
|
16 |
|
$this->credit->creditTransactionLineAdded($this); |
192
|
|
|
} |
193
|
16 |
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Get credit account |
197
|
|
|
* |
198
|
|
|
* @return null|Account |
199
|
|
|
*/ |
200
|
14 |
|
public function getCredit(): ?Account |
201
|
|
|
{ |
202
|
14 |
|
return $this->credit; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Get related equipment or service |
207
|
|
|
* |
208
|
|
|
* @return null|Bookable |
209
|
|
|
*/ |
210
|
4 |
|
public function getBookable(): ?Bookable |
211
|
|
|
{ |
212
|
4 |
|
return $this->bookable; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Set related equipment or service |
217
|
|
|
* |
218
|
|
|
* @param null|Bookable $bookable |
219
|
|
|
*/ |
220
|
6 |
|
public function setBookable(?Bookable $bookable): void |
221
|
|
|
{ |
222
|
6 |
|
$this->bookable = $bookable; |
223
|
6 |
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Set balance |
227
|
|
|
* |
228
|
|
|
* @param string $balance |
229
|
|
|
*/ |
230
|
16 |
|
public function setBalance(string $balance): void |
231
|
|
|
{ |
232
|
16 |
|
$this->balance = $balance; |
233
|
16 |
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return string |
237
|
|
|
*/ |
238
|
12 |
|
public function getBalance(): string |
239
|
|
|
{ |
240
|
12 |
|
return $this->balance; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Set date of transaction |
245
|
|
|
* |
246
|
|
|
* @param Chronos $transactionDate |
247
|
|
|
*/ |
248
|
17 |
|
public function setTransactionDate(Chronos $transactionDate): void |
249
|
|
|
{ |
250
|
17 |
|
$this->transactionDate = $transactionDate; |
251
|
17 |
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Get date of transaction |
255
|
|
|
* |
256
|
|
|
* @return Chronos |
257
|
|
|
*/ |
258
|
2 |
|
public function getTransactionDate(): Chronos |
259
|
|
|
{ |
260
|
2 |
|
return $this->transactionDate; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Set transaction tag |
265
|
|
|
* |
266
|
|
|
* @param null|TransactionTag $transactionTag |
267
|
|
|
*/ |
268
|
|
|
public function setTransactionTag(?TransactionTag $transactionTag): void |
269
|
|
|
{ |
270
|
|
|
$this->transactionTag = $transactionTag; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* Get transaction tag |
275
|
|
|
* |
276
|
|
|
* @return null|TransactionTag |
277
|
|
|
*/ |
278
|
|
|
public function getTransactionTag(): ?TransactionTag |
279
|
|
|
{ |
280
|
|
|
return $this->transactionTag; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Whether this line of transaction was reconciled (e.g. from a bank statement) |
285
|
|
|
* |
286
|
|
|
* @return bool |
287
|
|
|
*/ |
288
|
|
|
public function isReconciled(): bool |
289
|
|
|
{ |
290
|
|
|
return $this->isReconciled; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* Whether this line of transaction was reconciled (e.g. from a bank statement) |
295
|
|
|
* |
296
|
|
|
* @param bool $isReconciled |
297
|
|
|
*/ |
298
|
3 |
|
public function setIsReconciled(bool $isReconciled): void |
299
|
|
|
{ |
300
|
3 |
|
$this->isReconciled = $isReconciled; |
301
|
3 |
|
} |
302
|
|
|
} |
303
|
|
|
|