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 FiscalReports extends JoinModel |
23
|
|
|
{ |
24
|
|
|
const MAIN_TABLE = 'facturascli'; |
25
|
|
|
const SECONDARY_TABLE = 'facturascli AS f2'; |
26
|
|
|
const SECONDARY_TABLE_ALIAS = 'f2'; |
27
|
|
|
const LINES_TABLE = 'lineasfacturascli'; |
28
|
|
|
const ALMACENES_TABLE = 'almacenes'; |
29
|
|
|
const NCFTIPO_TABLE = 'rd_ncftipo'; |
30
|
|
|
const NCFTIPOMOV_TABLE = 'rd_ncftipomovimiento'; |
31
|
|
|
const NCFTIPOANUL_TABLE = 'rd_ncftipoanulacion'; |
32
|
|
|
const NCFTIPOPAGO_TABLE = 'rd_ncftipopagos'; |
33
|
|
|
const ESTADOSDOC_TABLE = 'estados_documentos'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
|
|
protected function getFields(): array |
40
|
|
|
{ |
41
|
|
|
$dateFormat = (FS_DB_TYPE === 'postgresql') ? "to_char" : "date_format"; |
|
|
|
|
42
|
|
|
$dateFormatString = (FS_DB_TYPE === 'postgresql') ? "YYYYMMDD" : "%Y%m%d"; |
|
|
|
|
43
|
|
|
|
44
|
|
|
$data = [ |
45
|
|
|
'idfactura' => static::MAIN_TABLE.'.idfactura', |
46
|
|
|
'idempresa' => static::MAIN_TABLE.'.idempresa', |
47
|
|
|
'fecha' => static::MAIN_TABLE.'.fecha', |
48
|
|
|
'codalmacen' => static::MAIN_TABLE.'.codalmacen', |
49
|
|
|
'almacen' => static::ALMACENES_TABLE.'.nombre', |
50
|
|
|
'cliente' => static::MAIN_TABLE.'.nombrecliente', |
51
|
|
|
'cifnif' => static::MAIN_TABLE.'.cifnif', |
52
|
|
|
'ncf' => static::MAIN_TABLE.'.numeroncf', |
53
|
|
|
'baseimponible' => 'sum(case when '.static::LINES_TABLE.'.iva != 0 then '.static::LINES_TABLE.'.pvptotal else 0 end)', |
54
|
|
|
'baseexenta' => 'sum(case when '.static::LINES_TABLE.'.iva = 0 then '.static::LINES_TABLE.'.pvptotal else 0 end)', |
55
|
|
|
'itbis' => static::MAIN_TABLE.'.totaliva', |
56
|
|
|
'total' => static::MAIN_TABLE.'.total', |
57
|
|
|
'pagada' => static::MAIN_TABLE.'.pagada', |
58
|
|
|
'estado' => static::ESTADOSDOC_TABLE.'.nombre', |
59
|
|
|
'ncfmodifica' => static::SECONDARY_TABLE_ALIAS.'.numeroncf', |
60
|
|
|
'tipocomprobante' => static::NCFTIPO_TABLE.'.descripcion', |
61
|
|
|
'tipopago' => static::NCFTIPOPAGO_TABLE.'.descripcion', |
62
|
|
|
'tipomovimiento' => static::NCFTIPOMOV_TABLE.'.descripcion', |
63
|
|
|
'tipoanulacion' => static::NCFTIPOANUL_TABLE.'.descripcion', |
64
|
|
|
]; |
65
|
|
|
return $data; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
protected function getGroupFields(): string |
73
|
|
|
{ |
74
|
|
|
return static::MAIN_TABLE.'.idfactura, '. |
75
|
|
|
static::MAIN_TABLE.'.idempresa, '. |
76
|
|
|
static::MAIN_TABLE.'.fecha, '. |
77
|
|
|
static::MAIN_TABLE.'.codalmacen, '. |
78
|
|
|
static::ALMACENES_TABLE.'.nombre, '. |
79
|
|
|
static::MAIN_TABLE.'.nombrecliente, '. |
80
|
|
|
static::MAIN_TABLE.'.cifnif, '. |
81
|
|
|
static::MAIN_TABLE.'.numeroncf, '. |
82
|
|
|
static::MAIN_TABLE.'.total, '. |
83
|
|
|
static::MAIN_TABLE.'.totaliva, '. |
84
|
|
|
static::MAIN_TABLE.'.pagada, '. |
85
|
|
|
static::ESTADOSDOC_TABLE.'.nombre, '. |
86
|
|
|
static::SECONDARY_TABLE_ALIAS.'.numeroncf, '. |
87
|
|
|
static::NCFTIPO_TABLE.'.descripcion, '. |
88
|
|
|
static::NCFTIPOPAGO_TABLE.'.descripcion, '. |
89
|
|
|
static::NCFTIPOMOV_TABLE.'.descripcion, '. |
90
|
|
|
static::NCFTIPOANUL_TABLE.'.descripcion'; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
protected function getSQLFrom(): string |
98
|
|
|
{ |
99
|
|
|
return static::MAIN_TABLE |
100
|
|
|
. ' LEFT JOIN ' . static::LINES_TABLE . ' ON (' |
101
|
|
|
. static::MAIN_TABLE . '.idfactura = ' . static::LINES_TABLE . '.idfactura)' |
102
|
|
|
. ' LEFT JOIN '. static::SECONDARY_TABLE . ' ON (' |
103
|
|
|
. static::MAIN_TABLE . '.idfacturarect = ' . static::SECONDARY_TABLE_ALIAS . '.idfactura)' |
104
|
|
|
. ' LEFT JOIN '. static::ALMACENES_TABLE . ' ON (' |
105
|
|
|
. static::MAIN_TABLE . '.codalmacen = ' . static::ALMACENES_TABLE . '.codalmacen)' |
106
|
|
|
. ' LEFT JOIN '. static::NCFTIPO_TABLE . ' ON (' |
107
|
|
|
. static::MAIN_TABLE . '.tipocomprobante = ' . static::NCFTIPO_TABLE . '.tipocomprobante)' |
108
|
|
|
. ' LEFT JOIN ' . static::NCFTIPOPAGO_TABLE . ' ON (' |
109
|
|
|
. static::MAIN_TABLE . '.ncftipopago = ' . static::NCFTIPOPAGO_TABLE . '.codigo)' |
110
|
|
|
. ' LEFT JOIN ' . static::NCFTIPOMOV_TABLE . ' ON (' |
111
|
|
|
. static::MAIN_TABLE . '.ncftipomovimiento = ' . static::NCFTIPOMOV_TABLE . '.codigo)' |
112
|
|
|
. ' LEFT JOIN ' . static::NCFTIPOANUL_TABLE . ' ON (' |
113
|
|
|
. static::MAIN_TABLE . '.ncftipoanulacion = ' . static::NCFTIPOANUL_TABLE . '.codigo)' |
114
|
|
|
. ' LEFT JOIN ' . static::ESTADOSDOC_TABLE . ' ON (' |
115
|
|
|
. static::MAIN_TABLE . '.idestado = ' . static::ESTADOSDOC_TABLE . '.idestado)'; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* |
120
|
|
|
* @return array |
121
|
|
|
*/ |
122
|
|
|
protected function getTables(): array |
123
|
|
|
{ |
124
|
|
|
return [ |
125
|
|
|
static::MAIN_TABLE, |
126
|
|
|
static::ALMACENES_TABLE, |
127
|
|
|
static::LINES_TABLE, |
128
|
|
|
static::NCFTIPO_TABLE, |
129
|
|
|
static::NCFTIPOANUL_TABLE, |
130
|
|
|
static::NCFTIPOMOV_TABLE, |
131
|
|
|
static::NCFTIPOPAGO_TABLE, |
132
|
|
|
static::ESTADOSDOC_TABLE |
133
|
|
|
]; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
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