Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Core/Controller/EditImpuesto.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2017-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2017-2025 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
Expand All @@ -22,6 +22,7 @@
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
use FacturaScripts\Core\Lib\ExtendedController\BaseView;
use FacturaScripts\Core\Lib\ExtendedController\EditController;
use FacturaScripts\Core\Lib\OperacionIVA;

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

default:
parent::loadData($viewName, $view);
$this->loadOperations($viewName);
break;
}
}

protected function loadOperations(string $viewName): void
Copy link

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This loadOperations logic is the same as in ListImpuesto; consider centralizing it (trait or parent class) to adhere to DRY principles.

Copilot uses AI. Check for mistakes.
{
$column = $this->views[$viewName]->columnForName('operation');
if ($column && $column->widget->getType() === 'select') {
$column->widget->setValuesFromArrayKeys(OperacionIVA::all(), true, true);
}
}
}
19 changes: 18 additions & 1 deletion Core/Controller/ListImpuesto.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2017-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2017-2025 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
Expand All @@ -20,6 +20,7 @@
namespace FacturaScripts\Core\Controller;

use FacturaScripts\Core\Lib\ExtendedController\ListController;
use FacturaScripts\Core\Lib\OperacionIVA;

/**
* Controller to list the items in the Impuesto model
Expand Down Expand Up @@ -63,4 +64,20 @@ protected function createViewsTax(string $viewName = 'ListImpuesto'): void
->addOrderBy(['descripcion'], 'description')
->addSearchFields(['descripcion', 'codimpuesto']);
}

protected function loadData($viewName, $view)
{
parent::loadData($viewName, $view);
if ($viewName === $this->getMainViewName()) {
$this->loadOperations($viewName);
}
}

protected function loadOperations(string $viewName): void
Copy link

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The loadOperations method is duplicated in both ListImpuesto and EditImpuesto; extract it into a shared trait or base class to avoid repeating code.

Copilot uses AI. Check for mistakes.
{
$column = $this->views[$viewName]->columnForName('operation');
if ($column && $column->widget->getType() === 'select') {
$column->widget->setValuesFromArrayKeys(OperacionIVA::all(), true, true);
}
}
}
14 changes: 7 additions & 7 deletions Core/Data/Codpais/ESP/impuestos.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
codimpuesto;descripcion;iva;recargo;codsubcuentarep;codsubcuentasop
"IVA0";"IVA 0%";"0";"0";;
"IVA10";"IVA 10%";"10";"1.4";"4770000010";"4720000010"
"IVA21";"IVA 21%";"21";"5.2";"4770000021";"4720000021"
"IVA4";"IVA 4%";"4";"0.5";"4770000004";"4720000004"
"IGIC3";"IGIC 3%";"3";"0";;
"IGIC7";"IGIC 7%";"7";"0";;
codimpuesto;descripcion;iva;recargo;codsubcuentarep;codsubcuentasop;operacion
"IVA0";"IVA 0%";"0";"0";;;"Valor añadido"
"IVA10";"IVA 10%";"10";"1.4";"4770000010";"4720000010";"Valor añadido"
"IVA21";"IVA 21%";"21";"5.2";"4770000021";"4720000021";"Valor añadido"
"IVA4";"IVA 4%";"4";"0.5";"4770000004";"4720000004";"Valor añadido"
"IGIC3";"IGIC 3%";"3";"0";;;"IGIC"
"IGIC7";"IGIC 7%";"7";"0";;;"IGIC"
59 changes: 59 additions & 0 deletions Core/Lib/OperacionIVA.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2025 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 operations related to taxes.
*
* @author Daniel Fernández Giménez <hola@danielfg.es>
*/
class OperacionIVA
{
const OPERATION_01 = 'Valor añadido';
const OPERATION_02 = 'Ceuta y Melilla';
const OPERATION_03 = 'IGIC';
const OPERATION_04 = 'Otros';

/** @var array */
private static $values = [];

public static function add(string $key, string $value): void
{
$fixedKey = substr($key, 0, 20);
self::$values[$fixedKey] = $value;
}

public static function all(): array
{
$defaultValues = [
self::OPERATION_01 => 'es-operation-tax-added-value',
self::OPERATION_02 => 'es-operation-tax-ceuta-melilla',
self::OPERATION_03 => 'es-operation-tax-igic',
self::OPERATION_04 => 'es-operation-tax-other',
];

return array_merge($defaultValues, self::$values);
}

public static function default(): string
{
return self::OPERATION_01;
}
}
3 changes: 3 additions & 0 deletions Core/Model/Impuesto.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class Impuesto extends ModelClass
/** @var string */
public $descripcion;

