diff --git a/add_expense_copy_modal.php b/add_expense_copy_modal.php index c37502f2..1b1bfa41 100644 --- a/add_expense_copy_modal.php +++ b/add_expense_copy_modal.php @@ -41,8 +41,19 @@ while($row = mysqli_fetch_array($sql2)){ $account_id2 = $row['account_id']; $account_name = $row['account_name']; + $opening_balance = $row['opening_balance']; + + $sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id2"); + $row = mysqli_fetch_array($sql_payments); + $total_payments = $row['total_payments']; + + $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id2"); + $row = mysqli_fetch_array($sql_expenses); + $total_expenses = $row['total_expenses']; + + $balance = $opening_balance + $total_payments - $total_expenses; ?> - + Description -