show all extra payments from customer

This commit is contained in:
edmondlang
2024-03-29 00:59:30 +08:00
parent 64400d1524
commit 0719285286
+43
View File
@@ -1253,3 +1253,46 @@ Route::get('fix-payment-status-updated-but-failed-update-invoice', function (Upd
Route::get('/payment-and-billing-2', function () {
return view('pages.paymentAndBilling2');
})->name('admin.payment-and-billing-2');
Route::get('/show-all-extra-payments', function () {
ini_set('memory_limit', '-1');
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)
->where('status', ApprovalStatus::COMPLETED)
->whereHas('transactions', function ($query) {
$query->where('type', TransactionType::PAYMENT)
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
})
->get();
echo '<table>
<tr>
<th>Transaction Type</th>
<th>Total</th>
<th>Paid</th>
<th>Customer</th>
<th>Order</th>
</tr>';
foreach ($invoices as $invoice) {
$paidAmount = $invoice->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
$packingList = $invoice->owner;
$order = $packingList->owner;
$companyModule= $order->companyModule;
$marking = $companyModule->getMarking();
if (($paidAmount <= $invoice->amount) || ($paidAmount - $invoice->amount < 0.01)) {
continue;
}
echo '<tr>';
echo '<td>' . $invoice->type . '</td>';
echo '<td>' . $invoice->amount . '</td>';
echo '<td>' . $paidAmount . '</td>';
echo '<td><a href="'.route('customer.profile', $marking).'" target="_blank">'.$marking.'</a></td>';
echo '<td><a target="_blank" href="' . route('order.show', $order->reference) . '">' . $order->reference . ' - ' . $order->created_at . '</a><br></td>';
echo '</tr>';
}
echo '</table>';
});