From b5cc24418c899a8dc2db8c8d5f8cd16ed9907572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez?= Date: Mon, 8 Jun 2026 14:21:07 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adir=20funcionalidad=20de=20edici=C3=B3n?= =?UTF-8?q?=20de=20asientos=20y=20vista=20de=20entrada=20contable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Arregla el bug que no aparece el campo para vincular proyectos en asientos - Se ha añadido la clase EditAsiento para gestionar la edición de asientos. - Se ha creado la clase Asiento para manejar la lógica de inserción y actualización de datos. - Se ha añadido la vista AccountingEntry.html.twig para la interfaz de usuario de entrada contable. - Se ha modificado Init.php para cargar las nuevas extensiones EditAsiento y Asiento. --- Extension/Controller/EditAsiento.php | 47 +++++ Extension/Model/Asiento.php | 49 ++++++ Extension/XMLView/EditAsiento.xml | 12 -- Init.php | 2 + View/Tab/AccountingEntry.html.twig | 250 +++++++++++++++++++++++++++ 5 files changed, 348 insertions(+), 12 deletions(-) create mode 100644 Extension/Controller/EditAsiento.php create mode 100644 Extension/Model/Asiento.php delete mode 100644 Extension/XMLView/EditAsiento.xml create mode 100644 View/Tab/AccountingEntry.html.twig diff --git a/Extension/Controller/EditAsiento.php b/Extension/Controller/EditAsiento.php new file mode 100644 index 0000000..4ec25f5 --- /dev/null +++ b/Extension/Controller/EditAsiento.php @@ -0,0 +1,47 @@ + + * + * 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 . + */ + +namespace FacturaScripts\Plugins\Proyectos\Extension\Controller; + +use Closure; +use FacturaScripts\Dinamic\Model\Proyecto; +use FacturaScripts\Plugins\Proyectos\Extension\Traits\ProjectControllerSalesPurchases; + +/** + * @author Esteban Sánchez Martínez + */ + +class EditAsiento +{ + use ProjectControllerSalesPurchases; + + public function createViews(): Closure + { + return function () { + $this->views['main']->template = '@PluginProyectos/Tab/AccountingEntry.html.twig'; + }; + } + + public function getProyectos(): Closure + { + return function () { + return Proyecto::all([], ['nombre' => 'ASC'], 0, 0); + }; + } +} diff --git a/Extension/Model/Asiento.php b/Extension/Model/Asiento.php new file mode 100644 index 0000000..4b77742 --- /dev/null +++ b/Extension/Model/Asiento.php @@ -0,0 +1,49 @@ + + * + * 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 . + */ + +namespace FacturaScripts\Plugins\Proyectos\Extension\Model; + +use Closure; + +/** + * @author Esteban Sánchez Martínez + */ + +class Asiento +{ + public function saveInsertBefore(): Closure + { + return function () { + $data = json_decode($_POST['data'] ?? '{}', true); + if (array_key_exists('idproyecto', $data)) { + $this->idproyecto = empty($data['idproyecto']) ? null : (int)$data['idproyecto']; + } + }; + } + + public function saveUpdateBefore(): Closure + { + return function () { + $data = json_decode($_POST['data'] ?? '{}', true); + if (array_key_exists('idproyecto', $data)) { + $this->idproyecto = empty($data['idproyecto']) ? null : (int)$data['idproyecto']; + } + }; + } +} diff --git a/Extension/XMLView/EditAsiento.xml b/Extension/XMLView/EditAsiento.xml deleted file mode 100644 index 1c63766..0000000 --- a/Extension/XMLView/EditAsiento.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Init.php b/Init.php index 226bb91..6b37716 100644 --- a/Init.php +++ b/Init.php @@ -51,6 +51,7 @@ final class Init extends InitClass public function init(): void { $this->loadExtension(new Extension\Controller\DocumentStitcher()); + $this->loadExtension(new Extension\Controller\EditAsiento()); $this->loadExtension(new Extension\Controller\EditAlbaranCliente()); $this->loadExtension(new Extension\Controller\EditAlbaranProveedor()); $this->loadExtension(new Extension\Controller\EditCliente()); @@ -71,6 +72,7 @@ public function init(): void $this->loadExtension(new Extension\Controller\ListPresupuestoCliente()); $this->loadExtension(new Extension\Controller\ListPresupuestoProveedor()); $this->loadExtension(new Extension\Controller\NewServicioAT()); + $this->loadExtension(new Extension\Model\Asiento()); $this->loadExtension(new Extension\Model\Base\BusinessDocument()); $this->loadExtension(new Extension\Model\Stock()); $this->loadExtension(new Extension\Model\FacturaProgramada()); diff --git a/View/Tab/AccountingEntry.html.twig b/View/Tab/AccountingEntry.html.twig new file mode 100644 index 0000000..37d9599 --- /dev/null +++ b/View/Tab/AccountingEntry.html.twig @@ -0,0 +1,250 @@ +{% set model = fsc.getCurrentView().model %} + + + +{# Template oculto del campo proyecto, clonado en el header via JS #} + + +
+ {{ formToken() }} + + + + + + {{ fsc.renderAccEntryForm(model, model.getLines()) | raw }} +