# 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 debt across all users.
def get_stat_debt():

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

    cur = conn.cursor()

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

    debt = cur.fetchone()[0]

    cur.close()

    conn.close()

    if debt is not None:

        return debt * -1

    else:

        return 0.0
