NCFTipoAnulacion::restoreData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
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\Model\Base;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Model\Base 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
27
/**
28
 * Description of NCFTipoAnulacion
29
 *
30
 * @author Joe Zegarra
31
 */
32
class NCFTipoAnulacion extends Base\ModelClass
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Model\Base\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...
33
{
34
    use Base\ModelTrait;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Model\Base\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...
35
    
36
    /**
37
     * The key for the record
38
     * @var string
39
     */
40
    public $codigo;
41
    
42
    /**
43
     * The description of the record
44
     * @var string
45
     */
46
    public $descripcion;
47
    
48
    /**
49
     * The status of the record, true if is active
50
     * @var bool
51
     */
52
    public $estado;
53
    
54
    public $arrayTipoAnulacion = array(
55
        ['codigo' => '01', 'descripcion' => 'Deterioro de Factura Pre-Imprensa', 'estado' => true],
56
        ['codigo' => '02', 'descripcion' => 'Errores de Impresión (Factura Pre-Impresa)', 'estado' => true],
57
        ['codigo' => '03', 'descripcion' => 'Impresión defectuosa', 'estado' => true],
58
        ['codigo' => '04', 'descripcion' => 'Duplicidad de Factura', 'estado' => true],
59
        ['codigo' => '05', 'descripcion' => 'Corrección de la Información', 'estado' => true],
60
        ['codigo' => '06', 'descripcion' => 'Cambio de Productos', 'estado' => true],
61
        ['codigo' => '07', 'descripcion' => 'Devolución de Productos', 'estado' => true],
62
        ['codigo' => '08', 'descripcion' => 'Omisión de Productos', 'estado' => true]
63
    );
64
    
65
    public static function primaryColumn(): string
66
    {
67
        return 'codigo';
68
    }
69
70
    public static function tableName(): string
71
    {
72
        return 'rd_ncftipoanulacion';
73
    }
74
    
75
    public function install(): string
76
    {
77
        parent::install();
78
        return "INSERT INTO rd_ncftipoanulacion (codigo, descripcion, estado) VALUES " .
79
            "('01','Deterioro de Factura Pre-Imprensa',true), " .
80
             "('02','Errores de Impresión (Factura Pre-Impresa)',true), " .
81
             "('03','Impresión defectuosa',true), " .
82
             "('04','Duplicidad de Factura',true), " .
83
             "('05','Corrección de la Información',true), " .
84
             "('06','Cambio de Productos',true), " .
85
             "('07','Devolución de Productos',true), " .
86
             "('08','Omisión de Productos',true);";
87
    }
88
    
89
    public function restoreData()
90
    {
91
        $dataBase = new DataBase();
92
        $sqlClean = "DELETE FROM " . $this->tableName() . ";";
93
        $dataBase->exec($sqlClean);
94
        foreach ($this->arrayTipoAnulacion as $arrayItem) {
95
            $initialData = new NCFTipoAnulacion($arrayItem);
96
            $initialData->save();
97
        }
98
        $this->clear();
99
    }
100
}
101