refactor(checkout): materialize purchase item snapshots at start

This commit is contained in:
2026-08-21 11:03:39 -03:00
parent 3a2dc8b7e0
commit 4e7e42d16e
9 changed files with 74 additions and 325 deletions

View File

@@ -154,12 +154,7 @@ class Purchase extends Model
return (float) $this->getRelation('items')->sum('total');
}
$itemsTotal = (float) $this->items()->sum('total');
if ($itemsTotal > 0 || $this->items()->exists()) {
return $itemsTotal;
}
return (float) ($this->cart?->getTotalAmount() ?? $this->total ?? 0);
return (float) $this->items()->sum('total');
}
protected function valueChangeTenantCode(): string