|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2019 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\Model; |
|
22
|
|
|
|
|
23
|
|
|
use FacturaScripts\Core\Base\DataBase; |
|
|
|
|
|
|
24
|
|
|
use FacturaScripts\Core\Base\DataBase\DataBaseWhere; |
|
|
|
|
|
|
25
|
|
|
use FacturaScripts\Core\Model\Base; |
|
|
|
|
|
|
26
|
|
|
use FacturaScripts\Dinamic\Model\Cliente; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Description of NCFTipo |
|
30
|
|
|
* |
|
31
|
|
|
* @author "Joe Zegarra <joenilson at gmail dot com>" |
|
32
|
|
|
*/ |
|
33
|
|
|
class NCFTipo extends Base\ModelClass |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
use Base\ModelTrait; |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Movement Class can be sum or rest suma|resta |
|
39
|
|
|
* @var string |
|
40
|
|
|
*/ |
|
41
|
|
|
public $clasemovimiento; |
|
42
|
|
|
/** |
|
43
|
|
|
* If the NCF Type is about purchase movement then must to have an X as value |
|
44
|
|
|
* @var string |
|
45
|
|
|
*/ |
|
46
|
|
|
public $compras; |
|
47
|
|
|
/** |
|
48
|
|
|
* If the NCF Type is about regular sales or purchase movements then must to have an X as value |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
public $contribuyente; |
|
52
|
|
|
/** |
|
53
|
|
|
* The description of the NCF Type |
|
54
|
|
|
* @var string |
|
55
|
|
|
*/ |
|
56
|
|
|
public $descripcion; |
|
57
|
|
|
/** |
|
58
|
|
|
* The status of the record |
|
59
|
|
|
* @var bool |
|
60
|
|
|
*/ |
|
61
|
|
|
public $estado; |
|
62
|
|
|
/** |
|
63
|
|
|
* If the NCF Type is about sales movement then must to have an X as value |
|
64
|
|
|
* @var string |
|
65
|
|
|
*/ |
|
66
|
|
|
public $ventas; |
|
67
|
|
|
/** |
|
68
|
|
|
* This is the key value that contains the two code type of document |
|
69
|
|
|
* @var string |
|
70
|
|
|
*/ |
|
71
|
|
|
public $tipocomprobante; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* List of NCF types |
|
75
|
|
|
* @var array |
|
76
|
|
|
*/ |
|
77
|
|
|
private $arrayComprobantes = array( |
|
78
|
|
|
[ |
|
79
|
|
|
'tipocomprobante' => '01', 'descripcion' => 'FACTURA DE CREDITO FISCAL', 'clasemovimiento'=>'suma', |
|
80
|
|
|
'ventas'=>'Y', 'compras'=>'Y', 'contribuyente'=>'Y', 'estado' => true |
|
81
|
|
|
], |
|
82
|
|
|
[ |
|
83
|
|
|
'tipocomprobante' => '02', 'descripcion' => 'FACTURA DE CONSUMO', 'clasemovimiento'=>'suma', |
|
84
|
|
|
'ventas'=>'Y', 'compras'=>'Y', 'contribuyente'=>'Y', 'estado' => true |
|
85
|
|
|
], |
|
86
|
|
|
[ |
|
87
|
|
|
'tipocomprobante' => '03', 'descripcion' => 'NOTA DE DEBITO', 'clasemovimiento'=>'suma', |
|
88
|
|
|
'ventas'=>'Y', 'compras'=>'Y', 'contribuyente'=>'N', 'estado' => true |
|
89
|
|
|
], |
|
90
|
|
|
[ |
|
91
|
|
|
'tipocomprobante' => '04', 'descripcion' => 'NOTA DE CREDITO', 'clasemovimiento'=>'resta', |
|
92
|
|
|
'ventas'=>'Y', 'compras'=>'Y', 'contribuyente'=>'N', 'estado' => true |
|
93
|
|
|
], |
|
94
|
|
|
[ |
|
95
|
|
|
'tipocomprobante' => '11', 'descripcion' => 'COMPROBANTE DE COMPRAS', 'clasemovimiento'=>'suma', |
|
96
|
|
|
'ventas'=>'N', 'compras'=>'Y', 'contribuyente'=>'Y', 'estado' => true |
|
97
|
|
|
], |
|
98
|
|
|
[ |
|
99
|
|
|
'tipocomprobante' => '12', 'descripcion' => 'REGISTRO UNICO DE INGRESOS', 'clasemovimiento'=>'suma', |
|
100
|
|
|
'ventas'=>'Y', 'compras'=>'N', 'contribuyente'=>'N', 'estado' => true |
|
101
|
|
|
], |
|
102
|
|
|
[ |
|
103
|
|
|
'tipocomprobante' => '13', 'descripcion' => 'COMPROBANTE PARA GASTOS MENORES', 'clasemovimiento'=>'suma', |
|
104
|
|
|
'ventas'=>'N', 'compras'=>'Y', 'contribuyente'=>'N', 'estado' => true |
|
105
|
|
|
], |
|
106
|
|
|
[ |
|
107
|
|
|
'tipocomprobante' => '14', 'descripcion' => 'COMPROBANTE DE REGIMENES ESPECIALES', 'clasemovimiento'=>'suma', |
|
108
|
|
|
'ventas'=>'Y', 'compras'=>'Y', 'contribuyente'=>'Y', 'estado' => true |
|
109
|
|
|
], |
|
110
|
|
|
[ |
|
111
|
|
|
'tipocomprobante' => '15', 'descripcion' => 'COMPROBANTE GUBERNAMENTAL', 'clasemovimiento'=>'suma', |
|
112
|
|
|
'ventas'=>'Y', 'compras'=>'Y', 'contribuyente'=>'Y', 'estado' => true |
|
113
|
|
|
], |
|
114
|
|
|
[ |
|
115
|
|
|
'tipocomprobante' => '16', 'descripcion' => 'COMPROBANTE PARA EXPORTACIONES', 'clasemovimiento'=>'suma', |
|
116
|
|
|
'ventas'=>'Y', 'compras'=>'N', 'contribuyente'=>'Y', 'estado' => true |
|
117
|
|
|
], |
|
118
|
|
|
[ |
|
119
|
|
|
'tipocomprobante' => '17', 'descripcion' => 'COMPROBANTE PARA PAGOS AL EXTERIOR', 'clasemovimiento'=>'suma', |
|
120
|
|
|
'ventas'=>'N', 'compras'=>'Y', 'contribuyente'=>'Y', 'estado' => true |
|
121
|
|
|
], |
|
122
|
|
|
); |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return string |
|
126
|
|
|
*/ |
|
127
|
|
|
public static function primaryColumn(): string |
|
128
|
|
|
{ |
|
129
|
|
|
return 'tipocomprobante'; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* |
|
134
|
|
|
* @return string |
|
135
|
|
|
*/ |
|
136
|
|
|
public static function tableName() |
|
137
|
|
|
{ |
|
138
|
|
|
return 'rd_ncftipo'; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* |
|
143
|
|
|
* @return string |
|
144
|
|
|
*/ |
|
145
|
|
|
public function install() |
|
146
|
|
|
{ |
|
147
|
|
|
parent::install(); |
|
148
|
|
|
$sql = "INSERT INTO rd_ncftipo (". |
|
149
|
|
|
"tipocomprobante, descripcion, estado, clasemovimiento, ventas, compras, contribuyente". |
|
150
|
|
|
" ) VALUES " . |
|
151
|
|
|
"('01','FACTURA DE CREDITO FISCAL',true, 'suma','Y','Y','Y')," . |
|
152
|
|
|
"('02','FACTURA DE CONSUMO',true, 'suma','Y','Y','Y')," . |
|
153
|
|
|
"('03','NOTA DE DEBITO',true, 'suma','Y','Y','N')," . |
|
154
|
|
|
"('04','NOTA DE CREDITO',true, 'resta','Y','Y','N')," . |
|
155
|
|
|
"('11','COMPROBANTE DE COMPRAS',true, 'suma','N','Y','Y')," . |
|
156
|
|
|
"('12','REGISTRO UNICO DE INGRESOS',true, 'suma','Y','N','N')," . |
|
157
|
|
|
"('13','COMPROBANTE PARA GASTOS MENORES',true, 'suma','N','Y','N')," . |
|
158
|
|
|
"('14','COMPROBANTE DE REGIMENES ESPECIALES',true, 'suma','Y','Y','Y')," . |
|
159
|
|
|
"('15','COMPROBANTE GUBERNAMENTAL',true, 'suma','Y','Y','Y')," . |
|
160
|
|
|
"('16','COMPROBANTE PARA EXPORTACIONES',true, 'suma','Y','N','Y')," . |
|
161
|
|
|
"('17','COMPROBANTE PARA PAGOS AL EXTERIOR',true, 'suma','N', 'Y','Y');"; |
|
162
|
|
|
return($sql); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
public function restoreData() |
|
166
|
|
|
{ |
|
167
|
|
|
$dataBase = new DataBase(); |
|
168
|
|
|
$sqlClean = "DELETE FROM " . $this->tableName() . ";"; |
|
169
|
|
|
$dataBase->exec($sqlClean); |
|
170
|
|
|
foreach ($this->arrayComprobantes as $arrayItem) { |
|
171
|
|
|
$initialData = new NCFTipo($arrayItem); |
|
172
|
|
|
$initialData->save(); |
|
173
|
|
|
} |
|
174
|
|
|
$this->clear(); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function allFor($type = "ventas", $movimiento = "suma") |
|
178
|
|
|
{ |
|
179
|
|
|
$where = [new DataBaseWhere($type, 'Y'),new DataBaseWhere('clasemovimiento', $movimiento)]; |
|
180
|
|
|
return $this->all($where, ['tipocomprobante' => 'ASC'], 0, 50); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
public function tipoCliente($codcliente) { |
|
184
|
|
|
$where = [new DatabaseWhere( 'codcliente', $_REQUEST['codcliente'])]; |
|
|
|
|
|
|
185
|
|
|
$clientes = new Cliente(); |
|
186
|
|
|
$cliente = $clientes->get($codcliente); |
|
187
|
|
|
return ['tipocomprobante' => $cliente->tipocomprobante, 'ncftipopago' => $cliente->ncftipopago]; |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
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