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 Closure; |
21
|
|
|
use FacturaScripts\Core\Tools; |
22
|
|
|
use FacturaScripts\Dinamic\Model\NCFRango; |
|
|
|
|
23
|
|
|
use FacturaScripts\Dinamic\Model\NCFTipoMovimiento; |
|
|
|
|
24
|
|
|
use FacturaScripts\Dinamic\Model\Proveedor; |
|
|
|
|
25
|
|
|
|
26
|
|
|
class FacturaProveedor |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var date |
|
|
|
|
30
|
|
|
*/ |
31
|
|
|
public $ncffechavencimiento; |
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
public $tipocomprobante; |
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
public $ncftipopago; |
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
public $ncftipomovimiento; |
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
public $ncftipoanulacion; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
public $numeroncf; |
53
|
|
|
|
54
|
|
|
public function saveBefore(): Closure |
55
|
|
|
{ |
56
|
|
|
return function () { |
57
|
|
|
$ArrayTipoNCFCompras = ['11', '12', '16', '17']; |
58
|
|
|
$ncfrango = new NCFRango(); |
59
|
|
|
$proveedor = new Proveedor(); |
60
|
|
|
//$appSettings = new AppSettings; |
61
|
|
|
$actualProveedor = $proveedor->get($this->codproveedor); |
|
|
|
|
62
|
|
|
$actualProveedor->idempresa = Tools::settings('default', 'idempresa'); |
63
|
|
|
$this->tipocomprobante = $_REQUEST['tipocomprobanter'] ?? $this->tipocomprobante; |
64
|
|
|
$this->numeroncf = $_REQUEST['numeroncfr'] ?? $this->numeroncf; |
65
|
|
|
$tipocomprobante = $this->tipocomprobante; |
66
|
|
|
if ($tipocomprobante !== null && in_array($tipocomprobante, $ArrayTipoNCFCompras, true)) { |
67
|
|
|
$ncfRangoToUse = $ncfrango->getByTipoComprobante($actualProveedor->idempresa, $tipocomprobante); |
68
|
|
|
if (!$ncfRangoToUse) { |
69
|
|
|
Tools::log()->error("no-ncf-range-for-$tipocomprobante"); |
70
|
|
|
return false; |
71
|
|
|
} |
72
|
|
|
$ncf = $ncfRangoToUse->generateNCF(); |
73
|
|
|
$this->numeroncf = $ncf; |
74
|
|
|
$this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento; |
75
|
|
|
$this->tipocomprobante = $ncfRangoToUse->tipocomprobante; |
76
|
|
|
$ncfRangoToUse->correlativo++; |
77
|
|
|
$ncfRangoToUse->save(); |
78
|
|
|
} |
79
|
|
|
if (($this->tipocomprobante === '03' || $this->tipocomprobante === '04') === true) { |
80
|
|
|
$this->ncftipoanulacion = isset($_REQUEST['ncftipoanulacionr']) |
81
|
|
|
? $_REQUEST['ncftipoanulacionr'] |
82
|
|
|
: $this->ncftipoanulacion; |
83
|
|
|
$this->ncffechavencimiento = isset($_REQUEST['ncffechavencimientor']) |
84
|
|
|
? $_REQUEST['ncffechavencimientor'] |
85
|
|
|
: $this->ncffechavencimiento; |
86
|
|
|
} |
87
|
|
|
$this->ncffechavencimiento = ($this->ncffechavencimiento == '') ? null : $this->ncffechavencimiento; |
|
|
|
|
88
|
|
|
}; |
89
|
|
|
} |
90
|
|
|
} |
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