Skip to content

Commit 68ff8a8

Browse files
committed
Agregado informes de comision y liquidación en el controlador y en el view, y sus traducciones
1 parent 4f6cfb2 commit 68ff8a8

3 files changed

Lines changed: 165 additions & 4 deletions

File tree

Controller/ReportAgentes.php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespace FacturaScripts\Plugins\Informes\Controller;
2121

2222
use FacturaScripts\Core\Base\Controller;
23+
use FacturaScripts\Core\Plugins;
2324
use FacturaScripts\Plugins\Informes\Model\Report;
2425

2526
class ReportAgentes extends Controller
@@ -30,6 +31,21 @@ class ReportAgentes extends Controller
3031
/** @var Report gráfica de albaranes por agente */
3132
public $albaranes;
3233

34+
/** @var Report gráfica de comisiones por mes */
35+
public $comisionesByMonth;
36+
37+
/** @var Report gráfica de comisiones por año */
38+
public $comisionesByYear;
39+
40+
/** @var bool indica si el plugin Comisiones está activo */
41+
public $comisionesEnabled = false;
42+
43+
/** @var Report gráfica de liquidaciones por mes */
44+
public $liquidacionesByMonth;
45+
46+
/** @var Report gráfica de liquidaciones por año */
47+
public $liquidacionesByYear;
48+
3349
/** @var Report gráfica de albaranes por mes (último año) */
3450
public $albaranesByMonth;
3551

@@ -76,6 +92,8 @@ public function privateCore(&$response, $user, $permissions)
7692
{
7793
parent::privateCore($response, $user, $permissions);
7894

95+
$this->comisionesEnabled = Plugins::isEnabled('Comisiones');
96+
7997
$this->loadAgentes();
8098
$this->loadAlbaranes();
8199
$this->loadAlbaranesByMonth();
@@ -89,6 +107,13 @@ public function privateCore(&$response, $user, $permissions)
89107
$this->loadPresupuestos();
90108
$this->loadPresupuestosByMonth();
91109
$this->loadPresupuestosByYear();
110+
111+
if ($this->comisionesEnabled) {
112+
$this->loadComisionesByMonth();
113+
$this->loadComisionesByYear();
114+
$this->loadLiquidacionesByMonth();
115+
$this->loadLiquidacionesByYear();
116+
}
92117
}
93118

94119
protected function loadAgentes(): void
@@ -145,6 +170,68 @@ protected function loadAlbaranesByYear(): void
145170
$this->albaranesByYear = $report;
146171
}
147172

