feat(purchase,sale,ticket): expose refunded total summary in admin sales and tickets
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?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, '.', '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user