mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Merge branch 'master' into ticket_notifications
This commit is contained in:
@@ -850,7 +850,7 @@ function calculateAccountBalance($mysqli, $account_id) {
|
||||
$sql_account = mysqli_query($mysqli, "SELECT * FROM accounts LEFT JOIN account_types ON accounts.account_type = account_types.account_type_id WHERE account_archived_at IS NULL AND account_id = $account_id ORDER BY account_name ASC; ");
|
||||
$row = mysqli_fetch_array($sql_account);
|
||||
$opening_balance = floatval($row['opening_balance']);
|
||||
$account_id = $row['account_id'];
|
||||
$account_id = intval($row['account_id']);
|
||||
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
@@ -873,6 +873,7 @@ function calculateAccountBalance($mysqli, $account_id) {
|
||||
return $balance;
|
||||
}
|
||||
|
||||
|
||||
function addToMailQueue($mysqli, $data) {
|
||||
$config_invoice_from_email = strval(getSettingValue($mysqli, 'config_invoice_from_email'));
|
||||
$config_invoice_from_name = strval(getSettingValue($mysqli, 'config_invoice_from_name'));
|
||||
@@ -887,4 +888,23 @@ function addToMailQueue($mysqli, $data) {
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
function calculateInvoiceBalance($mysqli, $invoice_id) {
|
||||
$sql_invoice = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql_invoice);
|
||||
$invoice_amount = floatval($row['invoice_amount']);
|
||||
$invoice_id = intval($row['invoice_id']);
|
||||
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$total_payments = floatval($row['total_payments']);
|
||||
|
||||
$balance = $invoice_amount - $total_payments;
|
||||
|
||||
if ($balance == '') {
|
||||
$balance = '0.00';
|
||||
}
|
||||
|
||||
return $balance;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user