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; |
|
|
|
|
25
|
|
|
use FacturaScripts\Dinamic\Model\NCFRango; |
|
|
|
|
26
|
|
|
use FacturaScripts\Dinamic\Model\NCFTipoMovimiento; |
|
|
|
|
27
|
|
|
use FacturaScripts\Dinamic\Model\Cliente; |
|
|
|
|
28
|
|
|
use FacturaScripts\Core\App\AppSettings; |
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Description of FacturaCliente |
32
|
|
|
* |
33
|
|
|
* @author joenilson |
34
|
|
|
*/ |
35
|
|
|
class FacturaCliente |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @var date |
|
|
|
|
39
|
|
|
*/ |
40
|
|
|
public $ncffechavencimiento; |
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
public $tipocomprobante; |
45
|
|
|
/** |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
public $ncftipopago; |
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
public $ncftipomovimiento; |
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
public $ncftipoanulacion; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
public $facturarectnumero2; |
65
|
|
|
|
66
|
|
|
public function saveBefore(): Closure |
67
|
|
|
{ |
68
|
|
|
return function () { |
69
|
|
|
|
70
|
|
|
$ncfrango = new NCFRango(); |
71
|
|
|
$cliente = new Cliente(); |
72
|
|
|
$appSettins = new AppSettings; |
73
|
|
|
$actualCliente = $cliente->get($this->codcliente); |
|
|
|
|
74
|
|
|
$actualCliente->idempresa = $appSettins::get('default', 'idempresa'); |
75
|
|
|
$this->tipocomprobante = $this->tipocomprobante ?? $actualCliente->tipocomprobante; |
76
|
|
|
$this->tipocomprobante = $_REQUEST['tipocomprobanter'] ?? $this->tipocomprobante; |
77
|
|
|
$this->numeroncf = (isset($_REQUEST['tipocomprobanter'])) ? '' : $this->numeroncf; |
|
|
|
|
78
|
|
|
if ($this->tipocomprobante !== '' && \in_array($this->numeroncf, ['', null], true)) { |
79
|
|
|
$tipocomprobante = "02"; |
80
|
|
|
if (($this->tipocomprobante !== null) === true) { |
81
|
|
|
$tipocomprobante = $this->tipocomprobante; |
82
|
|
|
} elseif (($this->tipocomprobante === null) === true) { |
83
|
|
|
$tipocomprobante = $actualCliente->tipocomprobante; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$ncfRangoToUse = $ncfrango->getByTipoComprobante($actualCliente->idempresa, $tipocomprobante); |
87
|
|
|
if (!$ncfRangoToUse) { |
88
|
|
|
$this->toolBox()->i18nLog()->error("no-ncf-range-for-$tipocomprobante"); |
|
|
|
|
89
|
|
|
return false; |
90
|
|
|
} |
91
|
|
|
$ncf = $ncfRangoToUse->generateNCF(); |
92
|
|
|
$this->numeroncf = $ncf; |
93
|
|
|
$this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento; |
94
|
|
|
$this->tipocomprobante = $ncfRangoToUse->tipocomprobante; |
95
|
|
|
$ncfRangoToUse->correlativo++; |
96
|
|
|
$ncfRangoToUse->save(); |
97
|
|
|
if (($this->tipocomprobante === '03' || $this->tipocomprobante === '04') === true) { |
98
|
|
|
$this->ncftipoanulacion = isset($_REQUEST['ncftipoanulacionr']) |
99
|
|
|
? $_REQUEST['ncftipoanulacionr'] |
100
|
|
|
: $this->ncftipoanulacion; |
101
|
|
|
$this->ncffechavencimiento = isset($_REQUEST['ncffechavencimientor']) |
102
|
|
|
? $_REQUEST['ncffechavencimientor'] |
103
|
|
|
: $this->ncffechavencimiento; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
$this->ncffechavencimiento = ($this->ncffechavencimiento == '') ? null : $this->ncffechavencimiento; |
|
|
|
|
107
|
|
|
}; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function all(): Closure |
111
|
|
|
{ |
112
|
|
|
return function () { |
113
|
|
|
$this->facturarectnumero2 = ''; |
114
|
|
|
if ($this->idfacturarect !== '') { |
|
|
|
|
115
|
|
|
$facturaRectificativa = $this->get($this->idfacturarect); |
|
|
|
|
116
|
|
|
$this->loadFromData(['facturarectnumero2' => 'SI' ]); |
|
|
|
|
117
|
|
|
$this->facturarectnumero2 = $facturaRectificativa->numero2; |
118
|
|
|
} else { |
119
|
|
|
$this->loadFromData(['facturarectnumero2' => 'NO HAY']); |
120
|
|
|
} |
121
|
|
|
return $this; |
122
|
|
|
}; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
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