update untuk paparan detail keuntungan pada arcc

This commit is contained in:
Nur Izzati
2025-07-28 15:42:56 +08:00
parent aa82301dc0
commit 66120c56eb
2 changed files with 54 additions and 5 deletions
+17 -2
View File
@@ -57,9 +57,24 @@ class TransactionController extends Controller
public function getTransactionByRujukan($norujukan){
$transaction = Transaction::on('mysql7')->where([['norujukan','=',$norujukan],['trans_type','=','A']])->get();
$transactions = Transaction::on('mysql7')
->where('norujukan', $norujukan)
->where('trans_type', 'A')
->get();
return response()->json($transaction);
foreach ($transactions as $transaction) {
$createdDate = Carbon::parse($transaction->created_at)->toDateString();
$keuntungan = \DB::connection('mysql7')
->table('transaksi_keuntungan')
->whereDate('tarikh_bayaran', $createdDate)
->where('norujukan', $transaction->norujukan)
->first(); // ambil seluruh rekod
$transaction->bayaran_keuntungan = number_format($keuntungan->bayaran_keuntungan ?? 0, 2);
$transaction->bayaran_pembiayaan = number_format($keuntungan->bayaran_pembiayaan ?? 0, 2);
}
return response()->json($transactions);
}
public function getTransactionByid($id){