feat(sales): scope sales actions totals history and exports by event

This commit is contained in:
2026-09-30 15:31:55 -03:00
parent 55c28f33ef
commit 655364bfec
6 changed files with 58 additions and 36 deletions

View File

@@ -8,12 +8,13 @@ use Illuminate\Database\Eloquent\Builder;
class PurchaseRefundSummaryService
{
public function totalForTenant(Tenant $tenant): string
public function totalForTenant(Tenant $tenant, ?int $eventId = null): string
{
$total = TicketRefund::query()
->whereHas(
'purchaseItem.purchase',
fn (Builder $query): Builder => $query->where('tenant_codigo', $tenant->codigo)
->when($eventId !== null, fn (Builder $purchase) => $purchase->where('event_id', $eventId))
)
->sum('amount');