|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace PhpCfdi\CfdiToPdf; |
|
6
|
|
|
|
|
7
|
|
|
use CfdiUtils\Nodes\NodeInterface; |
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
|
|
10
|
|
|
class CfdiData |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var NodeInterface */ |
|
13
|
|
|
private $comprobante; |
|
14
|
|
|
|
|
15
|
|
|
/** @var NodeInterface */ |
|
16
|
|
|
private $emisor; |
|
17
|
|
|
|
|
18
|
|
|
/** @var NodeInterface */ |
|
19
|
|
|
private $receptor; |
|
20
|
|
|
|
|
21
|
|
|
/** @var NodeInterface */ |
|
22
|
|
|
private $timbreFiscalDigital; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
private $qrUrl; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string */ |
|
28
|
|
|
private $tfdSourceString; |
|
29
|
|
|
|
|
30
|
5 |
|
public function __construct(NodeInterface $comprobante, string $qrUrl, string $tfdSourceString) |
|
31
|
|
|
{ |
|
32
|
5 |
|
$emisor = $comprobante->searchNode('cfdi:Emisor'); |
|
33
|
5 |
|
if (null === $emisor) { |
|
34
|
1 |
|
throw new RuntimeException('El CFDI no contiene nodo emisor'); |
|
35
|
|
|
} |
|
36
|
4 |
|
$receptor = $comprobante->searchNode('cfdi:Receptor'); |
|
37
|
4 |
|
if (null === $receptor) { |
|
38
|
1 |
|
throw new RuntimeException('El CFDI no contiene nodo receptor'); |
|
39
|
|
|
} |
|
40
|
3 |
|
$timbreFiscalDigital = $comprobante->searchNode('cfdi:Complemento', 'tfd:TimbreFiscalDigital'); |
|
41
|
3 |
|
if (null === $timbreFiscalDigital) { |
|
42
|
1 |
|
throw new RuntimeException('El CFDI no contiene complemento de timbre fiscal digital'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
2 |
|
$this->comprobante = $comprobante; |
|
46
|
2 |
|
$this->emisor = $emisor; |
|
47
|
2 |
|
$this->receptor = $receptor; |
|
48
|
2 |
|
$this->timbreFiscalDigital = $timbreFiscalDigital; |
|
49
|
2 |
|
$this->qrUrl = $qrUrl; |
|
50
|
2 |
|
$this->tfdSourceString = $tfdSourceString; |
|
51
|
2 |
|
} |
|
52
|
|
|
|
|
53
|
2 |
|
public function comprobante(): NodeInterface |
|
54
|
|
|
{ |
|
55
|
2 |
|
return $this->comprobante; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
2 |
|
public function emisor(): NodeInterface |
|
59
|
|
|
{ |
|
60
|
2 |
|
return $this->emisor; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
2 |
|
public function receptor(): NodeInterface |
|
64
|
|
|
{ |
|
65
|
2 |
|
return $this->receptor; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
2 |
|
public function timbreFiscalDigital(): NodeInterface |
|
69
|
|
|
{ |
|
70
|
2 |
|
return $this->timbreFiscalDigital; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
2 |
|
public function qrUrl(): string |
|
74
|
|
|
{ |
|
75
|
2 |
|
return $this->qrUrl; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
2 |
|
public function tfdSourceString(): string |
|
79
|
|
|
{ |
|
80
|
2 |
|
return $this->tfdSourceString; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|