|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (C) 2020 Joe Zegarra. |
|
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; |
|
22
|
|
|
|
|
23
|
|
|
use FacturaScripts\Core\Base\DataBase; |
|
|
|
|
|
|
24
|
|
|
use FacturaScripts\Core\Base\DataBase\DataBaseWhere; |
|
|
|
|
|
|
25
|
|
|
use FacturaScripts\Core\Base\InitClass; |
|
|
|
|
|
|
26
|
|
|
use FacturaScripts\Core\Model\Impuesto; |
|
|
|
|
|
|
27
|
|
|
use FacturaScripts\Dinamic\Lib\AssetManager; |
|
|
|
|
|
|
28
|
|
|
use FacturaScripts\Dinamic\Model\Cliente; |
|
|
|
|
|
|
29
|
|
|
use FacturaScripts\Dinamic\Model\EstadoDocumento; |
|
|
|
|
|
|
30
|
|
|
use FacturaScripts\Dinamic\Model\FacturaCliente; |
|
|
|
|
|
|
31
|
|
|
use FacturaScripts\Dinamic\Model\Proveedor; |
|
|
|
|
|
|
32
|
|
|
use FacturaScripts\Dinamic\Model\FacturaProveedor; |
|
|
|
|
|
|
33
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\ImpuestoProducto; |
|
34
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFRango; |
|
35
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipo; |
|
36
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoAnulacion; |
|
37
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoMovimiento; |
|
38
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoPago; |
|
39
|
|
|
|
|
40
|
|
|
use FacturaScripts\Core\Base\AjaxForms\SalesLineHTML; |
|
|
|
|
|
|
41
|
|
|
use FacturaScripts\Core\Base\AjaxForms\SalesFooterHTML; |
|
|
|
|
|
|
42
|
|
|
use FacturaScripts\Core\Base\AjaxForms\PurchasesFooterHTML; |
|
|
|
|
|
|
43
|
|
|
use FacturaScripts\Core\Base\Calculator; |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Description of Init |
|
47
|
|
|
* |
|
48
|
|
|
* @author Joe Zegarra |
|
49
|
|
|
*/ |
|
50
|
|
|
class Init extends InitClass |
|
51
|
|
|
{ |
|
52
|
|
|
public function init(): void |
|
53
|
|
|
{ |
|
54
|
|
|
$this->loadExtension(new Extension\Model\Cliente()); |
|
55
|
|
|
$this->loadExtension(new Extension\Model\FacturaCliente()); |
|
56
|
|
|
$this->loadExtension(new Extension\Model\FacturaProveedor()); |
|
57
|
|
|
$this->loadExtension(new Extension\Model\Producto()); |
|
58
|
|
|
$this->loadExtension(new Extension\Controller\EditCliente()); |
|
59
|
|
|
$this->loadExtension(new Extension\Controller\EditProveedor()); |
|
60
|
|
|
$this->loadExtension(new Extension\Controller\EditFacturaCliente()); |
|
61
|
|
|
$this->loadExtension(new Extension\Controller\EditFacturaProveedor()); |
|
62
|
|
|
$this->loadExtension(new Extension\Controller\EditProducto()); |
|
63
|
|
|
$this->loadExtension(new Extension\Controller\EditSettings()); |
|
64
|
|
|
AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonDomFunctions.js'); |
|
|
|
|
|
|
65
|
|
|
SalesLineHTML::addMod(new Mod\SalesLineMod()); |
|
66
|
|
|
SalesFooterHTML::addMod(new Mod\SalesFooterMod()); |
|
67
|
|
|
PurchasesFooterHTML::addMod(new Mod\PurchasesFooterMod()); |
|
68
|
|
|
Calculator::addMod(new Mod\CalculatorMod()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
private function actualizarEstados(): void |
|
72
|
|
|
{ |
|
73
|
|
|
$arrayDocumentos = [ |
|
74
|
|
|
'FacturaCliente', |
|
75
|
|
|
'FacturaProveedor', |
|
76
|
|
|
'AlbaranCliente', |
|
77
|
|
|
'AlbaranProveedor', |
|
78
|
|
|
'PedidoCliente', |
|
79
|
|
|
'PedidoProveedor' |
|
80
|
|
|
]; |
|
81
|
|
|
$estados = new EstadoDocumento(); |
|
82
|
|
|
|
|
83
|
|
|
foreach ($arrayDocumentos as $documento) { |
|
84
|
|
|
$lista = $estados->all( |
|
85
|
|
|
[ |
|
86
|
|
|
new DataBaseWhere('nombre', 'Anulada'), |
|
87
|
|
|
new DataBaseWhere('tipodoc', $documento) |
|
88
|
|
|
] |
|
89
|
|
|
); |
|
90
|
|
|
|
|
91
|
|
|
if (count($lista) === 0) { |
|
92
|
|
|
$nuevoDocumento = new EstadoDocumento(); |
|
93
|
|
|
$nuevoDocumento->nombre = 'Anulada'; |
|
94
|
|
|
$nuevoDocumento->tipodoc = $documento; |
|
95
|
|
|
$nuevoDocumento->icon = 'fas fa-handshake-slash'; |
|
96
|
|
|
$nuevoDocumento->editable = false; |
|
97
|
|
|
$nuevoDocumento->bloquear = true; |
|
98
|
|
|
$nuevoDocumento->actualizastock = 0; |
|
99
|
|
|
$nuevoDocumento->predeterminado = false; |
|
100
|
|
|
$nuevoDocumento->save(); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
private function actualizarNumeroNCF(): void |
|
106
|
|
|
{ |
|
107
|
|
|
$dataBase = new DataBase(); |
|
108
|
|
|
$dataBase->exec("UPDATE facturascli SET numeroncf = numero2 WHERE numero2 != '' and tipocomprobante != '' AND numeroncf is null;"); |
|
109
|
|
|
$dataBase->exec("UPDATE facturasprov SET numeroncf = numproveedor WHERE numproveedor != '' and tipocomprobante != '' AND numeroncf is null;"); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
private function actualizarImpuestos(): void |
|
113
|
|
|
{ |
|
114
|
|
|
$impuesto = new Impuesto(); |
|
115
|
|
|
$isc = $impuesto->get('ISC'); |
|
116
|
|
|
if ($isc === false) { |
|
117
|
|
|
$isc = new Impuesto(); |
|
118
|
|
|
$isc->codimpuesto = 'ISC'; |
|
119
|
|
|
$isc->descripcion = 'ISC 10%'; |
|
120
|
|
|
$isc->iva = 10; |
|
121
|
|
|
$isc->recargo = 0; |
|
122
|
|
|
$isc->tipo = 1; |
|
123
|
|
|
$isc->save(); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
$cdt = $impuesto->get('CDT'); |
|
127
|
|
|
if ($cdt === false) { |
|
128
|
|
|
$cdt = new Impuesto(); |
|
129
|
|
|
$cdt->codimpuesto = 'CDT'; |
|
130
|
|
|
$cdt->descripcion = 'CDT 2%'; |
|
131
|
|
|
$cdt->iva = 2; |
|
132
|
|
|
$cdt->recargo = 0; |
|
133
|
|
|
$cdt->tipo = 1; |
|
134
|
|
|
$cdt->save(); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
public function update() |
|
139
|
|
|
{ |
|
140
|
|
|
new NCFTipoPago(); |
|
141
|
|
|
new NCFTipoAnulacion(); |
|
142
|
|
|
new NCFTipoMovimiento(); |
|
143
|
|
|
new NCFTipo(); |
|
144
|
|
|
new NCFRango(); |
|
145
|
|
|
new Cliente(); |
|
146
|
|
|
new FacturaCliente(); |
|
147
|
|
|
new Proveedor(); |
|
148
|
|
|
new FacturaProveedor(); |
|
149
|
|
|
new ImpuestoProducto(); |
|
150
|
|
|
$this->actualizarEstados(); |
|
151
|
|
|
$this->actualizarNumeroNCF(); |
|
152
|
|
|
$this->actualizarImpuestos(); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
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