@extends('layout') @section('page_title', 'Invoice') @section('content')

Invoice for Agreement #{{ $agreement->id }}

Back

Company Details

{{ optional(App\Models\Setting::first())->company_name ?? 'InstalmentPro' }}
{{ config('app.url') ?? request()->getHost() }}
@php($logo = optional(App\Models\Setting::first())->logo_path) @if($logo) Company Logo @endif

Bill To

{{ optional($agreement->customer)->name ?? $agreement->customer_name }}
@if($agreement->customer)
{{ $agreement->customer->phone }} {{ $agreement->customer->email ? ' • '.$agreement->customer->email : '' }}
{{ $agreement->customer->address }}
@endif

Invoice Info

Invoice #
AG-{{ str_pad($agreement->id, 5, '0', STR_PAD_LEFT) }}
Date
{{ \Illuminate\Support\Carbon::parse($agreement->created_at)->format('M d, Y') }}
Start Date
{{ $agreement->start_date }}
Status
{{ ucfirst($agreement->status) }}
@php($currency = optional(App\Models\Setting::first())->currency ?? '$')

Agreement Summary

@php($base = max($agreement->total_amount - $agreement->down_payment, 0)) @php($totalPayable = $base + ($agreement->instalment_percentage ? ($base * ($agreement->instalment_percentage/100)) : 0)) @if($agreement->instalment_percentage) @endif
Item Details Amount
{{ optional($agreement->product)->name ?? 'Product/Service' }} Total: {{ $currency }}{{ number_format($agreement->total_amount, 2) }} @if($agreement->instalment_percentage)
Instalment %: {{ $agreement->instalment_percentage }}%
@endif
Instalments: {{ $agreement->instalments_count }} × {{ $currency }}{{ number_format($agreement->instalment_amount, 2) }}
{{ $currency }}{{ number_format($agreement->total_amount, 2) }}
Down Payment {{ $currency }}{{ number_format($agreement->down_payment, 2) }}
Amount After Down Payment {{ $currency }}{{ number_format($base, 2) }}
Markup ({{ $agreement->instalment_percentage }}%) {{ $currency }}{{ number_format($totalPayable - $base, 2) }}
Total Payable {{ $currency }}{{ number_format($totalPayable, 2) }}

Payment Schedule

@foreach($agreement->payments as $p) @endforeach
# Due Date Amount Status
{{ $p->id }} {{ \Illuminate\Support\Carbon::parse($p->due_date)->format('M d, Y') }} {{ $currency }}{{ number_format($p->amount, 2) }} @if($p->status === 'paid') Paid @else Pending @endif
@endsection