mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
multi payment final - finish top up and trsanction history
This commit is contained in:
+28
-1
@@ -959,6 +959,33 @@ Route::get('/packing-lists/delete-duplicated', function(Request $request){
|
||||
Route::get('/wallet/{marking}/details', function ($marking) {
|
||||
$connection = CompanyConnection::where('invitee_reference', $marking)->first();
|
||||
$id = $connection->invitee->id;
|
||||
return view('pages.wallet.index', ['id' => $id]);
|
||||
return view('pages.wallet.index', ['id' => $id, 'marking' => $marking]);
|
||||
})->name('wallet.details');
|
||||
|
||||
Route::get('/wallet/audit', function (Request $request) {
|
||||
$wallets = \App\Models\Wallet::all();
|
||||
|
||||
$i = 0;
|
||||
foreach ($wallets as $wallet){
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
foreach ($wallet->transactions as $transaction){
|
||||
if(!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if((int) $transaction->type === TransactionType::TOP_UP) {
|
||||
$topups += (float) $transaction->amount;
|
||||
}
|
||||
if((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
if((round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) == 0) AND $wallet->amount > -0.01) continue;
|
||||
|
||||
$i++;
|
||||
|
||||
echo $i.". Marking: ". $wallet->owner->connections->first()->invitee_reference ."(".$wallet->id.")<br>Current Balance: ". $wallet->amount ."<br>Audit Balance: ". (($topups + $credit) - ($payments + $debit)) ."<br>Difference: ". round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) ."<br><br><br>";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user