Passed
Push — master ( 1e4dff...7f4dae )
by Joe Nilson
03:57 queued 15s
created

FiscalReport608::getFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.7666
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;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Model\Base\JoinModel was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
22
class FiscalReport608 extends JoinModel
23
{
24
    const MAIN_TABLE = 'facturascli';
25
    const NCFCANCELTYPE_TABLE = 'rd_ncftipoanulacion';
26
    const ESTADOSDOC_TABLE = 'estados_documentos';
27
28
    /**
29
     *
30
     * @return array
31
     */
32
    protected function getFields(): array
33
    {
34
        $data = [
35
            'itemrow' => 'rank() over (order by '.static::MAIN_TABLE.'.numero2)',
36
            'idempresa' => static::MAIN_TABLE.'.idempresa',
37
            'codalmacen' => static::MAIN_TABLE.'.codalmacen',
38
            'ncf' => static::MAIN_TABLE.'.numero2',
39
            'tipoanulacion' => 'CASE WHEN ' .
40
                                static::ESTADOSDOC_TABLE . '.nombre = \'Anulada\' AND ' .
41
                                static::MAIN_TABLE.'.ncftipoanulacion is null ' .
42
                                'THEN CONCAT(\'05\',\' - \',\'Corrección de la Información\') ELSE ' .
43
                                'concat(' . static::MAIN_TABLE.'.ncftipoanulacion, \' - \', ' .
44
                                static::NCFCANCELTYPE_TABLE.'.descripcion) END',
45
            'fecha' => 'to_char('.static::MAIN_TABLE.'.fecha,\'YYYYMMDD\')',
46
            'estado' => 'CASE WHEN ' . static::ESTADOSDOC_TABLE .
47
                        '.nombre = \'Emitida\' THEN \'Activo\' ELSE \'Anulado\' END',
48
        ];
49
        return $data;
50
    }
51
52
    /**
53
     *
54
     * @return string
55
     */
56
    protected function getSQLFrom(): string
57
    {
58
        return static::MAIN_TABLE
59
            . ' JOIN ' . static::ESTADOSDOC_TABLE . ' ON ('
60
            . static::MAIN_TABLE . '.idestado = ' . static::ESTADOSDOC_TABLE . '.idestado AND '.static::ESTADOSDOC_TABLE.'.nombre = \'Anulada\')'
61
            . ' LEFT JOIN ' . static::NCFCANCELTYPE_TABLE . ' ON ('
62
            . static::MAIN_TABLE . '.ncftipoanulacion = ' . static::NCFCANCELTYPE_TABLE . '.codigo)';
63
    }
64
65
    /**
66
     *
67
     * @return array
68
     */
69
    protected function getTables(): array
70
    {
71
        return [
72
            static::MAIN_TABLE,
73
            static::NCFCANCELTYPE_TABLE,
74
            static::ESTADOSDOC_TABLE
75
        ];
76
    }
77
}
78