|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* LibreDTE: Biblioteca PHP (Núcleo). |
|
7
|
|
|
* Copyright (C) LibreDTE <https://www.libredte.cl> |
|
8
|
|
|
* |
|
9
|
|
|
* Este programa es software libre: usted puede redistribuirlo y/o modificarlo |
|
10
|
|
|
* bajo los términos de la Licencia Pública General Affero de GNU publicada por |
|
11
|
|
|
* la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, o |
|
12
|
|
|
* (a su elección) cualquier versión posterior de la misma. |
|
13
|
|
|
* |
|
14
|
|
|
* Este programa se distribuye con la esperanza de que sea útil, pero SIN |
|
15
|
|
|
* GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD |
|
16
|
|
|
* PARA UN PROPÓSITO DETERMINADO. Consulte los detalles de la Licencia Pública |
|
17
|
|
|
* General Affero de GNU para obtener una información más detallada. |
|
18
|
|
|
* |
|
19
|
|
|
* Debería haber recibido una copia de la Licencia Pública General Affero de |
|
20
|
|
|
* GNU junto a este programa. |
|
21
|
|
|
* |
|
22
|
|
|
* En caso contrario, consulte <http://www.gnu.org/licenses/agpl.html>. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace libredte\lib\Core\Package\Billing\Component\TradingParties\Entity; |
|
26
|
|
|
|
|
27
|
|
|
use Derafu\Lib\Core\Helper\Rut; |
|
28
|
|
|
use libredte\lib\Core\Package\Billing\Component\TradingParties\Contract\ContribuyenteInterface; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Clase para representar un contribuyente del SII de Chile. |
|
32
|
|
|
* |
|
33
|
|
|
* Proporciona información básica del contribuyente, como su RUT, razón social, |
|
34
|
|
|
* giro, entre otros. |
|
35
|
|
|
*/ |
|
36
|
|
|
class Contribuyente implements ContribuyenteInterface |
|
37
|
|
|
{ |
|
38
|
|
|
/** |
|
39
|
|
|
* RUT del contribuyente. |
|
40
|
|
|
* |
|
41
|
|
|
* @var int |
|
42
|
|
|
*/ |
|
43
|
|
|
protected int $rut; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Dígito verificador (DV) del RUT. |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected string $dv; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Razón social del contribuyente. |
|
54
|
|
|
* |
|
55
|
|
|
* @var string|null |
|
56
|
|
|
*/ |
|
57
|
|
|
protected ?string $razon_social; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Giro comercial del contribuyente. |
|
61
|
|
|
* |
|
62
|
|
|
* @var string|null |
|
63
|
|
|
*/ |
|
64
|
|
|
protected ?string $giro; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Código de actividad económica del contribuyente. |
|
68
|
|
|
* |
|
69
|
|
|
* @var int|null |
|
70
|
|
|
*/ |
|
71
|
|
|
protected ?int $actividad_economica; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Teléfono del contribuyente. |
|
75
|
|
|
* |
|
76
|
|
|
* @var string|null |
|
77
|
|
|
*/ |
|
78
|
|
|
protected ?string $telefono; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Dirección de correo electrónico del contribuyente. |
|
82
|
|
|
* |
|
83
|
|
|
* @var string|null |
|
84
|
|
|
*/ |
|
85
|
|
|
protected ?string $email; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Dirección física del contribuyente. |
|
89
|
|
|
* |
|
90
|
|
|
* @var string|null |
|
91
|
|
|
*/ |
|
92
|
|
|
protected ?string $direccion; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Comuna de residencia del contribuyente. |
|
96
|
|
|
* |
|
97
|
|
|
* @var string|null |
|
98
|
|
|
*/ |
|
99
|
|
|
protected ?string $comuna; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Constructor de la clase Contribuyente. |
|
103
|
|
|
* |
|
104
|
|
|
* @param string|int $rut RUT del contribuyente. |
|
105
|
|
|
* @param string|null $razon_social Razón social del contribuyente. |
|
106
|
|
|
* @param string|null $giro Giro comercial del contribuyente. |
|
107
|
|
|
* @param int|null $actividad_economica Código de actividad económica. |
|
108
|
|
|
* @param string|null $telefono Teléfono del contribuyente. |
|
109
|
|
|
* @param string|null $email Correo electrónico del contribuyente. |
|
110
|
|
|
* @param string|null $direccion Dirección física del contribuyente. |
|
111
|
|
|
* @param string|null $comuna Comuna de residencia. |
|
112
|
|
|
*/ |
|
113
|
59 |
|
public function __construct( |
|
114
|
|
|
string|int $rut, |
|
115
|
|
|
?string $razon_social = null, |
|
116
|
|
|
?string $giro = null, |
|
117
|
|
|
?int $actividad_economica = null, |
|
118
|
|
|
?string $telefono = null, |
|
119
|
|
|
?string $email = null, |
|
120
|
|
|
?string $direccion = null, |
|
121
|
|
|
?string $comuna = null, |
|
122
|
|
|
) { |
|
123
|
59 |
|
$rut = Rut::format($rut); |
|
124
|
59 |
|
[$this->rut, $this->dv] = Rut::toArray($rut); |
|
125
|
|
|
|
|
126
|
59 |
|
$this->razon_social = $razon_social ?: null; |
|
127
|
59 |
|
$this->giro = $giro ?: null; |
|
128
|
59 |
|
$this->actividad_economica = $actividad_economica ?: null; |
|
129
|
59 |
|
$this->telefono = $telefono ?: null; |
|
130
|
59 |
|
$this->email = $email ?: null; |
|
131
|
59 |
|
$this->direccion = $direccion ?: null; |
|
132
|
59 |
|
$this->comuna = $comuna ?: null; |
|
133
|
|
|
|
|
134
|
|
|
// Validar el RUT asignado (independiente del origen). |
|
135
|
59 |
|
Rut::validate($this->getRut()); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* {@inheritDoc} |
|
140
|
|
|
*/ |
|
141
|
1 |
|
public function getRutAsInt(): int |
|
142
|
|
|
{ |
|
143
|
1 |
|
return $this->rut; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* {@inheritDoc} |
|
148
|
|
|
*/ |
|
149
|
63 |
|
public function getRut(): string |
|
150
|
|
|
{ |
|
151
|
63 |
|
return $this->rut . '-' . $this->dv; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* {@inheritDoc} |
|
156
|
|
|
*/ |
|
157
|
63 |
|
public function getRazonSocial(): string |
|
158
|
|
|
{ |
|
159
|
63 |
|
return $this->razon_social ?? $this->getRut(); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* {@inheritDoc} |
|
164
|
|
|
*/ |
|
165
|
2 |
|
public function getGiro(): ?string |
|
166
|
|
|
{ |
|
167
|
2 |
|
return $this->giro; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* {@inheritDoc} |
|
172
|
|
|
*/ |
|
173
|
2 |
|
public function getActividadEconomica(): ?int |
|
174
|
|
|
{ |
|
175
|
2 |
|
return $this->actividad_economica; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* {@inheritDoc} |
|
180
|
|
|
*/ |
|
181
|
2 |
|
public function getTelefono(): ?string |
|
182
|
|
|
{ |
|
183
|
2 |
|
return $this->telefono; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* {@inheritDoc} |
|
188
|
|
|
*/ |
|
189
|
2 |
|
public function getEmail(): ?string |
|
190
|
|
|
{ |
|
191
|
2 |
|
return $this->email; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* {@inheritDoc} |
|
196
|
|
|
*/ |
|
197
|
2 |
|
public function getDireccion(): ?string |
|
198
|
|
|
{ |
|
199
|
2 |
|
return $this->direccion; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* {@inheritDoc} |
|
204
|
|
|
*/ |
|
205
|
2 |
|
public function getComuna(): ?string |
|
206
|
|
|
{ |
|
207
|
2 |
|
return $this->comuna; |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
|