From 98737938edcaf03b02c57abed3bf352c65b47729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez?= Date: Wed, 15 Jul 2026 16:49:10 +0200 Subject: [PATCH] =?UTF-8?q?Corrige=20el=20formato=20de=20n=C3=BAmero=20en?= =?UTF-8?q?=20Modelo303=20y=20actualiza=20las=20l=C3=ADneas=20de=20vista?= =?UTF-8?q?=20en=20EditRegularizacionImpuesto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modificado el formato de número en Modelo303 en IVARRE para usar 2 decimales en lugar de 1, evitando problemas de redondeo. - Actualizadas las llamadas a createViewsTaxLine en EditRegularizacionImpuesto para reflejar las categorías correctas: 'deductible-vat' y 'vat-accrued'. - Añadida una nueva prueba en Modelo303SquaresTest para validar el comportamiento con recargos de dos decimales. --- Controller/EditRegularizacionImpuesto.php | 4 ++-- Lib/Modelo303.php | 2 +- Test/main/Modelo303SquaresTest.php | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Controller/EditRegularizacionImpuesto.php b/Controller/EditRegularizacionImpuesto.php index de67fd9..52490a5 100644 --- a/Controller/EditRegularizacionImpuesto.php +++ b/Controller/EditRegularizacionImpuesto.php @@ -223,8 +223,8 @@ protected function createViews(): void $this->createViewsTaxSummary(); $this->createViewsTaxDetail(); - $this->createViewsTaxLine('ListPartidaImpuesto-1', 'purchases', 'fas fa-sign-in-alt'); - $this->createViewsTaxLine('ListPartidaImpuesto-2', 'sales', 'fas fa-sign-out-alt'); + $this->createViewsTaxLine('ListPartidaImpuesto-1', 'deductible-vat', 'fas fa-sign-in-alt'); + $this->createViewsTaxLine('ListPartidaImpuesto-2', 'vat-accrued', 'fas fa-sign-out-alt'); $this->createViewsEntryLine(); $this->createViewsPresentacion(); } diff --git a/Lib/Modelo303.php b/Lib/Modelo303.php index ab00e4e..a5ff507 100644 --- a/Lib/Modelo303.php +++ b/Lib/Modelo303.php @@ -385,7 +385,7 @@ private function addMovimiento(string $tipo, string $operacion, string $tipodoc, // Determine the correct group based on the tax rate. $tax = ($tipo === 'IVARRE') ? $recargo : $iva; - $key = rtrim(rtrim(number_format($tax, 1, '.', ''), '0'), '.'); + $key = rtrim(rtrim(number_format($tax, 2, '.', ''), '0'), '.'); $grupo = $this->casillaMap[$tipo][$key] ?? $this->casillaMap[$tipo][(string)(int)$tax] ?? $this->casillaMap[$tipo]['*'] diff --git a/Test/main/Modelo303SquaresTest.php b/Test/main/Modelo303SquaresTest.php index 8145e4d..bb64985 100644 --- a/Test/main/Modelo303SquaresTest.php +++ b/Test/main/Modelo303SquaresTest.php @@ -151,6 +151,26 @@ public function testRecargoEquivalencia(): void $this->assertEqualsWithDelta(52.0, $modelo->casilla('24'), 0.001); } + public function testRecargoEquivalenciaConDosDecimales(): void + { + // los tipos de recargo 0.26% y 1.75% tienen 2 decimales; number_format() con solo + // 1 decimal los redondeaba (0.26 -> "0.3", 1.75 -> "1.8") y no encajaban en el mapa + // de casillas, generando un aviso de importe sin casilla. + $modelo = new Modelo303(); + $modelo->loadFromResumen([ + $this->row('IVARRE', 0, 400.0, 1.04, '', 'venta', 0.26), + $this->row('IVARRE', 0, 400.0, 7.0, '', 'venta', 1.75), + ]); + + // recargo 0.26 -> base 168 / cuota 170 + $this->assertEqualsWithDelta(400.0, $modelo->casilla('168'), 0.001); + $this->assertEqualsWithDelta(1.04, $modelo->casilla('170'), 0.001); + // recargo 1.75 -> base 156 / cuota 158 + $this->assertEqualsWithDelta(400.0, $modelo->casilla('156'), 0.001); + $this->assertEqualsWithDelta(7.0, $modelo->casilla('158'), 0.001); + $this->assertEmpty($modelo->getAvisos()); + } + public function testRecargoEquivalenciaEnCuentaIVAREP(): void { // Cuando no hay subcuenta IVARRE configurada, el núcleo contabiliza el recargo en la