@if(!empty($for_pdf)) @endif

STATEMENT

{{$contact->business->name}}
P.O BOX 17671-00100
NAIROBI, KENYA
TEL: +254 777 215 570

@lang('lang_v1.to'):

{!! $contact->contact_address !!} @if(!empty($contact->email))
@lang('business.email'): {{$contact->email}} @endif
@lang('contact.mobile'): {{$contact->mobile}} @if(!empty($contact->tax_number))
@lang('contact.tax_no'): {{$contact->tax_number}} @endif
Shipping Address: {{$contact->shipping_address}}

@lang('lang_v1.date')
{{ \Carbon\Carbon::createFromFormat('d/m/Y', $ledger_details['start_date'])->format('d/m/Y') }} to {{ \Carbon\Carbon::createFromFormat('d/m/Y', $ledger_details['end_date'])->format('d/m/Y') }}
@php $amount_due = 0; $current_due = 0; $due_1_30_days = 0; $due_30_60_days = 0; $due_60_90_days = 0; $due_over_90_days = 0; $actual_rows = 0; $max_rows = 29; @endphp {{--
Amount Due Amount Enc.
@format_currency($ledger_details['balance_due'])
--}}

@foreach($ledger_details['ledger'] as $data) @php // Determine the sign: ledger_discount should reduce the totals $total_due = $data['total_due'] ?? 0; if(!empty($data['transaction_type']) && $data['transaction_type'] == 'ledger_discount') { $total_due = -abs($total_due); // subtract from totals } // Add to totals only if payment_status != 'paid' or it's not ledger_discount if($data['payment_status'] != 'paid') { $amount_due += $total_due; $days_diff = !empty($data['due_date']) ? $data['due_date']->diffInDays() : 0; if($days_diff == 0){ $current_due += $total_due; } elseif ($days_diff > 0 && $days_diff <= 30) { $due_1_30_days += $total_due; } elseif ($days_diff > 30 && $days_diff <= 60) { $due_30_60_days += $total_due; } elseif ($days_diff > 60 && $days_diff <= 90) { $due_60_90_days += $total_due; } elseif ($days_diff > 90) { $due_over_90_days += $total_due; } } $actual_rows++; @endphp @endforeach {{-- Add empty rows to make total 31 --}} @for ($i = 0; $i < $max_rows - $actual_rows; $i++) @endfor
@lang('lang_v1.date') @lang('lang_v1.transaction') @lang('sale.amount') @lang('lang_v1.balance')
{{ \Carbon\Carbon::parse($data['date'])->format('d/m/y') }} @if(!empty($data['transaction_type']) && $data['transaction_type'] == 'ledger_discount') Credit Note @endif INV #{{$data['ref_no']}} {{-- Only show due/orig amount if not ledger_discount --}} @if(!empty($data['due_date']) && $data['payment_status'] != 'paid' && $data['transaction_type'] != 'ledger_discount') @lang('lang_v1.due') {{@format_date($data['due_date'])}}. Orig. Amount @format_currency($data['final_total']) @endif @format_currency($data['final_total']) @php // Default display_due $display_due = $data['total_due']; // If ledger_discount, always show 0 if (!empty($data['transaction_type']) && $data['transaction_type'] == 'ledger_discount') { $display_due = 0; } // Format negative values as 0 if ($display_due < 0) { $display_due = 0; } // Format number with commas and 2 decimal places $formatted_due = number_format($display_due, 2, '.', ','); // Get currency symbol from business settings if available $currency_symbol = !empty($contact->business->currency_symbol) ? $contact->business->currency_symbol : 'KSh'; @endphp {{ $currency_symbol }} {{ $formatted_due }}