Skip to content
Open
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
13 changes: 12 additions & 1 deletion Controller/Modelo130.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class Modelo130 extends Controller
/** @var string */
public $activeTab = '';

/** @var bool */
public $applyGastosJustificacion = false;

/** @var float */
public $gastosJustificacion = 0.0;

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

Expand Down Expand Up @@ -428,9 +434,14 @@ protected function loadResults(): void

$this->taxbase = round($this->taxbaseIngresos - $this->taxbaseGastos, 2);

$this->applyGastosJustificacion = '1' === $this->request->request->get('gastosJustificacion', '0');
if ($this->applyGastosJustificacion && $this->taxbase > 0) {
$this->gastosJustificacion = round($this->taxbase * 0.05, 2);
}

$this->todeduct = (float)$this->request->request->get('todeduct', $this->todeduct);

$this->afterdeduct = round(($this->taxbase * $this->todeduct) / 100, 2);
$this->afterdeduct = round((($this->taxbase - $this->gastosJustificacion) * $this->todeduct) / 100, 2);

$this->result = round($this->afterdeduct - $this->taxbaseRetenciones - $this->positivosTrimestres, 2);

Expand Down
46 changes: 46 additions & 0 deletions Test/main/Modelo130ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,40 @@ public function testGetSqlValueListQuotesValues(): void
$this->assertSame("'6400000000','9999.1'", $controller->sqlValueList(['6400000000', '9999.1']));
}

public function testGastosJustificacionCalculaEl5PorCiento(): void
{
$controller = new Modelo130TestAccess(Modelo130TestAccess::class);
$controller->calcularGastos(10000, 2500, true);

$this->assertEquals(375.0, $controller->gastosJustificacion);
}

public function testGastosJustificacionEsCeroSiRendimientoNegativo(): void
{
$controller = new Modelo130TestAccess(Modelo130TestAccess::class);
$controller->calcularGastos(1000, 5000, true);

$this->assertEquals(0.0, $controller->gastosJustificacion);
}

public function testGastosJustificacionDesactivadoNoAfectaAfterdeduct(): void
{
$controller = new Modelo130TestAccess(Modelo130TestAccess::class);
$controller->calcularGastos(10000, 2500, false);

$this->assertEquals(0.0, $controller->gastosJustificacion);
$this->assertEquals(round(7500 * 0.20, 2), $controller->afterdeduct);
}

public function testAfterdeductSeCalculaSobreBaseReducida(): void
{
$controller = new Modelo130TestAccess(Modelo130TestAccess::class);
$controller->calcularGastos(10000, 2500, true);

// taxbase = 7500, gastosJustificacion = 375, base = 7125, afterdeduct = 7125 * 20% = 1425
$this->assertEquals(1425.0, $controller->afterdeduct);
}

protected function tearDown(): void
{
$this->logErrors();
Expand All @@ -84,4 +118,16 @@ public function sqlValueList(array $values): string
{
return $this->getSqlValueList($values);
}

public function calcularGastos(float $ingresos, float $gastos, bool $apply): void
{
$this->taxbaseIngresos = $ingresos;
$this->taxbaseGastos = $gastos;
$this->taxbase = round($ingresos - $gastos, 2);
$this->applyGastosJustificacion = $apply;
if ($apply && $this->taxbase > 0) {
$this->gastosJustificacion = round($this->taxbase * 0.05, 2);
}
$this->afterdeduct = round((($this->taxbase - $this->gastosJustificacion) * $this->todeduct) / 100, 2);
}
}
2 changes: 2 additions & 0 deletions Translation/es_ES.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"after-deduct": "sobre casilla 04",
"deductible-subaccounts": "Cuentas deducibles",
"gastos-justificacion": "Gastos de difícil justificación (5%)",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
"model-130-p": "El Modelo 130 es una declaración trimestral del impuesto de la renta de las personas físicas (IRPF) en el que se liquida el pago fraccionado de este impuesto, a cuenta de la declaración anual que se realiza el año siguiente.",
Expand Down
22 changes: 22 additions & 0 deletions View/Modelo130.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="mb-3">
<div class="form-check mb-1">
<input type="checkbox" class="form-check-input" id="gastosJustificacion"
name="gastosJustificacion" value="1"
onchange="this.form.submit();"
{{ fsc.applyGastosJustificacion ? 'checked' : '' }}>
<label class="form-check-label" for="gastosJustificacion">
{{ trans('gastos-justificacion') }}
</label>
</div>
<div class="input-group">
<input type="number" value="{{ fsc.gastosJustificacion }}" class="form-control text-end"
readonly/>
</div>
{% if fsc.gastosJustificacion > 2000 %}
<p class="form-text text-warning fw-bold">
<i class="fa-solid fa-triangle-exclamation me-1"></i>{{ trans('gastos-justificacion-limit') }}
</p>
{% endif %}
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="mb-3">
{{ trans('pct-to-deduct') }}
Expand Down
Loading