Passed
Push — master ( 72075e...fe7ce5 )
by Esteban De La Fuente
06:11
created

CodigoDocumento   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 57
dl 0
loc 117
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getInterface() 0 3 1
A getNombre() 0 3 1
A getCodigo() 0 3 1
A getNombreCorto() 0 3 1
A getAlias() 0 3 1
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\Document\Enum;
26
27
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\BoletaAfectaInterface;
28
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\BoletaExentaInterface;
29
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\FacturaAfectaInterface;
30
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\FacturaCompraInterface;
31
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\FacturaExentaInterface;
32
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\FacturaExportacionInterface;
33
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\GuiaDespachoInterface;
34
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\LiquidacionFacturaInterface;
35
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\NotaCreditoExportacionInterface;
36
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\NotaCreditoInterface;
37
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\NotaDebitoExportacionInterface;
38
use libredte\lib\Core\Package\Billing\Component\Document\Contract\Document\NotaDebitoInterface;
39
40
/**
41
 * Enum del código de los documentos tributarios electrónicos.
42
 */
43
enum CodigoDocumento: int
44
{
45
    case FACTURA_AFECTA = 33;
46
    case FACTURA_EXENTA = 34;
47
    case BOLETA_AFECTA = 39;
48
    case BOLETA_EXENTA = 41;
49
    case LIQUIDACION_FACTURA = 43;
50
    case FACTURA_COMPRA = 46;
51
    case GUIA_DESPACHO = 52;
52
    case NOTA_DEBITO = 56;
53
    case NOTA_CREDITO = 61;
54
    case FACTURA_EXPORTACION = 110;
55
    case NOTA_DEBITO_EXPORTACION = 111;
56
    case NOTA_CREDITO_EXPORTACION = 112;
57
58
    /**
59
     * Mapa con los códigos de documento y su nombre.
60
     */
61
    private const NOMBRES = [
62
        self::FACTURA_AFECTA->value => 'Factura electrónica',
63
        self::FACTURA_EXENTA->value => 'Factura no afecta o exenta electrónica',
64
        self::BOLETA_AFECTA->value => 'Boleta electrónica',
65
        self::BOLETA_EXENTA->value => 'Boleta no afecta o exenta electrónica',
66
        self::LIQUIDACION_FACTURA->value => 'Liquidación factura electrónica',
67
        self::FACTURA_COMPRA->value => 'Factura de compra electrónica',
68
        self::GUIA_DESPACHO->value => 'Guía de despacho electrónica',
69
        self::NOTA_DEBITO->value => 'Nota de débito electrónica',
70
        self::NOTA_CREDITO->value => 'Nota de crédito electrónica',
71
        self::FACTURA_EXPORTACION->value => 'Factura de exportación electrónica',
72
        self::NOTA_DEBITO_EXPORTACION->value => 'Nota de débito de exportación electrónica',
73
        self::NOTA_CREDITO_EXPORTACION->value => 'Nota de crédito de exportación electrónica',
74
    ];
75
76
    /**
77
     * Mapa con los códigos de documento y su alias.
78
     */
79
    private const ALIASES = [
80
        self::FACTURA_AFECTA->value => 'factura_afecta',
81
        self::FACTURA_EXENTA->value => 'factura_exenta',
82
        self::BOLETA_AFECTA->value => 'boleta_afecta',
83
        self::BOLETA_EXENTA->value => 'boleta_exenta',
84
        self::LIQUIDACION_FACTURA->value => 'liquidacion_factura',
85
        self::FACTURA_COMPRA->value => 'factura_compra',
86
        self::GUIA_DESPACHO->value => 'guia_despacho',
87
        self::NOTA_DEBITO->value => 'nota_debito',
88
        self::NOTA_CREDITO->value => 'nota_credito',
89
        self::FACTURA_EXPORTACION->value => 'factura_exportacion',
90
        self::NOTA_DEBITO_EXPORTACION->value => 'nota_debito_exportacion',
91
        self::NOTA_CREDITO_EXPORTACION->value => 'nota_credito_exportacion',
92
    ];
93
94
    /**
95
     * Mapa con los códigos de documento y su interfaz.
96
     */
97
    private const INTERFACES = [
98
        self::FACTURA_AFECTA->value => FacturaAfectaInterface::class,
99
        self::FACTURA_EXENTA->value => FacturaExentaInterface::class,
100
        self::BOLETA_AFECTA->value => BoletaAfectaInterface::class,
101
        self::BOLETA_EXENTA->value => BoletaExentaInterface::class,
102
        self::LIQUIDACION_FACTURA->value => LiquidacionFacturaInterface::class,
103
        self::FACTURA_COMPRA->value => FacturaCompraInterface::class,
104
        self::GUIA_DESPACHO->value => GuiaDespachoInterface::class,
105
        self::NOTA_DEBITO->value => NotaDebitoInterface::class,
106
        self::NOTA_CREDITO->value => NotaCreditoInterface::class,
107
        self::FACTURA_EXPORTACION->value => FacturaExportacionInterface::class,
108
        self::NOTA_DEBITO_EXPORTACION->value => NotaDebitoExportacionInterface::class,
109
        self::NOTA_CREDITO_EXPORTACION->value => NotaCreditoExportacionInterface::class,
110
    ];
111
112
    /**
113
     * Entrega el código del documento oficial del SII.
114
     *
115
     * @return int
116
     */
117 67
    public function getCodigo(): int
118
    {
119 67
        return $this->value;
120
    }
121
122
    /**
123
     * Entrega el nombre del tipo de documento.
124
     *
125
     * @return string
126
     */
127 74
    public function getNombre(): string
128
    {
129 74
        return self::NOMBRES[$this->value];
0 ignored issues
show
Bug introduced by
The constant libredte\lib\Core\Packag...odigoDocumento::NOMBRES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
130
    }
131
132
    /**
133
     * Entrega el nombre corto del tipo de documento.
134
     *
135
     * @return string
136
     */
137 74
    public function getNombreCorto(): string
138
    {
139 74
        return str_replace(' electrónica', '', self::NOMBRES[$this->value]);
0 ignored issues
show
Bug introduced by
The constant libredte\lib\Core\Packag...odigoDocumento::NOMBRES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
140
    }
141
142
    /**
143
     * Entrega el alias del documento.
144
     *
145
     * @return string
146
     */
147 74
    public function getAlias(): string
148
    {
149 74
        return self::ALIASES[$this->value];
0 ignored issues
show
Bug introduced by
The constant libredte\lib\Core\Packag...odigoDocumento::ALIASES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
150
    }
151
152
    /**
153
     * Entrega la interfaz PHP asociada al tipo de documento.
154
     *
155
     * @return string
156
     */
157 74
    public function getInterface(): string
158
    {
159 74
        return self::INTERFACES[$this->value];
0 ignored issues
show
Bug introduced by
The constant libredte\lib\Core\Packag...goDocumento::INTERFACES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
160
    }
161
}
162