multi payment final - finish top up and trsanction history

This commit is contained in:
edmondlang
2023-03-12 23:13:03 +08:00
parent eea8708b76
commit 2353c637d7
9 changed files with 117 additions and 60 deletions
+28 -1
View File
@@ -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>";
}
});