mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
shipping sales report
This commit is contained in:
+50
-3
@@ -428,9 +428,9 @@ Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exp
|
||||
|
||||
Route::get('/delayed_container/customers', function(){
|
||||
$containers = Container::whereHas('transports', function($query){
|
||||
return $query->whereHas('Schedules', function($query){
|
||||
return $query->where('etd', '>', \Carbon\Carbon::parse('15-10-2022'));
|
||||
});
|
||||
return $query->whereHas('Schedules', function($query){
|
||||
return $query->where('etd', '>', \Carbon\Carbon::parse('15-10-2022'));
|
||||
});
|
||||
})->get();
|
||||
|
||||
$orders = $containers->map(function($container){
|
||||
@@ -448,3 +448,50 @@ Route::get('/delayed_container/customers', function(){
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
Route::get('/container/billing/{month}/{year}', function($month, $year){
|
||||
$containers = Container::whereDate('loading_date', '>=', Carbon::parse('01-'.$month.'-'.$year))->get();
|
||||
|
||||
$totalBillable = 0;
|
||||
$billed = 0;
|
||||
$totalBilled = 0;
|
||||
$totalPaid = 0;
|
||||
|
||||
foreach($containers as $container) {
|
||||
$packingLists = $container->packingLists;
|
||||
$totalBillable += count($packingLists);
|
||||
echo '<h3>'.$container->reference.'</h3>';
|
||||
|
||||
foreach ($packingLists as $packingList) {
|
||||
$invoice = $packingList->transactions()
|
||||
->where('type', \App\Classes\ValueObjects\Constants\TransactionType::SHIPPING_INVOICE)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])
|
||||
->first();
|
||||
|
||||
if(!$invoice) {
|
||||
echo '<p style="color: red">'.$packingList->reference .' Warning: no billing</p>';
|
||||
continue;
|
||||
}
|
||||
|
||||
$payments = $invoice->transactions()
|
||||
->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])
|
||||
->get();
|
||||
|
||||
$billed += 1;
|
||||
$totalBilled += $invoice->amount;
|
||||
$totalPaid += $payments->sum('amount');
|
||||
|
||||
echo $packingList->reference.' | Amount: '.$invoice->amount.' | Paid: '.$payments->sum('amount');
|
||||
|
||||
}
|
||||
|
||||
echo '<br><br><br>';
|
||||
}
|
||||
|
||||
echo '<h2>Total Invoices: '.$billed.'/'.$totalBillable.'</h2>';
|
||||
echo '<h2>Billed Total: '.$totalBilled.'</h2>';
|
||||
echo '<h2>Total Paid: '.$totalPaid.'</h2>';
|
||||
echo '<h2>Outstanding: '.($totalBilled - $totalPaid).'</h2>';
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user