Skip to content

Commit

Permalink
- Corregido el worker que actualiza los saldos de cuentas para que ca…
Browse files Browse the repository at this point in the history
…lcule también el de las cuentas padre.

- Añadidos filtros debe, haber y saldo al listado de cuentas.
  • Loading branch information
NeoRazorX committed Jul 2, 2024
1 parent e48794c commit d403dad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion Core/Controller/ListCuenta.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ protected function createViewsAccounts(string $viewName = 'ListCuenta'): void
->addOrderBy(['codejercicio desc, descripcion'], 'description');

// filters
$this->addFilterSelect($viewName, 'codejercicio', 'exercise', 'codejercicio', Ejercicios::codeModel());
$this->listView($viewName)
->addFilterNumber('debit-major', 'debit', 'debe')
->addFilterNumber('debit-minor', 'debit', 'debe', '<=')
->addFilterNumber('credit-major', 'credit', 'haber')
->addFilterNumber('credit-minor', 'credit', 'haber', '<=')
->addFilterNumber('balance-major', 'balance', 'saldo')
->addFilterNumber('balance-minor', 'balance', 'saldo', '<=')
->addFilterSelect('codejercicio', 'exercise', 'codejercicio', Ejercicios::codeModel());

$specialAccounts = $this->codeModel->all('cuentasesp', 'codcuentaesp', 'codcuentaesp');
$this->addFilterSelect($viewName, 'codcuentaesp', 'special-account', 'codcuentaesp', $specialAccounts);
Expand Down
4 changes: 3 additions & 1 deletion Core/Worker/CuentaWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public function run(WorkEvent $event): bool
{
// cargamos la cuenta
$cuenta = new Cuenta();
if (false === $cuenta->loadFromCode($event->param('idcuenta'))) {
// si es una subcuenta, su cuenta padre es idcuenta, para cuentas es parent_idcuenta
$id = $event->param('parent_idcuenta') ?? $event->param('idcuenta');
if (false === $cuenta->loadFromCode($id)) {
return $this->done();
}

Expand Down
8 changes: 7 additions & 1 deletion Core/XMLView/ListCuenta.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of FacturaScripts
* Copyright (C) 2018-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2018-2024 Carlos Garcia Gomez <carlos@facturascripts.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand Down Expand Up @@ -55,4 +55,10 @@
<widget type="money" fieldname="saldo"/>
</column>
</columns>
<rows>
<row type="status">
<option color="danger" fieldname="saldo" title="negative-balance">lt:0</option>
<option color="success" fieldname="saldo" title="positive-balance">gt:0</option>
</row>
</rows>
</view>

0 comments on commit d403dad

Please sign in to comment.