@extends('layouts.app') @section('title', $commercialAccount->name . ' — Commercial Account') @section('breadcrumb') Commercial Accounts {{ $commercialAccount->name }} @endsection @section('content')
{{-- ── Header ── --}}

{{ $commercialAccount->name }}

{{ $commercialAccount->typeLabel() }}
@if($commercialAccount->notes)

{{ $commercialAccount->notes }}

@endif
@csrf @method('DELETE')
@csrf @method('PUT')
{{-- ── Tabs ── --}}
{{-- ════════════════════════════════════════════════════════════ --}} {{-- TAB: BUILDER CONTRACTS --}} {{-- ════════════════════════════════════════════════════════════ --}}
{{-- Contract Amount summary --}} @php $builderContractAmt = $commercialAccount->builderPos->where('contract_related', true)->sum('po_amount'); $builderTotalPo = $commercialAccount->builderPos->sum('po_amount'); @endphp
Contract Amount
${{ number_format($builderContractAmt, 2) }}
Auto-calculated from Contract-Related POs below
Total PO Value
${{ number_format($builderTotalPo, 2) }}
Sum of all purchase orders
{{-- ── Purchase Orders ── --}}

Purchase Orders

{{ $commercialAccount->builderPos->count() }} record{{ $commercialAccount->builderPos->count()!==1?'s':'' }}
@if($commercialAccount->builderPos->count())
@foreach($commercialAccount->builderPos as $po) @endforeach
P/O Amount P/O Number P/O Date Invoice No. Invoice Date Inv Paid Contract Related
${{ number_format($po->po_amount, 2) }} {{ $po->po_number ?? '—' }} {{ $po->po_date?->format('d/m/Y') ?? '—' }} {{ $po->invoice_no ?? '—' }} {{ $po->invoice_date?->format('d/m/Y') ?? '—' }} {{ $po->inv_paid_date?->format('d/m/Y') ?? '—' }} @if($po->contract_related) Yes @else No @endif
@csrf @method('DELETE')
@endif {{-- Add PO form --}}
@csrf
{{-- ── ETS / Purchase Order Requests ── --}}

ETS / Purchase Order Requests

{{ $commercialAccount->builderEts->count() }} record{{ $commercialAccount->builderEts->count()!==1?'s':'' }}
@if($commercialAccount->builderEts->count())
@foreach($commercialAccount->builderEts as $ets) @endforeach
Customer Rep ETS Date Request ETS Amount ETS Reference ETS Received ETS Ref No. Reg. Invoicing Comments
{{ $ets->customer_rep ?? '—' }} {{ $ets->ets_date_request?->format('d/m/Y') ?? '—' }} ${{ number_format($ets->ets_amount, 2) }} {{ $ets->ets_reference ?? '—' }} {{ $ets->ets_received_date?->format('d/m/Y') ?? '—' }} {{ $ets->ets_ref_no ?? '—' }} @if($ets->registered_for_invoicing) Yes @else @endif {{ Str::limit($ets->comments, 60) ?? '—' }}
@csrf @method('DELETE')
@endif {{-- Add ETS form --}}
@csrf
{{-- ════════════════════════════════════════════════════════════ --}} {{-- TAB: PRIVATE CONTRACTS --}} {{-- ════════════════════════════════════════════════════════════ --}}
@php $privateContractAmt = $commercialAccount->privateDetails->where('contract_related', true)->sum('amount'); $privateTotalAmt = $commercialAccount->privateDetails->sum('amount'); $totalPayments = $commercialAccount->privatePayments->sum('payment_amount'); @endphp
Contract Amount
${{ number_format($privateContractAmt, 2) }}
Auto-calculated from Contract-Related items
Total Value
${{ number_format($privateTotalAmt, 2) }}
Sum of all contract items
Payments Received
${{ number_format($totalPayments, 2) }}
Sum of payment structure
{{-- ── Contract Details ── --}}

Contract Details

{{ $commercialAccount->privateDetails->count() }} record{{ $commercialAccount->privateDetails->count()!==1?'s':'' }}
@if($commercialAccount->privateDetails->count())
@foreach($commercialAccount->privateDetails as $detail) @endforeach
Type Reference Date Amount Contract Related
{{ $detail->typeLabel() }} {{ $detail->contract_reference ?? '—' }} {{ $detail->contract_date?->format('d/m/Y') ?? '—' }} ${{ number_format($detail->amount, 2) }} @if($detail->contract_related) Yes @else No @endif
@csrf @method('DELETE')
Total Contract Related: ${{ number_format($privateContractAmt, 2) }}
@endif {{-- Add Private Detail form --}}
@csrf
{{-- ── Contract Payment Structure ── --}}

Contract Payment Structure

{{ $commercialAccount->privatePayments->count() }} record{{ $commercialAccount->privatePayments->count()!==1?'s':'' }}
@if($commercialAccount->privatePayments->count())
@foreach($commercialAccount->privatePayments as $pmt) @endforeach
Payment Detail Amount Invoice No. Invoice Date Invoice Paid
{{ $pmt->typeLabel() }} ${{ number_format($pmt->payment_amount, 2) }} {{ $pmt->invoice_no ?? '—' }} {{ $pmt->invoice_date?->format('d/m/Y') ?? '—' }} {{ $pmt->invoice_paid_date?->format('d/m/Y') ?? '—' }}
@csrf @method('DELETE')
Total Payments: ${{ number_format($totalPayments, 2) }}
@endif {{-- Add Payment form --}}
@csrf
@endsection