From 4fbf448597a1d14da43385e594f4a6e7f35ce71d Mon Sep 17 00:00:00 2001 From: Andrew Malsbury Date: Mon, 9 Oct 2023 22:15:27 +0000 Subject: [PATCH] Updated balance sheet to use DB types --- report_balance_sheet.php | 59 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/report_balance_sheet.php b/report_balance_sheet.php index 42b84396..6a486798 100644 --- a/report_balance_sheet.php +++ b/report_balance_sheet.php @@ -61,14 +61,14 @@ = 11 && $account_type <= 19) { - // Display assets account row - echoAccountRow($row, $balance); + $balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses']; + print_row($row, $balance, $currency_format); $total_assets += $balance; $formatted_total_assets = numfmt_format_currency($currency_format, $total_assets, $row['account_currency_code']); } + } ?> @@ -87,8 +87,8 @@ $balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses']; $account_type = $row['account_type']; if ($account_type >= 21 && $account_type <= 29) { - // Display liabilities account row - echoAccountRow($row, $balance); + $balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses']; + print_row($row, $balance, $currency_format); $total_liabilities += $balance; $formatted_total_liabilities = numfmt_format_currency($currency_format, $total_liabilities, $row['account_currency_code']); } @@ -110,8 +110,8 @@ $balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses']; $account_type = $row['account_type']; if ($account_type >= 30) { - // Display equity account row - echoAccountRow($row, $balance); + $balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses']; + print_row($row, $balance, $currency_format); $total_equity += $balance; $formatted_total_equity = numfmt_format_currency($currency_format, $total_equity, $row['account_currency_code']); } @@ -134,36 +134,35 @@ Total Liabilities and Equity + + + + Unbalanced: +
+
+ + - + "Current Assets", - 12 => "Fixed Assets", - 13 => "Other Assets", - 21 => "Current Liabilities", - 22 => "Long Term Liabilities", - 23 => "Other Liabilities", - 30 => "Equity" - ]; - $account_type_string = $account_type_strings[$accountRow['account_type']] ?? "Unknown"; - $account_name_encoded_nulled = nullable_htmlentities(urlencode($accountRow['account_name'])); - $account_name_nulled = nullable_htmlentities($accountRow['account_name']); - echo " - - $account_type_string - $account_name_nulled - " . numfmt_format_currency($currency_format, $balance, $accountRow['account_currency_code']) . " - - "; +function print_row($row, $balance, $currency_format) { + $account_name = nullable_htmlentities($row['account_name']); + $formatted_balance = numfmt_format_currency($currency_format, $balance, $row['account_currency_code']); + + echo ""; + echo ""; + echo "$account_name"; + echo "$formatted_balance"; + echo ""; } + ?>