|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (C) 2020 Jan Böhmer |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU Affero General Public License as published |
|
7
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
|
8
|
|
|
* (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU Affero General Public License for more details. |
|
14
|
|
|
* |
|
15
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace App\Entity\Embeddable; |
|
20
|
|
|
|
|
21
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
22
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* This embeddable contains all information about the person which should receive a payment of a payment order. |
|
26
|
|
|
* |
|
27
|
|
|
* @ORM\Embeddable() |
|
28
|
|
|
*/ |
|
29
|
|
|
class PayeeInfo |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @Assert\NotBlank() |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
* @ORM\Column(type="string") |
|
36
|
|
|
*/ |
|
37
|
|
|
private $account_owner = ''; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
* @Assert\NotBlank() |
|
42
|
|
|
* @ORM\Column(type="string") |
|
43
|
|
|
*/ |
|
44
|
|
|
private $street = ''; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var string |
|
48
|
|
|
* @Assert\NotBlank() |
|
49
|
|
|
* @ORM\Column(type="string") |
|
50
|
|
|
*/ |
|
51
|
|
|
private $zip_code = ''; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var string |
|
55
|
|
|
* @Assert\NotBlank() |
|
56
|
|
|
* @ORM\Column(type="string") |
|
57
|
|
|
*/ |
|
58
|
|
|
private $city = ''; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var string |
|
62
|
|
|
* @ORM\Column(type="string") |
|
63
|
|
|
* @Assert\Iban() |
|
64
|
|
|
*/ |
|
65
|
|
|
private $iban = ''; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @var string |
|
69
|
|
|
* @ORM\Column(type="string") |
|
70
|
|
|
* @Assert\Bic(ibanPropertyPath="iban") |
|
71
|
|
|
*/ |
|
72
|
|
|
private $bic = ''; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var string |
|
76
|
|
|
* @Assert\NotBlank() |
|
77
|
|
|
* @ORM\Column(type="string") |
|
78
|
|
|
*/ |
|
79
|
|
|
private $bank_name = ''; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @var string |
|
83
|
|
|
* @ORM\Column(type="string") |
|
84
|
|
|
* @Assert\Length(max="140") |
|
85
|
|
|
*/ |
|
86
|
|
|
private $reference = ''; |
|
87
|
|
|
|
|
88
|
|
|
public function __construct() |
|
89
|
|
|
{ |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Returns the name of the account owner / payment receiver. |
|
94
|
|
|
* |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getAccountOwner(): ?string |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->account_owner; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Sets the name of account owner / payment receiver. |
|
104
|
|
|
*/ |
|
105
|
|
|
public function setAccountOwner(string $account_owner): PayeeInfo |
|
106
|
|
|
{ |
|
107
|
|
|
$this->account_owner = $account_owner; |
|
108
|
|
|
|
|
109
|
|
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Returns the street and house no. where the payment receiver lives. |
|
114
|
|
|
* |
|
115
|
|
|
* @return string |
|
116
|
|
|
*/ |
|
117
|
|
|
public function getStreet(): ?string |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->street; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Sets the street and house no. where the payment receiver lives. |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setStreet(string $street): PayeeInfo |
|
126
|
|
|
{ |
|
127
|
|
|
$this->street = $street; |
|
128
|
|
|
|
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Returns the zip code where the payment receiver lives. |
|
134
|
|
|
* |
|
135
|
|
|
* @return string |
|
136
|
|
|
*/ |
|
137
|
|
|
public function getZipCode(): ?string |
|
138
|
|
|
{ |
|
139
|
|
|
return $this->zip_code; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Sets the zip code where the payment receiver lives. |
|
144
|
|
|
*/ |
|
145
|
|
|
public function setZipCode(string $zip_code): PayeeInfo |
|
146
|
|
|
{ |
|
147
|
|
|
$this->zip_code = $zip_code; |
|
148
|
|
|
|
|
149
|
|
|
return $this; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Returns the city name where the payment receiver lives. |
|
154
|
|
|
* |
|
155
|
|
|
* @return string |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getCity(): ?string |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->city; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Sets the city name where the payment receiver lives. |
|
164
|
|
|
*/ |
|
165
|
|
|
public function setCity(string $city): PayeeInfo |
|
166
|
|
|
{ |
|
167
|
|
|
$this->city = $city; |
|
168
|
|
|
|
|
169
|
|
|
return $this; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Returns the IBAN of the receivers bank account. |
|
174
|
|
|
* The IBAN is formatted with spaces after it was validated by IBAN constraint, so the returned value containes |
|
175
|
|
|
* spaces. |
|
176
|
|
|
* |
|
177
|
|
|
* @return string |
|
178
|
|
|
*/ |
|
179
|
|
|
public function getIban(): ?string |
|
180
|
|
|
{ |
|
181
|
|
|
return $this->iban; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Returns the IBAN of the receivers bank account without spaces. |
|
186
|
|
|
* This is useful for SEPA exporter and other places where a IBAN in a machine-readable form is needed. |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getIbanWithoutSpaces(): string |
|
189
|
|
|
{ |
|
190
|
|
|
return str_replace(' ', '', $this->getIban()); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Sets the IBAN of the receivers bank account. |
|
195
|
|
|
* The IBAN will be formatted with spaces after it was validated by IBAN constraint. |
|
196
|
|
|
*/ |
|
197
|
|
|
public function setIban(string $iban): PayeeInfo |
|
198
|
|
|
{ |
|
199
|
|
|
$this->iban = $iban; |
|
200
|
|
|
|
|
201
|
|
|
return $this; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* Returns the BIC of the receivers bank account. |
|
206
|
|
|
* Can be left empty for national payments (IBAN-only transaction). |
|
207
|
|
|
* |
|
208
|
|
|
* @return string |
|
209
|
|
|
*/ |
|
210
|
|
|
public function getBic(): ?string |
|
211
|
|
|
{ |
|
212
|
|
|
return $this->bic; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* Sets the BIC of the receivers bank account. |
|
217
|
|
|
* Can be left empty for national payments (IBAN-only transaction). |
|
218
|
|
|
*/ |
|
219
|
|
|
public function setBic(string $bic): PayeeInfo |
|
220
|
|
|
{ |
|
221
|
|
|
$this->bic = $bic; |
|
222
|
|
|
|
|
223
|
|
|
return $this; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* Returns the name of the receivers bank. |
|
228
|
|
|
* |
|
229
|
|
|
* @return string |
|
230
|
|
|
*/ |
|
231
|
|
|
public function getBankName(): ?string |
|
232
|
|
|
{ |
|
233
|
|
|
return $this->bank_name; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* Sets the name of the receivers bank. |
|
238
|
|
|
*/ |
|
239
|
|
|
public function setBankName(string $bank_name): PayeeInfo |
|
240
|
|
|
{ |
|
241
|
|
|
$this->bank_name = $bank_name; |
|
242
|
|
|
|
|
243
|
|
|
return $this; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* Returns the transaction reference that is used for the payment. |
|
248
|
|
|
* |
|
249
|
|
|
* @return string |
|
250
|
|
|
*/ |
|
251
|
|
|
public function getReference(): ?string |
|
252
|
|
|
{ |
|
253
|
|
|
return $this->reference; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* Sets the transaction reference that is used for the payment. |
|
258
|
|
|
* |
|
259
|
|
|
* @param string $reference |
|
260
|
|
|
*/ |
|
261
|
|
|
public function setReference(?string $reference): PayeeInfo |
|
262
|
|
|
{ |
|
263
|
|
|
$this->reference = $reference; |
|
264
|
|
|
|
|
265
|
|
|
return $this; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* Returns the whole address of the payment receiver as a single line (in the format "Street 1, 12345 City". |
|
270
|
|
|
*/ |
|
271
|
|
|
public function getAddress(): string |
|
272
|
|
|
{ |
|
273
|
|
|
return $this->getStreet().', '.$this->getZipCode().' '.$this->getCity(); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* Returns the whole address of the payment receiver in multiple lines (in the format "Street 1, 12345 City". |
|
278
|
|
|
*/ |
|
279
|
|
|
public function getAddressMultiline(): string |
|
280
|
|
|
{ |
|
281
|
|
|
return $this->getStreet()."\n".$this->getZipCode().' '.$this->getCity(); |
|
282
|
|
|
} |
|
283
|
|
|
} |
|
284
|
|
|
|