# Copyright (C) 2026 BoundWare LLC. All rights reserved.
# SnacTrac is licensed under the Apache License, Version 2.0
# See Licenses/LICENSE.txt for details.


import sqlite3


# Return total customer credit across all users.
def get_stat_credit():

    conn = sqlite3.connect("Data/Database.db")

    cur = conn.cursor()

    cur.execute("SELECT SUM(balance) FROM Users WHERE Balance > 0")

    credit = cur.fetchone()[0]

    cur.close()

    conn.close()

    if credit is not None:

        return credit

    else:

        return 0.0
