FiscalReport608   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
c 1
b 0
f 0
dl 0
loc 56
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFields() 0 21 3
A getSQLFrom() 0 7 1
A getTables() 0 6 1
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
use FacturaScripts\Core\Tools;
22
23
24
class FiscalReport608 extends JoinModel
25
{
26
    const MAIN_TABLE = 'facturascli';
27
    const NCFCANCELTYPE_TABLE = 'rd_ncftipoanulacion';
28
    const ESTADOSDOC_TABLE = 'estados_documentos';
29
30
    /**
31
     *
32
     * @return array
33
     */
34
    protected function getFields(): array
35
    {
36
        $dateFormat = (FS_DB_TYPE === 'postgresql') ? "to_char" : "date_format";
0 ignored issues
show
Bug introduced by
The constant FacturaScripts\Plugins\f...a\Model\Join\FS_DB_TYPE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
37
        $dateFormatString = (FS_DB_TYPE === 'postgresql') ? "YYYYMMDD" : "%Y%m%d";
38
39
        $data = [
40
            'itemrow' => static::MAIN_TABLE.'.idfactura',
41
            'idempresa' => static::MAIN_TABLE.'.idempresa',
42
            'codalmacen' => static::MAIN_TABLE.'.codalmacen',
43
            'ncf' => static::MAIN_TABLE.'.numeroncf',
44
            'tipoanulacion' => 'CASE WHEN ' .
45
                                static::ESTADOSDOC_TABLE . '.nombre = \'Anulada\' AND ' .
46
                                static::MAIN_TABLE.'.ncftipoanulacion is null ' .
47
                                'THEN CONCAT(\'05\',\' - \',\'Corrección de la Información\') ELSE ' .
48
                                'concat(' . static::MAIN_TABLE.'.ncftipoanulacion, \' - \', ' .
49
                                static::NCFCANCELTYPE_TABLE.'.descripcion) END',
50
            'fecha' => $dateFormat.'('.static::MAIN_TABLE.'.fecha,\''.$dateFormatString.'\')',
51
            'estado' => 'CASE WHEN ' . static::ESTADOSDOC_TABLE .
52
                        '.nombre = \'Emitida\' THEN \'Activo\' ELSE \'Anulado\' END',
53
        ];
54
        return $data;
55
    }
56
57
    /**
58
     *
59
     * @return string
60
     */
61
    protected function getSQLFrom(): string
62
    {
63
        return static::MAIN_TABLE
64
            . ' JOIN ' . static::ESTADOSDOC_TABLE . ' ON ('
65
            . static::MAIN_TABLE . '.idestado = ' . static::ESTADOSDOC_TABLE . '.idestado AND '.static::ESTADOSDOC_TABLE.'.nombre = \'Anulada\')'
66
            . ' LEFT JOIN ' . static::NCFCANCELTYPE_TABLE . ' ON ('
67
            . static::MAIN_TABLE . '.ncftipoanulacion = ' . static::NCFCANCELTYPE_TABLE . '.codigo)';
68
    }
69
70
    /**
71
     *
72
     * @return array
73
     */
74
    protected function getTables(): array
75
    {
76
        return [
77
            static::MAIN_TABLE,
78
            static::NCFCANCELTYPE_TABLE,
79
            static::ESTADOSDOC_TABLE
80
        ];
81
    }
82
}
83