estimate container shipping cost

This commit is contained in:
Omair Saleh
2022-12-01 18:35:24 +08:00
parent c9d2041653
commit 53b4af2b5c
+21 -20
View File
@@ -492,26 +492,6 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
->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;
$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>';
$packing_list_drop_date = PackingList::where('reference', $packingList->reference)->where('type', 1)->first()->transports->first()->drop_date;
$order = $packingList->owner;
@@ -555,6 +535,27 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
echo 'supplier cost:'.$cost;
echo '<br><br>';
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;
$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 '<h4>Container Invoices: '.$containerBilled.'/'.$containerTotalBillable.'</h4>';