/** @var string */
public $operacion;

/** @var int */
public $tipo;

Expand Down
4 changes: 4 additions & 0 deletions Core/Table/impuestos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<name>descripcion</name>
<type>character varying(50)</type>
</column>
<column>
<name>operacion</name>
<type>character varying(50)</type>
</column>
<column>
<name>tipo</name>
<type>integer</type>
Expand Down
10 changes: 5 additions & 5 deletions Core/View/Master/MenuTemplate.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{#
/**
* This file is part of FacturaScripts
* Copyright (C) 2017-2024 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2017-2025 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
Expand Down Expand Up @@ -43,8 +43,8 @@
{% include includeView['path'] %}
{% endfor %}
{% block css %}
<link rel="stylesheet" href="{{ asset('node_modules/bootstrap/dist/css/bootstrap.min.css') }}"/>
<link rel="stylesheet" href="{{ asset('node_modules/@fortawesome/fontawesome-free/css/all.min.css') }}"/>
<link rel="stylesheet" href="{{ asset('node_modules/bootstrap/dist/css/bootstrap.min.css') }}?v=5"/>
<link rel="stylesheet" href="{{ asset('node_modules/@fortawesome/fontawesome-free/css/all.min.css') }}?v=6"/>
<link rel="stylesheet" href="{{ asset('Dinamic/Assets/CSS/custom.css') }}?v=6"/>
{% endblock %}
{# Adds custom CSS assets #}
Expand All @@ -59,11 +59,11 @@
{% endfor %}
{% block javascripts %}
<script src="{{ asset('node_modules/jquery/dist/jquery.min.js') }}"></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.bundle.min.js') }}?v=5"></script>
<script src="{{ asset('node_modules/bootbox/dist/bootbox.min.js') }}"></script>
<script src="{{ asset('node_modules/bootbox/dist/bootbox.locales.min.js') }}"></script>
<script src="{{ asset('node_modules/pace-js/pace.min.js') }}"></script>
<script src="{{ asset('node_modules/@fortawesome/fontawesome-free/js/all.min.js') }}"></script>
<script src="{{ asset('node_modules/@fortawesome/fontawesome-free/js/all.min.js') }}?v=6"></script>
<script src="{{ asset('Dinamic/Assets/JS/Custom.js') }}?v=6"></script>
{% endblock %}
{# Adds custom JS assets #}
Expand Down
10 changes: 5 additions & 5 deletions Core/View/Master/MicroTemplate.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{#
/**
* This file is part of FacturaScripts
* Copyright (C) 2017-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2017-2025 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
Expand Down Expand Up @@ -36,8 +36,8 @@
<link rel="apple-touch-icon" sizes="180x180" href="{{ asset('Dinamic/Assets/Images/apple-icon-180x180.png') }}" />
{% endblock %}
{% block css %}
<link rel="stylesheet" href="{{ asset('node_modules/bootstrap/dist/css/bootstrap.min.css') }}" />
<link rel="stylesheet" href="{{ asset('node_modules/@fortawesome/fontawesome-free/css/all.min.css') }}"/>
<link rel="stylesheet" href="{{ asset('node_modules/bootstrap/dist/css/bootstrap.min.css') }}?v=5" />
<link rel="stylesheet" href="{{ asset('node_modules/@fortawesome/fontawesome-free/css/all.min.css') }}?v=6"/>
<style>
.btn-link {
text-decoration: none;
Expand All @@ -50,8 +50,8 @@
{% endfor %}
{% block javascripts %}
<script src="{{ asset('node_modules/jquery/dist/jquery.min.js') }}"></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ asset('node_modules/@fortawesome/fontawesome-free/js/all.min.js') }}"></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.bundle.min.js') }}?v=5"></script>
<script src="{{ asset('node_modules/@fortawesome/fontawesome-free/js/all.min.js') }}?v=6"></script>
{% endblock %}
{# Adds custom JS assets #}
{% for js in assetManager.get('js') %}
Expand Down
23 changes: 14 additions & 9 deletions Core/XMLView/EditImpuesto.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of FacturaScripts
* Copyright (C) 2017-2024 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2017-2025 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
Expand All @@ -24,7 +24,7 @@
<view>
<columns>
<group name="data" numcolumns="12">
<column name="description" numcolumns="6" order="100">
<column name="description" numcolumns="4" order="100">
<widget type="text" fieldname="descripcion" maxlength="50" required="true"/>
</column>
<column name="type" numcolumns="2" order="110">
Expand All @@ -33,31 +33,36 @@
<values title="fixed-value">2</values>
</widget>
</column>
<column name="vat" numcolumns="2" order="120">
<column name="operation" numcolumns="2" order="120">
<widget type="select" fieldname="operacion" translate="true" >
<values/>
</widget>
</column>
<column name="vat" numcolumns="2" order="130">
<widget type="number" decimal="2" fieldname="iva" required="true"/>
</column>
<column name="surcharge" numcolumns="2" order="130">
<column name="surcharge" numcolumns="2" order="140">
<widget type="number" decimal="2" fieldname="recargo" required="true"/>
</column>
<column name="code" description="optional" numcolumns="2" order="140">
<column name="code" description="optional" numcolumns="2" order="150">
<widget type="text" fieldname="codimpuesto" icon="fa-solid fa-hashtag" maxlength="10" readonly="dinamic"/>
</column>
<column name="impacted-tax-subaccount" description="optional" order="150">
<column name="impacted-tax-subaccount" description="optional" order="160">
<widget type="autocomplete" fieldname="codsubcuentarep">
<values source="subcuentas" fieldcode="codsubcuenta"/>
</widget>
</column>
<column name="impacted-tax-re-subaccount" description="optional" order="160">
<column name="impacted-tax-re-subaccount" description="optional" order="170">
<widget type="autocomplete" fieldname="codsubcuentarepre">
<values source="subcuentas" fieldcode="codsubcuenta"/>
</widget>
</column>
<column name="supported-tax-subaccount" description="optional" order="170">
<column name="supported-tax-subaccount" description="optional" order="180">
<widget type="autocomplete" fieldname="codsubcuentasop">
<values source="subcuentas" fieldcode="codsubcuenta"/>
</widget>
</column>
<column name="supported-tax-re-subaccount" description="optional" order="180">
<column name="supported-tax-re-subaccount" description="optional" order="190">
<widget type="autocomplete" fieldname="codsubcuentasopre">
<values source="subcuentas" fieldcode="codsubcuenta"/>
</widget>
Expand Down
19 changes: 12 additions & 7 deletions Core/XMLView/ListImpuesto.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of FacturaScripts
* Copyright (C) 2017-2024 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2017-2025 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
Expand Down Expand Up @@ -34,22 +34,27 @@
<values title="fixed-value">2</values>
</widget>
</column>
<column name="vat" display="right" order="130">
<column name="operation" display="none" order="130">
<widget type="select" fieldname="operacion" translate="true" >
<values/>
</widget>
</column>
<column name="vat" display="right" order="140">
<widget type="number" decimal="2" fieldname="iva"/>
</column>
<column name="surcharge" display="right" order="140">
<column name="surcharge" display="right" order="150">
<widget type="number" decimal="2" fieldname="recargo"/>
</column>
<column name="impacted-tax-subaccount" order="150">
<column name="impacted-tax-subaccount" order="160">
<widget type="text" fieldname="codsubcuentarep"/>
</column>
<column name="impacted-tax-re-subaccount" display="none" order="160">
<column name="impacted-tax-re-subaccount" display="none" order="170">
<widget type="text" fieldname="codsubcuentarepre"/>
</column>
<column name="supported-tax-subaccount" order="170">
<column name="supported-tax-subaccount" order="180">
<widget type="text" fieldname="codsubcuentasop"/>
</column>
<column name="supported-tax-re-subaccount" display="none" order="180">
<column name="supported-tax-re-subaccount" display="none" order="190">
<widget type="text" fieldname="codsubcuentasopre"/>
</column>
</columns>
Expand Down
Loading