|
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\Exchange\Worker\Sender\Strategy\Sii; |
|
26
|
|
|
|
|
27
|
|
|
use Derafu\Lib\Core\Foundation\Abstract\AbstractStrategy; |
|
28
|
|
|
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\EnvelopeInterface; |
|
29
|
|
|
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\ExchangeBagInterface; |
|
30
|
|
|
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\ExchangeResultInterface; |
|
31
|
|
|
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\SenderStrategyInterface; |
|
32
|
|
|
use libredte\lib\Core\Package\Billing\Component\Exchange\Exception\ExchangeException; |
|
33
|
|
|
use libredte\lib\Core\Package\Billing\Component\Exchange\Support\ExchangeResult; |
|
34
|
|
|
use libredte\lib\Core\Package\Billing\Component\Exchange\Support\ExchangeStatus; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Envío de documentos tributarios (excepto boletas) al SII. |
|
38
|
|
|
*/ |
|
39
|
|
|
class DteSenderStrategy extends AbstractStrategy implements SenderStrategyInterface |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritDoc} |
|
43
|
|
|
*/ |
|
44
|
|
|
public function send(ExchangeBagInterface $bag): array |
|
45
|
|
|
{ |
|
46
|
|
|
// Procesar cada sobre por separado. |
|
47
|
|
|
foreach ($bag->getEnvelopes() as $envelope) { |
|
48
|
|
|
$result = $this->sendEnvelope($envelope); |
|
49
|
|
|
$bag->addResult($result); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
// Entregar los resultados de la recepción de documentos. |
|
53
|
|
|
return $bag->getResults(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Envía los documentos de un sobre al SII en el XML EnvioDTE. |
|
58
|
|
|
* |
|
59
|
|
|
* @param EnvelopeInterface $envelope Sobre con documentos a enviar. |
|
60
|
|
|
* @return ExchangeResultInterface Resultado del envío del sobre. |
|
61
|
|
|
*/ |
|
62
|
|
|
private function sendEnvelope( |
|
63
|
|
|
EnvelopeInterface $envelope |
|
|
|
|
|
|
64
|
|
|
): ExchangeResultInterface { |
|
65
|
|
|
// TODO: Implementar el envío de los DTE al SII. |
|
66
|
|
|
throw new ExchangeException( |
|
67
|
|
|
'Estrategia de envío sii.dte no está implementada.' |
|
68
|
|
|
); |
|
69
|
|
|
|
|
70
|
|
|
// // Crear resultado del envío del sobre al SII. |
|
71
|
|
|
// $result = new ExchangeResult($envelope); |
|
72
|
|
|
// $result->addStatus(new ExchangeStatus( |
|
73
|
|
|
// 'sii.dte', |
|
74
|
|
|
// //$message->getError() |
|
75
|
|
|
// )); |
|
76
|
|
|
|
|
77
|
|
|
// // Entregar resultado del envío. |
|
78
|
|
|
// return $result; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritDoc} |
|
83
|
|
|
*/ |
|
84
|
|
|
public function canSend(ExchangeBagInterface|EnvelopeInterface $what): void |
|
85
|
|
|
{ |
|
86
|
|
|
// Todo OK. Las validaciones que se requieren se hicieron en el handler |
|
87
|
|
|
// SiiSenderHandler. |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.