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\Controller; |
19
|
|
|
|
20
|
|
|
use Closure; |
21
|
|
|
use FacturaScripts\Core\Base\DataBase\DataBaseWhere; |
|
|
|
|
22
|
|
|
use FacturaScripts\Dinamic\Lib\AssetManager; |
|
|
|
|
23
|
|
|
use FacturaScripts\Dinamic\Model\FacturaProveedor; |
|
|
|
|
24
|
|
|
use FacturaScripts\Dinamic\Model\NCFTipo; |
|
|
|
|
25
|
|
|
use FacturaScripts\Dinamic\Model\NCFTipoAnulacion; |
|
|
|
|
26
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Lib\CommonFunctionsDominicanRepublic; |
27
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Lib\WebserviceDgii; |
28
|
|
|
|
29
|
|
|
class EditFacturaProveedor |
30
|
|
|
{ |
31
|
|
|
public function createViews(): Closure |
32
|
|
|
{ |
33
|
|
|
return function () { |
34
|
|
|
parent::createViews(); |
35
|
|
|
AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonModals.js'); |
|
|
|
|
36
|
|
|
AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonDomFunctions.js'); |
37
|
|
|
}; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function execPreviousAction() |
41
|
|
|
{ |
42
|
|
|
return function ($action) { |
43
|
|
|
switch ($action) { |
44
|
|
|
case 'busca_tipo': |
45
|
|
|
$this->setTemplate(false); |
|
|
|
|
46
|
|
|
CommonFunctionsDominicanRepublic::ncfTipoComprobante($_REQUEST['tipodocumento']); |
47
|
|
|
break; |
48
|
|
|
case 'busca_movimiento': |
49
|
|
|
$this->setTemplate(false); |
50
|
|
|
CommonFunctionsDominicanRepublic::ncfTipoMovimiento($_REQUEST['tipomovimiento']); |
51
|
|
|
break; |
52
|
|
|
case 'busca_tipoanulacion': |
53
|
|
|
$this->setTemplate(false); |
54
|
|
|
CommonFunctionsDominicanRepublic::ncfTipoAnulacion($_REQUEST['tipoanulacion']); |
55
|
|
|
break; |
56
|
|
|
case 'busca_pago': |
57
|
|
|
$this->setTemplate(false); |
58
|
|
|
CommonFunctionsDominicanRepublic::ncfTipoPago($_REQUEST['tipopago']); |
59
|
|
|
break; |
60
|
|
|
case "verifica_documento": |
61
|
|
|
$this->setTemplate(false); |
62
|
|
|
$this->verifyDocument(); |
63
|
|
|
break; |
64
|
|
|
case 'busca_correlativo': |
65
|
|
|
$this->setTemplate(false); |
66
|
|
|
CommonFunctionsDominicanRepublic::ncfCorrelativo($_REQUEST['tipocomprobante'], $this->empresa->idempresa); |
|
|
|
|
67
|
|
|
break; |
68
|
|
|
case 'busca_rnc': |
69
|
|
|
$this->setTemplate(false); |
70
|
|
|
$consulta = new WebserviceDgii(); |
71
|
|
|
$rncNotFound = self::toolBox()->i18n()->trans('rnc-not-found'); |
|
|
|
|
72
|
|
|
$respuesta = $consulta->getExternalAPI($_REQUEST['cifnif']); |
73
|
|
|
$registros = $respuesta->totalResults; |
74
|
|
|
if ($registros !== 0) { |
75
|
|
|
$resultado = $respuesta->entry[0]; |
76
|
|
|
if ($resultado) { |
77
|
|
|
$arrayResultado = []; |
78
|
|
|
$arrayResultado["RGE_RUC"] = $resultado->rnc; |
79
|
|
|
$arrayResultado["RGE_NOMBRE"] = $resultado->nombre; |
80
|
|
|
$arrayResultado["NOMBRE_COMERCIAL"] = $resultado->razonsocial; |
81
|
|
|
$arrayResultado["ESTATUS"] = $resultado->estado; |
82
|
|
|
echo json_encode($arrayResultado); |
83
|
|
|
} else { |
84
|
|
|
echo '{"RGE_ERROR": "true", "message": "'.$rncNotFound.'"}'; |
85
|
|
|
} |
86
|
|
|
} else { |
87
|
|
|
echo '{"RGE_ERROR": "true", "message": "'.$rncNotFound.'"}'; |
88
|
|
|
} |
89
|
|
|
break; |
90
|
|
|
default: |
91
|
|
|
break; |
92
|
|
|
} |
93
|
|
|
}; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
private function verifyDocument() |
97
|
|
|
{ |
98
|
|
|
$facturasProveedores = new FacturaProveedor(); |
99
|
|
|
$where = [ |
100
|
|
|
new DataBaseWhere('numeroncf', $_REQUEST['ncf']), |
101
|
|
|
new DataBaseWhere('codproveedor', $_REQUEST['proveedor']) |
102
|
|
|
]; |
103
|
|
|
$verificacion = $facturasProveedores->all($where); |
104
|
|
|
if (!$verificacion) { |
105
|
|
|
echo json_encode(['success' => true], JSON_THROW_ON_ERROR); |
106
|
|
|
} else { |
107
|
|
|
$message = "Factura: " . $verificacion[0]->idfactura . " Fecha: " . $verificacion[0]->fecha; |
108
|
|
|
echo json_encode(['error' => true, 'message' => $message], JSON_THROW_ON_ERROR); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function ncftipo() |
113
|
|
|
{ |
114
|
|
|
return function () { |
115
|
|
|
return NCFTipo::allVentas(); |
116
|
|
|
}; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function ncftipoanulacion() |
120
|
|
|
{ |
121
|
|
|
return function () { |
122
|
|
|
$tiposAnulacion = new NCFTipoAnulacion(); |
123
|
|
|
return $tiposAnulacion->all(); |
124
|
|
|
}; |
125
|
|
|
} |
126
|
|
|
} |
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