modified: blueprints/auth.py
modified: blueprints/finance.py modified: core/db.py
This commit is contained in:
@@ -104,15 +104,19 @@ def trigger_sync():
|
|||||||
try:
|
try:
|
||||||
db_file = current_app.config.get('DB_FILE', '')
|
db_file = current_app.config.get('DB_FILE', '')
|
||||||
instance_id = current_app.config.get('INSTANCE_ID', '')
|
instance_id = current_app.config.get('INSTANCE_ID', '')
|
||||||
server_url = current_app.config.get('SERVER_URL', '')
|
server_url = ''
|
||||||
|
display_name = ''
|
||||||
sync_secret = ''
|
sync_secret = ''
|
||||||
if db_file:
|
if db_file:
|
||||||
instance_file = os.path.join(os.path.dirname(db_file), 'instance.json')
|
instance_file = os.path.join(os.path.dirname(db_file), 'instance.json')
|
||||||
if os.path.exists(instance_file):
|
if os.path.exists(instance_file):
|
||||||
with open(instance_file) as f:
|
with open(instance_file) as f:
|
||||||
sync_secret = json.load(f).get('sync_secret', '')
|
cfg = json.load(f)
|
||||||
|
server_url = cfg.get('server_url', '')
|
||||||
|
display_name = cfg.get('display_name', 'Caja Principal')
|
||||||
|
sync_secret = cfg.get('sync_secret', '')
|
||||||
if server_url:
|
if server_url:
|
||||||
sm = SyncManager(db_file, instance_id, server_url, current_app.config.get('DISPLAY_NAME', ''), sync_secret)
|
sm = SyncManager(db_file, instance_id, server_url, display_name, sync_secret)
|
||||||
sm._push()
|
sm._push()
|
||||||
sm._pull()
|
sm._pull()
|
||||||
return jsonify({"status": "ok"})
|
return jsonify({"status": "ok"})
|
||||||
|
|||||||
@@ -182,15 +182,6 @@ def gastos():
|
|||||||
with get_db_connection() as conn:
|
with get_db_connection() as conn:
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
||||||
cur.execute('''
|
|
||||||
CREATE TABLE IF NOT EXISTS expenses (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
description TEXT NOT NULL,
|
|
||||||
amount INTEGER NOT NULL
|
|
||||||
)
|
|
||||||
''')
|
|
||||||
|
|
||||||
sales_total = cur.execute("SELECT SUM(total) FROM sales WHERE strftime('%Y-%m', date, 'localtime') = ?", (selected_month,)).fetchone()[0] or 0
|
sales_total = cur.execute("SELECT SUM(total) FROM sales WHERE strftime('%Y-%m', date, 'localtime') = ?", (selected_month,)).fetchone()[0] or 0
|
||||||
expenses_total = cur.execute("SELECT SUM(amount) FROM expenses WHERE strftime('%Y-%m', date, 'localtime') = ?", (selected_month,)).fetchone()[0] or 0
|
expenses_total = cur.execute("SELECT SUM(amount) FROM expenses WHERE strftime('%Y-%m', date, 'localtime') = ?", (selected_month,)).fetchone()[0] or 0
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,12 @@ def init_db(db_file):
|
|||||||
subtotal REAL,
|
subtotal REAL,
|
||||||
FOREIGN KEY(ticket_id) REFERENCES debtor_tickets(id) ON DELETE CASCADE)''')
|
FOREIGN KEY(ticket_id) REFERENCES debtor_tickets(id) ON DELETE CASCADE)''')
|
||||||
|
|
||||||
|
conn.execute('''CREATE TABLE IF NOT EXISTS expenses
|
||||||
|
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
description TEXT NOT NULL,
|
||||||
|
amount INTEGER NOT NULL)''')
|
||||||
|
|
||||||
conn.execute('''CREATE TABLE IF NOT EXISTS sync_deletions
|
conn.execute('''CREATE TABLE IF NOT EXISTS sync_deletions
|
||||||
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
entity_type TEXT NOT NULL,
|
entity_type TEXT NOT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user