|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (C) 2022 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\Model\Join; |
|
19
|
|
|
|
|
20
|
|
|
use FacturaScripts\Core\Model\Base\JoinModel; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class FiscalReport607 extends JoinModel |
|
23
|
|
|
{ |
|
24
|
|
|
const MAIN_TABLE = 'facturascli'; |
|
25
|
|
|
const SECONDARY_TABLE = 'facturascli AS f2'; |
|
26
|
|
|
const SECONDARY_TABLE_ALIAS = 'f2'; |
|
27
|
|
|
const ESTADOSDOC_TABLE = 'estados_documentos'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* |
|
31
|
|
|
* @return array |
|
32
|
|
|
*/ |
|
33
|
|
|
protected function getFields(): array |
|
34
|
|
|
{ |
|
35
|
|
|
$data = [ |
|
36
|
|
|
'itemrow' => 'rank() over (order by '.static::MAIN_TABLE.'.numero2)', |
|
37
|
|
|
'idempresa' => static::MAIN_TABLE.'.idempresa', |
|
38
|
|
|
'codalmacen' => static::MAIN_TABLE.'.codalmacen', |
|
39
|
|
|
'cifnif' => 'CASE WHEN length('.static::MAIN_TABLE.'.cifnif)=9 THEN '.static::MAIN_TABLE.'.cifnif WHEN length('.static::MAIN_TABLE.'.cifnif)=11 THEN '.static::MAIN_TABLE.'.cifnif ELSE NULL END', |
|
40
|
|
|
'tipoid' => 'CASE WHEN length('.static::MAIN_TABLE.'.cifnif)=9 THEN 1 WHEN length('.static::MAIN_TABLE.'.cifnif)=11 THEN 2 ELSE 3 END', |
|
41
|
|
|
'ncf' => static::MAIN_TABLE.'.numero2', |
|
42
|
|
|
'ncfmodifica' => static::SECONDARY_TABLE_ALIAS.'.numero2', |
|
43
|
|
|
'tipoingreso' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipomovimiento is null THEN \'1\' ELSE '.static::MAIN_TABLE.'.ncftipomovimiento END', |
|
44
|
|
|
'fecha' => 'to_char('.static::MAIN_TABLE.'.fecha,\'YYYYMMDD\')', |
|
45
|
|
|
'fecharetencion' => '\'\'', |
|
46
|
|
|
'base' => 'CASE WHEN '.static::ESTADOSDOC_TABLE.'.nombre = \'Anulada\' THEN 0 WHEN '.static::ESTADOSDOC_TABLE.'.nombre = \'Emitida\' AND '.static::MAIN_TABLE.'.neto < 0 THEN '.static::MAIN_TABLE.'.neto*-1 ELSE '.static::MAIN_TABLE.'.neto END', |
|
47
|
|
|
'itbis' => 'CASE WHEN '.static::ESTADOSDOC_TABLE.'.nombre = \'Anulada\' THEN 0 WHEN '.static::ESTADOSDOC_TABLE.'.nombre = \'Emitida\' AND '.static::MAIN_TABLE.'.totaliva < 0 THEN '.static::MAIN_TABLE.'.totaliva*-1 ELSE '.static::MAIN_TABLE.'.totaliva END', |
|
48
|
|
|
'itbisretenido' => '0', |
|
49
|
|
|
'itbispercibido' => '0', |
|
50
|
|
|
'rentaretenido' => '0', |
|
51
|
|
|
'rentapercibido' => '0', |
|
52
|
|
|
'isc' => '0', |
|
53
|
|
|
'otrosimpuestos' => '0', |
|
54
|
|
|
'propinalegal' => '0', |
|
55
|
|
|
'totalefectivo' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipopago IS NULL OR '.static::MAIN_TABLE.'.ncftipopago = \'\' OR '.static::MAIN_TABLE.'.ncftipopago = \'17\' THEN '.static::MAIN_TABLE.'.neto else 0 END', |
|
56
|
|
|
'totalcheque' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipopago = \'18\' THEN '.static::MAIN_TABLE.'.neto else 0 END', |
|
57
|
|
|
'totaltarjeta' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipopago = \'19\' THEN '.static::MAIN_TABLE.'.neto else 0 END', |
|
58
|
|
|
'totalcredito' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipopago = \'20\' THEN '.static::MAIN_TABLE.'.neto else 0 END', |
|
59
|
|
|
'totalbonos' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipopago = \'21\' THEN '.static::MAIN_TABLE.'.neto else 0 END', |
|
60
|
|
|
'totalpermuta' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipopago = \'22\' THEN '.static::MAIN_TABLE.'.neto else 0 END', |
|
61
|
|
|
'totalotrasformas' => 'CASE WHEN '.static::MAIN_TABLE.'.ncftipopago = \'23\' THEN '.static::MAIN_TABLE.'.neto else 0 END', |
|
62
|
|
|
'estado' => 'CASE WHEN '.static::ESTADOSDOC_TABLE.'.nombre = \'Emitida\' THEN \'Activo\' ELSE \'Anulado\' END', |
|
63
|
|
|
]; |
|
64
|
|
|
return $data; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function getSQLFrom(): string |
|
72
|
|
|
{ |
|
73
|
|
|
return static::MAIN_TABLE |
|
74
|
|
|
. ' LEFT JOIN '. static::SECONDARY_TABLE . ' ON (' |
|
75
|
|
|
. static::MAIN_TABLE . '.idfacturarect = ' . static::SECONDARY_TABLE_ALIAS . '.idfactura)' |
|
76
|
|
|
. ' LEFT JOIN ' . static::ESTADOSDOC_TABLE . ' ON (' |
|
77
|
|
|
. static::MAIN_TABLE . '.idestado = ' . static::ESTADOSDOC_TABLE . '.idestado)'; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* |
|
82
|
|
|
* @return array |
|
83
|
|
|
*/ |
|
84
|
|
|
protected function getTables(): array |
|
85
|
|
|
{ |
|
86
|
|
|
return [ |
|
87
|
|
|
static::MAIN_TABLE, |
|
88
|
|
|
static::ESTADOSDOC_TABLE |
|
89
|
|
|
]; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
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