Skip to content

Commit b0d40b0

Browse files
author
Carlos Garcia
committed
Merge remote-tracking branch 'origin/master'
2 parents 41a4d77 + 47346f8 commit b0d40b0

File tree

8 files changed

+128
-25
lines changed

8 files changed

+128
-25
lines changed

Core/Controller/EditImpuesto.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* This file is part of FacturaScripts
4-
* Copyright (C) 2017-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
4+
* Copyright (C) 2017-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -22,6 +22,7 @@
2222
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
2323
use FacturaScripts\Core\Lib\ExtendedController\BaseView;
2424
use FacturaScripts\Core\Lib\ExtendedController\EditController;
25+
use FacturaScripts\Core\Lib\OperacionIVA;
2526

2627
/**
2728
* Controller to edit a single item from the Impuesto model
@@ -133,7 +134,16 @@ protected function loadData($viewName, $view)
133134

134135
default:
135136
parent::loadData($viewName, $view);
137+
$this->loadOperations($viewName);
136138
break;
137139
}
138140
}
141+
142+
protected function loadOperations(string $viewName): void
143+
{
144+
$column = $this->views[$viewName]->columnForName('operation');
145+
if ($column && $column->widget->getType() === 'select') {
146+
$column->widget->setValuesFromArrayKeys(OperacionIVA::all(), true, true);
147+
}
148+
}
139149
}

Core/Controller/ListImpuesto.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* This file is part of FacturaScripts
4-
* Copyright (C) 2017-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
4+
* Copyright (C) 2017-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -20,6 +20,7 @@
2020
namespace FacturaScripts\Core\Controller;
2121

2222
use FacturaScripts\Core\Lib\ExtendedController\ListController;
23+
use FacturaScripts\Core\Lib\OperacionIVA;
2324

2425
/**
2526
* Controller to list the items in the Impuesto model
@@ -63,4 +64,20 @@ protected function createViewsTax(string $viewName = 'ListImpuesto'): void
6364
->addOrderBy(['descripcion'], 'description')
6465
->addSearchFields(['descripcion', 'codimpuesto']);
6566
}
67+
68+
protected function loadData($viewName, $view)
69+
{
70+
parent::loadData($viewName, $view);
71+
if ($viewName === $this->getMainViewName()) {
72+
$this->loadOperations($viewName);
73+
}
74+
}
75+
76+
protected function loadOperations(string $viewName): void
77+
{
78+
$column = $this->views[$viewName]->columnForName('operation');
79+
if ($column && $column->widget->getType() === 'select') {
80+
$column->widget->setValuesFromArrayKeys(OperacionIVA::all(), true, true);
81+
}
82+
}
6683
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
codimpuesto;descripcion;iva;recargo;codsubcuentarep;codsubcuentasop
2-
"IVA0";"IVA 0%";"0";"0";;
3-
"IVA10";"IVA 10%";"10";"1.4";"4770000010";"4720000010"
4-
"IVA21";"IVA 21%";"21";"5.2";"4770000021";"4720000021"
5-
"IVA4";"IVA 4%";"4";"0.5";"4770000004";"4720000004"
6-
"IGIC3";"IGIC 3%";"3";"0";;
7-
"IGIC7";"IGIC 7%";"7";"0";;
1+
codimpuesto;descripcion;iva;recargo;codsubcuentarep;codsubcuentasop;operacion
2+
"IVA0";"IVA 0%";"0";"0";;;"ES_01"
3+
"IVA10";"IVA 10%";"10";"1.4";"4770000010";"4720000010";"ES_01"
4+
"IVA21";"IVA 21%";"21";"5.2";"4770000021";"4720000021";"ES_01"
5+
"IVA4";"IVA 4%";"4";"0.5";"4770000004";"4720000004";"ES_01"
6+
"IGIC3";"IGIC 3%";"3";"0";;;"ES_03"
7+
"IGIC7";"IGIC 7%";"7";"0";;;"ES_03"

Core/Lib/OperacionIVA.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* This file is part of FacturaScripts
4+
* Copyright (C) 2025 Carlos Garcia Gomez <carlos@facturascripts.com>
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* This program 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
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
namespace FacturaScripts\Core\Lib;
21+
22+
/**
23+
* This class centralizes all operations related to taxes.
24+
*
25+
* @author Daniel Fernández Giménez <hola@danielfg.es>
26+
*/
27+
class OperacionIVA
28+
{
29+
const ES_OPERATION_01 = 'ES_01'; // valor añadido
30+
const ES_OPERATION_02 = 'ES_02'; // Ceuta y Melilla
31+
const ES_OPERATION_03 = 'ES_03'; // IGIC
32+
const ES_OPERATION_99 = 'ES_99'; // otro
33+
34+
/** @var array */
35+
private static $values = [];
36+
37+
public static function add(string $key, string $value): void
38+
{
39+
$fixedKey = substr($key, 0, 20);
40+
self::$values[$fixedKey] = $value;
41+
}
42+
43+
public static function all(): array
44+
{
45+
$defaultValues = [
46+
self::ES_OPERATION_01 => 'es-operation-tax-added-value',
47+
self::ES_OPERATION_02 => 'es-operation-tax-ceuta-melilla',
48+
self::ES_OPERATION_03 => 'es-operation-tax-igic',
49+
self::ES_OPERATION_99 => 'es-operation-tax-other',
50+
];
51+
52+
return array_merge($defaultValues, self::$values);
53+
}
54+
55+
public static function default(): string
56+
{
57+
return self::ES_OPERATION_01;
58+
}
59+
}

