diff --git a/routes/web.php b/routes/web.php index a9756baa..6638efdb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -459,8 +459,15 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){ $totalPaid = 0; foreach($containers as $container) { + $containerTotalBillable = 0; + $containerBilled = 0; + $containerTotalBilled = 0; + $containerTotalPaid = 0; + $packingLists = $container->packingLists; + $totalBillable += count($packingLists); + $containerTotalBillable += count($packingLists); echo '

'.$container->reference.' ('.$container->loading_date->format('d-m-Y').')

'; foreach ($packingLists as $packingList) { @@ -478,14 +485,23 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){ ->get(); $billed += 1; + $containerBilled += 1; + $totalBilled += $invoice->amount; + $containerTotalBilled += $invoice->amount; + $totalPaid += $payments->sum('amount'); + $containerTotalPaid += $payments->sum('amount'); echo ''.$packingList->reference.' | Amount: '.$invoice->amount.' | Paid: '.$payments->sum('amount').' | Invoice Date: '.$invoice->created_at->format('d-m-Y'). (($invoice->amount - $payments->sum('amount')) < 0.01 ? '' : '('.$invoice->created_at->diffForHumans().')').''; echo '
'; } + echo '

Container Invoices: '.$containerBilled.'/'.$containerTotalBillable.'

'; + echo '

Billed Total: '.$containerTotalBilled.'

'; + echo '

Total Paid: '.$containerTotalPaid.'

'; + echo '

Outstanding: '.($totalBilled - $containerTotalPaid).'

'; echo '


'; } @@ -494,5 +510,4 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){ echo '

Total Paid: '.$totalPaid.'

'; echo '

Outstanding: '.($totalBilled - $totalPaid).'

'; - });