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 string |
88
|
|
|
* |
89
|
|
|
* @ORM\Column(type="string", length=18, options={"default" = ""}) |
90
|
|
|
*/ |
91
|
|
|
private $datatransRef = ''; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var bool |
95
|
|
|
* |
96
|
|
|
* @ORM\Column(type="boolean", options={"default" = 0}) |
97
|
|
|
*/ |
98
|
|
|
private $isReconcilied = false; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @API\Exclude |
102
|
|
|
* |
103
|
|
|
* @param Transaction $transaction |
104
|
|
|
*/ |
105
|
2 |
|
public function setTransaction(Transaction $transaction): void |
106
|
|
|
{ |
107
|
2 |
|
if ($this->transaction && $transaction !== $this->transaction) { |
108
|
|
|
$this->transaction->transactionLineRemoved($this); |
109
|
|
|
} |
110
|
|
|
|
111
|
2 |
|
$this->transaction = $transaction; |
112
|
2 |
|
$transaction->transactionLineAdded($this); |
113
|
2 |
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return Transaction |
117
|
|
|
*/ |
118
|
|
|
public function getTransaction(): Transaction |
119
|
|
|
{ |
120
|
|
|
return $this->transaction; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Get Datatrans payment reference number |
125
|
|
|
* |
126
|
|
|
* @param null|string $datatransRef |
127
|
|
|
*/ |
128
|
2 |
|
public function setDatatransRef(?string $datatransRef): void |
129
|
|
|
{ |
130
|
2 |
|
$this->datatransRefNo = $datatransRef; |
|
|
|
|
131
|
2 |
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Set Datatrans payment reference number |
135
|
|
|
* |
136
|
|
|
* @return null|string |
137
|
|
|
*/ |
138
|
|
|
public function getDatatransRef(): ?string |
139
|
|
|
{ |
140
|
|
|
return $this->datatransRef; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Set debit account |
145
|
|
|
* |
146
|
|
|
* @param null|Account $account |
147
|
|
|
*/ |
148
|
2 |
|
public function setDebit(?Account $account): void |
149
|
|
|
{ |
150
|
2 |
|
$this->debit = $account; |
151
|
2 |
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Get debit account |
155
|
|
|
* |
156
|
|
|
* @return null|Account |
157
|
|
|
*/ |
158
|
3 |
|
public function getDebit(): ?Account |
159
|
|
|
{ |
160
|
3 |
|
return $this->debit; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Set credit account |
165
|
|
|
* |
166
|
|
|
* @param null|Account $account |
167
|
|
|
*/ |
168
|
2 |
|
public function setCredit(?Account $account): void |
169
|
|
|
{ |
170
|
2 |
|
$this->credit = $account; |
171
|
2 |
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Get credit account |
175
|
|
|
* |
176
|
|
|
* @return null|Account |
177
|
|
|
*/ |
178
|
2 |
|
public function getCredit(): ?Account |
179
|
|
|
{ |
180
|
2 |
|
return $this->credit; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Get related equipment or service |
185
|
|
|
* |
186
|
|
|
* @return null|Bookable |
187
|
|
|
*/ |
188
|
|
|
public function getBookable(): ?Bookable |
189
|
|
|
{ |
190
|
|
|
return $this->bookable; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Set related equipment or service |
195
|
|
|
* |
196
|
|
|
* @param null|Bookable $bookable |
197
|
|
|
*/ |
198
|
|
|
public function setBookable(?Bookable $bookable): void |
199
|
|
|
{ |
200
|
|
|
$this->bookable = $bookable; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Set balance |
205
|
|
|
* |
206
|
|
|
* @param string $balance |
207
|
|
|
*/ |
208
|
3 |
|
public function setBalance(string $balance): void |
209
|
|
|
{ |
210
|
3 |
|
$this->balance = $balance; |
211
|
3 |
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
1 |
|
public function getBalance(): string |
217
|
|
|
{ |
218
|
1 |
|
return $this->balance; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Set date of transaction |
223
|
|
|
* |
224
|
|
|
* @param Date $transactionDate |
225
|
|
|
*/ |
226
|
3 |
|
public function setTransactionDate(Date $transactionDate): void |
227
|
|
|
{ |
228
|
3 |
|
$this->transactionDate = $transactionDate; |
229
|
3 |
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Get date of transaction |
233
|
|
|
* |
234
|
|
|
* @return Date |
235
|
|
|
*/ |
236
|
|
|
public function getTransactionDate(): Date |
237
|
|
|
{ |
238
|
|
|
return $this->transactionDate; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Set transaction tag |
243
|
|
|
* |
244
|
|
|
* @param null|TransactionTag $transactionTag |
245
|
|
|
*/ |
246
|
|
|
public function setTransactionTag(?TransactionTag $transactionTag): void |
247
|
|
|
{ |
248
|
|
|
$this->transactionTag = $transactionTag; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Get transaction tag |
253
|
|
|
* |
254
|
|
|
* @return null|TransactionTag |
255
|
|
|
*/ |
256
|
|
|
public function getTransactionTag(): ?TransactionTag |
257
|
|
|
{ |
258
|
|
|
return $this->transactionTag; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Whether this line of transaction was reconcilied (e.g. from a bank statement) |
263
|
|
|
* |
264
|
|
|
* @return bool |
265
|
|
|
*/ |
266
|
|
|
public function isReconcilied(): bool |
267
|
|
|
{ |
268
|
|
|
return $this->isReconcilied; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Whether this line of transaction was reconcilied (e.g. from a bank statement) |
273
|
|
|
* |
274
|
|
|
* @param bool $isReconcilied |
275
|
|
|
*/ |
276
|
2 |
|
public function setIsReconcilied(bool $isReconcilied): void |
277
|
|
|
{ |
278
|
2 |
|
$this->isReconcilied = $isReconcilied; |
279
|
2 |
|
} |
280
|
|
|
} |
281
|
|
|
|