@extends('layouts.master') @section('title', 'Laporan Piutang') @section('css') @endsection @section('content')
Laporan Piutang
Reset
@foreach ($customers as $customer) @php $receivables = collect($customer['receivables']); $total_debt = $receivables->sum('total_debt'); $total_paid = $receivables->sum('amount_paid'); $total_balance = $receivables->sum('adjusted_balance'); // Calculated in controller $ending_balance = $customer['beginning_balance'] + $total_balance; @endphp @foreach ($customer['receivables'] as $debt) {{-- Changed from debt_balance to adjusted_balance --}} @endforeach @endforeach {{-- Total Debt --}} {{-- Total Amount Paid (Historical) --}} {{-- Total Balance (Beginning Balance + Historical Balance) --}}
No Pelanggan Nomor Faktur Penjualan Tanggal Faktur Penjualan Tanggal Tenggat Total Piutang Total Terbayar Sisa Piutang
{{ $no++ }} {{ $customer['customer_name'] }} Saldo Awal {{ number_format($customer['beginning_balance'], 2) }}
{{ $no++ }} {{ $customer['customer_name'] }} {{ $debt['document_number'] }} {{ \Carbon\Carbon::parse($debt['document_date'])->format('d M Y') }} {{ \Carbon\Carbon::parse($debt['due_date'])->format('d M Y') }} {{ number_format($debt['total_debt'], 2) }} {{ number_format($debt['amount_paid'], 2) }}{{ number_format($debt['adjusted_balance'], 2) }}
{{ $no++ }} {{ $customer['customer_name'] }} Saldo Akhir {{ number_format($ending_balance, 2) }}
Total: {{ number_format($customers->sum(function($customer) { return collect($customer['receivables'])->sum('total_debt'); }), 2) }} {{ number_format($customers->sum(function($customer) { return collect($customer['receivables'])->sum('amount_paid'); }), 2) }} {{ number_format($customers->sum(function($customer) { return $customer['beginning_balance'] + collect($customer['receivables'])->sum('adjusted_balance'); }), 2) }}
@if (session('success')) @endif @if (session('error')) @endif @endsection @section('scripts') @endsection