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

EditFacturaProveedor   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 47
dl 0
loc 68
rs 10
c 1
b 0
f 0
wmc 11

4 Methods

Rating   Name   Duplication   Size   Complexity  
B execPreviousAction() 0 41 8
A createViews() 0 6 1
A ncftipo() 0 4 1
A ncftipoanulacion() 0 5 1
1
<?php
2
/*
3
 * Copyright (C) 2021 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\Extension\Controller;
19
20
use Closure;
21
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...
22
use FacturaScripts\Dinamic\Lib\AssetManager;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Lib\AssetManager 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\FacturaProveedor;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\FacturaProveedor 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\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...
25
use FacturaScripts\Dinamic\Model\NCFTipoAnulacion;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFTipoAnulacion 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...
26
use FacturaScripts\Plugins\fsRepublicaDominicana\Lib\CommonFunctionsDominicanRepublic;
27
28
class EditFacturaProveedor
29
{
30
    public function createViews(): Closure
31
    {
32
        return function () {
33
            parent::createViews();
34
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonModals.js');
0 ignored issues
show
Bug introduced by
The constant FS_ROUTE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
35
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonDomFunctions.js');
36
        };
37
    }
38
39
    public function execPreviousAction()
40
    {
41
        return function ($action) {
42
            switch ($action) {
43
                case 'busca_tipo':
44
                    $this->setTemplate(false);
0 ignored issues
show
Bug introduced by
The method setTemplate() does not exist on FacturaScripts\Plugins\f...er\EditFacturaProveedor. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
                    $this->/** @scrutinizer ignore-call */ 
45
                           setTemplate(false);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
                    CommonFunctionsDominicanRepublic::ncfTipoComprobante($_REQUEST['tipodocumento']);
46
                    break;
47
                case 'busca_movimiento':
48
                    $this->setTemplate(false);
49
                    CommonFunctionsDominicanRepublic::ncfTipoMovimiento($_REQUEST['tipomovimiento']);
50
                    break;
51
                case 'busca_tipoanulacion':
52
                    $this->setTemplate(false);
53
                    CommonFunctionsDominicanRepublic::ncfTipoAnulacion($_REQUEST['tipoanulacion']);
54
                    break;
55
                case 'busca_pago':
56
                    $this->setTemplate(false);
57
                    CommonFunctionsDominicanRepublic::ncfTipoPago($_REQUEST['tipopago']);
58
                    break;
59
                case "verifica_documento":
60
                    $this->setTemplate(false);
61
                    $facturasProveedores = new FacturaProveedor();
62
                    $where = [
63
                        new DataBaseWhere('numproveedor', $_REQUEST['ncf']),
64
                        new DataBaseWhere('codproveedor', $_REQUEST['proveedor'])
65
                    ];
66
                    $verificacion = $facturasProveedores->all($where);
67
                    if (!$verificacion) {
68
                        echo json_encode(['success' => true], JSON_THROW_ON_ERROR);
69
                    } else {
70
                        $message = "Factura: " . $verificacion[0]->idfactura . " Fecha: " . $verificacion[0]->fecha;
71
                        echo json_encode(['error' => true, 'message' => $message], JSON_THROW_ON_ERROR);
72
                    }
73
                    break;
74
                case 'busca_correlativo':
75
                    $this->setTemplate(false);
76
                    CommonFunctionsDominicanRepublic::ncfCorrelativo($_REQUEST['tipocomprobante'], $this->empresa->idempresa);
0 ignored issues
show
Bug Best Practice introduced by
The property empresa does not exist on FacturaScripts\Plugins\f...er\EditFacturaProveedor. Did you maybe forget to declare it?
Loading history...
77
                    break;
78
                default:
79
                    break;
80
            }
81
        };
82
    }
83
84
    public function ncftipo()
85
    {
86
        return function () {
87
            return NCFTipo::allVentas();
88
        };
89
    }
90
91
    public function ncftipoanulacion()
92
    {
93
        return function () {
94
            $tiposAnulacion = new NCFTipoAnulacion();
95
            return $tiposAnulacion->all();
96
        };
97
    }
98
}