23 lines
584 B
PHP
23 lines
584 B
PHP
<?php
|
|
|
|
namespace App\Domains\Purchase\Services;
|
|
|
|
use App\Domains\Purchase\Models\PurchaseItem;
|
|
use App\Domains\Tenant\Models\Tenant;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class PurchaseRefundSummaryService
|
|
{
|
|
public function totalForTenant(Tenant $tenant): string
|
|
{
|
|
$total = PurchaseItem::query()
|
|
->whereHas(
|
|
'purchase',
|
|
fn (Builder $query): Builder => $query->where('tenant_codigo', $tenant->codigo)
|
|
)
|
|
->sum('refunded_amount');
|
|
|
|
return number_format((float) $total, 2, '.', '');
|
|
}
|
|
}
|