Core/Model/Impuesto.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class Impuesto extends ModelClass
7575
/** @var string */
7676
public $descripcion;
7777

78+
/** @var string */
79+
public $operacion;
80+
7881
/** @var int */
7982
public $tipo;
8083

Core/Table/impuestos.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<name>descripcion</name>
3737
<type>character varying(50)</type>
3838
</column>
39+
<column>
40+
<name>operacion</name>
41+
<type>character varying(20)</type>
42+
</column>
3943
<column>
4044
<name>tipo</name>
4145
<type>integer</type>

Core/XMLView/EditImpuesto.xml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
* This file is part of FacturaScripts
4-
* Copyright (C) 2017-2024 Carlos Garcia Gomez <carlos@facturascripts.com>
4+
* Copyright (C) 2017-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -24,7 +24,7 @@
2424
<view>
2525
<columns>
2626
<group name="data" numcolumns="12">
27-
<column name="description" numcolumns="6" order="100">
27+
<column name="description" numcolumns="4" order="100">
2828
<widget type="text" fieldname="descripcion" maxlength="50" required="true"/>
2929
</column>
3030
<column name="type" numcolumns="2" order="110">
@@ -33,31 +33,36 @@
3333
<values title="fixed-value">2</values>
3434
</widget>
3535
</column>
36-
<column name="vat" numcolumns="2" order="120">
36+
<column name="operation" numcolumns="2" order="120">
37+
<widget type="select" fieldname="operacion" translate="true" >
38+
<values/>
39+
</widget>
40+
</column>
41+
<column name="vat" numcolumns="2" order="130">
3742
<widget type="number" decimal="2" fieldname="iva" required="true"/>
3843
</column>
39-
<column name="surcharge" numcolumns="2" order="130">
44+
<column name="surcharge" numcolumns="2" order="140">
4045
<widget type="number" decimal="2" fieldname="recargo" required="true"/>
4146
</column>
42-
<column name="code" description="optional" numcolumns="2" order="140">
47+
<column name="code" description="optional" numcolumns="2" order="150">
4348
<widget type="text" fieldname="codimpuesto" icon="fa-solid fa-hashtag" maxlength="10" readonly="dinamic"/>
4449
</column>
45-
<column name="impacted-tax-subaccount" description="optional" order="150">
50+
<column name="impacted-tax-subaccount" description="optional" order="160">
4651
<widget type="autocomplete" fieldname="codsubcuentarep">
4752
<values source="subcuentas" fieldcode="codsubcuenta"/>
4853
</widget>
4954
</column>
50-
<column name="impacted-tax-re-subaccount" description="optional" order="160">
55+
<column name="impacted-tax-re-subaccount" description="optional" order="170">
5156
<widget type="autocomplete" fieldname="codsubcuentarepre">
5257
<values source="subcuentas" fieldcode="codsubcuenta"/>
5358
</widget>
5459
</column>
55-
<column name="supported-tax-subaccount" description="optional" order="170">
60+
<column name="supported-tax-subaccount" description="optional" order="180">
5661
<widget type="autocomplete" fieldname="codsubcuentasop">
5762
<values source="subcuentas" fieldcode="codsubcuenta"/>
5863
</widget>
5964
</column>
60-
<column name="supported-tax-re-subaccount" description="optional" order="180">
65+
<column name="supported-tax-re-subaccount" description="optional" order="190">
6166
<widget type="autocomplete" fieldname="codsubcuentasopre">
6267
<values source="subcuentas" fieldcode="codsubcuenta"/>
6368
</widget>

Core/XMLView/ListImpuesto.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
* This file is part of FacturaScripts
4-
* Copyright (C) 2017-2024 Carlos Garcia Gomez <carlos@facturascripts.com>
4+
* Copyright (C) 2017-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -34,22 +34,27 @@
3434
<values title="fixed-value">2</values>
3535
</widget>
3636
</column>
37-
<column name="vat" display="right" order="130">
37+
<column name="operation" display="none" order="130">
38+
<widget type="select" fieldname="operacion" translate="true" >
39+
<values/>
40+
</widget>
41+
</column>
42+
<column name="vat" display="right" order="140">
3843
<widget type="number" decimal="2" fieldname="iva"/>
3944
</column>
40-
<column name="surcharge" display="right" order="140">
45+
<column name="surcharge" display="right" order="150">
4146
<widget type="number" decimal="2" fieldname="recargo"/>
4247
</column>
43-
<column name="impacted-tax-subaccount" order="150">
48+
<column name="impacted-tax-subaccount" order="160">
4449
<widget type="text" fieldname="codsubcuentarep"/>
4550
</column>
46-
<column name="impacted-tax-re-subaccount" display="none" order="160">
51+
<column name="impacted-tax-re-subaccount" display="none" order="170">
4752
<widget type="text" fieldname="codsubcuentarepre"/>
4853
</column>
49-
<column name="supported-tax-subaccount" order="170">
54+
<column name="supported-tax-subaccount" order="180">
5055
<widget type="text" fieldname="codsubcuentasop"/>
5156
</column>
52-
<column name="supported-tax-re-subaccount" display="none" order="180">
57+
<column name="supported-tax-re-subaccount" display="none" order="190">
5358
<widget type="text" fieldname="codsubcuentasopre"/>
5459
</column>
5560
</columns>

0 commit comments

Comments
 (0)