173+
protected function loadComisionesByMonth(): void
174+
{
175+
$report = new Report();
176+
$report->type = Report::TYPE_BAR;
177+
$report->table = 'facturascli';
178+
$report->xcolumn = 'fecha';
179+
$report->ycolumn = 'totalcomision';
180+
$report->xoperation = 'MONTHS';
181+
$report->yoperation = 'SUM';
182+
$report->addFieldXName('');
183+
$report->addCustomFilter('fecha', '>=', '{-1 year}');
184+
$report->addCustomFilter('fecha', '<=', '{today}');
185+
$report->addCustomFilter('codagente', 'IS NOT NULL', '');
186+
187+
$this->comisionesByMonth = $report;
188+
}
189+
190+
protected function loadComisionesByYear(): void
191+
{
192+
$report = new Report();
193+
$report->type = Report::TYPE_BAR;
194+
$report->table = 'facturascli';
195+
$report->xcolumn = 'fecha';
196+
$report->ycolumn = 'totalcomision';
197+
$report->xoperation = 'YEAR';
198+
$report->yoperation = 'SUM';
199+
$report->addFieldXName('');
200+
$report->addCustomFilter('codagente', 'IS NOT NULL', '');
201+
202+
$this->comisionesByYear = $report;
203+
}
204+
205+
protected function loadLiquidacionesByMonth(): void
206+
{
207+
$report = new Report();
208+
$report->type = Report::TYPE_BAR;
209+
$report->table = 'liquidacionescomisiones';
210+
$report->xcolumn = 'fecha';
211+
$report->ycolumn = 'total';
212+
$report->xoperation = 'MONTHS';
213+
$report->yoperation = 'SUM';
214+
$report->addFieldXName('');
215+
$report->addCustomFilter('fecha', '>=', '{-1 year}');
216+
$report->addCustomFilter('fecha', '<=', '{today}');
217+
218+
$this->liquidacionesByMonth = $report;
219+
}
220+
221+
protected function loadLiquidacionesByYear(): void
222+
{
223+
$report = new Report();
224+
$report->type = Report::TYPE_BAR;
225+
$report->table = 'liquidacionescomisiones';
226+
$report->xcolumn = 'fecha';
227+
$report->ycolumn = 'total';
228+
$report->xoperation = 'YEAR';
229+
$report->yoperation = 'SUM';
230+
$report->addFieldXName('');
231+
232+
$this->liquidacionesByYear = $report;
233+
}
234+
148235
protected function loadFacturas(): void
149236
{
150237
$report = new Report();

Translation/es_ES.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"active-customers": "Clientes activos",
33
"agents-report": "Informe de agentes",
4+
"commissions": "Comisiones",
5+
"commissions-by-month": "Comisiones por mes (último año)",
6+
"commissions-by-year": "Comisiones por año",
7+
"settlements-by-month": "Liquidaciones por mes (último año)",
8+
"settlements-by-year": "Liquidaciones por año",
49
"delivery-notes-by-agent": "Albaranes por agente",
510
"delivery-notes-by-month": "Albaranes por mes (último año)",
611
"delivery-notes-by-year": "Albaranes por año",

View/ReportAgentes.html.twig

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</h6>
3333
</div>
3434
<div class="card-body">
35-
{{ fsc.facturas.getChart().render({'height': 250}) | raw }}
35+
{{ fsc.facturas.getChart().render({'height': 260}) | raw }}
3636
</div>
3737
</div>
3838
</div>
@@ -82,7 +82,7 @@
8282
</h6>
8383
</div>
8484
<div class="card-body">
85-
{{ fsc.albaranes.getChart().render({'height': 250}) | raw }}
85+
{{ fsc.albaranes.getChart().render({'height': 260}) | raw }}
8686
</div>
8787
</div>
8888
</div>
@@ -132,7 +132,7 @@
132132
</h6>
133133
</div>
134134
<div class="card-body">
135-
{{ fsc.pedidos.getChart().render({'height': 250}) | raw }}
135+
{{ fsc.pedidos.getChart().render({'height': 260}) | raw }}
136136
</div>
137137
</div>
138138
</div>
@@ -182,7 +182,7 @@
182182
</h6>
183183
</div>
184184
<div class="card-body">
185-
{{ fsc.presupuestos.getChart().render({'height': 250}) | raw }}
185+
{{ fsc.presupuestos.getChart().render({'height': 260}) | raw }}
186186
</div>
187187
</div>
188188
</div>
@@ -215,5 +215,74 @@
215215
</div>
216216
</div>
217217
</div>
218+
{# === COMISIONES (solo si plugin Comisiones está activo) === #}
219+
{% if fsc.comisionesEnabled %}
220+
<div class="row">
221+
<div class="col-12 text-center mb-4">
222+
<h1 class="h3 mb-0 text-gray-800">{{ trans('commissions') }}</h1>
223+
</div>
224+
</div>
225+
<div class="row">
226+
<div class="col-6">
227+
<div class="card shadow mb-4">
228+
<div class="card-header py-3">
229+
<h6 class="m-0 font-weight-bold text-success">
230+
<i class="fa-solid fa-hand-holding-dollar me-1"></i>
231+
{{ trans('commissions-by-month') }}
232+
</h6>
233+
</div>
234+
<div class="card-body">
235+
{{ fsc.comisionesByMonth.getChart().render({'height': 250}) | raw }}
236+
</div>
237+
</div>
238+
</div>
239+
<div class="col-6">
240+
<div class="card shadow mb-4">
241+
<div class="card-header py-3">
242+
<h6 class="m-0 font-weight-bold text-success">
243+
<i class="fa-solid fa-chart-column me-1"></i>
244+
{{ trans('commissions-by-year') }}
245+
</h6>
246+
</div>
247+
<div class="card-body">
248+
{{ fsc.comisionesByYear.getChart().render({'height': 250}) | raw }}
249+
</div>
250+
</div>
251+
</div>
252+
</div>
253+
<div class="row">
254+
<div class="col-12 text-center mb-4">
255+
<h1 class="h3 mb-0 text-gray-800">{{ trans('settlements') }}</h1>
256+
</div>
257+
</div>
258+
<div class="row">
259+
<div class="col-6">
260+
<div class="card shadow mb-4">
261+
<div class="card-header py-3">
262+
<h6 class="m-0 font-weight-bold text-info">
263+
<i class="fa-solid fa-money-bill-transfer me-1"></i>
264+
{{ trans('settlements-by-month') }}
265+
</h6>
266+
</div>
267+
<div class="card-body">
268+
{{ fsc.liquidacionesByMonth.getChart().render({'height': 250}) | raw }}
269+
</div>
270+
</div>
271+
</div>
272+
<div class="col-6">
273+
<div class="card shadow mb-4">
274+
<div class="card-header py-3">
275+
<h6 class="m-0 font-weight-bold text-info">
276+
<i class="fa-solid fa-chart-column me-1"></i>
277+
{{ trans('settlements-by-year') }}
278+
</h6>
279+
</div>
280+
<div class="card-body">
281+
{{ fsc.liquidacionesByYear.getChart().render({'height': 250}) | raw }}
282+
</div>
283+
</div>
284+
</div>
285+
</div>
286+
{% endif %}
218287
</div>
219288
{% endblock %}

0 commit comments

Comments
 (0)