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