Passed
Push — master ( eee053...2b5061 )
by Joe Nilson
04:47
created

FacturaProveedor::saveInsert()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 16
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 19
rs 9.7333
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\Model;
19
20
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...
21
use FacturaScripts\Dinamic\Model\NCFTipoMovimiento;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFTipoMovimiento 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\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...
23
use FacturaScripts\Core\App\AppSettings;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\App\AppSettings 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
25
class FacturaProveedor
26
{
27
    /**
28
     *
29
     * @var date
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Plugins\f...na\Extension\Model\date 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
     */
31
    public $ncffechavencimiento;
32
    /**
33
     * @var string
34
     */
35
    public $tipocomprobante;
36
    /**
37
     *
38
     * @var string
39
     */
40
    public $ncftipopago;
41
    /**
42
     *
43
     * @var string
44
     */
45
    public $ncftipomovimiento;
46
    /**
47
     *
48
     * @var string
49
     */
50
    public $ncftipoanulacion;
51
52
    public function saveInsert()
53
    {
54
        return function () {
55
            $ArrayTipoNCFCompras = ['11','12','16','17'];
56
            $ncfrango = new NCFRango();
57
            $cliente = new Proveedor();
58
            $appSettings = new AppSettings;
59
            $actualProveedor = $cliente->get($this->codproveedor);
0 ignored issues
show
Bug Best Practice introduced by
The property codproveedor does not exist on FacturaScripts\Plugins\f...\Model\FacturaProveedor. Did you maybe forget to declare it?
Loading history...
60
            $actualProveedor->idempresa = $appSettings::get('default', 'idempresa');
61
            $codsubtipodoc = $this->codsubtipodoc;
0 ignored issues
show
Bug Best Practice introduced by
The property codsubtipodoc does not exist on FacturaScripts\Plugins\f...\Model\FacturaProveedor. Did you maybe forget to declare it?
Loading history...
62
            $ncfRangoToUse = $ncfrango->getByTipoComprobante($actualProveedor->idempresa, $codsubtipodoc);
63
64
            if(in_array($codsubtipodoc, $ArrayTipoNCFCompras, true)) {
65
                $ncf = $ncfRangoToUse->generateNCF();
66
                $this->numproveedor = $ncf;
0 ignored issues
show
Bug Best Practice introduced by
The property numproveedor does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
67
                $this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento;
68
                $this->tipocomprobante = $ncfRangoToUse->tipocomprobante;
69
                $ncfRangoToUse->correlativo++;
70
                $ncfRangoToUse->save();
71
            }
72
        };
73
    }
74
}