Skip to content

Commit 7a12d7d

Browse files
author
Daniel Fernández Giménez
committed
mostrar aviso al hacer el modelo 303/390 cuando una factura no tiene asiento
1 parent 9421c52 commit 7a12d7d

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Controller/EditRegularizacionImpuesto.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
use FacturaScripts\Core\Lib\ExtendedController\EditController;
2828
use FacturaScripts\Core\Lib\SubAccountTools;
2929
use FacturaScripts\Core\Tools;
30+
use FacturaScripts\Core\Where;
31+
use FacturaScripts\Dinamic\Model\FacturaCliente;
32+
use FacturaScripts\Dinamic\Model\FacturaProveedor;
3033
use FacturaScripts\Dinamic\Model\RegularizacionImpuesto;
3134
use FacturaScripts\Dinamic\Lib\Accounting\VatRegularizationToAccounting;
3235
use FacturaScripts\Dinamic\Lib\Modelo303;
@@ -62,6 +65,33 @@ public function getPageData(): array
6265
return $data;
6366
}
6467

68+
protected function checkInvoicesWithoutAccounting($model): void
69+
{
70+
// si el modelo no existe, no hacemos nada
71+
if (false === $model->exists()) {
72+
return;
73+
}
74+
75+
// construimos la consulta para buscar facturas sin asiento
76+
$where = [
77+
Where::isNull('idasiento'),
78+
Where::eq('codejercicio', $model->codejercicio),
79+
Where::gte('fecha', $model->fechainicio),
80+
Where::lte('fecha', $model->fechafin),
81+
Where::notEq('total', 0),
82+
];
83+
84+
// buscamos si hay facturas de compra sin asiento para la fecha de la regularización
85+
foreach (FacturaProveedor::all($where) as $invoice) {
86+
Tools::log()->warning('supplier-invoice-without-accounting-entry', ['%code%' => $invoice->codigo]);
87+
}
88+
89+
// buscamos si hay facturas de venta sin asiento para la fecha de la regularización
90+
foreach (FacturaCliente::all($where) as $invoice) {
91+
Tools::log()->warning('sale-invoice-without-accounting-entry', ['%code%' => $invoice->codigo]);
92+
}
93+
}
94+
6595
/**
6696
* Create accounting entry action procedure.
6797
*
@@ -272,6 +302,7 @@ protected function loadData($viewName, $view): void
272302
]);
273303

274304
$this->modelo303->loadFromResumen($view->cursor); // Load data into Modelo303 View
305+
$this->checkInvoicesWithoutAccounting($mainModel);
275306
break;
276307

277308
case 'ListPartida':

0 commit comments

Comments
 (0)