Passed
Push — master ( 8e49de...855750 )
by Joe Nilson
03:05
created

FacturaCliente::all()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 1
nop 0
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (C) 2020 joenilson.
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\Extension\Model;
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\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...
25
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...
26
use FacturaScripts\Dinamic\Model\Cliente;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, FacturaScripts\Plugins\f...Extension\Model\Cliente. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
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\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...
28
29
/**
30
 * Description of FacturaCliente
31
 *
32
 * @author joenilson
33
 */
34
class FacturaCliente
35
{
36
    /**
37
     * @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...
38
     */
39
    public $ncffechavencimiento;
40
    /**
41
     * @var string
42
     */
43
    public $tipocomprobante;
44
    /**
45
     *
46
     * @var string
47
     */
48
    public $ncftipopago;
49
    /**
50
     *
51
     * @var string
52
     */
53
    public $ncftipomovimiento;
54
    /**
55
     *
56
     * @var string
57
     */
58
    public $ncftipoanulacion;
59
60
    /**
61
     * @var string
62
     */
63
    public $facturarectnumero2;
64
    
65
    public function saveInsert()
66
    {
67
        return function () {
68
            $ncfrango = new NCFRango();
69
            $cliente = new Cliente();
70
            $appSettins = new AppSettings;
71
            $actualCliente = $cliente->get($this->codcliente);
0 ignored issues
show
Bug Best Practice introduced by
The property codcliente does not exist on FacturaScripts\Plugins\f...on\Model\FacturaCliente. Did you maybe forget to declare it?
Loading history...
72
            $actualCliente->idempresa = $appSettins::get('default', 'idempresa');
73
            $tipocomprobante = ($actualCliente->tipocomprobante !== $this->tipocomprobante)
74
                ? $this->tipocomprobante : $actualCliente->tipocomprobante;
75
            $ncfRangoToUse = $ncfrango->getByTipoComprobante($actualCliente->idempresa, $tipocomprobante);
76
            $ncf = $ncfRangoToUse->generateNCF();
77
            $this->numero2 = $ncf;
0 ignored issues
show
Bug Best Practice introduced by
The property numero2 does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
78
            $this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento;
79
            $this->tipocomprobante = $ncfRangoToUse->tipocomprobante;
80
            $ncfRangoToUse->correlativo++;
81
            $ncfRangoToUse->save();
82
        };
83
    }
84
85
    public function all()
86
    {
87
        //parent::all();
88
        return function () {
89
            $this->facturarectnumero2 = '';
90
            if ($this->idfacturarect !== '') {
0 ignored issues
show
Bug Best Practice introduced by
The property idfacturarect does not exist on FacturaScripts\Plugins\f...on\Model\FacturaCliente. Did you maybe forget to declare it?
Loading history...
91
                $facturaRectificativa = $this->get($this->idfacturarect);
0 ignored issues
show
Bug introduced by
The method get() does not exist on FacturaScripts\Plugins\f...on\Model\FacturaCliente. ( Ignorable by Annotation )

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

91
                /** @scrutinizer ignore-call */ 
92
                $facturaRectificativa = $this->get($this->idfacturarect);

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...
Unused Code introduced by
The assignment to $facturaRectificativa is dead and can be removed.
Loading history...
92
                $this->loadFromData(['facturarectnumero2' => 'SI' ]);
0 ignored issues
show
Bug introduced by
The method loadFromData() does not exist on FacturaScripts\Plugins\f...on\Model\FacturaCliente. ( Ignorable by Annotation )

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

92
                $this->/** @scrutinizer ignore-call */ 
93
                       loadFromData(['facturarectnumero2' => 'SI' ]);

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...
93
                $this->facturarectnumero2 = 'SI';
94
            } else {
95
                $this->loadFromData(['facturarectnumero2' => 'NO HAY']);
96
                $this->facturarectnumero2 = 'NO';
97
            }
98
            return $this;
99
        };
100
    }
101
}
102