From af6efb879845da2777fc534cf1959930888fd731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez?= Date: Wed, 20 May 2026 19:12:26 +0200 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20a=C3=B1adir=20funcionalidad=20de=20?= =?UTF-8?q?comisiones=20generadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://facturascripts.com/roadmap/4675 - Se ha añadido un nuevo archivo Comisiones.php que permite la creación de comisiones generadas utilizando Faker. - Se ha añadido un nuevo archivo Randomizer.php que incluye un controlador para cargar botones relacionados con las comisiones generadas. - Se ha actualizado el archivo es_ES.json para incluir la traducción de "Comisiones generadas: %quantity%". - Se ha modificado Init.php para cargar la extensión Randomizer si está disponible. todo tal y como lo hace el pluging poryectos --- Extension/Controller/Randomizer.php | 35 ++++++++++++++++++ Init.php | 4 +++ Lib/Random/Comisiones.php | 56 +++++++++++++++++++++++++++++ Translation/es_ES.json | 3 +- 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 Extension/Controller/Randomizer.php create mode 100644 Lib/Random/Comisiones.php diff --git a/Extension/Controller/Randomizer.php b/Extension/Controller/Randomizer.php new file mode 100644 index 0000000..ae10ffd --- /dev/null +++ b/Extension/Controller/Randomizer.php @@ -0,0 +1,35 @@ + + * + * 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\Comisiones\Extension\Controller; + +use Closure; + +/** + * @author Carlos Garcia Gomez + */ +class Randomizer +{ + protected function loadButtons(): Closure + { + return function () { + $this->addButton('plugins', 'comisiones', 'generated-commissions', 'commissions', 'fa-solid fa-percent', 'Random\\Comisiones', 'Comision'); + }; + } +} diff --git a/Init.php b/Init.php index 473aab5..7dcefb1 100644 --- a/Init.php +++ b/Init.php @@ -49,6 +49,10 @@ public function init(): void SalesLineHTML::addMod(new Mod\SalesLineHTMLMod()); TransformerDocument::addUnlockedField('totalcomision'); + + if (class_exists('FacturaScripts\\Dinamic\\Controller\\Randomizer')) { + $this->loadExtension(new Extension\Controller\Randomizer()); + } } public function uninstall(): void diff --git a/Lib/Random/Comisiones.php b/Lib/Random/Comisiones.php new file mode 100644 index 0000000..bdd65aa --- /dev/null +++ b/Lib/Random/Comisiones.php @@ -0,0 +1,56 @@ + + * + * 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\Comisiones\Lib\Random; + +use FacturaScripts\Plugins\Comisiones\Model\Comision; +use FacturaScripts\Plugins\Randomizer\Lib\Random\NewItems; +use Faker; + +/** + * @author Carlos Garcia Gomez + */ +class Comisiones extends NewItems +{ + public static function create(int $number = 50): int + { + $faker = Faker\Factory::create('es_ES'); + + for ($generated = 0; $generated < $number; $generated++) { + $comision = new Comision(); + $comision->codagente = static::codagente(); + $comision->codcliente = static::codcliente(); + $comision->codfamilia = static::codfamilia(); + $comision->idempresa = static::idempresa(); + $comision->idproducto = static::idproducto(); + $comision->porcentaje = $faker->numberBetween(1, 30); + $comision->prioridad = $faker->optional(0.1)->numberBetween(1, 10); + + if ($comision->exists()) { + continue; + } + + if (false === $comision->save()) { + break; + } + } + + return $generated; + } +} diff --git a/Translation/es_ES.json b/Translation/es_ES.json index cf709e0..1570d19 100644 --- a/Translation/es_ES.json +++ b/Translation/es_ES.json @@ -16,5 +16,6 @@ "total-position": "Posición del Total", "until-dto": "Hasta descuento", "until-penalty-info": "Fin del rango del descuento al que se aplica la penalización. '100' indica máximo del rango", - "edit-commission": "Editar Comisión" + "edit-commission": "Editar Comisión", + "generated-commissions": "Comisiones generadas: %quantity%" } From 7ad4b5936b4cc580aa508a1c3c43a3e3d5b46a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez?= Date: Wed, 20 May 2026 19:18:46 +0200 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20corregir=20nombre=20de=20bot=C3=B3n?= =?UTF-8?q?=20en=20Randomizer.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se ha modificado el nombre del botón de 'plugins' a 'sales' en la función loadButtons() del archivo Randomizer.php. Esto mejora la claridad y precisión en la interfaz de usuario. --- Extension/Controller/Randomizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/Controller/Randomizer.php b/Extension/Controller/Randomizer.php index ae10ffd..68b5f7c 100644 --- a/Extension/Controller/Randomizer.php +++ b/Extension/Controller/Randomizer.php @@ -29,7 +29,7 @@ class Randomizer protected function loadButtons(): Closure { return function () { - $this->addButton('plugins', 'comisiones', 'generated-commissions', 'commissions', 'fa-solid fa-percent', 'Random\\Comisiones', 'Comision'); + $this->addButton('sales', 'comisiones', 'generated-commissions', 'commissions', 'fa-solid fa-percentage', 'Random\\Comisiones', 'Comision'); }; } } From c2f1d1ed73813b3b35d64ac7c28b2e317cf8f521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez?= Date: Wed, 20 May 2026 19:24:06 +0200 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20actualizar=20informaci=C3=B3n=20de?= =?UTF-8?q?=20copyright=20y=20autor=20en=20Comisiones.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Se actualizó el año de copyright a 2026. - Se cambió el autor de Carlos Garcia Gomez a Esteban Sánchez Martínez. --- Extension/Controller/Randomizer.php | 4 ++-- Lib/Random/Comisiones.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Extension/Controller/Randomizer.php b/Extension/Controller/Randomizer.php index 68b5f7c..4ca1900 100644 --- a/Extension/Controller/Randomizer.php +++ b/Extension/Controller/Randomizer.php @@ -1,7 +1,7 @@ + * Copyright (C) 2026 Carlos Garcia Gomez * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -22,7 +22,7 @@ use Closure; /** - * @author Carlos Garcia Gomez + * @author Esteban Sánchez Martínez */ class Randomizer { diff --git a/Lib/Random/Comisiones.php b/Lib/Random/Comisiones.php index bdd65aa..560e286 100644 --- a/Lib/Random/Comisiones.php +++ b/Lib/Random/Comisiones.php @@ -1,7 +1,7 @@ + * Copyright (C) 2026 Carlos Garcia Gomez * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -24,7 +24,7 @@ use Faker; /** - * @author Carlos Garcia Gomez + * @author Esteban Sánchez Martínez */ class Comisiones extends NewItems { From b56b9c18e149426b2ecb96d224e80141ef026d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez?= Date: Wed, 20 May 2026 19:25:00 +0200 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20actualizar=20a=C3=B1o=20de=20copyr?= =?UTF-8?q?ight=20en=20Init.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se ha modificado el archivo Init.php para actualizar el año de copyright de 2025 a 2026. --- Init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Init.php b/Init.php index 7dcefb1..d534bd9 100644 --- a/Init.php +++ b/Init.php @@ -1,7 +1,7 @@ + * Copyright (C) 2022-2026 Carlos Garcia Gomez * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as