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

NCFTipoMovimiento   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 54
c 1
b 0
f 0
dl 0
loc 111
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 3 1
A primaryColumn() 0 3 1
A install() 0 21 1
A restoreData() 0 10 2
A findAllByTipomovimiento() 0 4 1
1
<?php
2
3
/*
4
 * Copyright (C) 2020 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 NCFTipoMovimiento
30
 *
31
 * @author Joe Zegarra
32
 */
33
class NCFTipoMovimiento 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 $tipomovimiento;
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 Movement types
61
     * @var array
62
     */
63
    private $arrayTiposMovimiento = array(
64
        array ('tipomovimiento'=>'COM','codigo' => '01', 'descripcion' => 'GASTOS DE PERSONAL', 'estado' => true),
65
        array ('tipomovimiento'=>'COM','codigo' => '02', 'descripcion' => 'GASTOS POR TRABAJOS, SUMINISTROS Y SERVICIOS', 'estado' => true),
66
        array ('tipomovimiento'=>'COM','codigo' => '03', 'descripcion' => 'ARRENDAMIENTOS', 'estado' => true),
67
        array ('tipomovimiento'=>'COM','codigo' => '04', 'descripcion' => 'GASTOS DE ACTIVOS FIJOS', 'estado' => true),
68
        array ('tipomovimiento'=>'COM','codigo' => '05', 'descripcion' => 'GASTOS DE REPRESENTACIÓN', 'estado' => true),
69
        array ('tipomovimiento'=>'COM','codigo' => '06', 'descripcion' => 'OTRAS DEDUCCIONES ADMITIDAS', 'estado' => true),
70
        array ('tipomovimiento'=>'COM','codigo' => '07', 'descripcion' => 'GASTOS FINANCIEROS', 'estado' => true),
71
        array ('tipomovimiento'=>'COM','codigo' => '08', 'descripcion' => 'GASTOS EXTRAORDINARIOS', 'estado' => true),
72
        array ('tipomovimiento'=>'COM','codigo' => '09', 'descripcion' => 'COMPRAS Y GASTOS QUE FORMARÁN PARTE DEL COSTO DE VENTA', 'estado' => true),
73
        array ('tipomovimiento'=>'COM','codigo' => '10', 'descripcion' => 'ADQUISICIONES DE ACTIVOS', 'estado' => true),
74
        array ('tipomovimiento'=>'COM','codigo' => '11', 'descripcion' => 'GASTOS DE SEGUROS', 'estado' => true),
75
        array ('tipomovimiento'=>'VEN','codigo' => '1', 'descripcion' => 'Ingresos por operaciones (No financieros)', 'estado' => true),
76
        array ('tipomovimiento'=>'VEN','codigo' => '2', 'descripcion' => 'Ingresos Financieros', 'estado' => true),
77
        array ('tipomovimiento'=>'VEN','codigo' => '3', 'descripcion' => 'Ingresos Extraordinarios', 'estado' => true),
78
        array ('tipomovimiento'=>'VEN','codigo' => '4', 'descripcion' => 'Ingresos por Arrendamientos', 'estado' => true),
79
        array ('tipomovimiento'=>'VEN','codigo' => '5', 'descripcion' => 'Ingresos por Venta de Activo Depreciable', 'estado' => true),
80
        array ('tipomovimiento'=>'VEN','codigo' => '6', 'descripcion' => 'Otros Ingresos', 'estado' => true)
81
    );
82
    
83
    /**
84
     * 
85
     * @return string
86
     */
87
    public static function primaryColumn()
88
    {
89
        return 'id';
90
    }
91
    
92
    /**
93
     * 
94
     * @return string
95
     */
96
    public static function tableName()
97
    {
98
        return 'rd_ncftipomovimiento';
99
    }
100
    
101
    /**
102
     * 
103
     * @return string
104
     */
105
    public function install() 
106
    {
107
        parent::install();
108
        return "INSERT INTO rd_ncftipomovimiento (tipomovimiento, codigo, descripcion, estado) VALUES " .
109
            "('COM','01','GASTOS DE PERSONAL',true), ".
110
            "('COM','02','GASTOS POR TRABAJOS, SUMINISTROS Y SERVICIOS',true), ".
111
            "('COM','03','ARRENDAMIENTOS',true), ".
112
            "('COM','04','GASTOS DE ACTIVOS FIJOS',true), ".
113
            "('COM','05','GASTOS DE REPRESENTACIÓN',true), ".
114
            "('COM','06','OTRAS DEDUCCIONES ADMITIDAS',true), ".
115
            "('COM','07','GASTOS FINANCIEROS',true), ".
116
            "('COM','08','GASTOS EXTRAORDINARIOS',true), ".
117
            "('COM','09','COMPRAS Y GASTOS QUE FORMARÁN PARTE DEL COSTO DE VENTA',true), ".
118
            "('COM','10','ADQUISICIONES DE ACTIVOS',true), ".
119
            "('COM','11','GASTOS DE SEGUROS',true), ".
120
            "('VEN','1','Ingresos por operaciones (No financieros)',true), ".
121
            "('VEN','2','Ingresos Financieros',true), ".
122
            "('VEN','3','Ingresos Extraordinarios',true), ".
123
            "('VEN','4','Ingresos por Arrendamientos',true), ".
124
            "('VEN','5','Ingresos por Venta de Activo Depreciable',true), ".
125
            "('VEN','6','Otros Ingresos',true);";
126
    }
127
    
128
    public function restoreData()
129
    {
130
        $dataBase = new DataBase();
131
        $sqlClean = "DELETE FROM " . $this->tableName() . ";";
132
        $dataBase->exec($sqlClean);
133
        foreach ($this->arrayTiposMovimiento as $arrayItem) {
134
            $initialData = new NCFTipoMovimiento($arrayItem);
135
            $initialData->save();
136
        }
137
        $this->clear();
138
    }
139
140
    public function findAllByTipomovimiento(string $tipomovimiento)
141
    {
142
        $where = [new DataBaseWhere('tipomovimiento', $tipomovimiento)];
143
        return $this->all($where, ['codigo' => 'ASC'], 0, 50);
144
    }
145
}
146