NCFTipoMovimiento::tableName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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\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...
27
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...
28
use FacturaScripts\Core\Tools;
29
30
31
/**
32
 * Description of NCFTipoMovimiento
33
 *
34
 * @author Joe Zegarra
35
 */
36
class NCFTipoMovimiento extends ModelClass
37
{
38
    use ModelTrait;
39
    /**
40
     * two digit string to identify the Payment Type
41
     * sales|purchase 01|02 options
42
     * @var string
43
     */
44
    public $tipomovimiento;
45
    /**
46
     * two digit string to identify the Payment Code
47
     * @var string
48
     */
49
    public $codigo;
50
    /**
51
     * The description of the Payment Type
52
     * @var string
53
     */
54
    public $descripcion;
55
    /**
56
     * The status of the record
57
     * @var bool
58
     */
59
    public $estado;
60
61
    
62
    /**
63
     * List of Movement types
64
     * @var array
65
     */
66
    private $arrayTiposMovimiento = [
67
        ['tipomovimiento'=>'COM','codigo' => '01', 'descripcion' => 'GASTOS DE PERSONAL', 'estado' => true],
68
        ['tipomovimiento'=>'COM','codigo' => '02', 'descripcion' => 'GASTOS POR TRABAJOS, SUMINISTROS Y SERVICIOS', 'estado' => true],
69
        ['tipomovimiento'=>'COM','codigo' => '03', 'descripcion' => 'ARRENDAMIENTOS', 'estado' => true],
70
        ['tipomovimiento'=>'COM','codigo' => '04', 'descripcion' => 'GASTOS DE ACTIVOS FIJOS', 'estado' => true],
71
        ['tipomovimiento'=>'COM','codigo' => '05', 'descripcion' => 'GASTOS DE REPRESENTACIÓN', 'estado' => true],
72
        ['tipomovimiento'=>'COM','codigo' => '06', 'descripcion' => 'OTRAS DEDUCCIONES ADMITIDAS', 'estado' => true],
73
        ['tipomovimiento'=>'COM','codigo' => '07', 'descripcion' => 'GASTOS FINANCIEROS', 'estado' => true],
74
        ['tipomovimiento'=>'COM','codigo' => '08', 'descripcion' => 'GASTOS EXTRAORDINARIOS', 'estado' => true],
75
        ['tipomovimiento'=>'COM','codigo' => '09', 'descripcion' => 'COMPRAS Y GASTOS QUE FORMARÁN PARTE DEL COSTO DE VENTA', 'estado' => true],
76
        ['tipomovimiento'=>'COM','codigo' => '10', 'descripcion' => 'ADQUISICIONES DE ACTIVOS', 'estado' => true],
77
        ['tipomovimiento'=>'COM','codigo' => '11', 'descripcion' => 'GASTOS DE SEGUROS', 'estado' => true],
78
        ['tipomovimiento'=>'VEN','codigo' => '1', 'descripcion' => 'Ingresos por operaciones (No financieros)', 'estado' => true],
79
        ['tipomovimiento'=>'VEN','codigo' => '2', 'descripcion' => 'Ingresos Financieros', 'estado' => true],
80
        ['tipomovimiento'=>'VEN','codigo' => '3', 'descripcion' => 'Ingresos Extraordinarios', 'estado' => true],
81
        ['tipomovimiento'=>'VEN','codigo' => '4', 'descripcion' => 'Ingresos por Arrendamientos', 'estado' => true],
82
        ['tipomovimiento'=>'VEN','codigo' => '5', 'descripcion' => 'Ingresos por Venta de Activo Depreciable', 'estado' => true],
83
        ['tipomovimiento'=>'VEN','codigo' => '6', 'descripcion' => 'Otros Ingresos', 'estado' => true]
84
    ];
85
    
86
    /**
87
     * @return string
88
     */
89
    public static function primaryColumn(): string
90
    {
91
        return 'id';
92
    }
93
    
94
    /**
95
     * @return string
96
     */
97
    public static function tableName(): string
98
    {
99
        return 'rd_ncftipomovimiento';
100
    }
101
    
102
    /**
103
     * @return string
104
     */
105
    public function install(): string
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): array
141
    {
142
        $where = [new DataBaseWhere('tipomovimiento', $tipomovimiento)];
143
        return $this->all($where, ['codigo' => 'ASC'], 0, 50);
144
    }
145
}
146