Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Controller/EditRegularizacionImpuesto.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
class EditRegularizacionImpuesto extends EditController
{
/** @var float */
public $purchases;
public float $purchases;

/** @var float */
public $sales;
public float $sales;

/** @var float */
public $total;
public float $total;

/** @var array */
public array $modelo303 = [];
Expand All @@ -63,7 +63,7 @@ public function getPageData(): array
$data = parent::getPageData();
$data['menu'] = 'reports';
$data['title'] = 'model-303-390';
$data['icon'] = 'fas fa-balance-scale-right';
$data['icon'] = 'fa-solid fa-balance-scale-right';
return $data;
}

Expand Down Expand Up @@ -97,7 +97,7 @@ protected function createAccountingEntryAction(): void
{
$reg = new RegularizacionImpuesto();
$code = $this->request->get('code');
if (false === $reg->loadFromCode($code)) {
if (false === $reg->load($code)) {
Tools::log()->warning('record-not-found');
return;
}
Expand Down Expand Up @@ -126,7 +126,7 @@ protected function createAccountingEntryAction(): void
/**
* Add the view set.
*/
protected function createViews()
protected function createViews(): void
{
parent::createViews();
$this->setTabsPosition('bottom');
Expand All @@ -137,7 +137,7 @@ protected function createViews()

protected function createViewsEntryLine(string $viewName = 'ListPartida'): void
{
$this->addListView($viewName, 'Partida', 'accounting-entry', 'fas fa-balance-scale');
$this->addListView($viewName, 'Partida', 'accounting-entry', 'fa-solid fa-balance-scale');
$this->disableButtons($viewName, true);
}

Expand All @@ -154,7 +154,7 @@ protected function createViewsTaxLine(string $viewName, string $caption, string

protected function createViewsTaxSummary(string $viewName = 'ListPartidaImpuestoResumen'): void
{
$this->addHtmlView($viewName, 'Modelo303', 'Impuesto', 'summary', 'fas fa-list-alt');
$this->addHtmlView($viewName, 'Modelo303', 'Impuesto', 'summary', 'fa-solid fa-list-alt');
$this->disableButtons($viewName);
}

Expand All @@ -173,7 +173,7 @@ protected function disableButtons(string $viewName, bool $clickable = false): vo
*
* @return bool
*/
protected function execPreviousAction($action)
protected function execPreviousAction($action): bool
{
switch ($action) {
case 'create-accounting-entry':
Expand All @@ -184,7 +184,7 @@ protected function execPreviousAction($action)
return parent::execPreviousAction($action);
}

protected function exportAction()
protected function exportAction(): void
{
$this->exportManager->setOrientation('landscape');
parent::exportAction();
Expand Down Expand Up @@ -227,7 +227,7 @@ protected function getListPartidaImpuestoResumen(BaseView $view): void
new DataBaseWhere('codejercicio', $this->getModel()->codejercicio),
new DataBaseWhere('fecha', $this->getModel()->fechainicio, '>='),
new DataBaseWhere('fecha', $this->getModel()->fechafin, '<'),
], [], 0, 0);
]);
$idsAsientos = array_unique(array_column($asientos, Asiento::primaryColumn()));

if(empty($idsAsientos)) {
Expand All @@ -238,7 +238,7 @@ protected function getListPartidaImpuestoResumen(BaseView $view): void
$partidas = Partida::all([
new DataBaseWhere('idasiento', $idsAsientos, 'IN'),
new DataBaseWhere('codsubcuenta', $subcuentas, 'IN')
], [], 0, 0);
]);

// agrupamos por subcuenta
$partidasAgrupadas = [];
Expand Down Expand Up @@ -390,7 +390,7 @@ protected function getPartidaImpuestoWhere(int $group): array

// obtenemos todos los ids de los asientos de las regularizaciones
$ids = [];
foreach (RegularizacionImpuesto::all([], [], 0, 0) as $reg) {
foreach (RegularizacionImpuesto::all() as $reg) {
if ($reg->idasiento) {
$ids[] = $reg->idasiento;
}
Expand All @@ -408,7 +408,7 @@ protected function getPartidaImpuestoWhere(int $group): array
* @param string $viewName
* @param BaseView $view
*/
protected function loadData($viewName, $view)
protected function loadData($viewName, $view): void
{
switch ($viewName) {
case 'EditRegularizacionImpuesto':
Expand Down Expand Up @@ -446,7 +446,7 @@ protected function setCreateAcEntryButton(string $viewName): void
'action' => 'create-accounting-entry',
'color' => 'success',
'confirm' => true,
'icon' => 'fas fa-balance-scale',
'icon' => 'fa-solid fa-balance-scale',
'label' => 'create-accounting-entry',
'row' => 'actions'
]);
Expand Down
12 changes: 6 additions & 6 deletions Controller/ListRegularizacionImpuesto.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ public function getPageData(): array
$data = parent::getPageData();
$data['menu'] = 'reports';
$data['title'] = 'model-303-390';
$data['icon'] = 'fas fa-book';
$data['icon'] = 'fa-solid fa-book';
return $data;
}

/**
* Load views
*/
protected function createViews()
protected function createViews(): void
{
$this->createViewsModel303();
$this->createViewsModel390();
}

protected function createViewsModel303(string $viewName = 'ListRegularizacionImpuesto')
protected function createViewsModel303(string $viewName = 'ListRegularizacionImpuesto'): void
{
$this->addView($viewName, 'RegularizacionImpuesto', 'model-303', 'fas fa-book')
$this->addView($viewName, 'RegularizacionImpuesto', 'model-303', 'fa-solid fa-book')
->addOrderBy(['fechainicio'], 'start-date', 2)
->addOrderBy(['codejercicio||periodo'], 'period')
->addSearchFields(['codsubcuentaacr', 'codsubcuentadeu']);
Expand All @@ -67,9 +67,9 @@ protected function createViewsModel303(string $viewName = 'ListRegularizacionImp
$this->addFilterSelect($viewName, 'codejercicio', 'exercise', 'codejercicio', $exercises);
}

protected function createViewsModel390(string $viewName = 'ListRegularizacionImpuesto-390')
protected function createViewsModel390(string $viewName = 'ListRegularizacionImpuesto-390'): void
{
$this->addView($viewName, 'RegularizacionImpuesto', 'model-390', 'fas fa-book')
$this->addView($viewName, 'RegularizacionImpuesto', 'model-390', 'fa-solid fa-book')
->addOrderBy(['fechainicio'], 'start-date', 2)
->addOrderBy(['codejercicio||periodo'], 'period')
->addSearchFields(['codsubcuentaacr', 'codsubcuentadeu']);
Expand Down
19 changes: 9 additions & 10 deletions Lib/Accounting/VatRegularizationToAccounting.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
class VatRegularizationToAccounting
{
/** @var float */
private $credit = 0.0;
private float $credit = 0.0;

/** @var float */
private $debit = 0.0;
private float $debit = 0.0;

public function generate(RegularizacionImpuesto &$reg): bool
{
Expand All @@ -64,10 +64,9 @@ public function generate(RegularizacionImpuesto &$reg): bool
if ($this->addAccountingTaxLines($accEntry, $reg) &&
$this->addAccountingResultLine($accEntry, $reg) &&
$accEntry->isBalanced()) {

$accEntry->importe = max([$this->debit, $this->credit]);
if ($accEntry->save()) {
$reg->idasiento = $accEntry->primaryColumnValue();
$reg->idasiento = $accEntry->id();
$reg->fechaasiento = $accEntry->fecha;
return true;
}
Expand All @@ -84,7 +83,7 @@ protected function addAccountingResultLine(Asiento $accEntry, RegularizacionImpu

// si el debe es mayor que el haber, seleccionamos la cuenta de acreedores
$id = $this->debit >= $this->credit ? $reg->idsubcuentaacr : $reg->idsubcuentadeu;
if (false === $subaccount->loadFromCode($id)) {
if (false === $subaccount->load($id)) {
return false;
}

Expand All @@ -104,14 +103,14 @@ protected function addAccountingTaxLines(Asiento $accEntry, RegularizacionImpues
{
foreach ($this->getSubtotals($reg) as $idsubcuenta => $total) {
$subaccount = new Subcuenta();
if (false === $subaccount->loadFromCode($idsubcuenta)) {
if (false === $subaccount->load($idsubcuenta)) {
return false;
}

$newLine = $accEntry->getNewLine();
$newLine->setAccount($subaccount);
$newLine->debe = round($total['debe'], FS_NF0);
$newLine->haber = round($total['haber'], FS_NF0);
$newLine->debe = round($total['debe'], Tools::settings('default', 'decimals'));
$newLine->haber = round($total['haber'], Tools::settings('default', 'decimals'));
if ($newLine->save()) {
$this->debit += $newLine->debe;
$this->credit += $newLine->haber;
Expand Down Expand Up @@ -176,9 +175,9 @@ private function checkInvoicesWithoutAccEntry($reg): bool
new DataBaseWhere('idasiento', 'IS NULL')
];

$facturasClienteSinAsiento = FacturaCliente::all($where, [], 0, 0);
$facturasClienteSinAsiento = FacturaCliente::all($where);

$facturasProveedorSinAsiento = FacturaProveedor::all($where, [], 0, 0);
$facturasProveedorSinAsiento = FacturaProveedor::all($where);

if (count($facturasClienteSinAsiento) > 0 || count($facturasProveedorSinAsiento) > 0) {
return false;
Expand Down
10 changes: 5 additions & 5 deletions Model/Join/PartidaImpuesto.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PartidaImpuesto extends JoinModel
/**
* Reset the values of all model view properties.
*/
public function clear()
public function clear(): void
{
parent::clear();
$this->baseimponible = 0.00;
Expand All @@ -57,12 +57,12 @@ protected function getFactura(): BusinessDocument
$where = [new DataBaseWhere('idasiento', $this->idasiento ?? 0)];

$facturaCliente = new FacturaCliente();
if ($facturaCliente->loadFromCode('', $where)) {
if ($facturaCliente->loadWhere($where)) {
return $facturaCliente;
}

$facturaProveedor = new FacturaProveedor();
$facturaProveedor->loadFromCode('', $where);
$facturaProveedor->loadWhere($where);
return $facturaProveedor;
}

Expand Down Expand Up @@ -123,7 +123,7 @@ protected function getTables(): array
*
* @param array $data
*/
protected function loadFromData(array $data)
protected function loadFromData(array $data): void
{
parent::loadFromData($data);

Expand All @@ -145,7 +145,7 @@ protected function loadFromData(array $data)
// si el campo factura está vacío, buscamos la factura con este asiento
if (empty($this->factura)) {
$factura = $this->getFactura();
if ($factura->primaryColumnValue()) {
if ($factura->id()) {
$this->factura = $factura->numero;
$this->documento = $factura->codigo;
$this->codserie = $factura->codserie;
Expand Down
4 changes: 2 additions & 2 deletions Model/Join/PartidaImpuestoResumen.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PartidaImpuestoResumen extends JoinModel
/**
* Reset the values of all model view properties.
*/
public function clear()
public function clear(): void
{
parent::clear();
$this->baseimponible = 0.0;
Expand Down Expand Up @@ -130,7 +130,7 @@ protected function getTables(): array
*
* @param array $data
*/
protected function loadFromData($data)
protected function loadFromData(array $data): void
{
parent::loadFromData($data);

Expand Down
2 changes: 2 additions & 0 deletions Test/main/ComprobarFechaDevengoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace FacturaScripts\Test\Plugins;

use Exception;
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
use FacturaScripts\Core\Model\FacturaCliente;
use FacturaScripts\Core\Tools;
Expand All @@ -18,6 +19,7 @@ class ComprobarFechaDevengoTest extends Modelo303TestCase
* y si no existe por la fecha de la factura.
*
* @return void
* @throws Exception
*/
public function testComprobarFechaDevengo()
{
Expand Down
4 changes: 2 additions & 2 deletions Translation/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$files[] = $lang . '.json';
}
foreach (scandir(__DIR__, SCANDIR_SORT_ASCENDING) as $filename) {
if (is_file($filename) && substr($filename, -5) === '.json' && false === in_array($filename, $files)) {
if (is_file($filename) && str_ends_with($filename, '.json') && false === in_array($filename, $files)) {
$files[] = $filename;
}
}
Expand Down Expand Up @@ -39,4 +39,4 @@
}

echo "Skip " . $filename . "\n";
}
}
2 changes: 1 addition & 1 deletion XMLView/ListPartidaImpuestoResumen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<rows>
<row type="footer">
<group name="actions"/>
<group name="summary" html="Block/PartidaImpuestoResumen.html.twig"></group>
<group name="summary" html="Block/PartidaImpuestoResumen.html.twig"/>
</row>
<row type="status">
<option color="warning" fieldname="codcuentaesp">IVASOP</option>
Expand Down
4 changes: 2 additions & 2 deletions facturascripts.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = 'Modelo303'
description = 'Modelo 303 y 390 de la Hacienda española para la declaración trimestral y anual de IVA.'
version = 2.62
min_version = 2023.2
version = 2.7
min_version = 2025