From f005fce53014ad0cbe2997d2ac879d02c94013ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Cuello=20Principal?= Date: Wed, 17 Jun 2026 08:39:19 +0200 Subject: [PATCH] Ajuste impuestos especiales MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 5% → casillas 153 (base) / 154 (tipo fijo 5,00) / 155 (cuota) - 7,5% → casillas 162 (base) / 163 (tipo fijo 7,50) / 164 (cuota) - Filas ocultas cuando están a cero: 2%, 5%, 7,5% (IVAREP) y los recargos especiales 1,75% y 0,26% --- Lib/Modelo303.php | 106 ++++++++++++++++++++------------------- View/Modelo303.html.twig | 24 +++++++++ 2 files changed, 78 insertions(+), 52 deletions(-) diff --git a/Lib/Modelo303.php b/Lib/Modelo303.php index 2d169f5..1910b9a 100644 --- a/Lib/Modelo303.php +++ b/Lib/Modelo303.php @@ -56,7 +56,8 @@ class Modelo303 'IVAREP' => [ '2' => ['base' => '165', 'cuota' => '167'], '4' => ['base' => '01', 'cuota' => '03'], - '7.5' => ['base' => '153', 'cuota' => '155'], + '5' => ['base' => '153', 'cuota' => '155'], + '7.5' => ['base' => '162', 'cuota' => '164'], '10' => ['base' => '04', 'cuota' => '06'], '21' => ['base' => '07', 'cuota' => '09'], ], @@ -124,8 +125,9 @@ public function __construct() $this->square['17'] = 1.00; $this->square['20'] = 1.40; $this->square['23'] = 5.20; - $this->square['154'] = 7.50; + $this->square['154'] = 5.00; $this->square['157'] = 1.75; + $this->square['163'] = 7.50; $this->square['169'] = 0.26; $this->square['166'] = 2.00; } @@ -236,6 +238,56 @@ public static function treasury(string $codejercicio, string $period): array ]; } + protected static function treasuryDates(Ejercicio $exercise, string $period): array + { + // si el periodo no es T1, T2, T3, T4 o Annual, se asume que es el primer trimestre + if (!in_array($period, ['T1', 'T2', 'T3', 'T4', 'ANNUAL'])) { + $period = 'T1'; + } + + return match ($period) { + 'T1' => [ + date('01-01-Y', strtotime($exercise->fechainicio)), + date('31-03-Y', strtotime($exercise->fechainicio)) + ], + 'T2' => [ + date('01-04-Y', strtotime($exercise->fechainicio)), + date('30-06-Y', strtotime($exercise->fechainicio)) + ], + 'T3' => [ + date('01-07-Y', strtotime($exercise->fechainicio)), + date('30-09-Y', strtotime($exercise->fechainicio)) + ], + 'ANNUAL' => [ + date('01-01-Y', strtotime($exercise->fechainicio)), + date('31-12-Y', strtotime($exercise->fechainicio)) + ], + default => [ + date('01-10-Y', strtotime($exercise->fechainicio)), + date('31-12-Y', strtotime($exercise->fechainicio)) + ], + }; + } + + protected static function treasurySaldoCuenta(string $cuenta, string $desde, string $hasta, DataBase $dataBase): float + { + $saldo = 0.0; + + if ($dataBase->tableExists('partidas')) { + // calculamos el saldo de todos aquellos asientos que afecten a caja + $sql = "select sum(debe-haber) as total from partidas where codsubcuenta LIKE " . $dataBase->var2str($cuenta) + . " and idasiento in (select idasiento from asientos where fecha >= " . $dataBase->var2str($desde) + . " and fecha <= " . $dataBase->var2str($hasta) . ");"; + + $data = $dataBase->select($sql); + if ($data && $data[0]['total'] !== null) { + $saldo = floatval($data[0]['total']); + } + } + + return $saldo; + } + /** * Adds the exempt tax base of a sales invoice to its informative square. * @@ -453,54 +505,4 @@ private function registrarNoMapeado(string $tipo, string $operacion, float $base '%quota%' => Tools::number($cuota, 2), ]); } - - protected static function treasuryDates(Ejercicio $exercise, string $period): array - { - // si el periodo no es T1, T2, T3, T4 o Annual, se asume que es el primer trimestre - if (!in_array($period, ['T1', 'T2', 'T3', 'T4', 'ANNUAL'])) { - $period = 'T1'; - } - - return match ($period) { - 'T1' => [ - date('01-01-Y', strtotime($exercise->fechainicio)), - date('31-03-Y', strtotime($exercise->fechainicio)) - ], - 'T2' => [ - date('01-04-Y', strtotime($exercise->fechainicio)), - date('30-06-Y', strtotime($exercise->fechainicio)) - ], - 'T3' => [ - date('01-07-Y', strtotime($exercise->fechainicio)), - date('30-09-Y', strtotime($exercise->fechainicio)) - ], - 'ANNUAL' => [ - date('01-01-Y', strtotime($exercise->fechainicio)), - date('31-12-Y', strtotime($exercise->fechainicio)) - ], - default => [ - date('01-10-Y', strtotime($exercise->fechainicio)), - date('31-12-Y', strtotime($exercise->fechainicio)) - ], - }; - } - - protected static function treasurySaldoCuenta(string $cuenta, string $desde, string $hasta, DataBase $dataBase): float - { - $saldo = 0.0; - - if ($dataBase->tableExists('partidas')) { - // calculamos el saldo de todos aquellos asientos que afecten a caja - $sql = "select sum(debe-haber) as total from partidas where codsubcuenta LIKE " . $dataBase->var2str($cuenta) - . " and idasiento in (select idasiento from asientos where fecha >= " . $dataBase->var2str($desde) - . " and fecha <= " . $dataBase->var2str($hasta) . ");"; - - $data = $dataBase->select($sql); - if ($data && $data[0]['total'] !== null) { - $saldo = floatval($data[0]['total']); - } - } - - return $saldo; - } } diff --git a/View/Modelo303.html.twig b/View/Modelo303.html.twig index 631fb83..4400ab3 100644 --- a/View/Modelo303.html.twig +++ b/View/Modelo303.html.twig @@ -32,6 +32,7 @@ {{ fsc.modelo303.casillaStr('152') }} + {% if fsc.modelo303.casilla('165') or fsc.modelo303.casilla('167') %} 165 @@ -46,6 +47,7 @@ {{ fsc.modelo303.casillaStr('167') }} + {% endif %} 01 @@ -60,6 +62,7 @@ {{ fsc.modelo303.casillaStr('03') }} + {% if fsc.modelo303.casilla('153') or fsc.modelo303.casilla('155') %} 153 @@ -74,6 +77,23 @@ {{ fsc.modelo303.casillaStr('155') }} + {% endif %} + {% if fsc.modelo303.casilla('162') or fsc.modelo303.casilla('164') %} + + 162 + + {{ fsc.modelo303.casillaStr('162') }} + + 163 + + {{ fsc.modelo303.casillaStr('163') }} + + 164 + + {{ fsc.modelo303.casillaStr('164') }} + + + {% endif %} 04 @@ -135,6 +155,7 @@ {{ fsc.modelo303.casillaStr('15') }} + {% if fsc.modelo303.casilla('156') or fsc.modelo303.casilla('158') %} 156 @@ -149,6 +170,8 @@ {{ fsc.modelo303.casillaStr('158') }} + {% endif %} + {% if fsc.modelo303.casilla('168') or fsc.modelo303.casilla('170') %} 168 @@ -163,6 +186,7 @@ {{ fsc.modelo303.casillaStr('170') }} + {% endif %} 16