forked from NeoRazorX/facturascripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegimenIVA.php
More file actions
141 lines (128 loc) · 5.35 KB
/
RegimenIVA.php
File metadata and controls
141 lines (128 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2013-2026 Carlos Garcia Gomez <carlos@facturascripts.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace FacturaScripts\Core\Lib;
/**
* This class centralizes all common method for VAT Regime.
*
* @author Carlos García Gómez <carlos@facturascripts.com>
* @collaborator Daniel Fernández Giménez <hola@danielfg.es>
*/
class RegimenIVA
{
// Deprecated: use TaxExceptions constants.
const ES_TAX_EXCEPTION_E1 = TaxExceptions::ES_TAX_EXCEPTION_20;
const ES_TAX_EXCEPTION_E2 = TaxExceptions::ES_TAX_EXCEPTION_21;
const ES_TAX_EXCEPTION_E3 = TaxExceptions::ES_TAX_EXCEPTION_22;
const ES_TAX_EXCEPTION_E4 = TaxExceptions::ES_TAX_EXCEPTION_23_24;
const ES_TAX_EXCEPTION_E5 = TaxExceptions::ES_TAX_EXCEPTION_25;
const ES_TAX_EXCEPTION_E6 = TaxExceptions::ES_TAX_EXCEPTION_OTHER;
const ES_TAX_EXCEPTION_N1 = TaxExceptions::ES_TAX_EXCEPTION_7;
const ES_TAX_EXCEPTION_N2 = TaxExceptions::ES_TAX_EXCEPTION_68_70;
const ES_TAX_EXCEPTION_PASSIVE_SUBJECT = TaxExceptions::ES_TAX_EXCEPTION_84;
const TAX_SYSTEM_AGRARIAN = 'Agrario';
const TAX_SYSTEM_CASH_CRITERIA = 'Caja';
const TAX_SYSTEM_EXEMPT = 'Exento';
const TAX_SYSTEM_GENERAL = 'General';
const TAX_SYSTEM_GOLD = 'Oro';
const TAX_SYSTEM_GROUP_ENTITIES = 'Grupo entidades';
const TAX_SYSTEM_ONE_STOP_SHOP_OSS = 'One Stop Shop (OSS)';
const TAX_SYSTEM_ONE_STOP_SHOP_IOSS = 'One Stop Shop (IOSS)';
const TAX_SYSTEM_SIMPLIFIED = 'Simplificado';
const TAX_SYSTEM_SPECIAL_SMALL_BUSINESS = 'Pequeño empresario';
const TAX_SYSTEM_SURCHARGE = 'Recargo';
const TAX_SYSTEM_TRAVEL = 'Agencias de viaje';
const TAX_SYSTEM_USED_GOODS = 'Bienes usados';
/** @var array */
private static $values = [];
/** @var array */
private static $removedValues = [];
public static function add(string $key, string $value): void
{
$fixedKey = substr($key, 0, 20);
self::$values[$fixedKey] = $value;
unset(self::$removedValues[$fixedKey]);
}
/**
* @deprecated Use TaxExceptions::add() instead.
*/
public static function addException(string $key, string $value): void
{
TaxExceptions::add($key, $value);
}
public static function remove(string $key): void
{
$fixedKey = substr($key, 0, 20);
unset(self::$values[$fixedKey]);
self::$removedValues[$fixedKey] = true;
}
/**
* @deprecated Use TaxExceptions::remove() instead.
*/
public static function removeException(string $key): void
{
TaxExceptions::remove($key);
}
public static function all(): array
{
$defaultValues = [
self::TAX_SYSTEM_EXEMPT => 'es-tax-regime-exempt',
self::TAX_SYSTEM_GENERAL => 'es-tax-regime-general',
self::TAX_SYSTEM_SURCHARGE => 'es-tax-regime-surcharge',
self::TAX_SYSTEM_SIMPLIFIED => 'es-tax-regime-simplified',
self::TAX_SYSTEM_AGRARIAN => 'es-tax-regime-agrarian',
self::TAX_SYSTEM_CASH_CRITERIA => 'es-tax-regime-cash-criteria',
self::TAX_SYSTEM_GROUP_ENTITIES => 'es-tax-regime-group-entities',
self::TAX_SYSTEM_TRAVEL => 'es-tax-regime-travel',
self::TAX_SYSTEM_USED_GOODS => 'es-tax-regime-used-goods',
self::TAX_SYSTEM_GOLD => 'es-tax-regime-gold',
self::TAX_SYSTEM_SPECIAL_SMALL_BUSINESS => 'es-tax-regime-special-small-business',
self::TAX_SYSTEM_ONE_STOP_SHOP_OSS => 'es-tax-regime-one-stop-shop-oss',
self::TAX_SYSTEM_ONE_STOP_SHOP_IOSS => 'es-tax-regime-one-stop-shop-ioss',
];
$all = array_merge($defaultValues, self::$values);
foreach (array_keys(self::$removedValues) as $key) {
unset($all[$key]);
}
return $all;
}
/**
* @deprecated Use TaxExceptions::all() instead.
*/
public static function allExceptions(): array
{
return TaxExceptions::all();
}
public static function defaultValue(): string
{
return self::TAX_SYSTEM_GENERAL;
}
/**
* Comprueba si la combinación de operación y excepción de IVA es válida.
*
* @param string|null $operation Valor de InvoiceOperation (intracomunitaria, exportacion, importacion, null…)
* @param string|null $exception Valor de excepción de IVA (ES_20, ES_25, ES_PASSIVE_SUBJECT, null…)
* @param string $context 'sales' o 'purchases'
*
* @deprecated Use TaxExceptions::isValidCombination() instead.
*/
public static function isValidCombination(?string $operation, ?string $exception, string $context): bool
{
return TaxExceptions::isValidCombination($operation, $exception, $context);
}
}