Passed
Push — master ( 9ab1a3...d29869 )
by Joe Nilson
01:57
created

Init   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 46
c 3
b 0
f 1
dl 0
loc 65
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ActualizarEstados() 0 30 3
A update() 0 13 1
A init() 0 14 1
1
<?php
2
/*
3
 * Copyright (C) 2020 Joe Zegarra.
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 3 of the License, or (at your option) any later version.
9
 *
10
 * This library 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 GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA 02110-1301  USA
19
 */
20
21
namespace FacturaScripts\Plugins\fsRepublicaDominicana;
22
23
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...
24
use FacturaScripts\Core\Base\InitClass;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\InitClass 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\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...
26
use FacturaScripts\Dinamic\Model\Cliente;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\Cliente 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...
27
use FacturaScripts\Dinamic\Model\EstadoDocumento;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\EstadoDocumento 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...
28
use FacturaScripts\Dinamic\Model\FacturaCliente;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\FacturaCliente 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...
29
use FacturaScripts\Dinamic\Model\Proveedor;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\Proveedor 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...
30
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...
31
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFRango;
32
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipo;
33
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoAnulacion;
34
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoMovimiento;
35
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoPago;
36
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\RNCDGIIDB;
37
38
use FacturaScripts\Core\Base\AjaxForms\SalesHeaderHTML;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\AjaxForms\SalesHeaderHTML 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...
39
use FacturaScripts\Core\Base\AjaxForms\SalesFooterHTML;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\AjaxForms\SalesFooterHTML 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...
40
use FacturaScripts\Core\Base\AjaxForms\PurchasesFooterHTML;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base...rms\PurchasesFooterHTML 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...
41
42
/**
43
 * Description of Init
44
 *
45
 * @author Joe Zegarra
46
 */
47
class Init extends InitClass
48
{
49
    public function init()
50
    {
51
        $this->loadExtension(new Extension\Model\Cliente());
52
        $this->loadExtension(new Extension\Model\FacturaCliente());
53
        $this->loadExtension(new Extension\Model\FacturaProveedor());
54
        $this->loadExtension(new Extension\Model\Producto());
55
        $this->loadExtension(new Extension\Controller\EditCliente());
56
        $this->loadExtension(new Extension\Controller\EditProveedor());
57
        $this->loadExtension(new Extension\Controller\EditFacturaCliente());
58
        $this->loadExtension(new Extension\Controller\EditFacturaProveedor());
59
        AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonDomFunctions.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...
60
        SalesHeaderHTML::addMod(new Mod\SalesHeaderMod());
61
        SalesFooterHTML::addMod(new Mod\SalesFooterMod());
62
        PurchasesFooterHTML::addMod(new Mod\PurchasesFooterMod());
63
    }
64
65
    private function ActualizarEstados()
66
    {
67
        $arrayDocumentos = [
68
            'FacturaCliente',
69
            'FacturaProveedor',
70
            'AlbaranCliente',
71
            'AlbaranProveedor',
72
            'PedidoCliente',
73
            'PedidoProveedor'
74
        ];
75
        $estados = new EstadoDocumento();
76
77
        foreach ($arrayDocumentos as $documento) {
78
            $lista = $estados->all(
79
                [
80
                    new DataBaseWhere('nombre', 'Anulada'),
81
                    new DataBaseWhere('tipodoc', $documento)
82
                ]
83
            );
84
85
            if (count($lista) === 0) {
86
                $nuevoDocumento = new EstadoDocumento();
87
                $nuevoDocumento->nombre = 'Anulada';
88
                $nuevoDocumento->tipodoc = $documento;
89
                $nuevoDocumento->icon = 'fas fa-handshake-slash';
90
                $nuevoDocumento->editable = false;
91
                $nuevoDocumento->bloquear = true;
92
                $nuevoDocumento->actualizastock = 0;
93
                $nuevoDocumento->predeterminado = false;
94
                $nuevoDocumento->save();
95
            }
96
        }
97
    }
98
    
99
    public function update()
100
    {
101
        new NCFTipoPago();
102
        new NCFTipoAnulacion();
103
        new NCFTipoMovimiento();
104
        new NCFTipo();
105
        new NCFRango();
106
        new Cliente();
107
        new FacturaCliente();
108
        new Proveedor();
109
        new FacturaProveedor();
110
        new RNCDGIIDB();
111
        $this->ActualizarEstados();
112
    }
113
}
114