1
|
|
|
<?php |
2
|
|
|
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Model; |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
use FacturaScripts\Core\Base\DataBase; |
|
|
|
|
6
|
|
|
use FacturaScripts\Core\Model\Base\ModelClass; |
|
|
|
|
7
|
|
|
use FacturaScripts\Core\Model\Base\ModelTrait; |
|
|
|
|
8
|
|
|
use FacturaScripts\Core\Session; |
|
|
|
|
9
|
|
|
use FacturaScripts\Dinamic\Model\Impuesto; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class ImpuestoProducto extends ModelClass |
12
|
|
|
{ |
13
|
|
|
use ModelTrait; |
14
|
|
|
|
15
|
|
|
/** @var string */ |
16
|
|
|
public $codimpuesto; |
17
|
|
|
|
18
|
|
|
/** @var bool */ |
19
|
|
|
public $compra; |
20
|
|
|
|
21
|
|
|
/** @var string */ |
22
|
|
|
public $creationdate; |
23
|
|
|
|
24
|
|
|
/** @var int */ |
25
|
|
|
public $id; |
26
|
|
|
|
27
|
|
|
/** @var int */ |
28
|
|
|
public $idempresa; |
29
|
|
|
|
30
|
|
|
/** @var int */ |
31
|
|
|
public $idproducto; |
32
|
|
|
|
33
|
|
|
/** @var string */ |
34
|
|
|
public $lastnick; |
35
|
|
|
|
36
|
|
|
/** @var string */ |
37
|
|
|
public $lastupdate; |
38
|
|
|
|
39
|
|
|
/** @var string */ |
40
|
|
|
public $nick; |
41
|
|
|
|
42
|
|
|
/** @var bool */ |
43
|
|
|
public $venta; |
44
|
|
|
|
45
|
|
|
/** @var @var int */ |
|
|
|
|
46
|
|
|
public $porcentaje; |
47
|
|
|
|
48
|
|
|
public function clear() |
49
|
|
|
{ |
50
|
|
|
parent::clear(); |
51
|
|
|
$this->compra = false; |
52
|
|
|
$this->creationdate = date(self::DATETIME_STYLE); |
53
|
|
|
$this->idempresa = 0; |
54
|
|
|
$this->idproducto = null; |
55
|
|
|
$this->nick = Session::get('user')->nick ?? null; |
56
|
|
|
$this->venta = false; |
57
|
|
|
$this->porcentaje = 0; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public static function primaryColumn(): string |
61
|
|
|
{ |
62
|
|
|
return "id"; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public static function tableName(): string |
66
|
|
|
{ |
67
|
|
|
return "impuestosproductos"; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function test(): bool |
71
|
|
|
{ |
72
|
|
|
$this->codimpuesto = $this->toolBox()->utils()->noHtml($this->codimpuesto); |
73
|
|
|
$this->lastnick = $this->toolBox()->utils()->noHtml($this->lastnick); |
74
|
|
|
$this->nick = $this->toolBox()->utils()->noHtml($this->nick); |
75
|
|
|
return parent::test(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
protected function saveInsert(array $values = []): bool |
79
|
|
|
{ |
80
|
|
|
$this->lastupdate = null; |
81
|
|
|
$this->lastnick = null; |
82
|
|
|
return parent::saveInsert($values); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
protected function saveUpdate(array $values = []): bool |
86
|
|
|
{ |
87
|
|
|
$this->lastupdate = date(self::DATETIME_STYLE); |
88
|
|
|
$this->lastnick = Session::get('user')->nick ?? null; |
89
|
|
|
return parent::saveUpdate($values); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getTaxByProduct($idproducto, $rdtaxid, $use = 'venta'): ?ImpuestoProducto |
93
|
|
|
{ |
94
|
|
|
$dataBase = new DataBase(); |
95
|
|
|
$sql = "SELECT * FROM impuestosproductos WHERE idproducto = " . |
96
|
|
|
self::toolBox()->utils()->intval($idproducto) . |
97
|
|
|
" AND codimpuesto = '" . self::toolBox()->utils()->normalize($rdtaxid) . "'" . |
98
|
|
|
" AND " . $use . " = true" . ";"; |
99
|
|
|
$data = $dataBase->select($sql); |
100
|
|
|
if (empty($data) === true || in_array($data[0], [null, ''], true)) { |
101
|
|
|
return null; |
102
|
|
|
} |
103
|
|
|
$impuestos = new Impuesto(); |
104
|
|
|
$impuesto = $impuestos->get($data[0]['codimpuesto']); |
105
|
|
|
$data[0]['porcentaje'] = $impuesto->iva; |
106
|
|
|
return new ImpuestoProducto($data[0]); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths