Passed
Push — master ( d29869...e61a0d )
by Joe Nilson
03:35
created

CommonFunctionsDominicanRepublic   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 45
dl 0
loc 97
rs 10
c 1
b 0
f 0
wmc 14

8 Methods

Rating   Name   Duplication   Size   Complexity  
A ncfTipoCliente() 0 8 2
A ncfTipoPago() 0 9 2
A ncfCorrelativo() 0 14 2
A ncfFechaVencimiento() 0 2 1
A ncfTipoComprobante() 0 9 2
A ncfRango() 0 2 1
A ncfTipoMovimiento() 0 9 2
A ncfTipoAnulacion() 0 9 2
1
<?php
2
/*
3
 * Copyright (C) 2022 Joe Nilson <[email protected]>
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as
7
 * published by the Free Software Foundation, either version 3 of the
8
 * License, or (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 Lesser General Public License for more details.
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Lib;
19
20
use FacturaScripts\Dinamic\Model\NCFTipo;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFTipo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use FacturaScripts\Plugins\fsRepublicaDominicana\Interfaces\CommonFunctionsInterface;
22
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\DataBase\DataBaseWhere was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use FacturaScripts\Dinamic\Model\NCFRango;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFRango was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoAnulacion;
25
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoMovimiento;
26
27
class CommonFunctionsDominicanRepublic implements CommonFunctionsInterface
28
{
29
    public static function ncfRango()
30
    {
31
        // TODO: Implement ncfRango() method.
32
    }
33
34
    public static function ncfCorrelativo($tipoComprobante, $idempresa)
35
    {
36
        $tipocomprobante = new NCFRango();
37
        $where = [
38
            //new DatabaseWhere('tipocomprobante', $_REQUEST['tipocomprobante']),
39
            new DatabaseWhere('tipocomprobante', $tipoComprobante),
40
            new DatabaseWhere('idempresa', $idempresa),
41
            new DatabaseWhere('estado', 1)
42
        ];
43
        $comprobante = $tipocomprobante->all($where);
44
        if ($comprobante) {
45
            echo json_encode(['existe' => $comprobante], JSON_THROW_ON_ERROR);
46
        } else {
47
            echo json_encode(['existe' => false], JSON_THROW_ON_ERROR);
48
        }
49
    }
50
51
    /**
52
     * @throws \JsonException
53
     */
54
    public static function ncfTipoPago(string $tipoPago)
55
    {
56
        $where = [new DatabaseWhere('tipopago', $tipoPago)];
57
        $tipoPagos = new NCFTipoPago();
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Plugins\f...inicana\Lib\NCFTipoPago was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
58
        $pagos = $tipoPagos->all($where);
59
        if ($pagos) {
60
            echo \json_encode(['pagos' => $pagos], JSON_THROW_ON_ERROR);
61
        } else {
62
            echo '';
63
        }
64
    }
65
66
    /**
67
     * @throws \JsonException
68
     */
69
    public static function ncfTipoMovimiento(string $tipoMovimiento)
70
    {
71
        $tipomovimiento = new NCFTipoMovimiento();
72
        $where = [new DatabaseWhere('tipomovimiento', $tipoMovimiento)];
73
        $movimientos = $tipomovimiento->all($where);
74
        if ($movimientos) {
75
            echo json_encode(['movimientos' => $movimientos], JSON_THROW_ON_ERROR);
76
        } else {
77
            echo '';
78
        }
79
    }
80
81
    public static function ncfTipoAnulacion(string $tipoAnulacion)
82
    {
83
        $where = [new DatabaseWhere('codigo', $tipoAnulacion)];
84
        $tipoAnulaciones = new NCFTipoAnulacion();
85
        $anulaciones = $tipoAnulaciones->all($where);
86
        if ($anulaciones) {
87
            echo \json_encode(['anulaciones' => $anulaciones], JSON_THROW_ON_ERROR);
88
        } else {
89
            echo '';
90
        }
91
    }
92
93
    /**
94
     * @throws \JsonException
95
     */
96
    public static function ncfTipoComprobante($tipoComprobante)
97
    {
98
        $where = [new DatabaseWhere($tipoComprobante, 'Y')];
99
        $tipoComprobantes = new NCFTipo();
100
        $lista = $tipoComprobantes->all($where);
101
        if ($lista) {
102
            echo json_encode(['tipocomprobantes' => $lista], JSON_THROW_ON_ERROR);
103
        } else {
104
            echo '';
105
        }
106
    }
107
108
    public static function ncfFechaVencimiento()
109
    {
110
        // TODO: Implement ncfFechaVencimiento() method.
111
    }
112
113
    /**
114
     * @throws \JsonException
115
     */
116
    public static function ncfTipoCliente(string $cliente)
117
    {
118
        $NCFTipo = new NCFTipo();
119
        $tipoCliente = $NCFTipo->tipoCliente($cliente);
120
        if ($tipoCliente) {
121
            echo json_encode(['infocliente' => $tipoCliente], JSON_THROW_ON_ERROR);
122
        } else {
123
            echo '';
124
        }
125
    }
126
}