@extends('layouts.layout-horizontal') @section('title', 'Debtors & Creditors') @section('css') @endsection @section('content') @php $grandReceivable = collect($data)->sum('totalReceivable'); $grandPayable = collect($data)->sum('totalPayable'); $netPosition = $grandReceivable - $grandPayable; $totalBar = max($grandReceivable + $grandPayable, 1); $recPercent = round($grandReceivable / $totalBar * 100); $isAll = $filterCompanyId === 'all'; $fyStartYear = (int) substr($fy, 0, 4); $ledgerStartDate = $fyStartYear . '-04-01'; $ledgerEndDate = ($fyStartYear + 1) . '-03-31'; @endphp
{{-- Filter Bar --}}

Debtors & Creditors

Excel
{{-- Summary Stats --}}
Party Owes You
₹{{ indian_number($grandReceivable, 2) }}
@php $totalRecCount = collect($data)->sum(fn($d) => collect($d['rows'])->where('net_balance', '>', 0)->count()); @endphp {{ $totalRecCount }} {{ $totalRecCount === 1 ? 'party' : 'parties' }}
You Owe Party
₹{{ indian_number($grandPayable, 2) }}
@php $totalPayCount = collect($data)->sum(fn($d) => collect($d['rows'])->where('net_balance', '<', 0)->count()); @endphp {{ $totalPayCount }} {{ $totalPayCount === 1 ? 'party' : 'parties' }}
Net Position
₹{{ indian_number(abs($netPosition), 2) }} {{ $netPosition >= 0 ? 'Surplus' : 'Deficit' }}
{{ $netPosition >= 0 ? 'More to receive than pay' : 'More to pay than receive' }}
{{-- Ratio Bar --}} @if($grandReceivable > 0 || $grandPayable > 0)
Owes You ₹{{ indian_number($grandReceivable, 0) }}
₹{{ indian_number($grandPayable, 0) }} You Owe
@endif {{-- Per-Company Unified Table --}} @foreach($data as $entry) @php $company = $entry['company']; $rows = $entry['rows']; @endphp @if(count($rows) > 0) @if($isAll && count($data) > 1)
{{ $company->name }}
@endif
Outstanding Balances
{{ count($rows) }}
@foreach($rows as $i => $o) @php $isDr = $o->net_balance >= 0; @endphp @endforeach
# Party Balance Status
{{ $i + 1 }} {{ $o->name }} ₹{{ indian_number(abs($o->net_balance), 2) }}{{ $isDr ? 'Dr' : 'Cr' }} {{ $isDr ? 'Owes you' : 'You owe' }} @if($o->mobile) @endif
@endif @endforeach @if(collect($data)->every(fn($e) => count($e['rows']) === 0))

All Clear

No outstanding balances for FY {{ $fy }}.
@endif
@endsection @push('scripts') @endpush