Passed
Push — master ( 8a423f...9c95d4 )
by Joe Nilson
01:52
created

NCFTipoPago::install()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 18
rs 9.7333
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 NCFTipoPago
29
 *
30
 * @author Joe Zegarra
31
 */
32
class NCFTipoPago 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
     * two digit string to identify the Payment Type 
37
     * sales|purchase 01|02 options
38
     * @var string
39
     */
40
    public $tipopago;    
41
    /**
42
     * two digit string to identify the Payment Code
43
     * @var string
44
     */
45
    public $codigo;
46
    /**
47
     * The description of the Payment Type
48
     * @var string
49
     */
50
    public $descripcion;
51
    /**
52
     * The status of the record
53
     * @var bool 
54
     */
55
    public $estado;
56
57
    
58
    /**
59
     * List of Payment types
60
     * @var array
61
     */
62
    public $arrayTipos = array(
63
        array ('tipopago'=>'01','codigo' => '17', 'descripcion' => 'EFECTIVO','estado'=>true),
64
        array ('tipopago'=>'01','codigo' => '18', 'descripcion' => 'CHEQUES/TRANSFERENCIAS/DEPOSITO','estado'=>true),
65
        array ('tipopago'=>'01','codigo' => '19', 'descripcion' => 'TARJETA CRÉDITO/DÉBITO','estado'=>true),
66
        array ('tipopago'=>'01','codigo' => '20', 'descripcion' => 'VENTA A CREDITO','estado'=>true),
67
        array ('tipopago'=>'01','codigo' => '21', 'descripcion' => 'BONOS O CERTIFICADOS DE REGALO','estado'=>true),
68
        array ('tipopago'=>'01','codigo' => '22', 'descripcion' => 'PERMUTA','estado'=>true),
69
        array ('tipopago'=>'01','codigo' => '23', 'descripcion' => 'OTRAS FORMAS DE VENTAS','estado'=>true),
70
        array ('tipopago'=>'02','codigo' => '01', 'descripcion' => 'EFECTIVO','estado'=>true),
71
        array ('tipopago'=>'02','codigo' => '02', 'descripcion' => 'CHEQUES/TRANSFERENCIAS/DEPOSITO','estado'=>true),
72
        array ('tipopago'=>'02','codigo' => '03', 'descripcion' => 'TARJETA CRÉDITO/DÉBITO','estado'=>true),
73
        array ('tipopago'=>'02','codigo' => '04', 'descripcion' => 'COMPRA A CREDITO','estado'=>true),
74
        array ('tipopago'=>'02','codigo' => '05', 'descripcion' => 'PERMUTA','estado'=>true),
75
        array ('tipopago'=>'02','codigo' => '06', 'descripcion' => 'NOTA DE CREDITO','estado'=>true),
76
        array ('tipopago'=>'02','codigo' => '07', 'descripcion' => 'MIXTO','estado'=>true)
77
    );
78
    
79
    /**
80
     * 
81
     * @return string
82
     */
83
    public static function primaryColumn()
84
    {
85
        return 'codigo';
86
    }
87
    
88
    /**
89
     * 
90
     * @return string
91
     */
92
    public static function tableName()
93
    {
94
        return 'rd_ncftipopagos';
95
    }
96
    
97
    /**
98
     * 
99
     * @return string
100
     */
101
    public function install() 
102
    {
103
        parent::install();
104
        return "INSERT INTO rd_ncftipopagos (tipopago, codigo, descripcion, estado) VALUES " .
105
            "('01','17','EFECTIVO',true), " .
106
            "('01','18','CHEQUES/TRANSFERENCIAS/DEPOSITO',true), " .
107
            "('01','19','TARJETA CRÉDITO/DÉBITO',true), " .
108
            "('01','20','VENTA A CRÉDITO',true), " .
109
            "('01','21','BONOS O CERTIFICADOS DE REGALO',true), " .
110
            "('01','22','PERMUTA',true), " .
111
            "('01','23','OTRAS FORMAS DE VENTAS',true), " .
112
            "('02','01','EFECTIVO',true), " .
113
            "('02','02','CHEQUES/TRANSFERENCIAS/DEPOSITO',true), " .
114
            "('02','03','TARJETA CRÉDITO/DÉBITO',true), " .
115
            "('02','04','COMPRA A CREDITO',true), " .
116
            "('02','05','PERMUTA',true), " .
117
            "('02','06','NOTA DE CREDITO',true), " .
118
            "('02','07','MIXTO',true);";
119
    }
120
    
121
    public function restoreData()
122
    {
123
        $dataBase = new DataBase();
124
        $sqlClean = "DELETE FROM " . $this->tableName() . ";";
125
        $dataBase->exec($sqlClean);
126
        foreach ($this->arrayTipos as $arrayItem) {
127
            $initialData = new NCFTipoPago($arrayItem);
128
            $initialData->save();
129
        }
130
        $this->clear();
131
    }
132
}
133