NCFTipoAnulacion   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A primaryColumn() 0 3 1
A tableName() 0 3 1
A restoreData() 0 10 2
A install() 0 12 1
1
<?php
2
3
/*
4
 * Copyright (C) 2019 Joe Zegarra.
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 3 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301  USA
20
 */
21
22
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Model;
23
24
use FacturaScripts\Core\Base\DataBase;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\DataBase 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...
25
use FacturaScripts\Core\Template\ModelClass;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Template\ModelClass 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...
26
use FacturaScripts\Core\Template\ModelTrait;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Template\ModelTrait 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...
27
use FacturaScripts\Core\Tools;
28
29
30
/**
31
 * Description of NCFTipoAnulacion
32
 *
33
 * @author Joe Zegarra
34
 */
35
class NCFTipoAnulacion extends ModelClass
36
{
37
    use ModelTrait;
38
    
39
    /**
40
     * The key for the record
41
     * @var string
42
     */
43
    public $codigo;
44
    
45
    /**
46
     * The description of the record
47
     * @var string
48
     */
49
    public $descripcion;
50
    
51
    /**
52
     * The status of the record, true if is active
53
     * @var bool
54
     */
55
    public $estado;
56
    
57
    public $arrayTipoAnulacion = array(
58
        ['codigo' => '01', 'descripcion' => 'Deterioro de Factura Pre-Imprensa', 'estado' => true],
59
        ['codigo' => '02', 'descripcion' => 'Errores de Impresión (Factura Pre-Impresa)', 'estado' => true],
60
        ['codigo' => '03', 'descripcion' => 'Impresión defectuosa', 'estado' => true],
61
        ['codigo' => '04', 'descripcion' => 'Duplicidad de Factura', 'estado' => true],
62
        ['codigo' => '05', 'descripcion' => 'Corrección de la Información', 'estado' => true],
63
        ['codigo' => '06', 'descripcion' => 'Cambio de Productos', 'estado' => true],
64
        ['codigo' => '07', 'descripcion' => 'Devolución de Productos', 'estado' => true],
65
        ['codigo' => '08', 'descripcion' => 'Omisión de Productos', 'estado' => true]
66
    );
67
    
68
    public static function primaryColumn(): string
69
    {
70
        return 'codigo';
71
    }
72
73
    public static function tableName(): string
74
    {
75
        return 'rd_ncftipoanulacion';
76
    }
77
    
78
    public function install(): string
79
    {
80
        parent::install();
81
        return "INSERT INTO rd_ncftipoanulacion (codigo, descripcion, estado) VALUES " .
82
            "('01','Deterioro de Factura Pre-Imprensa',true), " .
83
             "('02','Errores de Impresión (Factura Pre-Impresa)',true), " .
84
             "('03','Impresión defectuosa',true), " .
85
             "('04','Duplicidad de Factura',true), " .
86
             "('05','Corrección de la Información',true), " .
87
             "('06','Cambio de Productos',true), " .
88
             "('07','Devolución de Productos',true), " .
89
             "('08','Omisión de Productos',true);";
90
    }
91
    
92
    public function restoreData()
93
    {
94
        $dataBase = new DataBase();
95
        $sqlClean = "DELETE FROM " . $this->tableName() . ";";
96
        $dataBase->exec($sqlClean);
97
        foreach ($this->arrayTipoAnulacion as $arrayItem) {
98
            $initialData = new NCFTipoAnulacion($arrayItem);
99
            $initialData->save();
100
        }
101
        $this->clear();
102
    }
103
}
104