add container summary for billing report

This commit is contained in:
Omair Saleh
2022-11-07 13:16:42 +08:00
parent 945e8585d4
commit 34b4482139
+16 -1
View File
@@ -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 '<h3>'.$container->reference.' ('.$container->loading_date->format('d-m-Y').')</h3>';
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 '<span style="color: '.(($invoice->amount - $payments->sum('amount')) < 0.01 ? 'green' : 'red').'">'.$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().')').'</span>';
echo '<br>';
}
echo '<h2>Container Invoices: '.$containerBilled.'/'.$containerTotalBillable.'</h2>';
echo '<h2>Billed Total: '.$containerTotalBilled.'</h2>';
echo '<h2>Total Paid: '.$containerTotalPaid.'</h2>';
echo '<h2>Outstanding: '.($totalBilled - $containerTotalPaid).'</h2>';
echo '<br><br><br>';
}
@@ -494,5 +510,4 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
echo '<h2>Total Paid: '.$totalPaid.'</h2>';
echo '<h2>Outstanding: '.($totalBilled - $totalPaid).'</h2>';
});