summaryrefslogtreecommitdiff
path: root/includes/util/functions.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/util/functions.inc')
-rw-r--r--includes/util/functions.inc21
1 files changed, 21 insertions, 0 deletions
diff --git a/includes/util/functions.inc b/includes/util/functions.inc
index 3d84bb7..3bc8091 100644
--- a/includes/util/functions.inc
+++ b/includes/util/functions.inc
@@ -598,4 +598,25 @@ if (!function_exists("resolveMember")) {
return $name;
}
}
+}
+
+if (!function_exists("calculateFullAmount")) {
+ function calculateFullAmount($account, $asNumber = false, $gbpOnly = false): string|float|int {
+ global $rate;
+ $total = 0;
+
+ foreach ($account["transactions"] as $transaction) {
+ $total += $transaction["amount"];
+ }
+
+ if ($asNumber) {
+ if ($gbpOnly && $account["currency"] === "eur") {
+ return $total * $rate;
+ } else {
+ return $total;
+ }
+ } else {
+ return number_format($total, 2, '.', ',');
+ }
+ }
} \ No newline at end of file