Passed
Push — master ( 9c95d4...eee053 )
by Joe Nilson
03:19
created

NCFTipoPago   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 48
c 0
b 0
f 0
dl 0
loc 105
rs 10
wmc 6

5 Methods

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