Skip to content

Commit 1171364

Browse files
committed
fix: stampa fattura
1 parent 8dd64a7 commit 1171364

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

modules/fatture/src/Fattura.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,10 @@ public function getDirezioneAttribute()
332332
*/
333333
public function getPesoCalcolatoAttribute()
334334
{
335-
$righe = $this->getRighe()->load(['articolo']);
335+
$righe = $this->getRighe();
336+
$righe->filter(fn ($item) => $item->isArticolo())->each(function ($item) {
337+
$item->load(['articolo']);
338+
});
336339

337340
$peso_lordo = $righe->sum(fn ($item) => $item->isArticolo() ? $item->articolo->peso_lordo * $item->qta : 0);
338341

@@ -347,7 +350,10 @@ public function getPesoCalcolatoAttribute()
347350
public function getVolumeCalcolatoAttribute()
348351
{
349352
// Eager loading per evitare N+1 queries
350-
$righe = $this->getRighe()->load(['articolo']);
353+
$righe = $this->getRighe();
354+
$righe->filter(fn ($item) => $item->isArticolo())->each(function ($item) {
355+
$item->load(['articolo']);
356+
});
351357

352358
$volume = $righe->sum(fn ($item) => $item->isArticolo() ? $item->articolo->volume * $item->qta : 0);
353359

0 commit comments

Comments
 (0)