final-duplicated-invoice-debug

This commit is contained in:
edmondlang
2023-04-01 17:06:37 +08:00
parent 3871d8c010
commit c4642c2042
3 changed files with 126 additions and 1 deletions
+42
View File
@@ -955,3 +955,45 @@ Route::get('/packing-lists/delete-duplicated', function(Request $request){
}
}
});
Route::get('/final-duplicated-invoice-debug', function(){
$duplicatedTransactions = DB::table('transactions')
->select(DB::raw('owner_type, owner_id, receiver, type, GROUP_CONCAT(id) as transaction_ids, COUNT(*) as count'))
->groupBy('owner_type', 'owner_id', 'receiver', 'type')
->having('count', '>', 1)
->get();
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
echo '<table style="width: 100%; text-align: center; border: 1px solid black">
<tr>
<th style="border: 1px solid black" >Owner Type</th>
<th style="border: 1px solid black" >Owner Id</th>
<th style="border: 1px solid black" >Reveiver</th>
<th style="border: 1px solid black" >Transaction type</th>
<th style="border: 1px solid black" >Count</th>
<th style="border: 1px solid black" >Invoice Ids</th>
</tr>';
foreach ($duplicatedTransactions as $transaction) {
$transactionIds = explode(',', $transaction->transaction_ids);
$duplicatedInvoice = DB::table('transactions')->whereIn('id', $transactionIds)->get();
echo '<tr>';
echo '<td style="border: 1px solid black">' . $transaction->owner_type . '</td>';
echo '<td style="border: 1px solid black">' . $transaction->owner_id . '</td>';
echo '<td style="border: 1px solid black">' . $transaction->receiver . '</td>';
echo '<td style="border: 1px solid black">' . $transaction->type . '</td>';
echo '<td style="border: 1px solid black">' . count($transactionIds) . '</td>';
echo '<td style="border: 1px solid black">';
foreach ($duplicatedInvoice as $invoice) {
echo '<p>ID: ' . $invoice->id . '. Status: ' . $approvalStatusArray[$invoice->status] . '. Amount: ' . $invoice->amount . '. Is_Deleted: ' . ($invoice->deleted_at ? 'true' : 'false') . '</p>';
}
echo'</td>';
echo '</tr>';
}
echo '</table>';
});