Skip to content

Commit 46e50ab

Browse files
author
Carlos Garcia
committed
Añadido soporte para el core 2025
1 parent b3c1914 commit 46e50ab

7 files changed

Lines changed: 21 additions & 30 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php-version: ['8.0', '8.1']
17+
php-version: ['8.0', '8.1', '8.2', '8.3', '8.4']
1818
database: ['mysql', 'postgresql']
1919

2020
env:

Init.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222
use FacturaScripts\Core\Lib\AjaxForms\PurchasesHeaderHTML;
2323
use FacturaScripts\Core\Lib\AjaxForms\SalesHeaderHTML;
2424
use FacturaScripts\Core\Template\InitClass;
25-
use FacturaScripts\Core\Tools;
26-
2725
use FacturaScripts\Dinamic\Model\FacturaCliente;
2826
use FacturaScripts\Dinamic\Model\FacturaProveedor;
29-
use FacturaScripts\Dinamic\Model\User;
3027

3128
/**
3229
* Description of Init
@@ -37,10 +34,13 @@ final class Init extends InitClass
3734
{
3835
public function init(): void
3936
{
37+
// extensiones
4038
$this->loadExtension(new Extension\Model\Cliente());
4139
$this->loadExtension(new Extension\Model\FacturaCliente());
4240
$this->loadExtension(new Extension\Model\FacturaProveedor());
4341
$this->loadExtension(new Extension\Model\Proveedor());
42+
43+
// mods
4444
PurchasesHeaderHTML::addMod(new Mod\PurchasesHeaderHTMLMod());
4545
SalesHeaderHTML::addMod(new Mod\SalesHeaderHTMLMod());
4646
}
@@ -51,7 +51,6 @@ public function uninstall(): void
5151

5252
public function update(): void
5353
{
54-
new User();
5554
new FacturaCliente();
5655
new FacturaProveedor();
5756
}

Mod/PurchasesHeaderHTMLMod.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
namespace FacturaScripts\Plugins\Modelo347\Mod;
2121

2222
use FacturaScripts\Core\Contract\PurchasesModInterface;
23-
use FacturaScripts\Core\Translator;
2423
use FacturaScripts\Core\Model\Base\PurchaseDocument;
25-
use FacturaScripts\Core\Model\User;
2624
use FacturaScripts\Core\Tools;
2725

28-
2926
/**
3027
* Add new fields in the modal window of the document header
3128
* - excluir347: Allows the user to mark the invoice as excluded from the 347 calculation.
@@ -35,7 +32,7 @@
3532
*/
3633
class PurchasesHeaderHTMLMod implements PurchasesModInterface
3734
{
38-
public function apply(PurchaseDocument &$model, array $formData):void
35+
public function apply(PurchaseDocument &$model, array $formData): void
3936
{
4037
if (property_exists($model, 'excluir347')) {
4138
$model->excluir347 = ($formData['excluir347'] ?? '') === 'true';
@@ -63,8 +60,7 @@ public function newFields(): array
6360
public function renderField(PurchaseDocument $model, string $field): ?string
6461
{
6562
if ($field == 'excluir347') {
66-
$i18n = new Translator();
67-
return $this->excluir347($i18n, $model);
63+
return $this->excluir347($model);
6864
}
6965

7066
return null;
@@ -75,7 +71,7 @@ public function newModalFields(): array
7571
return ['excluir347'];
7672
}
7773

78-
private static function excluir347(Translator $i18n, PurchaseDocument $model): string
74+
private static function excluir347(PurchaseDocument $model): string
7975
{
8076
if (false === property_exists($model, 'excluir347')) {
8177
return '';
@@ -85,13 +81,13 @@ private static function excluir347(Translator $i18n, PurchaseDocument $model): s
8581
foreach (['false', 'true'] as $row) {
8682
$txt = ($row === 'true') ? 'yes' : 'no';
8783
$options[] = ($row == $model->excluir347) ?
88-
'<option value="' . $row . '" selected>' . $i18n->trans($txt) . '</option>' :
89-
'<option value="' . $row . '">' . $i18n->trans($txt) . '</option>';
84+
'<option value="' . $row . '" selected>' . Tools::trans($txt) . '</option>' :
85+
'<option value="' . $row . '">' . Tools::trans($txt) . '</option>';
9086
}
9187

9288
$attributes = $model->editable ? 'name="excluir347" required=""' : 'disabled=""';
9389
return '<div class="col-sm-6">'
94-
. '<div class="mb-3">' . $i18n->trans('exclude-347')
90+
. '<div class="mb-3">' . Tools::trans('exclude-347')
9591
. '<select ' . $attributes . ' class="form-select"/>' . implode('', $options) . '</select>'
9692
. '</div>'
9793
. '</div>';

Mod/SalesHeaderHTMLMod.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* This file is part of Modelo347 plugin for FacturaScripts
4-
* Copyright (C) 2020-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
4+
* Copyright (C) 2020-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -20,12 +20,9 @@
2020
namespace FacturaScripts\Plugins\Modelo347\Mod;
2121

2222
use FacturaScripts\Core\Contract\SalesModInterface;
23-
use FacturaScripts\Core\Translator;
2423
use FacturaScripts\Core\Model\Base\SalesDocument;
25-
use FacturaScripts\Core\Model\User;
2624
use FacturaScripts\Core\Tools;
2725

28-
2926
/**
3027
* Add new fields in the modal window of the document header
3128
* - excluir347: Allows the user to mark the invoice as excluded from the 347 calculation.
@@ -68,14 +65,13 @@ public function newModalFields(): array
6865
public function renderField(SalesDocument $model, string $field): ?string
6966
{
7067
if ($field == 'excluir347') {
71-
$i18n = new Translator();
72-
return $this->excluir347($i18n, $model);
68+
return $this->excluir347($model);
7369
}
7470

7571
return null;
7672
}
7773

78-
private static function excluir347(Translator $i18n, SalesDocument $model): string
74+
private static function excluir347(SalesDocument $model): string
7975
{
8076
if (false === property_exists($model, 'excluir347')) {
8177
return '';
@@ -85,13 +81,13 @@ private static function excluir347(Translator $i18n, SalesDocument $model): stri
8581
foreach (['false', 'true'] as $row) {
8682
$txt = ($row === 'true') ? 'yes' : 'no';
8783
$options[] = ($row == $model->excluir347) ?
88-
'<option value="' . $row . '" selected>' . $i18n->trans($txt) . '</option>' :
89-
'<option value="' . $row . '">' . $i18n->trans($txt) . '</option>';
84+
'<option value="' . $row . '" selected>' . Tools::trans($txt) . '</option>' :
85+
'<option value="' . $row . '">' . Tools::trans($txt) . '</option>';
9086
}
9187

9288
$attributes = $model->editable ? 'name="excluir347" required=""' : 'disabled=""';
9389
return '<div class="col-sm-6">'
94-
. '<div class="mb-3">' . $i18n->trans('exclude-347')
90+
. '<div class="mb-3">' . Tools::trans('exclude-347')
9591
. '<select ' . $attributes . ' class="form-select"/>' . implode('', $options) . '</select>'
9692
. '</div>'
9793
. '</div>';

Test/main/Extension/Table/FacturasTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function setUpBeforeClass(): void
4343
self::removeTaxRegularization();
4444
}
4545

46-
public function testExistsPropertyFacturaCliente()
46+
public function testExistsPropertyFacturaCliente(): void
4747
{
4848
// crear el cliente
4949
$customer = new Cliente();
@@ -77,7 +77,7 @@ public function testExistsPropertyFacturaCliente()
7777
$this->assertTrue($customer->delete(), 'cant-delete-customer');
7878
}
7979

80-
public function testExistsPropertyFacturaProveedor()
80+
public function testExistsPropertyFacturaProveedor(): void
8181
{
8282
// crear proveedor
8383
$suplier = new Proveedor();

Test/main/ModTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ final class ModTest extends TestCase
3131
{
3232
use LogErrorsTrait;
3333

34-
public function testPurchasesHeaderHTMLMod()
34+
public function testPurchasesHeaderHTMLMod(): void
3535
{
3636
new PurchasesHeaderHTMLMod();
3737
}
3838

39-
public function SalesHeaderHTMLMod()
39+
public function SalesHeaderHTMLMod(): void
4040
{
4141
new SalesHeaderHTMLMod();
4242
}

facturascripts.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name = 'Modelo347'
22
description = 'Permite obtener los datos necesarios para el modelo 347 de la hacienda española.'
3-
version = 3.1
3+
version = 3.2
44
min_version = 2025

0 commit comments

Comments
 (0)