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 Closure; |
||||||
24 | use FacturaScripts\Core\Base\DataBase\DataBaseWhere; |
||||||
0 ignored issues
–
show
|
|||||||
25 | use FacturaScripts\Core\Tools; |
||||||
26 | use FacturaScripts\Dinamic\Model\NCFRango; |
||||||
0 ignored issues
–
show
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
27 | use FacturaScripts\Dinamic\Model\NCFTipo; |
||||||
0 ignored issues
–
show
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
28 | use FacturaScripts\Dinamic\Model\NCFTipoMovimiento; |
||||||
0 ignored issues
–
show
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
29 | use FacturaScripts\Dinamic\Model\Cliente; |
||||||
0 ignored issues
–
show
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() 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
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||||||
30 | |||||||
31 | /** |
||||||
32 | * Description of FacturaCliente |
||||||
33 | * |
||||||
34 | * @author joenilson |
||||||
35 | */ |
||||||
36 | class FacturaCliente |
||||||
37 | { |
||||||
38 | /** |
||||||
39 | * @var date |
||||||
0 ignored issues
–
show
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
40 | */ |
||||||
41 | public $ncffechavencimiento; |
||||||
42 | /** |
||||||
43 | * @var string |
||||||
44 | */ |
||||||
45 | public $tipocomprobante; |
||||||
46 | /** |
||||||
47 | * @var string |
||||||
48 | */ |
||||||
49 | public $numeroncf; |
||||||
50 | /** |
||||||
51 | * |
||||||
52 | * @var string |
||||||
53 | */ |
||||||
54 | public $ncftipopago; |
||||||
55 | /** |
||||||
56 | * |
||||||
57 | * @var string |
||||||
58 | */ |
||||||
59 | public $ncftipomovimiento; |
||||||
60 | /** |
||||||
61 | * |
||||||
62 | * @var string |
||||||
63 | */ |
||||||
64 | public $ncftipoanulacion; |
||||||
65 | |||||||
66 | /** |
||||||
67 | * @var string |
||||||
68 | */ |
||||||
69 | public $facturarectnumero2; |
||||||
70 | |||||||
71 | public function saveBefore(): Closure |
||||||
72 | { |
||||||
73 | return function () { |
||||||
74 | if (null !== $this->codigorect && $this->idfactura === null) { |
||||||
75 | $this->cleanRefundData(); |
||||||
76 | } |
||||||
77 | |||||||
78 | $cliente = new Cliente(); |
||||||
79 | //$appSettins = new AppSettings; |
||||||
80 | $actualCliente = $cliente->get($this->codcliente); |
||||||
0 ignored issues
–
show
|
|||||||
81 | $actualCliente->idempresa = Tools::settings('default', 'idempresa'); |
||||||
82 | $this->tipocomprobante = $this->tipocomprobante ?? $actualCliente->tipocomprobante; |
||||||
83 | $this->tipocomprobante = $_REQUEST['tipocomprobanter'] ?? $this->tipocomprobante; |
||||||
84 | if ($this->tipocomprobante !== '' && \in_array($this->numeroncf, ['', null], true)) { |
||||||
85 | $tipocomprobante = "02"; |
||||||
86 | if (($this->tipocomprobante !== null) === true) { |
||||||
87 | $tipocomprobante = $this->tipocomprobante; |
||||||
88 | } elseif (($this->tipocomprobante === null) === true) { |
||||||
89 | $tipocomprobante = $actualCliente->tipocomprobante; |
||||||
90 | } |
||||||
91 | |||||||
92 | if (true === in_array($this->numeroncf, ['',null])) { |
||||||
93 | $ncfrango = new NCFRango(); |
||||||
94 | $ncfRangoToUse = $ncfrango->getByTipoComprobante($actualCliente->idempresa, $tipocomprobante); |
||||||
95 | if (!$ncfRangoToUse) { |
||||||
96 | Tools::log()->error("no-ncf-range-for-$tipocomprobante"); |
||||||
97 | return false; |
||||||
98 | } |
||||||
99 | $ncf = $ncfRangoToUse->generateNCF(); |
||||||
100 | $this->numeroncf = $ncf; |
||||||
101 | $this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento; |
||||||
102 | $this->tipocomprobante = $ncfRangoToUse->tipocomprobante; |
||||||
103 | $ncfRangoToUse->correlativo++; |
||||||
104 | $ncfRangoToUse->save(); |
||||||
105 | } |
||||||
106 | |||||||
107 | //Verificamos si $this->tipoComprobante es una nota de crédito o debito |
||||||
108 | $arrayNCFTypes = ['03','04']; |
||||||
109 | if (in_array($this->tipocomprobante, $arrayNCFTypes) === true) { |
||||||
110 | $this->ncftipoanulacion = $_REQUEST['ncftipoanulacionr'] ?? $this->ncftipoanulacion; |
||||||
111 | $this->ncffechavencimiento = $_REQUEST['ncffechavencimientor'] ?? $this->ncffechavencimiento; |
||||||
112 | } |
||||||
113 | } |
||||||
114 | $this->ncffechavencimiento = ($this->ncffechavencimiento === '') ? null : $this->ncffechavencimiento; |
||||||
0 ignored issues
–
show
|
|||||||
115 | return $this; |
||||||
116 | }; |
||||||
117 | } |
||||||
118 | |||||||
119 | public function all(): Closure |
||||||
120 | { |
||||||
121 | return function () { |
||||||
122 | $this->facturarectnumero2 = ''; |
||||||
123 | if ($this->idfacturarect !== '') { |
||||||
0 ignored issues
–
show
|
|||||||
124 | $facturaRectificativa = $this->get($this->idfacturarect); |
||||||
0 ignored issues
–
show
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
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. ![]() |
|||||||
125 | $this->loadFromData(['facturarectnumero2' => 'SI' ]); |
||||||
0 ignored issues
–
show
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
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. ![]() |
|||||||
126 | $this->facturarectnumero2 = $facturaRectificativa->numero2; |
||||||
127 | } else { |
||||||
128 | $this->loadFromData(['facturarectnumero2' => 'NO HAY']); |
||||||
129 | } |
||||||
130 | return $this; |
||||||
131 | }; |
||||||
132 | } |
||||||
133 | |||||||
134 | public function descripcionTipoComprobante(): Closure |
||||||
135 | { |
||||||
136 | return function () { |
||||||
137 | $ncftipocomprobante = new NCFTipo(); |
||||||
138 | $ncftipocomprobante->loadFromCode($this->tipocomprobante); |
||||||
139 | return $ncftipocomprobante->descripcion; |
||||||
140 | }; |
||||||
141 | } |
||||||
142 | protected function cleanRefundData() |
||||||
143 | { |
||||||
144 | return function () { |
||||||
145 | $this->numeroncf = ''; |
||||||
146 | $this->tipocomprobante = null; |
||||||
147 | $this->ncffechavencimiento = null; |
||||||
148 | $this->ncftipomovimiento = null; |
||||||
149 | $this->ncftipopago = null; |
||||||
150 | }; |
||||||
151 | } |
||||||
152 | } |
||||||
153 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths