@extends('app.shell') @section('body') @php /** @var \Illuminate\Support\Collection $sharedLists */ /** @var \Illuminate\Support\Collection $expenses */ /** @var \App\Models\Person|null $mePerson */ $locale = app()->getLocale(); $displayCurrency = request()->user()?->profile?->currency ?: 'USD'; $money = function (float $n, string $originalCurrency = 'USD') use ($displayCurrency, $locale): array { return \App\Support\Money::formatConvertedWithOriginal($n, $originalCurrency, $displayCurrency, $locale); }; $listProgress = function (\App\Models\SharedList $list): array { $total = $list->items->count(); $done = $list->items->where('done', true)->count(); return ['done' => $done, 'total' => $total]; }; $listMyBalance = function (string $listId) use ($expenses, $mePerson): float { if (! $mePerson) return 0.0; $relevant = $expenses->where('shared_list_id', $listId); $paid = (float) $relevant->where('paid_by_person_id', $mePerson->id)->sum('amount'); $share = 0.0; foreach ($relevant as $exp) { $split = is_array($exp->split_among) ? $exp->split_among : []; foreach ($split as $row) { $uid = (string) (data_get($row, 'user.id') ?? data_get($row, 'userId') ?? ''); if ($uid !== $mePerson->id) continue; $share += (float) (data_get($row, 'amount') ?? 0); } } return round($paid - $share, 2); }; $openLists = 0; $settledLists = 0; $openItems = 0; foreach ($sharedLists as $list) { $progress = $listProgress($list); $openItems += max(0, $progress['total'] - $progress['done']); if ($progress['total'] === 0 || $progress['done'] < $progress['total']) { $openLists++; } if (abs($listMyBalance($list->id)) < 0.01) { $settledLists++; } } @endphp

{{ __('Share items, track checkout, and see who still needs to settle.') }}

{{ trans_choice(':count list|:count lists', $sharedLists->count(), ['count' => $sharedLists->count()]) }}

πŸ›’

{{ __('Open') }}

{{ $openLists }}

{{ __('Items left') }}

{{ $openItems }}

{{ __('Settled') }}

{{ $settledLists }}

$sharedLists->count() === 0])>
@foreach ($sharedLists as $list) @php $progress = $listProgress($list); $spent = (float) $expenses->where('shared_list_id', $list->id)->sum('amount'); $amount = $listMyBalance($list->id); $pendingItems = max(0, $progress['total'] - $progress['done']); $isOpen = $progress['total'] === 0 || $pendingItems > 0; $isSettled = abs($amount) < 0.01; $fmtSpent = $money($spent); $fmtAmount = $money(abs($amount)); $searchText = collect([ $list->name, $list->members->pluck('name')->join(' '), $list->items->pluck('item_text')->join(' '), ])->filter()->join(' '); @endphp
{{ $list->emoji }}

{{ $list->name }}

{{ $list->members->count() }} {{ __('members') }} Β· {{ $progress['total'] }} {{ __('items') }}

@if ($isOpen) {{ $pendingItems }} {{ __('left') }} @endif @if (! $isOpen && $progress['total'] > 0) {{ __('Done') }} @endif
@php $progressPct = $progress['total'] > 0 ? min(100, max(0, (int) round(($progress['done'] / $progress['total']) * 100))) : 0; @endphp

{{ $progress['done'] }} / {{ $progress['total'] }} {{ __('items done') }}

@if ($spent > 0)

{{ __('Spent') }}

{{ $fmtSpent['primary'] }}

@else

{{ __('No checkout yet') }}

@endif
@if ($isSettled)

{{ __('Settled') }}

@else

{{ $amount > 0 ? __('You’re owed') : __('You owe') }}

{{ $fmtAmount['primary'] }}

@endif
@endforeach
$sharedLists->count() === 0]) >

{{ __('Create another shared list') }}

{{ __('Start a new checklist for the next run.') }}

$sharedLists->count() > 0])>
πŸ›’

{{ __('Create a shared checklist, add items, and split checkout costs.') }}

    @foreach ([ 'Add items as you go', 'Record a checkout and split it', 'Settle up with suggested payments', ] as $line)
  • {{ __($line) }}
  • @endforeach
{{ __('Create a shared list') }}
@endsection