1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* Copyright (C) 2020-2025 Iain Cambridge |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by |
10
|
|
|
* the Free Software Foundation, either version 2.1 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Lesser General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License |
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Parthenon\Billing\Entity; |
23
|
|
|
|
24
|
|
|
use Brick\Money\Money; |
25
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
26
|
|
|
use Doctrine\Common\Collections\Collection; |
27
|
|
|
use Parthenon\Common\Address; |
28
|
|
|
|
29
|
|
|
class Receipt implements ReceiptInterface |
30
|
|
|
{ |
31
|
|
|
private $id; |
32
|
|
|
|
33
|
|
|
private ?string $invoiceNumber = null; |
34
|
|
|
|
35
|
|
|
private bool $valid; |
36
|
|
|
|
37
|
|
|
private Address $billerAddress; |
38
|
|
|
|
39
|
|
|
private Address $payeeAddress; |
40
|
|
|
|
41
|
|
|
private CustomerInterface $customer; |
42
|
|
|
|
43
|
|
|
private array|Collection $payments; |
44
|
|
|
|
45
|
|
|
private array|Collection $subscriptions; |
46
|
|
|
|
47
|
|
|
private array|Collection $lines; |
48
|
|
|
|
49
|
|
|
private ?string $comment; |
50
|
|
|
|
51
|
|
|
private string $currency; |
52
|
|
|
|
53
|
|
|
private int $total; |
54
|
|
|
|
55
|
|
|
private int $subTotal; |
56
|
|
|
|
57
|
|
|
private int $vatTotal; |
58
|
|
|
|
59
|
|
|
private ?float $vatPercentage = null; |
60
|
|
|
|
61
|
|
|
private \DateTimeInterface $createdAt; |
62
|
|
|
|
63
|
|
|
public function __construct() |
64
|
|
|
{ |
65
|
|
|
$this->payments = new ArrayCollection([]); |
66
|
|
|
$this->subscriptions = new ArrayCollection([]); |
67
|
|
|
$this->lines = new ArrayCollection([]); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getId() |
71
|
|
|
{ |
72
|
|
|
return $this->id; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setId($id): void |
76
|
|
|
{ |
77
|
|
|
$this->id = $id; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getInvoiceNumber(): ?string |
81
|
|
|
{ |
82
|
|
|
return $this->invoiceNumber; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function setInvoiceNumber(?string $invoiceNumber): void |
86
|
|
|
{ |
87
|
|
|
$this->invoiceNumber = $invoiceNumber; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function isValid(): bool |
91
|
|
|
{ |
92
|
|
|
return $this->valid; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function setValid(bool $valid): void |
96
|
|
|
{ |
97
|
|
|
$this->valid = $valid; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getBillerAddress(): Address |
101
|
|
|
{ |
102
|
|
|
return $this->billerAddress; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function setBillerAddress(Address $billerAddress): void |
106
|
|
|
{ |
107
|
|
|
$this->billerAddress = $billerAddress; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getPayeeAddress(): Address |
111
|
|
|
{ |
112
|
|
|
return $this->payeeAddress; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function setPayeeAddress(Address $payeeAddress): void |
116
|
|
|
{ |
117
|
|
|
$this->payeeAddress = $payeeAddress; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getCustomer(): CustomerInterface |
121
|
|
|
{ |
122
|
|
|
return $this->customer; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function setCustomer(CustomerInterface $customer): void |
126
|
|
|
{ |
127
|
|
|
$this->customer = $customer; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function addPayment(Payment $payment): void |
131
|
|
|
{ |
132
|
|
|
$this->payments->add($payment); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return Collection|Payment[] |
137
|
|
|
*/ |
138
|
|
|
public function getPayments(): Collection|array |
139
|
|
|
{ |
140
|
|
|
return $this->payments; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function setPayments(Collection|array $payments): void |
144
|
|
|
{ |
145
|
|
|
$this->payments = $payments; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function getComment(): ?string |
149
|
|
|
{ |
150
|
|
|
return $this->comment; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function setComment(?string $comment): void |
154
|
|
|
{ |
155
|
|
|
$this->comment = $comment; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function getCurrency(): string |
159
|
|
|
{ |
160
|
|
|
return $this->currency; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function setCurrency(string $currency): void |
164
|
|
|
{ |
165
|
|
|
$this->currency = $currency; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getTotal(): int |
169
|
|
|
{ |
170
|
|
|
return $this->total; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function setTotal(int $total): void |
174
|
|
|
{ |
175
|
|
|
$this->total = $total; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function getSubTotal(): int |
179
|
|
|
{ |
180
|
|
|
return $this->subTotal; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
public function setSubTotal(int $subTotal): void |
184
|
|
|
{ |
185
|
|
|
$this->subTotal = $subTotal; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function getVatTotal(): int |
189
|
|
|
{ |
190
|
|
|
return $this->vatTotal; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function setVatTotal(int $vatTotal): void |
194
|
|
|
{ |
195
|
|
|
$this->vatTotal = $vatTotal; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
public function getCreatedAt(): \DateTimeInterface |
199
|
|
|
{ |
200
|
|
|
return $this->createdAt; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
public function setCreatedAt(\DateTimeInterface $createdAt): void |
204
|
|
|
{ |
205
|
|
|
$this->createdAt = $createdAt; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @return Collection|ReceiptLine[] |
210
|
|
|
*/ |
211
|
|
|
public function getLines(): Collection|array |
212
|
|
|
{ |
213
|
|
|
return $this->lines; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
public function setLines(Collection|array $lines): void |
217
|
|
|
{ |
218
|
|
|
$this->lines = $lines; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @return Subscription[]|Collection |
223
|
|
|
*/ |
224
|
|
|
public function getSubscriptions(): Collection|array |
225
|
|
|
{ |
226
|
|
|
return $this->subscriptions; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
public function setSubscriptions(Collection|array $subscriptions): void |
230
|
|
|
{ |
231
|
|
|
$this->subscriptions = $subscriptions; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
public function getTotalMoney(): Money |
235
|
|
|
{ |
236
|
|
|
return Money::ofMinor($this->total, strtoupper($this->currency)); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
public function getVatTotalMoney(): Money |
240
|
|
|
{ |
241
|
|
|
return Money::ofMinor($this->vatTotal, strtoupper($this->currency)); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
public function getSubTotalMoney(): Money |
245
|
|
|
{ |
246
|
|
|
return Money::ofMinor($this->subTotal, strtoupper($this->currency)); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
public function getVatPercentage(): ?float |
250
|
|
|
{ |
251
|
|
|
return $this->vatPercentage; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
public function setVatPercentage(?float $vatPercentage): void |
255
|
|
|
{ |
256
|
|
|
$this->vatPercentage = $vatPercentage; |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
|